diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 17e21f7f1..83fbd08aa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -151,7 +151,9 @@ jobs: - name: Checking OS version run: | echo "OS_NAME=$(lsb_release -si)-$(ls_release -sr)" >> $GITHUB_ENV - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 + with: + submodules: 'true' - name: Install dependencies run: | sudo apt-get install -y gfortran rpm mpich libmpich-dev libhwloc-dev @@ -167,7 +169,7 @@ jobs: key: libfabric-${{ matrix.libfabric_version }}-${{ env.OS_NAME }} - name: Checkout libfabric if: steps.cache-libfabric.outputs.cache-hit != 'true' - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: repository: ofiwg/libfabric path: repos/libfabric @@ -192,7 +194,7 @@ jobs: key: xpmem-${{ matrix.xpmem_version }}-${{ env.OS_NAME }} - name: Checkout XPMEM if: ${{ matrix.xpmem_version }} - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: repository: hjelmn/xpmem path: repos/xpmem @@ -223,7 +225,7 @@ jobs: make check TESTS= -j ${{ matrix.env_setup }} SHMEM_DEBUG=1 SHMEM_INFO=1 make VERBOSE=1 TEST_RUNNER="${SOS_PM} -np 2" check - cat test/unit/hello.log + cat modules/tests-sos/test/unit/hello.log - name: Test RPM (${{ matrix.rpm_build }}) if: ${{ matrix.rpm_build }} run: | @@ -453,7 +455,7 @@ jobs: # export PATH=${PRRTE_INSTALL_DIR}/bin:$PATH # ${{ matrix.sos_pm_pre }} # SHMEM_INFO=1 make VERBOSE=1 TEST_RUNNER="${{ matrix.sos_pm }} -np 2" check -# cat test/unit/hello.log +# cat modules/tests-sos/test/unit/hello.log # ${{ matrix.sos_pm_post }} # - name: Test SOS (hello) # if: ${{ matrix.sos_transport == 'portals4' }} @@ -462,7 +464,7 @@ jobs: # make check TESTS= -j # export PATH=${PRRTE_INSTALL_DIR}/bin:$PATH # ${{ matrix.sos_pm_pre }} -# SHMEM_INFO=1 ${{ matrix.sos_pm }} -np 1 test/unit/hello +# SHMEM_INFO=1 ${{ matrix.sos_pm }} -np 1 modules/tests-sos/test/unit/hello # ${{ matrix.sos_pm_post }} # UCX: @@ -474,8 +476,7 @@ jobs: - config_name: ucx-1.9.0 ucx_version: v1.9.0 xpmem_version: master - sos_config: [--enable-pmi-simple --disable-fortran --with-hwloc=no, - --enable-pmi-mpi CC=mpicc --disable-fortran, + sos_config: [--enable-pmi-simple --disable-fortran, --with-cma --enable-error-checking --enable-profiling --enable-pmi-simple --disable-fortran --with-hwloc=no, --with-xpmem --enable-error-checking --enable-pmi-simple --with-hwloc=no] @@ -483,7 +484,9 @@ jobs: - name: Checking OS version run: | echo "OS_NAME=$(lsb_release -si)-$(ls_release -sr)" >> $GITHUB_ENV - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 + with: + submodules: 'true' - name: Install dependencies run: | sudo apt-get install -y gfortran mpich libmpich-dev @@ -492,7 +495,7 @@ jobs: # XPMEM - name: Checkout XPMEM - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: repository: hjelmn/xpmem path: repos/xpmem @@ -517,7 +520,7 @@ jobs: key: ucx-${{ matrix.ucx_version}}-${{ env.OS_NAME }} - name: Checkout UCX if: steps.cache-ucx.outputs.cache-hit != 'true' - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: repository: openucx/ucx path: repos/ucx @@ -545,7 +548,7 @@ jobs: cd build make check TESTS= -j SHMEM_DEBUG=1 SHMEM_INFO=1 make VERBOSE=1 TEST_RUNNER="${SOS_PM} -np 2" check - cat test/unit/hello.log + cat modules/tests-sos/test/unit/hello.log Portals4: runs-on: ubuntu-20.04 @@ -573,7 +576,9 @@ jobs: - name: Checking OS version run: | echo "OS_NAME=$(lsb_release -si)-$(ls_release -sr)" >> $GITHUB_ENV - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 + with: + submodules: 'true' - name: Install dependencies run: | sudo apt-get install -y gfortran mpich libmpich-dev libev-dev libev-libevent-dev libhwloc-dev @@ -582,7 +587,7 @@ jobs: # XPMEM - name: Checkout XPMEM - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: repository: hjelmn/xpmem path: repos/xpmem @@ -607,7 +612,7 @@ jobs: key: portals4-${{ matrix.portals4_version}}-${{ env.OS_NAME }} - name: Checkout Portals4 if: steps.cache-portals4.outputs.cache-hit != 'true' - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: repository: regrant/portals4 path: repos/portals4 @@ -634,7 +639,7 @@ jobs: run: | cd build make check TESTS= -j - ${SOS_PM} -np 1 test/unit/hello + ${SOS_PM} -np 1 modules/tests-sos/test/unit/hello XPMEM_Only: runs-on: ubuntu-20.04 @@ -650,7 +655,9 @@ jobs: - name: Checking OS version run: | echo "OS_NAME=$(lsb_release -si)-$(ls_release -sr)" >> $GITHUB_ENV - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 + with: + submodules: 'true' - name: Install dependencies run: | sudo apt-get install -y gfortran mpich libmpich-dev libev-dev libev-libevent-dev libhwloc-dev @@ -659,7 +666,7 @@ jobs: # XPMEM - name: Checkout XPMEM - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: repository: hjelmn/xpmem path: repos/xpmem @@ -688,4 +695,4 @@ jobs: cd build make check TESTS= -j SHMEM_DEBUG=1 SHMEM_INFO=1 make VERBOSE=1 TEST_RUNNER="${SOS_PM} -np 2" check - ${SOS_PM} -np 1 test/unit/hello + ${SOS_PM} -np 1 modules/tests-sos/test/unit/hello diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..7a168ce27 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "modules/tests-sos"] + path = modules/tests-sos + url = ../../openshmem-org/tests-sos.git + branch = main diff --git a/Makefile.am b/Makefile.am index 5d152d519..ec4a407fc 100644 --- a/Makefile.am +++ b/Makefile.am @@ -21,7 +21,7 @@ endif dist_doc_DATA = README NEWS LICENSE -SUBDIRS = bindings mpp pmi-simple src test +SUBDIRS = bindings mpp pmi-simple src modules if ENABLE_MANPAGES SUBDIRS += man diff --git a/autogen.sh b/autogen.sh index 87c8d9623..4235694e3 100755 --- a/autogen.sh +++ b/autogen.sh @@ -2,6 +2,33 @@ test -d ./config || mkdir ./config +tests_sos_dir=modules/tests-sos + +script_dir="$(cd "$(dirname "$0")" && pwd)" +current_dir="$(pwd)" + +# Check if the script is being run from within the root SOS source directory +if [ "$script_dir" != "$current_dir" ]; then + echo "Error: Please run ./autogen.sh from the top-level directory of SOS." + exit 1 +fi + +if [ ! -d "${tests_sos_dir}" ]; then + echo "Error: the tests-sos submodule directory ${tests_sos_dir} does not exist" + exit 1 +elif [ ! -f "${tests_sos_dir}/test/Makefile.am" ] || + [ ! -f "${tests_sos_dir}/test/apps/Makefile.am" ] || + [ ! -f "${tests_sos_dir}/test/include/Makefile.am" ] || + [ ! -f "${tests_sos_dir}/test/performance/Makefile.am" ] || + [ ! -f "${tests_sos_dir}/test/shmemx/Makefile.am" ] || + [ ! -f "${tests_sos_dir}/test/spec-example/Makefile.am" ] || + [ ! -f "${tests_sos_dir}/test/unit/Makefile.am" ]; then + echo "Error: test submodule (${tests_sos_dir}) contents are missing." + echo "Please run the following command to download the SOS tests:" + echo " git submodule update --init" + exit 1 +fi + FILES=./man/*.1 echo -n "dist_man1_MANS =" > ./man/Makefile.am for f in $FILES diff --git a/configure.ac b/configure.ac index 39197dda8..bd55391ab 100755 --- a/configure.ac +++ b/configure.ac @@ -967,15 +967,17 @@ AC_CONFIG_FILES([Makefile mpp/shmem-def.h src/Makefile src/sandia-openshmem.pc - test/Makefile - test/unit/Makefile - test/shmemx/Makefile - test/spec-example/Makefile - test/include/Makefile - test/performance/Makefile - test/performance/shmem_perf_suite/Makefile - test/performance/tests/Makefile - test/apps/Makefile]) + modules/Makefile + modules/tests-sos/Makefile + modules/tests-sos/test/Makefile + modules/tests-sos/test/unit/Makefile + modules/tests-sos/test/shmemx/Makefile + modules/tests-sos/test/spec-example/Makefile + modules/tests-sos/test/include/Makefile + modules/tests-sos/test/performance/Makefile + modules/tests-sos/test/performance/shmem_perf_suite/Makefile + modules/tests-sos/test/performance/tests/Makefile + modules/tests-sos/test/apps/Makefile]) AC_OUTPUT diff --git a/test/Makefile.am b/modules/Makefile.am similarity index 77% rename from test/Makefile.am rename to modules/Makefile.am index 24abcc3e5..08c105379 100644 --- a/test/Makefile.am +++ b/modules/Makefile.am @@ -4,11 +4,11 @@ # DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government # retains certain rights in this software. # -# Copyright (c) 2017 Intel Corporation. All rights reserved. +# Copyright (c) 2024 Intel Corporation. All rights reserved. # This software is available to you under the BSD license. # # This file is part of the Sandia OpenSHMEM software package. For license # information, see the LICENSE file in the top level directory of the # distribution. -SUBDIRS = unit shmemx performance apps spec-example include +SUBDIRS = tests-sos diff --git a/modules/tests-sos b/modules/tests-sos new file mode 160000 index 000000000..d1adb71bc --- /dev/null +++ b/modules/tests-sos @@ -0,0 +1 @@ +Subproject commit d1adb71bcf68e61ab800cefb238e4e05e3102ef9 diff --git a/sandia-openshmem.spec.in b/sandia-openshmem.spec.in index b2d84526e..77ae9e576 100644 --- a/sandia-openshmem.spec.in +++ b/sandia-openshmem.spec.in @@ -49,17 +49,17 @@ rm -f %{buildroot}%{_libdir}/*.la # FIXME: It would be better to configure with --disable-libtool-wrapper so we # can pull from the standard dirs instead of .libs install -d %{testdir}/unit -install test/unit/.libs/* %{testdir}/unit +install modules/tests-sos/test/unit/.libs/* %{testdir}/unit install -d %{testdir}/shmemx -install test/shmemx/.libs/* %{testdir}/shmemx +install modules/tests-sos/test/shmemx/.libs/* %{testdir}/shmemx install -d %{testdir}/spec-example -install test/spec-example/.libs/* %{testdir}/spec-example +install modules/tests-sos/test/spec-example/.libs/* %{testdir}/spec-example install -d %{testdir}/apps -install test/apps/.libs/* %{testdir}/apps +install modules/tests-sos/test/apps/.libs/* %{testdir}/apps install -d %{testdir}/performance/shmem_perf_suite -install test/performance/shmem_perf_suite/.libs/* %{testdir}/performance/shmem_perf_suite +install modules/tests-sos/test/performance/shmem_perf_suite/.libs/* %{testdir}/performance/shmem_perf_suite install -d %{testdir}/performance/tests -install test/performance/tests/.libs/* %{testdir}/performance/tests +install modules/tests-sos/test/performance/tests/.libs/* %{testdir}/performance/tests %clean rm -rf %{buildroot} diff --git a/scripts/docker/Dockerfile b/scripts/docker/Dockerfile index 1e7e47a7d..648ff8d8a 100644 --- a/scripts/docker/Dockerfile +++ b/scripts/docker/Dockerfile @@ -97,7 +97,7 @@ RUN make install # Build SOS WORKDIR $SOS_INSTALL -RUN git clone https://github.com/Sandia-OpenSHMEM/SOS.git +RUN git clone --recurse-submodules https://github.com/Sandia-OpenSHMEM/SOS.git WORKDIR SOS RUN ./autogen.sh # To build SOS w/ basic Libfabric diff --git a/scripts/simple-build-ofi.sh b/scripts/simple-build-ofi.sh index 1e3b451ab..7b71d99a1 100755 --- a/scripts/simple-build-ofi.sh +++ b/scripts/simple-build-ofi.sh @@ -82,7 +82,7 @@ echo ======================================================================== echo = BUILDING SANDIA OPENSHMEM echo ======================================================================== -git clone -b $SOS_VERSION --depth $CLONE_DEPTH https://github.com/Sandia-OpenSHMEM/SOS.git sos +git clone -b $SOS_VERSION --depth $CLONE_DEPTH --recurse-submodules https://github.com/Sandia-OpenSHMEM/SOS.git sos cd sos ./autogen.sh ./configure --prefix=$INSTALL_DIR --with-ofi=$INSTALL_DIR $SOS_CONFIG_OPTS diff --git a/test/apps/Makefile.am b/test/apps/Makefile.am deleted file mode 100644 index 30cbfc1c0..000000000 --- a/test/apps/Makefile.am +++ /dev/null @@ -1,58 +0,0 @@ -# -*- Makefile -*- -# -# Copyright 2011 Sandia Corporation. Under the terms of Contract -# DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government -# retains certain rights in this software. -# -# Copyright (c) 2016 Los Alamos National Security, LLC. All rights reserved. -# -# Copyright (c) 2017 Intel Corporation. All rights reserved. -# This software is available to you under the BSD license. -# -# This file is part of the Sandia OpenSHMEM software package. For license -# information, see the LICENSE file in the top level directory of the -# distribution. - -NPROCS ?= 2 -LOG_COMPILER = $(TEST_RUNNER) - -AM_LDFLAGS = $(LIBTOOL_WRAPPER_LDFLAGS) - -check_PROGRAMS = \ - binary-search \ - gups - -SHORT_TESTS = \ - binary-search \ - gups - -if HAVE_PTHREADS -check_PROGRAMS += \ - mandelbrot - -SHORT_TESTS += \ - mandelbrot -endif - -if ENABLE_LENGTHY_TESTS -TESTS = $(check_PROGRAMS) -else -TESTS = $(SHORT_TESTS) -endif - -if EXTERNAL_TESTS -bin_PROGRAMS = $(check_PROGRAMS) -AM_CPPFLAGS = -I$(top_srcdir)/test/include -LDADD = -else -AM_CPPFLAGS = -I$(top_builddir)/mpp -I$(top_srcdir)/mpp -I$(top_srcdir)/test/include -LDADD = $(top_builddir)/src/libsma.la -endif - -if USE_PMI_SIMPLE -LDADD += $(top_builddir)/pmi-simple/libpmi_simple.la -endif - -mandelbrot_LDFLAGS = $(AM_LDFLAGS) $(PTHREAD_LIBS) -mandelbrot_CFLAGS = $(PTHREAD_CFLAGS) -mandelbrot_LDADD = $(LDADD) $(PTHREAD_CFLAGS) diff --git a/test/apps/binary-search.c b/test/apps/binary-search.c deleted file mode 100644 index 825febbe7..000000000 --- a/test/apps/binary-search.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include - -#define N_PER_PE 10 - -/* N_PER_PE*N_PES sorted, distributed shared array */ -int keys[N_PER_PE]; - -static int binary_search(int key) { - int low, mid, high; - - low = 0; - high = shmem_n_pes()*N_PER_PE; - - while(low < high) { - int val; - - mid = low + (high-low)/2; - val = shmem_int_g(&keys[mid%N_PER_PE], mid/N_PER_PE); - - if(val == key) { - return mid; - } else if(val < key) { - low = mid; - } else { - high = mid; - } - } - - return -1; -} - -int main(int argc, char **argv) { - int i, errors = 0; - - shmem_init(); - - for (i = 0; i < N_PER_PE; i++) - keys[i] = N_PER_PE * shmem_my_pe() + i; - - shmem_barrier_all(); - - for (i = 0; i < N_PER_PE * shmem_n_pes(); i++) { - int j = binary_search(i); - if (j != i) { - printf("%2d: Error searching for %d. Found at index %d, expected %d\n", - shmem_my_pe(), i, j, i); - errors++; - } - } - - shmem_finalize(); - - return errors; -} diff --git a/test/apps/gups.c b/test/apps/gups.c deleted file mode 100644 index 98e8b3aa6..000000000 --- a/test/apps/gups.c +++ /dev/null @@ -1,550 +0,0 @@ -/* -*- mode: C; tab-width: 2; indent-tabs-mode: nil; -*- */ - -/* - * This code has been contributed by the DARPA HPCS program. Contact - * David Koester or Bob Lucas - * if you have questions. - * - * - * GUPS (Giga UPdates per Second) is a measurement that profiles the memory - * architecture of a system and is a measure of performance similar to MFLOPS. - * The HPCS HPCchallenge RandomAccess benchmark is intended to exercise the - * GUPS capability of a system, much like the LINPACK benchmark is intended to - * exercise the MFLOPS capability of a computer. In each case, we would - * expect these benchmarks to achieve close to the "peak" capability of the - * memory system. The extent of the similarities between RandomAccess and - * LINPACK are limited to both benchmarks attempting to calculate a peak system - * capability. - * - * GUPS is calculated by identifying the number of memory locations that can be - * randomly updated in one second, divided by 1 billion (1e9). The term "randomly" - * means that there is little relationship between one address to be updated and - * the next, except that they occur in the space of one half the total system - * memory. An update is a read-modify-write operation on a table of 64-bit words. - * An address is generated, the value at that address read from memory, modified - * by an integer operation (add, and, or, xor) with a literal value, and that - * new value is written back to memory. - * - * We are interested in knowing the GUPS performance of both entire systems and - * system subcomponents --- e.g., the GUPS rating of a distributed memory - * multiprocessor the GUPS rating of an SMP node, and the GUPS rating of a - * single processor. While there is typically a scaling of FLOPS with processor - * count, a similar phenomenon may not always occur for GUPS. - * - * Select the memory size to be the power of two such that 2^n <= 1/2 of the - * total memory. Each CPU operates on its own address stream, and the single - * table may be distributed among nodes. The distribution of memory to nodes - * is left to the implementer. A uniform data distribution may help balance - * the workload, while non-uniform data distributions may simplify the - * calculations that identify processor location by eliminating the requirement - * for integer divides. A small (less than 1%) percentage of missed updates - * are permitted. - * - * When implementing a benchmark that measures GUPS on a distributed memory - * multiprocessor system, it may be required to define constraints as to how - * far in the random address stream each node is permitted to "look ahead". - * Likewise, it may be required to define a constraint as to the number of - * update messages that can be stored before processing to permit multi-level - * parallelism for those systems that support such a paradigm. The limits on - * "look ahead" and "stored updates" are being implemented to assure that the - * benchmark meets the intent to profile memory architecture and not induce - * significant artificial data locality. For the purpose of measuring GUPS, - * we will stipulate that each thread is permitted to look ahead no more than - * 1024 random address stream samples with the same number of update messages - * stored before processing. - * - * The supplied MPI-1 code generates the input stream {A} on all processors - * and the global table has been distributed as uniformly as possible to - * balance the workload and minimize any Amdahl fraction. This code does not - * exploit "look-ahead". Addresses are sent to the appropriate processor - * where the table entry resides as soon as each address is calculated. - * Updates are performed as addresses are received. Each message is limited - * to a single 64 bit long integer containing element ai from {A}. - * Local offsets for T[ ] are extracted by the destination processor. - * - * If the number of processors is equal to a power of two, then the global - * table can be distributed equally over the processors. In addition, the - * processor number can be determined from that portion of the input stream - * that identifies the address into the global table by masking off log2(p) - * bits in the address. - * - * If the number of processors is not equal to a power of two, then the global - * table cannot be equally distributed between processors. In the MPI-1 - * implementation provided, there has been an attempt to minimize the differences - * in workloads and the largest difference in elements of T[ ] is one. The - * number of values in the input stream generated by each processor will be - * related to the number of global table entries on each processor. - * - * The MPI-1 version of RandomAccess treats the potential instance where the - * number of processors is a power of two as a special case, because of the - * significant simplifications possible because processor location and local - * offset can be determined by applying masks to the input stream values. - * The non power of two case uses an integer division to determine the processor - * location. The integer division will be more costly in terms of machine - * cycles to perform than the bit masking operations - * - * For additional information on the GUPS metric, the HPCchallenge RandomAccess - * Benchmark,and the rules to run RandomAccess or modify it to optimize - * performance -- see http://icl.cs.utk.edu/hpcc/ - * - */ - -/* Jan 2005 - * - * This code has been modified to allow local bucket sorting of updates. - * The total maximum number of updates in the local buckets of a process - * is currently defined in "RandomAccess.h" as MAX_TOTAL_PENDING_UPDATES. - * When the total maximum number of updates is reached, the process selects - * the bucket (or destination process) with the largest number of - * updates and sends out all the updates in that bucket. See buckets.c - * for details about the buckets' implementation. - * - * This code also supports posting multiple MPI receive descriptors (based - * on a contribution by David Addison). - * - * In addition, this implementation provides an option for limiting - * the execution time of the benchmark to a specified time bound - * (see time_bound.c). The time bound is currently defined in - * time_bound.h, but it should be a benchmark parameter. By default - * the benchmark will execute the recommended number of updates, - * that is, four times the global table size. - */ - -/* - * OpenSHMEM version: - * - * Copyright (c) 2011 - 2015 - * University of Houston System and UT-Battelle, LLC. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * o Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * o Neither the name of the University of Houston System, - * UT-Battelle, LLC. nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -/* - * Copyright (c) 2016 Los Alamos National Security, LLC. All rights reserved. - * - * This file is part of the Sandia OpenSHMEM software package. For license - * information, see the LICENSE file in the top level directory of the - * distribution. - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#if 0 -#include "config.h" -#endif - -/* Random number generator */ -#define POLY 0x0000000000000007UL -#define PERIOD 1317624576693539401L - -/* Define 64-bit constants */ -#define ZERO64B 0LL - -uint64_t TotalMemOpt = 8192; -uint64_t NumUpdatesOpt = 0; -double SHMEMGUPs; -double SHMEMRandomAccess_ErrorsFraction; -double SHMEMRandomAccess_time; -double SHMEMRandomAccess_CheckTime; -int Failure; - -/* Allocate main table (in global memory) */ -uint64_t *HPCC_Table; -long *HPCC_PELock; - -static uint64_t GlobalStartMyProc; - -int SHMEMRandomAccess(void); - -static double RTSEC(void) -{ - struct timeval tp; - gettimeofday (&tp, NULL); - return tp.tv_sec + tp.tv_usec/(double)1.0e6; -} - -static void print_usage(void) -{ - fprintf(stderr, "\nOptions:\n"); - fprintf(stderr, " %-20s %s\n", "-h", "display this help message"); - fprintf(stderr, " %-20s %s\n", "-m", "memory in bytes per PE"); - fprintf(stderr, " %-20s %s\n", "-n", "number of updates per PE"); - - return; -} - -static int64_t starts(uint64_t n) -{ - /* int64_t i, j; */ - int i, j; - uint64_t m2[64]; - uint64_t temp, ran; - - /* - * this loop doesn't make sense - * so commenting out. - */ -#if 0 - while (n < 0) - n += PERIOD; -#endif - while (n > PERIOD) - n -= PERIOD; - if (n == 0) - return 0x1; - - temp = 0x1; - for (i=0; i<64; i++) { - m2[i] = temp; - temp = (temp << 1) ^ ((int64_t) temp < 0 ? POLY : 0); - temp = (temp << 1) ^ ((int64_t) temp < 0 ? POLY : 0); - } - - for (i=62; i>=0; i--) - if ((n >> i) & 1) break; - - ran = 0x2; - - while (i > 0) { - temp = 0; - for (j=0; j<64; j++) - if ((ran >> j) & 1) temp ^= m2[j]; - ran = temp; - i -= 1; - if ((n >> i) & 1) - ran = (ran << 1) ^ ((int64_t) ran < 0 ? POLY : 0); - } - - return ran; -} - -static void -UpdateTable(uint64_t *Table, - uint64_t TableSize, - uint64_t MinLocalTableSize, - uint64_t Top, - int Remainder, - uint64_t niterate, - int use_lock) -{ - uint64_t iterate; - int index; - uint64_t ran, global_offset; - int remote_pe; - int global_start_at_pe; -#ifdef USE_GET_PUT - uint64_t remote_val; -#endif - - /* setup: should not really be part of this timed routine */ - ran = starts(4*GlobalStartMyProc); - - for (iterate = 0; iterate < niterate; iterate++) { - ran = (ran << 1) ^ ((int64_t) ran < ZERO64B ? POLY : ZERO64B); - global_offset = ran & (TableSize-1); - if (global_offset < Top) { - remote_pe = global_offset / (MinLocalTableSize + 1); - global_start_at_pe = (MinLocalTableSize + 1) * remote_pe; - } else { - remote_pe = (global_offset - Remainder) / MinLocalTableSize; - global_start_at_pe = MinLocalTableSize * remote_pe + Remainder; - } - index = global_offset - global_start_at_pe; - - if (use_lock) shmem_set_lock(&HPCC_PELock[remote_pe]); -#ifdef USE_GET_PUT - remote_val = (uint64_t) shmem_long_g((long *)&Table[index], remote_pe); - remote_val ^= ran; - shmem_long_p((long *)&Table[index], remote_val, remote_pe); -#else - shmem_uint64_atomic_xor(&Table[index], ran, remote_pe); -#endif - if (use_lock) shmem_clear_lock(&HPCC_PELock[remote_pe]); - } -} - -int -SHMEMRandomAccess(void) -{ - int64_t i; - uint64_t i_u; - static int64_t NumErrors, GlbNumErrors; - - int NumProcs, MyProc; - int Remainder; /* Number of processors with (LocalTableSize + 1) entries */ - uint64_t Top; /* Number of table entries in top of Table */ - uint64_t LocalTableSize; /* Local table width */ - uint64_t MinLocalTableSize; /* Integer ratio TableSize/NumProcs */ - uint64_t logTableSize, TableSize; - - double RealTime; /* Real time to update table */ - - double TotalMem; - static int sAbort, rAbort; - - uint64_t NumUpdates; /* total number of updates to table */ - uint64_t ProcNumUpdates; /* number of updates per processor */ - - FILE *outFile = NULL; - double *GUPs; - double *temp_GUPs; - - - SHMEMGUPs = -1; - GUPs = &SHMEMGUPs; - - NumProcs = shmem_n_pes(); - MyProc = shmem_my_pe(); - - if (0 == MyProc) { - outFile = stdout; - setbuf(outFile, NULL); - } - - /* - * TODO: replace this - */ - - TotalMem = TotalMemOpt; /* max single node memory */ - TotalMem *= NumProcs; /* max memory in NumProcs nodes */ - - TotalMem /= sizeof(uint64_t); - - /* calculate TableSize --- the size of update array (must be a power of 2) */ - for (TotalMem *= 0.5, logTableSize = 0, TableSize = 1; - TotalMem >= 1.0; - TotalMem *= 0.5, logTableSize++, TableSize <<= 1) - ; /* EMPTY */ - - /* - * Calculate local table size, etc. - */ - - MinLocalTableSize = TableSize / NumProcs; - - /* Number of processors with (LocalTableSize + 1) entries */ - - Remainder = TableSize - (MinLocalTableSize * NumProcs); - - /* Number of table entries in top of Table */ - Top = (MinLocalTableSize + 1) * Remainder; - /* Local table size */ - if (MyProc < Remainder) { - LocalTableSize = MinLocalTableSize + 1; - GlobalStartMyProc = ( (MinLocalTableSize + 1) * MyProc); - } else { - LocalTableSize = MinLocalTableSize; - GlobalStartMyProc = ( (MinLocalTableSize * MyProc) + Remainder ); - } - - - sAbort = 0; - /* Ensure the allocation size is symmetric */ - HPCC_Table = shmem_malloc((Remainder > 0 ? (MinLocalTableSize + 1) : LocalTableSize) - * sizeof(uint64_t)); - if (! HPCC_Table) sAbort = 1; - - HPCC_PELock = (long *) shmem_malloc(sizeof(long) * NumProcs); - if (! HPCC_PELock) sAbort = 1; - - shmem_barrier_all(); - shmem_int_sum_reduce(SHMEM_TEAM_WORLD, &rAbort, &sAbort, 1); - shmem_barrier_all(); - - if (rAbort > 0) { - if (MyProc == 0) fprintf(outFile, "Failed to allocate memory\n"); - /* check all allocations in case there are new added and their order changes */ - if (HPCC_Table) shmem_free( HPCC_Table ); - if (HPCC_PELock) shmem_free( HPCC_PELock ); - goto failed_table; - } - - for (i = 0; i < NumProcs; i++) - HPCC_PELock[i] = 0; - - /* Default number of global updates to table: 4x number of table entries */ - if (NumUpdatesOpt == 0) { - ProcNumUpdates = 4 * LocalTableSize; - NumUpdates = 4 * TableSize; - } else { - ProcNumUpdates = NumUpdatesOpt; - NumUpdates = NumUpdatesOpt * NumProcs; - } - - if (MyProc == 0) { - fprintf( outFile, "Running on %d processors\n", NumProcs); - fprintf( outFile, "Total Main table size = 2^%" PRIu64 " = %" PRIu64 " words\n", - logTableSize, TableSize ); - fprintf( outFile, "PE Main table size = (2^%" PRIu64 ")/%d = %" PRIu64 " words/PE MAX\n", - logTableSize, NumProcs, LocalTableSize); - - fprintf( outFile, "Total number of updates = %" PRIu64 "\n", NumUpdates); - } - - /* Initialize main table */ - for (i_u=0; i_u 0.01*TableSize) Failure = 1; - } - /* End verification phase */ - - shmem_free( HPCC_Table ); - shmem_free( HPCC_PELock ); - failed_table: - - if (0 == MyProc) if (outFile != stderr) fclose( outFile ); - - shmem_barrier_all(); - - return 0; -} - -int main(int argc, char **argv) -{ - int op; - - while ((op = getopt(argc, argv, "hm:n:")) != -1) { - switch (op) { - /* - * memory per PE (used for determining table size) - */ - case 'm': - TotalMemOpt = atoll(optarg); - if (TotalMemOpt <= 0) { - print_usage(); - return -1; - } - break; - - /* - * num updates/PE - */ - case 'n': - NumUpdatesOpt = atoi(optarg); - if (NumUpdatesOpt <= 0) { - print_usage(); - return -1; - } - break; - - case '?': - case 'h': - print_usage(); - return -1; - } - } - - shmem_init(); - SHMEMRandomAccess(); - shmem_finalize(); - - return 0; -} diff --git a/test/apps/mandelbrot.c b/test/apps/mandelbrot.c deleted file mode 100644 index 092227fc4..000000000 --- a/test/apps/mandelbrot.c +++ /dev/null @@ -1,520 +0,0 @@ -/* - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - * Mandelbrot set calculation using OpenSHMEM - * - * James Dinan and Mario Flajslik, "Contexts: A Mechanism for High Throughput - * Communication in OpenSHMEM." In Proc. 8th Intl. Conf. on Partitioned Global - * Address Space Programming Models (PGAS '14). DOI: 10.1145/2676870.2676872. - */ - -#define _GNU_SOURCE -#include -#include -#include -#include -#include -#include -#include - -#ifdef ENABLE_PAPI -#include -#endif - -#include -/* For systems without the PThread barrier API (e.g. MacOS) */ -#include "pthread_barrier.h" - -#ifdef ENABLE_PINNING -// Number of CPUs on the machine -#define NUM_CPUS 12 -// Pin threads to every CPU_PIN_OFFSET core. Setting this to 2 allows for -// portals progress_thread to have a dedicated core -#define CPU_PIN_OFFSET 2 -#endif - -// MAX_ITERATIONS must be less than 65536 to satisfy pgm file format -#define MAX_ITERATIONS 1000 -// This PE prints stats and gather image data at the end -#define IMAGE_PE 0 - -// Default values for width and height -int width = 2048; -int height = 2048; - -// An interesting transition point is job_points*sizeof(int) being -// smaller/bigger than max_volatile size for Portals implementation -int job_points = 128; - -int me, npes; - -// Pointer to shmalloc-ed array for image data -int *imageData; -// Counter used for work load balancing -long nextPoint = 0; -// Stats -long sumTime = 0; -long sumWorkRate = 0; - -#ifdef ENABLE_PAPI -long sumL1_ICM = 0; -long sumL2_ICM = 0; -#endif - -pthread_barrier_t fencebar; - -// Parameters set on the command-line -int use_contexts = 0; -int use_pipelining = 0; -int use_blocking = 0; - -static long getTime(void) -{ - struct timeval tv; - - gettimeofday(&tv, NULL); - return tv.tv_sec*1e6 + tv.tv_usec; -} - -static void fileDump(void) { - int i, j; - FILE *fp; - fp = fopen("mandelbrot.pgm", "w"); - - if (NULL == fp) { - perror ("File open failed!"); - exit(1); - } - - fprintf(fp,"P2\n"); - fprintf(fp,"%d %d\n", width, height); - fprintf(fp,"%d\n", MAX_ITERATIONS); - - for (j = 0; j < height; j++) { - for (i = 0; i < width; i++) { - fprintf(fp,"%d ", imageData[i + j * width]); - } - fprintf(fp,"\n"); - } - - fclose(fp); -} - -static int computeSingle(int cx, int cy) { - - int i; - double x, y, x0, y0, x2, y2; - - // cx is in range [-2.5, 1.5] (x range = 4.0) - // cy is in range [-2.0, 2.0] (y range = 4.0) - - x0 = -2.5 + cx * (4.0 / width); - y0 = -2.0 + cy * (4.0 / height); - - x = 0; - y = 0; - x2 = x*x; - y2 = y*y; - - for (i = 0; (i < MAX_ITERATIONS) && (x2 + y2 < 4); i++) { - y = 2*x*y + y0; - x = x2-y2 + x0; - x2 = x*x; - y2 = y*y; - } - return MAX_ITERATIONS - i; -} - -struct th_arg{ - int tid; - shmem_ctx_t ctx[2]; - int cpu; -}; - -static void *thread_worker(void *arg) { - int tid = ((struct th_arg*)arg)->tid; - shmem_ctx_t *ctx = ((struct th_arg*)arg)->ctx; - int i, j; - long timer; - long work_start, work_end; - int *pixels[2]; - int rr_pe = me; // next PE in round-robin scheme - int pe_pending = npes; // number of PEs with work left - int *pe_mask; // flags indicating PEs with work left - int *pe_ct_max; // max work counter value for each PE - int index = 0; // index for comm/comp overlap - long total_work = 0; // total amound of work in this thread - -#ifdef ENABLE_PAPI - // we are tracking the instruction L1/L2 misses to show why a threaded implementation - // performs better than a pure PE implementation - long long counters[4]; - int PAPI_events[] = {PAPI_L1_ICM, PAPI_L2_ICM, - PAPI_L1_ICA, PAPI_L2_ICA}; -#endif -#ifdef ENABLE_PINNING - int my_cpu = ((struct th_arg*)arg)->cpu; - pthread_t thread = pthread_self(); - cpu_set_t cpuset; -#endif - -#ifdef ENABLE_PINNING - // Pin each thread - CPU_ZERO(&cpuset); - CPU_SET(my_cpu, &cpuset); - pthread_setaffinity_np(thread, sizeof(cpu_set_t), &cpuset); -#endif - - // Malloc local (non-symmetric) buffers - pixels[0] = malloc(sizeof(int)*job_points); - pixels[1] = malloc(sizeof(int)*job_points); - pe_mask = calloc(npes, sizeof(int)); - pe_ct_max = calloc(npes, sizeof(int)); - - if (NULL == pixels[0] || NULL == pixels[1] || NULL == pe_mask || NULL == pe_ct_max) { - printf("%d, %d: Error, thread malloc failed\n", me, tid); - - if (pixels[0]) free(pixels[0]); - if (pixels[1]) free(pixels[1]); - if (pe_mask) free(pe_mask); - if (pe_ct_max) free(pe_ct_max); - - return NULL; - } - - // Initialize the PE work available flags - for (i = 0; i < npes; i++) pe_mask[i] = 1; - - // Pre-calculate max value for all remote counters - for (i = 0; i < npes; i++) { - if (i < npes-1) { - pe_ct_max[i] = (width*height / npes)*(i+1); - } - else { - pe_ct_max[i] = width*height; - } - } - - // Synchornize all thraeds on all PEs before starting work - pthread_barrier_wait(&fencebar); - if (0 == tid) shmem_barrier_all(); - pthread_barrier_wait(&fencebar); - -#ifdef ENABLE_PAPI - // Start PAPI cache miss counters - PAPI_start_counters(PAPI_events, 4); -#endif - - // Start work - timer = getTime(); - while(pe_pending) { - // Next round-robin PE - do { - rr_pe = (rr_pe + 1) % npes; - } while(!pe_mask[rr_pe]); - - work_start = shmem_ctx_long_atomic_fetch_add(ctx[index], &nextPoint, job_points, rr_pe); - work_end = work_start + job_points; - - // Check if all work at this PE has been done - if (work_start >= pe_ct_max[rr_pe]) { // No more work at this PE - pe_pending--; - pe_mask[rr_pe] = 0; - continue; - } - - if (work_end >= pe_ct_max[rr_pe]) { // This is the last bit of work on this PE - work_end = pe_ct_max[rr_pe]; - pe_pending--; - pe_mask[rr_pe] = 0; - } - - if (!use_blocking) - shmem_ctx_quiet(ctx[index]); - - // Do actual compute work - for (i = work_start, j = 0; i < work_end; i++, j++) { - pixels[index][j] = computeSingle(i%width, i/width); - } - - // Return the computed image data to the PE responsible for it - if (use_blocking) - shmem_ctx_putmem(ctx[index], &imageData[work_start], pixels[index], - (work_end-work_start)*sizeof(int), rr_pe); - else - shmem_ctx_putmem_nbi(ctx[index], &imageData[work_start], pixels[index], - (work_end-work_start)*sizeof(int), rr_pe); - - total_work += work_end - work_start; - - if (use_pipelining) - index ^= 1; - } - shmem_quiet(); - timer = getTime() - timer; - - // send stats data to IMAGE_PE - shmem_long_atomic_add(&sumTime, timer, IMAGE_PE); - shmem_long_atomic_add(&sumWorkRate, (long)(total_work / ((double)timer / 1e6) + 0.5), IMAGE_PE); - -#ifdef ENABLE_PAPI - // Read PAPI cache miss counters - PAPI_read_counters(counters, 4); - shmem_long_atomic_add(&sumL1_ICM, counters[0]*1e6/counters[2], IMAGE_PE); - shmem_long_atomic_add(&sumL2_ICM, counters[1]*1e6/counters[3], IMAGE_PE); -#endif - - free(pixels[0]); - free(pixels[1]); - free(pe_mask); - free(pe_ct_max); - - return NULL; -} - -static void printUsage(void) { - printf("USAGE: mandelbrot [options]\n"); - printf(" -t number of worker threads (def: 1)\n"); - printf(" -w width of the mandelbrot domain (def: 2048)\n"); - printf(" -h height of the mandelbrot domain (def: 2048)\n"); - printf(" -j load balancing granularity (def: 128)\n"); - printf(" -o output image mandelbrot.pgm (def: off)\n"); - printf(" -c use OpenSHMEM contexts (def: off)\n"); - printf(" -p enable pipelining (implies -c) (def: off)\n"); - printf(" -b use blocking communication (def: off)\n"); - printf(" -? prints this message\n"); -} - -int main(int argc, char** argv) { - int tl, i; - int c; - int num_threads = 1; - int out_file = 0; - pthread_t *threads; - struct th_arg *t_arg; - -#ifdef ENABLE_PINNING - int p4_cpu; - pthread_t thread = pthread_self(); - cpu_set_t cpuset; -#endif - -#ifdef ENABLE_PINNING - // Must pin the main thread here before calling PtlInit() inside shmem_init(). - // This is the way we control the pinning of Portals4 progress_thread. - // see portals4 configuration flag: --enable-progress-thread-polling - //p4_cpu = CPU_PIN_OFFSET*(getpid()%(NUM_CPUS/CPU_PIN_OFFSET)); - p4_cpu = 3; - CPU_ZERO(&cpuset); - CPU_SET(p4_cpu, &cpuset); - pthread_setaffinity_np(thread, sizeof(cpu_set_t), &cpuset); -#endif - - while ((c = getopt (argc, argv, "?copbt:w:h:j:")) != -1) { - switch(c) { - case 't': - num_threads = atoi(optarg); - break; - case 'o': - out_file = 1; - break; - case 'c': - use_contexts = 1; - break; - case 'p': - use_contexts = 1; - use_pipelining = 1; - break; - case 'b': - use_blocking = 1; - break; - case 'w': - width = atoi(optarg); - break; - case 'h': - height = atoi(optarg); - break; - case 'j': - job_points = atoi(optarg); - break; - case '?': - printUsage(); - return 0; - default: - printUsage(); - return 1; - } - } - -#ifdef ENABLE_PAPI - // Init PAPI - PAPI_library_init(PAPI_VER_CURRENT); - // This is a little sketcy since pthread_self is not guaranteed to return an integer, but it works. - if (num_threads > 1 && PAPI_thread_init(pthread_self) != PAPI_OK) { - printf("ERROR: PAPI thread init failed\n"); - return 1; - } -#endif - - // Allocate local memory (non-symmetric) - t_arg = malloc(sizeof(struct th_arg)*num_threads); - threads = malloc(sizeof(pthread_t)*num_threads); - - if (NULL == t_arg || NULL == threads) { - printf("ERROR: malloc failed\n"); - return 1; - } - - // Start SHMEM (allso calls PtlInit()) - if (num_threads > 1) { - shmem_init_thread(SHMEM_THREAD_MULTIPLE, &tl); - // If OpenSHMEM doesn't support multithreading, exit gracefully - if (SHMEM_THREAD_MULTIPLE != tl) { - printf("Warning: Exiting because threading is disabled, tested nothing\n"); - shmem_global_exit(0); - return 0; - } - } - else { - shmem_init_thread(SHMEM_THREAD_SINGLE, &tl); - } - - // Allocate symmtric memory for image data - // For shmalloc of more than 512MB, set SMA_SYMMETRIC_SIZE to increase symmetric heap size. - imageData = shmem_malloc(sizeof(int)*width*height); - if (NULL == imageData) { - printf("ERROR: shmem_malloc failed\n"); - return 1; - } - - me = shmem_my_pe(); - npes = shmem_n_pes(); - - // Divide work balancing counter between all PEs - nextPoint = (width*height / npes) * me; - - // Initalize barrier for thread synchronization inside PE - pthread_barrier_init(&fencebar, NULL, num_threads); - - shmem_barrier_all(); - - // Ready to go... - if (me == IMAGE_PE) printf("Starting benchmark on %d PEs, %d threads/PE\n", npes, num_threads); - - // Initialize worker threads - for (i = 0; i < num_threads; i++) { - int err; - t_arg[i].tid = i; - if (1 == use_contexts) { - // Attempt to create the contexts. If creation fails, fall back to - // the default context - err = shmem_ctx_create(0, &t_arg[i].ctx[0]); - if (err) t_arg[i].ctx[0] = SHMEM_CTX_DEFAULT; - - if (use_pipelining) { - err = shmem_ctx_create(0, &t_arg[i].ctx[1]); - if (err) t_arg[i].ctx[1] = SHMEM_CTX_DEFAULT; - } - else - t_arg[i].ctx[1] = t_arg[i].ctx[0]; - } - else { - t_arg[i].ctx[0] = SHMEM_CTX_DEFAULT; - t_arg[i].ctx[1] = SHMEM_CTX_DEFAULT; - } -#ifdef ENABLE_PINNING - t_arg[i].cpu = (p4_cpu+i+1)%NUM_CPUS; -#else - t_arg[i].cpu = -1; -#endif - - err = pthread_create(&threads[i], NULL, thread_worker, (void*) &t_arg[i]); - assert(0 == err); - } - - // Wait for local threads to finish work - for (i = 0; i < num_threads; i++) { - int err; - err = pthread_join(threads[i], NULL); - assert(0 == err); - } - - // Wait for all PEs to finish work - shmem_barrier_all(); - - // Collect all image data on IMAGE_PE and dump it to a file - if (1 == out_file) { - if (me != IMAGE_PE) { - if (me < npes-1) { - shmem_putmem(&imageData[(width*height / npes) * me], - &imageData[(width*height / npes) * me], - (width*height / npes)*sizeof(int), IMAGE_PE); - } - else { - shmem_putmem(&imageData[(width*height / npes) * me], - &imageData[(width*height / npes) * me], - (width*height - (width*height / npes) * me)*sizeof(int), IMAGE_PE); - } - } - shmem_barrier_all(); - if (me == IMAGE_PE) { - fileDump(); - } - } - - // Print stats - if (me == IMAGE_PE) { -#ifdef ENABLE_PAPI - printf("Average thread L1 instruction misses(%%): %f\n", (double)sumL1_ICM/(npes*num_threads)/1e4); - printf("Average thread L2 instruction misses(%%): %f\n", (double)sumL2_ICM/(npes*num_threads)/1e4); -#endif - printf("Total cumulative runtime (sec) : %f\n", (double)sumTime/1e6); - printf("Average thread work rate (points/sec) : %f\n", (double)sumWorkRate/(npes*num_threads)); - printf("Average thread work runtime (sec) : %f\n", ((double)sumTime/1e6)/(npes*num_threads)); - printf("Total work rate (points/sec) : %e\n", - width*height/(((double)sumTime/1e6)/(npes*num_threads))); - } - - // Cleanup - for (i = 0; i < num_threads; i++) { - if (t_arg[i].ctx[0] != SHMEM_CTX_DEFAULT) - shmem_ctx_destroy(t_arg[i].ctx[0]); - - if (use_pipelining) { - if (t_arg[i].ctx[1] != SHMEM_CTX_DEFAULT) - shmem_ctx_destroy(t_arg[i].ctx[1]); - } - } - - pthread_barrier_destroy(&fencebar); - shmem_free(imageData); - free(t_arg); - free(threads); - shmem_finalize(); - return 0; -} diff --git a/test/include/Makefile.am b/test/include/Makefile.am deleted file mode 100644 index db367018b..000000000 --- a/test/include/Makefile.am +++ /dev/null @@ -1,17 +0,0 @@ -# -*- Makefile -*- -# -# Copyright 2011 Sandia Corporation. Under the terms of Contract -# DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government -# retains certain rights in this software. -# -# Copyright (c) 2017 Intel Corporation. All rights reserved. -# This software is available to you under the BSD license. -# -# This file is part of the Sandia OpenSHMEM software package. For license -# information, see the LICENSE file in the top level directory of the -# distribution. - -noinst_HEADERS = \ - uthash.h \ - pthread_barrier.h \ - tests_sos/wtime.h diff --git a/test/include/pthread_barrier.h b/test/include/pthread_barrier.h deleted file mode 100644 index 6e95f4847..000000000 --- a/test/include/pthread_barrier.h +++ /dev/null @@ -1,71 +0,0 @@ -/* Apple currently doesn't provide a pthread_barrier. This file implements the - * functions needed for threaded SHMEM tests using the other parts of the - * PThread API. */ -#ifdef __APPLE__ - -#ifndef PTHREAD_BARRIER_H_ -#define PTHREAD_BARRIER_H_ - -#include -#include - -#define PTHREAD_BARRIER_SERIAL_THREAD -1 - -typedef int pthread_barrierattr_t; - -typedef struct { - int cur_count; - int count; - pthread_cond_t cond; - pthread_mutex_t mutex; -} pthread_barrier_t; - - -static int pthread_barrier_init(pthread_barrier_t *barrier, const pthread_barrierattr_t *attr, unsigned int count) { - int err; - - err = pthread_mutex_init(&barrier->mutex, 0); - if (err) return err; - err = pthread_cond_init(&barrier->cond, 0); - if (err) { - pthread_mutex_destroy(&barrier->mutex); - return err; - } - - barrier->cur_count = barrier->count = count; - - return 0; -} - - -static int pthread_barrier_destroy(pthread_barrier_t *barrier) { - pthread_cond_destroy(&barrier->cond); - pthread_mutex_destroy(&barrier->mutex); - return 0; -} - - -static int pthread_barrier_wait(pthread_barrier_t *barrier) { - int ret = 0; - - pthread_mutex_lock(&barrier->mutex); - - if (barrier->cur_count <= 0) return EINVAL; - else { - barrier->cur_count--; - - if (barrier->cur_count == 0) { - ret = PTHREAD_BARRIER_SERIAL_THREAD; - barrier->cur_count = barrier->count; - pthread_cond_broadcast(&barrier->cond); - } else { - pthread_cond_wait(&barrier->cond, &barrier->mutex); - } - } - - pthread_mutex_unlock(&barrier->mutex); - return ret; -} - -#endif /* PTHREAD_BARRIER_H_ */ -#endif /* __APPLE__ */ diff --git a/test/include/tests_sos/wtime.h b/test/include/tests_sos/wtime.h deleted file mode 100644 index e2f37ac47..000000000 --- a/test/include/tests_sos/wtime.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2023 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license. - * - * This file is part of the Sandia OpenSHMEM software package. For license - * information, see the LICENSE file in the top level directory of the - * distribution. */ - -#include - -/* This is the same implementation as shmemx_wtime() in SOS, but is provided - * for the convenience of implementations that do not define shmemx_wtime() */ -#ifndef HAVE_SHMEMX_WTIME -static inline double tests_sos_wtime(void) -{ - double wtime = 0.0; - -#ifdef HAVE_CLOCK_GETTIME - struct timespec tv; - clock_gettime(CLOCK_MONOTONIC, &tv); - wtime = tv.tv_sec; - wtime += (double)tv.tv_nsec / 1.0e9; -#else - struct timeval tv; - gettimeofday(&tv, NULL); - wtime = tv.tv_sec; - wtime += (double)tv.tv_usec / 1.0e6; -#endif - return wtime; -} -#else -static inline double tests_sos_wtime(void) -{ - return shmemx_wtime(); -} -#endif /* HAVE_SHMEMX_WTIME */ diff --git a/test/include/uthash.h b/test/include/uthash.h deleted file mode 100644 index 45d1f9fc1..000000000 --- a/test/include/uthash.h +++ /dev/null @@ -1,1074 +0,0 @@ -/* -Copyright (c) 2003-2016, Troy D. Hanson http://troydhanson.github.com/uthash/ -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef UTHASH_H -#define UTHASH_H - -#define UTHASH_VERSION 2.0.1 - -#include /* memcmp,strlen */ -#include /* ptrdiff_t */ -#include /* exit() */ - -/* These macros use decltype or the earlier __typeof GNU extension. - As decltype is only available in newer compilers (VS2010 or gcc 4.3+ - when compiling c++ source) this code uses whatever method is needed - or, for VS2008 where neither is available, uses casting workarounds. */ -#if defined(_MSC_VER) /* MS compiler */ -#if _MSC_VER >= 1600 && defined(__cplusplus) /* VS2010 or newer in C++ mode */ -#define DECLTYPE(x) (decltype(x)) -#else /* VS2008 or older (or VS2010 in C mode) */ -#define NO_DECLTYPE -#define DECLTYPE(x) -#endif -#elif defined(__BORLANDC__) || defined(__LCC__) || defined(__WATCOMC__) -#define NO_DECLTYPE -#define DECLTYPE(x) -#else /* GNU, Sun and other compilers */ -#define DECLTYPE(x) (__typeof(x)) -#endif - -#ifdef NO_DECLTYPE -#define DECLTYPE_ASSIGN(dst,src) \ -do { \ - char **_da_dst = (char**)(&(dst)); \ - *_da_dst = (char*)(src); \ -} while (0) -#else -#define DECLTYPE_ASSIGN(dst,src) \ -do { \ - (dst) = DECLTYPE(dst)(src); \ -} while (0) -#endif - -/* a number of the hash function use uint32_t which isn't defined on Pre VS2010 */ -#if defined(_WIN32) -#if defined(_MSC_VER) && _MSC_VER >= 1600 -#include -#elif defined(__WATCOMC__) || defined(__MINGW32__) || defined(__CYGWIN__) -#include -#else -typedef unsigned int uint32_t; -typedef unsigned char uint8_t; -#endif -#elif defined(__GNUC__) && !defined(__VXWORKS__) -#include -#else -typedef unsigned int uint32_t; -typedef unsigned char uint8_t; -#endif - -#ifndef uthash_fatal -#define uthash_fatal(msg) exit(-1) /* fatal error (out of memory,etc) */ -#endif -#ifndef uthash_malloc -#define uthash_malloc(sz) malloc(sz) /* malloc fcn */ -#endif -#ifndef uthash_free -#define uthash_free(ptr,sz) free(ptr) /* free fcn */ -#endif -#ifndef uthash_strlen -#define uthash_strlen(s) strlen(s) -#endif -#ifndef uthash_memcmp -#define uthash_memcmp(a,b,n) memcmp(a,b,n) -#endif - -#ifndef uthash_noexpand_fyi -#define uthash_noexpand_fyi(tbl) /* can be defined to log noexpand */ -#endif -#ifndef uthash_expand_fyi -#define uthash_expand_fyi(tbl) /* can be defined to log expands */ -#endif - -/* initial number of buckets */ -#define HASH_INITIAL_NUM_BUCKETS 32U /* initial number of buckets */ -#define HASH_INITIAL_NUM_BUCKETS_LOG2 5U /* lg2 of initial number of buckets */ -#define HASH_BKT_CAPACITY_THRESH 10U /* expand when bucket count reaches */ - -/* calculate the element whose hash handle address is hhp */ -#define ELMT_FROM_HH(tbl,hhp) ((void*)(((char*)(hhp)) - ((tbl)->hho))) -/* calculate the hash handle from element address elp */ -#define HH_FROM_ELMT(tbl,elp) ((UT_hash_handle *)(((char*)(elp)) + ((tbl)->hho))) - -#define HASH_VALUE(keyptr,keylen,hashv) \ -do { \ - HASH_FCN(keyptr, keylen, hashv); \ -} while (0) - -#define HASH_FIND_BYHASHVALUE(hh,head,keyptr,keylen,hashval,out) \ -do { \ - (out) = NULL; \ - if (head) { \ - unsigned _hf_bkt; \ - HASH_TO_BKT(hashval, (head)->hh.tbl->num_buckets, _hf_bkt); \ - if (HASH_BLOOM_TEST((head)->hh.tbl, hashval) != 0) { \ - HASH_FIND_IN_BKT((head)->hh.tbl, hh, (head)->hh.tbl->buckets[ _hf_bkt ], keyptr, keylen, hashval, out); \ - } \ - } \ -} while (0) - -#define HASH_FIND(hh,head,keyptr,keylen,out) \ -do { \ - unsigned _hf_hashv; \ - HASH_VALUE(keyptr, keylen, _hf_hashv); \ - HASH_FIND_BYHASHVALUE(hh, head, keyptr, keylen, _hf_hashv, out); \ -} while (0) - -#ifdef HASH_BLOOM -#define HASH_BLOOM_BITLEN (1UL << HASH_BLOOM) -#define HASH_BLOOM_BYTELEN (HASH_BLOOM_BITLEN/8UL) + (((HASH_BLOOM_BITLEN%8UL)!=0UL) ? 1UL : 0UL) -#define HASH_BLOOM_MAKE(tbl) \ -do { \ - (tbl)->bloom_nbits = HASH_BLOOM; \ - (tbl)->bloom_bv = (uint8_t*)uthash_malloc(HASH_BLOOM_BYTELEN); \ - if (!((tbl)->bloom_bv)) { uthash_fatal( "out of memory"); } \ - memset((tbl)->bloom_bv, 0, HASH_BLOOM_BYTELEN); \ - (tbl)->bloom_sig = HASH_BLOOM_SIGNATURE; \ -} while (0) - -#define HASH_BLOOM_FREE(tbl) \ -do { \ - uthash_free((tbl)->bloom_bv, HASH_BLOOM_BYTELEN); \ -} while (0) - -#define HASH_BLOOM_BITSET(bv,idx) (bv[(idx)/8U] |= (1U << ((idx)%8U))) -#define HASH_BLOOM_BITTEST(bv,idx) (bv[(idx)/8U] & (1U << ((idx)%8U))) - -#define HASH_BLOOM_ADD(tbl,hashv) \ - HASH_BLOOM_BITSET((tbl)->bloom_bv, (hashv & (uint32_t)((1ULL << (tbl)->bloom_nbits) - 1U))) - -#define HASH_BLOOM_TEST(tbl,hashv) \ - HASH_BLOOM_BITTEST((tbl)->bloom_bv, (hashv & (uint32_t)((1ULL << (tbl)->bloom_nbits) - 1U))) - -#else -#define HASH_BLOOM_MAKE(tbl) -#define HASH_BLOOM_FREE(tbl) -#define HASH_BLOOM_ADD(tbl,hashv) -#define HASH_BLOOM_TEST(tbl,hashv) (1) -#define HASH_BLOOM_BYTELEN 0U -#endif - -#define HASH_MAKE_TABLE(hh,head) \ -do { \ - (head)->hh.tbl = (UT_hash_table*)uthash_malloc( \ - sizeof(UT_hash_table)); \ - if (!((head)->hh.tbl)) { uthash_fatal( "out of memory"); } \ - memset((head)->hh.tbl, 0, sizeof(UT_hash_table)); \ - (head)->hh.tbl->tail = &((head)->hh); \ - (head)->hh.tbl->num_buckets = HASH_INITIAL_NUM_BUCKETS; \ - (head)->hh.tbl->log2_num_buckets = HASH_INITIAL_NUM_BUCKETS_LOG2; \ - (head)->hh.tbl->hho = (char*)(&(head)->hh) - (char*)(head); \ - (head)->hh.tbl->buckets = (UT_hash_bucket*)uthash_malloc( \ - HASH_INITIAL_NUM_BUCKETS*sizeof(struct UT_hash_bucket)); \ - if (! (head)->hh.tbl->buckets) { uthash_fatal( "out of memory"); } \ - memset((head)->hh.tbl->buckets, 0, \ - HASH_INITIAL_NUM_BUCKETS*sizeof(struct UT_hash_bucket)); \ - HASH_BLOOM_MAKE((head)->hh.tbl); \ - (head)->hh.tbl->signature = HASH_SIGNATURE; \ -} while (0) - -#define HASH_REPLACE_BYHASHVALUE_INORDER(hh,head,fieldname,keylen_in,hashval,add,replaced,cmpfcn) \ -do { \ - (replaced) = NULL; \ - HASH_FIND_BYHASHVALUE(hh, head, &((add)->fieldname), keylen_in, hashval, replaced); \ - if (replaced) { \ - HASH_DELETE(hh, head, replaced); \ - } \ - HASH_ADD_KEYPTR_BYHASHVALUE_INORDER(hh, head, &((add)->fieldname), keylen_in, hashval, add, cmpfcn); \ -} while (0) - -#define HASH_REPLACE_BYHASHVALUE(hh,head,fieldname,keylen_in,hashval,add,replaced) \ -do { \ - (replaced) = NULL; \ - HASH_FIND_BYHASHVALUE(hh, head, &((add)->fieldname), keylen_in, hashval, replaced); \ - if (replaced) { \ - HASH_DELETE(hh, head, replaced); \ - } \ - HASH_ADD_KEYPTR_BYHASHVALUE(hh, head, &((add)->fieldname), keylen_in, hashval, add); \ -} while (0) - -#define HASH_REPLACE(hh,head,fieldname,keylen_in,add,replaced) \ -do { \ - unsigned _hr_hashv; \ - HASH_VALUE(&((add)->fieldname), keylen_in, _hr_hashv); \ - HASH_REPLACE_BYHASHVALUE(hh, head, fieldname, keylen_in, _hr_hashv, add, replaced); \ -} while (0) - -#define HASH_REPLACE_INORDER(hh,head,fieldname,keylen_in,add,replaced,cmpfcn) \ -do { \ - unsigned _hr_hashv; \ - HASH_VALUE(&((add)->fieldname), keylen_in, _hr_hashv); \ - HASH_REPLACE_BYHASHVALUE_INORDER(hh, head, fieldname, keylen_in, _hr_hashv, add, replaced, cmpfcn); \ -} while (0) - -#define HASH_APPEND_LIST(hh, head, add) \ -do { \ - (add)->hh.next = NULL; \ - (add)->hh.prev = ELMT_FROM_HH((head)->hh.tbl, (head)->hh.tbl->tail); \ - (head)->hh.tbl->tail->next = (add); \ - (head)->hh.tbl->tail = &((add)->hh); \ -} while (0) - -#define HASH_ADD_KEYPTR_BYHASHVALUE_INORDER(hh,head,keyptr,keylen_in,hashval,add,cmpfcn) \ -do { \ - unsigned _ha_bkt; \ - (add)->hh.hashv = (hashval); \ - (add)->hh.key = (char*) (keyptr); \ - (add)->hh.keylen = (unsigned) (keylen_in); \ - if (!(head)) { \ - (add)->hh.next = NULL; \ - (add)->hh.prev = NULL; \ - (head) = (add); \ - HASH_MAKE_TABLE(hh, head); \ - } else { \ - struct UT_hash_handle *_hs_iter = &(head)->hh; \ - (add)->hh.tbl = (head)->hh.tbl; \ - do { \ - if (cmpfcn(DECLTYPE(head) ELMT_FROM_HH((head)->hh.tbl, _hs_iter), add) > 0) \ - break; \ - } while ((_hs_iter = _hs_iter->next)); \ - if (_hs_iter) { \ - (add)->hh.next = _hs_iter; \ - if (((add)->hh.prev = _hs_iter->prev)) { \ - HH_FROM_ELMT((head)->hh.tbl, _hs_iter->prev)->next = (add); \ - } else { \ - (head) = (add); \ - } \ - _hs_iter->prev = (add); \ - } else { \ - HASH_APPEND_LIST(hh, head, add); \ - } \ - } \ - (head)->hh.tbl->num_items++; \ - HASH_TO_BKT(hashval, (head)->hh.tbl->num_buckets, _ha_bkt); \ - HASH_ADD_TO_BKT((head)->hh.tbl->buckets[_ha_bkt], &(add)->hh); \ - HASH_BLOOM_ADD((head)->hh.tbl, hashval); \ - HASH_EMIT_KEY(hh, head, keyptr, keylen_in); \ - HASH_FSCK(hh, head); \ -} while (0) - -#define HASH_ADD_KEYPTR_INORDER(hh,head,keyptr,keylen_in,add,cmpfcn) \ -do { \ - unsigned _hs_hashv; \ - HASH_VALUE(keyptr, keylen_in, _hs_hashv); \ - HASH_ADD_KEYPTR_BYHASHVALUE_INORDER(hh, head, keyptr, keylen_in, _hs_hashv, add, cmpfcn); \ -} while (0) - -#define HASH_ADD_BYHASHVALUE_INORDER(hh,head,fieldname,keylen_in,hashval,add,cmpfcn) \ - HASH_ADD_KEYPTR_BYHASHVALUE_INORDER(hh, head, &((add)->fieldname), keylen_in, hashval, add, cmpfcn) - -#define HASH_ADD_INORDER(hh,head,fieldname,keylen_in,add,cmpfcn) \ - HASH_ADD_KEYPTR_INORDER(hh, head, &((add)->fieldname), keylen_in, add, cmpfcn) - -#define HASH_ADD_KEYPTR_BYHASHVALUE(hh,head,keyptr,keylen_in,hashval,add) \ -do { \ - unsigned _ha_bkt; \ - (add)->hh.hashv = (hashval); \ - (add)->hh.key = (char*) (keyptr); \ - (add)->hh.keylen = (unsigned) (keylen_in); \ - if (!(head)) { \ - (add)->hh.next = NULL; \ - (add)->hh.prev = NULL; \ - (head) = (add); \ - HASH_MAKE_TABLE(hh, head); \ - } else { \ - (add)->hh.tbl = (head)->hh.tbl; \ - HASH_APPEND_LIST(hh, head, add); \ - } \ - (head)->hh.tbl->num_items++; \ - HASH_TO_BKT(hashval, (head)->hh.tbl->num_buckets, _ha_bkt); \ - HASH_ADD_TO_BKT((head)->hh.tbl->buckets[_ha_bkt], &(add)->hh); \ - HASH_BLOOM_ADD((head)->hh.tbl, hashval); \ - HASH_EMIT_KEY(hh, head, keyptr, keylen_in); \ - HASH_FSCK(hh, head); \ -} while (0) - -#define HASH_ADD_KEYPTR(hh,head,keyptr,keylen_in,add) \ -do { \ - unsigned _ha_hashv; \ - HASH_VALUE(keyptr, keylen_in, _ha_hashv); \ - HASH_ADD_KEYPTR_BYHASHVALUE(hh, head, keyptr, keylen_in, _ha_hashv, add); \ -} while (0) - -#define HASH_ADD_BYHASHVALUE(hh,head,fieldname,keylen_in,hashval,add) \ - HASH_ADD_KEYPTR_BYHASHVALUE(hh, head, &((add)->fieldname), keylen_in, hashval, add) - -#define HASH_ADD(hh,head,fieldname,keylen_in,add) \ - HASH_ADD_KEYPTR(hh, head, &((add)->fieldname), keylen_in, add) - -#define HASH_TO_BKT(hashv,num_bkts,bkt) \ -do { \ - bkt = ((hashv) & ((num_bkts) - 1U)); \ -} while (0) - -/* delete "delptr" from the hash table. - * "the usual" patch-up process for the app-order doubly-linked-list. - * The use of _hd_hh_del below deserves special explanation. - * These used to be expressed using (delptr) but that led to a bug - * if someone used the same symbol for the head and deletee, like - * HASH_DELETE(hh,users,users); - * We want that to work, but by changing the head (users) below - * we were forfeiting our ability to further refer to the deletee (users) - * in the patch-up process. Solution: use scratch space to - * copy the deletee pointer, then the latter references are via that - * scratch pointer rather than through the repointed (users) symbol. - */ -#define HASH_DELETE(hh,head,delptr) \ -do { \ - struct UT_hash_handle *_hd_hh_del; \ - if ( ((delptr)->hh.prev == NULL) && ((delptr)->hh.next == NULL) ) { \ - uthash_free((head)->hh.tbl->buckets, \ - (head)->hh.tbl->num_buckets*sizeof(struct UT_hash_bucket) ); \ - HASH_BLOOM_FREE((head)->hh.tbl); \ - uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \ - head = NULL; \ - } else { \ - unsigned _hd_bkt; \ - _hd_hh_del = &((delptr)->hh); \ - if ((delptr) == ELMT_FROM_HH((head)->hh.tbl,(head)->hh.tbl->tail)) { \ - (head)->hh.tbl->tail = \ - (UT_hash_handle*)((ptrdiff_t)((delptr)->hh.prev) + \ - (head)->hh.tbl->hho); \ - } \ - if ((delptr)->hh.prev != NULL) { \ - ((UT_hash_handle*)((ptrdiff_t)((delptr)->hh.prev) + \ - (head)->hh.tbl->hho))->next = (delptr)->hh.next; \ - } else { \ - DECLTYPE_ASSIGN(head,(delptr)->hh.next); \ - } \ - if (_hd_hh_del->next != NULL) { \ - ((UT_hash_handle*)((ptrdiff_t)_hd_hh_del->next + \ - (head)->hh.tbl->hho))->prev = \ - _hd_hh_del->prev; \ - } \ - HASH_TO_BKT( _hd_hh_del->hashv, (head)->hh.tbl->num_buckets, _hd_bkt); \ - HASH_DEL_IN_BKT(hh,(head)->hh.tbl->buckets[_hd_bkt], _hd_hh_del); \ - (head)->hh.tbl->num_items--; \ - } \ - HASH_FSCK(hh,head); \ -} while (0) - - -/* convenience forms of HASH_FIND/HASH_ADD/HASH_DEL */ -#define HASH_FIND_STR(head,findstr,out) \ - HASH_FIND(hh,head,findstr,(unsigned)uthash_strlen(findstr),out) -#define HASH_ADD_STR(head,strfield,add) \ - HASH_ADD(hh,head,strfield[0],(unsigned)uthash_strlen(add->strfield),add) -#define HASH_REPLACE_STR(head,strfield,add,replaced) \ - HASH_REPLACE(hh,head,strfield[0],(unsigned)uthash_strlen(add->strfield),add,replaced) -#define HASH_FIND_INT(head,findint,out) \ - HASH_FIND(hh,head,findint,sizeof(int),out) -#define HASH_ADD_INT(head,intfield,add) \ - HASH_ADD(hh,head,intfield,sizeof(int),add) -#define HASH_REPLACE_INT(head,intfield,add,replaced) \ - HASH_REPLACE(hh,head,intfield,sizeof(int),add,replaced) -#define HASH_FIND_PTR(head,findptr,out) \ - HASH_FIND(hh,head,findptr,sizeof(void *),out) -#define HASH_ADD_PTR(head,ptrfield,add) \ - HASH_ADD(hh,head,ptrfield,sizeof(void *),add) -#define HASH_REPLACE_PTR(head,ptrfield,add,replaced) \ - HASH_REPLACE(hh,head,ptrfield,sizeof(void *),add,replaced) -#define HASH_DEL(head,delptr) \ - HASH_DELETE(hh,head,delptr) - -/* HASH_FSCK checks hash integrity on every add/delete when HASH_DEBUG is defined. - * This is for uthash developer only; it compiles away if HASH_DEBUG isn't defined. - */ -#ifdef HASH_DEBUG -#define HASH_OOPS(...) do { fprintf(stderr,__VA_ARGS__); exit(-1); } while (0) -#define HASH_FSCK(hh,head) \ -do { \ - struct UT_hash_handle *_thh; \ - if (head) { \ - unsigned _bkt_i; \ - unsigned _count; \ - char *_prev; \ - _count = 0; \ - for( _bkt_i = 0; _bkt_i < (head)->hh.tbl->num_buckets; _bkt_i++) { \ - unsigned _bkt_count = 0; \ - _thh = (head)->hh.tbl->buckets[_bkt_i].hh_head; \ - _prev = NULL; \ - while (_thh) { \ - if (_prev != (char*)(_thh->hh_prev)) { \ - HASH_OOPS("invalid hh_prev %p, actual %p\n", \ - _thh->hh_prev, _prev ); \ - } \ - _bkt_count++; \ - _prev = (char*)(_thh); \ - _thh = _thh->hh_next; \ - } \ - _count += _bkt_count; \ - if ((head)->hh.tbl->buckets[_bkt_i].count != _bkt_count) { \ - HASH_OOPS("invalid bucket count %u, actual %u\n", \ - (head)->hh.tbl->buckets[_bkt_i].count, _bkt_count); \ - } \ - } \ - if (_count != (head)->hh.tbl->num_items) { \ - HASH_OOPS("invalid hh item count %u, actual %u\n", \ - (head)->hh.tbl->num_items, _count ); \ - } \ - /* traverse hh in app order; check next/prev integrity, count */ \ - _count = 0; \ - _prev = NULL; \ - _thh = &(head)->hh; \ - while (_thh) { \ - _count++; \ - if (_prev !=(char*)(_thh->prev)) { \ - HASH_OOPS("invalid prev %p, actual %p\n", \ - _thh->prev, _prev ); \ - } \ - _prev = (char*)ELMT_FROM_HH((head)->hh.tbl, _thh); \ - _thh = ( _thh->next ? (UT_hash_handle*)((char*)(_thh->next) + \ - (head)->hh.tbl->hho) : NULL ); \ - } \ - if (_count != (head)->hh.tbl->num_items) { \ - HASH_OOPS("invalid app item count %u, actual %u\n", \ - (head)->hh.tbl->num_items, _count ); \ - } \ - } \ -} while (0) -#else -#define HASH_FSCK(hh,head) -#endif - -/* When compiled with -DHASH_EMIT_KEYS, length-prefixed keys are emitted to - * the descriptor to which this macro is defined for tuning the hash function. - * The app can #include to get the prototype for write(2). */ -#ifdef HASH_EMIT_KEYS -#define HASH_EMIT_KEY(hh,head,keyptr,fieldlen) \ -do { \ - unsigned _klen = fieldlen; \ - write(HASH_EMIT_KEYS, &_klen, sizeof(_klen)); \ - write(HASH_EMIT_KEYS, keyptr, (unsigned long)fieldlen); \ -} while (0) -#else -#define HASH_EMIT_KEY(hh,head,keyptr,fieldlen) -#endif - -/* default to Jenkin's hash unless overridden e.g. DHASH_FUNCTION=HASH_SAX */ -#ifdef HASH_FUNCTION -#define HASH_FCN HASH_FUNCTION -#else -#define HASH_FCN HASH_JEN -#endif - -/* The Bernstein hash function, used in Perl prior to v5.6. Note (x<<5+x)=x*33. */ -#define HASH_BER(key,keylen,hashv) \ -do { \ - unsigned _hb_keylen=(unsigned)keylen; \ - const unsigned char *_hb_key=(const unsigned char*)(key); \ - (hashv) = 0; \ - while (_hb_keylen-- != 0U) { \ - (hashv) = (((hashv) << 5) + (hashv)) + *_hb_key++; \ - } \ -} while (0) - - -/* SAX/FNV/OAT/JEN hash functions are macro variants of those listed at - * http://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_hashing.aspx */ -#define HASH_SAX(key,keylen,hashv) \ -do { \ - unsigned _sx_i; \ - const unsigned char *_hs_key=(const unsigned char*)(key); \ - hashv = 0; \ - for(_sx_i=0; _sx_i < keylen; _sx_i++) { \ - hashv ^= (hashv << 5) + (hashv >> 2) + _hs_key[_sx_i]; \ - } \ -} while (0) -/* FNV-1a variation */ -#define HASH_FNV(key,keylen,hashv) \ -do { \ - unsigned _fn_i; \ - const unsigned char *_hf_key=(const unsigned char*)(key); \ - hashv = 2166136261U; \ - for(_fn_i=0; _fn_i < keylen; _fn_i++) { \ - hashv = hashv ^ _hf_key[_fn_i]; \ - hashv = hashv * 16777619U; \ - } \ -} while (0) - -#define HASH_OAT(key,keylen,hashv) \ -do { \ - unsigned _ho_i; \ - const unsigned char *_ho_key=(const unsigned char*)(key); \ - hashv = 0; \ - for(_ho_i=0; _ho_i < keylen; _ho_i++) { \ - hashv += _ho_key[_ho_i]; \ - hashv += (hashv << 10); \ - hashv ^= (hashv >> 6); \ - } \ - hashv += (hashv << 3); \ - hashv ^= (hashv >> 11); \ - hashv += (hashv << 15); \ -} while (0) - -#define HASH_JEN_MIX(a,b,c) \ -do { \ - a -= b; a -= c; a ^= ( c >> 13 ); \ - b -= c; b -= a; b ^= ( a << 8 ); \ - c -= a; c -= b; c ^= ( b >> 13 ); \ - a -= b; a -= c; a ^= ( c >> 12 ); \ - b -= c; b -= a; b ^= ( a << 16 ); \ - c -= a; c -= b; c ^= ( b >> 5 ); \ - a -= b; a -= c; a ^= ( c >> 3 ); \ - b -= c; b -= a; b ^= ( a << 10 ); \ - c -= a; c -= b; c ^= ( b >> 15 ); \ -} while (0) - -#define HASH_JEN(key,keylen,hashv) \ -do { \ - unsigned _hj_i,_hj_j,_hj_k; \ - unsigned const char *_hj_key=(unsigned const char*)(key); \ - hashv = 0xfeedbeefu; \ - _hj_i = _hj_j = 0x9e3779b9u; \ - _hj_k = (unsigned)(keylen); \ - while (_hj_k >= 12U) { \ - _hj_i += (_hj_key[0] + ( (unsigned)_hj_key[1] << 8 ) \ - + ( (unsigned)_hj_key[2] << 16 ) \ - + ( (unsigned)_hj_key[3] << 24 ) ); \ - _hj_j += (_hj_key[4] + ( (unsigned)_hj_key[5] << 8 ) \ - + ( (unsigned)_hj_key[6] << 16 ) \ - + ( (unsigned)_hj_key[7] << 24 ) ); \ - hashv += (_hj_key[8] + ( (unsigned)_hj_key[9] << 8 ) \ - + ( (unsigned)_hj_key[10] << 16 ) \ - + ( (unsigned)_hj_key[11] << 24 ) ); \ - \ - HASH_JEN_MIX(_hj_i, _hj_j, hashv); \ - \ - _hj_key += 12; \ - _hj_k -= 12U; \ - } \ - hashv += (unsigned)(keylen); \ - switch ( _hj_k ) { \ - case 11: hashv += ( (unsigned)_hj_key[10] << 24 ); /* FALLTHROUGH */ \ - case 10: hashv += ( (unsigned)_hj_key[9] << 16 ); /* FALLTHROUGH */ \ - case 9: hashv += ( (unsigned)_hj_key[8] << 8 ); /* FALLTHROUGH */ \ - case 8: _hj_j += ( (unsigned)_hj_key[7] << 24 ); /* FALLTHROUGH */ \ - case 7: _hj_j += ( (unsigned)_hj_key[6] << 16 ); /* FALLTHROUGH */ \ - case 6: _hj_j += ( (unsigned)_hj_key[5] << 8 ); /* FALLTHROUGH */ \ - case 5: _hj_j += _hj_key[4]; /* FALLTHROUGH */ \ - case 4: _hj_i += ( (unsigned)_hj_key[3] << 24 ); /* FALLTHROUGH */ \ - case 3: _hj_i += ( (unsigned)_hj_key[2] << 16 ); /* FALLTHROUGH */ \ - case 2: _hj_i += ( (unsigned)_hj_key[1] << 8 ); /* FALLTHROUGH */ \ - case 1: _hj_i += _hj_key[0]; \ - } \ - HASH_JEN_MIX(_hj_i, _hj_j, hashv); \ -} while (0) - -/* The Paul Hsieh hash function */ -#undef get16bits -#if (defined(__GNUC__) && defined(__i386__)) || defined(__WATCOMC__) \ - || defined(_MSC_VER) || defined (__BORLANDC__) || defined (__TURBOC__) -#define get16bits(d) (*((const uint16_t *) (d))) -#endif - -#if !defined (get16bits) -#define get16bits(d) ((((uint32_t)(((const uint8_t *)(d))[1])) << 8) \ - +(uint32_t)(((const uint8_t *)(d))[0]) ) -#endif -#define HASH_SFH(key,keylen,hashv) \ -do { \ - unsigned const char *_sfh_key=(unsigned const char*)(key); \ - uint32_t _sfh_tmp, _sfh_len = (uint32_t)keylen; \ - \ - unsigned _sfh_rem = _sfh_len & 3U; \ - _sfh_len >>= 2; \ - hashv = 0xcafebabeu; \ - \ - /* Main loop */ \ - for (;_sfh_len > 0U; _sfh_len--) { \ - hashv += get16bits (_sfh_key); \ - _sfh_tmp = ((uint32_t)(get16bits (_sfh_key+2)) << 11) ^ hashv; \ - hashv = (hashv << 16) ^ _sfh_tmp; \ - _sfh_key += 2U*sizeof (uint16_t); \ - hashv += hashv >> 11; \ - } \ - \ - /* Handle end cases */ \ - switch (_sfh_rem) { \ - case 3: hashv += get16bits (_sfh_key); \ - hashv ^= hashv << 16; \ - hashv ^= (uint32_t)(_sfh_key[sizeof (uint16_t)]) << 18; \ - hashv += hashv >> 11; \ - break; \ - case 2: hashv += get16bits (_sfh_key); \ - hashv ^= hashv << 11; \ - hashv += hashv >> 17; \ - break; \ - case 1: hashv += *_sfh_key; \ - hashv ^= hashv << 10; \ - hashv += hashv >> 1; \ - } \ - \ - /* Force "avalanching" of final 127 bits */ \ - hashv ^= hashv << 3; \ - hashv += hashv >> 5; \ - hashv ^= hashv << 4; \ - hashv += hashv >> 17; \ - hashv ^= hashv << 25; \ - hashv += hashv >> 6; \ -} while (0) - -#ifdef HASH_USING_NO_STRICT_ALIASING -/* The MurmurHash exploits some CPU's (x86,x86_64) tolerance for unaligned reads. - * For other types of CPU's (e.g. Sparc) an unaligned read causes a bus error. - * MurmurHash uses the faster approach only on CPU's where we know it's safe. - * - * Note the preprocessor built-in defines can be emitted using: - * - * gcc -m64 -dM -E - < /dev/null (on gcc) - * cc -## a.c (where a.c is a simple test file) (Sun Studio) - */ -#if (defined(__i386__) || defined(__x86_64__) || defined(_M_IX86)) -#define MUR_GETBLOCK(p,i) p[i] -#else /* non intel */ -#define MUR_PLUS0_ALIGNED(p) (((unsigned long)p & 3UL) == 0UL) -#define MUR_PLUS1_ALIGNED(p) (((unsigned long)p & 3UL) == 1UL) -#define MUR_PLUS2_ALIGNED(p) (((unsigned long)p & 3UL) == 2UL) -#define MUR_PLUS3_ALIGNED(p) (((unsigned long)p & 3UL) == 3UL) -#define WP(p) ((uint32_t*)((unsigned long)(p) & ~3UL)) -#if (defined(__BIG_ENDIAN__) || defined(SPARC) || defined(__ppc__) || defined(__ppc64__)) -#define MUR_THREE_ONE(p) ((((*WP(p))&0x00ffffff) << 8) | (((*(WP(p)+1))&0xff000000) >> 24)) -#define MUR_TWO_TWO(p) ((((*WP(p))&0x0000ffff) <<16) | (((*(WP(p)+1))&0xffff0000) >> 16)) -#define MUR_ONE_THREE(p) ((((*WP(p))&0x000000ff) <<24) | (((*(WP(p)+1))&0xffffff00) >> 8)) -#else /* assume little endian non-intel */ -#define MUR_THREE_ONE(p) ((((*WP(p))&0xffffff00) >> 8) | (((*(WP(p)+1))&0x000000ff) << 24)) -#define MUR_TWO_TWO(p) ((((*WP(p))&0xffff0000) >>16) | (((*(WP(p)+1))&0x0000ffff) << 16)) -#define MUR_ONE_THREE(p) ((((*WP(p))&0xff000000) >>24) | (((*(WP(p)+1))&0x00ffffff) << 8)) -#endif -#define MUR_GETBLOCK(p,i) (MUR_PLUS0_ALIGNED(p) ? ((p)[i]) : \ - (MUR_PLUS1_ALIGNED(p) ? MUR_THREE_ONE(p) : \ - (MUR_PLUS2_ALIGNED(p) ? MUR_TWO_TWO(p) : \ - MUR_ONE_THREE(p)))) -#endif -#define MUR_ROTL32(x,r) (((x) << (r)) | ((x) >> (32 - (r)))) -#define MUR_FMIX(_h) \ -do { \ - _h ^= _h >> 16; \ - _h *= 0x85ebca6bu; \ - _h ^= _h >> 13; \ - _h *= 0xc2b2ae35u; \ - _h ^= _h >> 16; \ -} while (0) - -#define HASH_MUR(key,keylen,hashv) \ -do { \ - const uint8_t *_mur_data = (const uint8_t*)(key); \ - const int _mur_nblocks = (int)(keylen) / 4; \ - uint32_t _mur_h1 = 0xf88D5353u; \ - uint32_t _mur_c1 = 0xcc9e2d51u; \ - uint32_t _mur_c2 = 0x1b873593u; \ - uint32_t _mur_k1 = 0; \ - const uint8_t *_mur_tail; \ - const uint32_t *_mur_blocks = (const uint32_t*)(_mur_data+(_mur_nblocks*4)); \ - int _mur_i; \ - for(_mur_i = -_mur_nblocks; _mur_i!=0; _mur_i++) { \ - _mur_k1 = MUR_GETBLOCK(_mur_blocks,_mur_i); \ - _mur_k1 *= _mur_c1; \ - _mur_k1 = MUR_ROTL32(_mur_k1,15); \ - _mur_k1 *= _mur_c2; \ - \ - _mur_h1 ^= _mur_k1; \ - _mur_h1 = MUR_ROTL32(_mur_h1,13); \ - _mur_h1 = (_mur_h1*5U) + 0xe6546b64u; \ - } \ - _mur_tail = (const uint8_t*)(_mur_data + (_mur_nblocks*4)); \ - _mur_k1=0; \ - switch((keylen) & 3U) { \ - case 3: _mur_k1 ^= (uint32_t)_mur_tail[2] << 16; /* FALLTHROUGH */ \ - case 2: _mur_k1 ^= (uint32_t)_mur_tail[1] << 8; /* FALLTHROUGH */ \ - case 1: _mur_k1 ^= (uint32_t)_mur_tail[0]; \ - _mur_k1 *= _mur_c1; \ - _mur_k1 = MUR_ROTL32(_mur_k1,15); \ - _mur_k1 *= _mur_c2; \ - _mur_h1 ^= _mur_k1; \ - } \ - _mur_h1 ^= (uint32_t)(keylen); \ - MUR_FMIX(_mur_h1); \ - hashv = _mur_h1; \ -} while (0) -#endif /* HASH_USING_NO_STRICT_ALIASING */ - -/* iterate over items in a known bucket to find desired item */ -#define HASH_FIND_IN_BKT(tbl,hh,head,keyptr,keylen_in,hashval,out) \ -do { \ - if ((head).hh_head != NULL) { \ - DECLTYPE_ASSIGN(out, ELMT_FROM_HH(tbl, (head).hh_head)); \ - } else { \ - (out) = NULL; \ - } \ - while ((out) != NULL) { \ - if ((out)->hh.hashv == (hashval) && (out)->hh.keylen == (keylen_in)) { \ - if (uthash_memcmp((out)->hh.key, keyptr, keylen_in) == 0) { \ - break; \ - } \ - } \ - if ((out)->hh.hh_next != NULL) { \ - DECLTYPE_ASSIGN(out, ELMT_FROM_HH(tbl, (out)->hh.hh_next)); \ - } else { \ - (out) = NULL; \ - } \ - } \ -} while (0) - -/* add an item to a bucket */ -#define HASH_ADD_TO_BKT(head,addhh) \ -do { \ - head.count++; \ - (addhh)->hh_next = head.hh_head; \ - (addhh)->hh_prev = NULL; \ - if (head.hh_head != NULL) { (head).hh_head->hh_prev = (addhh); } \ - (head).hh_head=addhh; \ - if ((head.count >= ((head.expand_mult+1U) * HASH_BKT_CAPACITY_THRESH)) \ - && ((addhh)->tbl->noexpand != 1U)) { \ - HASH_EXPAND_BUCKETS((addhh)->tbl); \ - } \ -} while (0) - -/* remove an item from a given bucket */ -#define HASH_DEL_IN_BKT(hh,head,hh_del) \ - (head).count--; \ - if ((head).hh_head == hh_del) { \ - (head).hh_head = hh_del->hh_next; \ - } \ - if (hh_del->hh_prev) { \ - hh_del->hh_prev->hh_next = hh_del->hh_next; \ - } \ - if (hh_del->hh_next) { \ - hh_del->hh_next->hh_prev = hh_del->hh_prev; \ - } - -/* Bucket expansion has the effect of doubling the number of buckets - * and redistributing the items into the new buckets. Ideally the - * items will distribute more or less evenly into the new buckets - * (the extent to which this is true is a measure of the quality of - * the hash function as it applies to the key domain). - * - * With the items distributed into more buckets, the chain length - * (item count) in each bucket is reduced. Thus by expanding buckets - * the hash keeps a bound on the chain length. This bounded chain - * length is the essence of how a hash provides constant time lookup. - * - * The calculation of tbl->ideal_chain_maxlen below deserves some - * explanation. First, keep in mind that we're calculating the ideal - * maximum chain length based on the *new* (doubled) bucket count. - * In fractions this is just n/b (n=number of items,b=new num buckets). - * Since the ideal chain length is an integer, we want to calculate - * ceil(n/b). We don't depend on floating point arithmetic in this - * hash, so to calculate ceil(n/b) with integers we could write - * - * ceil(n/b) = (n/b) + ((n%b)?1:0) - * - * and in fact a previous version of this hash did just that. - * But now we have improved things a bit by recognizing that b is - * always a power of two. We keep its base 2 log handy (call it lb), - * so now we can write this with a bit shift and logical AND: - * - * ceil(n/b) = (n>>lb) + ( (n & (b-1)) ? 1:0) - * - */ -#define HASH_EXPAND_BUCKETS(tbl) \ -do { \ - unsigned _he_bkt; \ - unsigned _he_bkt_i; \ - struct UT_hash_handle *_he_thh, *_he_hh_nxt; \ - UT_hash_bucket *_he_new_buckets, *_he_newbkt; \ - _he_new_buckets = (UT_hash_bucket*)uthash_malloc( \ - 2UL * tbl->num_buckets * sizeof(struct UT_hash_bucket)); \ - if (!_he_new_buckets) { uthash_fatal( "out of memory"); } \ - memset(_he_new_buckets, 0, \ - 2UL * tbl->num_buckets * sizeof(struct UT_hash_bucket)); \ - tbl->ideal_chain_maxlen = \ - (tbl->num_items >> (tbl->log2_num_buckets+1U)) + \ - (((tbl->num_items & ((tbl->num_buckets*2U)-1U)) != 0U) ? 1U : 0U); \ - tbl->nonideal_items = 0; \ - for(_he_bkt_i = 0; _he_bkt_i < tbl->num_buckets; _he_bkt_i++) \ - { \ - _he_thh = tbl->buckets[ _he_bkt_i ].hh_head; \ - while (_he_thh != NULL) { \ - _he_hh_nxt = _he_thh->hh_next; \ - HASH_TO_BKT( _he_thh->hashv, tbl->num_buckets*2U, _he_bkt); \ - _he_newbkt = &(_he_new_buckets[ _he_bkt ]); \ - if (++(_he_newbkt->count) > tbl->ideal_chain_maxlen) { \ - tbl->nonideal_items++; \ - _he_newbkt->expand_mult = _he_newbkt->count / \ - tbl->ideal_chain_maxlen; \ - } \ - _he_thh->hh_prev = NULL; \ - _he_thh->hh_next = _he_newbkt->hh_head; \ - if (_he_newbkt->hh_head != NULL) { _he_newbkt->hh_head->hh_prev = \ - _he_thh; } \ - _he_newbkt->hh_head = _he_thh; \ - _he_thh = _he_hh_nxt; \ - } \ - } \ - uthash_free( tbl->buckets, tbl->num_buckets*sizeof(struct UT_hash_bucket) ); \ - tbl->num_buckets *= 2U; \ - tbl->log2_num_buckets++; \ - tbl->buckets = _he_new_buckets; \ - tbl->ineff_expands = (tbl->nonideal_items > (tbl->num_items >> 1)) ? \ - (tbl->ineff_expands+1U) : 0U; \ - if (tbl->ineff_expands > 1U) { \ - tbl->noexpand=1; \ - uthash_noexpand_fyi(tbl); \ - } \ - uthash_expand_fyi(tbl); \ -} while (0) - - -/* This is an adaptation of Simon Tatham's O(n log(n)) mergesort */ -/* Note that HASH_SORT assumes the hash handle name to be hh. - * HASH_SRT was added to allow the hash handle name to be passed in. */ -#define HASH_SORT(head,cmpfcn) HASH_SRT(hh,head,cmpfcn) -#define HASH_SRT(hh,head,cmpfcn) \ -do { \ - unsigned _hs_i; \ - unsigned _hs_looping,_hs_nmerges,_hs_insize,_hs_psize,_hs_qsize; \ - struct UT_hash_handle *_hs_p, *_hs_q, *_hs_e, *_hs_list, *_hs_tail; \ - if (head != NULL) { \ - _hs_insize = 1; \ - _hs_looping = 1; \ - _hs_list = &((head)->hh); \ - while (_hs_looping != 0U) { \ - _hs_p = _hs_list; \ - _hs_list = NULL; \ - _hs_tail = NULL; \ - _hs_nmerges = 0; \ - while (_hs_p != NULL) { \ - _hs_nmerges++; \ - _hs_q = _hs_p; \ - _hs_psize = 0; \ - for ( _hs_i = 0; _hs_i < _hs_insize; _hs_i++ ) { \ - _hs_psize++; \ - _hs_q = (UT_hash_handle*)((_hs_q->next != NULL) ? \ - ((void*)((char*)(_hs_q->next) + \ - (head)->hh.tbl->hho)) : NULL); \ - if (! (_hs_q) ) { break; } \ - } \ - _hs_qsize = _hs_insize; \ - while ((_hs_psize > 0U) || ((_hs_qsize > 0U) && (_hs_q != NULL))) {\ - if (_hs_psize == 0U) { \ - _hs_e = _hs_q; \ - _hs_q = (UT_hash_handle*)((_hs_q->next != NULL) ? \ - ((void*)((char*)(_hs_q->next) + \ - (head)->hh.tbl->hho)) : NULL); \ - _hs_qsize--; \ - } else if ( (_hs_qsize == 0U) || (_hs_q == NULL) ) { \ - _hs_e = _hs_p; \ - if (_hs_p != NULL){ \ - _hs_p = (UT_hash_handle*)((_hs_p->next != NULL) ? \ - ((void*)((char*)(_hs_p->next) + \ - (head)->hh.tbl->hho)) : NULL); \ - } \ - _hs_psize--; \ - } else if (( \ - cmpfcn(DECLTYPE(head)(ELMT_FROM_HH((head)->hh.tbl,_hs_p)), \ - DECLTYPE(head)(ELMT_FROM_HH((head)->hh.tbl,_hs_q))) \ - ) <= 0) { \ - _hs_e = _hs_p; \ - if (_hs_p != NULL){ \ - _hs_p = (UT_hash_handle*)((_hs_p->next != NULL) ? \ - ((void*)((char*)(_hs_p->next) + \ - (head)->hh.tbl->hho)) : NULL); \ - } \ - _hs_psize--; \ - } else { \ - _hs_e = _hs_q; \ - _hs_q = (UT_hash_handle*)((_hs_q->next != NULL) ? \ - ((void*)((char*)(_hs_q->next) + \ - (head)->hh.tbl->hho)) : NULL); \ - _hs_qsize--; \ - } \ - if ( _hs_tail != NULL ) { \ - _hs_tail->next = ((_hs_e != NULL) ? \ - ELMT_FROM_HH((head)->hh.tbl,_hs_e) : NULL); \ - } else { \ - _hs_list = _hs_e; \ - } \ - if (_hs_e != NULL) { \ - _hs_e->prev = ((_hs_tail != NULL) ? \ - ELMT_FROM_HH((head)->hh.tbl,_hs_tail) : NULL); \ - } \ - _hs_tail = _hs_e; \ - } \ - _hs_p = _hs_q; \ - } \ - if (_hs_tail != NULL){ \ - _hs_tail->next = NULL; \ - } \ - if ( _hs_nmerges <= 1U ) { \ - _hs_looping=0; \ - (head)->hh.tbl->tail = _hs_tail; \ - DECLTYPE_ASSIGN(head,ELMT_FROM_HH((head)->hh.tbl, _hs_list)); \ - } \ - _hs_insize *= 2U; \ - } \ - HASH_FSCK(hh,head); \ - } \ -} while (0) - -/* This function selects items from one hash into another hash. - * The end result is that the selected items have dual presence - * in both hashes. There is no copy of the items made; rather - * they are added into the new hash through a secondary hash - * hash handle that must be present in the structure. */ -#define HASH_SELECT(hh_dst, dst, hh_src, src, cond) \ -do { \ - unsigned _src_bkt, _dst_bkt; \ - void *_last_elt=NULL, *_elt; \ - UT_hash_handle *_src_hh, *_dst_hh, *_last_elt_hh=NULL; \ - ptrdiff_t _dst_hho = ((char*)(&(dst)->hh_dst) - (char*)(dst)); \ - if (src != NULL) { \ - for(_src_bkt=0; _src_bkt < (src)->hh_src.tbl->num_buckets; _src_bkt++) { \ - for(_src_hh = (src)->hh_src.tbl->buckets[_src_bkt].hh_head; \ - _src_hh != NULL; \ - _src_hh = _src_hh->hh_next) { \ - _elt = ELMT_FROM_HH((src)->hh_src.tbl, _src_hh); \ - if (cond(_elt)) { \ - _dst_hh = (UT_hash_handle*)(((char*)_elt) + _dst_hho); \ - _dst_hh->key = _src_hh->key; \ - _dst_hh->keylen = _src_hh->keylen; \ - _dst_hh->hashv = _src_hh->hashv; \ - _dst_hh->prev = _last_elt; \ - _dst_hh->next = NULL; \ - if (_last_elt_hh != NULL) { _last_elt_hh->next = _elt; } \ - if (dst == NULL) { \ - DECLTYPE_ASSIGN(dst,_elt); \ - HASH_MAKE_TABLE(hh_dst,dst); \ - } else { \ - _dst_hh->tbl = (dst)->hh_dst.tbl; \ - } \ - HASH_TO_BKT(_dst_hh->hashv, _dst_hh->tbl->num_buckets, _dst_bkt); \ - HASH_ADD_TO_BKT(_dst_hh->tbl->buckets[_dst_bkt],_dst_hh); \ - (dst)->hh_dst.tbl->num_items++; \ - _last_elt = _elt; \ - _last_elt_hh = _dst_hh; \ - } \ - } \ - } \ - } \ - HASH_FSCK(hh_dst,dst); \ -} while (0) - -#define HASH_CLEAR(hh,head) \ -do { \ - if (head != NULL) { \ - uthash_free((head)->hh.tbl->buckets, \ - (head)->hh.tbl->num_buckets*sizeof(struct UT_hash_bucket)); \ - HASH_BLOOM_FREE((head)->hh.tbl); \ - uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \ - (head)=NULL; \ - } \ -} while (0) - -#define HASH_OVERHEAD(hh,head) \ - ((head != NULL) ? ( \ - (size_t)(((head)->hh.tbl->num_items * sizeof(UT_hash_handle)) + \ - ((head)->hh.tbl->num_buckets * sizeof(UT_hash_bucket)) + \ - sizeof(UT_hash_table) + \ - (HASH_BLOOM_BYTELEN))) : 0U) - -#ifdef NO_DECLTYPE -#define HASH_ITER(hh,head,el,tmp) \ -for(((el)=(head)), ((*(char**)(&(tmp)))=(char*)((head!=NULL)?(head)->hh.next:NULL)); \ - (el) != NULL; ((el)=(tmp)), ((*(char**)(&(tmp)))=(char*)((tmp!=NULL)?(tmp)->hh.next:NULL))) -#else -#define HASH_ITER(hh,head,el,tmp) \ -for(((el)=(head)), ((tmp)=DECLTYPE(el)((head!=NULL)?(head)->hh.next:NULL)); \ - (el) != NULL; ((el)=(tmp)), ((tmp)=DECLTYPE(el)((tmp!=NULL)?(tmp)->hh.next:NULL))) -#endif - -/* obtain a count of items in the hash */ -#define HASH_COUNT(head) HASH_CNT(hh,head) -#define HASH_CNT(hh,head) ((head != NULL)?((head)->hh.tbl->num_items):0U) - -typedef struct UT_hash_bucket { - struct UT_hash_handle *hh_head; - unsigned count; - - /* expand_mult is normally set to 0. In this situation, the max chain length - * threshold is enforced at its default value, HASH_BKT_CAPACITY_THRESH. (If - * the bucket's chain exceeds this length, bucket expansion is triggered). - * However, setting expand_mult to a non-zero value delays bucket expansion - * (that would be triggered by additions to this particular bucket) - * until its chain length reaches a *multiple* of HASH_BKT_CAPACITY_THRESH. - * (The multiplier is simply expand_mult+1). The whole idea of this - * multiplier is to reduce bucket expansions, since they are expensive, in - * situations where we know that a particular bucket tends to be overused. - * It is better to let its chain length grow to a longer yet-still-bounded - * value, than to do an O(n) bucket expansion too often. - */ - unsigned expand_mult; - -} UT_hash_bucket; - -/* random signature used only to find hash tables in external analysis */ -#define HASH_SIGNATURE 0xa0111fe1u -#define HASH_BLOOM_SIGNATURE 0xb12220f2u - -typedef struct UT_hash_table { - UT_hash_bucket *buckets; - unsigned num_buckets, log2_num_buckets; - unsigned num_items; - struct UT_hash_handle *tail; /* tail hh in app order, for fast append */ - ptrdiff_t hho; /* hash handle offset (byte pos of hash handle in element */ - - /* in an ideal situation (all buckets used equally), no bucket would have - * more than ceil(#items/#buckets) items. that's the ideal chain length. */ - unsigned ideal_chain_maxlen; - - /* nonideal_items is the number of items in the hash whose chain position - * exceeds the ideal chain maxlen. these items pay the penalty for an uneven - * hash distribution; reaching them in a chain traversal takes >ideal steps */ - unsigned nonideal_items; - - /* ineffective expands occur when a bucket doubling was performed, but - * afterward, more than half the items in the hash had nonideal chain - * positions. If this happens on two consecutive expansions we inhibit any - * further expansion, as it's not helping; this happens when the hash - * function isn't a good fit for the key domain. When expansion is inhibited - * the hash will still work, albeit no longer in constant time. */ - unsigned ineff_expands, noexpand; - - uint32_t signature; /* used only to find hash tables in external analysis */ -#ifdef HASH_BLOOM - uint32_t bloom_sig; /* used only to test bloom exists in external analysis */ - uint8_t *bloom_bv; - uint8_t bloom_nbits; -#endif - -} UT_hash_table; - -typedef struct UT_hash_handle { - struct UT_hash_table *tbl; - void *prev; /* prev element in app order */ - void *next; /* next element in app order */ - struct UT_hash_handle *hh_prev; /* previous hh in bucket order */ - struct UT_hash_handle *hh_next; /* next hh in bucket order */ - void *key; /* ptr to enclosing struct's key */ - unsigned keylen; /* enclosing struct's key len */ - unsigned hashv; /* result of hash-fcn(key) */ -} UT_hash_handle; - -#endif /* UTHASH_H */ diff --git a/test/performance/Makefile.am b/test/performance/Makefile.am deleted file mode 100644 index 575cfd362..000000000 --- a/test/performance/Makefile.am +++ /dev/null @@ -1,10 +0,0 @@ -# -*- Makefile -*- -# -# Copyright (c) 2017 Intel Corporation. All rights reserved. -# This software is available to you under the BSD license. -# -# This file is part of the Sandia OpenSHMEM software package. For license -# information, see the LICENSE file in the top level directory of the -# distribution. - -SUBDIRS = shmem_perf_suite tests diff --git a/test/performance/shmem_perf_suite/Makefile.am b/test/performance/shmem_perf_suite/Makefile.am deleted file mode 100644 index d99a75101..000000000 --- a/test/performance/shmem_perf_suite/Makefile.am +++ /dev/null @@ -1,113 +0,0 @@ -# -*- Makefile -*- -# -# Copyright (c) 2018 Intel Corporation. All rights reserved. -# This software is available to you under the BSD license. -# -# This file is part of the Sandia OpenSHMEM software package. For license -# information, see the LICENSE file in the top level directory of the -# distribution. - -check_PROGRAMS = \ - shmem_latency_put_perf \ - shmem_latency_put_perf_nb \ - shmem_latency_get_perf \ - shmem_latency_get_perf_nb \ - shmem_bw_put_perf \ - shmem_bw_put_perf_nb \ - shmem_bibw_put_perf \ - shmem_bibw_put_perf_nb \ - shmem_bw_get_perf \ - shmem_bw_get_perf_nb \ - shmem_bibw_get_perf \ - shmem_bibw_get_perf_nb \ - shmem_bw_atomics_perf \ - shmem_bibw_atomics_perf \ - shmem_bw_nb_atomics_perf \ - shmem_bibw_nb_atomics_perf - -if HAVE_OPENMP -check_PROGRAMS += \ - shmem_bw_put_ctx_perf \ - shmem_bw_put_ctx_perf_nb \ - shmem_bibw_put_ctx_perf \ - shmem_bibw_put_ctx_perf_nb \ - shmem_latency_put_ctx_perf \ - shmem_latency_put_ctx_perf_nb \ - shmem_latency_get_ctx_perf \ - shmem_latency_get_ctx_perf_nb -endif - -noinst_HEADERS = \ - common.h \ - latency_common.h \ - round_t_latency.h \ - int_element_latency.h \ - bw_common.h \ - uni_dir.h \ - uni_dir_ctx.h \ - bi_dir.h \ - bi_dir_ctx.h \ - target_put.h \ - latency_ctx.h - -if ENABLE_LENGTHY_TESTS -TESTS = $(check_PROGRAMS) -endif - -NPROCS ?= 2 -LOG_COMPILER = $(TEST_RUNNER) - -AM_LDFLAGS = $(LIBTOOL_WRAPPER_LDFLAGS) - -if EXTERNAL_TESTS -bin_PROGRAMS = $(check_PROGRAMS) -AM_CPPFLAGS = -LDADD = -else -AM_CPPFLAGS = -I$(top_builddir)/mpp -I$(top_srcdir)/mpp -LDADD = $(top_builddir)/src/libsma.la -endif - -if USE_PMI_SIMPLE -LDADD += $(top_builddir)/pmi-simple/libpmi_simple.la -endif - -shmem_latency_put_perf_nb_SOURCES = shmem_latency_put_perf.c -shmem_latency_put_perf_nb_CFLAGS = -DUSE_NONBLOCKING_API - -shmem_latency_get_perf_nb_SOURCES = shmem_latency_get_perf.c -shmem_latency_get_perf_nb_CFLAGS = -DUSE_NONBLOCKING_API - -shmem_bw_put_perf_nb_SOURCES = shmem_bw_put_perf.c -shmem_bw_put_perf_nb_CFLAGS = -DUSE_NONBLOCKING_API - -shmem_bw_get_perf_nb_SOURCES = shmem_bw_get_perf.c -shmem_bw_get_perf_nb_CFLAGS = -DUSE_NONBLOCKING_API - -shmem_bibw_put_perf_nb_SOURCES = shmem_bibw_put_perf.c -shmem_bibw_put_perf_nb_CFLAGS = -DUSE_NONBLOCKING_API - -shmem_bibw_get_perf_nb_SOURCES = shmem_bibw_get_perf.c -shmem_bibw_get_perf_nb_CFLAGS = -DUSE_NONBLOCKING_API - -shmem_bw_put_ctx_perf_CFLAGS = $(AM_OPENMP_CFLAGS) - -shmem_bw_put_ctx_perf_nb_SOURCES = shmem_bw_put_ctx_perf.c -shmem_bw_put_ctx_perf_nb_CFLAGS = $(AM_OPENMP_CFLAGS) -DUSE_NONBLOCKING_API - -shmem_bibw_put_ctx_perf_CFLAGS = $(AM_OPENMP_CFLAGS) - -shmem_bibw_put_ctx_perf_nb_SOURCES = shmem_bibw_put_ctx_perf.c -shmem_bibw_put_ctx_perf_nb_CFLAGS = $(AM_OPENMP_CFLAGS) -DUSE_NONBLOCKING_API - -shmem_latency_put_ctx_perf_CFLAGS = $(AM_OPENMP_CFLAGS) - -shmem_latency_put_ctx_perf_nb_SOURCES = shmem_latency_put_ctx_perf.c -shmem_latency_put_ctx_perf_nb_CFLAGS = $(AM_OPENMP_CFLAGS) -DUSE_NONBLOCKING_API - -shmem_latency_get_ctx_perf_CFLAGS = $(AM_OPENMP_CFLAGS) - -shmem_latency_get_ctx_perf_nb_SOURCES = shmem_latency_get_ctx_perf.c -shmem_latency_get_ctx_perf_nb_CFLAGS = $(AM_OPENMP_CFLAGS) -DUSE_NONBLOCKING_API - -AM_CPPFLAGS += -DENABLE_THREADS diff --git a/test/performance/shmem_perf_suite/README b/test/performance/shmem_perf_suite/README deleted file mode 100644 index 07abc6f79..000000000 --- a/test/performance/shmem_perf_suite/README +++ /dev/null @@ -1,87 +0,0 @@ -=============================================================================== - - User Manual: Latency and Bandwidth Performance Test Suite - -=============================================================================== -includes: - shmem_bw_put_perf - shmem_bw_get_perf - shmem_bw_atomics_perf - shmem_bw_put_ctx_perf - shmem_bibw_put_perf - shmem_bibw_get_perf - shmem_bibw_atomics_perf - shmem_bibw_put_ctx_perf - shmem_latency_put_perf - shmem_latency_get_perf - shmem_latency_nb_put_perf - shmem_latency_nb_get_perf - -Notes for Users: - - Bandwidth tests: only even set of PEs can run the tests, assumed 2-node model with - multiple processors per node: half of PE's comes from one node and - other half from partner node - - calculation parameters: runs for x numbers of iterations, over varying input - specified data size, for 64 back to back operations (window size = 64) - - bw tests: uni-direction bw tests - (half of PE set does put/get to other half) - bibw tests: bi-direction bw test - (PE pairs put to each other simultaneously but to different buffers) - - Latency tests: two-nodes only - 1) runs a single long element (shmem_long_p/g) round-trip communication - scheme for x number of iterations - 2) for x numbers of iterations, over varying input specified data size - range, latency calculation - - Input Parameters: - -e : end length (power of two) DEFAULT: 8MB - -s : start length (power of two) DEFAULT: 1B - -n : number of trials (must be greater than 20 (warmup size)) DEFAULT: 100 - -m : scale the number of trials by a floating point multiplier DEFAULT: 1.0 - -v : validate input stream used for performance data (off by default) - BW only: - -k : output in KB - -b : output in B - -T : number of threads, DEFAULT: 1 - -C : thread level (SINGLE, FUNNELED, SERIALIZED, MULTIPLE), DEFAULT: SINGLE - - Environment Variables: - SHMEM_PERF_SUITE_TRIALS_MULTIPLIER : Scale the number of trials by a floating - point multiplier. - -Notes for performance tests developers: - overall model: - development assumed that the initialization of data, calculating and printing of - output, as well as input from user is constant and reusable between put/get - performance tests. Thus header files define resuable items amongst .c - performance files. The scope of reuse (i.e. between latency or bw files) is - specified by header name, common.h being used amongst all the files. The - unique aspect to the performance files, gathering the actual timing data - from a communication pattern is implemented in each individual .c performance - file (thus they implement the header extern bw/latency function call that - plugs into the rest of the framework). - - NOTE: data is automatically initialized for latency/bw functions that are implemented - in the .c files, they are initialized with the following assumptions - assumed that the uni direction test only needs a single symmetric buffer of - max length to use for uni_dir_bw implementation, bi-direction, assumes - two unique symmetric buffers, latency one element assumes single long symmetric - element data needed, streaming latency assumes single symmetric buffer - -all buffers are initialized with my_pe, and are validating by checking that they - contain partners PE number, expect the latency one element function - must be initialized per latency implementation (in .c file) - - common.h: functions used in both latency/bw tests - latency_common.h: the init path is assumed to be reusable and static amongst tests - only the latency calculation is assumed to be unique between tests and thus - is implemented in each shmem_latency....c file - latency_common.h: the init path is assumed to be reusable and static amongst tests - only the latency timing is assumed to be unique between tests and thus - is implemented in each shmem_latency....c file - bw_common.h: the init path is assumed to be reusable and static amongst tests - only the bw timing is assumed to be unique between tests and thus - is implemented in each shmem_bw....c file diff --git a/test/performance/shmem_perf_suite/bi_dir.h b/test/performance/shmem_perf_suite/bi_dir.h deleted file mode 100644 index 97dc46901..000000000 --- a/test/performance/shmem_perf_suite/bi_dir.h +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright (c) 2018 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -static inline void bi_bw_put(int len, perf_metrics_t * const metric_info) -{ - double start = 0.0, end = 0.0; - int dest = partner_node(metric_info); - unsigned long int i = 0, j = 0; - static int check_once = 0; - static int fin = -1; - - if (!check_once) { - /* check to see whether sender and receiver are the same process */ - if (dest == metric_info->my_node) { - fprintf(stderr, "Warning: Sender and receiver are the same process (%d)\n", - dest); - } - /* hostname validation for all sender and receiver processes */ - int status = check_hostname_validation(metric_info); - if (status != 0) return; - check_once++; - } - - shmem_barrier_all(); - - for (i = 0; i < metric_info->warmup; i++) { - for(j = 0; j < metric_info->window_size; j++) { -#ifdef USE_NONBLOCKING_API - shmem_putmem_nbi(metric_info->dest, metric_info->src, len, dest); -#else - shmem_putmem(metric_info->dest, metric_info->src, len, dest); -#endif - } - shmem_quiet(); - } - - shmem_barrier_all(); - if (streaming_node(metric_info)) { - start = perf_shmemx_wtime(); - } - - for (i = 0; i < metric_info->trials; i++) { - for(j = 0; j < metric_info->window_size; j++) { -#ifdef USE_NONBLOCKING_API - shmem_putmem_nbi(metric_info->dest, metric_info->src, len, dest); -#else - shmem_putmem(metric_info->dest, metric_info->src, len, dest); -#endif - } - shmem_quiet(); - } - - if (streaming_node(metric_info)) { - shmem_int_atomic_set(&fin, 1, dest); - shmem_int_wait_until(&fin, SHMEM_CMP_EQ, 0); - end = perf_shmemx_wtime(); - calc_and_print_results(end, start, len, metric_info); - } else { - shmem_int_wait_until(&fin, SHMEM_CMP_EQ, 1); - shmem_int_atomic_set(&fin, 0, dest); - } - -} - -static inline void bi_bw_get(int len, perf_metrics_t * const metric_info) -{ - double start = 0.0, end = 0.0; - int dest = partner_node(metric_info); - unsigned long int i = 0, j = 0; - static int check_once = 0; - static int fin = -1; - - if (!check_once) { - /* check to see whether sender and receiver are the same process */ - if (dest == metric_info->my_node) { - fprintf(stderr, "Warning: Sender and receiver are the same process (%d)\n", - dest); - } - /* hostname validation for all sender and receiver processes */ - int status = check_hostname_validation(metric_info); - if (status != 0) return; - check_once++; - } - - shmem_barrier_all(); - - for (i = 0; i < metric_info->warmup; i++) { - for(j = 0; j < metric_info->window_size; j++) { - /* Choosing to skip quiet for both blocking and non-blocking getmem - * as this sequence of operation (writing to the same location) is - * currently undefined by the OpenSHMEM Spec. */ -#ifdef USE_NONBLOCKING_API - shmem_getmem_nbi(metric_info->dest, metric_info->src, len, dest); -#else - shmem_getmem(metric_info->dest, metric_info->src, len, dest); -#endif - } -#ifdef USE_NONBLOCKING_API - shmem_quiet(); -#endif - } - - shmem_barrier_all(); - if (streaming_node(metric_info)) { - start = perf_shmemx_wtime(); - } - - for (i = 0; i < metric_info->trials; i++) { - for(j = 0; j < metric_info->window_size; j++) { - /* Choosing to skip quiet for both blocking and non-blocking getmem - * as this sequence of operation (writing to the same location) is - * currently undefined by the OpenSHMEM Spec. */ -#ifdef USE_NONBLOCKING_API - shmem_getmem_nbi(metric_info->dest, metric_info->src, len, dest); -#else - shmem_getmem(metric_info->dest, metric_info->src, len, dest); -#endif - } -#ifdef USE_NONBLOCKING_API - shmem_quiet(); -#endif - } - - if (streaming_node(metric_info)) { - shmem_int_atomic_set(&fin, 1, dest); - shmem_int_wait_until(&fin, SHMEM_CMP_EQ, 0); - end = perf_shmemx_wtime(); - calc_and_print_results(end, start, len, metric_info); - } else { - shmem_int_wait_until(&fin, SHMEM_CMP_EQ, 1); - shmem_int_atomic_set(&fin, 0, dest); - } -} - diff --git a/test/performance/shmem_perf_suite/bi_dir_ctx.h b/test/performance/shmem_perf_suite/bi_dir_ctx.h deleted file mode 100644 index a2fc96acc..000000000 --- a/test/performance/shmem_perf_suite/bi_dir_ctx.h +++ /dev/null @@ -1,152 +0,0 @@ -/* -* Copyright (c) 2018 Intel Corporation. All rights reserved. -* This software is available to you under the BSD license below: -* -* Redistribution and use in source and binary forms, with or -* without modification, are permitted provided that the following -* conditions are met: -* -* - Redistributions of source code must retain the above -* copyright notice, this list of conditions and the following -* disclaimer. -* -* - Redistributions in binary form must reproduce the above -* copyright notice, this list of conditions and the following -* disclaimer in the documentation and/or other materials -* provided with the distribution. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -* SOFTWARE. -*/ - - -static inline void bi_bw_ctx (int len, perf_metrics_t *metric_info) -{ - double start = 0.0, end = 0.0; - int dest = partner_node(metric_info); - unsigned long int i, j; - static int check_once = 0; - - if (!check_once) { - /* check to see whether sender and receiver are the same process */ - if (dest == metric_info->my_node) { - fprintf(stderr, "Warning: Sender and receiver are the same " - "process (%d)\n", dest); - } - /* hostname validation for all sender and receiver processes */ - int status = check_hostname_validation(metric_info); - if (status != 0) return; - check_once++; - } - - shmem_barrier_all(); - -#pragma omp parallel default(none) firstprivate(len, dest) private(i, j) \ -shared(metric_info, start, end) num_threads(metric_info->nthreads) - { - const int thread_id = omp_get_thread_num(); - shmem_ctx_t ctx; - int err = shmem_ctx_create(SHMEM_CTX_PRIVATE, &ctx); - - if (err) { - printf("PE %d, Thr. %d: Error, context creation failed\n", - metric_info->my_node, thread_id); - /* Exit with success to avoid test failures in automated testing */ - shmem_global_exit(0); - } - - for (i = 0; i < metric_info->warmup; i++) { - for(j = 0; j < metric_info->window_size; j++) { -#ifdef USE_NONBLOCKING_API - shmem_ctx_putmem_nbi(ctx, metric_info->dest + thread_id * len, - metric_info->src + thread_id * len, len, dest); -#else - shmem_ctx_putmem(ctx, metric_info->dest + thread_id * len, - metric_info->src + thread_id * len, len, dest); -#endif - } - shmem_ctx_quiet(ctx); - } - shmem_ctx_destroy(ctx); - } - - shmem_barrier_all(); - if (streaming_node(metric_info)) { -#pragma omp parallel default(none) firstprivate(len, dest) private(i, j) \ -shared(metric_info, start, end) num_threads(metric_info->nthreads) - { - const int thread_id = omp_get_thread_num(); - shmem_ctx_t ctx; - int err = shmem_ctx_create(SHMEM_CTX_PRIVATE, &ctx); - - if (err) { - printf("PE %d, Thr. %d: Error, context creation failed\n", - metric_info->my_node, thread_id); - /* Exit with success to avoid test failures in automated testing */ - shmem_global_exit(0); - } - -#pragma omp barrier -#pragma omp master - { - start = perf_shmemx_wtime(); - } - for (i = 0; i < metric_info->trials; i++) { - for(j = 0; j < metric_info->window_size; j++) { -#ifdef USE_NONBLOCKING_API - shmem_ctx_putmem_nbi(ctx, metric_info->dest + thread_id * len, - metric_info->src + thread_id * len, len, dest); -#else - shmem_ctx_putmem(ctx, metric_info->dest + thread_id * len, - metric_info->src + thread_id * len, len, dest); -#endif - } - shmem_ctx_quiet(ctx); - } - shmem_ctx_destroy(ctx); - } - } else { -#pragma omp parallel default(none) firstprivate(len, dest) private(i, j) \ -shared(metric_info, start, end) num_threads(metric_info->nthreads) - { - const int thread_id = omp_get_thread_num(); - shmem_ctx_t ctx; - int err = shmem_ctx_create(SHMEM_CTX_PRIVATE, &ctx); - - if (err) { - printf("PE %d, Thr. %d: Error, context creation failed\n", - metric_info->my_node, thread_id); - /* Exit with success to avoid test failures in automated testing */ - shmem_global_exit(0); - } - - for (i = 0; i < metric_info->trials; i++) { - for(j = 0; j < metric_info->window_size; j++) { -#ifdef USE_NONBLOCKING_API - shmem_ctx_putmem_nbi(ctx, metric_info->dest + thread_id * len, - metric_info->src + thread_id * len, len, dest); -#else - shmem_ctx_putmem(ctx, metric_info->dest + thread_id * len, - metric_info->src + thread_id * len, len, dest); -#endif - } - shmem_ctx_quiet(ctx); - } - shmem_ctx_destroy(ctx); - } - } - - shmem_barrier_all(); - if (streaming_node(metric_info)) { - end = perf_shmemx_wtime(); - calc_and_print_results(end, start, len, metric_info); - } - - shmem_barrier_all(); -} diff --git a/test/performance/shmem_perf_suite/bw_common.h b/test/performance/shmem_perf_suite/bw_common.h deleted file mode 100644 index 257a1176c..000000000 --- a/test/performance/shmem_perf_suite/bw_common.h +++ /dev/null @@ -1,506 +0,0 @@ -/* - * Copyright (c) 2018 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#ifdef ENABLE_OPENMP -#include -#endif - -static const char * dt_names [] = { "uint", "ulong", "ulonglong" }; - -/*default settings if no input is provided */ -static -void init_metrics(perf_metrics_t *metric_info) { - metric_info->t_type = BW; - set_metric_defaults(metric_info); - - metric_info->unit = MB; - metric_info->target_data = false; - metric_info->cstyle = COMM_PAIRWISE; - metric_info->opstyle = STYLE_RMA; -} - -static -void update_bw_type(perf_metrics_t *data, int b_type) { - if (b_type == BI_DIR) { - data->bw_type_str = "Bi-dir"; - data->b_type = BI_DIR; - } else { - data->bw_type_str = "Uni-dir"; - data->b_type = UNI_DIR; - } -} - -/**************************************************************/ -/* Result Printing and Calc */ -/**************************************************************/ - -static -void print_atomic_header(perf_metrics_t * const metric_info) { - print_header(metric_info); - printf("\n\nBandwidth test type: %10s\n", metric_info->bw_type_str); - - if (metric_info->cstyle == COMM_INCAST) { - printf("Communication style: INCAST\n"); - } else { - assert(metric_info->cstyle == COMM_PAIRWISE); - printf("Communication style: PAIRWISE\n"); - } - - printf("\nOperation%15sBandwidth%15sMessage Rate%15sLatency\n", - " ", " ", " "); - - if (metric_info->unit == MB) { - printf("%19s in mbytes/sec"," "); - } else if (metric_info->unit == KB) { - printf("%19s in kbytes/sec", " "); - } else { - printf("%20s in bytes/sec", " "); - } - - printf("%15s in Mops/sec%15s in us\n", " ", " "); -} - -static -void print_bw_header(perf_metrics_t * const metric_info) { - print_header(metric_info); - printf("\n\nBandwidth test type: %10s\n", metric_info->bw_type_str); - - printf("\nMessage Size%15sBandwidth%15sMessage Rate\n", " ", " "); - - printf("%4sin bytes", " "); - if (metric_info->unit == MB) { - printf("%11sin mbytes/sec", " "); - } else if (metric_info->unit == KB) { - printf("%11sin kbytes/sec", " "); - } else { - printf("%12sin bytes/sec", " "); - } - - printf("%16sin msgs/sec\n", " "); -} - -static -void print_data_results(double bw, double mr, const perf_metrics_t * const data, - int len, double total_t) { - static int atomic_type_index = 0; - - if (data->opstyle == STYLE_ATOMIC) { - printf("%-10s", dt_names[atomic_type_index]); - atomic_type_index = (atomic_type_index + 1) % ATOMICS_N_DTs; - } else - printf("%2s%10d", " ", len); - - if(data->unit == KB) { - bw = bw * 1.0e3; - } else if(data->unit == B) { - bw = bw * 1.0e6; - } - - if (data->opstyle == STYLE_ATOMIC) { - printf("%13s%10.2f%15s%12.2f%12s%10.2f", " ", bw, " ", - mr/1.0e6, " ", total_t/(data->trials * data->window_size)); - } else - printf("%14s%10.2f%15s%12.2f", " ", bw, " ", mr); - - if(data->target_data) { - if(data->my_node < data->szinitiator) { - printf("%2sIniter", " "); - } else { - printf("%2sTarget", " "); - } - } - - printf("\n"); -} - -static inline -void calc_and_print_results(double end_t, double start_t, int len, - perf_metrics_t * const metric_info) { - int start_pe = 0, nPEs = metric_info->num_pes; - static double pe_bw_sum, bw = 0.0; /*must be symmetric for reduction*/ - double pe_bw_avg = 0.0, pe_mr_avg = 0.0; - int nred_elements = 1; - static double pe_time_start, pe_time_end, - end_time_max = 0.0, start_time_min = 0.0; - double total_t = 0.0, total_t_max = 0.0; - int multiplier = 1; - shmem_team_t sync_team; - - PE_set_used_adjustments(&nPEs, &start_pe, metric_info); - sync_team = (start_pe == 0) ? streaming_team : target_team; - - /* 2x as many messages at once for bi-directional */ - if(metric_info->b_type == BI_DIR) - multiplier = 2; - - if (end_t > 0 && start_t > 0 && (end_t - start_t) > 0) { - total_t = end_t - start_t; -#ifdef ENABLE_OPENMP - bw = ((double) len * (double) metric_info->num_partners * (double) multiplier / 1.0e6 * - metric_info->window_size * metric_info->trials * - (double) metric_info->nthreads) / (total_t / 1.0e6); -#else - bw = ((double) len * (double) metric_info->num_partners * (double) multiplier / 1.0e6 * - metric_info->window_size * metric_info->trials) / - (total_t / 1.0e6); -#endif - } else { - fprintf(stderr, "Incorrect time measured from bandwidth test: " - "start = %lf, end = %lf\n", start_t, end_t); - } - - /* base case: will be overwritten by collective if num_pes > 2 */ - pe_bw_sum = bw; - - if (metric_info->individual_report == 1) { - if (metric_info->my_node < metric_info->midpt) { - printf("Individual bandwith for PE %6d (initer) is %10.2f\n", - metric_info->my_node, pe_bw_sum); - } else { - printf("Individual bandwith for PE %6d (target) is %10.2f\n", - metric_info->my_node, pe_bw_sum); - } - } - - pe_time_start = start_t; - pe_time_end = end_t; - shmem_team_sync(sync_team); - if (metric_info->cstyle != COMM_INCAST) { - if (nPEs >= 2) { - shmem_double_min_reduce(streaming_team, &start_time_min, &pe_time_start, nred_elements); - shmem_team_sync(sync_team); - shmem_double_max_reduce(streaming_team, &end_time_max, &pe_time_end, nred_elements); - } else if (nPEs == 1) { - start_time_min = pe_time_start; - end_time_max = pe_time_end; - } - - /* calculating bandwidth based on the highest time duration across all PEs */ - if (end_time_max > 0 && start_time_min > 0 && - (end_time_max - start_time_min) > 0) { - - total_t_max = (end_time_max - start_time_min); - int total_transfers = MAX(metric_info->szinitiator, metric_info->sztarget); -#ifdef ENABLE_OPENMP - bw = ((double) len * (double) multiplier * (double) total_transfers / - 1.0e6 * metric_info->window_size * metric_info->trials * - (double) metric_info->nthreads) / (total_t_max / 1.0e6); -#else - bw = ((double) len * (double) multiplier * (double) total_transfers / - 1.0e6 * metric_info->window_size * metric_info->trials) / - (total_t_max / 1.0e6); -#endif - } else { - fprintf(stderr, "Incorrect time measured from bandwidth test: " - "start_min = %lf, end_max = %lf\n", - start_time_min, end_time_max); - } - pe_bw_sum = bw; - } else { - if (nPEs >= 2) { - shmem_double_sum_reduce(streaming_team, &pe_bw_sum, &bw, nred_elements); - } else if (nPEs == 1) { - pe_bw_sum = bw; - } - } - - /* aggregate bw since bw op pairs are communicating simultaneously */ - if(metric_info->my_node == start_pe) { - pe_bw_avg = pe_bw_sum; - pe_mr_avg = pe_bw_avg / (len / 1.0e6); - print_data_results(pe_bw_avg, pe_mr_avg, metric_info, len, total_t); - } -} - -static int validate_atomics(perf_metrics_t * const m_info) { - int snode = streaming_node(m_info); - int * my_buf = (int *)m_info->dest; - bw_type tbw = m_info->b_type; - int expected_val = 0, errors = 0; - unsigned int ppe_exp_val = ((m_info->trials + m_info->warmup) * m_info->window_size - * ATOMICS_N_DTs * ATOMICS_N_OPs) + m_info->my_node; - - if (m_info->cstyle == COMM_INCAST) { - if (tbw == BI_DIR) - printf("WARNING: This use-case is not currently well defined\n"); - - if (m_info->my_node == 0) { - expected_val = ppe_exp_val * m_info->num_pes; - } else - expected_val = m_info->my_node; - } else { - assert(m_info->cstyle == COMM_PAIRWISE); - expected_val = ppe_exp_val; - } - - if ((!snode && tbw == UNI_DIR) || tbw == BI_DIR) { - if(my_buf[0] != expected_val) { - printf("Validation error for PE %d: %d != %d \n", m_info->my_node, my_buf[0], - expected_val); - errors++; - } - } - - return errors; -} - -/**************************************************************/ -/* Bi-Directional BW */ -/**************************************************************/ - -/*have two symmetric char array metric_info->src/dest of max_len to - * use for calculation initalized with my_node number - * NOTE: post function validation assumptions, data isn't flushed pre/post */ -extern void bi_dir_bw(int len, perf_metrics_t *metric_info); - -static inline -void bi_dir_bw_test_and_output(perf_metrics_t * const metric_info) { - int partner_pe = partner_node(metric_info); - - if(metric_info->my_node == 0) { - if (metric_info->opstyle == STYLE_ATOMIC) { - metric_info->max_len = sizeof(unsigned long long); - print_atomic_header(metric_info); - } - else - print_bw_header(metric_info); - } - - if (metric_info->opstyle == STYLE_ATOMIC) { - bi_dir_bw(0 /* ignored */, metric_info); - } else { - unsigned long int len = 0; - for (len = metric_info->start_len; len <= metric_info->max_len; - len *= metric_info->size_inc) { - - large_message_metric_chg(metric_info, len); - - bi_dir_bw(len, metric_info); - } - } - - shmem_barrier_all(); - - if (metric_info->validate) { - int errors = -1; - if (metric_info->opstyle != STYLE_ATOMIC) { - errors = validate_recv(metric_info->dest, metric_info->max_len, partner_pe); - } else { - errors = validate_atomics(metric_info); - } - if (errors >= 0) - printf("Validation complete (%d errors)\n", errors); - } -} - -/**************************************************************/ -/* UNI-Directional BW */ -/**************************************************************/ - -/* have one symmetric char array metric_info->buf of max_len to use for - * calculation initalized with my_node number - * NOTE: post function validation assumptions, data isn't flushed pre/post */ -extern void uni_dir_bw(int len, perf_metrics_t *metric_info); - -static inline -void uni_dir_bw_test_and_output(perf_metrics_t * const metric_info) { - int partner_pe = partner_node(metric_info); - - if(metric_info->my_node == 0) { - if (metric_info->opstyle == STYLE_ATOMIC) { - metric_info->max_len = sizeof(unsigned long long); - print_atomic_header(metric_info); - } - else - print_bw_header(metric_info); - } - - if (metric_info->opstyle == STYLE_ATOMIC) { - uni_dir_bw(0 /* ignored */, metric_info); - } else { - unsigned long int len = 0; - for (len = metric_info->start_len; len <= metric_info->max_len; - len *= metric_info->size_inc) { - - large_message_metric_chg(metric_info, len); - - uni_dir_bw(len, metric_info); - } - } - - shmem_barrier_all(); - - if (metric_info->validate) { - int errors = -1; - if ((streaming_node(metric_info) && metric_info->opstyle == STYLE_GET) || - (target_node(metric_info) && metric_info->opstyle == STYLE_PUT)) { - errors = validate_recv(metric_info->dest, metric_info->max_len, partner_pe); - } else if (metric_info->opstyle == STYLE_ATOMIC) { - errors = validate_atomics(metric_info); - } - if (errors >= 0) - printf("Validation complete (%d errors)\n", errors); - } -} - -/**************************************************************/ -/* INIT and teardown of resources */ -/**************************************************************/ - -/* create and init (with my_PE_num) two symmetric arrays on the heap */ -static inline -int bw_init_data_stream(perf_metrics_t * const metric_info, - int argc, char *argv[]) { - - init_metrics(metric_info); - int ret = command_line_arg_check(argc, argv, metric_info); - -#ifndef VERSION_1_0 -#if defined(ENABLE_THREADS) - int tl; - shmem_init_thread(metric_info->thread_safety, &tl); - if(tl < metric_info->thread_safety) { - fprintf(stderr,"Could not initialize with requested thread " - "level %d: got %d\n", metric_info->thread_safety, tl); - return -1; - } -#else - shmem_init(); -#endif -#else - start_pes(0); -#endif - - update_metrics(metric_info); - - if (ret) { - if (metric_info->my_node == 0) { - print_usage(ret); - } - return -1; - } else { - if (metric_info->num_pes < 2) { - fprintf(stderr, "This test requires at least two processes.\n"); - print_usage(1); - return -1; - } - } - - if (error_checking_init_target_usage(metric_info) == -1) - return -1; -#if defined(ENABLE_THREADS) - thread_safety_validation_check(metric_info); -#endif - - if (only_even_PEs_check(metric_info->my_node, metric_info->num_pes) != 0) { - return -1; - } - - metric_info->src = aligned_buffer_alloc(metric_info->max_len * metric_info->nthreads); - init_array(metric_info->src, metric_info->max_len * metric_info->nthreads, metric_info->my_node); - - metric_info->dest = aligned_buffer_alloc(metric_info->max_len * metric_info->nthreads); - init_array(metric_info->dest, metric_info->max_len * metric_info->nthreads, metric_info->my_node); - - if (create_teams(metric_info) != 0) { - return -1; - } - - return 0; -} - - -static inline -int bi_dir_init(perf_metrics_t * const metric_info, int argc, - char *argv[], op_style opstyle) { - int ret = bw_init_data_stream(metric_info, argc, argv); - if (ret == 0) { - metric_info->opstyle = opstyle; - update_bw_type(metric_info, BI_DIR); - return 0; - } else - return ret; -} - -static inline -int uni_dir_init(perf_metrics_t * const metric_info, int argc, - char *argv[], op_style opstyle) { - int ret = bw_init_data_stream(metric_info, argc, argv); - if (ret == 0) { - /* uni-dir validate needs to know if its a put or get */ - metric_info->opstyle = opstyle; - update_bw_type(metric_info, UNI_DIR); - return 0; - } else - return ret; -} - -static inline -void bw_data_free(const perf_metrics_t * const metric_info) { - shmem_barrier_all(); - - aligned_buffer_free(metric_info->src); - aligned_buffer_free(metric_info->dest); -} - -static inline -void bw_finalize(void) { -#ifndef VERSION_1_0 - shmem_finalize(); -#endif -} - -static inline -void bi_dir_bw_main(int argc, char *argv[], op_style opstyle) { - - perf_metrics_t metric_info; - - int ret = bi_dir_init(&metric_info, argc, argv, opstyle); - - if (ret == 0) { - bi_dir_bw_test_and_output(&metric_info); - bw_data_free(&metric_info); - } - - bw_finalize(); -} - -static inline -void uni_dir_bw_main(int argc, char *argv[], op_style opstyle) { - - perf_metrics_t metric_info; - - int ret = uni_dir_init(&metric_info, argc, argv, opstyle); - - if (ret == 0) { - uni_dir_bw_test_and_output(&metric_info); - bw_data_free(&metric_info); - } - - bw_finalize(); -} diff --git a/test/performance/shmem_perf_suite/common.h b/test/performance/shmem_perf_suite/common.h deleted file mode 100644 index 5ecc95667..000000000 --- a/test/performance/shmem_perf_suite/common.h +++ /dev/null @@ -1,836 +0,0 @@ -/* - * Copyright (c) 2018 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* hostname length to check for hostname errors */ -#ifdef MAXHOSTNAMELEN -#define MAX_HOSTNAME_LEN MAXHOSTNAMELEN -#else -#define MAX_HOSTNAME_LEN HOST_NAME_MAX -#endif - -#ifndef MAX -#define MAX(A,B) (((A)>(B)) ? (A) : (B)) -#endif - -#define ONE 1 - -/* constants for experiments */ -#define MAX_MSG_SIZE (1<<23) -#define START_LEN 1 -#define INC 2 -#define TRIALS 1000 -#define WINDOW_SIZE 64 -#define WARMUP 100 - -/* constants for experiments with large message sizes */ -#define TRIALS_LARGE 100 -#define WINDOW_SIZE_LARGE 64 -#define WARMUP_LARGE 10 -#define LARGE_MESSAGE_SIZE 65536 - -#define TARGET_SZ_MIN 8 -#define TARGET_SZ_MAX 4096 - -/* atomics common */ -#define ATOMICS_N_DTs 3 -/* note: ignoring cswap/swap for now in verification */ -#define ATOMICS_N_OPs 4 -/* PE 0 is printing its latency, thus have it not be the INCAST PE*/ -#define INCAST_PE 1 - -/* perf metrics structures */ -typedef enum { - LAT, - BW -} test_type; - -typedef enum { - UNI_DIR, - BI_DIR -} bw_type; - -typedef enum { - STYLE_PUT, - STYLE_GET, - STYLE_RMA, - STYLE_ATOMIC -} op_style; - -typedef enum { - FIRST_HALF, - SECOND_HALF, - FULL_SET -} red_PE_set; - -typedef enum { - COMM_PAIRWISE, - COMM_INCAST -} comm_style; - -typedef enum { - B, - KB, - MB -} bw_units; - -typedef enum { - OP_SET = 0, - OP_INC, - OP_ADD, - OP_AND, - OP_OR, - OP_XOR, - OP_FETCH, - OP_CSWAP, - OP_SWAP, - OP_FINC, - OP_FADD, - OP_FAND, - OP_FOR, - OP_FXOR, - LAST_OP -} atomic_op_type; - -#define FIRST_FETCH_OP OP_FETCH - -const char *atomic_op_name[] = { "set", "inc", "add", "and", - "or", "xor", - "fetch", "cswap", "swap", "finc", - "fadd", "fand", "for", "fxor" }; - -typedef struct perf_metrics { - /* common parameters */ - test_type t_type; - unsigned long int start_len, max_len; - unsigned long int size_inc, trials; - unsigned long int window_size, warmup; - int my_node, num_pes, sztarget, szinitiator, midpt; - char *src, *dest; - op_style opstyle; - - float trials_multiplier; /* adjust trials value through env var - * SHMEM_PERF_SUITE_TRIALS_MULTIPLIER. */ - - /* parameters for threaded tests */ - int nthreads; - int thread_safety; - - /* parameters specific to bandwidth tests */ - bw_units unit; - const char *bw_type_str; - bw_type b_type; - comm_style cstyle; - int target_data; - int num_partners; - - /* parameters specific to latency tests */ - long *target; - - /* misc parameters */ - int validate; - int individual_report; -} perf_metrics_t; - - -shmem_team_t streaming_team, target_team; - -/* default settings with no input provided */ -static inline -void set_metric_defaults(perf_metrics_t *metric_info) { - char *val = NULL; - metric_info->trials_multiplier = 1.0; /* Default 1 */ - val = getenv("SHMEM_PERF_SUITE_TRIALS_MULTIPLIER"); - if (val && strlen(val)) - metric_info->trials_multiplier = atof(val); - - metric_info->start_len = START_LEN; - metric_info->max_len = MAX_MSG_SIZE; - metric_info->size_inc = INC; - metric_info->trials = TRIALS * metric_info->trials_multiplier; - metric_info->window_size = WINDOW_SIZE; /*back-to-back msg stream*/ - metric_info->warmup = WARMUP; /*number of initial iterations to skip*/ - - metric_info->my_node = -1; - metric_info->num_pes = -1; - metric_info->midpt = -1; - metric_info->sztarget = -1; - metric_info->szinitiator = -1; - - metric_info->src = NULL; - metric_info->dest = NULL; - - metric_info->num_partners = 1; - -#if defined(ENABLE_THREADS) - metric_info->thread_safety = SHMEM_THREAD_SINGLE; -#else - metric_info->thread_safety = 0; -#endif - metric_info->nthreads = 1; - - metric_info->validate = false; - metric_info->individual_report = -1; -} - -/* update metrics after shmem init */ -static inline -void update_metrics(perf_metrics_t *metric_info) { - metric_info->my_node = shmem_my_pe(); - metric_info->num_pes = shmem_n_pes(); - assert(metric_info->num_pes); - metric_info->midpt = metric_info->num_pes / 2; -} - -/* return microseconds */ -double perf_shmemx_wtime(void); - -double perf_shmemx_wtime(void) -{ - double wtime = 0.0; - -#ifdef CLOCK_MONOTONIC - struct timespec tv; - clock_gettime(CLOCK_MONOTONIC, &tv); - wtime = tv.tv_sec * 1e6; - wtime += (double)tv.tv_nsec / 1000.0; -#else - struct timeval tv; - gettimeofday(&tv, NULL); - wtime = tv.tv_sec * 1e6; - wtime += (double)tv.tv_usec; -#endif - return wtime; -} - -#ifdef CRAY_SHMEM -#define shmem_putmem_nbi(dest, source, nelems, pe) shmem_putmem_nb(dest, source, nelems, pe, NULL) -#define shmem_getmem_nbi(dest, source, nelems, pe) shmem_getmem_nb(dest, source, nelems, pe, NULL) -#endif - -static char * aligned_buffer_alloc(int len) -{ - unsigned long alignment = 0; - char *ptr1 = NULL, *ptr_aligned = NULL; - size_t ptr_size = sizeof(uintptr_t); - uintptr_t save_ptr1 = 0; - - alignment = getpagesize(); - -#ifndef VERSION_1_0 - ptr1 = shmem_malloc(ptr_size + alignment + len); -#else - ptr1 = shmalloc(ptr_size + alignment + len); -#endif - assert(ptr1 != NULL); - - save_ptr1 = (uintptr_t)ptr1; - - /* reserve at least ptr_size before alignment chunk */ - ptr1 = (char *) (ptr1 + ptr_size); - - /* only offset ptr by alignment to ensure len is preserved */ - /* clear bottom bits to ensure alignment */ - ptr_aligned = (char *) ( ((uintptr_t) ((char *) (ptr1 + alignment))) - & ~(alignment-1)); - - /* embed org ptr address in reserved ptr_size space */ - memcpy((ptr_aligned - ptr_size), &save_ptr1, ptr_size); - - return ptr_aligned; -} - -static void aligned_buffer_free(char * ptr_aligned) -{ - char * ptr_org; - uintptr_t temp_p; - size_t ptr_size = sizeof(uintptr_t); - - /* grab ptr */ - memcpy(&temp_p, (ptr_aligned - ptr_size), ptr_size); - ptr_org = (char *) temp_p; - -#ifndef VERSION_1_0 - shmem_free(ptr_org); -#else - shfree(ptr_org); -#endif -} - -static inline -int is_divisible_by_4(int num) { - if (num < 0) - shmem_global_exit(1); - return (num % 4 == 0); -} - -/*to be a power of 2 must only have 1 set bit*/ -static inline -int is_pow_of_2(unsigned int num) { - /*move first set bit all the way to right*/ - while(num && !((num >>=1 ) & 1)); - - /*it will be 1 if its the only set bit*/ - return ((num == 1 || num == 0) ? true : false); -} - -static -void init_array(const char *buf, int len, int my_pe_num) { - int i = 0; - int array_size = len / sizeof(int); - int *ibuf = (int *)buf; - - assert(is_divisible_by_4(len)); - - for(i = 0; i < array_size; i++) - ibuf[i] = my_pe_num; -} - -static inline -int validate_recv(char *buf, int len, int partner_pe) { - int i = 0; - int array_size = len / sizeof(int); - int *ibuf = (int *)buf; - int errors = 0; - - assert(is_divisible_by_4(len)); - - for (i = 0; i < array_size; i++) { - if (ibuf[i] != partner_pe) { - errors++; - } - } - if (errors > 0) { - printf("Validation error: stored_value = %d, expected value = %d\n", - ibuf[0], partner_pe); - } - return errors; -} - -/**************************************************************/ -/* Input Checking */ -/**************************************************************/ - -static -int command_line_arg_check(int argc, char *argv[], perf_metrics_t * const metric_info) { - int ch, errors = 0; - extern char *optarg; - - /* check command line args */ - while ((ch = getopt(argc, argv, "e:s:n:m:w:p:r:l:kbivtC:T:")) != EOF) { - switch (ch) { - case 's': - metric_info->start_len = strtoul(optarg, (char **)NULL, 0); - if ( metric_info->start_len < 1 ) metric_info->start_len = 1; - if(!is_pow_of_2(metric_info->start_len)) { - fprintf(stderr, "Error: start_length must be a power of two\n"); - errors++; - } - if (metric_info->start_len > INT_MAX) { - fprintf(stderr, "Error: start_length is out of integer range\n"); - errors++; - } - break; - case 'e': - metric_info->max_len = strtoul(optarg, (char **)NULL, 0); - if(!is_pow_of_2(metric_info->max_len)) { - fprintf(stderr, "Error: end_length must be a power of two\n"); - errors++; - } - if(metric_info->max_len < metric_info->start_len) { - fprintf(stderr, "Error: end_length (%ld) must be >= " - "start_length (%ld)\n", metric_info->max_len, - metric_info->start_len); - errors++; - } - if (metric_info->max_len > INT_MAX) { - fprintf(stderr, "Error: end_length is out of integer range\n"); - errors++; - } - break; - case 'n': - metric_info->trials = strtoul(optarg, (char **)NULL, 0); - if(metric_info->trials < (metric_info->warmup * 2)) { - fprintf(stderr, "Error: trials (%ld) must be >= 2*warmup " - "(%ld)\n", metric_info->trials, metric_info->warmup * 2); - errors++; - } - break; - case 'm': - metric_info->trials_multiplier = strtod(optarg, (char **)NULL); - if(metric_info->trials * metric_info->trials_multiplier < - (metric_info->warmup * 2)) { - fprintf(stderr, "Error: trials * trials_multiplier (%ld) must be >= 2*warmup (%ld)\n", - (unsigned long int)(metric_info->trials * metric_info->trials_multiplier), - metric_info->warmup * 2); - errors++; - } - metric_info->trials *= metric_info->trials_multiplier; - break; - case 'p': - metric_info->warmup = strtoul(optarg, (char **)NULL, 0); - if(metric_info->warmup > (metric_info->trials/2)) { - fprintf(stderr, "Error: warmup (%ld) must be <= trials/2 " - "(%ld)\n", metric_info->warmup, metric_info->trials/2); - errors++; - } - break; - case 'k': - metric_info->unit = KB; - if (metric_info->t_type != BW) - errors++; - break; - case 'b': - metric_info->unit = B; - if (metric_info->t_type != BW) - errors++; - break; - case 'v': - metric_info->validate = true; - if(metric_info->t_type == BW && metric_info->target_data) - errors++; - break; - case 'w': - metric_info->window_size = strtoul(optarg, (char **)NULL, 0); - if (metric_info->t_type != BW) { - errors++; - } else { - if (metric_info->target_data) { - errors++; - } - } - break; - case 't': - metric_info->target_data = true; - if (metric_info->t_type != BW) { - errors++; - } else { - if (metric_info->validate) { - errors++; - } - } - break; - case 'r': - metric_info->sztarget = strtoul(optarg, (char **)NULL, 0); - break; - case 'l': - metric_info->szinitiator = strtoul(optarg, (char **)NULL, 0); - break; - case 'C': -#if defined(ENABLE_THREADS) - if (strcmp(optarg, "SINGLE") == 0) { - metric_info->thread_safety = SHMEM_THREAD_SINGLE; - } else if (strcmp(optarg, "FUNNELED") == 0) { - metric_info->thread_safety = SHMEM_THREAD_FUNNELED; - } else if (strcmp(optarg, "SERIALIZED") == 0) { - metric_info->thread_safety = SHMEM_THREAD_SERIALIZED; - } else if (strcmp(optarg, "MULTIPLE") == 0) { - metric_info->thread_safety = SHMEM_THREAD_MULTIPLE; - } else { - fprintf(stderr, "Invalid threading level: \"%s\"\n", optarg); - errors++; - } -#else - fprintf(stderr, "Threading support disabled. " - "Ignoring threading level: \"%s\"\n", optarg); - metric_info->thread_safety = 0; -#endif - break; - case 'T': - metric_info->nthreads = atoi(optarg); - break; - case 'i': - metric_info->individual_report = 1; - break; - default: - errors++; - break; - } - } - - return errors; -} - -static inline -void print_usage(int errors) { - fprintf(stderr, "\nNumber of errors in the command line: %d\n", errors); - fprintf(stderr, "\nUsage: [OPTION]\n" - " -s START_MSG_SIZE Smallest message size. Must be power of 2\n" - " -e END_MSG_SIZE Largest message size. Must be power of 2\n" - " -p WARMUP Number of warmup iterations\n" - " -n TRIALS Number of trial iterations. Must be at\n" - " least twice of WARMUP\n" - " -m TRIALS_MULTIPLIER Scale the TRIALS value by a floating\n" - " point multiplier. Must be greater than 0.\n" - " -w WINDOW_SIZE Window size for streaming. Cannot be used\n" - " in conjunction with -t. Specific to band-\n" - " -width experiments\n" - " -k Setting bandwidth metric to kbytes/second\n" - " -b Setting bandwidth metric to bytes/second\n" - " -v Turning on validation of data\n" - " -i Turning on individual process reporting\n" - " -t Output data for target side (default is \n" - " initiator, only use with Put Bandwidth),\n" - " cannot be used in conjunction with \n" - " validate, special sizes used, trials + \n" - " warmup * sizes (8/4KB) <= max length \n" - " -r TARGET_SIZE Number of target nodes, use only with -t;\n" - " -l SOURCE_SIZE Number of initiator nodes, use only with\n" - " -t\n" - " -T THREADS Number of threads\n" - " -C THREAD_LEVEL SHMEM thread level. Possible values: \n" - " SINGLE, FUNNELED, SERIALIZED, MULTIPLE \n" - ); -} - - -#if defined(ENABLE_THREADS) -static -const char *thread_safety_str(perf_metrics_t * const metric_info) { - if (metric_info->thread_safety == SHMEM_THREAD_SINGLE) { - return "SINGLE"; - } else if (metric_info->thread_safety == SHMEM_THREAD_FUNNELED) { - return "FUNNELED"; - } else if (metric_info->thread_safety == SHMEM_THREAD_SERIALIZED) { - return "SERIALIZED"; - } else if (metric_info->thread_safety == SHMEM_THREAD_MULTIPLE) { - return "MULTIPLE"; - } else { - fprintf(stderr, "Unexpected thread safety value: %d. " - "Setting it to SINGLE\n", metric_info->thread_safety); - metric_info->thread_safety = SHMEM_THREAD_SINGLE; - return "SINGLE"; - } -} - -static inline -void thread_safety_validation_check(perf_metrics_t * const metric_info) { - if (metric_info->nthreads == 1) - return; - else { - if (metric_info->thread_safety != SHMEM_THREAD_MULTIPLE) { - if(metric_info->my_node == 0) { - fprintf(stderr, "Warning: argument \"-T %d\" is ignored" - " because of the thread level specified." - " Switching to single thread with thread" - " safety %s\n", metric_info->nthreads, - thread_safety_str(metric_info)); - } - metric_info->nthreads = 1; - } - return; - } -} -#endif - -/* Only even number of PEs are allowed for performance tests */ -static inline -int only_even_PEs_check(int my_node, int num_pes) { - if (num_pes % 2 != 0) { - if (my_node == 0) { - fprintf(stderr, "Only even number of processes can be used\n"); - } - return 77; - } else - return 0; -} - - -/* Returns partner node; Assumes only one partner */ -static inline -int partner_node(const perf_metrics_t * const my_info) -{ - if (my_info->num_pes == 1) - return 0; - - if (my_info->t_type == BW) { - if(my_info->cstyle == COMM_PAIRWISE) { - int pairs = my_info->midpt; - - return (my_info->my_node < pairs ? (my_info->my_node + pairs) : - (my_info->my_node - pairs)); - } else { - assert(my_info->cstyle == COMM_INCAST); - return INCAST_PE; - } - } else { - int pairs = my_info->midpt; - - return (my_info->my_node < pairs ? (my_info->my_node + pairs) : - (my_info->my_node - pairs)); - } -} - -static inline -int streaming_node(const perf_metrics_t * const my_info) -{ - if (my_info->cstyle == COMM_PAIRWISE) { - return (my_info->my_node < my_info->szinitiator); - } else { - assert(my_info->cstyle == COMM_INCAST); - return true; - } -} - -static inline -int target_node(const perf_metrics_t * const my_info) -{ - return (my_info->my_node >= my_info->midpt && - (my_info->my_node < (my_info->midpt + my_info->sztarget))); -} - -static inline -int is_streaming_node(const perf_metrics_t * const my_info, int node) -{ - if (my_info->cstyle == COMM_PAIRWISE) { - return (node < my_info->szinitiator); - } else { - assert(my_info->cstyle == COMM_INCAST); - return true; - } -} - -static inline -int check_hostname_validation(const perf_metrics_t * const my_info) { - - int hostname_status = -1; - - int hostname_size = MAX_HOSTNAME_LEN; - int i, errors = 0; - - char *hostname = (char *) shmem_malloc (hostname_size * sizeof(char)); - char *dest = (char *) shmem_malloc (my_info->num_pes * hostname_size * - sizeof(char)); - - if (hostname == NULL || dest == NULL) { - fprintf(stderr, "shmem_malloc failed to allocate for hostname strings\n"); - return -1; - } - - hostname_status = gethostname(hostname, hostname_size); - if (hostname_status != 0) { - fprintf(stderr, "gethostname failed (%d)\n", hostname_status); - return -1; - } - shmem_barrier_all(); - - shmem_char_fcollect(SHMEM_TEAM_WORLD, dest, hostname, hostname_size); - - char *snode_name = NULL; - char *tnode_name = NULL; - for (i = 0; i < my_info->num_pes; i++) { - char *curr_name = &dest[i * hostname_size]; - - if (is_streaming_node(my_info, i)) { - if (snode_name == NULL) { - snode_name = curr_name; - } - - if (strncmp(snode_name, curr_name, hostname_size) != 0) { - fprintf(stderr, "PE %d on %s is a streaming node " - "but not placed on %s\n", i, curr_name, - snode_name); - errors++; - } - } else { - if (tnode_name == NULL) { - tnode_name = curr_name; - } - - if (strncmp(tnode_name, curr_name, hostname_size) != 0) { - fprintf(stderr, "PE %d on %s is a target node " - "but not placed on %s\n", i, curr_name, - tnode_name); - errors++; - } - } - } - - if (snode_name == NULL || tnode_name == NULL) { - fprintf(stderr, "Error: no streaming or target node\n"); - return -1; - } - - if (strncmp(snode_name, tnode_name, hostname_size) == 0) { - fprintf(stderr, "Warning: senders and receivers are running on the " - "same node %s\n", snode_name); - } - - shmem_free(dest); - shmem_free(hostname); - - return errors; -} - -static -int error_checking_init_target_usage(perf_metrics_t * const metric_info) { - int error = false; - assert(metric_info->midpt > 0); - - if (metric_info->sztarget != -1 && metric_info->szinitiator == -1) { - if (metric_info->sztarget < 1 || - metric_info->sztarget > metric_info->midpt || - !metric_info->target_data) { - error = true; - } else { - metric_info->szinitiator = metric_info->midpt; - } - } else if (metric_info->sztarget == -1 && metric_info->szinitiator != -1) { - if( metric_info->szinitiator < 1 || - metric_info->szinitiator > metric_info->midpt || - !metric_info->target_data) { - error = true; - } else { - metric_info->sztarget = metric_info->midpt; - } - } else if (metric_info->sztarget == -1 && metric_info->szinitiator == -1) { - metric_info->szinitiator = metric_info->midpt; - metric_info->sztarget = metric_info->midpt; - } else { - if (!metric_info->target_data) { - error = true; - } - } - - if (error) { - fprintf(stderr, "Invalid usage of command line arg -r/-l\n"); - return -1; - } - return 0; -} - -static inline -void large_message_metric_chg(perf_metrics_t * const metric_info, int len) { - if(len > LARGE_MESSAGE_SIZE) { - metric_info->window_size = WINDOW_SIZE_LARGE; - metric_info->trials = TRIALS_LARGE * metric_info->trials_multiplier; - metric_info->warmup = WARMUP_LARGE; - } -} - -/* put/get bw use opposite streaming/validate nodes */ -static inline -red_PE_set validation_set(perf_metrics_t * const my_info, int *nPEs) -{ - if (my_info->cstyle == COMM_PAIRWISE) { - if (streaming_node(my_info)) { - *nPEs = my_info->szinitiator; - return FIRST_HALF; - } else if (target_node(my_info)) { - *nPEs = my_info->sztarget; - return SECOND_HALF; - } else { - fprintf(stderr, "Warning: you are getting data from a node that " - "wasn't a part of the perf set \n "); - return 0; - } - } else { - assert(my_info->cstyle == COMM_INCAST); - *nPEs = my_info->num_pes; - return FULL_SET; - } -} - -static inline -void PE_set_used_adjustments(int *nPEs, int *start_pe, perf_metrics_t * const my_info) { - red_PE_set PE_set = validation_set(my_info, nPEs); - - if(PE_set == FIRST_HALF || PE_set == FULL_SET) { - *start_pe = 0; - } - else { - assert(PE_set == SECOND_HALF); - *start_pe = my_info->midpt; - } -} - -static -void print_header(perf_metrics_t * const metric_info) { - printf("\n%20sSandia OpenSHMEM Performance Suite%20s\n", " ", " "); - printf("%20s==================================%20s\n", " ", " "); - printf("Total Number of PEs: %10d%6sWindow size: %10lu\n", - metric_info->num_pes, " ", metric_info->window_size); - printf("Number of source PEs: %10d%6sMaximum message size: %10lu\n", - metric_info->szinitiator, " ", metric_info->max_len); - printf("Number of target PEs: %10d%6sNumber of threads: %10d\n", - metric_info->sztarget, " ", metric_info->nthreads); - printf("Iteration count: %10lu%6s", metric_info->trials, " "); -#if defined(ENABLE_THREADS) - printf("Thread safety: %10s\n", thread_safety_str(metric_info)); -#endif - printf("\n"); -} - -static -int create_streaming_team(perf_metrics_t * const metric_info) { - shmem_team_split_strided(SHMEM_TEAM_WORLD, 0, 1, metric_info->num_pes / 2, NULL, 0, &streaming_team); - - int my_pe = metric_info->my_node; - if (streaming_team == SHMEM_TEAM_INVALID && (my_pe >= 0 && my_pe < metric_info->num_pes / 2)) { - fprintf(stderr, "PE %d: Streaming team creation failed\n", metric_info->my_node); - return -1; - } - - return 0; -} - -static -int create_target_team(perf_metrics_t * const metric_info) { - shmem_team_split_strided(SHMEM_TEAM_WORLD, metric_info->midpt, 1, metric_info->num_pes / 2, NULL, 0, &target_team); - - int my_pe = metric_info->my_node; - if (target_team == SHMEM_TEAM_INVALID && (my_pe >= metric_info->midpt && my_pe < metric_info->num_pes)) { - fprintf(stderr, "PE %d: Target team creation failed\n", metric_info->my_node); - return -1; - } - - return 0; -} - -/* Create two teams: streaming and target. - * PEs [0, 1, ..., npes/2-1] will be in streaming_team and - * PEs [npes/2, npes/2+1, ..., npes-1] in target_team. */ -static -int create_teams(perf_metrics_t * const metric_info) { - int ret = create_streaming_team(metric_info); - if (!ret) - return create_target_team(metric_info); - - return ret; -} diff --git a/test/performance/shmem_perf_suite/int_element_latency.h b/test/performance/shmem_perf_suite/int_element_latency.h deleted file mode 100644 index a32cab7c9..000000000 --- a/test/performance/shmem_perf_suite/int_element_latency.h +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) 2018 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -static inline -void int_p_latency(perf_metrics_t * const metric_info) -{ - double start = 0.0; - double end = 0.0; - unsigned int i = 0; - int dest = partner_node(metric_info); - int sender = (metric_info->num_pes != 1) ? streaming_node(metric_info) : true; - static int check_once = 0; - - if (!check_once) { - /* check to see whether sender and receiver are the same process */ - if (dest == metric_info->my_node) { - fprintf(stderr, "Warning: Sender and receiver are the same process (%d)\n", - dest); - } - /* hostname validation for all sender and receiver processes */ - int status = check_hostname_validation(metric_info); - if (status != 0) return; - check_once++; - } - - if (metric_info->my_node == 0) { - printf("\nshmem_int_p results:\n"); - print_latency_header(); - } - shmem_barrier_all(); - - /* puts to zero to match gets validation scheme */ - if (sender) { - - for (i = 0; i < metric_info->trials + metric_info->warmup; i++) { - if(i == metric_info->warmup) - start = perf_shmemx_wtime(); - - shmem_int_p((int*) metric_info->dest, metric_info->my_node, dest); - shmem_quiet(); - - } - end = perf_shmemx_wtime(); - - calc_and_print_results(start, end, sizeof(int), metric_info); - } - - shmem_barrier_all(); - - if(!sender && metric_info->validate) - validate_recv(metric_info->dest, sizeof(int), dest); - -} /* latency/bw for one-way trip */ - -static inline -void int_g_latency(perf_metrics_t * const metric_info) -{ - double start = 0.0; - double end = 0.0; - unsigned int i = 0; - int rtnd = -1; - int dest = partner_node(metric_info); - int receiver = (metric_info->num_pes != 1) ? streaming_node(metric_info) : true; - static int check_once = 0; - - if (!check_once) { - /* check to see whether sender and receiver are the same process */ - if (dest == metric_info->my_node) { - fprintf(stderr, "Warning: Sender and receiver are the same process (%d)\n", - dest); - } - /* hostname validation for all sender and receiver processes */ - int status = check_hostname_validation(metric_info); - if (status != 0) return; - check_once++; - } - - if (metric_info->my_node == 0) { - printf("\nshmem_int_g results:\n"); - print_latency_header(); - } - shmem_barrier_all(); - - if (receiver) { - - for (i = 0; i < metric_info->trials + metric_info->warmup; i++) { - if(i == metric_info->warmup) - start = perf_shmemx_wtime(); - - rtnd = shmem_int_g((int*) metric_info->src, dest); - } - end = perf_shmemx_wtime(); - - calc_and_print_results(start, end, sizeof(int), metric_info); - } - - shmem_barrier_all(); - - if(receiver && metric_info->validate) - validate_recv((char*) &rtnd, sizeof(int), dest); -} diff --git a/test/performance/shmem_perf_suite/latency_common.h b/test/performance/shmem_perf_suite/latency_common.h deleted file mode 100644 index 2e473447e..000000000 --- a/test/performance/shmem_perf_suite/latency_common.h +++ /dev/null @@ -1,258 +0,0 @@ -/* - * Copyright (c) 2018 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#ifdef ENABLE_OPENMP -#include -#endif - -#define INIT_VALUE 1 - -static -void init_metrics(perf_metrics_t * const metric_info) { - metric_info->t_type = LAT; - set_metric_defaults(metric_info); - metric_info->target = NULL; - metric_info->cstyle = COMM_PAIRWISE; - metric_info->opstyle = STYLE_RMA; -} - -static inline -void print_latency_header(void) { - printf("\nMessage Size%15sLatency\n", " "); - printf("%4sin bytes%17sin us\n", " ", " "); -} - -/* calculation and printing of the latency */ -static inline -void calc_and_print_results(double start, double end, int len, - perf_metrics_t * const metric_info) { - int start_pe = 0, nPEs = metric_info->num_pes; - int nred_elements = 1; - static double latency = 0.0, avg_latency = 0.0; - shmem_team_t sync_team; - - PE_set_used_adjustments(&nPEs, &start_pe, metric_info); - sync_team = (start_pe == 0) ? streaming_team : target_team; - - if (end > 0 && start > 0 && (end - start) > 0) { - latency = (end - start) / metric_info->trials; - } else { - fprintf(stderr, "Incorrect time measured from latency test: " - "start = %lf, end = %lf\n", start, end); - } - - if (metric_info->individual_report == 1) { - printf("Individual latency for PE %6d is %10.2f\n", - metric_info->my_node, latency); - } - shmem_team_sync(sync_team); - - if (nPEs >= 2) { - shmem_double_sum_reduce(streaming_team, &avg_latency, &latency, nred_elements); - avg_latency /= nPEs; - } else { - avg_latency = latency; - } - - if (metric_info->my_node == start_pe) { - printf("%2s%10d%12s%10.2f\n", " ", len, " ", avg_latency); - } - -} - -/**************************************************************/ -/* Latency data gathering */ -/**************************************************************/ - -/*have single symmetric long element "target" from perf_metrics_t - * that needs to be initialized in function*/ -extern void long_element_round_trip_latency(perf_metrics_t *data); - -extern void int_element_latency(perf_metrics_t *data); - -/*have symmetric buffers src/dest from perf_metrics_t - * that has been initialized to my_node number */ -extern void streaming_latency(int len, perf_metrics_t *data); - -static inline -void multi_size_latency(perf_metrics_t * const data, char *argv[]) { - unsigned int len; - int partner_pe = partner_node(data); - - if (data->my_node == 0) { - print_latency_header(); - } - - for (len = data->start_len; len <= data->max_len; len *= data->size_inc) { - large_message_metric_chg(data, len); - streaming_latency(len, data); - } - - shmem_barrier_all(); - - if (data->validate) { - int errors = -1; - if ((streaming_node(data) && data->opstyle == STYLE_GET) || - (target_node(data) && data->opstyle == STYLE_PUT)) - errors = validate_recv(data->dest, data->max_len, partner_pe); - - if (errors >= 0) - printf("Validation complete (%d errors)\n", errors); - } -} - - - -/**************************************************************/ -/* INIT and teardown of resources */ -/**************************************************************/ - -static inline -int latency_init_resources(int argc, char *argv[], - perf_metrics_t * const metric_info) { - init_metrics(metric_info); - int ret = command_line_arg_check(argc, argv, metric_info); - -#ifndef VERSION_1_0 -#if defined(ENABLE_THREADS) - int tl; - shmem_init_thread(metric_info->thread_safety, &tl); - if(tl < metric_info->thread_safety) { - fprintf(stderr,"Could not initialize with requested thread " - "level %d: got %d\n", metric_info->thread_safety, tl); - return -1; - } -#else - shmem_init(); -#endif -#else - start_pes(0); -#endif - - update_metrics(metric_info); - - if (ret) { - if (metric_info->my_node == 0) { - print_usage(ret); - } - return -1; - } else { - if (metric_info->num_pes < 2) { - fprintf(stderr, "This test requires at least two processes.\n"); - print_usage(1); - return -1; - } - } - - if (error_checking_init_target_usage(metric_info) == -1) - return -1; -#if defined(ENABLE_THREADS) - thread_safety_validation_check(metric_info); -#endif - - if(only_even_PEs_check(metric_info->my_node, metric_info->num_pes) != 0) { - return -1; - } - - metric_info->src = aligned_buffer_alloc(metric_info->max_len); - init_array(metric_info->src, metric_info->max_len, metric_info->my_node); - - metric_info->dest = aligned_buffer_alloc(metric_info->max_len); - init_array(metric_info->dest, metric_info->max_len, metric_info->my_node); - -#ifndef VERSION_1_0 - metric_info->target = shmem_malloc(sizeof(long)); -#else - metric_info->target = shmalloc(sizeof(long)); -#endif - - if (create_teams(metric_info) != 0) { - return -1; - } - - return 0; -} - -static inline -void latency_free_resources(const perf_metrics_t * const metric_info) { - shmem_barrier_all(); - -#ifndef VERSION_1_0 - shmem_free(metric_info->target); -#else - shfree(metric_info->target); -#endif - aligned_buffer_free(metric_info->src); - aligned_buffer_free(metric_info->dest); -} - -static inline -void latency_finalize(void) { -#ifndef VERSION_1_0 - shmem_finalize(); -#endif -} - -static inline -void latency_main(int argc, char *argv[], op_style opstyle) { - perf_metrics_t metric_info; - - int ret = latency_init_resources(argc, argv, &metric_info); - metric_info.opstyle = opstyle; - - if (ret == 0) { - if (metric_info.my_node == 0) { - print_header(&metric_info); - } - long_element_round_trip_latency(&metric_info); - int_element_latency(&metric_info); - multi_size_latency(&metric_info, argv); - latency_free_resources(&metric_info); - } - - latency_finalize(); -} - -static inline -void latency_main_ctx(int argc, char *argv[], op_style opstyle) { - perf_metrics_t metric_info; - - int ret = latency_init_resources(argc, argv, &metric_info); - metric_info.opstyle = opstyle; - - if (ret == 0) { - if (metric_info.my_node == 0) { - print_header(&metric_info); - } - multi_size_latency(&metric_info, argv); - latency_free_resources(&metric_info); - } - - latency_finalize(); -} - diff --git a/test/performance/shmem_perf_suite/latency_ctx.h b/test/performance/shmem_perf_suite/latency_ctx.h deleted file mode 100644 index b3d3804c1..000000000 --- a/test/performance/shmem_perf_suite/latency_ctx.h +++ /dev/null @@ -1,218 +0,0 @@ -/* -* Copyright (c) 2018 Intel Corporation. All rights reserved. -* This software is available to you under the BSD license below: -* -* Redistribution and use in source and binary forms, with or -* without modification, are permitted provided that the following -* conditions are met: -* -* - Redistributions of source code must retain the above -* copyright notice, this list of conditions and the following -* disclaimer. -* -* - Redistributions in binary form must reproduce the above -* copyright notice, this list of conditions and the following -* disclaimer in the documentation and/or other materials -* provided with the distribution. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -* SOFTWARE. -*/ - -static inline -void streaming_put_latency_ctx(int len, perf_metrics_t *metric_info, int streaming_node) -{ - double start = 0.0, end = 0.0; - unsigned long int i; - int dest = partner_node(metric_info); - static int check_once = 0; - - if (!check_once) { - /* check to see whether sender and receiver are the same process */ - if (dest == metric_info->my_node) { - fprintf(stderr, "Warning: Sender and receiver are the same " - "process (%d)\n", dest); - } - /* hostname validation for all sender and receiver processes */ - int status = check_hostname_validation(metric_info); - if (status != 0) return; - check_once++; - } - - shmem_barrier_all(); - - if (streaming_node) { -#pragma omp parallel default(none) firstprivate(len, dest) private(i) \ -shared(metric_info, start, end) num_threads(metric_info->nthreads) - { - const int thread_id = omp_get_thread_num(); - shmem_ctx_t ctx; - int err = shmem_ctx_create(SHMEM_CTX_PRIVATE, &ctx); - - if (err) { - printf("PE %d, Thr. %d: Error, context creation failed\n", - metric_info->my_node, thread_id); - /* Exit with success to avoid test failures in automated testing */ - shmem_global_exit(0); - } - - for (i = 0; i < metric_info->warmup; i++) { -#ifdef USE_NONBLOCKING_API - shmem_ctx_putmem_nbi(ctx, metric_info->dest + thread_id * len, - metric_info->src + thread_id * len, len, dest); -#else - shmem_ctx_putmem(ctx, metric_info->dest + thread_id * len, - metric_info->src + thread_id * len, len, dest); -#endif - shmem_ctx_quiet(ctx); - } - shmem_ctx_destroy(ctx); - } - } - - shmem_barrier_all(); - if (streaming_node) { -#pragma omp parallel default(none) firstprivate(len, dest) private(i) \ -shared(metric_info, start, end) num_threads(metric_info->nthreads) - { - const int thread_id = omp_get_thread_num(); - shmem_ctx_t ctx; - int err = shmem_ctx_create(SHMEM_CTX_PRIVATE, &ctx); - - if (err) { - printf("PE %d, Thr. %d: Error, context creation failed\n", - metric_info->my_node, thread_id); - /* Exit with success to avoid test failures in automated testing */ - shmem_global_exit(0); - } - -#pragma omp barrier -#pragma omp master - { - start = perf_shmemx_wtime(); - } - - for (i = 0; i < metric_info->trials; i++) { -#ifdef USE_NONBLOCKING_API - shmem_ctx_putmem_nbi(ctx, metric_info->dest + thread_id * len, - metric_info->src + thread_id * len, len, dest); -#else - shmem_ctx_putmem(ctx, metric_info->dest + thread_id * len, - metric_info->src + thread_id * len, len, dest); -#endif - shmem_ctx_quiet(ctx); - } - shmem_ctx_destroy(ctx); - } - } - - shmem_barrier_all(); - if (streaming_node) { - end = perf_shmemx_wtime(); - calc_and_print_results(start, end, len, metric_info); - } - - shmem_barrier_all(); -} - -static inline -void streaming_get_latency_ctx(int len, perf_metrics_t *metric_info, int streaming_node) -{ - double start = 0.0, end = 0.0; - unsigned long int i; - int dest = partner_node(metric_info); - static int check_once = 0; - - if (!check_once) { - /* check to see whether sender and receiver are the same process */ - if (dest == metric_info->my_node) { - fprintf(stderr, "Warning: Sender and receiver are the same " - "process (%d)\n", dest); - } - /* hostname validation for all sender and receiver processes */ - int status = check_hostname_validation(metric_info); - if (status != 0) return; - check_once++; - } - - shmem_barrier_all(); - - if (streaming_node) { -#pragma omp parallel default(none) firstprivate(len, dest) private(i) \ -shared(metric_info, start, end) num_threads(metric_info->nthreads) - { - const int thread_id = omp_get_thread_num(); - shmem_ctx_t ctx; - int err = shmem_ctx_create(SHMEM_CTX_PRIVATE, &ctx); - - if (err) { - printf("PE %d, Thr. %d: Error, context creation failed\n", - metric_info->my_node, thread_id); - /* Exit with success to avoid test failures in automated testing */ - shmem_global_exit(0); - } - - for (i = 0; i < metric_info->warmup; i++) { -#ifdef USE_NONBLOCKING_API - shmem_ctx_getmem_nbi(ctx, metric_info->dest + thread_id * len, - metric_info->src + thread_id * len, len, dest); - shmem_ctx_quiet(ctx); -#else - shmem_ctx_getmem(ctx, metric_info->dest + thread_id * len, - metric_info->src + thread_id * len, len, dest); -#endif - } - shmem_ctx_destroy(ctx); - } - } - - shmem_barrier_all(); - if (streaming_node) { -#pragma omp parallel default(none) firstprivate(len, dest) private(i) \ -shared(metric_info, start, end) num_threads(metric_info->nthreads) - { - const int thread_id = omp_get_thread_num(); - shmem_ctx_t ctx; - int err = shmem_ctx_create(SHMEM_CTX_PRIVATE, &ctx); - - if (err) { - printf("PE %d, Thr. %d: Error, context creation failed\n", - metric_info->my_node, thread_id); - /* Exit with success to avoid test failures in automated testing */ - shmem_global_exit(0); - } - -#pragma omp barrier -#pragma omp master - { - start = perf_shmemx_wtime(); - } - - for (i = 0; i < metric_info->trials; i++) { -#ifdef USE_NONBLOCKING_API - shmem_ctx_getmem_nbi(ctx, metric_info->dest + thread_id * len, - metric_info->src + thread_id * len, len, dest); - shmem_ctx_quiet(ctx); -#else - shmem_ctx_getmem(ctx, metric_info->dest + thread_id * len, - metric_info->src + thread_id * len, len, dest); -#endif - } - shmem_ctx_destroy(ctx); - } - } - - shmem_barrier_all(); - if (streaming_node) { - end = perf_shmemx_wtime(); - calc_and_print_results(start, end, len, metric_info); - } - - shmem_barrier_all(); -} diff --git a/test/performance/shmem_perf_suite/round_t_latency.h b/test/performance/shmem_perf_suite/round_t_latency.h deleted file mode 100644 index bcfa9a8bc..000000000 --- a/test/performance/shmem_perf_suite/round_t_latency.h +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (c) 2018 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -static inline -void long_element_round_trip_latency_get(perf_metrics_t * const metric_info) -{ - double start = 0.0; - double end = 0.0; - int dest = partner_node(metric_info); - int receiver = (metric_info->num_pes != 1) ? streaming_node(metric_info) : true; - *metric_info->target = metric_info->my_node; - static int check_once = 0; - - if (!check_once) { - /* check to see whether sender and receiver are the same process */ - if (dest == metric_info->my_node) { - fprintf(stderr, "Warning: Sender and receiver are the same process (%d)\n", - dest); - } - /* hostname validation for all sender and receiver processes */ - int status = check_hostname_validation(metric_info); - if (status != 0) return; - check_once++; - } - - if (metric_info->my_node == 0) { - printf("shmem_long_g results:\n"); - print_latency_header(); - } - - shmem_barrier_all(); - - if (receiver) { - unsigned int i; - for (i = 0; i < metric_info->trials + metric_info->warmup; i++) { - if(i == metric_info->warmup) - start = perf_shmemx_wtime(); - - *metric_info->target = shmem_long_g(metric_info->target, dest); - } - end = perf_shmemx_wtime(); - - calc_and_print_results(start, end, sizeof(long), metric_info); - - if(metric_info->validate) { - if(*metric_info->target != dest) - printf("validation error shmem_long_g target = %ld != %d\n", - *metric_info->target, dest); - } - } -} /*gauge small get pathway round trip latency*/ - -static inline -void long_element_round_trip_latency_put(perf_metrics_t * const metric_info) -{ - double start = 0.0; - double end = 0.0; - long tmp; - int dest = partner_node(metric_info); - int sender = (metric_info->num_pes != 1) ? streaming_node(metric_info) : true; - unsigned int i; - tmp = *metric_info->target = INIT_VALUE; - static int check_once = 0; - - if (!check_once) { - /* check to see whether sender and receiver are the same process */ - if (dest == metric_info->my_node) { - fprintf(stderr, "Warning: Sender and receiver are the same process (%d)\n", - dest); - } - /* hostname validation for all sender and receiver processes */ - int status = check_hostname_validation(metric_info); - if (status != 0) return; - check_once++; - } - - if (metric_info->my_node == 0) { - printf("Ping-Pong shmem_long_p results:\n"); - print_latency_header(); - } - - shmem_barrier_all(); - - if (sender) { - for (i = 0; i < metric_info->trials + metric_info->warmup; i++) { - if(i == metric_info->warmup) - start = perf_shmemx_wtime(); - - shmem_long_atomic_set(metric_info->target, ++tmp, dest); - shmem_long_wait_until(metric_info->target, SHMEM_CMP_EQ, tmp); - } - end = perf_shmemx_wtime(); - metric_info->trials = metric_info->trials * 2; /*output half to get single round trip time*/ - calc_and_print_results(start, end, sizeof(long), metric_info); - - } else { - for (i = 0; i < metric_info->trials + metric_info->warmup; i++) { - shmem_long_wait_until(metric_info->target, SHMEM_CMP_EQ, ++tmp); - shmem_long_atomic_set(metric_info->target, tmp, dest); - } - } - -} /* gauge small put pathway round trip latency */ diff --git a/test/performance/shmem_perf_suite/shmem_bibw_atomics_perf.c b/test/performance/shmem_perf_suite/shmem_bibw_atomics_perf.c deleted file mode 100644 index 2347cfd62..000000000 --- a/test/performance/shmem_perf_suite/shmem_bibw_atomics_perf.c +++ /dev/null @@ -1,314 +0,0 @@ -/* - * Copyright (c) 2018 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* -** -** This is a bandwidth centric test for atomic operations -** -** Features of Test: bi-directional bandwidth -** -** -by default megabytes/second results -** -*/ - -#include - -#define bi_bw(metric_info, NAME, TYPE, op) \ - do { \ - double start = 0.0, end = 0.0; \ - unsigned long int i = 0, j = 0, num_itr = metric_info->trials + metric_info->warmup; \ - int snode = streaming_node(metric_info); \ - int dest = partner_node(metric_info); \ - shmem_barrier_all(); \ - \ - switch(op) { \ - case OP_SET: \ - for(i = 0; i < num_itr; i++) { \ - if (i == metric_info->warmup) { \ - shmem_barrier_all(); \ - if (snode) \ - start = perf_shmemx_wtime(); \ - } \ - \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_set( \ - (TYPE *)(metric_info->dest), ONE, dest); \ - \ - shmem_quiet(); \ - } \ - if(snode) \ - end = perf_shmemx_wtime(); \ - break; \ - case OP_AND: \ - for(i = 0; i < num_itr; i++) { \ - if (i == metric_info->warmup) { \ - shmem_barrier_all(); \ - if (snode) \ - start = perf_shmemx_wtime(); \ - } \ - \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_and( \ - (TYPE *)(metric_info->dest), ONE, dest); \ - \ - shmem_quiet(); \ - } \ - if(snode) \ - end = perf_shmemx_wtime(); \ - break; \ - case OP_OR: \ - for(i = 0; i < num_itr; i++) { \ - if (i == metric_info->warmup) { \ - shmem_barrier_all(); \ - if (snode) \ - start = perf_shmemx_wtime(); \ - } \ - \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_or( \ - (TYPE *)(metric_info->dest), ONE, dest); \ - \ - shmem_quiet(); \ - } \ - if(snode) \ - end = perf_shmemx_wtime(); \ - break; \ - case OP_XOR: \ - for(i = 0; i < num_itr; i++) { \ - if (i == metric_info->warmup) { \ - shmem_barrier_all(); \ - if (snode) \ - start = perf_shmemx_wtime(); \ - } \ - \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_xor( \ - (TYPE *)(metric_info->dest), ONE, dest); \ - \ - shmem_quiet(); \ - } \ - if(snode) \ - end = perf_shmemx_wtime(); \ - break; \ - case OP_ADD: \ - for(i = 0; i < num_itr; i++) { \ - if (i == metric_info->warmup) { \ - shmem_barrier_all(); \ - if (snode) \ - start = perf_shmemx_wtime(); \ - } \ - \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_add( \ - (TYPE *)(metric_info->dest), ONE, dest); \ - \ - shmem_quiet(); \ - } \ - if(snode) \ - end = perf_shmemx_wtime(); \ - break; \ - case OP_INC: \ - for(i = 0; i < num_itr; i++) { \ - if (i == metric_info->warmup) { \ - shmem_barrier_all(); \ - if (snode) \ - start = perf_shmemx_wtime(); \ - } \ - \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_inc( \ - (TYPE *)(metric_info->dest), dest); \ - \ - shmem_quiet(); \ - } \ - if(snode) \ - end = perf_shmemx_wtime(); \ - break; \ - case OP_FETCH: \ - for(i = 0; i < num_itr; i++) { \ - if (i == metric_info->warmup) { \ - shmem_barrier_all(); \ - if (snode) \ - start = perf_shmemx_wtime(); \ - } \ - \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_fetch( \ - (TYPE *)(metric_info->dest), dest); \ - } \ - if(snode) \ - end = perf_shmemx_wtime(); \ - break; \ - case OP_FAND: \ - for(i = 0; i < num_itr; i++) { \ - if (i == metric_info->warmup) { \ - shmem_barrier_all(); \ - if (snode) \ - start = perf_shmemx_wtime(); \ - } \ - \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_fetch_and( \ - (TYPE *)(metric_info->dest), ONE, dest); \ - } \ - if(snode) \ - end = perf_shmemx_wtime(); \ - break; \ - case OP_FOR: \ - for(i = 0; i < num_itr; i++) { \ - if (i == metric_info->warmup) { \ - shmem_barrier_all(); \ - if (snode) \ - start = perf_shmemx_wtime(); \ - } \ - \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_fetch_or( \ - (TYPE *)(metric_info->dest), ONE, dest); \ - } \ - if(snode) \ - end = perf_shmemx_wtime(); \ - break; \ - case OP_FXOR: \ - for(i = 0; i < num_itr; i++) { \ - if (i == metric_info->warmup) { \ - shmem_barrier_all(); \ - if (snode) \ - start = perf_shmemx_wtime(); \ - } \ - \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_fetch_xor( \ - (TYPE *)(metric_info->dest), ONE, dest); \ - } \ - if(snode) \ - end = perf_shmemx_wtime(); \ - break; \ - case OP_FADD: \ - for(i = 0; i < num_itr; i++) { \ - if (i == metric_info->warmup) { \ - shmem_barrier_all(); \ - if (snode) \ - start = perf_shmemx_wtime(); \ - } \ - \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_fetch_add( \ - (TYPE *)(metric_info->dest), ONE, dest); \ - } \ - if(snode) \ - end = perf_shmemx_wtime(); \ - break; \ - case OP_FINC: \ - for(i = 0; i < num_itr; i++) { \ - if (i == metric_info->warmup) { \ - shmem_barrier_all(); \ - if (snode) \ - start = perf_shmemx_wtime(); \ - } \ - \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_fetch_inc( \ - (TYPE *)(metric_info->dest), dest); \ - } \ - if(snode) \ - end = perf_shmemx_wtime(); \ - break; \ - case OP_SWAP: \ - for(i = 0; i < num_itr; i++) { \ - if (i == metric_info->warmup) { \ - shmem_barrier_all(); \ - if (snode) \ - start = perf_shmemx_wtime(); \ - } \ - \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_swap( \ - (TYPE *)(metric_info->src), ONE, dest); \ - } \ - if(snode) \ - end = perf_shmemx_wtime(); \ - break; \ - case OP_CSWAP: \ - for(i = 0; i < num_itr; i++) { \ - if (i == metric_info->warmup) { \ - shmem_barrier_all(); \ - if (snode) \ - start = perf_shmemx_wtime(); \ - } \ - \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_compare_swap( \ - (TYPE *)(metric_info->src), dest, ONE, dest); \ - } \ - if(snode) \ - end = perf_shmemx_wtime(); \ - break; \ - default: \ - fprintf(stderr, "Error %d not a valid op case \ - for atomics\n", op); \ - break; \ - } \ - if(snode) \ - calc_and_print_results(end, start, metric_info->start_len, metric_info); \ - } while(0) - -static inline void bw_set_metric_info_len(perf_metrics_t * const metric_info) -{ - atomic_op_type op_type; - - for (op_type = 0; op_type < LAST_OP; op_type++) { - if(metric_info->my_node == 0) { - printf("\nshmem_%s\n", atomic_op_name[op_type]); - printf("-----------\n"); - } - - metric_info->start_len = sizeof(unsigned int); - shmem_barrier_all(); - bi_bw(metric_info, uint, unsigned int, op_type); - - metric_info->start_len = sizeof(unsigned long); - shmem_barrier_all(); - bi_bw(metric_info, ulong, unsigned long, op_type); - - metric_info->start_len = sizeof(unsigned long long); - shmem_barrier_all(); - bi_bw(metric_info, ulonglong, unsigned long long, op_type); - } -} - -void bi_dir_bw(int len, perf_metrics_t * const metric_info) -{ - bw_set_metric_info_len(metric_info); -} - -int main(int argc, char *argv[]) -{ - bi_dir_bw_main(argc, argv, STYLE_ATOMIC); - - return 0; -} diff --git a/test/performance/shmem_perf_suite/shmem_bibw_get_perf.c b/test/performance/shmem_perf_suite/shmem_bibw_get_perf.c deleted file mode 100644 index bdf0f1779..000000000 --- a/test/performance/shmem_perf_suite/shmem_bibw_get_perf.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2018 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* -** -** This is a bandwidth centric test for get: back-to-back message rate -** -** Features of Test: bi-direction bandwidth -** -** -by default megabytes/second results -** -*/ - -#include -#include - -int main(int argc, char *argv[]) -{ - bi_dir_bw_main(argc, argv, STYLE_GET); - - return 0; -} /* end of main() */ - -void -bi_dir_bw(int len, perf_metrics_t * const metric_info) -{ - bi_bw_get(len, metric_info); -} diff --git a/test/performance/shmem_perf_suite/shmem_bibw_nb_atomics_perf.c b/test/performance/shmem_perf_suite/shmem_bibw_nb_atomics_perf.c deleted file mode 100644 index 05c46e6a0..000000000 --- a/test/performance/shmem_perf_suite/shmem_bibw_nb_atomics_perf.c +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Copyright (c) 2018 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* -** -** This is a bandwidth centric test for non-blocking atomic operations -** -** Features of Test: bi-directional bandwidth -** -** -by default megabytes/second results -** -*/ - -#include - -#define bi_bw(metric_info, NAME, TYPE, op) \ - do { \ - double start = 0.0, end = 0.0; \ - unsigned long int i = 0, j = 0, num_itr = metric_info->trials + metric_info->warmup; \ - int snode = streaming_node(metric_info); \ - int dest = partner_node(metric_info); \ - TYPE fetch; \ - shmem_barrier_all(); \ - \ - switch(op) { \ - case OP_FETCH: \ - for(i = 0; i < num_itr; i++) { \ - if (i == metric_info->warmup) { \ - shmem_barrier_all(); \ - if (snode) \ - start = perf_shmemx_wtime(); \ - } \ - \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_fetch_nbi((TYPE *) &fetch, \ - (TYPE *)(metric_info->dest), dest); \ - shmem_quiet(); \ - } \ - if(snode) \ - end = perf_shmemx_wtime(); \ - break; \ - case OP_FAND: \ - for(i = 0; i < num_itr; i++) { \ - if (i == metric_info->warmup) { \ - shmem_barrier_all(); \ - if (snode) \ - start = perf_shmemx_wtime(); \ - } \ - \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_fetch_and_nbi((TYPE *) &fetch, \ - (TYPE *)(metric_info->dest), ONE, dest); \ - shmem_quiet(); \ - } \ - if(snode) \ - end = perf_shmemx_wtime(); \ - break; \ - case OP_FOR: \ - for(i = 0; i < num_itr; i++) { \ - if (i == metric_info->warmup) { \ - shmem_barrier_all(); \ - if (snode) \ - start = perf_shmemx_wtime(); \ - } \ - \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_fetch_or_nbi((TYPE *) &fetch, \ - (TYPE *)(metric_info->dest), ONE, dest); \ - shmem_quiet(); \ - } \ - if(snode) \ - end = perf_shmemx_wtime(); \ - break; \ - case OP_FXOR: \ - for(i = 0; i < num_itr; i++) { \ - if (i == metric_info->warmup) { \ - shmem_barrier_all(); \ - if (snode) \ - start = perf_shmemx_wtime(); \ - } \ - \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_fetch_xor_nbi((TYPE *) &fetch, \ - (TYPE *)(metric_info->dest), ONE, dest); \ - shmem_quiet(); \ - } \ - if(snode) \ - end = perf_shmemx_wtime(); \ - break; \ - case OP_FADD: \ - for(i = 0; i < num_itr; i++) { \ - if (i == metric_info->warmup) { \ - shmem_barrier_all(); \ - if (snode) \ - start = perf_shmemx_wtime(); \ - } \ - \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_fetch_add_nbi((TYPE *) &fetch, \ - (TYPE *)(metric_info->dest), ONE, dest); \ - shmem_quiet(); \ - } \ - if(snode) \ - end = perf_shmemx_wtime(); \ - break; \ - case OP_FINC: \ - for(i = 0; i < num_itr; i++) { \ - if (i == metric_info->warmup) { \ - shmem_barrier_all(); \ - if (snode) \ - start = perf_shmemx_wtime(); \ - } \ - \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_fetch_inc_nbi((TYPE *) &fetch, \ - (TYPE *)(metric_info->dest), dest); \ - shmem_quiet(); \ - } \ - if(snode) \ - end = perf_shmemx_wtime(); \ - break; \ - case OP_SWAP: \ - for(i = 0; i < num_itr; i++) { \ - if (i == metric_info->warmup) { \ - shmem_barrier_all(); \ - if (snode) \ - start = perf_shmemx_wtime(); \ - } \ - \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_swap_nbi((TYPE *) &fetch, \ - (TYPE *)(metric_info->src), ONE, dest); \ - shmem_quiet(); \ - } \ - if(snode) \ - end = perf_shmemx_wtime(); \ - break; \ - case OP_CSWAP: \ - for(i = 0; i < num_itr; i++) { \ - if (i == metric_info->warmup) { \ - shmem_barrier_all(); \ - if (snode) \ - start = perf_shmemx_wtime(); \ - } \ - \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_compare_swap_nbi((TYPE *) &fetch, \ - (TYPE *)(metric_info->src), dest, ONE, dest); \ - shmem_quiet(); \ - } \ - if(snode) \ - end = perf_shmemx_wtime(); \ - break; \ - default: \ - fprintf(stderr, "Error %d not a valid op case \ - for atomics\n", op); \ - break; \ - } \ - if(snode) \ - calc_and_print_results(end, start, metric_info->start_len, metric_info); \ - } while(0) - -static inline void bw_set_metric_info_len(perf_metrics_t * const metric_info) -{ - atomic_op_type op_type; - - for (op_type = FIRST_FETCH_OP; op_type < LAST_OP; op_type++) { - if(metric_info->my_node == 0) { - printf("\nshmem_%s\n", atomic_op_name[op_type]); - printf("-----------\n"); - } - - metric_info->start_len = sizeof(unsigned int); - shmem_barrier_all(); - bi_bw(metric_info, uint, unsigned int, op_type); - - metric_info->start_len = sizeof(unsigned long); - shmem_barrier_all(); - bi_bw(metric_info, ulong, unsigned long, op_type); - - metric_info->start_len = sizeof(unsigned long long); - shmem_barrier_all(); - bi_bw(metric_info, ulonglong, unsigned long long, op_type); - } -} - -void bi_dir_bw(int len, perf_metrics_t * const metric_info) -{ - bw_set_metric_info_len(metric_info); -} - -int main(int argc, char *argv[]) -{ - bi_dir_bw_main(argc, argv, STYLE_ATOMIC); - - return 0; -} diff --git a/test/performance/shmem_perf_suite/shmem_bibw_put_ctx_perf.c b/test/performance/shmem_perf_suite/shmem_bibw_put_ctx_perf.c deleted file mode 100644 index a6b6564aa..000000000 --- a/test/performance/shmem_perf_suite/shmem_bibw_put_ctx_perf.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2018 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* -** -** This is a bandwidth centric test for put: back-to-back message rate -** -** Features of Test: bi-direction bandwidth -** -** -by default megabytes/second results -** -*/ - -#define ENABLE_OPENMP - -#include -#include - -int main(int argc, char *argv[]) -{ - bi_dir_bw_main(argc, argv, STYLE_PUT); - - return 0; -} - -void -bi_dir_bw(int len, perf_metrics_t * const metric_info) -{ - bi_bw_ctx(len, metric_info); -} diff --git a/test/performance/shmem_perf_suite/shmem_bibw_put_perf.c b/test/performance/shmem_perf_suite/shmem_bibw_put_perf.c deleted file mode 100644 index 279536a4e..000000000 --- a/test/performance/shmem_perf_suite/shmem_bibw_put_perf.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2018 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* -** -** This is a bandwidth centric test for put: back-to-back message rate -** -** Features of Test: bi-direction bandwidth -** -** -by default megabytes/second results -** -*/ - -#include -#include - -int main(int argc, char *argv[]) -{ - bi_dir_bw_main(argc, argv, STYLE_PUT); - - return 0; -} - -void -bi_dir_bw(int len, perf_metrics_t * const metric_info) -{ - bi_bw_put(len, metric_info); -} diff --git a/test/performance/shmem_perf_suite/shmem_bw_atomics_perf.c b/test/performance/shmem_perf_suite/shmem_bw_atomics_perf.c deleted file mode 100644 index 2164f00a6..000000000 --- a/test/performance/shmem_perf_suite/shmem_bw_atomics_perf.c +++ /dev/null @@ -1,382 +0,0 @@ -/* - * Copyright (c) 2018 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* -** -** This is a bandwidth centric test for atomic operations -** -** Features of Test: uni-directional bandwidth -** -** -by default megabytes/second results -** -*/ -#include - -#define uni_bw(metric_info, NAME, TYPE, op) \ - do { \ - double start = 0.0, end = 0.0; \ - unsigned long int i = 0, j = 0; \ - int snode = streaming_node(metric_info); \ - int dest = partner_node(metric_info); \ - shmem_barrier_all(); \ - \ - switch(op) { \ - case OP_SET: \ - if(snode) { \ - for(i = 0; i < metric_info->warmup; i++) { \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_set( \ - (TYPE *)(metric_info->dest), ONE, dest); \ - \ - shmem_quiet(); \ - } \ - } \ - shmem_barrier_all(); \ - if(snode) { \ - start = perf_shmemx_wtime(); \ - for(i = 0; i < metric_info->trials; i++) { \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_set( \ - (TYPE *)(metric_info->dest), ONE, dest); \ - \ - shmem_quiet(); \ - } \ - end = perf_shmemx_wtime(); \ - } \ - break; \ - case OP_AND: \ - if(snode) { \ - for(i = 0; i < metric_info->warmup; i++) { \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_and( \ - (TYPE *)(metric_info->dest), ONE, dest); \ - \ - shmem_quiet(); \ - } \ - } \ - shmem_barrier_all(); \ - if(snode) { \ - start = perf_shmemx_wtime(); \ - for(i = 0; i < metric_info->trials; i++) { \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_and( \ - (TYPE *)(metric_info->dest), ONE, dest); \ - \ - shmem_quiet(); \ - } \ - end = perf_shmemx_wtime(); \ - } \ - break; \ - case OP_OR: \ - if(snode) { \ - for(i = 0; i < metric_info->warmup; i++) { \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_or( \ - (TYPE *)(metric_info->dest), ONE, dest); \ - \ - shmem_quiet(); \ - } \ - } \ - shmem_barrier_all(); \ - if(snode) { \ - start = perf_shmemx_wtime(); \ - for(i = 0; i < metric_info->trials; i++) { \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_or( \ - (TYPE *)(metric_info->dest), ONE, dest); \ - \ - shmem_quiet(); \ - } \ - end = perf_shmemx_wtime(); \ - } \ - break; \ - case OP_XOR: \ - if(snode) { \ - for(i = 0; i < metric_info->warmup; i++) { \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_xor( \ - (TYPE *)(metric_info->dest), ONE, dest); \ - \ - shmem_quiet(); \ - } \ - } \ - shmem_barrier_all(); \ - if(snode) { \ - start = perf_shmemx_wtime(); \ - for(i = 0; i < metric_info->trials; i++) { \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_xor( \ - (TYPE *)(metric_info->dest), ONE, dest); \ - \ - shmem_quiet(); \ - } \ - end = perf_shmemx_wtime(); \ - } \ - break; \ - case OP_ADD: \ - if(snode) { \ - for(i = 0; i < metric_info->warmup; i++) { \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_add( \ - (TYPE *)(metric_info->dest), ONE, dest); \ - \ - shmem_quiet(); \ - } \ - } \ - shmem_barrier_all(); \ - if(snode) { \ - start = perf_shmemx_wtime(); \ - for(i = 0; i < metric_info->trials; i++) { \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_add( \ - (TYPE *)(metric_info->dest), ONE, dest); \ - \ - shmem_quiet(); \ - } \ - end = perf_shmemx_wtime(); \ - } \ - break; \ - case OP_INC: \ - if(snode) { \ - for(i = 0; i < metric_info->warmup; i++) { \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_inc( \ - (TYPE *)(metric_info->dest), dest); \ - \ - shmem_quiet(); \ - } \ - } \ - shmem_barrier_all(); \ - if(snode) { \ - start = perf_shmemx_wtime(); \ - for(i = 0; i < metric_info->trials; i++) { \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_inc( \ - (TYPE *)(metric_info->dest), dest); \ - \ - shmem_quiet(); \ - } \ - end = perf_shmemx_wtime(); \ - } \ - break; \ - case OP_FETCH: \ - if(snode) { \ - for(i = 0; i < metric_info->warmup; i++) { \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_fetch( \ - (TYPE *)(metric_info->dest), dest); \ - } \ - } \ - shmem_barrier_all(); \ - if(snode) { \ - start = perf_shmemx_wtime(); \ - for(i = 0; i < metric_info->trials; i++) { \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_fetch( \ - (TYPE *)(metric_info->dest), dest); \ - } \ - end = perf_shmemx_wtime(); \ - } \ - break; \ - case OP_FAND: \ - if(snode) { \ - for(i = 0; i < metric_info->warmup; i++) { \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_fetch_and( \ - (TYPE *)(metric_info->dest), ONE, dest); \ - } \ - } \ - shmem_barrier_all(); \ - if(snode) { \ - start = perf_shmemx_wtime(); \ - for(i = 0; i < metric_info->trials; i++) { \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_fetch_and( \ - (TYPE *)(metric_info->dest), ONE, dest); \ - } \ - end = perf_shmemx_wtime(); \ - } \ - break; \ - case OP_FOR: \ - if(snode) { \ - for(i = 0; i < metric_info->warmup; i++) { \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_fetch_or( \ - (TYPE *)(metric_info->dest), ONE, dest); \ - } \ - } \ - shmem_barrier_all(); \ - if(snode) { \ - start = perf_shmemx_wtime(); \ - for(i = 0; i < metric_info->trials; i++) { \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_fetch_or( \ - (TYPE *)(metric_info->dest), ONE, dest); \ - } \ - end = perf_shmemx_wtime(); \ - } \ - break; \ - case OP_FXOR: \ - if(snode) { \ - for(i = 0; i < metric_info->warmup; i++) { \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_fetch_xor( \ - (TYPE *)(metric_info->dest), ONE, dest); \ - } \ - } \ - shmem_barrier_all(); \ - if(snode) { \ - start = perf_shmemx_wtime(); \ - for(i = 0; i < metric_info->trials; i++) { \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_fetch_xor( \ - (TYPE *)(metric_info->dest), ONE, dest); \ - } \ - end = perf_shmemx_wtime(); \ - } \ - break; \ - case OP_FADD: \ - if(snode) { \ - for(i = 0; i < metric_info->warmup; i++) { \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_fetch_add( \ - (TYPE *)(metric_info->dest), ONE, dest); \ - } \ - } \ - shmem_barrier_all(); \ - if(snode) { \ - start = perf_shmemx_wtime(); \ - for(i = 0; i < metric_info->trials; i++) { \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_fetch_add( \ - (TYPE *)(metric_info->dest), ONE, dest); \ - } \ - end = perf_shmemx_wtime(); \ - } \ - break; \ - case OP_FINC: \ - if(snode) { \ - for(i = 0; i < metric_info->warmup; i++) { \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_fetch_inc( \ - (TYPE *)(metric_info->dest), dest); \ - } \ - } \ - shmem_barrier_all(); \ - if(snode) { \ - start = perf_shmemx_wtime(); \ - for(i = 0; i < metric_info->trials; i++) { \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_fetch_inc( \ - (TYPE *)(metric_info->dest), dest); \ - } \ - end = perf_shmemx_wtime(); \ - } \ - break; \ - case OP_SWAP: \ - if(snode) { \ - for(i = 0; i < metric_info->warmup; i++) { \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_swap( \ - (TYPE *)(metric_info->src), ONE, dest); \ - } \ - } \ - shmem_barrier_all(); \ - if(snode) { \ - start = perf_shmemx_wtime(); \ - for(i = 0; i < metric_info->trials; i++) { \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_swap( \ - (TYPE *)(metric_info->src), ONE, dest); \ - } \ - end = perf_shmemx_wtime(); \ - } \ - break; \ - case OP_CSWAP: \ - if(snode) { \ - for(i = 0; i < metric_info->warmup; i++) { \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_compare_swap( \ - (TYPE *)(metric_info->src), dest, ONE, dest); \ - } \ - } \ - shmem_barrier_all(); \ - if(snode) { \ - start = perf_shmemx_wtime(); \ - for(i = 0; i < metric_info->trials; i++) { \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_compare_swap( \ - (TYPE *)(metric_info->src), dest, ONE, dest); \ - } \ - end = perf_shmemx_wtime(); \ - } \ - break; \ - default: \ - fprintf(stderr, "Error %d not a valid op case \ - for atomics\n", op); \ - break; \ - } \ - if(snode) { \ - calc_and_print_results(end, start, metric_info->start_len, metric_info); \ - } \ - } while(0) - -static inline void bw_set_metric_info_len(perf_metrics_t * const metric_info) -{ - atomic_op_type op_type; - - for (op_type = 0; op_type < LAST_OP; op_type++) { - if(metric_info->my_node == 0) { - printf("\nshmem_%s\n", atomic_op_name[op_type]); - printf("-----------\n"); - } - - metric_info->start_len = sizeof(unsigned int); - shmem_barrier_all(); - uni_bw(metric_info, uint, unsigned int, op_type); - - metric_info->start_len = sizeof(unsigned long); - shmem_barrier_all(); - uni_bw(metric_info, ulong, unsigned long, op_type); - - metric_info->start_len = sizeof(unsigned long long); - shmem_barrier_all(); - uni_bw(metric_info, ulonglong, unsigned long long, op_type); - } -} - -void uni_dir_bw(int len, perf_metrics_t * const metric_info) -{ - bw_set_metric_info_len(metric_info); -} - -int main(int argc, char *argv[]) -{ - uni_dir_bw_main(argc, argv, STYLE_ATOMIC); - - return 0; -} diff --git a/test/performance/shmem_perf_suite/shmem_bw_get_perf.c b/test/performance/shmem_perf_suite/shmem_bw_get_perf.c deleted file mode 100644 index 105558bf8..000000000 --- a/test/performance/shmem_perf_suite/shmem_bw_get_perf.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2018 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* -** -** This is a bandwidth centric test for get: back-to-back message rate -** -** Features of Test: uni-directional bandwidth -** -** -by default megabytes/second results -** -*/ - -#include -#include - -int main(int argc, char *argv[]) -{ - uni_dir_bw_main(argc,argv, STYLE_GET); - - return 0; -} /* end of main() */ - -void -uni_dir_bw(int len, perf_metrics_t * const metric_info) -{ - uni_bw_get(len, metric_info); -} - diff --git a/test/performance/shmem_perf_suite/shmem_bw_nb_atomics_perf.c b/test/performance/shmem_perf_suite/shmem_bw_nb_atomics_perf.c deleted file mode 100644 index 3a1f1d06e..000000000 --- a/test/performance/shmem_perf_suite/shmem_bw_nb_atomics_perf.c +++ /dev/null @@ -1,261 +0,0 @@ -/* - * Copyright (c) 2018 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* -** -** This is a bandwidth centric test for nb atomic operations -** -** Features of Test: uni-directional bandwidth -** -** -by default megabytes/second results -** -*/ -#include - -#define uni_bw(metric_info, NAME, TYPE, op) \ - do { \ - double start = 0.0, end = 0.0; \ - unsigned long int i = 0, j = 0; \ - int snode = streaming_node(metric_info); \ - int dest = partner_node(metric_info); \ - TYPE fetch; \ - shmem_barrier_all(); \ - \ - switch(op) { \ - case OP_FETCH: \ - if(snode) { \ - for(i = 0; i < metric_info->warmup; i++) { \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_fetch_nbi((TYPE *) &fetch, \ - (TYPE *)(metric_info->dest), dest); \ - shmem_quiet(); \ - } \ - } \ - shmem_barrier_all(); \ - if(snode) { \ - start = perf_shmemx_wtime(); \ - for(i = 0; i < metric_info->trials; i++) { \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_fetch_nbi((TYPE *) &fetch, \ - (TYPE *)(metric_info->dest), dest); \ - shmem_quiet(); \ - } \ - end = perf_shmemx_wtime(); \ - } \ - break; \ - case OP_FAND: \ - if(snode) { \ - for(i = 0; i < metric_info->warmup; i++) { \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_fetch_and_nbi((TYPE *) &fetch, \ - (TYPE *)(metric_info->dest), ONE, dest); \ - shmem_quiet(); \ - } \ - } \ - shmem_barrier_all(); \ - if(snode) { \ - start = perf_shmemx_wtime(); \ - for(i = 0; i < metric_info->trials; i++) { \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_fetch_and_nbi((TYPE *) &fetch, \ - (TYPE *)(metric_info->dest), ONE, dest); \ - shmem_quiet(); \ - } \ - end = perf_shmemx_wtime(); \ - } \ - break; \ - case OP_FOR: \ - if(snode) { \ - for(i = 0; i < metric_info->warmup; i++) { \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_fetch_or_nbi((TYPE *) &fetch, \ - (TYPE *)(metric_info->dest), ONE, dest); \ - shmem_quiet(); \ - } \ - } \ - shmem_barrier_all(); \ - if(snode) { \ - start = perf_shmemx_wtime(); \ - for(i = 0; i < metric_info->trials; i++) { \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_fetch_or_nbi((TYPE *) &fetch, \ - (TYPE *)(metric_info->dest), ONE, dest); \ - shmem_quiet(); \ - } \ - end = perf_shmemx_wtime(); \ - } \ - break; \ - case OP_FXOR: \ - if(snode) { \ - for(i = 0; i < metric_info->warmup; i++) { \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_fetch_xor_nbi((TYPE *) &fetch, \ - (TYPE *)(metric_info->dest), ONE, dest); \ - shmem_quiet(); \ - } \ - } \ - shmem_barrier_all(); \ - if(snode) { \ - start = perf_shmemx_wtime(); \ - for(i = 0; i < metric_info->trials; i++) { \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_fetch_xor_nbi((TYPE *) &fetch, \ - (TYPE *)(metric_info->dest), ONE, dest); \ - shmem_quiet(); \ - } \ - end = perf_shmemx_wtime(); \ - } \ - break; \ - case OP_FADD: \ - if(snode) { \ - for(i = 0; i < metric_info->warmup; i++) { \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_fetch_add_nbi((TYPE *) &fetch, \ - (TYPE *)(metric_info->dest), ONE, dest); \ - shmem_quiet(); \ - } \ - } \ - shmem_barrier_all(); \ - if(snode) { \ - start = perf_shmemx_wtime(); \ - for(i = 0; i < metric_info->trials; i++) { \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_fetch_add_nbi((TYPE *) &fetch, \ - (TYPE *)(metric_info->dest), ONE, dest); \ - shmem_quiet(); \ - } \ - end = perf_shmemx_wtime(); \ - } \ - break; \ - case OP_FINC: \ - if(snode) { \ - for(i = 0; i < metric_info->warmup; i++) { \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_fetch_inc_nbi((TYPE *) &fetch, \ - (TYPE *)(metric_info->dest), dest); \ - shmem_quiet(); \ - } \ - } \ - shmem_barrier_all(); \ - if(snode) { \ - start = perf_shmemx_wtime(); \ - for(i = 0; i < metric_info->trials; i++) { \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_fetch_inc_nbi((TYPE *) &fetch, \ - (TYPE *)(metric_info->dest), dest); \ - shmem_quiet(); \ - } \ - end = perf_shmemx_wtime(); \ - } \ - break; \ - case OP_SWAP: \ - if(snode) { \ - for(i = 0; i < metric_info->warmup; i++) { \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_swap_nbi((TYPE *) &fetch, \ - (TYPE *)(metric_info->src), ONE, dest); \ - shmem_quiet(); \ - } \ - } \ - shmem_barrier_all(); \ - if(snode) { \ - start = perf_shmemx_wtime(); \ - for(i = 0; i < metric_info->trials; i++) { \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_swap_nbi((TYPE *) &fetch, \ - (TYPE *)(metric_info->src), ONE, dest); \ - shmem_quiet(); \ - } \ - end = perf_shmemx_wtime(); \ - } \ - break; \ - case OP_CSWAP: \ - if(snode) { \ - for(i = 0; i < metric_info->warmup; i++) { \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_compare_swap_nbi((TYPE *) &fetch, \ - (TYPE *)(metric_info->src), dest, ONE, dest); \ - shmem_quiet(); \ - } \ - } \ - shmem_barrier_all(); \ - if(snode) { \ - start = perf_shmemx_wtime(); \ - for(i = 0; i < metric_info->trials; i++) { \ - for(j = 0; j < metric_info->window_size; j++) \ - shmem_##NAME##_atomic_compare_swap_nbi((TYPE *) &fetch, \ - (TYPE *)(metric_info->src), dest, ONE, dest); \ - shmem_quiet(); \ - } \ - end = perf_shmemx_wtime(); \ - } \ - break; \ - default: \ - fprintf(stderr, "Error %d not a valid op case \ - for atomics\n", op); \ - break; \ - } \ - if(snode) { \ - calc_and_print_results(end, start, metric_info->start_len, metric_info); \ - } \ - } while(0) - -static inline void bw_set_metric_info_len(perf_metrics_t * const metric_info) -{ - atomic_op_type op_type; - - for (op_type = FIRST_FETCH_OP; op_type < LAST_OP; op_type++) { - if(metric_info->my_node == 0) { - printf("\nshmem_%s\n", atomic_op_name[op_type]); - printf("-----------\n"); - } - - metric_info->start_len = sizeof(unsigned int); - shmem_barrier_all(); - uni_bw(metric_info, uint, unsigned int, op_type); - - metric_info->start_len = sizeof(unsigned long); - shmem_barrier_all(); - uni_bw(metric_info, ulong, unsigned long, op_type); - - metric_info->start_len = sizeof(unsigned long long); - shmem_barrier_all(); - uni_bw(metric_info, ulonglong, unsigned long long, op_type); - } -} - -void uni_dir_bw(int len, perf_metrics_t * const metric_info) -{ - bw_set_metric_info_len(metric_info); -} - -int main(int argc, char *argv[]) -{ - uni_dir_bw_main(argc, argv, STYLE_ATOMIC); - - return 0; -} diff --git a/test/performance/shmem_perf_suite/shmem_bw_put_ctx_perf.c b/test/performance/shmem_perf_suite/shmem_bw_put_ctx_perf.c deleted file mode 100644 index 598da06c4..000000000 --- a/test/performance/shmem_perf_suite/shmem_bw_put_ctx_perf.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2018 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. -** -** This is a bandwidth centric test for put: back-to-back message rate -** -** Features of Test: uni-directional bandwidth using contexts driven by -** multiple threads. -** -** -by default megabytes/second results -** -*/ - -#define ENABLE_OPENMP - -#include -#include - -int main(int argc, char *argv[]) -{ - uni_dir_bw_main(argc, argv, STYLE_PUT); - - return 0; -} - -void -uni_dir_bw(int len, perf_metrics_t * const metric_info) -{ - uni_bw_ctx(len, metric_info, streaming_node(metric_info)); -} diff --git a/test/performance/shmem_perf_suite/shmem_bw_put_perf.c b/test/performance/shmem_perf_suite/shmem_bw_put_perf.c deleted file mode 100644 index ca5157199..000000000 --- a/test/performance/shmem_perf_suite/shmem_bw_put_perf.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2018 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* -** -** This is a bandwidth centric test for put: back-to-back message rate -** -** Features of Test: uni-directional bandwidth -** -** -by default megabytes/second results -** -*/ -#include -#include - -int main(int argc, char *argv[]) -{ - uni_dir_bw_main(argc, argv, STYLE_PUT); - - return 0; -} - -void -uni_dir_bw(int len, perf_metrics_t * const metric_info) -{ - uni_bw_put(len, metric_info); -} - diff --git a/test/performance/shmem_perf_suite/shmem_latency_get_ctx_perf.c b/test/performance/shmem_perf_suite/shmem_latency_get_ctx_perf.c deleted file mode 100644 index 6556f2030..000000000 --- a/test/performance/shmem_perf_suite/shmem_latency_get_ctx_perf.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2018 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. -** -** This is a latency test for get. -** -** Features of Test: latency using contexts driven by -** multiple threads. -** -** -in micro seconds -** -*/ - -#define ENABLE_OPENMP - -#include -#include - -int main(int argc, char *argv[]) -{ - latency_main_ctx(argc, argv, STYLE_GET); - - return 0; -} - -void -streaming_latency(int len, perf_metrics_t * const metric_info) -{ - streaming_get_latency_ctx(len, metric_info, streaming_node(metric_info)); -} diff --git a/test/performance/shmem_perf_suite/shmem_latency_get_perf.c b/test/performance/shmem_perf_suite/shmem_latency_get_perf.c deleted file mode 100644 index 523b19f18..000000000 --- a/test/performance/shmem_perf_suite/shmem_latency_get_perf.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2018 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* -** -** Notice: micro benchmark ~ two nodes only -** -** Features of Test: -** 1) small get latency test -** 2) getmem latency test to calculate latency of various sizes -** -*/ - -#include -#include -#include - -int main(int argc, char *argv[]) -{ - - latency_main(argc, argv, STYLE_GET); - - return 0; -} /* end of main() */ - - -void -long_element_round_trip_latency(perf_metrics_t * const data) -{ -#ifndef USE_NONBLOCKING_API - long_element_round_trip_latency_get(data); -#endif -} - -void -int_element_latency(perf_metrics_t * const data) -{ -#ifndef USE_NONBLOCKING_API - int_g_latency(data); -#endif -} - -void -streaming_latency(int len, perf_metrics_t * const metric_info) -{ - double start = 0.0; - double end = 0.0; - unsigned long int i = 0; - int dest = partner_node(metric_info); - int receiver = (metric_info->num_pes != 1) ? streaming_node(metric_info) : true; - static int check_once = 0; - - if (!check_once) { - /* check to see whether sender and receiver are the same process */ - if (dest == metric_info->my_node) { - fprintf(stderr, "Warning: Sender and receiver are the same process (%d)\n", - dest); - } - /* hostname validation for all sender and receiver processes */ - int status = check_hostname_validation(metric_info); - if (status != 0) return; - check_once++; - } - - shmem_barrier_all(); - if (receiver) { - - for (i = 0; i < metric_info->trials + metric_info->warmup; i++) { - if(i == metric_info->warmup) - start = perf_shmemx_wtime(); -#ifdef USE_NONBLOCKING_API - shmem_getmem_nbi(metric_info->dest, metric_info->src, len, dest); - shmem_quiet(); -#else - shmem_getmem(metric_info->dest, metric_info->src, len, dest); -#endif - } - end = perf_shmemx_wtime(); - - calc_and_print_results(start, end, len, metric_info); - } -} /* latency/bw for one-way trip */ diff --git a/test/performance/shmem_perf_suite/shmem_latency_put_ctx_perf.c b/test/performance/shmem_perf_suite/shmem_latency_put_ctx_perf.c deleted file mode 100644 index ffc62191b..000000000 --- a/test/performance/shmem_perf_suite/shmem_latency_put_ctx_perf.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2018 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. -** -** This is a latency test for put. -** -** Features of Test: latency using contexts driven by -** multiple threads. -** -** -in micro seconds -** -*/ - -#define ENABLE_OPENMP - -#include -#include - -int main(int argc, char *argv[]) -{ - latency_main_ctx(argc, argv, STYLE_PUT); - - return 0; -} - -void -streaming_latency(int len, perf_metrics_t * const metric_info) -{ - streaming_put_latency_ctx(len, metric_info, streaming_node(metric_info)); -} diff --git a/test/performance/shmem_perf_suite/shmem_latency_put_perf.c b/test/performance/shmem_perf_suite/shmem_latency_put_perf.c deleted file mode 100644 index 5cadc2116..000000000 --- a/test/performance/shmem_perf_suite/shmem_latency_put_perf.c +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2018 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* -** -** Notice: micro benchmark ~ two nodes only -** -** Features of Test: -** 1) small put pingpong latency test -** 2) one sided latency test to calculate latency of various sizes -** to the network stack -** -*/ - -#include -#include -#include - -int main(int argc, char *argv[]) -{ - latency_main(argc, argv, STYLE_PUT); - - return 0; -} /* end of main() */ - - -void -long_element_round_trip_latency(perf_metrics_t * const data) -{ -#ifndef USE_NONBLOCKING_API - long_element_round_trip_latency_put(data); -#endif -} - -void -int_element_latency(perf_metrics_t * const data) -{ -#ifndef USE_NONBLOCKING_API - int_p_latency(data); -#endif -} - -void -streaming_latency(int len, perf_metrics_t * const metric_info) -{ - double start = 0.0; - double end = 0.0; - unsigned long int i = 0; - int dest = partner_node(metric_info); - int sender = (metric_info->num_pes != 1) ? streaming_node(metric_info) : true; - static int check_once = 0; - - if (!check_once) { - /* check to see whether sender and receiver are the same process */ - if (dest == metric_info->my_node) { - fprintf(stderr, "Warning: Sender and receiver are the same process (%d)\n", - dest); - } - /* hostname validation for all sender and receiver processes */ - int status = check_hostname_validation(metric_info); - if (status != 0) return; - check_once++; - } - - shmem_barrier_all(); - /*puts to zero to match gets validation scheme*/ - if (sender) { - for (i = 0; i < metric_info->trials + metric_info->warmup; i++) { - if(i == metric_info->warmup) - start = perf_shmemx_wtime(); - -#ifdef USE_NONBLOCKING_API - shmem_putmem_nbi(metric_info->dest, metric_info->src, len, dest); -#else - shmem_putmem(metric_info->dest, metric_info->src, len, dest); -#endif - shmem_quiet(); - - } - end = perf_shmemx_wtime(); - - calc_and_print_results(start, end, len, metric_info); - } -} /* latency/bw for one-way trip */ diff --git a/test/performance/shmem_perf_suite/target_put.h b/test/performance/shmem_perf_suite/target_put.h deleted file mode 100644 index cac4b6234..000000000 --- a/test/performance/shmem_perf_suite/target_put.h +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright (c) 2018 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -static inline int get_size_of_side(const perf_metrics_t * const my_info) { - if(my_info->my_node < my_info->midpt) - return my_info->szinitiator; - else - return my_info->sztarget; -} - -static inline int get_size_of_other_side(const perf_metrics_t * const my_info) { - if(my_info->my_node < my_info->midpt) - return my_info->sztarget; - else - return my_info->szinitiator; -} - -static inline int get_num_partners(perf_metrics_t * const my_info, int snode) { - int unused_PEs = 0, num_partners = 0; - int active_PEs = get_size_of_side(my_info); - int other_side = get_size_of_other_side(my_info); - - if(active_PEs >= other_side) - return 1; - - num_partners = other_side / active_PEs; - unused_PEs = other_side % active_PEs; - - if (snode) { - if((my_info->my_node % active_PEs) < unused_PEs) - num_partners++; - } else { - if(((my_info->my_node - my_info->midpt) % active_PEs) < unused_PEs) - num_partners++; - } - - return num_partners; -} - -/* target only needs to know num of partners */ -static inline int *get_initiators_partners(const perf_metrics_t * const my_info, int num_partners) { - int node_to_shadow = my_info->my_node; - int i = 0; - int *partner_nodes = NULL; - - assert(my_info->cstyle == COMM_PAIRWISE && !target_node(my_info)); - if(num_partners < 1) - return partner_nodes; - - partner_nodes = (int *) malloc(sizeof(int) * num_partners); - assert(partner_nodes); - - for(i = 0; i < num_partners; i++) { - partner_nodes[i] = ((node_to_shadow % my_info->sztarget) + my_info->midpt); - node_to_shadow += my_info->szinitiator; - } - - return partner_nodes; -} - -static inline void target_data_uni_bw(int len, perf_metrics_t * const metric_info) -{ - double start = 0.0, end = 0.0; - int i = 0; - unsigned long int j, k; - int snode = (metric_info->num_pes != 1)? streaming_node(metric_info) : true; - int num_partners = get_num_partners(metric_info, snode); - static int completion_signal = 0; - int *my_PE_partners = (snode ? - get_initiators_partners(metric_info, num_partners): NULL); - - metric_info->num_partners = num_partners; - shmem_barrier_all(); - if (target_node(metric_info)) { - shmem_int_wait_until(&completion_signal, SHMEM_CMP_EQ, num_partners); - } else if (snode) { - for (i = 0; i < num_partners; i++) { - for(j = 0; j < metric_info->warmup; j++) { - for(k = 0; k < metric_info->window_size; k++) { -#ifdef USE_NONBLOCKING_API - shmem_putmem_nbi(metric_info->dest, metric_info->src, len, my_PE_partners[i]); -#else - shmem_putmem(metric_info->dest, metric_info->src, len, my_PE_partners[i]); -#endif - } - shmem_quiet(); - } - shmem_int_atomic_inc(&completion_signal, my_PE_partners[i]); - } - } - - completion_signal = 0; - shmem_barrier_all(); - start = perf_shmemx_wtime(); - - if (target_node(metric_info)) { - shmem_int_wait_until(&completion_signal, SHMEM_CMP_EQ, num_partners); - } else if (snode) { - for (i = 0; i < num_partners; i++) { - for(j = 0; j < metric_info->trials; j++) { - for(k = 0; k < metric_info->window_size; k++) { -#ifdef USE_NONBLOCKING_API - shmem_putmem_nbi(metric_info->dest, metric_info->src, len, my_PE_partners[i]); -#else - shmem_putmem(metric_info->dest, metric_info->src, len, my_PE_partners[i]); -#endif - } - shmem_quiet(); - } - shmem_int_atomic_inc(&completion_signal, my_PE_partners[i]); - } - } - - if (snode || target_node(metric_info)) { - end = perf_shmemx_wtime(); - calc_and_print_results(end, start, len, metric_info); - } - completion_signal = 0; - free(my_PE_partners); -} - -static inline void target_bw_itr(int len, perf_metrics_t * const metric_info) -{ - target_data_uni_bw(len, metric_info); -} diff --git a/test/performance/shmem_perf_suite/uni_dir.h b/test/performance/shmem_perf_suite/uni_dir.h deleted file mode 100644 index 7f113a271..000000000 --- a/test/performance/shmem_perf_suite/uni_dir.h +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright (c) 2018 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include - -static inline void uni_bw_put(int len, perf_metrics_t *metric_info) -{ - double start = 0.0, end = 0.0; - unsigned long int i = 0, j = 0; - int dest = partner_node(metric_info); - int snode = (metric_info->num_pes != 1)? streaming_node(metric_info) : true; - static int check_once = 0; - static int fin = -1; - - if(metric_info->target_data) { - target_bw_itr(len, metric_info); - return; - } - - if (!check_once) { - /* check to see whether sender and receiver are the same process */ - if (dest == metric_info->my_node) { - fprintf(stderr, "Warning: Sender and receiver are the same process (%d)\n", - dest); - } - /* hostname validation for all sender and receiver processes */ - int status = check_hostname_validation(metric_info); - if (status != 0) return; - check_once++; - } - - shmem_barrier_all(); - - if (snode) { - for (i = 0; i < metric_info->warmup; i++) { - for(j = 0; j < metric_info->window_size; j++) { -#ifdef USE_NONBLOCKING_API - shmem_putmem_nbi(metric_info->dest, metric_info->src, len, dest); -#else - shmem_putmem(metric_info->dest, metric_info->src, len, dest); -#endif - } - shmem_quiet(); - } - } - - shmem_barrier_all(); - if (snode) { - start = perf_shmemx_wtime(); - for (i = 0; i < metric_info->trials; i++) { - for(j = 0; j < metric_info->window_size; j++) { -#ifdef USE_NONBLOCKING_API - shmem_putmem_nbi(metric_info->dest, metric_info->src, len, dest); -#else - shmem_putmem(metric_info->dest, metric_info->src, len, dest); -#endif - } - shmem_quiet(); - } - shmem_int_atomic_set(&fin, 1, dest); - shmem_int_wait_until(&fin, SHMEM_CMP_EQ, 0); - end = perf_shmemx_wtime(); - calc_and_print_results(end, start, len, metric_info); - } else { - shmem_int_wait_until(&fin, SHMEM_CMP_EQ, 1); - shmem_int_atomic_set(&fin, 0, dest); - } -} - -static inline void uni_bw_get(int len, perf_metrics_t *metric_info) -{ - double start = 0.0, end = 0.0; - unsigned long int i = 0, j = 0; - int dest = partner_node(metric_info); - int snode = (metric_info->num_pes != 1) ? streaming_node(metric_info) : true; - static int check_once = 0; - static int fin = -1; - - if(metric_info->target_data) { - target_bw_itr(len, metric_info); - return; - } - - if (!check_once) { - /* check to see whether sender and receiver are the same process */ - if (dest == metric_info->my_node) { - fprintf(stderr, "Warning: Sender and receiver are the same process (%d)\n", - dest); - } - /* hostname validation for all sender and receiver processes */ - int status = check_hostname_validation(metric_info); - if (status != 0) return; - check_once++; - } - - shmem_barrier_all(); - - if (snode) { - for (i = 0; i < metric_info->warmup; i++) { - for(j = 0; j < metric_info->window_size; j++) { - /* Choosing to skip quiet for both blocking and non-blocking getmem - * as this sequence of operation (writing to the same location) is - * currently undefined by the OpenSHMEM Spec. */ -#ifdef USE_NONBLOCKING_API - shmem_getmem_nbi(metric_info->dest, metric_info->src, len, dest); -#else - shmem_getmem(metric_info->dest, metric_info->src, len, dest); -#endif - } -#ifdef USE_NONBLOCKING_API - shmem_quiet(); -#endif - } - } - - shmem_barrier_all(); - if (snode) { - start = perf_shmemx_wtime(); - for (i = 0; i < metric_info->trials; i++) { - for(j = 0; j < metric_info->window_size; j++) { -#ifdef USE_NONBLOCKING_API - shmem_getmem_nbi(metric_info->dest, metric_info->src, len, dest); -#else - shmem_getmem(metric_info->dest, metric_info->src, len, dest); -#endif - } -#ifdef USE_NONBLOCKING_API - shmem_quiet(); -#endif - } - shmem_int_atomic_set(&fin, 1, dest); - shmem_int_wait_until(&fin, SHMEM_CMP_EQ, 0); - end = perf_shmemx_wtime(); - calc_and_print_results(end, start, len, metric_info); - } else { - shmem_int_wait_until(&fin, SHMEM_CMP_EQ, 1); - shmem_int_atomic_set(&fin, 0, dest); - } -} - diff --git a/test/performance/shmem_perf_suite/uni_dir_ctx.h b/test/performance/shmem_perf_suite/uni_dir_ctx.h deleted file mode 100644 index 0ea034f0b..000000000 --- a/test/performance/shmem_perf_suite/uni_dir_ctx.h +++ /dev/null @@ -1,126 +0,0 @@ -/* -* Copyright (c) 2018 Intel Corporation. All rights reserved. -* This software is available to you under the BSD license below: -* -* Redistribution and use in source and binary forms, with or -* without modification, are permitted provided that the following -* conditions are met: -* -* - Redistributions of source code must retain the above -* copyright notice, this list of conditions and the following -* disclaimer. -* -* - Redistributions in binary form must reproduce the above -* copyright notice, this list of conditions and the following -* disclaimer in the documentation and/or other materials -* provided with the distribution. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -* SOFTWARE. -*/ - -static inline -void uni_bw_ctx(int len, perf_metrics_t *metric_info, int streaming_node) -{ - double start = 0.0, end = 0.0; - unsigned long int i, j; - int dest = partner_node(metric_info); - static int check_once = 0; - - if (!check_once) { - /* check to see whether sender and receiver are the same process */ - if (dest == metric_info->my_node) { - fprintf(stderr, "Warning: Sender and receiver are the same " - "process (%d)\n", dest); - } - /* hostname validation for all sender and receiver processes */ - int status = check_hostname_validation(metric_info); - if (status != 0) return; - check_once++; - } - - shmem_barrier_all(); - - if (streaming_node) { -#pragma omp parallel default(none) firstprivate(len, dest) private(i, j) \ -shared(metric_info, start, end) num_threads(metric_info->nthreads) - { - const int thread_id = omp_get_thread_num(); - shmem_ctx_t ctx; - int err = shmem_ctx_create(SHMEM_CTX_PRIVATE, &ctx); - - if (err) { - printf("PE %d, Thr. %d: Error, context creation failed\n", - metric_info->my_node, thread_id); - /* Exit with success to avoid test failures in automated testing */ - shmem_global_exit(0); - } - - for (i = 0; i < metric_info->warmup; i++) { - for (j = 0; j < metric_info->window_size; j++) { -#ifdef USE_NONBLOCKING_API - shmem_ctx_putmem_nbi(ctx, metric_info->dest + thread_id * len, - metric_info->src + thread_id * len, len, dest); -#else - shmem_ctx_putmem(ctx, metric_info->dest + thread_id * len, - metric_info->src + thread_id * len, len, dest); -#endif - } - shmem_ctx_quiet(ctx); - } - shmem_ctx_destroy(ctx); - } - } - - shmem_barrier_all(); - if (streaming_node) { -#pragma omp parallel default(none) firstprivate(len, dest) private(i, j) \ -shared(metric_info, start, end) num_threads(metric_info->nthreads) - { - const int thread_id = omp_get_thread_num(); - shmem_ctx_t ctx; - int err = shmem_ctx_create(SHMEM_CTX_PRIVATE, &ctx); - - if (err) { - printf("PE %d, Thr. %d: Error, context creation failed\n", - metric_info->my_node, thread_id); - /* Exit with success to avoid test failures in automated testing */ - shmem_global_exit(0); - } - -#pragma omp barrier -#pragma omp master - { - start = perf_shmemx_wtime(); - } - - for (i = 0; i < metric_info->trials; i++) { - for (j = 0; j < metric_info->window_size; j++) { -#ifdef USE_NONBLOCKING_API - shmem_ctx_putmem_nbi(ctx, metric_info->dest + thread_id * len, - metric_info->src + thread_id * len, len, dest); -#else - shmem_ctx_putmem(ctx, metric_info->dest + thread_id * len, - metric_info->src + thread_id * len, len, dest); -#endif - } - shmem_ctx_quiet(ctx); - } - shmem_ctx_destroy(ctx); - } - } - - shmem_barrier_all(); - if (streaming_node) { - end = perf_shmemx_wtime(); - calc_and_print_results(end, start, len, metric_info); - } - - shmem_barrier_all(); -} diff --git a/test/performance/tests/Makefile.am b/test/performance/tests/Makefile.am deleted file mode 100644 index 358942c4f..000000000 --- a/test/performance/tests/Makefile.am +++ /dev/null @@ -1,38 +0,0 @@ -# -*- Makefile -*- -# -# Copyright 2011 Sandia Corporation. Under the terms of Contract -# DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government -# retains certain rights in this software. -# -# Copyright (c) 2017 Intel Corporation. All rights reserved. -# This software is available to you under the BSD license. -# -# This file is part of the Sandia OpenSHMEM software package. For license -# information, see the LICENSE file in the top level directory of the -# distribution. - -check_PROGRAMS = \ - shmemlatency \ - msgrate - -if ENABLE_LENGTHY_TESTS -TESTS = $(check_PROGRAMS) -endif - -NPROCS ?= 2 -LOG_COMPILER = $(TEST_RUNNER) - -AM_LDFLAGS = $(LIBTOOL_WRAPPER_LDFLAGS) - -if EXTERNAL_TESTS -bin_PROGRAMS = $(check_PROGRAMS) -AM_CPPFLAGS = -LDADD = -else -AM_CPPFLAGS = -I$(top_builddir)/mpp -I$(top_srcdir)/mpp -LDADD = $(top_builddir)/src/libsma.la -endif - -if USE_PMI_SIMPLE -LDADD += $(top_builddir)/pmi-simple/libpmi_simple.la -endif diff --git a/test/performance/tests/msgrate.c b/test/performance/tests/msgrate.c deleted file mode 100644 index 6c2297c80..000000000 --- a/test/performance/tests/msgrate.c +++ /dev/null @@ -1,379 +0,0 @@ -/* -*- C -*- - * - * Copyright 2006 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -/* - * Adapted to Cray SHMEM by Brian Barrett - */ - -#include -#include -#include -#include -#include -#include -#include - -/* configuration parameters - setable by command line arguments */ -int npeers = 2; -int niters = 128; -int nmsgs = 128; -int nbytes = 8; -int cache_size = (8 * 1024 * 1024 / sizeof(int)); -int ppn = 1; -int machine_output = 0; - -/* globals */ -int *send_peers; -int *recv_peers; -int *cache_buf; -char *send_buf; -char *recv_buf; -int start_err = 0; -double tmp = 0; -double total = 0; - -int rank = -1; -int world_size = -1; - -static void -abort_app(const char *msg) -{ - perror(msg); - abort(); -} - - -static void -cache_invalidate(void) -{ - int i; - - cache_buf[0] = 1; - for (i = 1 ; i < cache_size ; ++i) { - cache_buf[i] = cache_buf[i - 1]; - } -} - - -static inline double -timer(void) -{ -#ifdef HAVE_SHMEMX_WTIME - return shmemx_wtime(); -#else - struct timeval tv; - gettimeofday(&tv, NULL); - return (double) tv.tv_sec + (double) tv.tv_usec / 1000000.0; -#endif /* HAVE_SHMEMX_WTIME */ -} - - -static void -display_result(const char *test, const double result) -{ - if (0 == rank) { - if (machine_output) { - printf("%.2f ", result); - } else { - printf("%16s: %.2f\n", test, result); - } - } -} - - -static void -test_one_way(void) -{ - int i, k; - - tmp = 0; - total = 0; - - shmem_barrier_all(); - - shmem_team_t sync_team; - if (world_size % 2 == 1 && world_size != 1) - shmem_team_split_strided(SHMEM_TEAM_WORLD, 0, 1, world_size - 1, NULL, 0, &sync_team); - else - sync_team = SHMEM_TEAM_WORLD; - - if (!(world_size % 2 == 1 && rank == (world_size - 1))) { - if (rank < world_size / 2) { - for (i = 0 ; i < niters ; ++i) { - cache_invalidate(); - - shmem_quiet(); - shmem_team_sync(sync_team); - - tmp = timer(); - for (k = 0 ; k < nmsgs ; ++k) { - shmem_putmem(recv_buf + (nbytes * k), - send_buf + (nbytes * k), - nbytes, rank + (world_size / 2)); - } - shmem_quiet(); - total += (timer() - tmp); - } - } else { - for (i = 0 ; i < niters ; ++i) { - cache_invalidate(); - - shmem_quiet(); - shmem_team_sync(sync_team); - - tmp = timer(); - shmem_short_wait_until((short*) (recv_buf + (nbytes * (nmsgs - 1))), SHMEM_CMP_NE, 0); - total += (timer() - tmp); - memset(recv_buf, 0, npeers * nmsgs * nbytes); - } - } - - shmem_double_sum_reduce(sync_team, &tmp, &total, 1); - display_result("single direction", (niters * nmsgs) / (tmp / world_size)); - } - - shmem_barrier_all(); -} - - -static void -test_same_direction(void) -{ - /* Not implemented yet */ -} - - -static void -test_prepost(void) -{ - int i, j, k; - - tmp = 0; - total = 0; - - shmem_barrier_all(); - - for (i = 0 ; i < niters - 1 ; ++i) { - cache_invalidate(); - - shmem_barrier_all(); - - tmp = timer(); - for (j = 0 ; j < npeers ; ++j) { - for (k = 0 ; k < nmsgs ; ++k) { - shmem_putmem(recv_buf + (nbytes * (k + j * nmsgs)), - send_buf + (nbytes * (k + j * nmsgs)), - nbytes, send_peers[npeers - j - 1]); - } - } - shmem_quiet(); - shmem_short_wait_until((short*) (recv_buf + (nbytes * ((nmsgs - 1) + (npeers - 1) * nmsgs))), SHMEM_CMP_NE, 0); - total += (timer() - tmp); - memset(recv_buf, 0, npeers * nmsgs * nbytes); - } - - shmem_double_sum_reduce(SHMEM_TEAM_WORLD, &tmp, &total, 1); - display_result("pre-post", (niters * npeers * nmsgs * 2) / (tmp / world_size)); -} - - -static void -test_allstart(void) -{ - /* BWB: Not implemented */ -} - - -static void -usage(void) -{ - fprintf(stderr, "Usage: msgrate -n [OPTION]...\n\n"); - fprintf(stderr, " -h Display this help message and exit\n"); - fprintf(stderr, " -p Number of peers used in communication\n"); - fprintf(stderr, " -i Number of iterations per test\n"); - fprintf(stderr, " -m Number of messages per peer per iteration\n"); - fprintf(stderr, " -s Number of bytes per message\n"); - fprintf(stderr, " -c Cache size in bytes\n"); - fprintf(stderr, " -n Number of procs per node\n"); - fprintf(stderr, " -o Format output to be machine readable\n"); - fprintf(stderr, "\nReport bugs to \n"); -} - - -int -main(int argc, char *argv[]) -{ - int i; - - shmem_init(); - - rank = shmem_my_pe(); - world_size = shmem_n_pes(); - - /* root handles arguments and bcasts answers */ - if (0 == rank) { - int ch; - while (start_err != 1 && - (ch = getopt(argc, argv, "p:i:m:s:c:n:oh")) != -1) { - switch (ch) { - case 'p': - npeers = atoi(optarg); - break; - case 'i': - niters = atoi(optarg); - break; - case 'm': - nmsgs = atoi(optarg); - break; - case 's': - nbytes = atoi(optarg); - break; - case 'c': - cache_size = atoi(optarg) / sizeof(int); - break; - case 'n': - ppn = atoi(optarg); - break; - case 'o': - machine_output = 1; - break; - case 'h': - case '?': - default: - start_err = 1; - usage(); - } - } - - /* sanity check */ - if (start_err != 1) { - if (world_size < npeers) { - fprintf(stderr, "Error: job size (%d) < number of peers (%d)\n", - world_size, npeers); - start_err = 77; - } else if (ppn < 1) { - fprintf(stderr, "Error: must specify process per node (-n #)\n"); - start_err = 77; - } else if (world_size / ppn < npeers) { - fprintf(stderr, "Error: node count < number of peers\n"); - start_err = 77; - } - } - } - - shmem_barrier_all(); - - /* broadcast results */ - shmem_int_broadcast(SHMEM_TEAM_WORLD, &start_err, &start_err, 1, 0); - if (0 != start_err) { - shmem_finalize(); - exit(start_err); - } - shmem_barrier_all(); - shmem_int_broadcast(SHMEM_TEAM_WORLD, &npeers, &npeers, 1, 0); - shmem_barrier_all(); - shmem_int_broadcast(SHMEM_TEAM_WORLD, &niters, &niters, 1, 0); - shmem_barrier_all(); - shmem_int_broadcast(SHMEM_TEAM_WORLD, &nmsgs, &nmsgs, 1, 0); - shmem_barrier_all(); - shmem_int_broadcast(SHMEM_TEAM_WORLD, &nbytes, &nbytes, 1, 0); - shmem_barrier_all(); - shmem_int_broadcast(SHMEM_TEAM_WORLD, &cache_size, &cache_size, 1, 0); - shmem_barrier_all(); - shmem_int_broadcast(SHMEM_TEAM_WORLD, &ppn, &ppn, 1, 0); - shmem_barrier_all(); - if (0 == rank) { - if (!machine_output) { - printf("job size: %d\n", world_size); - printf("npeers: %d\n", npeers); - printf("niters: %d\n", niters); - printf("nmsgs: %d\n", nmsgs); - printf("nbytes: %d\n", nbytes); - printf("cache size: %d\n", cache_size * (int)sizeof(int)); - printf("ppn: %d\n", ppn); - } else { - printf("%d %d %d %d %d %d %d ", - world_size, npeers, niters, nmsgs, nbytes, - cache_size * (int)sizeof(int), ppn); - } - } - - /* allocate buffers */ - send_peers = malloc(sizeof(int) * npeers); - if (NULL == send_peers) abort_app("malloc"); - recv_peers = malloc(sizeof(int) * npeers); - if (NULL == recv_peers) abort_app("malloc"); - cache_buf = malloc(sizeof(int) * cache_size); - if (NULL == cache_buf) abort_app("malloc"); - send_buf = malloc(npeers * nmsgs * nbytes); - if (NULL == send_buf) abort_app("malloc"); - memset(send_buf, 1, npeers * nmsgs * nbytes); - - recv_buf = shmem_malloc(npeers * nmsgs * nbytes); - if (NULL == recv_buf) abort_app("malloc"); - memset(recv_buf, 0, npeers * nmsgs * nbytes); - - /* calculate peers */ - for (i = 0 ; i < npeers ; ++i) { - if (i < npeers / 2) { - send_peers[i] = (rank + world_size + ((i - npeers / 2) * ppn)) % world_size; - } else { - send_peers[i] = (rank + world_size + ((i - npeers / 2 + 1) * ppn)) % world_size; - } - } - if (npeers % 2 == 0) { - /* even */ - for (i = 0 ; i < npeers ; ++i) { - if (i < npeers / 2) { - recv_peers[i] = (rank + world_size + ((i - npeers / 2) *ppn)) % world_size; - } else { - recv_peers[i] = (rank + world_size + ((i - npeers / 2 + 1) * ppn)) % world_size; - } - } - } else { - /* odd */ - for (i = 0 ; i < npeers ; ++i) { - if (i < npeers / 2 + 1) { - recv_peers[i] = (rank + world_size + ((i - npeers / 2 - 1) * ppn)) % world_size; - } else { - recv_peers[i] = (rank + world_size + ((i - npeers / 2) * ppn)) % world_size; - } - } - } - - /* BWB: FIX ME: trash the free lists / malloc here */ - - /* sync, although tests will do this on their own (in theory) */ - shmem_barrier_all(); - - /* run tests */ - test_one_way(); - test_same_direction(); - test_prepost(); - test_allstart(); - - if (rank == 0 && machine_output) printf("\n"); - - /* done */ - shmem_finalize(); - return 0; -} diff --git a/test/performance/tests/shmemlatency.c b/test/performance/tests/shmemlatency.c deleted file mode 100644 index decb7f862..000000000 --- a/test/performance/tests/shmemlatency.c +++ /dev/null @@ -1,243 +0,0 @@ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* -** This is a pingpong test used to calculate -** latency and bandwidth for various message -** sizes. -** -** SHMEM version -*/ - -#include -#include -#include -#include -#include -#include - -#define SIZE (10000000) - -#define TRUE (1) -#define FALSE (0) - -static uint64_t sig = 0; -void doit(int len, double *latency, double *bandwidth); - -#ifndef HAVE_SHMEMX_WTIME -static double shmemx_wtime(void) { - struct timeval tv; - gettimeofday(&tv, NULL); - return (double) tv.tv_sec + (double) tv.tv_usec / 1000000.0; -} -#endif /* HAVE_SHMEMX_WTIME */ - -double aligned_buf[SIZE/sizeof(double)]; - -char *buf; - -int my_node; - -int -main(int argc, char *argv[]) -{ - - extern char *optarg; - int ch, error; - int len, start_len, end_len, increment, inc, trials, i; - int mega; - double latency, bandwidth; - double tot_latency, tot_bandwidth; - double max_latency, max_bandwidth; - double min_latency, min_bandwidth; - - shmem_init(); - - my_node = shmem_my_pe(); - - if ( shmem_n_pes() < 2) { - if (my_node == 0) { - fprintf(stderr, "Need to run on at least two nodes\n"); - } - exit(77); - } - - /* Set the defaults */ - error= FALSE; - start_len= 1; - end_len= 1024; - increment = 64; - trials= 100; - mega= TRUE; - - /* check command line args */ - while ((ch= getopt(argc, argv, "i:e:s:n:m")) != EOF) { - switch (ch) { - case 'i': - increment= strtol(optarg, (char **)NULL, 0); - break; - case 'e': - end_len= strtol(optarg, (char **)NULL, 0); - break; - case 's': - start_len= strtol(optarg, (char **)NULL, 0); - if ( start_len < 1 ) start_len = 1; - break; - case 'n': - trials= strtol(optarg, (char **)NULL, 0); - break; - case 'm': - mega= FALSE; - break; - default: - error= TRUE; - break; - } - } - - if (error) { - if (my_node == 0) { - fprintf(stderr, "Usage: %s [-s start_length] [-e end_length] [-i inc] [-n trials] [-m (millions)]\n", argv[0]); - } - exit (-1); - } - - - if (my_node == 0) { - printf("\n"); - printf("Results for %d trials each of length %d through %d in increments of %d\n\n", - trials, start_len, end_len, increment); - printf("Length Latency Bandwidth\n"); - printf("in bytes in micro seconds "); - if (mega) { - printf("in mega bytes per second\n"); - } else { - printf("in million bytes per second\n"); - } - printf(" minimum average maximum minimum average maximum\n"); - } - - - for (len= start_len; len <= end_len; len += inc) { - buf= (char *)aligned_buf; - latency= tot_latency= 0.0; - max_latency= 0.0; - min_latency= 1000000000.0; - bandwidth= tot_bandwidth= 0.0; - max_bandwidth= 0.0; - min_bandwidth= 1000000000.0; - - for (i= 0; i < trials; i++) { - - buf[len-1] = (char)my_node; - sig = 0; - - shmem_barrier_all(); - - doit(len, &latency, &bandwidth); - tot_latency= tot_latency + latency; - if (latency < min_latency) { - min_latency= latency; - } - if (latency > max_latency) { - max_latency= latency; - } - tot_bandwidth= tot_bandwidth + bandwidth; - if (bandwidth < min_bandwidth) { - min_bandwidth= bandwidth; - } - if (bandwidth > max_bandwidth) { - max_bandwidth= bandwidth; - } - } - - if (my_node == 0) { - printf("%9d %8.2f %8.2f %8.2f ", - len, min_latency, tot_latency / trials, max_latency); - if (mega) { - printf("%8.2f %8.2f %8.2f\n", - min_bandwidth / (1024 * 1024), - (tot_bandwidth / trials) / (1024 * 1024), - max_bandwidth / (1024 * 1024)); - } else { - printf("%8.2f %8.2f %8.2f\n", - min_bandwidth / 1000000.0, - (tot_bandwidth / trials) / 1000000.0, - max_bandwidth / 1000000.0); - } - } - - if ( len == 1 ) { - inc = increment - 1; - } else { - inc = increment; - } - } - - shmem_finalize(); - return 0; -} /* end of main() */ - - -void -doit(int len, double *latency, double *bandwidth) -{ - - double start, end; - - if (my_node == 0) { - - start = shmemx_wtime(); - - shmem_putmem_signal( buf, buf, len, &sig, 1, SHMEM_SIGNAL_SET, 1); - - shmem_uint64_wait_until( &sig, SHMEM_CMP_EQ, (uint64_t) 1 ); - - end = shmemx_wtime(); - - *latency= (end - start) * 1000000.0 / 2.0; - - if ( (end - start) != 0 ) { - *bandwidth= len / (end - start) * 2.0; - } else { - *bandwidth = 0.0; - } - - } else { - - shmem_uint64_wait_until( &sig, SHMEM_CMP_EQ, (uint64_t) 1 ); - - shmem_putmem_signal( buf, buf, len, &sig, 1, SHMEM_SIGNAL_SET, 0); - - *latency = 1.0; - *bandwidth = 10.0; - } -} /* end of doit() */ diff --git a/test/shmemx/Makefile.am b/test/shmemx/Makefile.am deleted file mode 100644 index adb276e54..000000000 --- a/test/shmemx/Makefile.am +++ /dev/null @@ -1,105 +0,0 @@ -# -*- Makefile -*- -# -# Copyright 2011 Sandia Corporation. Under the terms of Contract -# DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government -# retains certain rights in this software. -# -# Copyright (c) 2017 Intel Corporation. All rights reserved. -# This software is available to you under the BSD license. -# -# This file is part of the Sandia OpenSHMEM software package. For license -# information, see the LICENSE file in the top level directory of the -# distribution. - -check_PROGRAMS = - -if USE_PORTALS4 -check_PROGRAMS += \ - shmem_ct -endif - -if SHMEMX_TESTS -check_PROGRAMS += \ - perf_counter \ - shmemx_team_node \ - shmem_malloc_with_hints - -if HAVE_PTHREADS -check_PROGRAMS += \ - gettid_register -endif -endif SHMEMX_TESTS - -if HAVE_CXX -if SHMEMX_TESTS -check_PROGRAMS += \ - cxx_test_shmem_g \ - cxx_test_shmem_get \ - cxx_test_shmem_p \ - cxx_test_shmem_put \ - cxx_test_shmem_atomic_fetch \ - cxx_test_shmem_atomic_set \ - cxx_test_shmem_atomic_add \ - cxx_test_shmem_atomic_inc \ - cxx_test_shmem_atomic_and \ - cxx_test_shmem_atomic_or \ - cxx_test_shmem_atomic_xor \ - cxx_test_shmem_atomic_swap \ - cxx_test_shmem_atomic_cswap \ - cxx_test_shmem_wait_until \ - cxx_test_shmem_test -endif -endif - -TESTS = $(check_PROGRAMS) - -NPROCS ?= 2 -LOG_COMPILER = $(TEST_RUNNER) - -AM_LDFLAGS = $(LIBTOOL_WRAPPER_LDFLAGS) - -if EXTERNAL_TESTS -bin_PROGRAMS = $(check_PROGRAMS) -AM_CPPFLAGS = -I$(top_srcdir)/test/include -AM_FCFLAGS = -LDADD = -else -AM_CPPFLAGS = -I$(top_builddir)/mpp -I$(top_srcdir)/mpp -I$(top_srcdir)/test/include -AM_FCFLAGS = -I$(top_builddir)/mpp -LDADD = $(top_builddir)/src/libsma.la -endif - -if USE_PMI_SIMPLE -LDADD += $(top_builddir)/pmi-simple/libpmi_simple.la -endif - -if SHMEMX_TESTS -gettid_register_LDFLAGS = $(AM_LDFLAGS) $(PTHREAD_LIBS) -gettid_register_CFLAGS = $(PTHREAD_CFLAGS) -gettid_register_LDADD = $(LDADD) $(PTHREAD_CFLAGS) - -AM_CPPFLAGS += -DENABLE_SHMEMX_TESTS - -if ENABLE_DEPRECATED_TESTS -AM_CPPFLAGS += -DENABLE_DEPRECATED_TESTS -AM_CFLAGS = -DENABLE_DEPRECATED_TESTS -endif - -# C++ Tests -cxx_test_shmem_g_SOURCES = cxx_test_shmem_g.cpp -cxx_test_shmem_get_SOURCES = cxx_test_shmem_get.cpp -cxx_test_shmem_p_SOURCES = cxx_test_shmem_p.cpp -cxx_test_shmem_put_SOURCES = cxx_test_shmem_put.cpp -cxx_test_shmem_atomic_fetch_SOURCES = cxx_test_shmem_atomic_fetch.cpp -cxx_test_shmem_atomic_set_SOURCES = cxx_test_shmem_atomic_set.cpp -cxx_test_shmem_atomic_add_SOURCES = cxx_test_shmem_atomic_add.cpp -cxx_test_shmem_atomic_inc_SOURCES = cxx_test_shmem_atomic_inc.cpp -cxx_test_shmem_atomic_and_SOURCES = cxx_test_shmem_atomic_and.cpp -cxx_test_shmem_atomic_or_SOURCES = cxx_test_shmem_atomic_or.cpp -cxx_test_shmem_atomic_xor_SOURCES = cxx_test_shmem_atomic_xor.cpp -cxx_test_shmem_atomic_swap_SOURCES = cxx_test_shmem_atomic_swap.cpp -cxx_test_shmem_atomic_cswap_SOURCES = cxx_test_shmem_atomic_cswap.cpp -cxx_test_shmem_wait_until_SOURCES = cxx_test_shmem_wait_until.cpp -cxx_test_shmem_test_SOURCES = cxx_test_shmem_test.cpp - -endif diff --git a/test/shmemx/cxx_test_shmem_atomic_add.cpp b/test/shmemx/cxx_test_shmem_atomic_add.cpp deleted file mode 100644 index e64852af9..000000000 --- a/test/shmemx/cxx_test_shmem_atomic_add.cpp +++ /dev/null @@ -1,241 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include - -enum op { ADD = 0, ATOMIC_ADD, CTX_ATOMIC_ADD, FADD, ATOMIC_FETCH_ADD, - CTX_ATOMIC_FETCH_ADD, ATOMIC_FETCH_ADD_NBI, CTX_ATOMIC_FETCH_ADD_NBI }; - -#ifdef ENABLE_DEPRECATED_TESTS -#define DEPRECATED_ADD shmem_add -#define DEPRECATED_FADD shmem_fadd -#else -#define DEPRECATED_ADD shmem_atomic_add -#define DEPRECATED_FADD shmem_atomic_fetch_add -#endif - -#define SHMEM_NBI_OPS_CASES(OP, TYPE) \ - case ATOMIC_FETCH_ADD_NBI: \ - shmem_atomic_fetch_add_nbi(&old, &remote, (TYPE)(mype + 1), i); \ - shmem_quiet(); \ - if (old > (TYPE)(npes * (npes + 1) / 2)) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - case CTX_ATOMIC_FETCH_ADD_NBI: \ - shmem_atomic_fetch_add_nbi(SHMEM_CTX_DEFAULT, &old, &remote, \ - (TYPE)(mype + 1), i); \ - shmem_quiet(); \ - if (old > (TYPE)(npes * (npes + 1) / 2)) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; - -#define TEST_SHMEM_ADD(OP, TYPE) \ - do { \ - static TYPE remote; \ - TYPE old; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - remote = (TYPE)0; \ - shmem_barrier_all(); \ - for (int i = 0; i < npes; i++) \ - switch (OP) { \ - case ADD: \ - DEPRECATED_ADD(&remote, (TYPE)(mype + 1), i); \ - break; \ - case ATOMIC_ADD: \ - shmem_atomic_add(&remote, (TYPE)(mype + 1), i); \ - break; \ - case CTX_ATOMIC_ADD: \ - shmem_atomic_add(SHMEM_CTX_DEFAULT, &remote, (TYPE)(mype + 1), i); \ - break; \ - case FADD: \ - old = DEPRECATED_FADD(&remote, (TYPE)(mype + 1), i); \ - if (old > (TYPE)(npes * (npes + 1) / 2)) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - case ATOMIC_FETCH_ADD: \ - old = shmem_atomic_fetch_add(&remote, (TYPE)(mype + 1), i); \ - if (old > (TYPE)(npes * (npes + 1) / 2)) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - case CTX_ATOMIC_FETCH_ADD: \ - old = shmem_atomic_fetch_add(SHMEM_CTX_DEFAULT, &remote, (TYPE)(mype + 1), i); \ - if (old > (TYPE)(npes * (npes + 1) / 2)) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - SHMEM_NBI_OPS_CASES(OP, TYPE) \ - default: \ - printf("Invalid operation (%d)\n", OP); \ - shmem_global_exit(1); \ - } \ - shmem_barrier_all(); \ - if (remote != (TYPE)(npes * (npes + 1) / 2)) { \ - printf("PE %i observed error with TEST_SHMEM_ADD(%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (false) - - -int main(int argc, char* argv[]) { - shmem_init(); - - int rc = EXIT_SUCCESS; - -#ifdef ENABLE_DEPRECATED_TESTS - TEST_SHMEM_ADD(ADD, int); - TEST_SHMEM_ADD(ADD, long); - TEST_SHMEM_ADD(ADD, long long); - TEST_SHMEM_ADD(ADD, unsigned int); - TEST_SHMEM_ADD(ADD, unsigned long); - TEST_SHMEM_ADD(ADD, unsigned long long); - TEST_SHMEM_ADD(ADD, int32_t); - TEST_SHMEM_ADD(ADD, int64_t); - TEST_SHMEM_ADD(ADD, uint32_t); - TEST_SHMEM_ADD(ADD, uint64_t); - TEST_SHMEM_ADD(ADD, size_t); - TEST_SHMEM_ADD(ADD, ptrdiff_t); -#endif /* ENABLE_DEPRECATED_TESTS */ - - TEST_SHMEM_ADD(ATOMIC_ADD, int); - TEST_SHMEM_ADD(ATOMIC_ADD, long); - TEST_SHMEM_ADD(ATOMIC_ADD, long long); - TEST_SHMEM_ADD(ATOMIC_ADD, unsigned int); - TEST_SHMEM_ADD(ATOMIC_ADD, unsigned long); - TEST_SHMEM_ADD(ATOMIC_ADD, unsigned long long); - TEST_SHMEM_ADD(ATOMIC_ADD, int32_t); - TEST_SHMEM_ADD(ATOMIC_ADD, int64_t); - TEST_SHMEM_ADD(ATOMIC_ADD, uint32_t); - TEST_SHMEM_ADD(ATOMIC_ADD, uint64_t); - TEST_SHMEM_ADD(ATOMIC_ADD, size_t); - TEST_SHMEM_ADD(ATOMIC_ADD, ptrdiff_t); - - TEST_SHMEM_ADD(CTX_ATOMIC_ADD, int); - TEST_SHMEM_ADD(CTX_ATOMIC_ADD, long); - TEST_SHMEM_ADD(CTX_ATOMIC_ADD, long long); - TEST_SHMEM_ADD(CTX_ATOMIC_ADD, unsigned int); - TEST_SHMEM_ADD(CTX_ATOMIC_ADD, unsigned long); - TEST_SHMEM_ADD(CTX_ATOMIC_ADD, unsigned long long); - TEST_SHMEM_ADD(CTX_ATOMIC_ADD, int32_t); - TEST_SHMEM_ADD(CTX_ATOMIC_ADD, int64_t); - TEST_SHMEM_ADD(CTX_ATOMIC_ADD, uint32_t); - TEST_SHMEM_ADD(CTX_ATOMIC_ADD, uint64_t); - TEST_SHMEM_ADD(CTX_ATOMIC_ADD, size_t); - TEST_SHMEM_ADD(CTX_ATOMIC_ADD, ptrdiff_t); - - TEST_SHMEM_ADD(FADD, int); - TEST_SHMEM_ADD(FADD, long); - TEST_SHMEM_ADD(FADD, long long); - TEST_SHMEM_ADD(FADD, unsigned int); - TEST_SHMEM_ADD(FADD, unsigned long); - TEST_SHMEM_ADD(FADD, unsigned long long); - TEST_SHMEM_ADD(FADD, int32_t); - TEST_SHMEM_ADD(FADD, int64_t); - TEST_SHMEM_ADD(FADD, uint32_t); - TEST_SHMEM_ADD(FADD, uint64_t); - TEST_SHMEM_ADD(FADD, size_t); - TEST_SHMEM_ADD(FADD, ptrdiff_t); - - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD, int); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD, long); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD, long long); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD, unsigned int); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD, unsigned long); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD, unsigned long long); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD, int32_t); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD, int64_t); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD, uint32_t); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD, uint64_t); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD, size_t); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD, ptrdiff_t); - - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD, int); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD, long); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD, long long); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD, unsigned int); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD, unsigned long); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD, unsigned long long); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD, int32_t); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD, int64_t); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD, uint32_t); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD, uint64_t); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD, size_t); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD, ptrdiff_t); - - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD_NBI, int); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD_NBI, long); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD_NBI, long long); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD_NBI, unsigned int); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD_NBI, unsigned long); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD_NBI, unsigned long long); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD_NBI, int32_t); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD_NBI, int64_t); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD_NBI, uint32_t); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD_NBI, uint64_t); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD_NBI, size_t); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD_NBI, ptrdiff_t); - - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD_NBI, int); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD_NBI, long); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD_NBI, long long); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD_NBI, unsigned int); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD_NBI, unsigned long); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD_NBI, unsigned long long); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD_NBI, int32_t); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD_NBI, int64_t); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD_NBI, uint32_t); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD_NBI, uint64_t); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD_NBI, size_t); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD_NBI, ptrdiff_t); - - shmem_finalize(); - return rc; -} diff --git a/test/shmemx/cxx_test_shmem_atomic_and.cpp b/test/shmemx/cxx_test_shmem_atomic_and.cpp deleted file mode 100644 index 872f31d33..000000000 --- a/test/shmemx/cxx_test_shmem_atomic_and.cpp +++ /dev/null @@ -1,169 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include -#include - -enum op { AND = 0, CTX_AND, FETCH_AND, CTX_FETCH_AND, FETCH_AND_NBI, - CTX_FETCH_AND_NBI }; - -/* Initially, remote = 111...b. Each PE performs an atomic AND where the - * PEth bit of the input value is set to 0 and all other bits are set to 1. - * The result has the NPES least significant bits cleared, 111...000...b. - */ - -#define SHMEM_NBI_OPS_CASES(OP, TYPE) \ - case FETCH_AND_NBI: \ - shmem_atomic_fetch_and_nbi(&old, &remote, \ - ~(TYPE)(1LLU << mype), i); \ - shmem_quiet(); \ - if ((old & (TYPE)(1LLU << mype)) == 0) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - case CTX_FETCH_AND_NBI: \ - shmem_atomic_fetch_and_nbi(SHMEM_CTX_DEFAULT, &old, &remote, \ - ~(TYPE)(1LLU << mype), i); \ - shmem_quiet(); \ - if ((old & (TYPE)(1LLU << mype)) == 0) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; - -#define TEST_SHMEM_AND(OP, TYPE) \ - do { \ - static TYPE remote = ~(TYPE)0; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - TYPE old = (TYPE)0; \ - if ((size_t) npes-1 > sizeof(TYPE)) break; /* Avoid overflow */ \ - for (int i = 0; i < npes; i++) \ - switch (OP) { \ - case AND: \ - shmem_atomic_and(&remote, ~(TYPE)(1LLU << mype), i); \ - break; \ - case CTX_AND: \ - shmem_atomic_and(SHMEM_CTX_DEFAULT, &remote, ~(TYPE)(1LLU << mype), i); \ - break; \ - case FETCH_AND: \ - old = shmem_atomic_fetch_and(&remote, ~(TYPE)(1LLU << mype), i); \ - if ((old & (TYPE)(1LLU << mype)) == 0) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - case CTX_FETCH_AND: \ - old = shmem_atomic_fetch_and(SHMEM_CTX_DEFAULT, &remote, ~(TYPE)(1LLU << mype), i); \ - if ((old & (TYPE)(1LLU << mype)) == 0) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - SHMEM_NBI_OPS_CASES(OP, TYPE) \ - default: \ - printf("Invalid operation (%d)\n", OP); \ - shmem_global_exit(1); \ - } \ - shmem_barrier_all(); \ - if (remote != ~(TYPE)((1LLU << npes) - 1LLU)) { \ - printf("PE %i observed error with TEST_SHMEM_AND(%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (false) - - -int main(int argc, char* argv[]) { - shmem_init(); - - int rc = EXIT_SUCCESS; - TEST_SHMEM_AND(AND, unsigned int); - TEST_SHMEM_AND(AND, unsigned long); - TEST_SHMEM_AND(AND, unsigned long long); - TEST_SHMEM_AND(AND, int32_t); - TEST_SHMEM_AND(AND, int64_t); - TEST_SHMEM_AND(AND, uint32_t); - TEST_SHMEM_AND(AND, uint64_t); - - TEST_SHMEM_AND(CTX_AND, unsigned int); - TEST_SHMEM_AND(CTX_AND, unsigned long); - TEST_SHMEM_AND(CTX_AND, unsigned long long); - TEST_SHMEM_AND(CTX_AND, int32_t); - TEST_SHMEM_AND(CTX_AND, int64_t); - TEST_SHMEM_AND(CTX_AND, uint32_t); - TEST_SHMEM_AND(CTX_AND, uint64_t); - - TEST_SHMEM_AND(FETCH_AND, unsigned int); - TEST_SHMEM_AND(FETCH_AND, unsigned long); - TEST_SHMEM_AND(FETCH_AND, unsigned long long); - TEST_SHMEM_AND(FETCH_AND, int32_t); - TEST_SHMEM_AND(FETCH_AND, int64_t); - TEST_SHMEM_AND(FETCH_AND, uint32_t); - TEST_SHMEM_AND(FETCH_AND, uint64_t); - - TEST_SHMEM_AND(CTX_FETCH_AND, unsigned int); - TEST_SHMEM_AND(CTX_FETCH_AND, unsigned long); - TEST_SHMEM_AND(CTX_FETCH_AND, unsigned long long); - TEST_SHMEM_AND(CTX_FETCH_AND, int32_t); - TEST_SHMEM_AND(CTX_FETCH_AND, int64_t); - TEST_SHMEM_AND(CTX_FETCH_AND, uint32_t); - TEST_SHMEM_AND(CTX_FETCH_AND, uint64_t); - - TEST_SHMEM_AND(FETCH_AND_NBI, unsigned int); - TEST_SHMEM_AND(FETCH_AND_NBI, unsigned long); - TEST_SHMEM_AND(FETCH_AND_NBI, unsigned long long); - TEST_SHMEM_AND(FETCH_AND_NBI, int32_t); - TEST_SHMEM_AND(FETCH_AND_NBI, int64_t); - TEST_SHMEM_AND(FETCH_AND_NBI, uint32_t); - TEST_SHMEM_AND(FETCH_AND_NBI, uint64_t); - - TEST_SHMEM_AND(CTX_FETCH_AND_NBI, unsigned int); - TEST_SHMEM_AND(CTX_FETCH_AND_NBI, unsigned long); - TEST_SHMEM_AND(CTX_FETCH_AND_NBI, unsigned long long); - TEST_SHMEM_AND(CTX_FETCH_AND_NBI, int32_t); - TEST_SHMEM_AND(CTX_FETCH_AND_NBI, int64_t); - TEST_SHMEM_AND(CTX_FETCH_AND_NBI, uint32_t); - TEST_SHMEM_AND(CTX_FETCH_AND_NBI, uint64_t); - - shmem_finalize(); - return rc; -} diff --git a/test/shmemx/cxx_test_shmem_atomic_cswap.cpp b/test/shmemx/cxx_test_shmem_atomic_cswap.cpp deleted file mode 100644 index a2d44049c..000000000 --- a/test/shmemx/cxx_test_shmem_atomic_cswap.cpp +++ /dev/null @@ -1,174 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include - -enum op { CSWAP = 0, ATOMIC_COMPARE_SWAP, CTX_ATOMIC_COMPARE_SWAP, - ATOMIC_COMPARE_SWAP_NBI, CTX_ATOMIC_COMPARE_SWAP_NBI }; - -#ifdef ENABLE_DEPRECATED_TESTS -#define DEPRECATED_CSWAP shmem_cswap -#else -#define DEPRECATED_CSWAP shmem_atomic_compare_swap -#endif - -#define SHMEM_NBI_OPS_CASES(OP, TYPE) \ - case ATOMIC_COMPARE_SWAP_NBI: \ - shmem_atomic_compare_swap_nbi(&old, &remote, (TYPE)npes, \ - (TYPE)mype, (mype + 1) % npes); \ - break; \ - case CTX_ATOMIC_COMPARE_SWAP_NBI: \ - shmem_atomic_compare_swap_nbi(SHMEM_CTX_DEFAULT, &old, &remote, \ - (TYPE)npes, (TYPE)mype, \ - (mype + 1) % npes); \ - break; - -#define TEST_SHMEM_CSWAP(OP, TYPE) \ - do { \ - static TYPE remote; \ - TYPE old; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - remote = npes; \ - shmem_barrier_all(); \ - switch (OP) { \ - case CSWAP: \ - old = DEPRECATED_CSWAP(&remote, (TYPE)npes, (TYPE)mype, \ - (mype + 1) % npes); \ - break; \ - case ATOMIC_COMPARE_SWAP: \ - old = shmem_atomic_compare_swap(&remote, (TYPE)npes, \ - (TYPE)mype, (mype + 1) % npes); \ - break; \ - case CTX_ATOMIC_COMPARE_SWAP: \ - old = shmem_atomic_compare_swap(SHMEM_CTX_DEFAULT, &remote, \ - (TYPE)npes, (TYPE)mype, \ - (mype + 1) % npes); \ - break; \ - SHMEM_NBI_OPS_CASES(OP, TYPE) \ - default: \ - printf("invalid operation (%d)\n", OP); \ - shmem_global_exit(1); \ - } \ - shmem_barrier_all(); \ - if (remote != (TYPE)((mype + npes - 1) % npes)) { \ - printf("PE %i observed error with TEST_SHMEM_CSWAP(%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - if (old != (TYPE) npes) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (false) - - -int main(int argc, char* argv[]) { - shmem_init(); - - int rc = EXIT_SUCCESS; - -#ifdef ENABLE_DEPRECATED_TESTS - TEST_SHMEM_CSWAP(CSWAP, int); - TEST_SHMEM_CSWAP(CSWAP, long); - TEST_SHMEM_CSWAP(CSWAP, long long); - TEST_SHMEM_CSWAP(CSWAP, unsigned int); - TEST_SHMEM_CSWAP(CSWAP, unsigned long); - TEST_SHMEM_CSWAP(CSWAP, unsigned long long); - TEST_SHMEM_CSWAP(CSWAP, int32_t); - TEST_SHMEM_CSWAP(CSWAP, int64_t); - TEST_SHMEM_CSWAP(CSWAP, uint32_t); - TEST_SHMEM_CSWAP(CSWAP, uint64_t); - TEST_SHMEM_CSWAP(CSWAP, size_t); - TEST_SHMEM_CSWAP(CSWAP, ptrdiff_t); -#endif /* ENABLE_DEPRECATED_TESTS */ - - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP, int); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP, long); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP, long long); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP, unsigned int); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP, unsigned long); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP, unsigned long long); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP, int32_t); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP, int64_t); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP, uint32_t); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP, uint64_t); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP, size_t); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP, ptrdiff_t); - - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP, int); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP, long); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP, long long); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP, unsigned int); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP, unsigned long); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP, unsigned long long); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP, int32_t); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP, int64_t); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP, uint32_t); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP, uint64_t); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP, size_t); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP, ptrdiff_t); - - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP_NBI, int); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP_NBI, long); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP_NBI, long long); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP_NBI, unsigned int); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP_NBI, unsigned long); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP_NBI, unsigned long long); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP_NBI, int32_t); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP_NBI, int64_t); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP_NBI, uint32_t); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP_NBI, uint64_t); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP_NBI, size_t); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP_NBI, ptrdiff_t); - - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP_NBI, int); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP_NBI, long); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP_NBI, long long); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP_NBI, unsigned int); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP_NBI, unsigned long); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP_NBI, unsigned long long); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP_NBI, int32_t); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP_NBI, int64_t); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP_NBI, uint32_t); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP_NBI, uint64_t); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP_NBI, size_t); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP_NBI, ptrdiff_t); - - shmem_finalize(); - return rc; -} diff --git a/test/shmemx/cxx_test_shmem_atomic_fetch.cpp b/test/shmemx/cxx_test_shmem_atomic_fetch.cpp deleted file mode 100644 index 7f233aac7..000000000 --- a/test/shmemx/cxx_test_shmem_atomic_fetch.cpp +++ /dev/null @@ -1,175 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include - -enum op { FETCH = 0, ATOMIC_FETCH, CTX_ATOMIC_FETCH, ATOMIC_FETCH_NBI, - CTX_ATOMIC_FETCH_NBI }; - -#ifdef ENABLE_DEPRECATED_TESTS -#define DEPRECATED_FETCH shmem_fetch -#else -#define DEPRECATED_FETCH shmem_atomic_fetch -#endif - -#define SHMEM_NBI_OPS_CASES(OP, TYPE) \ - case ATOMIC_FETCH_NBI: \ - shmem_atomic_fetch_nbi(&val, &remote, \ - (mype + 1) % npes); \ - shmem_quiet(); \ - break; \ - case CTX_ATOMIC_FETCH_NBI: \ - shmem_atomic_fetch_nbi(SHMEM_CTX_DEFAULT, &val, \ - &remote, (mype + 1) % npes); \ - shmem_quiet(); \ - break; - -#define TEST_SHMEM_FETCH(OP, TYPE) \ - do { \ - static TYPE remote; \ - TYPE val; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - remote = (TYPE)mype; \ - shmem_barrier_all(); \ - switch (OP) { \ - case FETCH: \ - val = DEPRECATED_FETCH(&remote, (mype + 1) % npes); \ - break; \ - case ATOMIC_FETCH: \ - val = shmem_atomic_fetch(&remote, (mype + 1) % npes); \ - break; \ - case CTX_ATOMIC_FETCH: \ - val = shmem_atomic_fetch(SHMEM_CTX_DEFAULT, &remote, (mype + 1) % npes); \ - break; \ - SHMEM_NBI_OPS_CASES(OP, TYPE) \ - default: \ - printf("Invalid operation (%d)\n", OP); \ - shmem_global_exit(1); \ - } \ - if (val != (TYPE)((mype + 1) % npes)) { \ - printf("PE %i received incorrect value with " \ - "TEST_SHMEM_FETCH(%s, %s)\n", mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (false) - - -int main(int argc, char* argv[]) { - shmem_init(); - - int rc = EXIT_SUCCESS; - -#ifdef ENABLE_DEPRECATED_TESTS - TEST_SHMEM_FETCH(FETCH, float); - TEST_SHMEM_FETCH(FETCH, double); - TEST_SHMEM_FETCH(FETCH, int); - TEST_SHMEM_FETCH(FETCH, long); - TEST_SHMEM_FETCH(FETCH, long long); - TEST_SHMEM_FETCH(FETCH, unsigned int); - TEST_SHMEM_FETCH(FETCH, unsigned long); - TEST_SHMEM_FETCH(FETCH, unsigned long long); - TEST_SHMEM_FETCH(FETCH, int32_t); - TEST_SHMEM_FETCH(FETCH, int64_t); - TEST_SHMEM_FETCH(FETCH, uint32_t); - TEST_SHMEM_FETCH(FETCH, uint64_t); - TEST_SHMEM_FETCH(FETCH, size_t); - TEST_SHMEM_FETCH(FETCH, ptrdiff_t); -#endif /* ENABLE_DEPRECATED_TESTS */ - - TEST_SHMEM_FETCH(ATOMIC_FETCH, float); - TEST_SHMEM_FETCH(ATOMIC_FETCH, double); - TEST_SHMEM_FETCH(ATOMIC_FETCH, int); - TEST_SHMEM_FETCH(ATOMIC_FETCH, long); - TEST_SHMEM_FETCH(ATOMIC_FETCH, long long); - TEST_SHMEM_FETCH(ATOMIC_FETCH, unsigned int); - TEST_SHMEM_FETCH(ATOMIC_FETCH, unsigned long); - TEST_SHMEM_FETCH(ATOMIC_FETCH, unsigned long long); - TEST_SHMEM_FETCH(ATOMIC_FETCH, int32_t); - TEST_SHMEM_FETCH(ATOMIC_FETCH, int64_t); - TEST_SHMEM_FETCH(ATOMIC_FETCH, uint32_t); - TEST_SHMEM_FETCH(ATOMIC_FETCH, uint64_t); - TEST_SHMEM_FETCH(ATOMIC_FETCH, size_t); - TEST_SHMEM_FETCH(ATOMIC_FETCH, ptrdiff_t); - - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH, float); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH, double); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH, int); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH, long); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH, long long); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH, unsigned int); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH, unsigned long); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH, unsigned long long); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH, int32_t); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH, int64_t); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH, uint32_t); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH, uint64_t); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH, size_t); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH, ptrdiff_t); - - TEST_SHMEM_FETCH(ATOMIC_FETCH_NBI, float); - TEST_SHMEM_FETCH(ATOMIC_FETCH_NBI, double); - TEST_SHMEM_FETCH(ATOMIC_FETCH_NBI, int); - TEST_SHMEM_FETCH(ATOMIC_FETCH_NBI, long); - TEST_SHMEM_FETCH(ATOMIC_FETCH_NBI, long long); - TEST_SHMEM_FETCH(ATOMIC_FETCH_NBI, unsigned int); - TEST_SHMEM_FETCH(ATOMIC_FETCH_NBI, unsigned long); - TEST_SHMEM_FETCH(ATOMIC_FETCH_NBI, unsigned long long); - TEST_SHMEM_FETCH(ATOMIC_FETCH_NBI, int32_t); - TEST_SHMEM_FETCH(ATOMIC_FETCH_NBI, int64_t); - TEST_SHMEM_FETCH(ATOMIC_FETCH_NBI, uint32_t); - TEST_SHMEM_FETCH(ATOMIC_FETCH_NBI, uint64_t); - TEST_SHMEM_FETCH(ATOMIC_FETCH_NBI, size_t); - TEST_SHMEM_FETCH(ATOMIC_FETCH_NBI, ptrdiff_t); - - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH_NBI, float); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH_NBI, double); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH_NBI, int); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH_NBI, long); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH_NBI, long long); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH_NBI, unsigned int); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH_NBI, unsigned long); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH_NBI, unsigned long long); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH_NBI, int32_t); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH_NBI, int64_t); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH_NBI, uint32_t); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH_NBI, uint64_t); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH_NBI, size_t); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH_NBI, ptrdiff_t); - - shmem_finalize(); - return rc; -} diff --git a/test/shmemx/cxx_test_shmem_atomic_inc.cpp b/test/shmemx/cxx_test_shmem_atomic_inc.cpp deleted file mode 100644 index 37273c4f2..000000000 --- a/test/shmemx/cxx_test_shmem_atomic_inc.cpp +++ /dev/null @@ -1,241 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include - -enum op { INC = 0, ATOMIC_INC, CTX_ATOMIC_INC, FINC, ATOMIC_FETCH_INC, - CTX_ATOMIC_FETCH_INC, ATOMIC_FETCH_INC_NBI, - CTX_ATOMIC_FETCH_INC_NBI }; - -#ifdef ENABLE_DEPRECATED_TESTS -#define DEPRECATED_INC shmem_inc -#define DEPRECATED_FINC shmem_finc -#else -#define DEPRECATED_INC shmem_atomic_inc -#define DEPRECATED_FINC shmem_atomic_fetch_inc -#endif - -#define SHMEM_NBI_OPS_CASES(OP, TYPE) \ - case ATOMIC_FETCH_INC_NBI: \ - shmem_atomic_fetch_inc_nbi(&old, &remote, i); \ - shmem_quiet(); \ - if (old > (TYPE) npes) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - case CTX_ATOMIC_FETCH_INC_NBI: \ - shmem_atomic_fetch_inc_nbi(SHMEM_CTX_DEFAULT, &old, &remote, i); \ - shmem_quiet(); \ - if (old > (TYPE) npes) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; - -#define TEST_SHMEM_INC(OP, TYPE) \ - do { \ - static TYPE remote = (TYPE)0; \ - TYPE old; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - remote = (TYPE)0; \ - shmem_barrier_all(); \ - for (int i = 0; i < npes; i++) \ - switch (OP) { \ - case INC: \ - DEPRECATED_INC(&remote, i); \ - break; \ - case ATOMIC_INC: \ - shmem_atomic_inc(&remote, i); \ - break; \ - case CTX_ATOMIC_INC: \ - shmem_atomic_inc(SHMEM_CTX_DEFAULT, &remote, i); \ - break; \ - case FINC: \ - old = DEPRECATED_FINC(&remote, i); \ - if (old > (TYPE) npes) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - case ATOMIC_FETCH_INC: \ - old = shmem_atomic_fetch_inc(&remote, i); \ - if (old > (TYPE) npes) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - case CTX_ATOMIC_FETCH_INC: \ - old = shmem_atomic_fetch_inc(SHMEM_CTX_DEFAULT, &remote, i); \ - if (old > (TYPE) npes) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - SHMEM_NBI_OPS_CASES(OP, TYPE) \ - default: \ - printf("Invalid operation (%d)\n", OP); \ - shmem_global_exit(1); \ - } \ - shmem_barrier_all(); \ - if (remote != (TYPE)npes) { \ - printf("PE %i observed error with TEST_SHMEM_INC(%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (false) - - -int main(int argc, char* argv[]) { - shmem_init(); - - int rc = EXIT_SUCCESS; - -#ifdef ENABLE_DEPRECATED_TESTS - TEST_SHMEM_INC(INC, int); - TEST_SHMEM_INC(INC, long); - TEST_SHMEM_INC(INC, long long); - TEST_SHMEM_INC(INC, unsigned int); - TEST_SHMEM_INC(INC, unsigned long); - TEST_SHMEM_INC(INC, unsigned long long); - TEST_SHMEM_INC(INC, int32_t); - TEST_SHMEM_INC(INC, int64_t); - TEST_SHMEM_INC(INC, uint32_t); - TEST_SHMEM_INC(INC, uint64_t); - TEST_SHMEM_INC(INC, size_t); - TEST_SHMEM_INC(INC, ptrdiff_t); -#endif /* ENABLE_DEPRECATED_TESTS */ - - TEST_SHMEM_INC(ATOMIC_INC, int); - TEST_SHMEM_INC(ATOMIC_INC, long); - TEST_SHMEM_INC(ATOMIC_INC, long long); - TEST_SHMEM_INC(ATOMIC_INC, unsigned int); - TEST_SHMEM_INC(ATOMIC_INC, unsigned long); - TEST_SHMEM_INC(ATOMIC_INC, unsigned long long); - TEST_SHMEM_INC(ATOMIC_INC, int32_t); - TEST_SHMEM_INC(ATOMIC_INC, int64_t); - TEST_SHMEM_INC(ATOMIC_INC, uint32_t); - TEST_SHMEM_INC(ATOMIC_INC, uint64_t); - TEST_SHMEM_INC(ATOMIC_INC, size_t); - TEST_SHMEM_INC(ATOMIC_INC, ptrdiff_t); - - TEST_SHMEM_INC(CTX_ATOMIC_INC, int); - TEST_SHMEM_INC(CTX_ATOMIC_INC, long); - TEST_SHMEM_INC(CTX_ATOMIC_INC, long long); - TEST_SHMEM_INC(CTX_ATOMIC_INC, unsigned int); - TEST_SHMEM_INC(CTX_ATOMIC_INC, unsigned long); - TEST_SHMEM_INC(CTX_ATOMIC_INC, unsigned long long); - TEST_SHMEM_INC(CTX_ATOMIC_INC, int32_t); - TEST_SHMEM_INC(CTX_ATOMIC_INC, int64_t); - TEST_SHMEM_INC(CTX_ATOMIC_INC, uint32_t); - TEST_SHMEM_INC(CTX_ATOMIC_INC, uint64_t); - TEST_SHMEM_INC(CTX_ATOMIC_INC, size_t); - TEST_SHMEM_INC(CTX_ATOMIC_INC, ptrdiff_t); - - TEST_SHMEM_INC(FINC, int); - TEST_SHMEM_INC(FINC, long); - TEST_SHMEM_INC(FINC, long long); - TEST_SHMEM_INC(FINC, unsigned int); - TEST_SHMEM_INC(FINC, unsigned long); - TEST_SHMEM_INC(FINC, unsigned long long); - TEST_SHMEM_INC(FINC, int32_t); - TEST_SHMEM_INC(FINC, int64_t); - TEST_SHMEM_INC(FINC, uint32_t); - TEST_SHMEM_INC(FINC, uint64_t); - TEST_SHMEM_INC(FINC, size_t); - TEST_SHMEM_INC(FINC, ptrdiff_t); - - TEST_SHMEM_INC(ATOMIC_FETCH_INC, int); - TEST_SHMEM_INC(ATOMIC_FETCH_INC, long); - TEST_SHMEM_INC(ATOMIC_FETCH_INC, long long); - TEST_SHMEM_INC(ATOMIC_FETCH_INC, unsigned int); - TEST_SHMEM_INC(ATOMIC_FETCH_INC, unsigned long); - TEST_SHMEM_INC(ATOMIC_FETCH_INC, unsigned long long); - TEST_SHMEM_INC(ATOMIC_FETCH_INC, int32_t); - TEST_SHMEM_INC(ATOMIC_FETCH_INC, int64_t); - TEST_SHMEM_INC(ATOMIC_FETCH_INC, uint32_t); - TEST_SHMEM_INC(ATOMIC_FETCH_INC, uint64_t); - TEST_SHMEM_INC(ATOMIC_FETCH_INC, size_t); - TEST_SHMEM_INC(ATOMIC_FETCH_INC, ptrdiff_t); - - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC, int); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC, long); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC, long long); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC, unsigned int); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC, unsigned long); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC, unsigned long long); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC, int32_t); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC, int64_t); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC, uint32_t); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC, uint64_t); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC, size_t); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC, ptrdiff_t); - - TEST_SHMEM_INC(ATOMIC_FETCH_INC_NBI, int); - TEST_SHMEM_INC(ATOMIC_FETCH_INC_NBI, long); - TEST_SHMEM_INC(ATOMIC_FETCH_INC_NBI, long long); - TEST_SHMEM_INC(ATOMIC_FETCH_INC_NBI, unsigned int); - TEST_SHMEM_INC(ATOMIC_FETCH_INC_NBI, unsigned long); - TEST_SHMEM_INC(ATOMIC_FETCH_INC_NBI, unsigned long long); - TEST_SHMEM_INC(ATOMIC_FETCH_INC_NBI, int32_t); - TEST_SHMEM_INC(ATOMIC_FETCH_INC_NBI, int64_t); - TEST_SHMEM_INC(ATOMIC_FETCH_INC_NBI, uint32_t); - TEST_SHMEM_INC(ATOMIC_FETCH_INC_NBI, uint64_t); - TEST_SHMEM_INC(ATOMIC_FETCH_INC_NBI, size_t); - TEST_SHMEM_INC(ATOMIC_FETCH_INC_NBI, ptrdiff_t); - - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC_NBI, int); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC_NBI, long); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC_NBI, long long); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC_NBI, unsigned int); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC_NBI, unsigned long); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC_NBI, unsigned long long); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC_NBI, int32_t); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC_NBI, int64_t); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC_NBI, uint32_t); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC_NBI, uint64_t); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC_NBI, size_t); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC_NBI, ptrdiff_t); - - shmem_finalize(); - return rc; -} diff --git a/test/shmemx/cxx_test_shmem_atomic_or.cpp b/test/shmemx/cxx_test_shmem_atomic_or.cpp deleted file mode 100644 index 47a17f004..000000000 --- a/test/shmemx/cxx_test_shmem_atomic_or.cpp +++ /dev/null @@ -1,171 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include -#include - -enum op { OR = 0, CTX_OR, FETCH_OR, CTX_FETCH_OR, FETCH_OR_NBI, - CTX_FETCH_OR_NBI }; - -/* Initially, remote = 000...b. Each PE performs an atomic OR where the - * PEth bit of the input value is set to 1 and all other bits are set to 0. - * The result has the NPES least significant bits set, 000...111...b. - */ - -#define SHMEM_NBI_OPS_CASES(OP, TYPE) \ - case FETCH_OR_NBI: \ - shmem_atomic_fetch_or_nbi(&old, &remote, \ - (TYPE)(1LLU << mype), i); \ - shmem_quiet(); \ - if ((old & (TYPE)(1LLU << mype)) != 0) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - case CTX_FETCH_OR_NBI: \ - shmem_atomic_fetch_or_nbi(SHMEM_CTX_DEFAULT, &old, &remote, \ - (TYPE)(1LLU << mype), i); \ - shmem_quiet(); \ - if ((old & (TYPE)(1LLU << mype)) != 0) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; - -#define TEST_SHMEM_OR(OP, TYPE) \ - do { \ - static TYPE remote = (TYPE)0; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - TYPE old = (TYPE)0; \ - if ((size_t) npes-1 > sizeof(TYPE)) break; /* Avoid overflow */ \ - for (int i = 0; i < npes; i++) \ - switch (OP) { \ - case OR: \ - shmem_atomic_or(&remote, (TYPE)(1LLU << mype), i); \ - break; \ - case CTX_OR: \ - shmem_atomic_or(SHMEM_CTX_DEFAULT, &remote, \ - (TYPE)(1LLU << mype), i); \ - break; \ - case FETCH_OR: \ - old = shmem_atomic_fetch_or(&remote, (TYPE)(1LLU << mype), i);\ - if ((old & (TYPE)(1LLU << mype)) != 0) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - case CTX_FETCH_OR: \ - old = shmem_atomic_fetch_or(SHMEM_CTX_DEFAULT, &remote, \ - (TYPE)(1LLU << mype), i); \ - if ((old & (TYPE)(1LLU << mype)) != 0) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - SHMEM_NBI_OPS_CASES(OP, TYPE) \ - default: \ - printf("Invalid operation (%d)\n", OP); \ - shmem_global_exit(1); \ - } \ - shmem_barrier_all(); \ - if (remote != (TYPE)((1LLU << npes) - 1LLU)) { \ - printf("PE %i observed error with TEST_SHMEM_OR(%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (false) - - -int main(int argc, char* argv[]) { - shmem_init(); - - int rc = EXIT_SUCCESS; - TEST_SHMEM_OR(OR, unsigned int); - TEST_SHMEM_OR(OR, unsigned long); - TEST_SHMEM_OR(OR, unsigned long long); - TEST_SHMEM_OR(OR, int32_t); - TEST_SHMEM_OR(OR, int64_t); - TEST_SHMEM_OR(OR, uint32_t); - TEST_SHMEM_OR(OR, uint64_t); - - TEST_SHMEM_OR(CTX_OR, unsigned int); - TEST_SHMEM_OR(CTX_OR, unsigned long); - TEST_SHMEM_OR(CTX_OR, unsigned long long); - TEST_SHMEM_OR(CTX_OR, int32_t); - TEST_SHMEM_OR(CTX_OR, int64_t); - TEST_SHMEM_OR(CTX_OR, uint32_t); - TEST_SHMEM_OR(CTX_OR, uint64_t); - - TEST_SHMEM_OR(FETCH_OR, unsigned int); - TEST_SHMEM_OR(FETCH_OR, unsigned long); - TEST_SHMEM_OR(FETCH_OR, unsigned long long); - TEST_SHMEM_OR(FETCH_OR, int32_t); - TEST_SHMEM_OR(FETCH_OR, int64_t); - TEST_SHMEM_OR(FETCH_OR, uint32_t); - TEST_SHMEM_OR(FETCH_OR, uint64_t); - - TEST_SHMEM_OR(CTX_FETCH_OR, unsigned int); - TEST_SHMEM_OR(CTX_FETCH_OR, unsigned long); - TEST_SHMEM_OR(CTX_FETCH_OR, unsigned long long); - TEST_SHMEM_OR(CTX_FETCH_OR, int32_t); - TEST_SHMEM_OR(CTX_FETCH_OR, int64_t); - TEST_SHMEM_OR(CTX_FETCH_OR, uint32_t); - TEST_SHMEM_OR(CTX_FETCH_OR, uint64_t); - - TEST_SHMEM_OR(FETCH_OR_NBI, unsigned int); - TEST_SHMEM_OR(FETCH_OR_NBI, unsigned long); - TEST_SHMEM_OR(FETCH_OR_NBI, unsigned long long); - TEST_SHMEM_OR(FETCH_OR_NBI, int32_t); - TEST_SHMEM_OR(FETCH_OR_NBI, int64_t); - TEST_SHMEM_OR(FETCH_OR_NBI, uint32_t); - TEST_SHMEM_OR(FETCH_OR_NBI, uint64_t); - - TEST_SHMEM_OR(CTX_FETCH_OR_NBI, unsigned int); - TEST_SHMEM_OR(CTX_FETCH_OR_NBI, unsigned long); - TEST_SHMEM_OR(CTX_FETCH_OR_NBI, unsigned long long); - TEST_SHMEM_OR(CTX_FETCH_OR_NBI, int32_t); - TEST_SHMEM_OR(CTX_FETCH_OR_NBI, int64_t); - TEST_SHMEM_OR(CTX_FETCH_OR_NBI, uint32_t); - TEST_SHMEM_OR(CTX_FETCH_OR_NBI, uint64_t); - - shmem_finalize(); - return rc; -} diff --git a/test/shmemx/cxx_test_shmem_atomic_set.cpp b/test/shmemx/cxx_test_shmem_atomic_set.cpp deleted file mode 100644 index 9cb15077b..000000000 --- a/test/shmemx/cxx_test_shmem_atomic_set.cpp +++ /dev/null @@ -1,129 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include - -enum op { SET = 0, ATOMIC_SET, CTX_ATOMIC_SET }; - -#ifdef ENABLE_DEPRECATED_TESTS -#define DEPRECATED_SET shmem_set -#else -#define DEPRECATED_SET shmem_atomic_set -#endif - -#define TEST_SHMEM_SET(OP, TYPE) \ - do { \ - static TYPE remote; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - switch (OP) { \ - case SET: \ - DEPRECATED_SET(&remote, (TYPE)mype, (mype + 1) % npes); \ - break; \ - case ATOMIC_SET: \ - shmem_atomic_set(&remote, (TYPE)mype, (mype + 1) % npes); \ - break; \ - case CTX_ATOMIC_SET: \ - shmem_atomic_set(SHMEM_CTX_DEFAULT, &remote, (TYPE)mype, (mype + 1) % npes); \ - break; \ - default: \ - printf("Invalid operation (%d)\n", OP); \ - shmem_global_exit(1); \ - } \ - shmem_barrier_all(); \ - if (remote != (TYPE)((mype + npes - 1) % npes)) { \ - printf("PE %i received incorrect value with " \ - "TEST_SHMEM_SET(%s, %s)\n", mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (false) - - -int main(int argc, char* argv[]) { - shmem_init(); - - int rc = EXIT_SUCCESS; - -#ifdef ENABLE_DEPRECATED_TESTS - TEST_SHMEM_SET(SET, float); - TEST_SHMEM_SET(SET, double); - TEST_SHMEM_SET(SET, int); - TEST_SHMEM_SET(SET, long); - TEST_SHMEM_SET(SET, long long); - TEST_SHMEM_SET(SET, unsigned int); - TEST_SHMEM_SET(SET, unsigned long); - TEST_SHMEM_SET(SET, unsigned long long); - TEST_SHMEM_SET(SET, int32_t); - TEST_SHMEM_SET(SET, int64_t); - TEST_SHMEM_SET(SET, uint32_t); - TEST_SHMEM_SET(SET, uint64_t); - TEST_SHMEM_SET(SET, size_t); - TEST_SHMEM_SET(SET, ptrdiff_t); -#endif /* ENABLE_DEPRECATED_TESTS */ - - TEST_SHMEM_SET(ATOMIC_SET, float); - TEST_SHMEM_SET(ATOMIC_SET, double); - TEST_SHMEM_SET(ATOMIC_SET, int); - TEST_SHMEM_SET(ATOMIC_SET, long); - TEST_SHMEM_SET(ATOMIC_SET, long long); - TEST_SHMEM_SET(ATOMIC_SET, unsigned int); - TEST_SHMEM_SET(ATOMIC_SET, unsigned long); - TEST_SHMEM_SET(ATOMIC_SET, unsigned long long); - TEST_SHMEM_SET(ATOMIC_SET, int32_t); - TEST_SHMEM_SET(ATOMIC_SET, int64_t); - TEST_SHMEM_SET(ATOMIC_SET, uint32_t); - TEST_SHMEM_SET(ATOMIC_SET, uint64_t); - TEST_SHMEM_SET(ATOMIC_SET, size_t); - TEST_SHMEM_SET(ATOMIC_SET, ptrdiff_t); - - TEST_SHMEM_SET(CTX_ATOMIC_SET, float); - TEST_SHMEM_SET(CTX_ATOMIC_SET, double); - TEST_SHMEM_SET(CTX_ATOMIC_SET, int); - TEST_SHMEM_SET(CTX_ATOMIC_SET, long); - TEST_SHMEM_SET(CTX_ATOMIC_SET, long long); - TEST_SHMEM_SET(CTX_ATOMIC_SET, unsigned int); - TEST_SHMEM_SET(CTX_ATOMIC_SET, unsigned long); - TEST_SHMEM_SET(CTX_ATOMIC_SET, unsigned long long); - TEST_SHMEM_SET(CTX_ATOMIC_SET, int32_t); - TEST_SHMEM_SET(CTX_ATOMIC_SET, int64_t); - TEST_SHMEM_SET(CTX_ATOMIC_SET, uint32_t); - TEST_SHMEM_SET(CTX_ATOMIC_SET, uint64_t); - TEST_SHMEM_SET(CTX_ATOMIC_SET, size_t); - TEST_SHMEM_SET(CTX_ATOMIC_SET, ptrdiff_t); - - shmem_finalize(); - return rc; -} diff --git a/test/shmemx/cxx_test_shmem_atomic_swap.cpp b/test/shmemx/cxx_test_shmem_atomic_swap.cpp deleted file mode 100644 index 496f240d2..000000000 --- a/test/shmemx/cxx_test_shmem_atomic_swap.cpp +++ /dev/null @@ -1,180 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include - -enum op { SWAP = 0, ATOMIC_SWAP, CTX_ATOMIC_SWAP, ATOMIC_SWAP_NBI, - CTX_ATOMIC_SWAP_NBI }; - -#ifdef ENABLE_DEPRECATED_TESTS -#define DEPRECATED_SWAP shmem_swap -#else -#define DEPRECATED_SWAP shmem_atomic_swap -#endif - -#define SHMEM_NBI_OPS_CASES(OP, TYPE) \ - case ATOMIC_SWAP_NBI: \ - shmem_atomic_swap_nbi(&old, &remote, \ - (TYPE)mype, (mype + 1) % npes); \ - break; \ - case CTX_ATOMIC_SWAP_NBI: \ - shmem_atomic_swap_nbi(SHMEM_CTX_DEFAULT, &old, &remote, \ - (TYPE)mype, (mype + 1) % npes); \ - break; - -#define TEST_SHMEM_SWAP(OP, TYPE) \ - do { \ - static TYPE remote; \ - TYPE old; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - remote = npes; \ - shmem_barrier_all(); \ - switch (OP) { \ - case SWAP: \ - old = DEPRECATED_SWAP(&remote, (TYPE)mype, (mype + 1) % npes); \ - break; \ - case ATOMIC_SWAP: \ - old = shmem_atomic_swap(&remote, (TYPE)mype, (mype + 1) % npes); \ - break; \ - case CTX_ATOMIC_SWAP: \ - old = shmem_atomic_swap(SHMEM_CTX_DEFAULT, &remote, \ - (TYPE)mype, (mype + 1) % npes); \ - break; \ - SHMEM_NBI_OPS_CASES(OP, TYPE) \ - default: \ - printf("invalid operation (%d)\n", OP); \ - shmem_global_exit(1); \ - } \ - shmem_barrier_all(); \ - if (remote != (TYPE)((mype + npes - 1) % npes)) { \ - printf("PE %i received incorrect value with " \ - "TEST_SHMEM_SWAP(%s, %s)\n", mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - if (old != (TYPE) npes) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (false) - - -int main(int argc, char* argv[]) { - shmem_init(); - - int rc = EXIT_SUCCESS; - -#ifdef ENABLE_DEPRECATED_TESTS - TEST_SHMEM_SWAP(SWAP, float); - TEST_SHMEM_SWAP(SWAP, double); - TEST_SHMEM_SWAP(SWAP, int); - TEST_SHMEM_SWAP(SWAP, long); - TEST_SHMEM_SWAP(SWAP, long long); - TEST_SHMEM_SWAP(SWAP, unsigned int); - TEST_SHMEM_SWAP(SWAP, unsigned long); - TEST_SHMEM_SWAP(SWAP, unsigned long long); - TEST_SHMEM_SWAP(SWAP, int32_t); - TEST_SHMEM_SWAP(SWAP, int64_t); - TEST_SHMEM_SWAP(SWAP, uint32_t); - TEST_SHMEM_SWAP(SWAP, uint64_t); - TEST_SHMEM_SWAP(SWAP, size_t); - TEST_SHMEM_SWAP(SWAP, ptrdiff_t); -#endif /* ENABLE_DEPRECATED_TESTS */ - - TEST_SHMEM_SWAP(ATOMIC_SWAP, float); - TEST_SHMEM_SWAP(ATOMIC_SWAP, double); - TEST_SHMEM_SWAP(ATOMIC_SWAP, int); - TEST_SHMEM_SWAP(ATOMIC_SWAP, long); - TEST_SHMEM_SWAP(ATOMIC_SWAP, long long); - TEST_SHMEM_SWAP(ATOMIC_SWAP, unsigned int); - TEST_SHMEM_SWAP(ATOMIC_SWAP, unsigned long); - TEST_SHMEM_SWAP(ATOMIC_SWAP, unsigned long long); - TEST_SHMEM_SWAP(ATOMIC_SWAP, int32_t); - TEST_SHMEM_SWAP(ATOMIC_SWAP, int64_t); - TEST_SHMEM_SWAP(ATOMIC_SWAP, uint32_t); - TEST_SHMEM_SWAP(ATOMIC_SWAP, uint64_t); - TEST_SHMEM_SWAP(ATOMIC_SWAP, size_t); - TEST_SHMEM_SWAP(ATOMIC_SWAP, ptrdiff_t); - - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP, float); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP, double); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP, int); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP, long); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP, long long); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP, unsigned int); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP, unsigned long); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP, unsigned long long); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP, int32_t); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP, int64_t); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP, uint32_t); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP, uint64_t); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP, size_t); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP, ptrdiff_t); - - TEST_SHMEM_SWAP(ATOMIC_SWAP_NBI, float); - TEST_SHMEM_SWAP(ATOMIC_SWAP_NBI, double); - TEST_SHMEM_SWAP(ATOMIC_SWAP_NBI, int); - TEST_SHMEM_SWAP(ATOMIC_SWAP_NBI, long); - TEST_SHMEM_SWAP(ATOMIC_SWAP_NBI, long long); - TEST_SHMEM_SWAP(ATOMIC_SWAP_NBI, unsigned int); - TEST_SHMEM_SWAP(ATOMIC_SWAP_NBI, unsigned long); - TEST_SHMEM_SWAP(ATOMIC_SWAP_NBI, unsigned long long); - TEST_SHMEM_SWAP(ATOMIC_SWAP_NBI, int32_t); - TEST_SHMEM_SWAP(ATOMIC_SWAP_NBI, int64_t); - TEST_SHMEM_SWAP(ATOMIC_SWAP_NBI, uint32_t); - TEST_SHMEM_SWAP(ATOMIC_SWAP_NBI, uint64_t); - TEST_SHMEM_SWAP(ATOMIC_SWAP_NBI, size_t); - TEST_SHMEM_SWAP(ATOMIC_SWAP_NBI, ptrdiff_t); - - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP_NBI, float); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP_NBI, double); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP_NBI, int); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP_NBI, long); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP_NBI, long long); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP_NBI, unsigned int); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP_NBI, unsigned long); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP_NBI, unsigned long long); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP_NBI, int32_t); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP_NBI, int64_t); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP_NBI, uint32_t); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP_NBI, uint64_t); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP_NBI, size_t); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP_NBI, ptrdiff_t); - - shmem_finalize(); - return rc; -} diff --git a/test/shmemx/cxx_test_shmem_atomic_xor.cpp b/test/shmemx/cxx_test_shmem_atomic_xor.cpp deleted file mode 100644 index 1350cba70..000000000 --- a/test/shmemx/cxx_test_shmem_atomic_xor.cpp +++ /dev/null @@ -1,169 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include -#include - -enum op { XOR = 0, CTX_XOR, FETCH_XOR, CTX_FETCH_XOR, FETCH_XOR_NBI, - CTX_FETCH_XOR_NBI }; - -/* Initially, remote = 111...b. Each PE performs an atomic XOR where the - * PEth bit of the input value is set to 1 and all other bits are set to 0. - * The result has the NPES least significant bits cleared, 111...000...b. - */ - -#define SHMEM_NBI_OPS_CASES(OP, TYPE) \ - case FETCH_XOR_NBI: \ - shmem_atomic_fetch_xor_nbi(&old, &remote, \ - (TYPE)(1LLU << mype), i); \ - shmem_quiet(); \ - if (((old ^ (TYPE)(1LLU << mype)) & (TYPE)(1LLU << mype)) != 0) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - case CTX_FETCH_XOR_NBI: \ - shmem_atomic_fetch_xor_nbi(SHMEM_CTX_DEFAULT, &old, &remote, \ - (TYPE)(1LLU << mype), i); \ - shmem_quiet(); \ - if (((old ^ (TYPE)(1LLU << mype)) & (TYPE)(1LLU << mype)) != 0) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; - -#define TEST_SHMEM_XOR(OP, TYPE) \ - do { \ - static TYPE remote = ~(TYPE)0; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - TYPE old; \ - if ((size_t) npes-1 > sizeof(TYPE)) break; /* Avoid overflow */ \ - for (int i = 0; i < npes; i++) \ - switch (OP) { \ - case XOR: \ - shmem_atomic_xor(&remote, (TYPE)(1LLU << mype), i); \ - break; \ - case CTX_XOR: \ - shmem_atomic_xor(SHMEM_CTX_DEFAULT, &remote, (TYPE)(1LLU << mype), i); \ - break; \ - case FETCH_XOR: \ - old = shmem_atomic_fetch_xor(&remote, (TYPE)(1LLU << mype), i); \ - if (((old ^ (TYPE)(1LLU << mype)) & (TYPE)(1LLU << mype)) != 0) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - case CTX_FETCH_XOR: \ - old = shmem_atomic_fetch_xor(SHMEM_CTX_DEFAULT, &remote, (TYPE)(1LLU << mype), i); \ - if (((old ^ (TYPE)(1LLU << mype)) & (TYPE)(1LLU << mype)) != 0) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - SHMEM_NBI_OPS_CASES(OP, TYPE) \ - default: \ - printf("Invalid operation (%d)\n", OP); \ - shmem_global_exit(1); \ - } \ - shmem_barrier_all(); \ - if (remote != ~(TYPE)((1LLU << npes) - 1LLU)) { \ - printf("PE %i observed error with TEST_SHMEM_XOR(%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (false) - - -int main(int argc, char* argv[]) { - shmem_init(); - - int rc = EXIT_SUCCESS; - TEST_SHMEM_XOR(XOR, unsigned int); - TEST_SHMEM_XOR(XOR, unsigned long); - TEST_SHMEM_XOR(XOR, unsigned long long); - TEST_SHMEM_XOR(XOR, int32_t); - TEST_SHMEM_XOR(XOR, int64_t); - TEST_SHMEM_XOR(XOR, uint32_t); - TEST_SHMEM_XOR(XOR, uint64_t); - - TEST_SHMEM_XOR(CTX_XOR, unsigned int); - TEST_SHMEM_XOR(CTX_XOR, unsigned long); - TEST_SHMEM_XOR(CTX_XOR, unsigned long long); - TEST_SHMEM_XOR(CTX_XOR, int32_t); - TEST_SHMEM_XOR(CTX_XOR, int64_t); - TEST_SHMEM_XOR(CTX_XOR, uint32_t); - TEST_SHMEM_XOR(CTX_XOR, uint64_t); - - TEST_SHMEM_XOR(FETCH_XOR, unsigned int); - TEST_SHMEM_XOR(FETCH_XOR, unsigned long); - TEST_SHMEM_XOR(FETCH_XOR, unsigned long long); - TEST_SHMEM_XOR(FETCH_XOR, int32_t); - TEST_SHMEM_XOR(FETCH_XOR, int64_t); - TEST_SHMEM_XOR(FETCH_XOR, uint32_t); - TEST_SHMEM_XOR(FETCH_XOR, uint64_t); - - TEST_SHMEM_XOR(CTX_FETCH_XOR, unsigned int); - TEST_SHMEM_XOR(CTX_FETCH_XOR, unsigned long); - TEST_SHMEM_XOR(CTX_FETCH_XOR, unsigned long long); - TEST_SHMEM_XOR(CTX_FETCH_XOR, int32_t); - TEST_SHMEM_XOR(CTX_FETCH_XOR, int64_t); - TEST_SHMEM_XOR(CTX_FETCH_XOR, uint32_t); - TEST_SHMEM_XOR(CTX_FETCH_XOR, uint64_t); - - TEST_SHMEM_XOR(FETCH_XOR_NBI, unsigned int); - TEST_SHMEM_XOR(FETCH_XOR_NBI, unsigned long); - TEST_SHMEM_XOR(FETCH_XOR_NBI, unsigned long long); - TEST_SHMEM_XOR(FETCH_XOR_NBI, int32_t); - TEST_SHMEM_XOR(FETCH_XOR_NBI, int64_t); - TEST_SHMEM_XOR(FETCH_XOR_NBI, uint32_t); - TEST_SHMEM_XOR(FETCH_XOR_NBI, uint64_t); - - TEST_SHMEM_XOR(CTX_FETCH_XOR_NBI, unsigned int); - TEST_SHMEM_XOR(CTX_FETCH_XOR_NBI, unsigned long); - TEST_SHMEM_XOR(CTX_FETCH_XOR_NBI, unsigned long long); - TEST_SHMEM_XOR(CTX_FETCH_XOR_NBI, int32_t); - TEST_SHMEM_XOR(CTX_FETCH_XOR_NBI, int64_t); - TEST_SHMEM_XOR(CTX_FETCH_XOR_NBI, uint32_t); - TEST_SHMEM_XOR(CTX_FETCH_XOR_NBI, uint64_t); - - shmem_finalize(); - return rc; -} diff --git a/test/shmemx/cxx_test_shmem_g.cpp b/test/shmemx/cxx_test_shmem_g.cpp deleted file mode 100644 index a7912a789..000000000 --- a/test/shmemx/cxx_test_shmem_g.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include - -#define TEST_SHMEM_G(USE_CTX, TYPE) \ - do { \ - static TYPE remote; \ - TYPE val; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - remote = (TYPE)mype; \ - shmem_barrier_all(); \ - if (USE_CTX) \ - val = shmem_g(SHMEM_CTX_DEFAULT, &remote, (mype + 1) % npes); \ - else \ - val = shmem_g(&remote, (mype + 1) % npes); \ - if (val != (TYPE)((mype + 1) % npes)) { \ - printf("PE %i received incorrect value with" \ - "TEST_SHMEM_G(%d, %s)\n", mype, \ - (int)(USE_CTX), #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (false) - -int main(int argc, char* argv[]) { - shmem_init(); - - int rc = EXIT_SUCCESS; - TEST_SHMEM_G(0, float); - TEST_SHMEM_G(0, double); - TEST_SHMEM_G(0, long double); - TEST_SHMEM_G(0, char); - TEST_SHMEM_G(0, signed char); - TEST_SHMEM_G(0, short); - TEST_SHMEM_G(0, int); - TEST_SHMEM_G(0, long); - TEST_SHMEM_G(0, long long); - TEST_SHMEM_G(0, unsigned char); - TEST_SHMEM_G(0, unsigned short); - TEST_SHMEM_G(0, unsigned int); - TEST_SHMEM_G(0, unsigned long); - TEST_SHMEM_G(0, unsigned long long); - TEST_SHMEM_G(0, int8_t); - TEST_SHMEM_G(0, int16_t); - TEST_SHMEM_G(0, int32_t); - TEST_SHMEM_G(0, int64_t); - TEST_SHMEM_G(0, uint8_t); - TEST_SHMEM_G(0, uint16_t); - TEST_SHMEM_G(0, uint32_t); - TEST_SHMEM_G(0, uint64_t); - TEST_SHMEM_G(0, size_t); - TEST_SHMEM_G(0, ptrdiff_t); - - TEST_SHMEM_G(1, float); - TEST_SHMEM_G(1, double); - TEST_SHMEM_G(1, long double); - TEST_SHMEM_G(1, char); - TEST_SHMEM_G(1, signed char); - TEST_SHMEM_G(1, short); - TEST_SHMEM_G(1, int); - TEST_SHMEM_G(1, long); - TEST_SHMEM_G(1, long long); - TEST_SHMEM_G(1, unsigned char); - TEST_SHMEM_G(1, unsigned short); - TEST_SHMEM_G(1, unsigned int); - TEST_SHMEM_G(1, unsigned long); - TEST_SHMEM_G(1, unsigned long long); - TEST_SHMEM_G(1, int8_t); - TEST_SHMEM_G(1, int16_t); - TEST_SHMEM_G(1, int32_t); - TEST_SHMEM_G(1, int64_t); - TEST_SHMEM_G(1, uint8_t); - TEST_SHMEM_G(1, uint16_t); - TEST_SHMEM_G(1, uint32_t); - TEST_SHMEM_G(1, uint64_t); - TEST_SHMEM_G(1, size_t); - TEST_SHMEM_G(1, ptrdiff_t); - - shmem_finalize(); - return rc; -} diff --git a/test/shmemx/cxx_test_shmem_get.cpp b/test/shmemx/cxx_test_shmem_get.cpp deleted file mode 100644 index 437c27977..000000000 --- a/test/shmemx/cxx_test_shmem_get.cpp +++ /dev/null @@ -1,239 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include - -enum op { GET = 0, IGET, GET_NBI }; - -#define TEST_SHMEM_GET(OP, USE_CTX, TYPE) \ - do { \ - static TYPE remote[10]; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - TYPE local[10]; \ - for (int i = 0; i < 10; i++) \ - remote[i] = (TYPE)mype; \ - shmem_barrier_all(); \ - switch (OP) { \ - case GET: \ - if (USE_CTX) \ - shmem_get(SHMEM_CTX_DEFAULT, local, remote, 10, (mype + 1) % npes); \ - else \ - shmem_get(local, remote, 10, (mype + 1) % npes); \ - break; \ - case IGET: \ - if (USE_CTX) \ - shmem_iget(SHMEM_CTX_DEFAULT, local, remote, 1, 1, 10, (mype + 1) % npes); \ - else \ - shmem_iget(local, remote, 1, 1, 10, (mype + 1) % npes); \ - break; \ - case GET_NBI: \ - if (USE_CTX) \ - shmem_get_nbi(SHMEM_CTX_DEFAULT, local, remote, 10, (mype + 1) % npes); \ - else \ - shmem_get_nbi(local, remote, 10, (mype + 1) % npes); \ - shmem_quiet(); \ - break; \ - default: \ - printf("Invalid operation (%d)\n", OP); \ - shmem_global_exit(1); \ - } \ - for (int i = 0; i < 10; i++) \ - if (local[i] != (TYPE)((mype + 1) % npes)) { \ - printf("PE %i received incorrect value with" \ - "TEST_SHMEM_GET(%s, %d, %s)\n", mype, #OP, \ - (int)(USE_CTX), #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (false) - -int main(int argc, char* argv[]) { - shmem_init(); - - int rc = EXIT_SUCCESS; - TEST_SHMEM_GET(GET, 0, float); - TEST_SHMEM_GET(GET, 0, double); - TEST_SHMEM_GET(GET, 0, long double); - TEST_SHMEM_GET(GET, 0, char); - TEST_SHMEM_GET(GET, 0, signed char); - TEST_SHMEM_GET(GET, 0, short); - TEST_SHMEM_GET(GET, 0, int); - TEST_SHMEM_GET(GET, 0, long); - TEST_SHMEM_GET(GET, 0, long long); - TEST_SHMEM_GET(GET, 0, unsigned char); - TEST_SHMEM_GET(GET, 0, unsigned short); - TEST_SHMEM_GET(GET, 0, unsigned int); - TEST_SHMEM_GET(GET, 0, unsigned long); - TEST_SHMEM_GET(GET, 0, unsigned long long); - TEST_SHMEM_GET(GET, 0, int8_t); - TEST_SHMEM_GET(GET, 0, int16_t); - TEST_SHMEM_GET(GET, 0, int32_t); - TEST_SHMEM_GET(GET, 0, int64_t); - TEST_SHMEM_GET(GET, 0, uint8_t); - TEST_SHMEM_GET(GET, 0, uint16_t); - TEST_SHMEM_GET(GET, 0, uint32_t); - TEST_SHMEM_GET(GET, 0, uint64_t); - TEST_SHMEM_GET(GET, 0, size_t); - TEST_SHMEM_GET(GET, 0, ptrdiff_t); - - TEST_SHMEM_GET(GET, 1, float); - TEST_SHMEM_GET(GET, 1, double); - TEST_SHMEM_GET(GET, 1, long double); - TEST_SHMEM_GET(GET, 1, char); - TEST_SHMEM_GET(GET, 1, signed char); - TEST_SHMEM_GET(GET, 1, short); - TEST_SHMEM_GET(GET, 1, int); - TEST_SHMEM_GET(GET, 1, long); - TEST_SHMEM_GET(GET, 1, long long); - TEST_SHMEM_GET(GET, 1, unsigned char); - TEST_SHMEM_GET(GET, 1, unsigned short); - TEST_SHMEM_GET(GET, 1, unsigned int); - TEST_SHMEM_GET(GET, 1, unsigned long); - TEST_SHMEM_GET(GET, 1, unsigned long long); - TEST_SHMEM_GET(GET, 1, int8_t); - TEST_SHMEM_GET(GET, 1, int16_t); - TEST_SHMEM_GET(GET, 1, int32_t); - TEST_SHMEM_GET(GET, 1, int64_t); - TEST_SHMEM_GET(GET, 1, uint8_t); - TEST_SHMEM_GET(GET, 1, uint16_t); - TEST_SHMEM_GET(GET, 1, uint32_t); - TEST_SHMEM_GET(GET, 1, uint64_t); - TEST_SHMEM_GET(GET, 1, size_t); - TEST_SHMEM_GET(GET, 1, ptrdiff_t); - - TEST_SHMEM_GET(IGET, 0, float); - TEST_SHMEM_GET(IGET, 0, double); - TEST_SHMEM_GET(IGET, 0, long double); - TEST_SHMEM_GET(IGET, 0, char); - TEST_SHMEM_GET(IGET, 0, signed char); - TEST_SHMEM_GET(IGET, 0, short); - TEST_SHMEM_GET(IGET, 0, int); - TEST_SHMEM_GET(IGET, 0, long); - TEST_SHMEM_GET(IGET, 0, long long); - TEST_SHMEM_GET(IGET, 0, unsigned char); - TEST_SHMEM_GET(IGET, 0, unsigned short); - TEST_SHMEM_GET(IGET, 0, unsigned int); - TEST_SHMEM_GET(IGET, 0, unsigned long); - TEST_SHMEM_GET(IGET, 0, unsigned long long); - TEST_SHMEM_GET(IGET, 0, int8_t); - TEST_SHMEM_GET(IGET, 0, int16_t); - TEST_SHMEM_GET(IGET, 0, int32_t); - TEST_SHMEM_GET(IGET, 0, int64_t); - TEST_SHMEM_GET(IGET, 0, uint8_t); - TEST_SHMEM_GET(IGET, 0, uint16_t); - TEST_SHMEM_GET(IGET, 0, uint32_t); - TEST_SHMEM_GET(IGET, 0, uint64_t); - TEST_SHMEM_GET(IGET, 0, size_t); - TEST_SHMEM_GET(IGET, 0, ptrdiff_t); - - TEST_SHMEM_GET(IGET, 1, float); - TEST_SHMEM_GET(IGET, 1, double); - TEST_SHMEM_GET(IGET, 1, long double); - TEST_SHMEM_GET(IGET, 1, char); - TEST_SHMEM_GET(IGET, 1, signed char); - TEST_SHMEM_GET(IGET, 1, short); - TEST_SHMEM_GET(IGET, 1, int); - TEST_SHMEM_GET(IGET, 1, long); - TEST_SHMEM_GET(IGET, 1, long long); - TEST_SHMEM_GET(IGET, 1, unsigned char); - TEST_SHMEM_GET(IGET, 1, unsigned short); - TEST_SHMEM_GET(IGET, 1, unsigned int); - TEST_SHMEM_GET(IGET, 1, unsigned long); - TEST_SHMEM_GET(IGET, 1, unsigned long long); - TEST_SHMEM_GET(IGET, 1, int8_t); - TEST_SHMEM_GET(IGET, 1, int16_t); - TEST_SHMEM_GET(IGET, 1, int32_t); - TEST_SHMEM_GET(IGET, 1, int64_t); - TEST_SHMEM_GET(IGET, 1, uint8_t); - TEST_SHMEM_GET(IGET, 1, uint16_t); - TEST_SHMEM_GET(IGET, 1, uint32_t); - TEST_SHMEM_GET(IGET, 1, uint64_t); - TEST_SHMEM_GET(IGET, 1, size_t); - TEST_SHMEM_GET(IGET, 1, ptrdiff_t); - - TEST_SHMEM_GET(GET_NBI, 0, float); - TEST_SHMEM_GET(GET_NBI, 0, double); - TEST_SHMEM_GET(GET_NBI, 0, long double); - TEST_SHMEM_GET(GET_NBI, 0, char); - TEST_SHMEM_GET(GET_NBI, 0, signed char); - TEST_SHMEM_GET(GET_NBI, 0, short); - TEST_SHMEM_GET(GET_NBI, 0, int); - TEST_SHMEM_GET(GET_NBI, 0, long); - TEST_SHMEM_GET(GET_NBI, 0, long long); - TEST_SHMEM_GET(GET_NBI, 0, unsigned char); - TEST_SHMEM_GET(GET_NBI, 0, unsigned short); - TEST_SHMEM_GET(GET_NBI, 0, unsigned int); - TEST_SHMEM_GET(GET_NBI, 0, unsigned long); - TEST_SHMEM_GET(GET_NBI, 0, unsigned long long); - TEST_SHMEM_GET(GET_NBI, 0, int8_t); - TEST_SHMEM_GET(GET_NBI, 0, int16_t); - TEST_SHMEM_GET(GET_NBI, 0, int32_t); - TEST_SHMEM_GET(GET_NBI, 0, int64_t); - TEST_SHMEM_GET(GET_NBI, 0, uint8_t); - TEST_SHMEM_GET(GET_NBI, 0, uint16_t); - TEST_SHMEM_GET(GET_NBI, 0, uint32_t); - TEST_SHMEM_GET(GET_NBI, 0, uint64_t); - TEST_SHMEM_GET(GET_NBI, 0, size_t); - TEST_SHMEM_GET(GET_NBI, 0, ptrdiff_t); - - TEST_SHMEM_GET(GET_NBI, 1, float); - TEST_SHMEM_GET(GET_NBI, 1, double); - TEST_SHMEM_GET(GET_NBI, 1, long double); - TEST_SHMEM_GET(GET_NBI, 1, char); - TEST_SHMEM_GET(GET_NBI, 1, signed char); - TEST_SHMEM_GET(GET_NBI, 1, short); - TEST_SHMEM_GET(GET_NBI, 1, int); - TEST_SHMEM_GET(GET_NBI, 1, long); - TEST_SHMEM_GET(GET_NBI, 1, long long); - TEST_SHMEM_GET(GET_NBI, 1, unsigned char); - TEST_SHMEM_GET(GET_NBI, 1, unsigned short); - TEST_SHMEM_GET(GET_NBI, 1, unsigned int); - TEST_SHMEM_GET(GET_NBI, 1, unsigned long); - TEST_SHMEM_GET(GET_NBI, 1, unsigned long long); - TEST_SHMEM_GET(GET_NBI, 1, int8_t); - TEST_SHMEM_GET(GET_NBI, 1, int16_t); - TEST_SHMEM_GET(GET_NBI, 1, int32_t); - TEST_SHMEM_GET(GET_NBI, 1, int64_t); - TEST_SHMEM_GET(GET_NBI, 1, uint8_t); - TEST_SHMEM_GET(GET_NBI, 1, uint16_t); - TEST_SHMEM_GET(GET_NBI, 1, uint32_t); - TEST_SHMEM_GET(GET_NBI, 1, uint64_t); - TEST_SHMEM_GET(GET_NBI, 1, size_t); - TEST_SHMEM_GET(GET_NBI, 1, ptrdiff_t); - - shmem_finalize(); - return rc; -} diff --git a/test/shmemx/cxx_test_shmem_p.cpp b/test/shmemx/cxx_test_shmem_p.cpp deleted file mode 100644 index 9dfbd7ece..000000000 --- a/test/shmemx/cxx_test_shmem_p.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include - -#define TEST_SHMEM_P(USE_CTX, TYPE) \ - do { \ - static TYPE remote; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - if (USE_CTX) \ - shmem_p(SHMEM_CTX_DEFAULT, &remote, (TYPE)mype, (mype + 1) % npes); \ - else \ - shmem_p(&remote, (TYPE)mype, (mype + 1) % npes);\ - shmem_barrier_all(); \ - if (remote != (TYPE)((mype + npes - 1) % npes)) { \ - printf("PE %i received incorrect value with " \ - "TEST_SHMEM_P(%d, %s)\n", mype, \ - (int)(USE_CTX), #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (false) - -int main(int argc, char* argv[]) { - shmem_init(); - - int rc = EXIT_SUCCESS; - TEST_SHMEM_P(0, float); - TEST_SHMEM_P(0, double); - TEST_SHMEM_P(0, long double); - TEST_SHMEM_P(0, char); - TEST_SHMEM_P(0, signed char); - TEST_SHMEM_P(0, short); - TEST_SHMEM_P(0, int); - TEST_SHMEM_P(0, long); - TEST_SHMEM_P(0, long long); - TEST_SHMEM_P(0, unsigned char); - TEST_SHMEM_P(0, unsigned short); - TEST_SHMEM_P(0, unsigned int); - TEST_SHMEM_P(0, unsigned long); - TEST_SHMEM_P(0, unsigned long long); - TEST_SHMEM_P(0, int8_t); - TEST_SHMEM_P(0, int16_t); - TEST_SHMEM_P(0, int32_t); - TEST_SHMEM_P(0, int64_t); - TEST_SHMEM_P(0, uint8_t); - TEST_SHMEM_P(0, uint16_t); - TEST_SHMEM_P(0, uint32_t); - TEST_SHMEM_P(0, uint64_t); - TEST_SHMEM_P(0, size_t); - TEST_SHMEM_P(0, ptrdiff_t); - - TEST_SHMEM_P(1, float); - TEST_SHMEM_P(1, double); - TEST_SHMEM_P(1, long double); - TEST_SHMEM_P(1, char); - TEST_SHMEM_P(1, signed char); - TEST_SHMEM_P(1, short); - TEST_SHMEM_P(1, int); - TEST_SHMEM_P(1, long); - TEST_SHMEM_P(1, long long); - TEST_SHMEM_P(1, unsigned char); - TEST_SHMEM_P(1, unsigned short); - TEST_SHMEM_P(1, unsigned int); - TEST_SHMEM_P(1, unsigned long); - TEST_SHMEM_P(1, unsigned long long); - TEST_SHMEM_P(1, int8_t); - TEST_SHMEM_P(1, int16_t); - TEST_SHMEM_P(1, int32_t); - TEST_SHMEM_P(1, int64_t); - TEST_SHMEM_P(1, uint8_t); - TEST_SHMEM_P(1, uint16_t); - TEST_SHMEM_P(1, uint32_t); - TEST_SHMEM_P(1, uint64_t); - TEST_SHMEM_P(1, size_t); - TEST_SHMEM_P(1, ptrdiff_t); - - shmem_finalize(); - return rc; -} diff --git a/test/shmemx/cxx_test_shmem_put.cpp b/test/shmemx/cxx_test_shmem_put.cpp deleted file mode 100644 index 196df8d0b..000000000 --- a/test/shmemx/cxx_test_shmem_put.cpp +++ /dev/null @@ -1,239 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include - -enum op { PUT = 0, IPUT, PUT_NBI }; - -#define TEST_SHMEM_PUT(OP, USE_CTX, TYPE) \ - do { \ - static TYPE remote[10]; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - TYPE local[10]; \ - for (int i = 0; i < 10; i++) \ - local[i] = (TYPE)mype; \ - switch (OP) { \ - case PUT: \ - if (USE_CTX) \ - shmem_put(SHMEM_CTX_DEFAULT, remote, local, 10, (mype + 1) % npes); \ - else \ - shmem_put(remote, local, 10, (mype + 1) % npes); \ - break; \ - case IPUT: \ - if (USE_CTX) \ - shmem_iput(SHMEM_CTX_DEFAULT, remote, local, 1, 1, 10, (mype + 1) % npes); \ - else \ - shmem_iput(remote, local, 1, 1, 10, (mype + 1) % npes); \ - break; \ - case PUT_NBI: \ - if (USE_CTX) \ - shmem_put_nbi(SHMEM_CTX_DEFAULT, remote, local, 10, (mype + 1) % npes); \ - else \ - shmem_put_nbi(remote, local, 10, (mype + 1) % npes); \ - shmem_quiet(); \ - break; \ - default: \ - printf("Invalid operation (%d)\n", OP); \ - shmem_global_exit(1); \ - } \ - shmem_barrier_all(); \ - for (int i = 0; i < 10; i++) \ - if (remote[i] != (TYPE)((mype + npes - 1) % npes)) { \ - printf("PE %i received incorrect value with " \ - "TEST_SHMEM_PUT(%s, %d, %s)\n", mype, \ - #OP, (int)(USE_CTX), #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (false) - -int main(int argc, char* argv[]) { - shmem_init(); - - int rc = EXIT_SUCCESS; - TEST_SHMEM_PUT(PUT, 0, float); - TEST_SHMEM_PUT(PUT, 0, double); - TEST_SHMEM_PUT(PUT, 0, long double); - TEST_SHMEM_PUT(PUT, 0, char); - TEST_SHMEM_PUT(PUT, 0, signed char); - TEST_SHMEM_PUT(PUT, 0, short); - TEST_SHMEM_PUT(PUT, 0, int); - TEST_SHMEM_PUT(PUT, 0, long); - TEST_SHMEM_PUT(PUT, 0, long long); - TEST_SHMEM_PUT(PUT, 0, unsigned char); - TEST_SHMEM_PUT(PUT, 0, unsigned short); - TEST_SHMEM_PUT(PUT, 0, unsigned int); - TEST_SHMEM_PUT(PUT, 0, unsigned long); - TEST_SHMEM_PUT(PUT, 0, unsigned long long); - TEST_SHMEM_PUT(PUT, 0, int8_t); - TEST_SHMEM_PUT(PUT, 0, int16_t); - TEST_SHMEM_PUT(PUT, 0, int32_t); - TEST_SHMEM_PUT(PUT, 0, int64_t); - TEST_SHMEM_PUT(PUT, 0, uint8_t); - TEST_SHMEM_PUT(PUT, 0, uint16_t); - TEST_SHMEM_PUT(PUT, 0, uint32_t); - TEST_SHMEM_PUT(PUT, 0, uint64_t); - TEST_SHMEM_PUT(PUT, 0, size_t); - TEST_SHMEM_PUT(PUT, 0, ptrdiff_t); - - TEST_SHMEM_PUT(PUT, 1, float); - TEST_SHMEM_PUT(PUT, 1, double); - TEST_SHMEM_PUT(PUT, 1, long double); - TEST_SHMEM_PUT(PUT, 1, char); - TEST_SHMEM_PUT(PUT, 1, signed char); - TEST_SHMEM_PUT(PUT, 1, short); - TEST_SHMEM_PUT(PUT, 1, int); - TEST_SHMEM_PUT(PUT, 1, long); - TEST_SHMEM_PUT(PUT, 1, long long); - TEST_SHMEM_PUT(PUT, 1, unsigned char); - TEST_SHMEM_PUT(PUT, 1, unsigned short); - TEST_SHMEM_PUT(PUT, 1, unsigned int); - TEST_SHMEM_PUT(PUT, 1, unsigned long); - TEST_SHMEM_PUT(PUT, 1, unsigned long long); - TEST_SHMEM_PUT(PUT, 1, int8_t); - TEST_SHMEM_PUT(PUT, 1, int16_t); - TEST_SHMEM_PUT(PUT, 1, int32_t); - TEST_SHMEM_PUT(PUT, 1, int64_t); - TEST_SHMEM_PUT(PUT, 1, uint8_t); - TEST_SHMEM_PUT(PUT, 1, uint16_t); - TEST_SHMEM_PUT(PUT, 1, uint32_t); - TEST_SHMEM_PUT(PUT, 1, uint64_t); - TEST_SHMEM_PUT(PUT, 1, size_t); - TEST_SHMEM_PUT(PUT, 1, ptrdiff_t); - - TEST_SHMEM_PUT(IPUT, 0, float); - TEST_SHMEM_PUT(IPUT, 0, double); - TEST_SHMEM_PUT(IPUT, 0, long double); - TEST_SHMEM_PUT(IPUT, 0, char); - TEST_SHMEM_PUT(IPUT, 0, signed char); - TEST_SHMEM_PUT(IPUT, 0, short); - TEST_SHMEM_PUT(IPUT, 0, int); - TEST_SHMEM_PUT(IPUT, 0, long); - TEST_SHMEM_PUT(IPUT, 0, long long); - TEST_SHMEM_PUT(IPUT, 0, unsigned char); - TEST_SHMEM_PUT(IPUT, 0, unsigned short); - TEST_SHMEM_PUT(IPUT, 0, unsigned int); - TEST_SHMEM_PUT(IPUT, 0, unsigned long); - TEST_SHMEM_PUT(IPUT, 0, unsigned long long); - TEST_SHMEM_PUT(IPUT, 0, int8_t); - TEST_SHMEM_PUT(IPUT, 0, int16_t); - TEST_SHMEM_PUT(IPUT, 0, int32_t); - TEST_SHMEM_PUT(IPUT, 0, int64_t); - TEST_SHMEM_PUT(IPUT, 0, uint8_t); - TEST_SHMEM_PUT(IPUT, 0, uint16_t); - TEST_SHMEM_PUT(IPUT, 0, uint32_t); - TEST_SHMEM_PUT(IPUT, 0, uint64_t); - TEST_SHMEM_PUT(IPUT, 0, size_t); - TEST_SHMEM_PUT(IPUT, 0, ptrdiff_t); - - TEST_SHMEM_PUT(IPUT, 1, float); - TEST_SHMEM_PUT(IPUT, 1, double); - TEST_SHMEM_PUT(IPUT, 1, long double); - TEST_SHMEM_PUT(IPUT, 1, char); - TEST_SHMEM_PUT(IPUT, 1, signed char); - TEST_SHMEM_PUT(IPUT, 1, short); - TEST_SHMEM_PUT(IPUT, 1, int); - TEST_SHMEM_PUT(IPUT, 1, long); - TEST_SHMEM_PUT(IPUT, 1, long long); - TEST_SHMEM_PUT(IPUT, 1, unsigned char); - TEST_SHMEM_PUT(IPUT, 1, unsigned short); - TEST_SHMEM_PUT(IPUT, 1, unsigned int); - TEST_SHMEM_PUT(IPUT, 1, unsigned long); - TEST_SHMEM_PUT(IPUT, 1, unsigned long long); - TEST_SHMEM_PUT(IPUT, 1, int8_t); - TEST_SHMEM_PUT(IPUT, 1, int16_t); - TEST_SHMEM_PUT(IPUT, 1, int32_t); - TEST_SHMEM_PUT(IPUT, 1, int64_t); - TEST_SHMEM_PUT(IPUT, 1, uint8_t); - TEST_SHMEM_PUT(IPUT, 1, uint16_t); - TEST_SHMEM_PUT(IPUT, 1, uint32_t); - TEST_SHMEM_PUT(IPUT, 1, uint64_t); - TEST_SHMEM_PUT(IPUT, 1, size_t); - TEST_SHMEM_PUT(IPUT, 1, ptrdiff_t); - - TEST_SHMEM_PUT(PUT_NBI, 0, float); - TEST_SHMEM_PUT(PUT_NBI, 0, double); - TEST_SHMEM_PUT(PUT_NBI, 0, long double); - TEST_SHMEM_PUT(PUT_NBI, 0, char); - TEST_SHMEM_PUT(PUT_NBI, 0, signed char); - TEST_SHMEM_PUT(PUT_NBI, 0, short); - TEST_SHMEM_PUT(PUT_NBI, 0, int); - TEST_SHMEM_PUT(PUT_NBI, 0, long); - TEST_SHMEM_PUT(PUT_NBI, 0, long long); - TEST_SHMEM_PUT(PUT_NBI, 0, unsigned char); - TEST_SHMEM_PUT(PUT_NBI, 0, unsigned short); - TEST_SHMEM_PUT(PUT_NBI, 0, unsigned int); - TEST_SHMEM_PUT(PUT_NBI, 0, unsigned long); - TEST_SHMEM_PUT(PUT_NBI, 0, unsigned long long); - TEST_SHMEM_PUT(PUT_NBI, 0, int8_t); - TEST_SHMEM_PUT(PUT_NBI, 0, int16_t); - TEST_SHMEM_PUT(PUT_NBI, 0, int32_t); - TEST_SHMEM_PUT(PUT_NBI, 0, int64_t); - TEST_SHMEM_PUT(PUT_NBI, 0, uint8_t); - TEST_SHMEM_PUT(PUT_NBI, 0, uint16_t); - TEST_SHMEM_PUT(PUT_NBI, 0, uint32_t); - TEST_SHMEM_PUT(PUT_NBI, 0, uint64_t); - TEST_SHMEM_PUT(PUT_NBI, 0, size_t); - TEST_SHMEM_PUT(PUT_NBI, 0, ptrdiff_t); - - TEST_SHMEM_PUT(PUT_NBI, 1, float); - TEST_SHMEM_PUT(PUT_NBI, 1, double); - TEST_SHMEM_PUT(PUT_NBI, 1, long double); - TEST_SHMEM_PUT(PUT_NBI, 1, char); - TEST_SHMEM_PUT(PUT_NBI, 1, signed char); - TEST_SHMEM_PUT(PUT_NBI, 1, short); - TEST_SHMEM_PUT(PUT_NBI, 1, int); - TEST_SHMEM_PUT(PUT_NBI, 1, long); - TEST_SHMEM_PUT(PUT_NBI, 1, long long); - TEST_SHMEM_PUT(PUT_NBI, 1, unsigned char); - TEST_SHMEM_PUT(PUT_NBI, 1, unsigned short); - TEST_SHMEM_PUT(PUT_NBI, 1, unsigned int); - TEST_SHMEM_PUT(PUT_NBI, 1, unsigned long); - TEST_SHMEM_PUT(PUT_NBI, 1, unsigned long long); - TEST_SHMEM_PUT(PUT_NBI, 1, int8_t); - TEST_SHMEM_PUT(PUT_NBI, 1, int16_t); - TEST_SHMEM_PUT(PUT_NBI, 1, int32_t); - TEST_SHMEM_PUT(PUT_NBI, 1, int64_t); - TEST_SHMEM_PUT(PUT_NBI, 1, uint8_t); - TEST_SHMEM_PUT(PUT_NBI, 1, uint16_t); - TEST_SHMEM_PUT(PUT_NBI, 1, uint32_t); - TEST_SHMEM_PUT(PUT_NBI, 1, uint64_t); - TEST_SHMEM_PUT(PUT_NBI, 1, size_t); - TEST_SHMEM_PUT(PUT_NBI, 1, ptrdiff_t); - - shmem_finalize(); - return rc; -} diff --git a/test/shmemx/cxx_test_shmem_test.cpp b/test/shmemx/cxx_test_shmem_test.cpp deleted file mode 100644 index cfd491451..000000000 --- a/test/shmemx/cxx_test_shmem_test.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include - -#define TEST_SHMEM_TEST(TYPE) \ - do { \ - static TYPE remote = 0; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - shmem_p(&remote, (TYPE)mype+1, (mype + 1) % npes); \ - while (!shmem_test(&remote, SHMEM_CMP_NE, 0)) ; \ - if (remote != (TYPE)((mype + npes - 1) % npes)+1) { \ - printf("PE %i received incorrect value with " \ - "TEST_SHMEM_TEST(%s)\n", mype, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (false) - -int main(int argc, char* argv[]) { - shmem_init(); - - int rc = EXIT_SUCCESS; - TEST_SHMEM_TEST(int); - TEST_SHMEM_TEST(long); - TEST_SHMEM_TEST(long long); - TEST_SHMEM_TEST(unsigned int); - TEST_SHMEM_TEST(unsigned long); - TEST_SHMEM_TEST(unsigned long long); - TEST_SHMEM_TEST(int32_t); - TEST_SHMEM_TEST(int64_t); - TEST_SHMEM_TEST(uint32_t); - TEST_SHMEM_TEST(uint64_t); - TEST_SHMEM_TEST(size_t); - TEST_SHMEM_TEST(ptrdiff_t); - - shmem_finalize(); - return rc; -} diff --git a/test/shmemx/cxx_test_shmem_wait_until.cpp b/test/shmemx/cxx_test_shmem_wait_until.cpp deleted file mode 100644 index 3230a8eed..000000000 --- a/test/shmemx/cxx_test_shmem_wait_until.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include - -#define TEST_SHMEM_WAIT_UNTIL(TYPE) \ - do { \ - static TYPE remote = 0; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - shmem_p(&remote, (TYPE)mype+1, (mype + 1) % npes); \ - shmem_wait_until(&remote, SHMEM_CMP_NE, 0); \ - if (remote != (TYPE)((mype + npes - 1) % npes)+1) { \ - printf("PE %i received incorrect value with " \ - "TEST_SHMEM_WAIT_UNTIL(%s)\n", mype, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (false) - -int main(int argc, char* argv[]) { - shmem_init(); - - int rc = EXIT_SUCCESS; - TEST_SHMEM_WAIT_UNTIL(int); - TEST_SHMEM_WAIT_UNTIL(long); - TEST_SHMEM_WAIT_UNTIL(long long); - TEST_SHMEM_WAIT_UNTIL(unsigned int); - TEST_SHMEM_WAIT_UNTIL(unsigned long); - TEST_SHMEM_WAIT_UNTIL(unsigned long long); - TEST_SHMEM_WAIT_UNTIL(int32_t); - TEST_SHMEM_WAIT_UNTIL(int64_t); - TEST_SHMEM_WAIT_UNTIL(uint32_t); - TEST_SHMEM_WAIT_UNTIL(uint64_t); - TEST_SHMEM_WAIT_UNTIL(size_t); - TEST_SHMEM_WAIT_UNTIL(ptrdiff_t); - - shmem_finalize(); - return rc; -} diff --git a/test/shmemx/gettid_register.c b/test/shmemx/gettid_register.c deleted file mode 100644 index a018f7e79..000000000 --- a/test/shmemx/gettid_register.c +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright (c) 2018 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* Gettid Register Test: Register a custom gettid function pointer */ - -#include -#include -#include -#include -#include -#include - -#define T 8 - -int dest; - -int me, npes; -int errors = 0; - -pthread_key_t key; - -static uint64_t my_gettid(void) { - uint64_t tid_val = 0; - - void* ret = pthread_getspecific(key); - if (ret != NULL) - tid_val = * (uint64_t*) ret; - else { - printf("Calling pthread_getspecific(key) returned NULL\n"); - shmem_global_exit(3); - } - - return tid_val; -} - - -static void * thread_main(void *arg) { - int i; - - int ret = pthread_setspecific(key, arg); - assert(0 == ret); - - shmem_ctx_t ctx; - ret = shmem_ctx_create(SHMEM_CTX_PRIVATE, &ctx); - if (ret != 0) { - printf("Error creating context (%d)\n", ret); - ctx = SHMEM_CTX_DEFAULT; - } - - for (i = 1; i <= npes; i++) - shmem_ctx_int_atomic_add(ctx, &dest, *(uint64_t *)arg, (me + i) % npes); - - shmem_quiet(); - - if (ctx != SHMEM_CTX_DEFAULT) - shmem_ctx_destroy(ctx); - - return NULL; -} - - -int main(int argc, char **argv) { - int tl, i, ret; - pthread_t threads[T]; - uint64_t t_arg[T]; - - shmemx_register_gettid( &my_gettid ); - - ret = shmem_init_thread(SHMEM_THREAD_MULTIPLE, &tl); - - if (tl != SHMEM_THREAD_MULTIPLE || ret != 0) { - printf("Init failed (requested thread level %d, got %d, ret %d)\n", - SHMEM_THREAD_MULTIPLE, tl, ret); - - if (ret == 0) { - shmem_global_exit(1); - } else { - return ret; - } - } - - if (sizeof(pthread_t) > sizeof(uint64_t)) { - printf("Cannot run this test, size of pthread_t is larger than 64 bits\n"); - shmem_finalize(); - return 0; - } - - me = shmem_my_pe(); - npes = shmem_n_pes(); - - - if (me == 0) printf("Starting multithreaded test on %d PEs, %d threads/PE\n", npes, T); - - ret = pthread_key_create(&key, NULL); - assert(0 == ret); - - for (i = 0; i < T; i++) { - int err; - t_arg[i] = i; - err = pthread_create(&threads[i], NULL, thread_main, (void*) &t_arg[i]); - assert(0 == err); - } - - for (i = 0; i < T; i++) { - int err; - err = pthread_join(threads[i], NULL); - assert(0 == err); - } - - shmem_sync_all(); - - if (dest != ((T-1)*T/2)*npes) { - printf("%d: dest = %d, expected %d\n", me, dest, ((T-1)*T/2)*npes); - errors++; - } - - shmem_finalize(); - return (errors == 0) ? 0 : 1; -} diff --git a/test/shmemx/perf_counter.c b/test/shmemx/perf_counter.c deleted file mode 100644 index 9e5d40e53..000000000 --- a/test/shmemx/perf_counter.c +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (c) 2018 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* Single-threaded test for validation of performance counter APIs -*/ - -#include -#include -#include -#include - -#define ITER 100 -#define WINDOW 64 -#define LENGTH 1024 - -int me, npes; -char *src_array, *dest_array; -uint64_t c_put, c_get, p_put, p_get, target; - -static void collect(shmem_ctx_t ctx) { - shmemx_pcntr_get_completed_write(ctx, &c_put); - shmemx_pcntr_get_completed_read(ctx, &c_get); - shmemx_pcntr_get_completed_target(&target); - shmemx_pcntr_get_issued_write(ctx, &p_put); - shmemx_pcntr_get_issued_read(ctx, &p_get); -} - -static void put_and_progress_check(void) { - int i, j, ret; - int partner = ((npes % 2 == 0) ? (me % 2 == 0 ? me + 1 : me - 1) : - (me % 2 != 0 ? me - 1 : - (me == npes - 1) ? me : me + 1)); - - shmem_ctx_t ctx; - shmemx_pcntr_t pcntr; - ret = shmem_ctx_create(SHMEM_CTX_PRIVATE, &ctx); - if (ret) { - printf("Error creating context (%d)\n", ret); - ctx = SHMEM_CTX_DEFAULT; - } - - for (i = 0; i < ITER; i++) { - for (j = 0; j < WINDOW; j++) { - shmem_ctx_putmem_nbi(ctx, dest_array, src_array, LENGTH, partner); - collect(ctx); - } - shmem_ctx_quiet(ctx); - } - - shmemx_pcntr_get_all(ctx, &pcntr); - if (ctx != SHMEM_CTX_DEFAULT) - shmem_ctx_destroy(ctx); - - /* Report the counter values observed through get_all API after the loop - * completion. Except the target counter, other counter values should - * reflect the final expected value */ - printf("Value observed of the performance counters from combined API: \n" - "Completed Put = %10"PRIu64"\n" - "Completed Get = %10"PRIu64"\n" - "Issued Put = %10"PRIu64"\n" - "Issued Get = %10"PRIu64"\n" - "Target = %10"PRIu64"\n" - , pcntr.completed_put, pcntr.completed_get, pcntr.pending_put, - pcntr.pending_get, pcntr.target); - - return; -} - -int main(int argc, char **argv) { - - shmem_init(); - - me = shmem_my_pe(); - npes = shmem_n_pes(); - - src_array = shmem_malloc(LENGTH); - dest_array = shmem_malloc(LENGTH); - - if (me == 0) { - printf("Performance counter API test with %d PEs\n", npes); - } - - put_and_progress_check(); - shmem_barrier_all(); - - /* Report the counter values observed through single parameter APIs in - * the final iteration. The values reported here may be less than the actual - * final value as they are captured before the barrier one counter at a time - * */ - printf("Final value observed of the performance counters from individual APIs: \n" - "Completed Put = %10"PRIu64"\n" - "Completed Get = %10"PRIu64"\n" - "Issued Put = %10"PRIu64"\n" - "Issued Get = %10"PRIu64"\n" - "Target = %10"PRIu64"\n" - , c_put, c_get, p_put, p_get, target); - - shmem_free(dest_array); - shmem_free(src_array); - - shmem_finalize(); - return 0; -} diff --git a/test/shmemx/shmem_ct.c b/test/shmemx/shmem_ct.c deleted file mode 100644 index 53379d98e..000000000 --- a/test/shmemx/shmem_ct.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include - -int data; - -int main(int argc, char **argv) { - int me, npes, i; - int mine, ct_val; - shmemx_ct_t ct; - - shmem_init(); - me = mine = shmem_my_pe(); - npes = shmem_n_pes(); - - shmemx_ct_create(&ct); - ct_val = shmemx_ct_get(ct); - - if (ct_val != 0) { - printf("[%3d] Error: Initial value of ct was nonzero (%d)\n", me, ct_val); - shmem_global_exit(1); - } - - /* TEST 1: Everyone puts to rank 0 */ - shmem_barrier_all(); - shmemx_putmem_ct(ct, &data, &mine, sizeof(int), 0); - - if (me == 0) { - shmemx_ct_wait(ct, npes); - } - shmem_barrier_all(); - - /* Reset the counter */ - shmemx_ct_set(ct, 0); - ct_val = shmemx_ct_get(ct); - if (ct_val != 0) { - printf("[%3d] Error: Reset value of ct was nonzero (%d)\n", me, ct_val); - shmem_global_exit(1); - } - - /* TEST 1.5: Everyone gets from rank 0 */ - data = -1; - shmem_barrier_all(); - shmemx_getmem_ct(ct, &mine, &data, sizeof(int), 0); - - if (me == 0) { - shmemx_ct_wait(ct, npes); - } - shmem_barrier_all(); - - if (mine != -1) { - printf("[%3d] Error: Getmem_ct value read was incorrect (%d)\n", me, mine); - shmem_global_exit(1); - } - - /* Reset the counter */ - shmemx_ct_set(ct, 0); - ct_val = shmemx_ct_get(ct); - if (ct_val != 0) { - printf("[%3d] Error: Reset value of ct was nonzero (%d)\n", me, ct_val); - shmem_global_exit(1); - } - - /* TEST 2: Everyone puts to every other rank, but not themselves */ - shmem_barrier_all(); - - for (i = 1; i < npes; i++) - shmemx_putmem_ct(ct, &data, &mine, sizeof(int), (me + i) % npes); - - shmemx_ct_wait(ct, npes-1); - - shmem_barrier_all(); - shmemx_ct_free(&ct); - - shmem_finalize(); - - return 0; -} diff --git a/test/shmemx/shmem_malloc_with_hints.c b/test/shmemx/shmem_malloc_with_hints.c deleted file mode 100644 index 6fe78ee9d..000000000 --- a/test/shmemx/shmem_malloc_with_hints.c +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2022 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include - -#define N 128 -#define SHMEM_MALLOC_INVALID_HINT ~(SHMEM_MALLOC_ATOMICS_REMOTE) - -int main(int argc, char **argv) { - int npes, mype; - int errors = 0; - - shmem_init(); - - npes = shmem_n_pes(); - mype = shmem_my_pe(); - - int *src[N]; - - /* Allocate an array of N buffers on the symmeytric heap */ - for (int i = 0; i < N; i++) - src[i] = (int *)shmem_malloc_with_hints(N * sizeof(int), SHMEMX_MALLOC_NO_BARRIER); - - shmem_barrier_all(); /* Synchronization is required after using the SHMEMX_MALLOC_NO_BARRIER hint */ - int *dst = (int *)malloc(N * sizeof(int)); - - for (int i = 0; i < N; i++) { - for (int j = 0; j < N; j++) { - src[i][j] = -1; - } - } - - /* src is initialized to become a diagonal matrix */ - for (int i = 0; i < N; i++) { - src[i][i] = i; - dst[i] = -1; - } - - shmem_sync_all(); /* sync sender and receiver */ - - if (mype == 0) { - for (int i = 0; i < N; i++) { - /* get elements from src's diagonal on each PE and copy into dst on PE 0 */ - shmem_int_get(&dst[i], &src[i][i], 1, i % npes); - } - } - - shmem_barrier_all(); /* sync sender and receiver */ - - if (mype == 0) { - for (int i = 0 ; i < N ; ++i) { - if (src[i][i] != dst[i]) { - printf("%d,%d ", src[i][i], dst[i]); - ++errors; - } - } - if(errors) { - printf("\nFailed with %d errors\n", errors); - shmem_global_exit(errors); - } - } - - for (int i = 0; i < N; i++) - shmem_free(src[i]); - free(dst); - - if (mype == 0) - printf("Passed with 0 errors\n"); - - shmem_finalize(); - - return 0; -} diff --git a/test/shmemx/shmemx_team_node.c b/test/shmemx/shmemx_team_node.c deleted file mode 100644 index 8fb8d3742..000000000 --- a/test/shmemx/shmemx_team_node.c +++ /dev/null @@ -1,54 +0,0 @@ -/* Copyright (c) 2023 Intel Corporation. - * SPDX-License-Identifier: BSD-3-Clause - * - * This file is part of the Sandia OpenSHMEM software package. For license - * information, see the LICENSE file in the top level directory of the - * distribution. - */ - -#include -#include -#include -#include - - -int main(void) -{ - static long lock = 0; - - shmem_init(); - int me = shmem_my_pe(); - int npes = shmem_n_pes(); - - int team_shared_npes = shmem_team_n_pes(SHMEMX_TEAM_NODE); - - int *peers = malloc(team_shared_npes * sizeof(int)); - int num_peers = 0; - - /* Print the team members on SHMEMX_TEAM_NODE */ - /* Use a lock for cleaner output */ - shmem_set_lock(&lock); - - printf("[PE: %d] SHMEMX_TEAM_NODE peers: { ", me); - for (int i = 0; i < npes; i++) { - if (shmem_team_translate_pe(SHMEM_TEAM_WORLD, i, - SHMEMX_TEAM_NODE) != -1) { - peers[num_peers++] = i; - printf("%d ", i); - } - } - - printf("} (num_peers: %d)\n", num_peers); - - fflush(NULL); - - shmem_clear_lock(&lock); - - if (num_peers != team_shared_npes) { - shmem_global_exit(1); - } - - free(peers); - shmem_finalize(); - return 0; -} diff --git a/test/spec-example/Makefile.am b/test/spec-example/Makefile.am deleted file mode 100644 index 0d030c09a..000000000 --- a/test/spec-example/Makefile.am +++ /dev/null @@ -1,70 +0,0 @@ -# -*- Makefile -*- -# -# Copyright 2011 Sandia Corporation. Under the terms of Contract -# DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government -# retains certain rights in this software. -# -# Copyright (c) 2017 Intel Corporation. All rights reserved. -# This software is available to you under the BSD license. -# -# This file is part of the Sandia OpenSHMEM software package. For license -# information, see the LICENSE file in the top level directory of the -# distribution. - -check_PROGRAMS = \ - shmem_ctx_pipelined_reduce \ - shmem_wait_until_all \ - shmem_wait_until_any \ - shmem_wait_until_some \ - shmem_wait_until_any_vector \ - shmem_test_any \ - shmem_test_some \ - shmem_team_split_strided \ - shmem_team_split_2D \ - shmem_team_translate \ - shmem_team_context \ - shmem_team_broadcast \ - shmem_team_collect \ - shmem_team_alltoall \ - shmem_team_alltoalls - -if HAVE_OPENMP -check_PROGRAMS += \ - shmem_ctx -endif - -if HAVE_C11 -check_PROGRAMS += \ - shmem_team_sync \ - shmem_reduce_example -endif - -if USE_PMI_MPI -check_PROGRAMS += \ - hybrid_mpi_mapping_id \ - hybrid_mpi_mapping_id_shmem_comm -endif - -TESTS = $(check_PROGRAMS) - -NPROCS ?= 2 -LOG_COMPILER = $(TEST_RUNNER) - -AM_LDFLAGS = $(LIBTOOL_WRAPPER_LDFLAGS) - -if EXTERNAL_TESTS -bin_PROGRAMS = $(check_PROGRAMS) -AM_CPPFLAGS = -I$(top_srcdir)/test/include -AM_FCFLAGS = -LDADD = -else -AM_CPPFLAGS = -I$(top_builddir)/mpp -I$(top_srcdir)/mpp -I$(top_srcdir)/test/include -AM_FCFLAGS = -I$(top_builddir)/mpp -LDADD = $(top_builddir)/src/libsma.la -endif - -if USE_PMI_SIMPLE -LDADD += $(top_builddir)/pmi-simple/libpmi_simple.la -endif - -shmem_ctx_CFLAGS = $(AM_OPENMP_CFLAGS) diff --git a/test/spec-example/hybrid_mpi_mapping_id.c b/test/spec-example/hybrid_mpi_mapping_id.c deleted file mode 100644 index ca0d8bbbc..000000000 --- a/test/spec-example/hybrid_mpi_mapping_id.c +++ /dev/null @@ -1,33 +0,0 @@ -/* - * This test program is derived from an example program in the - * OpenSHMEM specification. - */ - -#include -#include -#include - -int main(int argc, char *argv[]) { - MPI_Init(&argc, &argv); - shmem_init(); - - int mype = shmem_team_my_pe(SHMEM_TEAM_WORLD); - int npes = shmem_team_n_pes(SHMEM_TEAM_WORLD); - - static int myrank; - MPI_Comm_rank(MPI_COMM_WORLD, &myrank); - - int *mpi_ranks = shmem_calloc(npes, sizeof(int)); - - shmem_int_collect(SHMEM_TEAM_WORLD, mpi_ranks, &myrank, 1); - if (mype == 0) - for (int i = 0; i < npes; i++) - printf("PE %d’s MPI rank is %d\n", i, mpi_ranks[i]); - - shmem_free(mpi_ranks); - - shmem_finalize(); - MPI_Finalize(); - - return 0; -} diff --git a/test/spec-example/hybrid_mpi_mapping_id_shmem_comm.c b/test/spec-example/hybrid_mpi_mapping_id_shmem_comm.c deleted file mode 100644 index 718dfc809..000000000 --- a/test/spec-example/hybrid_mpi_mapping_id_shmem_comm.c +++ /dev/null @@ -1,28 +0,0 @@ -/* - * This test program is derived from an example program in the - * OpenSHMEM specification. - */ - -#include -#include -#include - -int main(int argc, char *argv[]) { - MPI_Init(&argc, &argv); - shmem_init(); - - int mype = shmem_my_pe(); - - MPI_Comm shmem_comm; - MPI_Comm_split(MPI_COMM_WORLD, 0, mype, &shmem_comm); - - int myrank; - MPI_Comm_rank(shmem_comm, &myrank); - printf("PE %d’s MPI rank is %d\n", mype, myrank); - - MPI_Comm_free(&shmem_comm); - shmem_finalize(); - MPI_Finalize(); - - return 0; -} diff --git a/test/spec-example/shmem_ctx.c b/test/spec-example/shmem_ctx.c deleted file mode 100644 index 3b081fcb1..000000000 --- a/test/spec-example/shmem_ctx.c +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * This test is derived from an example provided in the OpenSHMEM 1.4 - * specification. Additional copyrights may apply. - * - */ - -#include -#include - -long task_cntr = 0; /* Next task counter */ -long tasks_done = 0; /* Tasks done by this PE */ -long total_done = 0; /* Total tasks done by all PEs */ - -int main(void) { - int tl, ret; - long ntasks = 1024; /* Total tasks per PE */ - - ret = shmem_init_thread(SHMEM_THREAD_MULTIPLE, &tl); - - if (tl != SHMEM_THREAD_MULTIPLE || ret != 0) { - printf("Init failed (requested thread level %d, got %d, ret %d)\n", - SHMEM_THREAD_MULTIPLE, tl, ret); - - if (ret == 0) { - shmem_global_exit(1); - } else { - return ret; - } - } - - int me = shmem_my_pe(); - int npes = shmem_n_pes(); - -#pragma omp parallel reduction (+:tasks_done) - { - shmem_ctx_t ctx; - int task_pe = me, pes_done = 0; - int ret = shmem_ctx_create(SHMEM_CTX_PRIVATE, &ctx); - - if (ret != 0) { - printf("%d: Warning, unable to create context (%d)\n", me, ret); - ctx = SHMEM_CTX_DEFAULT; - } - - /* Process tasks on all PEs, starting with the local PE. After - * all tasks on a PE are completed, help the next PE. */ - while (pes_done < npes) { - long task = shmem_ctx_long_atomic_fetch_inc(ctx, &task_cntr, task_pe); - while (task < ntasks) { - /* Perform task (task_pe, task) */ - tasks_done++; - task = shmem_ctx_long_atomic_fetch_inc(ctx, &task_cntr, task_pe); - } - pes_done++; - task_pe = (task_pe + 1) % npes; - } - - if (ctx != SHMEM_CTX_DEFAULT) shmem_ctx_destroy(ctx); - } - - shmem_long_sum_reduce(SHMEM_TEAM_WORLD, &total_done, &tasks_done, 1); - - int result = (total_done != ntasks * npes); - if (me == 0 && result) - printf("Error: total_done is %ld, expected %ld\n", total_done, ntasks * npes); - - shmem_finalize(); - return result; -} diff --git a/test/spec-example/shmem_ctx_pipelined_reduce.c b/test/spec-example/shmem_ctx_pipelined_reduce.c deleted file mode 100644 index f99b7103e..000000000 --- a/test/spec-example/shmem_ctx_pipelined_reduce.c +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * This test is derived from an example provided in the OpenSHMEM 1.4 - * specification. Additional copyrights may apply. - * - */ - -#include -#include -#include - -#define LEN 8192 /* Full buffer length */ -#define PLEN 512 /* Length of each pipeline stage */ - -int in_buf[LEN], out_buf[LEN]; - -int main(void) { - int i, j, *pbuf[2]; - shmem_ctx_t ctx[2]; - - shmem_init(); - int me = shmem_my_pe(); - int npes = shmem_n_pes(); - - pbuf[0] = shmem_malloc(PLEN * npes * sizeof(int)); - pbuf[1] = shmem_malloc(PLEN * npes * sizeof(int)); - - int ret_0 = shmem_ctx_create(0, &ctx[0]); - int ret_1 = shmem_ctx_create(0, &ctx[1]); - - if (ret_0) ctx[0] = SHMEM_CTX_DEFAULT; - if (ret_1) ctx[1] = SHMEM_CTX_DEFAULT; - - for (i = 0; i < LEN; i++) { - in_buf[i] = me; out_buf[i] = 0; - } - - /* Index of ctx and pbuf (p_idx) for current pipeline stage (p) */ - int p_idx = 0, p = 0; - for (i = 1; i <= npes; i++) - shmem_ctx_int_put_nbi(ctx[p_idx], &pbuf[p_idx][PLEN*me], - &in_buf[PLEN*p], PLEN, (me+i) % npes); - - /* Issue communication for pipeline stage p, then accumulate results for - * stage p-1 */ - for (p = 1; p < LEN/PLEN; p++) { - p_idx ^= 1; - for (i = 1; i <= npes; i++) - shmem_ctx_int_put_nbi(ctx[p_idx], &pbuf[p_idx][PLEN*me], - &in_buf[PLEN*p], PLEN, (me+i) % npes); - - shmem_ctx_quiet(ctx[p_idx^1]); - shmem_sync_all(); - for (i = 0; i < npes; i++) - for (j = 0; j < PLEN; j++) - out_buf[PLEN*(p-1)+j] += pbuf[p_idx^1][PLEN*i+j]; - } - - shmem_ctx_quiet(ctx[p_idx]); - shmem_sync_all(); - for (i = 0; i < npes; i++) - for (j = 0; j < PLEN; j++) - out_buf[PLEN*(p-1)+j] += pbuf[p_idx][PLEN*i+j]; - - int errors = 0; - int expected = (npes - 1) * npes / 2; - for (i = 0; i < LEN; i++) { - if (out_buf[i] != expected) { - printf("%d: out_buf[%d] = %d, expected %d\n", me, i, out_buf[i], expected); - errors++; - } - } - - shmem_finalize(); - return errors; -} diff --git a/test/spec-example/shmem_reduce_example.c b/test/spec-example/shmem_reduce_example.c deleted file mode 100644 index 7efb03851..000000000 --- a/test/spec-example/shmem_reduce_example.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - * This test program is derived from an example program in the - * OpenSHMEM specification. - */ - -#include -#include -#include - -#define NELEMS 32 - -int main(void) { - shmem_init(); - int mype = shmem_my_pe(); - int npes = shmem_n_pes(); - - int *values = shmem_malloc(NELEMS * sizeof(int)); - - unsigned char *value_is_maximal = shmem_malloc(NELEMS * sizeof(unsigned char)); - unsigned char *value_is_maximal_all = shmem_malloc(NELEMS * sizeof(unsigned char)); - - static int maximal_values_count = 0; - static int maximal_values_total; - - srand((unsigned)mype); - - for (int i = 0; i < NELEMS; i++) { - values[i] = rand() % npes; - - /* Track and count instances of maximal values (i.e., values equal to (npes-1)) */ - value_is_maximal[i] = (values[i] == (npes - 1)) ? 1 : 0; - maximal_values_count += value_is_maximal[i]; - } - - /* Wait for all PEs to initialize reductions arrays */ - shmem_sync(SHMEM_TEAM_WORLD); - - shmem_or_reduce(SHMEM_TEAM_WORLD, value_is_maximal_all, value_is_maximal, NELEMS); - shmem_sum_reduce(SHMEM_TEAM_WORLD, &maximal_values_total, &maximal_values_count, 1); - - if (mype == 0) { - printf("Found %d maximal random numbers across all PEs.\n", maximal_values_total); - printf("A maximal number occured (at least once) at the following indices:\n"); - for (int i = 0; i < NELEMS; i++) { - if (value_is_maximal_all[i] == 1) { - printf("%d ", i); - } - } - printf("\n"); - } - - shmem_finalize(); - return 0; -} diff --git a/test/spec-example/shmem_team_alltoall.c b/test/spec-example/shmem_team_alltoall.c deleted file mode 100644 index 7724ad8d1..000000000 --- a/test/spec-example/shmem_team_alltoall.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * This test program is derived from an example program in the - * OpenSHMEM specification. - */ - -#include -#include -#include - -int main(void) -{ - shmem_init(); - int me = shmem_my_pe(); - int npes = shmem_n_pes(); - - const int count = 2; - int64_t* dest = (int64_t*) shmem_malloc(count * npes * sizeof(int64_t)); - int64_t* source = (int64_t*) shmem_malloc(count * npes * sizeof(int64_t)); - - /* assign source values */ - for (int pe = 0; pe < npes; pe++) { - for (int i = 0; i < count; i++) { - source[(pe * count) + i] = me + pe; - dest[(pe * count) + i] = 9999; - } - } - /* wait for all PEs to initialize source/dest */ - shmem_team_sync(SHMEM_TEAM_WORLD); - - /* alltoall on all PES */ - shmem_int64_alltoall(SHMEM_TEAM_WORLD, dest, source, count); - - /* verify results */ - for (int pe = 0; pe < npes; pe++) { - for (int i = 0; i < count; i++) { - if (dest[(pe * count) + i] != pe + me) { - printf("[%d] ERROR: dest[%d]=%" PRId64 ", should be %d\n", - me, (pe * count) + i, dest[(pe * count) + i], pe + me); - } - } - } - - shmem_free(dest); - shmem_free(source); - shmem_finalize(); - return 0; -} diff --git a/test/spec-example/shmem_team_alltoalls.c b/test/spec-example/shmem_team_alltoalls.c deleted file mode 100644 index 7aabe7dda..000000000 --- a/test/spec-example/shmem_team_alltoalls.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * This test program is derived from an example program in the - * OpenSHMEM specification. - */ - -#include -#include -#include - -int main(void) -{ - shmem_init(); - int me = shmem_my_pe(); - int npes = shmem_n_pes(); - - const int count = 2; - const ptrdiff_t dst = 2; - const ptrdiff_t sst = 3; - int64_t* dest = (int64_t*) shmem_malloc(count * dst * npes * sizeof(int64_t)); - int64_t* source = (int64_t*) shmem_malloc(count * sst * npes * sizeof(int64_t)); - - /* assign source values */ - for (int pe = 0; pe < npes; pe++) { - for (int i = 0; i < count; i++) { - source[sst * ((pe * count) + i)] = me + pe; - dest[dst * ((pe * count) + i)] = 9999; - } - } - /* wait for all PEs to initialize source/dest */ - shmem_team_sync(SHMEM_TEAM_WORLD); - - /* alltoalls on all PES */ - shmem_int64_alltoalls(SHMEM_TEAM_WORLD, dest, source, dst, sst, count); - - /* verify results */ - for (int pe = 0; pe < npes; pe++) { - for (int i = 0; i < count; i++) { - int j = dst * ((pe * count) + i); - if (dest[j] != pe + me) { - printf("[%d] ERROR: dest[%d]=%" PRId64 ", should be %d\n", - me, j, dest[j], pe + me); - } - } - } - - shmem_free(dest); - shmem_free(source); - shmem_finalize(); - return 0; -} diff --git a/test/spec-example/shmem_team_broadcast.c b/test/spec-example/shmem_team_broadcast.c deleted file mode 100644 index 108afca3c..000000000 --- a/test/spec-example/shmem_team_broadcast.c +++ /dev/null @@ -1,33 +0,0 @@ -/* - * This test program is derived from an example program in the - * OpenSHMEM specification. - */ - -#include -#include -#include - -int main(void) -{ - static long source[4], dest[4]; - - shmem_init(); - int me = shmem_my_pe(); - - if (me == 0) - for (int i = 0; i < 4; i++) - source[i] = i; - - shmem_long_broadcast(SHMEM_TEAM_WORLD, dest, source, 4, 0); - - printf("%d: %ld, %ld, %ld, %ld\n", me, dest[0], dest[1], dest[2], dest[3]); - - for (int i = 0; i < 4; i++) - if (dest[i] != i) { - printf("PE %d error - wrong value (%ld != %d)\n", me, dest[i], i); - shmem_global_exit(1); - } - - shmem_finalize(); - return 0; -} diff --git a/test/spec-example/shmem_team_collect.c b/test/spec-example/shmem_team_collect.c deleted file mode 100644 index 51d34c79d..000000000 --- a/test/spec-example/shmem_team_collect.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This test program is derived from an example program in the - * OpenSHMEM specification. - */ - -#include -#include -#include - -int main(void) -{ - static long lock = 0; - - shmem_init(); - int me = shmem_my_pe(); - int npes = shmem_n_pes(); - int my_nelem = me + 1; /* linearly increasing number of elements with PE */ - int total_nelem = (npes * (npes + 1)) / 2; - - int *source = (int *)shmem_malloc(npes * sizeof(int)); /* symmetric alloc */ - int *dest = (int *)shmem_malloc(total_nelem * sizeof(int)); - - for (int i = 0; i < my_nelem; i++) - source[i] = (me * (me + 1)) / 2 + i; - for (int i = 0; i < total_nelem; i++) - dest[i] = -9999; - - /* Wait for all PEs to initialize source/dest: */ - shmem_team_sync(SHMEM_TEAM_WORLD); - - shmem_int_collect(SHMEM_TEAM_WORLD, dest, source, my_nelem); - - shmem_set_lock(&lock); /* Lock prevents interleaving printfs */ - printf("%d: %d", me, dest[0]); - for (int i = 1; i < total_nelem; i++) - printf(", %d", dest[i]); - printf("\n"); - shmem_clear_lock(&lock); - - for (int i = 0; i < total_nelem; i++) - if (dest[i] != i) - shmem_global_exit(1); - - shmem_finalize(); - return 0; -} diff --git a/test/spec-example/shmem_team_context.c b/test/spec-example/shmem_team_context.c deleted file mode 100644 index ea3710af7..000000000 --- a/test/spec-example/shmem_team_context.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - * This test program is derived from an example program in the - * OpenSHMEM specification. - */ - -#include -#include - - -int main(void) -{ - static int sum = 0, val_2, val_3; - shmem_team_t team_2, team_3; - shmem_ctx_t ctx_2, ctx_3; - shmem_team_config_t conf; - - shmem_init(); - - int npes = shmem_n_pes(); - int mype = shmem_my_pe(); - conf.num_contexts = 1; - long cmask = SHMEM_TEAM_NUM_CONTEXTS; - - /* Create team_2 with PEs numbered 0, 2, 4, ... */ - int ret = shmem_team_split_strided(SHMEM_TEAM_WORLD, 0, 2, (npes + 1) / 2, &conf, cmask, &team_2); - - if (ret != 0) { - printf("%d: Error creating team team_2 (%d)\n", mype, ret); - shmem_global_exit(ret); - } - - /* Create team_3 with PEs numbered 0, 3, 6, ... */ - ret = shmem_team_split_strided(SHMEM_TEAM_WORLD, 0, 3, (npes + 2) / 3, &conf, cmask, &team_3); - - if (ret != 0) { - printf("%d: Error creating team team_3 (%d)\n", mype, ret); - shmem_global_exit(ret); - } - - /* Create a context on team_2. */ - ret = shmem_team_create_ctx(team_2, 0, &ctx_2); - - if (ret != 0 && team_2 != SHMEM_TEAM_INVALID) { - printf("%d: Error creating context ctx_2 (%d)\n", mype, ret); - shmem_global_exit(ret); - } - - /* Create a context on team_3. */ - ret = shmem_team_create_ctx(team_3, 0, &ctx_3); - - if (ret != 0 && team_3 != SHMEM_TEAM_INVALID) { - printf("%d: Error creating context ctx_3 (%d)\n", mype, ret); - shmem_global_exit(ret); - } - - /* Within each team, put my PE number to my neighbor in a ring-based manner. */ - if (ctx_2 != SHMEM_CTX_INVALID) { - int pe = shmem_team_my_pe(team_2); - shmem_ctx_int_put(ctx_2, &val_2, &pe, 1, (pe + 1) % shmem_team_n_pes(team_2)); - } - - if (ctx_3 != SHMEM_CTX_INVALID) { - int pe = shmem_team_my_pe(team_3); - shmem_ctx_int_put(ctx_3, &val_3, &pe, 1, (pe + 1) % shmem_team_n_pes(team_3)); - } - - /* Quiet both contexts and synchronize all PEs to complete the data transfers. */ - shmem_ctx_quiet(ctx_2); - shmem_ctx_quiet(ctx_3); - shmem_team_sync(SHMEM_TEAM_WORLD); - - /* Sum the values among PEs that are in both team_2 and team_3 on PE 0 with ctx_2. */ - if (team_3 != SHMEM_TEAM_INVALID && team_2 != SHMEM_TEAM_INVALID) - shmem_ctx_int_atomic_add(ctx_2, &sum, val_2 + val_3, 0); - - /* Quiet the context and synchronize PEs to complete the operation. */ - shmem_ctx_quiet(ctx_2); - shmem_team_sync(SHMEM_TEAM_WORLD); - - /* Validate the result. */ - if (mype == 0) { - int vsum = 0; - for (int i = 0; i < npes; i ++) { - if (i % 2 == 0 && i % 3 == 0) { - vsum += ((i - 2) < 0) ? shmem_team_n_pes(team_2) - 1 : - shmem_team_translate_pe(SHMEM_TEAM_WORLD, i - 2, team_2); - vsum += ((i - 3) < 0) ? shmem_team_n_pes(team_3) - 1 : - shmem_team_translate_pe(SHMEM_TEAM_WORLD, i - 3, team_3); - } - } - if (sum != vsum) { - fprintf(stderr, "Unexpected result, npes = %d, vsum = %d, sum = %d\n", shmem_n_pes(), vsum, sum); - shmem_global_exit(1); - } - } - - /* Destroy contexts before teams. */ - shmem_ctx_destroy(ctx_2); - shmem_team_destroy(team_2); - - shmem_ctx_destroy(ctx_3); - shmem_team_destroy(team_3); - - shmem_finalize(); - return 0; -} diff --git a/test/spec-example/shmem_team_split_2D.c b/test/spec-example/shmem_team_split_2D.c deleted file mode 100644 index ec672c713..000000000 --- a/test/spec-example/shmem_team_split_2D.c +++ /dev/null @@ -1,69 +0,0 @@ -/* - * This test program is derived from an example program in the - * OpenSHMEM specification. - */ - -#include -#include -#include - -/* Find x and y such that x * y == npes and abs(x - y) is minimized. */ -static void find_xy_dims(int npes, int *x, int *y) { - for(int divider = ceil(sqrt(npes)); divider >= 1; divider--) - if (npes % divider == 0) { - *x = divider; - *y = npes / divider; - return; - } -} - -/* Find x, y, and z such that x * y * z == npes and - * abs(x - y) + abs(x - z) + abs(y - z) is minimized. */ -static void find_xyz_dims(int npes, int *x, int *y, int *z) { - *x = *y = *z = 1; - for(int divider = ceil(cbrt(npes)); divider >= 1; divider--) - if (npes % divider == 0) { - *x = divider; - find_xy_dims(npes / divider, y, z); - return; - } -} - -int main(void) { - int xdim, ydim, zdim; - - shmem_init(); - int mype = shmem_my_pe(); - int npes = shmem_n_pes(); - - find_xyz_dims(npes, &xdim, &ydim, &zdim); - - if (shmem_my_pe() == 0) printf("xdim = %d, ydim = %d, zdim = %d\n", xdim, ydim, zdim); - - shmem_team_t xteam, yzteam, yteam, zteam; - - shmem_team_split_2d(SHMEM_TEAM_WORLD, xdim, NULL, 0, &xteam, NULL, 0, &yzteam); - // yzteam is immediately ready to be used in collectives - shmem_team_split_2d(yzteam, ydim, NULL, 0, &yteam, NULL, 0, &zteam); - - // We don't need the yzteam anymore - shmem_team_destroy(yzteam); - - int my_x = shmem_team_my_pe(xteam); - int my_y = shmem_team_my_pe(yteam); - int my_z = shmem_team_my_pe(zteam); - - for (int zdx = 0; zdx < zdim; zdx++) { - for (int ydx = 0; ydx < ydim; ydx++) { - for (int xdx = 0; xdx < xdim; xdx++) { - if ((my_x == xdx) && (my_y == ydx) && (my_z == zdx)) { - printf("(%d, %d, %d) is mype = %d\n", my_x, my_y, my_z, mype); - } - shmem_team_sync(SHMEM_TEAM_WORLD); - } - } - } - - shmem_finalize(); - return 0; -} diff --git a/test/spec-example/shmem_team_split_strided.c b/test/spec-example/shmem_team_split_strided.c deleted file mode 100644 index 61b8e84d8..000000000 --- a/test/spec-example/shmem_team_split_strided.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * This test program is derived from an example program in the - * OpenSHMEM specification. - */ - -#include -#include - -int main(int argc, char *argv[]) -{ - int rank, npes; - int t_pe, t_size; - int ret; - shmem_team_t new_team; - shmem_team_config_t *config; - - shmem_init(); - config = NULL; - rank = shmem_my_pe(); - npes = shmem_n_pes(); - - if (npes < 2) { - fprintf(stderr, "ERR - Requires at least 2 PEs\n"); - shmem_finalize(); - return 0; - } - - ret = shmem_team_split_strided(SHMEM_TEAM_WORLD, 0, 2, (npes + 1) / 2, - config, 0, &new_team); - - if (ret != 0) { - shmem_global_exit(2); - } - - t_size = shmem_team_n_pes(new_team); - t_pe = shmem_team_my_pe(new_team); - - if (new_team != SHMEM_TEAM_INVALID) { - if ((rank % 2 != 0) || (rank / 2 != t_pe) || ((npes + 1) / 2 != t_size)) { - shmem_global_exit(3); - } - } else { - if ((rank % 2 == 0) || (t_pe != -1) || (t_size != -1)) { - shmem_global_exit(4); - } - } - - - shmem_finalize(); - return 0; -} - diff --git a/test/spec-example/shmem_team_sync.c b/test/spec-example/shmem_team_sync.c deleted file mode 100644 index fc10c9508..000000000 --- a/test/spec-example/shmem_team_sync.c +++ /dev/null @@ -1,69 +0,0 @@ -/* - * This test program is derived from an example program in the - * OpenSHMEM specification. - */ - -#include -#include - -#if !(defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) -#define shmem_p shmem_int_p -#endif - -int main(void) -{ - static int x = 10101; - - shmem_team_t twos_team = SHMEM_TEAM_INVALID; - shmem_team_t threes_team = SHMEM_TEAM_INVALID; - shmem_team_config_t *config; - - shmem_init(); - config = NULL; - int me = shmem_my_pe(); - int npes = shmem_n_pes(); - - if (npes > 2) - shmem_team_split_strided(SHMEM_TEAM_WORLD, 2, 2, (npes-1) / 2, config, - 0, &twos_team); - - if (npes > 3) - shmem_team_split_strided(SHMEM_TEAM_WORLD, 3, 3, (npes-1) / 3, config, - 0, &threes_team); - - int my_pe_twos = shmem_team_my_pe(twos_team); - int my_pe_threes = shmem_team_my_pe(threes_team); - int npes_twos = shmem_team_n_pes(twos_team); - int npes_threes = shmem_team_n_pes(threes_team); - - if (twos_team != SHMEM_TEAM_INVALID) { - /* put the value 2 to the next team member in a circular fashion */ - shmem_p(&x, 2, shmem_team_translate_pe(twos_team, (my_pe_twos + 1) % - npes_twos, SHMEM_TEAM_WORLD)); - shmem_quiet(); - shmem_sync(twos_team); - } - - shmem_sync(SHMEM_TEAM_WORLD); - - if (threes_team != SHMEM_TEAM_INVALID) { - /* put the value 3 to the next team member in a circular fashion */ - shmem_p(&x, 3, shmem_team_translate_pe(threes_team, (my_pe_threes + 1) % - npes_threes, SHMEM_TEAM_WORLD)); - shmem_quiet(); - shmem_sync(threes_team); - } - - if (me && me % 3 == 0) { - if (x != 3) shmem_global_exit(3); - } - else if (me && me % 2 == 0) { - if (x != 2) shmem_global_exit(2); - } - else if (x != 10101) { - shmem_global_exit(1); - } - - shmem_finalize(); - return 0; -} diff --git a/test/spec-example/shmem_team_translate.c b/test/spec-example/shmem_team_translate.c deleted file mode 100644 index add6af977..000000000 --- a/test/spec-example/shmem_team_translate.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This test program is derived from an example program in the - * OpenSHMEM specification. - */ - -#include -#include - -int main(int argc, char *argv[]) -{ - int rank, npes; - int t_pe; - int t_global; - shmem_team_t new_team; - shmem_team_config_t *config; - - shmem_init(); - config = NULL; - rank = shmem_my_pe(); - npes = shmem_n_pes(); - - if (npes < 2) { - fprintf(stderr, "ERR - Requires > 1 PEs\n"); - shmem_finalize(); - return 0; - } - - shmem_team_split_strided(SHMEM_TEAM_WORLD, 0, 2, npes / 2, config, 0, - &new_team); - - t_pe = shmem_team_my_pe(new_team); - t_global = shmem_team_translate_pe(new_team, t_pe, SHMEM_TEAM_WORLD); - - if (new_team != SHMEM_TEAM_INVALID) { - if (t_global != rank) { - shmem_global_exit(2); - } - } else { - if (t_global != -1) { - shmem_global_exit(3); - } - } - - shmem_finalize(); - return 0; -} diff --git a/test/spec-example/shmem_test_any.c b/test/spec-example/shmem_test_any.c deleted file mode 100644 index b36a19db4..000000000 --- a/test/spec-example/shmem_test_any.c +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2018 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * This test is derived from an example provided in the OpenSHMEM 1.4 - * specification. Additional copyrights may apply. - * - */ - -#include -#include - -int main(void) -{ - shmem_init(); - int mype = shmem_my_pe(); - int npes = shmem_n_pes(); - - int *flags = shmem_calloc(npes, sizeof(int)); - int *status = calloc(npes, sizeof(int)); - - for (int i = 0; i < npes; i++) - shmem_int_atomic_set(&flags[mype], 1, i); - - int ncompleted = 0; - size_t completed_idx; - - while (ncompleted < npes) { - completed_idx = shmem_int_test_any(flags, npes, status, SHMEM_CMP_EQ, 1); - if (completed_idx != SIZE_MAX) { - ncompleted++; - status[completed_idx] = 1; - } else { - /* Overlap some computation here */ - } - } - - /* Check the flags array */ - for (int i = 0; i < npes; i++) { - if (flags[i] != 1) - shmem_global_exit(1); - } - - /* Sanity check of shmem_test_any's fairness */ - ncompleted = 0; - int *found = calloc(npes, sizeof(int)); - - while (ncompleted < npes) { - int idx = shmem_int_test_any(flags, npes, NULL, SHMEM_CMP_EQ, 1); - if (found[idx] == 0) { - found[idx] = 1; - ncompleted++; - } - } - - for (int i = 0; i < npes; i++) { - if (found[i] != 1) { - shmem_global_exit(2); - } - } - - /* Sanity check case with NULL status array */ - completed_idx = shmem_int_test_any(flags, npes, NULL, SHMEM_CMP_EQ, 1); - - if (completed_idx >= (size_t)npes) - shmem_global_exit(3); - - - free(found); - free(status); - shmem_free(flags); - shmem_finalize(); - return 0; -} diff --git a/test/spec-example/shmem_test_some.c b/test/spec-example/shmem_test_some.c deleted file mode 100644 index 3377198a8..000000000 --- a/test/spec-example/shmem_test_some.c +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2018 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * This test is derived from an example provided in the OpenSHMEM 1.4 - * specification. Additional copyrights may apply. - * - */ - -#include -#include - -#define N 100 - -int main(void) -{ - int total_sum = 0; - - shmem_init(); - int mype = shmem_my_pe(); - int npes = shmem_n_pes(); - - int *my_data = malloc(N * sizeof(int)); - int *all_data = shmem_malloc(N * npes * sizeof(int)); - - int *flags = shmem_calloc(npes, sizeof(int)); - size_t *indices = calloc(npes, sizeof(size_t)); - int *status = calloc(npes, sizeof(int)); - - for (int i = 0; i < N; i++) - my_data[i] = mype*N + i; - - for (int i = 0; i < npes; i++) - shmem_int_put_nbi(&all_data[mype*N], my_data, N, i); - - shmem_fence(); - - for (int i = 0; i < npes; i++) - shmem_int_atomic_set(&flags[mype], 1, i); - - int ncompleted = 0; - - while (ncompleted < npes) { - int ntested = shmem_int_test_some(flags, npes, indices, status, SHMEM_CMP_NE, 0); - if (ntested > 0) { - for (int i = 0; i < ntested; i++) { - for (int j = 0; j < N; j++) { - total_sum += all_data[indices[i]*N + j]; - } - status[indices[i]] = 1; - } - ncompleted += ntested; - } else { - /* Overlap some computation here */ - } - } - - /* Check the flags array */ - for (int i = 0; i < npes; i++) { - if (flags[i] != 1) - shmem_global_exit(1); - } - - /* check result */ - int M = N * npes - 1; - if (total_sum != M * (M + 1) / 2) { - shmem_global_exit(2); - } - - /* Sanity check case with NULL status array */ - ncompleted = shmem_int_test_some(flags, npes, indices, NULL, SHMEM_CMP_EQ, 1); - - if (ncompleted != npes) - shmem_global_exit(3); - - shmem_finalize(); - return 0; -} diff --git a/test/spec-example/shmem_wait_until_all.c b/test/spec-example/shmem_wait_until_all.c deleted file mode 100644 index 47ac6c840..000000000 --- a/test/spec-example/shmem_wait_until_all.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2018 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * This test is derived from an example provided in the OpenSHMEM 1.4 - * specification. Additional copyrights may apply. - * - */ - -#include - -int main(void) -{ - shmem_init(); - int mype = shmem_my_pe(); - int npes = shmem_n_pes(); - - int *flags = shmem_calloc(npes, sizeof(int)); - int *status = NULL; - - for (int i = 0; i < npes; i++) - shmem_int_atomic_set(&flags[mype], 1, i); - - shmem_int_wait_until_all(flags, npes, status, SHMEM_CMP_EQ, 1); - - /* Check the flags array */ - for (int i = 0; i < npes; i++) { - if (flags[i] != 1) - shmem_global_exit(1); - } - - shmem_free(flags); - shmem_finalize(); - return 0; -} diff --git a/test/spec-example/shmem_wait_until_any.c b/test/spec-example/shmem_wait_until_any.c deleted file mode 100644 index 02f93bd62..000000000 --- a/test/spec-example/shmem_wait_until_any.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2018 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * This test is derived from an example provided in the OpenSHMEM 1.4 - * specification. Additional copyrights may apply. - * - */ - -#include -#include - -#define N 100 - -int main(void) -{ - int total_sum = 0; - - shmem_init(); - int mype = shmem_my_pe(); - int npes = shmem_n_pes(); - - int *my_data = malloc(N * sizeof(int)); - int *all_data = shmem_malloc(N * npes * sizeof(int)); - - int *flags = shmem_calloc(npes, sizeof(int)); - int *status = calloc(npes, sizeof(int)); - - for (int i = 0; i < N; i++) - my_data[i] = mype*N + i; - - for (int i = 0; i < npes; i++) - shmem_int_put_nbi(&all_data[mype*N], my_data, N, i); - - shmem_fence(); - - for (int i = 0; i < npes; i++) - shmem_int_atomic_set(&flags[mype], 1, i); - - size_t completed_idx; - for (int i = 0; i < npes; i++) { - completed_idx = shmem_int_wait_until_any(flags, npes, status, SHMEM_CMP_NE, 0); - for (int j = 0; j < N; j++) { - total_sum += all_data[completed_idx * N + j]; - } - status[completed_idx] = 1; - } - - /* Check the flags array */ - for (int i = 0; i < npes; i++) { - if (flags[i] != 1) - shmem_global_exit(1); - } - - /* check result */ - int M = N * npes - 1; - if (total_sum != M * (M + 1) / 2) { - shmem_global_exit(2); - } - - /* Sanity check the case with NULL status array */ - completed_idx = shmem_int_wait_until_any(flags, npes, NULL, SHMEM_CMP_EQ, 1); - - if (completed_idx >= (size_t)npes) - shmem_global_exit(3); - - shmem_finalize(); - return 0; -} diff --git a/test/spec-example/shmem_wait_until_any_vector.c b/test/spec-example/shmem_wait_until_any_vector.c deleted file mode 100644 index 8860855a1..000000000 --- a/test/spec-example/shmem_wait_until_any_vector.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2018 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * This test is derived from an example provided in the OpenSHMEM 1.4 - * specification. Additional copyrights may apply. - * - */ - -#include -#include - -#define N 100 - -int main(void) -{ - int total_sum = 0; - - shmem_init(); - int mype = shmem_my_pe(); - int npes = shmem_n_pes(); - - int *ivars = shmem_calloc(npes, sizeof(int)); - int *status = calloc(npes, sizeof(int)); - int *cmp_values = malloc(npes * sizeof(int)); - - /* All odd PEs put 2 and all even PEs put 1 */ - for (int i = 0; i < npes; i++) { - shmem_int_atomic_set(&ivars[mype], mype % 2 + 1, i); - - /* Set cmp_values to the expected values coming from each PE */ - cmp_values[i] = i % 2 + 1; - } - - size_t completed_idx; - for (int i = 0; i < npes; i++) { - completed_idx = shmem_int_wait_until_any_vector(ivars, npes, status, SHMEM_CMP_EQ, cmp_values); - status[completed_idx] = 1; - total_sum += ivars[completed_idx]; - } - - /* check the result */ - int correct_result = npes + npes / 2; - if (total_sum != correct_result) { - shmem_global_exit(1); - } - - shmem_finalize(); - return 0; -} diff --git a/test/spec-example/shmem_wait_until_some.c b/test/spec-example/shmem_wait_until_some.c deleted file mode 100644 index 61df1ba36..000000000 --- a/test/spec-example/shmem_wait_until_some.c +++ /dev/null @@ -1,63 +0,0 @@ -#include -#include - -#define N 100 - -int main(void) -{ - int total_sum = 0; - - shmem_init(); - int mype = shmem_my_pe(); - int npes = shmem_n_pes(); - - int *my_data = malloc(N * sizeof(int)); - int *all_data = shmem_malloc(N * npes * sizeof(int)); - - int *flags = shmem_calloc(npes, sizeof(int)); - size_t *indices = malloc(npes * sizeof(size_t)); - int *status = calloc(npes, sizeof(int)); - - for (int i = 0; i < N; i++) - my_data[i] = mype*N + i; - - for (int i = 0; i < npes; i++) - shmem_int_put_nbi(&all_data[mype*N], my_data, N, i); - - shmem_fence(); - - for (int i = 0; i < npes; i++) - shmem_int_atomic_set(&flags[mype], 1, i); - - size_t ncompleted; - while ((ncompleted = shmem_int_wait_until_some(flags, npes, indices, - status, SHMEM_CMP_NE, 0))) { - for (size_t i = 0; i < ncompleted; i++) { - for (size_t j = 0; j < N; j++) { - total_sum += all_data[indices[i]*N + j]; - } - status[indices[i]] = 1; - } - } - - /* Check the flags array */ - for (int i = 0; i < npes; i++) { - if (flags[i] != 1) - shmem_global_exit(1); - } - - /* check result */ - int M = N * npes - 1; - if (total_sum != M * (M + 1) / 2) { - shmem_global_exit(2); - } - - /* Sanity check the case with NULL status array */ - ncompleted = shmem_int_wait_until_some(flags, npes, indices, NULL, SHMEM_CMP_EQ, 1); - - if (ncompleted != (size_t)npes) - shmem_global_exit(3); - - shmem_finalize(); - return 0; -} diff --git a/test/unit/Makefile.am b/test/unit/Makefile.am deleted file mode 100644 index 94ab211c0..000000000 --- a/test/unit/Makefile.am +++ /dev/null @@ -1,283 +0,0 @@ -# -*- Makefile -*- -# -# Copyright 2011 Sandia Corporation. Under the terms of Contract -# DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government -# retains certain rights in this software. -# -# Copyright (c) 2017 Intel Corporation. All rights reserved. -# This software is available to you under the BSD license. -# -# This file is part of the Sandia OpenSHMEM software package. For license -# information, see the LICENSE file in the top level directory of the -# distribution. - -check_PROGRAMS = \ - hello \ - pi \ - micro_unit_shmem \ - circular_shift \ - accessible_ping \ - max_reduction \ - big_reduction \ - to_all \ - strided_put \ - barrier \ - bcast \ - put1 \ - get1 \ - swap1 \ - ping \ - pingpong \ - shmalloc \ - shmem_calloc \ - shrealloc \ - shmemalign \ - get_g \ - iput32 \ - iput64 \ - iput128 \ - iput_short \ - iput_double \ - iput_float \ - iput_long \ - iput_longdouble \ - iput_longlong \ - sping \ - pingpong-short \ - ipgm \ - iput-iget \ - swapm \ - cswap \ - waituntil \ - atomic_inc \ - set_lock \ - test_lock \ - test_lock_cswap \ - fcollect64 \ - bigput \ - bigget \ - ns \ - bcast_flood \ - lfinc \ - shmem_info \ - query_thread \ - asym_alloc \ - set_fetch \ - alltoall \ - alltoalls \ - c11_test_shmem_g \ - c11_test_shmem_get \ - c11_test_shmem_p \ - c11_test_shmem_put \ - c11_test_shmem_put_signal \ - c11_test_shmem_atomic_fetch \ - c11_test_shmem_atomic_set \ - c11_test_shmem_atomic_add \ - c11_test_shmem_atomic_inc \ - c11_test_shmem_atomic_and \ - c11_test_shmem_atomic_or \ - c11_test_shmem_atomic_xor \ - c11_test_shmem_atomic_swap \ - c11_test_shmem_atomic_cswap \ - c11_test_shmem_wait_until \ - c11_test_shmem_wait_until_vector \ - c11_shmem_wait_until_all_any_some \ - c11_test_shmem_test \ - c11_shmem_test_vector \ - c11_shmem_test_all_any_some \ - c11_shmem_team_collective_types \ - c11_shmem_team_reduce \ - get_nbi \ - put_nbi \ - rma_coverage \ - collect \ - repeated_barriers \ - repeated_syncs \ - broadcast_active_set \ - reduce_active_set \ - reduce_in_place \ - bcast_in_place \ - collect_active_set \ - atomic_bitwise \ - nop_collectives \ - self_collectives \ - zero_comm \ - sync-size \ - many-ctx \ - shmem_test \ - shmem_ptr \ - shmem_team_ptr \ - shmem_malloc_with_hints \ - put_signal \ - put_signal_nbi \ - signal_fetch \ - signal_wait_until \ - shmem_team_b2b_collectives \ - shmem_team_collect_active_set \ - shmem_team_max \ - shmem_team_reuse_teams \ - shmem_team_shared \ - shmem_team_split_2d \ - shmem_team_translate \ - shmem_team_reduce \ - shmem_team_get_config \ - shmem_team_negative_stride \ - shmem_ctx_get_team \ - atomic_nbi \ - fadd_nbi - -# Temporarily disabled: Global exit test tends to fail with MPI-PMI -if !USE_PMI_MPI -check_PROGRAMS += \ - global_exit -endif - -if ENABLE_PROFILING -check_PROGRAMS += \ - rma_coverage_pshmem \ - pcontrol -endif - -if HAVE_CXX -check_PROGRAMS += \ - cxx_test_shmem_complex \ - cxx_test_shmem_g \ - cxx_test_shmem_get \ - cxx_test_shmem_p \ - cxx_test_shmem_put \ - cxx_test_shmem_atomic_fetch \ - cxx_test_shmem_atomic_set \ - cxx_test_shmem_atomic_add \ - cxx_test_shmem_atomic_inc \ - cxx_test_shmem_atomic_and \ - cxx_test_shmem_atomic_or \ - cxx_test_shmem_atomic_xor \ - cxx_test_shmem_atomic_swap \ - cxx_test_shmem_atomic_cswap \ - cxx_test_shmem_wait_until \ - cxx_test_shmem_test \ - cxx_test_shmem_bitwise_reduce \ - cxx_test_shmem_max_min_reduce \ - cxx_test_shmem_sum_prod_reduce \ - cxx_shmem_test_all -endif - -if HAVE_FORTRAN -check_PROGRAMS += \ - hello_f - -if !HAVE_LONG_FORTRAN_HEADER -check_PROGRAMS += \ - complex_reductions_f \ - set_fetch_f \ - shmem_info_f -endif -endif - -if HAVE_PTHREADS -check_PROGRAMS += \ - mt_a2a \ - mt_contention \ - mt_membar \ - mt_lock_test \ - threading \ - web \ - thread_wait \ - query_thread_funneled -endif - -TESTS = $(check_PROGRAMS) - -NPROCS ?= 2 -LOG_COMPILER = $(TEST_RUNNER) - -AM_LDFLAGS = $(LIBTOOL_WRAPPER_LDFLAGS) - -if EXTERNAL_TESTS -bin_PROGRAMS = $(check_PROGRAMS) -AM_CPPFLAGS = -I$(top_srcdir)/test/include -AM_FCFLAGS = -LDADD = -else -AM_CPPFLAGS = -I$(top_builddir)/mpp -I$(top_srcdir)/mpp -I$(top_srcdir)/test/include -AM_FCFLAGS = -I$(top_builddir)/mpp -LDADD = $(top_builddir)/src/libsma.la -endif - -if USE_PMI_SIMPLE -LDADD += $(top_builddir)/pmi-simple/libpmi_simple.la -endif - -if SHMEMX_TESTS -AM_CFLAGS = -DENABLE_SHMEMX_TESTS -AM_CPPFLAGS += -DENABLE_SHMEMX_TESTS -endif - -if ENABLE_DEPRECATED_TESTS -AM_CFLAGS = -DENABLE_DEPRECATED_TESTS -AM_CPPFLAGS += -DENABLE_DEPRECATED_TESTS -endif - -# C Tests with special flags -rma_coverage_pshmem_SOURCES = rma_coverage.c -rma_coverage_pshmem_CFLAGS = -DTEST_PSHMEM - -query_thread_funneled_SOURCES = query_thread.c -query_thread_funneled_CFLAGS = -DENABLE_THREADS - -mt_a2a_SOURCES = mt_a2a.c -mt_a2a_LDFLAGS = $(AM_LDFLAGS) $(PTHREAD_LIBS) -mt_a2a_CFLAGS = $(PTHREAD_CFLAGS) -mt_a2a_LDADD = $(LDADD) $(PTHREAD_CFLAGS) - -mt_contention_LDFLAGS = $(AM_LDFLAGS) $(PTHREAD_LIBS) -mt_contention_CFLAGS = $(PTHREAD_CFLAGS) -mt_contention_LDADD = $(LDADD) $(PTHREAD_CFLAGS) - -mt_lock_test_SOURCES = mt_lock_test.c mt_lock.c mt_lock.h -mt_lock_test_LDFLAGS = $(AM_LDFLAGS) $(PTHREAD_LIBS) -mt_lock_test_CFLAGS = $(PTHREAD_CFLAGS) -mt_lock_test_LDADD = $(LDADD) $(PTHREAD_CFLAGS) - -mt_membar_LDFLAGS = $(AM_LDFLAGS) $(PTHREAD_LIBS) -mt_membar_CFLAGS = $(PTHREAD_CFLAGS) -mt_membar_LDADD = $(LDADD) $(PTHREAD_CFLAGS) - -threading_LDFLAGS = $(AM_LDFLAGS) $(PTHREAD_LIBS) -threading_CFLAGS = $(PTHREAD_CFLAGS) -threading_LDADD = $(LDADD) $(PTHREAD_CFLAGS) - -web_LDFLAGS = $(AM_LDFLAGS) $(PTHREAD_LIBS) -web_CFLAGS = $(PTHREAD_CFLAGS) -web_LDADD = $(LDADD) $(PTHREAD_CFLAGS) - -thread_wait_LDFLAGS = $(AM_LDFLAGS) $(PTHREAD_LIBS) -thread_wait_CFLAGS = $(PTHREAD_CFLAGS) -thread_wait_LDADD = $(LDADD) $(PTHREAD_CFLAGS) - -# Fortran Tests (only .c tests use automatic _SOURCES) -hello_f_SOURCES = hello_f.f90 -complex_reductions_f_SOURCES = complex_reductions_f.f90 -shmem_info_f_SOURCES = shmem_info_f.f90 -set_fetch_f_SOURCES = set_fetch_f.f90 - -# C++ Tests -cxx_test_shmem_complex_SOURCES = cxx_test_shmem_complex.cpp -cxx_test_shmem_g_SOURCES = cxx_test_shmem_g.cpp -cxx_test_shmem_get_SOURCES = cxx_test_shmem_get.cpp -cxx_test_shmem_p_SOURCES = cxx_test_shmem_p.cpp -cxx_test_shmem_put_SOURCES = cxx_test_shmem_put.cpp -cxx_test_shmem_atomic_fetch_SOURCES = cxx_test_shmem_atomic_fetch.cpp -cxx_test_shmem_atomic_set_SOURCES = cxx_test_shmem_atomic_set.cpp -cxx_test_shmem_atomic_add_SOURCES = cxx_test_shmem_atomic_add.cpp -cxx_test_shmem_atomic_inc_SOURCES = cxx_test_shmem_atomic_inc.cpp -cxx_test_shmem_atomic_and_SOURCES = cxx_test_shmem_atomic_and.cpp -cxx_test_shmem_atomic_or_SOURCES = cxx_test_shmem_atomic_or.cpp -cxx_test_shmem_atomic_xor_SOURCES = cxx_test_shmem_atomic_xor.cpp -cxx_test_shmem_atomic_swap_SOURCES = cxx_test_shmem_atomic_swap.cpp -cxx_test_shmem_atomic_cswap_SOURCES = cxx_test_shmem_atomic_cswap.cpp -cxx_test_shmem_wait_until_SOURCES = cxx_test_shmem_wait_until.cpp -cxx_test_shmem_test_SOURCES = cxx_test_shmem_test.cpp -cxx_test_shmem_bitwise_reduce_SOURCES = cxx_test_shmem_bitwise_reduce.cpp -cxx_test_shmem_max_min_reduce_SOURCES = cxx_test_shmem_max_min_reduce.cpp -cxx_test_shmem_sum_prod_reduce_SOURCES = cxx_test_shmem_sum_prod_reduce.cpp diff --git a/test/unit/accessible_ping.c b/test/unit/accessible_ping.c deleted file mode 100644 index 687c3dcb3..000000000 --- a/test/unit/accessible_ping.c +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - * test if PE is accessible - * - */ - -#include -#include -#include - -int -main(int argc, char* argv[]) -{ - int me, npes; - setbuf(stdout, NULL); - shmem_init(); - me = shmem_my_pe(); - npes = shmem_n_pes(); - if (me == 0) { - int i; - int verbose = (NULL == getenv("MAKELEVEL")) ? 1 : 0; - for (i = 1; i < npes; i += 1) { - if (verbose) { - printf("From %d: PE %d is ", me, i); - printf("%s", shmem_pe_accessible(i) ? "" : "NOT "); - printf("accessible\n"); - } - if (! shmem_pe_accessible(i)) - shmem_global_exit(1); - } - } - - shmem_finalize(); - - return 0; -} diff --git a/test/unit/alltoall.c b/test/unit/alltoall.c deleted file mode 100644 index 3e5385bb9..000000000 --- a/test/unit/alltoall.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include - -/* Tranlate a group PE index to a global PE rank. */ -static int pe_group_to_world(int group_pe, int pe_start, int pe_stride, int pe_size) { - return group_pe >= pe_size ? -1 : pe_start + group_pe * pe_stride; -} - -static void alltoall_test(int32_t *out, int32_t *in, int pe_start, int pe_stride, - int pe_size) -{ - int me, npes, i; - int failed = 0; - - me = shmem_my_pe(); - npes = shmem_n_pes(); - - if (me == pe_start) - printf("A2A: pe_start = %d, pe_stride = %d, pe_size = %d\n", pe_start, - pe_stride, pe_size); - - for (i = 0; i < npes; i++) { - in[i] = me; - out[i] = -1; - } - - shmem_barrier_all(); - - shmem_team_t new_team; - shmem_team_split_strided(SHMEM_TEAM_WORLD, pe_start, pe_stride, pe_size, NULL, 0, &new_team); - if (new_team != SHMEM_TEAM_INVALID) - shmem_int32_alltoall(new_team, out, in, 1); - - for (i = 0; i < npes; i++) { - int expected; - - if (new_team != SHMEM_TEAM_INVALID) - expected = pe_group_to_world(i, pe_start, pe_stride, pe_size); - else - expected = -1; - - if (out[i] != expected) { - printf("[%d] out[%d] = %d, expected %d\n", me, i, out[i], expected); - failed = 1; - } - } - - if (failed) - shmem_global_exit(1); -} - - -int main(int argc, char **argv) { - int npes; - int32_t *in, *out; - - shmem_init(); - - npes = shmem_n_pes(); - - in = shmem_malloc(4 * npes); - out = shmem_malloc(4 * npes); - - /* All PEs */ - alltoall_test(out, in, 0, 1, npes); - /* Only PE 0, stride is invalid (should be ignored if NPES < 13) */ - alltoall_test(out, in, 0, 13, 1); - /* Only even PEs */ - alltoall_test(out, in, 0, 2, npes / 2 + npes % 2); - - if (npes > 1) { - /* Remove PE n-1 */ - alltoall_test(out, in, 0, 1, npes-1); - /* Remove PE 0 */ - alltoall_test(out, in, 1, 1, npes-1); - /* Only odd PEs */ - alltoall_test(out, in, 1, 2, npes / 2); - } - - shmem_finalize(); - return 0; -} diff --git a/test/unit/alltoalls.c b/test/unit/alltoalls.c deleted file mode 100644 index 41061de8b..000000000 --- a/test/unit/alltoalls.c +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include - -#define NELEM 16 - -/* Tranlate a group PE index to a global PE rank. */ -static int pe_group_to_world(int group_pe, int pe_start, int pe_stride, int pe_size) { - return group_pe >= pe_size ? -1 : pe_start + group_pe * pe_stride; -} - -static void alltoalls_test(int32_t *out, int32_t *in, int dst, int sst, int nelem, - int pe_start, int pe_stride, int pe_size) -{ - int me, npes, i, j, k; - int failed = 0; - - me = shmem_my_pe(); - npes = shmem_n_pes(); - - if (me == pe_start) - printf("A2AS: dst = %2d, sst = %2d, nelem = %2d, " - "pe_start = %2d, pe_stride = %2d, pe_size = %2d\n", - dst, sst, nelem, pe_start, pe_stride, pe_size); - - for (i = 0; i < NELEM*npes; i++) { - in[i] = me; - out[i] = -1; - } - - shmem_barrier_all(); - - shmem_team_t new_team; - shmem_team_split_strided(SHMEM_TEAM_WORLD, pe_start, pe_stride, pe_size, NULL, 0, &new_team); - if (new_team != SHMEM_TEAM_INVALID) - shmem_int32_alltoalls(new_team, out, in, dst, sst, nelem); - - for (i = 0; i < npes; i++) { - int expected; - - for (j = 0; j < nelem; j++) { - for (k = 0; k < dst; k++) { - int idx = i*dst*nelem + j*dst + k; - if (new_team != SHMEM_TEAM_INVALID) - expected = (k % dst == 0) ? pe_group_to_world(i, pe_start, pe_stride, pe_size) : -1; - else - expected = -1; - - if (out[idx] != expected) { - printf("[%d] out[%d] = %d, expected %d\n", me, idx, out[idx], expected); - failed = 1; - } - } - } - } - - if (failed) - shmem_global_exit(1); -} - - -int main(int argc, char **argv) { - int npes; - int32_t *in, *out; - - shmem_init(); - - npes = shmem_n_pes(); - - in = shmem_malloc(4 * NELEM * npes); - out = shmem_malloc(4 * NELEM * npes); - - /* All PEs */ - alltoalls_test(out, in, 1, 1, 1, 0, 1, npes); /* Same as alltoall */ - alltoalls_test(out, in, 1, 1, 0, 0, 1, npes); /* No op */ - alltoalls_test(out, in, 2, 2, NELEM/2, 0, 1, npes); /* Alternate elements */ - alltoalls_test(out, in, 2, 1, NELEM/2, 0, 1, npes); /* dst != sst */ - alltoalls_test(out, in, 1, 2, NELEM/2 - 1, 0, 1, npes); /* dst != sst */ - /* Only PE 0, stride is invalid (should be ignored if NPES < 13) */ - alltoalls_test(out, in, 1, 1, 1, 0, 13, 1); /* Same as alltoall */ - alltoalls_test(out, in, 1, 1, 0, 0, 13, 1); /* No op */ - alltoalls_test(out, in, 2, 2, NELEM/2, 0, 13, 1); /* Alternate elements */ - alltoalls_test(out, in, 2, 1, NELEM/2, 0, 13, 1); /* dst != sst */ - alltoalls_test(out, in, 1, 2, NELEM/2 - 1, 0, 13, 1); /* dst != sst */ - /* Only even PEs */ - alltoalls_test(out, in, 1, 1, 1, 0, 2, npes / 2 + npes % 2); /* Same as alltoall */ - alltoalls_test(out, in, 1, 1, 0, 0, 2, npes / 2 + npes % 2); /* No op */ - alltoalls_test(out, in, 2, 2, NELEM/2, 0, 2, npes / 2 + npes % 2); /* Alternate elements */ - alltoalls_test(out, in, 2, 1, NELEM/2, 0, 2, npes / 2 + npes % 2); /* dst != sst */ - alltoalls_test(out, in, 1, 2, NELEM/2 - 1, 0, 2, npes / 2 + npes % 2); /* dst != sst */ - - if (npes > 1) { - /* Remove PE n-1 */ - alltoalls_test(out, in, 1, 1, 1, 0, 1, npes-1); /* Same as alltoall */ - alltoalls_test(out, in, 1, 1, 0, 0, 1, npes-1); /* No op */ - alltoalls_test(out, in, 2, 2, NELEM/2, 0, 1, npes-1); /* Alternate elements */ - alltoalls_test(out, in, 2, 1, NELEM/2, 0, 1, npes-1); /* dst != sst */ - alltoalls_test(out, in, 1, 2, NELEM/2 - 1, 0, 1, npes-1); /* dst != sst */ - /* Remove PE 0 */ - alltoalls_test(out, in, 1, 1, 1, 1, 1, npes-1); /* Same as alltoall */ - alltoalls_test(out, in, 1, 1, 0, 1, 1, npes-1); /* No op */ - alltoalls_test(out, in, 2, 2, NELEM/2, 1, 1, npes-1); /* Alternate elements */ - alltoalls_test(out, in, 2, 1, NELEM/2, 1, 1, npes-1); /* dst != sst */ - alltoalls_test(out, in, 1, 2, NELEM/2 - 1, 1, 1, npes-1); /* dst != sst */ - /* Only odd PEs */ - alltoalls_test(out, in, 1, 1, 1, 1, 2, npes / 2); /* Same as alltoall */ - alltoalls_test(out, in, 1, 1, 0, 1, 2, npes / 2); /* No op */ - alltoalls_test(out, in, 2, 2, NELEM/2, 1, 2, npes / 2); /* Alternate elements */ - alltoalls_test(out, in, 2, 1, NELEM/2, 1, 2, npes / 2); /* dst != sst */ - alltoalls_test(out, in, 1, 2, NELEM/2 - 1, 1, 2, npes / 2); /* dst != sst */ - } - - shmem_finalize(); - return 0; -} diff --git a/test/unit/asym_alloc.c b/test/unit/asym_alloc.c deleted file mode 100644 index 398b700ff..000000000 --- a/test/unit/asym_alloc.c +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* Synopsis: Test that a single asymmetric allocation works correctly. - * - * This semantic is provided in OpenSHMEM 1.1 and some versions of Cray SHMEM. - * It was removed from OpenSHMEM in 1.2, but we maintain it for backward - * compatibility. - */ - -#include -#include -#include - -long bufsize, maxbufsize; - -int main(int argc, char **argv) { - int *buf, *buf_in; - int me, npes, i, target; - - shmem_init(); - me = shmem_my_pe(); - npes = shmem_n_pes(); - - /* Each PE allocates space for "me + 1" integers */ - bufsize = me + 1; - buf = shmem_malloc(sizeof(int) * bufsize); - - if (NULL == buf) - shmem_global_exit(1); - - for (i = 0; i < bufsize; i++) - buf[i] = -1; - - shmem_barrier_all(); - - /* Write to neighbor's buffer */ - target = (me + 1) % npes; - buf_in = malloc(sizeof(int) * (target + 1)); - if (!buf_in) { - fprintf(stderr, "ERR - null buf_in pointer\n"); - shmem_global_exit(1); - } - - for (i = 0; i < target + 1; i++) - buf_in[i] = target; - - shmem_int_put(buf, buf_in, target + 1, target); - - shmem_barrier_all(); - - /* Validate data was written correctly */ - for (i = 0; i < me + 1; i++) { - if (buf[i] != me) { - printf("Error [%3d]: buf[%d] == %d, expected %d\n", me, i, buf[i], me); - shmem_global_exit(2); - } - } - - free(buf_in); - shmem_free(buf); - shmem_finalize(); - return 0; -} diff --git a/test/unit/atomic_bitwise.c b/test/unit/atomic_bitwise.c deleted file mode 100644 index b9dd9afa1..000000000 --- a/test/unit/atomic_bitwise.c +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Copyright (c) 2017 Rice University. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - * Test various bitwise atomics. These tests assume that an unsigned int is at - * least 4 bytes. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#define XOR_MASK 0xff -#define XOR_MASK2 0xffff -#define OR_MASK 0xff -#define OR_MASK2 0xff0000 -#define AND_MASK 0xffff00 -#define AND_MASK2 0xff0000 - -unsigned int shared_uint = 0; -unsigned long shared_ulong = 0; -unsigned long long shared_ulonglong = 0; -int32_t shared_int32 = 0; -int64_t shared_int64 = 0; -uint32_t shared_uint32 = 0; -uint64_t shared_uint64 = 0; - -int -main(int argc, char* argv[]) -{ - shmem_init(); - int my_rank = shmem_my_pe(); - int num_ranks = shmem_n_pes(); - if (num_ranks == 1) { - fprintf(stderr, "ERR - Requires > 1 PEs\n"); - shmem_finalize(); - return 0; - } - if (num_ranks % 2 != 0) { - fprintf(stderr, "ERR - Requires even number of PEs\n"); - shmem_finalize(); - return 0; - } - if (sizeof(unsigned int) < 4) { - fprintf(stderr, "ERR - Expected ints to be at least 4 bytes\n"); - shmem_finalize(); - return 0; - } - - int neighbor; - if ((my_rank % 2) == 0) { - neighbor = my_rank + 1; - } else { - neighbor = my_rank - 1; - } - - /* - * Test non-fetching XOR. This should result in each shared variable having - * its value set to XOR_MASK. All shared values are initialized to zero. - */ - shmem_uint_atomic_xor(&shared_uint, (unsigned int)XOR_MASK, neighbor); - shmem_ulong_atomic_xor(&shared_ulong, (unsigned long)XOR_MASK, neighbor); - shmem_ulonglong_atomic_xor(&shared_ulonglong, (unsigned long long)XOR_MASK, neighbor); - shmem_int32_atomic_xor(&shared_int32, (int32_t)XOR_MASK, neighbor); - shmem_int64_atomic_xor(&shared_int64, (int64_t)XOR_MASK, neighbor); - shmem_uint32_atomic_xor(&shared_uint32, (uint32_t)XOR_MASK, neighbor); - shmem_uint64_atomic_xor(&shared_uint64, (uint64_t)XOR_MASK, neighbor); - - shmem_barrier_all(); - - assert(shared_uint == XOR_MASK); - assert(shared_ulong == XOR_MASK); - assert(shared_ulonglong == XOR_MASK); - assert(shared_int32 == XOR_MASK); - assert(shared_int64 == XOR_MASK); - assert(shared_uint32 == XOR_MASK); - assert(shared_uint64 == XOR_MASK); - - shmem_barrier_all(); - - /* - * Test fetching XOR. Prior to this block, all shared variables contain the - * value XOR_MASK. Here, we XOR them with XOR_MASK2. - */ - unsigned int fetched_uint = shmem_uint_atomic_fetch_xor(&shared_uint, (unsigned int)XOR_MASK2, neighbor); - unsigned long fetched_ulong = shmem_ulong_atomic_fetch_xor(&shared_ulong, (unsigned long)XOR_MASK2, neighbor); - unsigned long long fetched_ulonglong = shmem_ulonglong_atomic_fetch_xor(&shared_ulonglong, (unsigned long long)XOR_MASK2, neighbor); - int32_t fetched_int32 = shmem_int32_atomic_fetch_xor(&shared_int32, (int32_t)XOR_MASK2, neighbor); - int64_t fetched_int64 = shmem_int64_atomic_fetch_xor(&shared_int64, (int64_t)XOR_MASK2, neighbor); - uint32_t fetched_uint32 = shmem_uint32_atomic_fetch_xor(&shared_uint32, (uint32_t)XOR_MASK2, neighbor); - uint64_t fetched_uint64 = shmem_uint64_atomic_fetch_xor(&shared_uint64, (uint64_t)XOR_MASK2, neighbor); - - shmem_barrier_all(); - - assert(fetched_uint == XOR_MASK); assert(shared_uint == ((unsigned int)XOR_MASK ^ (unsigned int)XOR_MASK2)); - assert(fetched_ulong == XOR_MASK); assert(shared_ulong == ((unsigned long)XOR_MASK ^ (unsigned long)XOR_MASK2)); - assert(fetched_ulonglong == XOR_MASK); assert(shared_ulonglong == ((unsigned long long)XOR_MASK ^ (unsigned long long)XOR_MASK2)); - assert(fetched_int32 == XOR_MASK); assert(shared_int32 == ((int32_t)XOR_MASK ^ (int32_t)XOR_MASK2)); - assert(fetched_int64 == XOR_MASK); assert(shared_int64 == ((int64_t)XOR_MASK ^ (int64_t)XOR_MASK2)); - assert(fetched_uint32 == XOR_MASK); assert(shared_uint32 == ((uint32_t)XOR_MASK ^ (uint32_t)XOR_MASK2)); - assert(fetched_uint64 == XOR_MASK); assert(shared_uint64 == ((uint64_t)XOR_MASK ^ (uint64_t)XOR_MASK2)); - - shmem_barrier_all(); - - /* - * Test non-fetching OR. Prior to this block, all shared variables have the - * value XOR_MASK ^ XOR_MASK2 (i.e. 0xff00). Here, we do a bitwise OR with - * OR_MASK (i.e. 0xff). - */ - shmem_uint_atomic_or(&shared_uint, (unsigned int)OR_MASK, neighbor); - shmem_ulong_atomic_or(&shared_ulong, (unsigned long)OR_MASK, neighbor); - shmem_ulonglong_atomic_or(&shared_ulonglong, (unsigned long long)OR_MASK, neighbor); - shmem_int32_atomic_or(&shared_int32, (int32_t)OR_MASK, neighbor); - shmem_int64_atomic_or(&shared_int64, (int64_t)OR_MASK, neighbor); - shmem_uint32_atomic_or(&shared_uint32, (uint32_t)OR_MASK, neighbor); - shmem_uint64_atomic_or(&shared_uint64, (uint64_t)OR_MASK, neighbor); - - shmem_barrier_all(); - - assert(shared_uint == 0xffff); - assert(shared_ulong == 0xffff); - assert(shared_ulonglong == 0xffff); - assert(shared_int32 == 0xffff); - assert(shared_int64 == 0xffff); - assert(shared_uint32 == 0xffff); - assert(shared_uint64 == 0xffff); - - shmem_barrier_all(); - - /* - * Test fetching OR. Prior to this block, all shared variables have the - * value (XOR_MASK ^ XOR_MASK2) | OR_MASK (i.e. 0xffff). Here we OR with - * OR_MASK2 (i.e. 0xff0000). - */ - fetched_uint = shmem_uint_atomic_fetch_or(&shared_uint, (unsigned int)OR_MASK2, neighbor); - fetched_ulong = shmem_ulong_atomic_fetch_or(&shared_ulong, (unsigned long)OR_MASK2, neighbor); - fetched_ulonglong = shmem_ulonglong_atomic_fetch_or(&shared_ulonglong, (unsigned long long)OR_MASK2, neighbor); - fetched_int32 = shmem_int32_atomic_fetch_or(&shared_int32, (int32_t)OR_MASK2, neighbor); - fetched_int64 = shmem_int64_atomic_fetch_or(&shared_int64, (int64_t)OR_MASK2, neighbor); - fetched_uint32 = shmem_uint32_atomic_fetch_or(&shared_uint32, (uint32_t)OR_MASK2, neighbor); - fetched_uint64 = shmem_uint64_atomic_fetch_or(&shared_uint64, (uint64_t)OR_MASK2, neighbor); - - shmem_barrier_all(); - - assert(fetched_uint == 0xffff); assert(shared_uint == (unsigned int)0xffffff); - assert(fetched_ulong == 0xffff); assert(shared_ulong == (unsigned long)0xffffff); - assert(fetched_ulonglong == 0xffff); assert(shared_ulonglong == (unsigned long long)0xffffff); - assert(fetched_int32 == 0xffff); assert(shared_int32 == (int32_t)0xffffff); - assert(fetched_int64 == 0xffff); assert(shared_int64 == (int64_t)0xffffff); - assert(fetched_uint32 == 0xffff); assert(shared_uint32 == (uint32_t)0xffffff); - assert(fetched_uint64 == 0xffff); assert(shared_uint64 == (uint64_t)0xffffff); - - shmem_barrier_all(); - - /* - * Test non-fetching AND. All shared variables store the value 0xffffff. - * Here, we AND with 0xffff00. - */ - shmem_uint_atomic_and(&shared_uint, (unsigned int)AND_MASK, neighbor); - shmem_ulong_atomic_and(&shared_ulong, (unsigned long)AND_MASK, neighbor); - shmem_ulonglong_atomic_and(&shared_ulonglong, (unsigned long long)AND_MASK, neighbor); - shmem_int32_atomic_and(&shared_int32, (int32_t)AND_MASK, neighbor); - shmem_int64_atomic_and(&shared_int64, (int64_t)AND_MASK, neighbor); - shmem_uint32_atomic_and(&shared_uint32, (uint32_t)AND_MASK, neighbor); - shmem_uint64_atomic_and(&shared_uint64, (uint64_t)AND_MASK, neighbor); - - shmem_barrier_all(); - - assert(shared_uint == AND_MASK); - assert(shared_ulong == AND_MASK); - assert(shared_ulonglong == AND_MASK); - assert(shared_int32 == AND_MASK); - assert(shared_int64 == AND_MASK); - assert(shared_uint32 == AND_MASK); - assert(shared_uint64 == AND_MASK); - - shmem_barrier_all(); - - /* - * Test fetching AND. All shared variables store the value 0xffff00. Here, - * we AND with 0xff0000. - */ - fetched_uint = shmem_uint_atomic_fetch_and(&shared_uint, (unsigned int)AND_MASK2, neighbor); - fetched_ulong = shmem_ulong_atomic_fetch_and(&shared_ulong, (unsigned long)AND_MASK2, neighbor); - fetched_ulonglong = shmem_ulonglong_atomic_fetch_and(&shared_ulonglong, (unsigned long long)AND_MASK2, neighbor); - fetched_int32 = shmem_int32_atomic_fetch_and(&shared_int32, (int32_t)AND_MASK2, neighbor); - fetched_int64 = shmem_int64_atomic_fetch_and(&shared_int64, (int64_t)AND_MASK2, neighbor); - fetched_uint32 = shmem_uint32_atomic_fetch_and(&shared_uint32, (uint32_t)AND_MASK2, neighbor); - fetched_uint64 = shmem_uint64_atomic_fetch_and(&shared_uint64, (uint64_t)AND_MASK2, neighbor); - - shmem_barrier_all(); - - assert(fetched_uint == AND_MASK); assert(shared_uint == (unsigned int)AND_MASK2); - assert(fetched_ulong == AND_MASK); assert(shared_ulong == (unsigned long)AND_MASK2); - assert(fetched_ulonglong == AND_MASK); assert(shared_ulonglong == (unsigned long long)AND_MASK2); - assert(fetched_int32 == AND_MASK); assert(shared_int32 == (int32_t)AND_MASK2); - assert(fetched_int64 == AND_MASK); assert(shared_int64 == (int64_t)AND_MASK2); - assert(fetched_uint32 == AND_MASK); assert(shared_uint32 == (uint32_t)AND_MASK2); - assert(fetched_uint64 == AND_MASK); assert(shared_uint64 == (uint64_t)AND_MASK2); - - shmem_finalize(); - - if (my_rank == 0) { - printf("Passed!\n"); - } - - return 0; -} diff --git a/test/unit/atomic_inc.c b/test/unit/atomic_inc.c deleted file mode 100644 index 5fb392673..000000000 --- a/test/unit/atomic_inc.c +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - * test shmem_int_atomic_inc() atomic_inc {-v|q} {loop-cnt(default=10)(default=10)} - * where: -q == quiet, -v == verbose/debug - * Loop for loop-cnt - * all PEs call shmem_int_atomic_inc(), PE-0 totals - * - */ - -#include -#include -#include -#include -#include -#include -#include - -#define Rfprintf if (shmem_my_pe() == 0) fprintf -#define Rprintf if (shmem_my_pe() == 0) printf -#define RDfprintf if (Verbose && shmem_my_pe() == 0) fprintf -#define RDprintf if (Verbose && shmem_my_pe() == 0) printf -#define Vprintf if (Verbose) printf -#define Vfprintf if (Verbose) fprintf - -int Verbose; -int lock_cnt; -long lock; - -int -main(int argc, char* argv[]) -{ - int c, cloop, loops; - int my_rank, num_ranks; - int Announce = (NULL == getenv("MAKELEVEL")) ? 1 : 0; - - shmem_init(); - my_rank = shmem_my_pe(); - num_ranks = shmem_n_pes(); - if (num_ranks == 1) { - fprintf(stderr, "ERR - Requires > 1 PEs\n"); - shmem_finalize(); - return 0; - } - - while((c=getopt(argc,argv,"vq")) != -1) { - switch(c) { - case 'v': - Verbose++; - break; - case 'q': - Announce = 0; - break; - default: - Rfprintf(stderr,"ERR - unknown -%c ?\n",c); - shmem_finalize(); - return 1; - } - } - - if (optind == argc) - loops = 10; - else { - loops = atoi(argv[optind++]); - if (loops <= 0 || loops > 1000000) { - Rfprintf(stderr, - "ERR - loops arg out of bounds '%d'?\n", loops); - shmem_finalize(); - return 1; - } - } - - for(cloop=1; cloop <= loops; cloop++) - { - lock_cnt = 0; - shmem_barrier_all(); /* sync all ranks */ - - for(c=0; c < num_ranks; c++) - shmem_int_atomic_inc( &lock_cnt, c ); - - Vprintf("[%d] locked: lock_cnt(%d)\n", my_rank, lock_cnt); - - shmem_int_wait_until( &lock_cnt, SHMEM_CMP_GE, num_ranks ); - - shmem_barrier_all(); /* sync all ranks */ - - if (lock_cnt != num_ranks) - printf ("[%d] loop %d: bad lock_cnt %d, expected %d?\n", - my_rank, cloop, lock_cnt, num_ranks); - - if ( (cloop % 10) == 0 ) { - if (my_rank == 0 && Announce) - printf("%d ranks completed %d loops\n", num_ranks, cloop); - } - } - - Vprintf ("[%d] of %d, Exit: lock_cnt %d\n", - my_rank, num_ranks, lock_cnt); - - shmem_finalize(); - - return 0; -} diff --git a/test/unit/atomic_nbi.c b/test/unit/atomic_nbi.c deleted file mode 100644 index dc115173f..000000000 --- a/test/unit/atomic_nbi.c +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2018 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include - -#define N 2 - -static long target; - -int main(void) { - int i, errors = 0; - - shmem_init(); - - int me = shmem_my_pe(); - int npes = shmem_n_pes(); - - long *result = malloc(sizeof(long)*npes); - - /* Test NBI swap */ - - target = me; - for (i = 0; i < npes; i++) - result[i] = -1; - - shmem_barrier_all(); - - /* Loop until we observe 'npes' values that are congruent to 'me' mod N */ - for (int ncompleted = 0; ncompleted < npes; ) { - for (i = 0; i < npes; i++) - shmem_long_atomic_swap_nbi(&result[i], &target, me, i); - shmem_quiet(); - for (i = 0; i < npes; i++) - if (me % N == result[i] % N) ++ncompleted; - } - - shmem_barrier_all(); - - if (target < 0 || target >= npes) { - printf("%d: Invalid target (%ld) in NBI swap test\n", me, target); - ++errors; - } - - for (i = 0; i < npes; i++) { - if (result[i] < 0 || result[i] >= npes) { - printf("%d: Invalid result (%ld) in NBI swap test\n", me, result[i]); - ++errors; - } - } - - /* Test NBI cswap */ - - target = -1; - for (i = 0; i < npes; i++) - result[i] = npes; - - shmem_barrier_all(); - - /* Target value at each PE counts from -1 up to npes-1 */ - for (;;) { - int ncompleted = 0; - - /* Attempt to increment each PE not already incremented by me */ - for (i = 0; i < npes; i++) - if (result[i] != me-1) - shmem_long_atomic_compare_swap_nbi(&result[i], &target, me-1, me, i); - - shmem_quiet(); - - for (i = 0; i < npes; i++) - if (result[i] == me-1) ++ncompleted; - if (ncompleted == npes) - break; - } - - shmem_barrier_all(); - - if (target != npes-1) { - printf("%d: Invalid target (%ld) in NBI cswap test\n", me, target); - ++errors; - } - - for (i = 0; i < npes; i++) { - if (result[i] != me-1) { - printf("%d: Invalid result (%ld) in NBI cswap test\n", me, result[i]); - ++errors; - } - } - - shmem_finalize(); - return errors != 0; -} diff --git a/test/unit/barrier.c b/test/unit/barrier.c deleted file mode 100644 index aba9e0f26..000000000 --- a/test/unit/barrier.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - * shmem_barrier() test barrier {-V} {loop-cnt} - */ -#include -#include -#include -#include - -#include - -#define Rfprintf if (shmem_my_pe() == 0) fprintf -#define Rprintf if (shmem_my_pe() == 0) printf -#define RDfprintf if (Verbose && shmem_my_pe() == 0) fprintf -#define RDprintf if (Verbose && shmem_my_pe() == 0) printf - -int Verbose; - -int -main(int argc, char* argv[]) -{ - int c, j,loops; - int rank, num_ranks; - char *prog_name; - - shmem_init(); - rank = shmem_my_pe(); - num_ranks = shmem_n_pes(); - if (num_ranks == 1) { - Rfprintf(stderr, - "ERR - Requires > 1 PEs\n"); - shmem_finalize(); - return 0; - } - prog_name = strrchr(argv[0],'/'); - if ( prog_name ) - prog_name++; - else - prog_name = argv[0]; - - while((c=getopt(argc,argv,"v")) != -1) { - switch(c) { - case 'V': - Verbose++; - break; - default: - Rfprintf(stderr,"ERR - unknown -%c ?\n",c); - shmem_finalize(); - return 1; - } - } - - if (optind == argc) - loops = 30; - else { - loops = atoi(argv[optind++]); - if (loops <= 0 || loops > 1000000) { - Rfprintf(stderr, - "ERR - loops arg out of bounds '%d'?\n", loops); - shmem_finalize(); - return 1; - } - } - - for(j=0; j < loops; j++) { - //if ( j==0 || (j % 10) == 0 ) - RDfprintf(stderr,"[%d] pre-barrier(%d)\n", rank,j); - - shmem_barrier_all(); /* sync sender and receiver */ - - //if ( j==0 || (j % 10) == 0 ) - RDfprintf(stderr,"[%d] post barrier(%d)\n", rank,j); - } - - RDprintf ("%d(%d) Exit\n", rank, num_ranks); - - shmem_finalize(); - - return 0; -} diff --git a/test/unit/bcast.c b/test/unit/bcast.c deleted file mode 100644 index b15ef1fad..000000000 --- a/test/unit/bcast.c +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - * broadcast [0...num_pes] - * - * usage: bcast {-v|h} - * - * Loop - shmem_broadcast_all() with increasing data amount. - */ - -#include -#include -#include -#include -#include - -#define START_BCAST_SIZE 16 -#define BCAST_INCR 1024 - -int -main(int argc, char* argv[]) -{ - int i, Verbose=0; - int mpe, num_pes, loops=10, cloop; - char *pgm; - long *dst, *src; - int nBytes = START_BCAST_SIZE; - int nLongs=0; - - shmem_init(); - mpe = shmem_my_pe(); - num_pes = shmem_n_pes(); - - if (num_pes == 1) { - printf("%s: Requires number of PEs > 1\n", argv[0]); - shmem_finalize(); - return 0; - } - - if (sizeof(long) != 8) { - printf("Test assumes 64-bit long (%zd)\n", sizeof(long)); - shmem_global_exit(1); - return 0; - } - - if ((pgm=strrchr(argv[0],'/'))) { - pgm++; - } else { - pgm = argv[0]; - } - - if (argc > 1) { - if (strncmp(argv[1],"-v",3) == 0) { - Verbose=1; - } else if (strncmp(argv[1],"-h",3) == 0) { - fprintf(stderr,"usage: %s {-v(verbose)|h(help)}\n",pgm); - shmem_finalize(); - exit(1); - } - } - - if ( mpe == 0 && Verbose ) { - fprintf(stderr,"%d loops\n",loops); - } - - for(cloop=1; cloop <= loops; cloop++) { - - nLongs = nBytes / sizeof(long); - dst = (long *)shmem_malloc(nBytes*2); - if ( !dst ) { - fprintf(stderr,"[%d] shmem_malloc(%d) failed %s\n", - mpe,nBytes,strerror(errno)); - return 0; - } - memset( (void*)dst, 0, nBytes ); - src = &dst[nLongs]; - for (i = 1; i < nLongs; i++) { - src[i] = i+1; - } - - shmem_barrier_all(); - - shmem_long_broadcast(SHMEM_TEAM_WORLD, dst, src, nLongs, 1); - - for(i=0; i < nLongs; i++) { - if (dst[i] != src[i]) { - fprintf(stderr,"[%d] dst[%d] %ld != expected %ld\n", - mpe, i, dst[i],src[i]); - shmem_global_exit(1); - } - } - shmem_barrier_all(); - - shmem_free (dst); - if (Verbose && mpe ==0) - fprintf(stderr,"loop %2d Bcast %d, Done.\n",cloop,nBytes); - nBytes += BCAST_INCR; - } - - shmem_finalize(); - - return 0; -} diff --git a/test/unit/bcast_flood.c b/test/unit/bcast_flood.c deleted file mode 100644 index 0852dd5c6..000000000 --- a/test/unit/bcast_flood.c +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* Broadcast flood - bcast 100KB to all, default to using 2 pSync vars */ - -#include -#include -#include -#include -#include -#include - -#include -#include "tests_sos/wtime.h" - -static int atoi_scaled(char *s); -static void usage(char *pgm); - -int Verbose=0; -int Serialize; - -#define DFLT_LOOPS 600 // downsized for 'make check' -//#define DFLT_LOOPS 10000 -#define N_ELEMENTS 25600 /*100 KB as ints */ - -int -main(int argc, char **argv) -{ - int i; - int *target; - int *source; - int me, npes, elements=N_ELEMENTS, loops=DFLT_LOOPS; - char *pgm; - double start_time, time_taken; - - shmem_init(); - me = shmem_my_pe(); - npes = shmem_n_pes(); - - if ((pgm=strrchr(argv[0],'/'))) { - pgm++; - } else { - pgm = argv[0]; - } - - while ((i = getopt (argc, argv, "hve:l:p:s")) != EOF) { - switch (i) - { - case 'v': - Verbose++; - break; - case 'e': - if ((elements = atoi_scaled(optarg)) <= 0) { - fprintf(stderr,"ERR: Bad elements count %d\n",elements); - shmem_finalize(); - return 1; - } - break; - case 'l': - if ((loops = atoi_scaled(optarg)) <= 0) { - fprintf(stderr,"ERR: Bad loop count %d\n",loops); - shmem_finalize(); - return 1; - } - break; - case 's': - Serialize++; - break; - case 'h': - if (me == 0) - usage(pgm); - return 0; - default: - if (me == 0) { - fprintf(stderr,"%s: unknown switch '-%c'?\n",pgm,i); - usage(pgm); - } - shmem_finalize(); - return 1; - } - } - - source = (int *) shmem_malloc( elements * sizeof(*source) ); - if (!source) { - fprintf(stderr, "ERR - null source pointer\n"); - shmem_global_exit(1); - } - - target = (int *) shmem_malloc( elements * sizeof(*target) ); - if (!target) { - fprintf(stderr, "ERR - null target pointer\n"); - shmem_global_exit(1); - } - for (i = 0; i < elements; i += 1) { - source[i] = i + 1; - target[i] = -90; - } - - if (me==0 && Verbose) { - fprintf(stderr,"loops %d nElems %d\n", - loops,elements); - } - - shmem_barrier_all(); - - for(time_taken = 0.0, i = 0; i < loops; i++) { - - start_time = tests_sos_wtime(); - - shmem_int_broadcast(SHMEM_TEAM_WORLD, target, source, elements, 0); - - if (Serialize) shmem_barrier_all(); - - time_taken += (tests_sos_wtime() - start_time); - - } - - if(me == 0 && Verbose) { - printf("%d loops of Broadcast32(%ld bytes) over %d PEs: %7.3f secs\n", - loops, (elements*sizeof(*source)), npes, time_taken); - elements = (elements * loops * sizeof(*source)) / (1024*1024); - printf(" %7.5f secs per broadcast() @ %7.4f MB/sec\n", - (time_taken/(double)loops), ((double)elements / time_taken) ); - } - - if (Verbose > 1) fprintf(stderr,"[%d] pre B1\n",me); - - shmem_barrier_all(); - - if (Verbose > 1) fprintf(stderr,"[%d] post B1\n",me); - - shmem_free(target); - shmem_free(source); - - shmem_finalize(); - - return 0; -} - - -static int -atoi_scaled(char *s) -{ - long val; - char *e; - - val = strtol(s,&e,0); - if (e == NULL || *e =='\0') - return (int)val; - - if (*e == 'k' || *e == 'K') - val *= 1024; - else if (*e == 'm' || *e == 'M') - val *= 1024*1024; - else if (*e == 'g' || *e == 'G') - val *= 1024*1024*1024; - - return (int)val; -} - - -static void -usage(char *pgm) -{ - fprintf(stderr, - "usage: %s -{lhv}\n" - " where:\n" - " -l loops (%d) loop count.\n" - " -e ints # of integers to broadcast\n" - " -v be verbose, multiple 'v' more verbose\n" - " -h this text.\n", - pgm,DFLT_LOOPS); -} - diff --git a/test/unit/bcast_in_place.c b/test/unit/bcast_in_place.c deleted file mode 100644 index c10bd5006..000000000 --- a/test/unit/bcast_in_place.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2022 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include - -#define NELEM 10 - -long src[NELEM]; - -int main(void) -{ - int me; - int errors = 0; - - shmem_init(); - - me = shmem_my_pe(); - - for (int i = 0; i < NELEM; i++) - src[i] = me + i; - - shmem_barrier_all(); - - shmem_long_broadcast(SHMEM_TEAM_WORLD, src, src, NELEM, 0); - - /* Validate broadcast data */ - for (int j = 0; j < NELEM; j++) { - long expected = j; - if (src[j] != expected) { - printf("%d: Expected src[%d] = %ld, got src[%d] = %ld\n", me, j, expected, j, src[j]); - errors++; - } - } - - shmem_finalize(); - - return errors != 0; -} diff --git a/test/unit/big_reduction.c b/test/unit/big_reduction.c deleted file mode 100644 index c76d343a5..000000000 --- a/test/unit/big_reduction.c +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - * reduce across PEs with shmem_max_to_all() - * - * usage: big_reduction {-v|h} -*/ - -#include -#include -#include -#include - -#define N 128 - -long src[N]; -long dst[N]; - -#define MAX(a, b) ((a) > (b)) ? (a) : (b) -#define WRK_SIZE MAX(N/2+1, SHMEM_REDUCE_MIN_WRKDATA_SIZE) - -int -main(int argc, char* argv[]) -{ - int i, Verbose=0; - char *pgm; - - if ((pgm=strrchr(argv[0],'/'))) { - pgm++; - } else { - pgm = argv[0]; - } - - if (argc > 1) { - if (strncmp(argv[1],"-v",3) == 0) { - Verbose=1; - } else if (strncmp(argv[1],"-h",3) == 0) { - fprintf(stderr,"usage: %s {-v(verbose)|h(help)}\n",pgm); - shmem_finalize(); - exit(1); - } - } - - shmem_init(); - - for (i = 0; i < N; i += 1) { - src[i] = shmem_my_pe() + i; - } - shmem_barrier_all(); - - shmem_long_max_reduce(SHMEM_TEAM_WORLD, dst, src, N); - - if (Verbose) { - printf("%d/%d\tdst =", shmem_my_pe(), shmem_n_pes() ); - for (i = 0; i < N; i+= 1) { - printf(" %ld", dst[i]); - } - printf("\n"); - } - - for (i = 0; i < N; i+= 1) { - if (dst[i] != shmem_n_pes() - 1 + i) { - printf("[%3d] Error: dst[%d] == %ld, expected %ld\n", - shmem_my_pe(), i, dst[i], shmem_n_pes() - 1 + (long) i); - shmem_global_exit(1); - } - } - - shmem_finalize(); - - return 0; -} diff --git a/test/unit/bigget.c b/test/unit/bigget.c deleted file mode 100644 index 1aa29f6ce..000000000 --- a/test/unit/bigget.c +++ /dev/null @@ -1,242 +0,0 @@ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - * (big get) each PE gets N elements (1 MB) from (my_pe()+1 mod num_pes()). - */ - -#include -#include -#include -#include -#include - -#include -#include "tests_sos/wtime.h" - -#define NUM_ELEMENTS 4194304 // 32 MB by longs -//#define DFLT_LOOPS 10000 -#define DFLT_LOOPS 1000 - -int Verbose; -int Sync; -int Track; -int elements = NUM_ELEMENTS; -double *total_time; - -static int -atoi_scaled(char *s) -{ - long val; - char *e; - - val = strtol(s,&e,0); - if (e == NULL || *e =='\0') - return (int)val; - - if (*e == 'k' || *e == 'K') - val *= 1024; - else if (*e == 'm' || *e == 'M') - val *= 1024*1024; - else if (*e == 'g' || *e == 'G') - val *= 1024*1024*1024; - - return (int)val; -} - - -static void -usage(char *pgm) -{ - fprintf(stderr, - "usage: %s -{hvclst}\n" - " where: (big gets)\n" - " -v be verbose, multiple 'v' more verbose\n" - " -e element-cnt (%d) # of int sized elements to get\n" - " -l loops (%d) loop count.\n" - " -s synchronize: barrier after each shmem_get()\n" - " -t track: output '.' for every 200 shmem_get()s\n", - pgm,NUM_ELEMENTS,DFLT_LOOPS); -} - - -int -main(int argc, char **argv) -{ - int loops=DFLT_LOOPS; - char *pgm; - int *Target; - int *Source; - int i, me, npes; - int target_pe; - long bytes; - double time_taken=0.0, start_time; - - shmem_init(); - me = shmem_my_pe(); - npes = shmem_n_pes(); - - if ((pgm=strrchr(argv[0],'/'))) - pgm++; - else - pgm = argv[0]; - - while ((i = getopt (argc, argv, "hve:l:st")) != EOF) { - switch (i) - { - case 'v': - Verbose++; - break; - case 'e': - if ((elements = atoi_scaled(optarg)) <= 0) { - fprintf(stderr,"ERR: Bad elements count %d\n",elements); - shmem_finalize(); - return 1; - } - break; - case 'l': - if ((loops = atoi_scaled(optarg)) <= 0) { - fprintf(stderr,"ERR: Bad loop count %d\n",loops); - shmem_finalize(); - return 1; - } - break; - case 's': - Sync++; - break; - case 't': - Track++; - break; - case 'h': - if (me == 0) - usage(pgm); - return 0; - default: - if (me == 0) { - fprintf(stderr,"%s: unknown switch '-%c'?\n",pgm,i); - usage(pgm); - } - shmem_finalize(); - return 1; - } - } - - target_pe = (me+1) % npes; - - total_time = (double *) shmem_malloc( npes * sizeof(double) ); - if (!total_time) { - fprintf(stderr,"ERR: bad total_time shmem_malloc(%ld)\n", - (elements * sizeof(double))); - shmem_global_exit(1); - } - - Source = (int *) shmem_malloc( elements * sizeof(*Source) ); - if (!Source) { - fprintf(stderr,"ERR: bad Source shmem_malloc(%ld)\n", - (elements * sizeof(*Target))); - shmem_free(total_time); - shmem_global_exit(1); - } - - Target = (int *) shmem_malloc( elements * sizeof(*Target) ); - if (!Target) { - fprintf(stderr,"ERR: bad Target shmem_malloc(%ld)\n", - (elements * sizeof(*Target))); - shmem_free(Source); - shmem_free(total_time); - shmem_global_exit(1); - } - - for (i = 0; i < elements; i++) { - Target[i] = -90; - Source[i] = i + 1; - } - - bytes = loops * sizeof(int) * elements; - - if (Verbose && me==0) - fprintf(stderr, "%s: INFO - %d loops, get %d (int) elements from PE+1\n", - pgm, loops, elements); - - shmem_barrier_all(); - - for(i=0; i < loops; i++) { - - start_time = tests_sos_wtime(); - - shmem_int_get( Target, Source, elements, target_pe ); - - time_taken += tests_sos_wtime() - start_time; - - if (me==0) { - if ( Track && i > 0 && ((i % 200) == 0)) - fprintf(stderr,".%d",i); - } - if (Sync) - shmem_barrier_all(); - } - - // collect time per node elapsed time. - shmem_double_put( &total_time[me], &time_taken, 1, 0 ); - - shmem_barrier_all(); - - for (i = 0; i < elements; i++) { - if (Target[i] != i + 1) { - printf("%d: Error Target[%d] = %d, expected %d\n", - me, i, Target[i], i + 1); - shmem_global_exit(1); - } - } - - if ( Track && me == 0 ) - fprintf(stderr,"\n"); - - if (Verbose && me == 0) { - double rate,secs; - - // average time - for(i=0,secs=0.0; i < npes; i++) - secs += total_time[i]; - secs /= (double)npes; - rate = ((double)bytes/(1024.0*1024.0)) / secs; - printf("%s: ave %5.3f MB/sec (bytes %ld secs %5.3f)\n", - pgm, rate, bytes, secs); - } - - shmem_free(total_time); - shmem_free(Target); - shmem_free(Source); - - shmem_finalize(); - - return 0; -} diff --git a/test/unit/bigput.c b/test/unit/bigput.c deleted file mode 100644 index fb5b0b058..000000000 --- a/test/unit/bigput.c +++ /dev/null @@ -1,254 +0,0 @@ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - * (big puts) each PE puts N elements (1MB) to ((my_pe()+1) mod num_pes()). - */ - -#include -#include -#include -#include -#include - -#include -#include "tests_sos/wtime.h" - -#define NUM_ELEMENTS 4194304 // 32 MB by longs -//#define DFLT_LOOPS 10000 // reset when Portals4 can achieve this. -#define DFLT_LOOPS 100 - -int Verbose; -int Sync; -int Track; -int elements = NUM_ELEMENTS; -double sum_time, time_taken; - -static int -atoi_scaled(char *s) -{ - long val; - char *e; - - val = strtol(s,&e,0); - if (e == NULL || *e =='\0') - return (int)val; - - if (*e == 'k' || *e == 'K') - val *= 1024; - else if (*e == 'm' || *e == 'M') - val *= 1024*1024; - else if (*e == 'g' || *e == 'G') - val *= 1024*1024*1024; - - return (int)val; -} - -static void -usage(char *pgm) -{ - fprintf(stderr, - "usage: %s -{hvclst}\n" - " where: (big puts)\n" - " -v be verbose, multiple 'v' more verbose\n" - " -e element-cnt (%d) # of int sized elements to put\n" - " -l loops (%d) loop count.\n" - " -s synchronize: barrier after each shmem_put()\n" - " -t track: output '.' for every 200 shmem_put()s\n", - pgm,NUM_ELEMENTS,DFLT_LOOPS); -} - - -int -main(int argc, char **argv) -{ - int loops=DFLT_LOOPS; - char *pgm; - int *Target; - int *Source; - int i, me, npes; - int target_PE; - long bytes; - double start_time, *total_time; - - shmem_init(); - me = shmem_my_pe(); - npes = shmem_n_pes(); - - if ((pgm=strrchr(argv[0],'/'))) - pgm++; - else - pgm = argv[0]; - - while ((i = getopt (argc, argv, "hve:l:st")) != EOF) { - switch (i) - { - case 'v': - Verbose++; - break; - case 'e': - if ((elements = atoi_scaled(optarg)) <= 0) { - fprintf(stderr,"ERR: Bad elements count %d\n",elements); - shmem_finalize(); - return 1; - } - break; - case 'l': - if ((loops = atoi_scaled(optarg)) <= 0) { - fprintf(stderr,"ERR: Bad loop count %d\n",loops); - shmem_finalize(); - return 1; - } - break; - case 's': - Sync++; - break; - case 't': - Track++; - break; - case 'h': - if (me == 0) - usage(pgm); - return 0; - default: - if (me == 0) { - fprintf(stderr,"%s: unknown switch '-%c'?\n",pgm,i); - usage(pgm); - } - shmem_finalize(); - return 1; - } - } - - target_PE = (me+1) % npes; - - total_time = (double *) shmem_malloc( npes * sizeof(double) ); - if (!total_time) { - fprintf(stderr,"ERR: bad total_time shmem_malloc(%ld)\n", - (elements * sizeof(double))); - shmem_global_exit(1); - } - for(i=0; i < npes; i++) - total_time[i] = -1.0; - - Source = (int *) shmem_malloc( elements * sizeof(*Source) ); - if (!Source) { - fprintf(stderr,"ERR: bad Source shmem_malloc(%ld)\n", - (elements * sizeof(*Target))); - shmem_free(total_time); - shmem_global_exit(1); - } - - Target = (int *) shmem_malloc( elements * sizeof(*Target) ); - if (!Target) { - fprintf(stderr,"ERR: bad Target shmem_malloc(%ld)\n", - (elements * sizeof(*Target))); - shmem_free(Source); - shmem_free(total_time); - shmem_global_exit(1); - } - - for (i = 0; i < elements; i++) { - Target[i] = -90; - Source[i] = i + 1; - } - - bytes = loops * sizeof(int) * elements; - - if (Verbose && me==0) { - fprintf(stderr, - "%s: INFO - %d loops, put %d (int) elements to PE+1 Max put ??\n", - pgm, loops, elements); - } - shmem_barrier_all(); - - for(i=0; i < loops; i++) { - - start_time = tests_sos_wtime(); - - shmem_int_put(Target, Source, elements, target_PE); - - time_taken += (tests_sos_wtime() - start_time); - - if (me==0) { - if ( Track && i > 0 && ((i % 200) == 0)) - fprintf(stderr,".%d",i); - } - if (Sync) - shmem_barrier_all(); - } - - // collect time per node. - shmem_double_put( &total_time[me], &time_taken, 1, 0 ); - shmem_double_sum_reduce(SHMEM_TEAM_WORLD, &sum_time, &time_taken, 1); - - shmem_barrier_all(); - - for (i = 0; i < elements; i++) { - if (Target[i] != i + 1) { - printf("%d: Error Target[%d] = %d, expected %d\n", - me, i, Target[i], i + 1); - shmem_global_exit(1); - } - } - - if ( Track && me == 0 ) fprintf(stderr,"\n"); - - if(Verbose && me == 0) { - double rate, comp_time; - - if (Verbose > 1) - fprintf(stdout,"Individule PE times: (seconds)\n"); - for(i=0,comp_time=0.0; i < npes; i++) { - comp_time += total_time[i]; - if (Verbose > 1) - fprintf(stdout," PE[%d] %8.6f\n",i,total_time[i]); - } - - sum_time /= (double)npes; - comp_time /= (double)npes; - if (sum_time != comp_time) - printf("%s: computed_time %7.5f != sum_reduce_time %7.5f)\n", - pgm, comp_time, sum_time ); - - rate = ((double)bytes/(1024.0*1024.0)) / comp_time; - printf("%s: shmem_int_put() %7.4f MB/sec (bytes %ld secs %7.4f)\n", - pgm, rate, bytes, sum_time); - } - - shmem_free(total_time); - shmem_free(Target); - shmem_free(Source); - - shmem_finalize(); - - return 0; -} diff --git a/test/unit/broadcast_active_set.c b/test/unit/broadcast_active_set.c deleted file mode 100644 index c40eba7f0..000000000 --- a/test/unit/broadcast_active_set.c +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include - -#define NELEM 10 - -#ifdef ENABLE_DEPRECATED_TESTS -long bcast_psync[SHMEM_BCAST_SYNC_SIZE]; - -/* Note: Need to alternate psync arrays because the active set changes */ -long barrier_psync0[SHMEM_BARRIER_SYNC_SIZE]; -long barrier_psync1[SHMEM_BARRIER_SYNC_SIZE]; -#endif - -int64_t src[NELEM]; -int64_t dst[NELEM]; - -/* Validate broadcasted data */ -static int validate_data(int i) { - int errors = 0; - int j; - for (j = 0; j < NELEM; j++) { -#ifdef ENABLE_DEPRECATED_TESTS - int64_t expected = (shmem_my_pe() == i) ? i-1 : i; -#else - int64_t expected = i; -#endif - if (dst[j] != expected) { - printf("%d: Expected dst[%d] = %"PRId64", got dst[%d] = %"PRId64", iteration %d\n", - shmem_my_pe(), j, expected, j, dst[j], i); - errors++; - } - } - return errors; -} - -int main(void) -{ - int i, me, npes; - int errors = 0; - - shmem_init(); - - me = shmem_my_pe(); - npes = shmem_n_pes(); - - for (i = 0; i < NELEM; i++) { - src[i] = me; - dst[i] = -1; - } - -#ifdef ENABLE_DEPRECATED_TESTS - for (i = 0; i < SHMEM_BCAST_SYNC_SIZE; i++) - bcast_psync[i] = SHMEM_SYNC_VALUE; - - for (i = 0; i < SHMEM_BARRIER_SYNC_SIZE; i++) { - barrier_psync0[i] = SHMEM_SYNC_VALUE; - barrier_psync1[i] = SHMEM_SYNC_VALUE; - } -#endif - - if (me == 0) - printf("Shrinking active set test\n"); - - shmem_barrier_all(); - - /* A total of npes tests are performed, where the active set in each test - * includes PEs i..npes-1 */ -#ifdef ENABLE_DEPRECATED_TESTS - for (i = 0; i <= me; i++) { - - if (me == i) { - printf("+ active set size %d\n", npes-i); - } - - shmem_broadcast64(dst, src, NELEM, 0, i, 0, npes-i, bcast_psync); - - errors += validate_data(i); - shmem_barrier(i, 0, npes-i, (i % 2) ? barrier_psync0 : barrier_psync1); - } -#else - shmem_team_t new_team; - for (i = 0; i < npes; i++) { - - if (me == i) { - printf(" + active set size %d\n", npes-i); - } - - shmem_team_split_strided(SHMEM_TEAM_WORLD, i, 1, npes-i, NULL, 0, &new_team); - if (new_team != SHMEM_TEAM_INVALID) { - shmem_int64_broadcast(new_team, dst, src, NELEM, 0); - - errors += validate_data(i); - } - - shmem_barrier_all(); - - } -#endif - - shmem_barrier_all(); - - for (i = 0; i < NELEM; i++) - dst[i] = -1; - - if (me == 0) - printf("Changing root test\n"); - - shmem_barrier_all(); - - /* A total of npes tests are performed, where the root changes each time */ - for (i = 0; i < npes; i++) { - - if (me == i) - printf(" + root %d\n", i); - -#ifdef ENABLE_DEPRECATED_TESTS - shmem_broadcast64(dst, src, NELEM, i, 0, 0, npes, bcast_psync); -#else - shmem_int64_broadcast(SHMEM_TEAM_WORLD, dst, src, NELEM, i); -#endif - - errors += validate_data(i); - - shmem_barrier_all(); - } - shmem_finalize(); - - return errors != 0; -} diff --git a/test/unit/c11_shmem_team_collective_types.c b/test/unit/c11_shmem_team_collective_types.c deleted file mode 100644 index 7c50584f4..000000000 --- a/test/unit/c11_shmem_team_collective_types.c +++ /dev/null @@ -1,281 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2019 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include - -#define MAX_NPES 32 - -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L - -enum op { BCAST = 0, COLLECT, FCOLLECT, ALLTOALL, ALLTOALLS }; - -#define TEST_SHMEM_COLLECTIVE(OP, TYPE) \ - do { \ - static TYPE src[MAX_NPES]; \ - static TYPE dest[MAX_NPES*MAX_NPES]; \ - \ - for (int i = 0; i < MAX_NPES; i++) { \ - src[i] = (TYPE)mype; \ - } \ - \ - switch (OP) { \ - case BCAST: \ - shmem_broadcast(SHMEM_TEAM_WORLD, dest, src, MAX_NPES, npes-1); \ - break; \ - case COLLECT: \ - shmem_collect(SHMEM_TEAM_WORLD, dest, src, MAX_NPES); \ - break; \ - case FCOLLECT: \ - shmem_fcollect(SHMEM_TEAM_WORLD, dest, src, MAX_NPES); \ - break; \ - case ALLTOALL: \ - shmem_alltoall(SHMEM_TEAM_WORLD, dest, src, 1); \ - break; \ - case ALLTOALLS: \ - shmem_alltoalls(SHMEM_TEAM_WORLD, dest, src, 1, 1, 1); \ - break; \ - default: \ - printf("Invalid operation (%d)\n", OP); \ - shmem_global_exit(1); \ - } \ - shmem_barrier_all(); \ - \ - switch (OP) { \ - case BCAST: \ - if (mype != npes-1) { \ - for (int i = 0; i < MAX_NPES; i++) { \ - if (dest[i] != (TYPE)npes-1) { \ - printf("PE %i received incorrect value with " \ - "TEST_SHMEM_COLLECTIVE(%s, %s)\n", mype, \ - #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } \ - break; \ - case COLLECT: \ - for (int i = 0; i < MAX_NPES*npes; i++) { \ - if (dest[i] != (TYPE)(i / MAX_NPES)) { \ - printf("PE %i received incorrect value with " \ - "TEST_SHMEM_COLLECTIVE(%s, %s)\n", mype, \ - #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } \ - break; \ - case FCOLLECT: \ - for (int i = 0; i < MAX_NPES*npes; i++) { \ - if (dest[i] != (TYPE)(i / MAX_NPES)) { \ - printf("PE %i received incorrect value with " \ - "TEST_SHMEM_COLLECTIVE(%s, %s)\n", mype, \ - #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } \ - break; \ - case ALLTOALL: \ - for (int i = 0; i < npes; i++) { \ - if (dest[i] != (TYPE)i) { \ - printf("PE %i received incorrect value with " \ - "TEST_SHMEM_COLLECTIVE(%s, %s)\n", mype, \ - #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } \ - break; \ - case ALLTOALLS: \ - for (int i = 0; i < npes; i++) { \ - if (dest[i] != (TYPE)i) { \ - printf("PE %i received incorrect value with " \ - "TEST_SHMEM_COLLECTIVE(%s, %s)\n", mype, \ - #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } \ - break; \ - default: \ - printf("Invalid operation (%d)\n", OP); \ - shmem_global_exit(1); \ - } \ - } \ - } while (0) - -#else -#define TEST_SHMEM_COLLECTIVE(OP, TYPE) - -#endif - -int main(void) { - shmem_init(); - - int rc = EXIT_SUCCESS; - - const int mype = shmem_my_pe(); - const int npes = shmem_n_pes(); - - if (npes > MAX_NPES) { - if (mype == 0) - fprintf(stderr, "ERR - Requires at least %d PEs\n", MAX_NPES); - shmem_finalize(); - return 0; - } - - TEST_SHMEM_COLLECTIVE(BCAST, float); - TEST_SHMEM_COLLECTIVE(BCAST, double); - TEST_SHMEM_COLLECTIVE(BCAST, long double); - TEST_SHMEM_COLLECTIVE(BCAST, char); - TEST_SHMEM_COLLECTIVE(BCAST, signed char); - TEST_SHMEM_COLLECTIVE(BCAST, short); - TEST_SHMEM_COLLECTIVE(BCAST, int); - TEST_SHMEM_COLLECTIVE(BCAST, long); - TEST_SHMEM_COLLECTIVE(BCAST, long long); - TEST_SHMEM_COLLECTIVE(BCAST, unsigned char); - TEST_SHMEM_COLLECTIVE(BCAST, unsigned short); - TEST_SHMEM_COLLECTIVE(BCAST, unsigned int); - TEST_SHMEM_COLLECTIVE(BCAST, unsigned long); - TEST_SHMEM_COLLECTIVE(BCAST, unsigned long long); - TEST_SHMEM_COLLECTIVE(BCAST, int8_t); - TEST_SHMEM_COLLECTIVE(BCAST, int16_t); - TEST_SHMEM_COLLECTIVE(BCAST, int32_t); - TEST_SHMEM_COLLECTIVE(BCAST, int64_t); - TEST_SHMEM_COLLECTIVE(BCAST, uint8_t); - TEST_SHMEM_COLLECTIVE(BCAST, uint16_t); - TEST_SHMEM_COLLECTIVE(BCAST, uint32_t); - TEST_SHMEM_COLLECTIVE(BCAST, uint64_t); - TEST_SHMEM_COLLECTIVE(BCAST, size_t); - TEST_SHMEM_COLLECTIVE(BCAST, ptrdiff_t); - - TEST_SHMEM_COLLECTIVE(COLLECT, float); - TEST_SHMEM_COLLECTIVE(COLLECT, double); - TEST_SHMEM_COLLECTIVE(COLLECT, long double); - TEST_SHMEM_COLLECTIVE(COLLECT, char); - TEST_SHMEM_COLLECTIVE(COLLECT, signed char); - TEST_SHMEM_COLLECTIVE(COLLECT, short); - TEST_SHMEM_COLLECTIVE(COLLECT, int); - TEST_SHMEM_COLLECTIVE(COLLECT, long); - TEST_SHMEM_COLLECTIVE(COLLECT, long long); - TEST_SHMEM_COLLECTIVE(COLLECT, unsigned char); - TEST_SHMEM_COLLECTIVE(COLLECT, unsigned short); - TEST_SHMEM_COLLECTIVE(COLLECT, unsigned int); - TEST_SHMEM_COLLECTIVE(COLLECT, unsigned long); - TEST_SHMEM_COLLECTIVE(COLLECT, unsigned long long); - TEST_SHMEM_COLLECTIVE(COLLECT, int8_t); - TEST_SHMEM_COLLECTIVE(COLLECT, int16_t); - TEST_SHMEM_COLLECTIVE(COLLECT, int32_t); - TEST_SHMEM_COLLECTIVE(COLLECT, int64_t); - TEST_SHMEM_COLLECTIVE(COLLECT, uint8_t); - TEST_SHMEM_COLLECTIVE(COLLECT, uint16_t); - TEST_SHMEM_COLLECTIVE(COLLECT, uint32_t); - TEST_SHMEM_COLLECTIVE(COLLECT, uint64_t); - TEST_SHMEM_COLLECTIVE(COLLECT, size_t); - TEST_SHMEM_COLLECTIVE(COLLECT, ptrdiff_t); - - TEST_SHMEM_COLLECTIVE(FCOLLECT, float); - TEST_SHMEM_COLLECTIVE(FCOLLECT, double); - TEST_SHMEM_COLLECTIVE(FCOLLECT, long double); - TEST_SHMEM_COLLECTIVE(FCOLLECT, char); - TEST_SHMEM_COLLECTIVE(FCOLLECT, signed char); - TEST_SHMEM_COLLECTIVE(FCOLLECT, short); - TEST_SHMEM_COLLECTIVE(FCOLLECT, int); - TEST_SHMEM_COLLECTIVE(FCOLLECT, long); - TEST_SHMEM_COLLECTIVE(FCOLLECT, long long); - TEST_SHMEM_COLLECTIVE(FCOLLECT, unsigned char); - TEST_SHMEM_COLLECTIVE(FCOLLECT, unsigned short); - TEST_SHMEM_COLLECTIVE(FCOLLECT, unsigned int); - TEST_SHMEM_COLLECTIVE(FCOLLECT, unsigned long); - TEST_SHMEM_COLLECTIVE(FCOLLECT, unsigned long long); - TEST_SHMEM_COLLECTIVE(FCOLLECT, int8_t); - TEST_SHMEM_COLLECTIVE(FCOLLECT, int16_t); - TEST_SHMEM_COLLECTIVE(FCOLLECT, int32_t); - TEST_SHMEM_COLLECTIVE(FCOLLECT, int64_t); - TEST_SHMEM_COLLECTIVE(FCOLLECT, uint8_t); - TEST_SHMEM_COLLECTIVE(FCOLLECT, uint16_t); - TEST_SHMEM_COLLECTIVE(FCOLLECT, uint32_t); - TEST_SHMEM_COLLECTIVE(FCOLLECT, uint64_t); - TEST_SHMEM_COLLECTIVE(FCOLLECT, size_t); - TEST_SHMEM_COLLECTIVE(FCOLLECT, ptrdiff_t); - - TEST_SHMEM_COLLECTIVE(ALLTOALL, float); - TEST_SHMEM_COLLECTIVE(ALLTOALL, double); - TEST_SHMEM_COLLECTIVE(ALLTOALL, long double); - TEST_SHMEM_COLLECTIVE(ALLTOALL, char); - TEST_SHMEM_COLLECTIVE(ALLTOALL, signed char); - TEST_SHMEM_COLLECTIVE(ALLTOALL, short); - TEST_SHMEM_COLLECTIVE(ALLTOALL, int); - TEST_SHMEM_COLLECTIVE(ALLTOALL, long); - TEST_SHMEM_COLLECTIVE(ALLTOALL, long long); - TEST_SHMEM_COLLECTIVE(ALLTOALL, unsigned char); - TEST_SHMEM_COLLECTIVE(ALLTOALL, unsigned short); - TEST_SHMEM_COLLECTIVE(ALLTOALL, unsigned int); - TEST_SHMEM_COLLECTIVE(ALLTOALL, unsigned long); - TEST_SHMEM_COLLECTIVE(ALLTOALL, unsigned long long); - TEST_SHMEM_COLLECTIVE(ALLTOALL, int8_t); - TEST_SHMEM_COLLECTIVE(ALLTOALL, int16_t); - TEST_SHMEM_COLLECTIVE(ALLTOALL, int32_t); - TEST_SHMEM_COLLECTIVE(ALLTOALL, int64_t); - TEST_SHMEM_COLLECTIVE(ALLTOALL, uint8_t); - TEST_SHMEM_COLLECTIVE(ALLTOALL, uint16_t); - TEST_SHMEM_COLLECTIVE(ALLTOALL, uint32_t); - TEST_SHMEM_COLLECTIVE(ALLTOALL, uint64_t); - TEST_SHMEM_COLLECTIVE(ALLTOALL, size_t); - TEST_SHMEM_COLLECTIVE(ALLTOALL, ptrdiff_t); - - TEST_SHMEM_COLLECTIVE(ALLTOALLS, float); - TEST_SHMEM_COLLECTIVE(ALLTOALLS, double); - TEST_SHMEM_COLLECTIVE(ALLTOALLS, long double); - TEST_SHMEM_COLLECTIVE(ALLTOALLS, char); - TEST_SHMEM_COLLECTIVE(ALLTOALLS, signed char); - TEST_SHMEM_COLLECTIVE(ALLTOALLS, short); - TEST_SHMEM_COLLECTIVE(ALLTOALLS, int); - TEST_SHMEM_COLLECTIVE(ALLTOALLS, long); - TEST_SHMEM_COLLECTIVE(ALLTOALLS, long long); - TEST_SHMEM_COLLECTIVE(ALLTOALLS, unsigned char); - TEST_SHMEM_COLLECTIVE(ALLTOALLS, unsigned short); - TEST_SHMEM_COLLECTIVE(ALLTOALLS, unsigned int); - TEST_SHMEM_COLLECTIVE(ALLTOALLS, unsigned long); - TEST_SHMEM_COLLECTIVE(ALLTOALLS, unsigned long long); - TEST_SHMEM_COLLECTIVE(ALLTOALLS, int8_t); - TEST_SHMEM_COLLECTIVE(ALLTOALLS, int16_t); - TEST_SHMEM_COLLECTIVE(ALLTOALLS, int32_t); - TEST_SHMEM_COLLECTIVE(ALLTOALLS, int64_t); - TEST_SHMEM_COLLECTIVE(ALLTOALLS, uint8_t); - TEST_SHMEM_COLLECTIVE(ALLTOALLS, uint16_t); - TEST_SHMEM_COLLECTIVE(ALLTOALLS, uint32_t); - TEST_SHMEM_COLLECTIVE(ALLTOALLS, uint64_t); - TEST_SHMEM_COLLECTIVE(ALLTOALLS, size_t); - TEST_SHMEM_COLLECTIVE(ALLTOALLS, ptrdiff_t); - - shmem_finalize(); - return rc; -} diff --git a/test/unit/c11_shmem_team_reduce.c b/test/unit/c11_shmem_team_reduce.c deleted file mode 100644 index a00d6b3b7..000000000 --- a/test/unit/c11_shmem_team_reduce.c +++ /dev/null @@ -1,325 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2019 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include -#include -#include - -#define MAX_NPES 32 - -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L - -enum op { and = 0, or, xor, max, min, sum, prod }; - -const double FLOATING_POINT_TOLERANCE = 1e-6; - -#define REDUCTION(OP) \ - do { ret = shmem_##OP##_reduce(SHMEM_TEAM_WORLD, dest, src, npes); } while (0) - -#define is_floating_point(X) _Generic((X), \ - float: true, \ - double: true, \ - long double: true, \ - float _Complex: true, \ - double _Complex: true, \ - default: false \ -) - -#define INIT_SRC_BUFFER(TYPE) \ - do { \ - for (int i = 0; i < MAX_NPES; i++) { \ - src[i] = (TYPE)1ULL; \ - } \ - } while (0) - -#define CHECK_DEST_BUFFER(OP, TYPE, CORRECT_VAL) \ - do { \ - for (int i = 0; i < npes; i++) { \ - if (dest[i] != (TYPE)CORRECT_VAL) { \ - printf("PE %i received incorrect value with " \ - "TEST_SHMEM_REDUCE(%s, %s)\n", mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } \ - } while (0) - -#define CHECK_DEST_BUFFER_FP(OP, TYPE, CORRECT_VAL, TOLERANCE) \ - do { \ - for (int i = 0; i < npes; i++) { \ - if (fabsl(creal(dest[i]) - creal((TYPE)CORRECT_VAL)) > TOLERANCE) { \ - printf("PE %i received incorrect real value with " \ - "TEST_SHMEM_REDUCE(%s, %s)\n", mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - if (fabsl(cimag(dest[i]) - cimag((TYPE)CORRECT_VAL)) > TOLERANCE) { \ - printf("PE %i received incorrect imaginary value with " \ - "TEST_SHMEM_REDUCE(%s, %s)\n", mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } \ - } while (0) - -#define TEST_SHMEM_REDUCE(OP, TYPE) \ - do { \ - static TYPE src[MAX_NPES]; \ - static TYPE dest[MAX_NPES]; \ - int ret; \ - const bool floating_point_val = is_floating_point((TYPE)0); \ - \ - INIT_SRC_BUFFER(TYPE); \ - \ - REDUCTION(OP); \ - \ - if (ret != 0) { \ - printf("Reduction returned non-zero value (%i) on PE (%i) with " \ - "TEST_SHMEM_REDUCE(%s, %s)\n", ret, mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - \ - shmem_barrier_all(); \ - \ - switch (OP) { \ - case and: \ - CHECK_DEST_BUFFER(OP, TYPE, 1ULL); \ - break; \ - case or: \ - CHECK_DEST_BUFFER(OP, TYPE, 1ULL); \ - break; \ - case xor: \ - CHECK_DEST_BUFFER(OP, TYPE, (TYPE)(npes % 2 ? 1ULL : 0ULL)); \ - break; \ - case max: \ - if (floating_point_val) \ - CHECK_DEST_BUFFER_FP(OP, TYPE, 1ULL, FLOATING_POINT_TOLERANCE); \ - else \ - CHECK_DEST_BUFFER(OP, TYPE, 1ULL); \ - break; \ - case min: \ - if (floating_point_val) \ - CHECK_DEST_BUFFER_FP(OP, TYPE, 1ULL, FLOATING_POINT_TOLERANCE); \ - else \ - CHECK_DEST_BUFFER(OP, TYPE, 1ULL); \ - break; \ - case sum: \ - if (floating_point_val) \ - CHECK_DEST_BUFFER_FP(OP, TYPE, npes, FLOATING_POINT_TOLERANCE); \ - else \ - CHECK_DEST_BUFFER(OP, TYPE, npes); \ - break; \ - case prod: \ - if (floating_point_val) \ - CHECK_DEST_BUFFER_FP(OP, TYPE, 1ULL, FLOATING_POINT_TOLERANCE); \ - else \ - CHECK_DEST_BUFFER(OP, TYPE, 1ULL); \ - break; \ - default: \ - printf("Invalid operation (%d)\n", OP); \ - shmem_global_exit(1); \ - } \ - } while (0) - -#else -#define TEST_SHMEM_REDUCE(OP, TYPE) -#endif - - -int main(void) { - - shmem_init(); - - int rc = EXIT_SUCCESS; - - const int mype = shmem_my_pe(); - const int npes = shmem_n_pes(); - - if (npes > MAX_NPES) { - if (mype == 0) - fprintf(stderr, "ERR - Requires less than %d PEs\n", MAX_NPES); - shmem_global_exit(1); - } - - TEST_SHMEM_REDUCE(and, unsigned char); - TEST_SHMEM_REDUCE(and, unsigned short); - TEST_SHMEM_REDUCE(and, unsigned int); - TEST_SHMEM_REDUCE(and, unsigned long); - TEST_SHMEM_REDUCE(and, unsigned long long); - TEST_SHMEM_REDUCE(and, int8_t); - TEST_SHMEM_REDUCE(and, int16_t); - TEST_SHMEM_REDUCE(and, int32_t); - TEST_SHMEM_REDUCE(and, int64_t); - TEST_SHMEM_REDUCE(and, uint8_t); - TEST_SHMEM_REDUCE(and, uint16_t); - TEST_SHMEM_REDUCE(and, uint32_t); - TEST_SHMEM_REDUCE(and, uint64_t); - TEST_SHMEM_REDUCE(and, size_t); - - TEST_SHMEM_REDUCE(or, unsigned char); - TEST_SHMEM_REDUCE(or, unsigned short); - TEST_SHMEM_REDUCE(or, unsigned int); - TEST_SHMEM_REDUCE(or, unsigned long); - TEST_SHMEM_REDUCE(or, unsigned long long); - TEST_SHMEM_REDUCE(or, int8_t); - TEST_SHMEM_REDUCE(or, int16_t); - TEST_SHMEM_REDUCE(or, int32_t); - TEST_SHMEM_REDUCE(or, int64_t); - TEST_SHMEM_REDUCE(or, uint8_t); - TEST_SHMEM_REDUCE(or, uint16_t); - TEST_SHMEM_REDUCE(or, uint32_t); - TEST_SHMEM_REDUCE(or, uint64_t); - TEST_SHMEM_REDUCE(or, size_t); - - TEST_SHMEM_REDUCE(xor, unsigned char); - TEST_SHMEM_REDUCE(xor, unsigned short); - TEST_SHMEM_REDUCE(xor, unsigned int); - TEST_SHMEM_REDUCE(xor, unsigned long); - TEST_SHMEM_REDUCE(xor, unsigned long long); - TEST_SHMEM_REDUCE(xor, int8_t); - TEST_SHMEM_REDUCE(xor, int16_t); - TEST_SHMEM_REDUCE(xor, int32_t); - TEST_SHMEM_REDUCE(xor, int64_t); - TEST_SHMEM_REDUCE(xor, uint8_t); - TEST_SHMEM_REDUCE(xor, uint16_t); - TEST_SHMEM_REDUCE(xor, uint32_t); - TEST_SHMEM_REDUCE(xor, uint64_t); - TEST_SHMEM_REDUCE(xor, size_t); - - TEST_SHMEM_REDUCE(max, char); - TEST_SHMEM_REDUCE(max, signed char); - TEST_SHMEM_REDUCE(max, short); - TEST_SHMEM_REDUCE(max, int); - TEST_SHMEM_REDUCE(max, long); - TEST_SHMEM_REDUCE(max, long long); - TEST_SHMEM_REDUCE(max, ptrdiff_t); - TEST_SHMEM_REDUCE(max, unsigned char); - TEST_SHMEM_REDUCE(max, unsigned short); - TEST_SHMEM_REDUCE(max, unsigned int); - TEST_SHMEM_REDUCE(max, unsigned long); - TEST_SHMEM_REDUCE(max, unsigned long long); - TEST_SHMEM_REDUCE(max, int8_t); - TEST_SHMEM_REDUCE(max, int16_t); - TEST_SHMEM_REDUCE(max, int32_t); - TEST_SHMEM_REDUCE(max, int64_t); - TEST_SHMEM_REDUCE(max, uint8_t); - TEST_SHMEM_REDUCE(max, uint16_t); - TEST_SHMEM_REDUCE(max, uint32_t); - TEST_SHMEM_REDUCE(max, uint64_t); - TEST_SHMEM_REDUCE(max, size_t); - TEST_SHMEM_REDUCE(max, float); - TEST_SHMEM_REDUCE(max, double); - TEST_SHMEM_REDUCE(max, long double); - - TEST_SHMEM_REDUCE(min, char); - TEST_SHMEM_REDUCE(min, signed char); - TEST_SHMEM_REDUCE(min, short); - TEST_SHMEM_REDUCE(min, int); - TEST_SHMEM_REDUCE(min, long); - TEST_SHMEM_REDUCE(min, long long); - TEST_SHMEM_REDUCE(min, ptrdiff_t); - TEST_SHMEM_REDUCE(min, unsigned char); - TEST_SHMEM_REDUCE(min, unsigned short); - TEST_SHMEM_REDUCE(min, unsigned int); - TEST_SHMEM_REDUCE(min, unsigned long); - TEST_SHMEM_REDUCE(min, unsigned long long); - TEST_SHMEM_REDUCE(min, int8_t); - TEST_SHMEM_REDUCE(min, int16_t); - TEST_SHMEM_REDUCE(min, int32_t); - TEST_SHMEM_REDUCE(min, int64_t); - TEST_SHMEM_REDUCE(min, uint8_t); - TEST_SHMEM_REDUCE(min, uint16_t); - TEST_SHMEM_REDUCE(min, uint32_t); - TEST_SHMEM_REDUCE(min, uint64_t); - TEST_SHMEM_REDUCE(min, size_t); - TEST_SHMEM_REDUCE(min, float); - TEST_SHMEM_REDUCE(min, double); - TEST_SHMEM_REDUCE(min, long double); - - TEST_SHMEM_REDUCE(sum, char); - TEST_SHMEM_REDUCE(sum, signed char); - TEST_SHMEM_REDUCE(sum, short); - TEST_SHMEM_REDUCE(sum, int); - TEST_SHMEM_REDUCE(sum, long); - TEST_SHMEM_REDUCE(sum, long long); - TEST_SHMEM_REDUCE(sum, ptrdiff_t); - TEST_SHMEM_REDUCE(sum, unsigned char); - TEST_SHMEM_REDUCE(sum, unsigned short); - TEST_SHMEM_REDUCE(sum, unsigned int); - TEST_SHMEM_REDUCE(sum, unsigned long); - TEST_SHMEM_REDUCE(sum, unsigned long long); - TEST_SHMEM_REDUCE(sum, int8_t); - TEST_SHMEM_REDUCE(sum, int16_t); - TEST_SHMEM_REDUCE(sum, int32_t); - TEST_SHMEM_REDUCE(sum, int64_t); - TEST_SHMEM_REDUCE(sum, uint8_t); - TEST_SHMEM_REDUCE(sum, uint16_t); - TEST_SHMEM_REDUCE(sum, uint32_t); - TEST_SHMEM_REDUCE(sum, uint64_t); - TEST_SHMEM_REDUCE(sum, size_t); - TEST_SHMEM_REDUCE(sum, float); - TEST_SHMEM_REDUCE(sum, double); - TEST_SHMEM_REDUCE(sum, long double); - TEST_SHMEM_REDUCE(sum, double _Complex); - TEST_SHMEM_REDUCE(sum, float _Complex); - - TEST_SHMEM_REDUCE(prod, char); - TEST_SHMEM_REDUCE(prod, signed char); - TEST_SHMEM_REDUCE(prod, short); - TEST_SHMEM_REDUCE(prod, int); - TEST_SHMEM_REDUCE(prod, long); - TEST_SHMEM_REDUCE(prod, long long); - TEST_SHMEM_REDUCE(prod, ptrdiff_t); - TEST_SHMEM_REDUCE(prod, unsigned char); - TEST_SHMEM_REDUCE(prod, unsigned short); - TEST_SHMEM_REDUCE(prod, unsigned int); - TEST_SHMEM_REDUCE(prod, unsigned long); - TEST_SHMEM_REDUCE(prod, unsigned long long); - TEST_SHMEM_REDUCE(prod, int8_t); - TEST_SHMEM_REDUCE(prod, int16_t); - TEST_SHMEM_REDUCE(prod, int32_t); - TEST_SHMEM_REDUCE(prod, int64_t); - TEST_SHMEM_REDUCE(prod, uint8_t); - TEST_SHMEM_REDUCE(prod, uint16_t); - TEST_SHMEM_REDUCE(prod, uint32_t); - TEST_SHMEM_REDUCE(prod, uint64_t); - TEST_SHMEM_REDUCE(prod, size_t); - TEST_SHMEM_REDUCE(prod, float); - TEST_SHMEM_REDUCE(prod, double); - TEST_SHMEM_REDUCE(prod, long double); - TEST_SHMEM_REDUCE(prod, double _Complex); - TEST_SHMEM_REDUCE(prod, float _Complex); - - shmem_finalize(); - return rc; -} diff --git a/test/unit/c11_shmem_test_all_any_some.c b/test/unit/c11_shmem_test_all_any_some.c deleted file mode 100644 index 5a6899545..000000000 --- a/test/unit/c11_shmem_test_all_any_some.c +++ /dev/null @@ -1,143 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include - -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L - -#define TEST_SHMEM_TEST_ALL(TYPE) \ - do { \ - static TYPE remote = 0; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - int status = 0; \ - shmem_p(&remote, (TYPE)mype+1, (mype + 1) % npes); \ - while (!shmem_test_all(&remote, 1, &status, SHMEM_CMP_NE, 0)) ; \ - if (remote != (TYPE)((mype + npes - 1) % npes)+1) { \ - printf("PE %i received incorrect value with " \ - "TEST_SHMEM_TEST_ALL(%s)\n", mype, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (0) - -#define TEST_SHMEM_TEST_ANY(TYPE) \ - do { \ - static TYPE remote = 0; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - int status = 0; \ - shmem_p(&remote, (TYPE)mype+1, (mype + 1) % npes); \ - while (shmem_test_any(&remote, 1, &status, SHMEM_CMP_NE, 0) == SIZE_MAX); \ - if (remote != (TYPE)((mype + npes - 1) % npes)+1) { \ - printf("PE %i received incorrect value with " \ - "TEST_SHMEM_TEST_ANY(%s)\n", mype, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (0) - -#define TEST_SHMEM_TEST_SOME(TYPE) \ - do { \ - static TYPE remote = 0; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - int status = 0; \ - size_t indices; \ - shmem_p(&remote, (TYPE)mype+1, (mype + 1) % npes); \ - while (!shmem_test_some(&remote, 1, &indices, &status, SHMEM_CMP_NE, 0)); \ - if (remote != (TYPE)((mype + npes - 1) % npes)+1) { \ - printf("PE %i received incorrect value with " \ - "TEST_SHMEM_TEST_SOME(%s)\n", mype, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (0) - -#else -#define TEST_SHMEM_TEST_ALL(TYPE) -#define TEST_SHMEM_TEST_ANY(TYPE) -#define TEST_SHMEM_TEST_SOME(TYPE) - -#endif - -int main(int argc, char* argv[]) { - shmem_init(); - - int rc = EXIT_SUCCESS; - TEST_SHMEM_TEST_ALL(short); - TEST_SHMEM_TEST_ALL(int); - TEST_SHMEM_TEST_ALL(long); - TEST_SHMEM_TEST_ALL(long long); - TEST_SHMEM_TEST_ALL(unsigned short); - TEST_SHMEM_TEST_ALL(unsigned int); - TEST_SHMEM_TEST_ALL(unsigned long); - TEST_SHMEM_TEST_ALL(unsigned long long); - TEST_SHMEM_TEST_ALL(int32_t); - TEST_SHMEM_TEST_ALL(int64_t); - TEST_SHMEM_TEST_ALL(uint32_t); - TEST_SHMEM_TEST_ALL(uint64_t); - TEST_SHMEM_TEST_ALL(size_t); - TEST_SHMEM_TEST_ALL(ptrdiff_t); - - TEST_SHMEM_TEST_ANY(short); - TEST_SHMEM_TEST_ANY(int); - TEST_SHMEM_TEST_ANY(long); - TEST_SHMEM_TEST_ANY(long long); - TEST_SHMEM_TEST_ANY(unsigned short); - TEST_SHMEM_TEST_ANY(unsigned int); - TEST_SHMEM_TEST_ANY(unsigned long); - TEST_SHMEM_TEST_ANY(unsigned long long); - TEST_SHMEM_TEST_ANY(int32_t); - TEST_SHMEM_TEST_ANY(int64_t); - TEST_SHMEM_TEST_ANY(uint32_t); - TEST_SHMEM_TEST_ANY(uint64_t); - TEST_SHMEM_TEST_ANY(size_t); - TEST_SHMEM_TEST_ANY(ptrdiff_t); - - TEST_SHMEM_TEST_SOME(short); - TEST_SHMEM_TEST_SOME(int); - TEST_SHMEM_TEST_SOME(long); - TEST_SHMEM_TEST_SOME(long long); - TEST_SHMEM_TEST_SOME(unsigned short); - TEST_SHMEM_TEST_SOME(unsigned int); - TEST_SHMEM_TEST_SOME(unsigned long); - TEST_SHMEM_TEST_SOME(unsigned long long); - TEST_SHMEM_TEST_SOME(int32_t); - TEST_SHMEM_TEST_SOME(int64_t); - TEST_SHMEM_TEST_SOME(uint32_t); - TEST_SHMEM_TEST_SOME(uint64_t); - TEST_SHMEM_TEST_SOME(size_t); - TEST_SHMEM_TEST_SOME(ptrdiff_t); - shmem_finalize(); - return rc; -} diff --git a/test/unit/c11_shmem_test_vector.c b/test/unit/c11_shmem_test_vector.c deleted file mode 100644 index ad6fe3cc2..000000000 --- a/test/unit/c11_shmem_test_vector.c +++ /dev/null @@ -1,172 +0,0 @@ -#include -#include -#include - -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L - -#define TEST_SHMEM_TEST_ALL(TYPE) \ - do { \ - \ - const int my_pe = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - TYPE *ivars = shmem_calloc(npes, sizeof(TYPE)); \ - int *status = calloc(npes, sizeof(int)); \ - TYPE *cmp_values = malloc(npes * sizeof(TYPE)); \ - \ - int i = 0; \ - int expected_sum = 0; \ - int total_sum = 0; \ - \ - for(i = 0; i -#include -#include -#include - -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L - -#define TEST_SHMEM_WAIT_UNTIL_ALL(TYPE) \ - do { \ - static TYPE remote = 0; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - int status = 0; \ - shmem_p(&remote, (TYPE)mype+1, (mype + 1) % npes); \ - shmem_wait_until_all(&remote, 1, &status, SHMEM_CMP_NE, 0); \ - if (remote != (TYPE)((mype + npes - 1) % npes)+1) { \ - printf("PE %i received incorrect value with " \ - "TEST_SHMEM_WAIT_UNTIL_ALL(%s)\n", mype, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (0) - -#define TEST_SHMEM_WAIT_UNTIL_ANY(TYPE) \ - do { \ - static TYPE remote = 0; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - int status = 0; \ - shmem_p(&remote, (TYPE)mype+1, (mype + 1) % npes); \ - shmem_wait_until_any(&remote, 1, &status, SHMEM_CMP_NE, 0); \ - if (remote != (TYPE)((mype + npes - 1) % npes)+1) { \ - printf("PE %i received incorrect value with " \ - "TEST_SHMEM_WAIT_UNTIL_ANY(%s)\n", mype, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (0) - -#define TEST_SHMEM_WAIT_UNTIL_SOME(TYPE) \ - do { \ - static TYPE remote = 0; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - int status = 0; \ - size_t indices; \ - shmem_p(&remote, (TYPE)mype+1, (mype + 1) % npes); \ - shmem_wait_until_some(&remote, 1, &indices, &status, SHMEM_CMP_NE, 0); \ - if (remote != (TYPE)((mype + npes - 1) % npes)+1) { \ - printf("PE %i received incorrect value with " \ - "TEST_SHMEM_WAIT_UNTIL_SOME(%s)\n", mype, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (0) - -#else -#define TEST_SHMEM_WAIT_UNTIL_ALL(TYPE) -#define TEST_SHMEM_WAIT_UNTIL_ANY(TYPE) -#define TEST_SHMEM_WAIT_UNTIL_SOME(TYPE) - -#endif - -int main(int argc, char* argv[]) { - shmem_init(); - - int rc = EXIT_SUCCESS; - TEST_SHMEM_WAIT_UNTIL_ALL(short); - TEST_SHMEM_WAIT_UNTIL_ALL(int); - TEST_SHMEM_WAIT_UNTIL_ALL(long); - TEST_SHMEM_WAIT_UNTIL_ALL(long long); - TEST_SHMEM_WAIT_UNTIL_ALL(unsigned short); - TEST_SHMEM_WAIT_UNTIL_ALL(unsigned int); - TEST_SHMEM_WAIT_UNTIL_ALL(unsigned long); - TEST_SHMEM_WAIT_UNTIL_ALL(unsigned long long); - TEST_SHMEM_WAIT_UNTIL_ALL(int32_t); - TEST_SHMEM_WAIT_UNTIL_ALL(int64_t); - TEST_SHMEM_WAIT_UNTIL_ALL(uint32_t); - TEST_SHMEM_WAIT_UNTIL_ALL(uint64_t); - TEST_SHMEM_WAIT_UNTIL_ALL(size_t); - TEST_SHMEM_WAIT_UNTIL_ALL(ptrdiff_t); - - TEST_SHMEM_WAIT_UNTIL_ANY(short); - TEST_SHMEM_WAIT_UNTIL_ANY(int); - TEST_SHMEM_WAIT_UNTIL_ANY(long); - TEST_SHMEM_WAIT_UNTIL_ANY(long long); - TEST_SHMEM_WAIT_UNTIL_ANY(unsigned short); - TEST_SHMEM_WAIT_UNTIL_ANY(unsigned int); - TEST_SHMEM_WAIT_UNTIL_ANY(unsigned long); - TEST_SHMEM_WAIT_UNTIL_ANY(unsigned long long); - TEST_SHMEM_WAIT_UNTIL_ANY(int32_t); - TEST_SHMEM_WAIT_UNTIL_ANY(int64_t); - TEST_SHMEM_WAIT_UNTIL_ANY(uint32_t); - TEST_SHMEM_WAIT_UNTIL_ANY(uint64_t); - TEST_SHMEM_WAIT_UNTIL_ANY(size_t); - TEST_SHMEM_WAIT_UNTIL_ANY(ptrdiff_t); - - TEST_SHMEM_WAIT_UNTIL_SOME(short); - TEST_SHMEM_WAIT_UNTIL_SOME(int); - TEST_SHMEM_WAIT_UNTIL_SOME(long); - TEST_SHMEM_WAIT_UNTIL_SOME(long long); - TEST_SHMEM_WAIT_UNTIL_SOME(unsigned short); - TEST_SHMEM_WAIT_UNTIL_SOME(unsigned int); - TEST_SHMEM_WAIT_UNTIL_SOME(unsigned long); - TEST_SHMEM_WAIT_UNTIL_SOME(unsigned long long); - TEST_SHMEM_WAIT_UNTIL_SOME(int32_t); - TEST_SHMEM_WAIT_UNTIL_SOME(int64_t); - TEST_SHMEM_WAIT_UNTIL_SOME(uint32_t); - TEST_SHMEM_WAIT_UNTIL_SOME(uint64_t); - TEST_SHMEM_WAIT_UNTIL_SOME(size_t); - TEST_SHMEM_WAIT_UNTIL_SOME(ptrdiff_t); - - shmem_finalize(); - return rc; -} diff --git a/test/unit/c11_test_shmem_atomic_add.c b/test/unit/c11_test_shmem_atomic_add.c deleted file mode 100644 index 5df80fb40..000000000 --- a/test/unit/c11_test_shmem_atomic_add.c +++ /dev/null @@ -1,246 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include - -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L - -enum op { ADD = 0, ATOMIC_ADD, CTX_ATOMIC_ADD, FADD, ATOMIC_FETCH_ADD, - CTX_ATOMIC_FETCH_ADD, ATOMIC_FETCH_ADD_NBI, CTX_ATOMIC_FETCH_ADD_NBI }; - -#ifdef ENABLE_DEPRECATED_TESTS -#define DEPRECATED_ADD shmem_add -#define DEPRECATED_FADD shmem_fadd -#else -#define DEPRECATED_ADD shmem_atomic_add -#define DEPRECATED_FADD shmem_atomic_fetch_add -#endif - -#define SHMEM_NBI_OPS_CASES(OP, TYPE) \ - case ATOMIC_FETCH_ADD_NBI: \ - shmem_atomic_fetch_add_nbi(&old, &remote, (TYPE)(mype + 1), i); \ - shmem_quiet(); \ - if (old > (TYPE)(npes * (npes + 1) / 2)) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - case CTX_ATOMIC_FETCH_ADD_NBI: \ - shmem_atomic_fetch_add_nbi(SHMEM_CTX_DEFAULT, &old, &remote, \ - (TYPE)(mype + 1), i); \ - shmem_quiet(); \ - if (old > (TYPE)(npes * (npes + 1) / 2)) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; - -#define TEST_SHMEM_ADD(OP, TYPE) \ - do { \ - static TYPE remote; \ - TYPE old; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - remote = (TYPE)0; \ - shmem_barrier_all(); \ - for (int i = 0; i < npes; i++) \ - switch (OP) { \ - case ADD: \ - DEPRECATED_ADD(&remote, (TYPE)(mype + 1), i); \ - break; \ - case ATOMIC_ADD: \ - shmem_atomic_add(&remote, (TYPE)(mype + 1), i); \ - break; \ - case CTX_ATOMIC_ADD: \ - shmem_atomic_add(SHMEM_CTX_DEFAULT, &remote, (TYPE)(mype + 1), i); \ - break; \ - case FADD: \ - old = DEPRECATED_FADD(&remote, (TYPE)(mype + 1), i); \ - if (old > (TYPE)(npes * (npes + 1) / 2)) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - case ATOMIC_FETCH_ADD: \ - old = shmem_atomic_fetch_add(&remote, (TYPE)(mype + 1), i); \ - if (old > (TYPE)(npes * (npes + 1) / 2)) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - case CTX_ATOMIC_FETCH_ADD: \ - old = shmem_atomic_fetch_add(SHMEM_CTX_DEFAULT, &remote, (TYPE)(mype + 1), i); \ - if (old > (TYPE)(npes * (npes + 1) / 2)) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - SHMEM_NBI_OPS_CASES(OP, TYPE) \ - default: \ - printf("Invalid operation (%d)\n", OP); \ - shmem_global_exit(1); \ - } \ - shmem_barrier_all(); \ - if (remote != (TYPE)(npes * (npes + 1) / 2)) { \ - printf("PE %i observed error with TEST_SHMEM_ADD(%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (0) - -#else -#define TEST_SHMEM_ADD(OP, TYPE) - -#endif - -int main(int argc, char* argv[]) { - shmem_init(); - - int rc = EXIT_SUCCESS; - -#ifdef ENABLE_DEPRECATED_TESTS - TEST_SHMEM_ADD(ADD, int); - TEST_SHMEM_ADD(ADD, long); - TEST_SHMEM_ADD(ADD, long long); - TEST_SHMEM_ADD(ADD, unsigned int); - TEST_SHMEM_ADD(ADD, unsigned long); - TEST_SHMEM_ADD(ADD, unsigned long long); - TEST_SHMEM_ADD(ADD, int32_t); - TEST_SHMEM_ADD(ADD, int64_t); - TEST_SHMEM_ADD(ADD, uint32_t); - TEST_SHMEM_ADD(ADD, uint64_t); - TEST_SHMEM_ADD(ADD, size_t); - TEST_SHMEM_ADD(ADD, ptrdiff_t); -#endif /* ENABLE_DEPRECATED_TESTS */ - - TEST_SHMEM_ADD(ATOMIC_ADD, int); - TEST_SHMEM_ADD(ATOMIC_ADD, long); - TEST_SHMEM_ADD(ATOMIC_ADD, long long); - TEST_SHMEM_ADD(ATOMIC_ADD, unsigned int); - TEST_SHMEM_ADD(ATOMIC_ADD, unsigned long); - TEST_SHMEM_ADD(ATOMIC_ADD, unsigned long long); - TEST_SHMEM_ADD(ATOMIC_ADD, int32_t); - TEST_SHMEM_ADD(ATOMIC_ADD, int64_t); - TEST_SHMEM_ADD(ATOMIC_ADD, uint32_t); - TEST_SHMEM_ADD(ATOMIC_ADD, uint64_t); - TEST_SHMEM_ADD(ATOMIC_ADD, size_t); - TEST_SHMEM_ADD(ATOMIC_ADD, ptrdiff_t); - - TEST_SHMEM_ADD(CTX_ATOMIC_ADD, int); - TEST_SHMEM_ADD(CTX_ATOMIC_ADD, long); - TEST_SHMEM_ADD(CTX_ATOMIC_ADD, long long); - TEST_SHMEM_ADD(CTX_ATOMIC_ADD, unsigned int); - TEST_SHMEM_ADD(CTX_ATOMIC_ADD, unsigned long); - TEST_SHMEM_ADD(CTX_ATOMIC_ADD, unsigned long long); - TEST_SHMEM_ADD(CTX_ATOMIC_ADD, int32_t); - TEST_SHMEM_ADD(CTX_ATOMIC_ADD, int64_t); - TEST_SHMEM_ADD(CTX_ATOMIC_ADD, uint32_t); - TEST_SHMEM_ADD(CTX_ATOMIC_ADD, uint64_t); - TEST_SHMEM_ADD(CTX_ATOMIC_ADD, size_t); - TEST_SHMEM_ADD(CTX_ATOMIC_ADD, ptrdiff_t); - - TEST_SHMEM_ADD(FADD, int); - TEST_SHMEM_ADD(FADD, long); - TEST_SHMEM_ADD(FADD, long long); - TEST_SHMEM_ADD(FADD, unsigned int); - TEST_SHMEM_ADD(FADD, unsigned long); - TEST_SHMEM_ADD(FADD, unsigned long long); - TEST_SHMEM_ADD(FADD, int32_t); - TEST_SHMEM_ADD(FADD, int64_t); - TEST_SHMEM_ADD(FADD, uint32_t); - TEST_SHMEM_ADD(FADD, uint64_t); - TEST_SHMEM_ADD(FADD, size_t); - TEST_SHMEM_ADD(FADD, ptrdiff_t); - - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD, int); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD, long); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD, long long); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD, unsigned int); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD, unsigned long); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD, unsigned long long); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD, int32_t); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD, int64_t); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD, uint32_t); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD, uint64_t); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD, size_t); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD, ptrdiff_t); - - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD, int); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD, long); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD, long long); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD, unsigned int); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD, unsigned long); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD, unsigned long long); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD, int32_t); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD, int64_t); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD, uint32_t); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD, uint64_t); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD, size_t); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD, ptrdiff_t); - - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD_NBI, int); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD_NBI, long); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD_NBI, long long); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD_NBI, unsigned int); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD_NBI, unsigned long); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD_NBI, unsigned long long); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD_NBI, int32_t); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD_NBI, int64_t); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD_NBI, uint32_t); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD_NBI, uint64_t); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD_NBI, size_t); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD_NBI, ptrdiff_t); - - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD_NBI, int); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD_NBI, long); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD_NBI, long long); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD_NBI, unsigned int); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD_NBI, unsigned long); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD_NBI, unsigned long long); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD_NBI, int32_t); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD_NBI, int64_t); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD_NBI, uint32_t); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD_NBI, uint64_t); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD_NBI, size_t); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD_NBI, ptrdiff_t); - - shmem_finalize(); - return rc; -} diff --git a/test/unit/c11_test_shmem_atomic_and.c b/test/unit/c11_test_shmem_atomic_and.c deleted file mode 100644 index 1d1eb133d..000000000 --- a/test/unit/c11_test_shmem_atomic_and.c +++ /dev/null @@ -1,174 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include - -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L - -enum op { AND = 0, CTX_AND, FETCH_AND, CTX_FETCH_AND, FETCH_AND_NBI, - CTX_FETCH_AND_NBI }; - -/* Initially, remote = 111...b. Each PE performs an atomic AND where the - * PEth bit of the input value is set to 0 and all other bits are set to 1. - * The result has the NPES least significant bits cleared, 111...000...b. - */ - -#define SHMEM_NBI_OPS_CASES(OP, TYPE) \ - case FETCH_AND_NBI: \ - shmem_atomic_fetch_and_nbi(&old, &remote, \ - ~(TYPE)(1LLU << mype), i); \ - shmem_quiet(); \ - if ((old & (TYPE)(1LLU << mype)) == 0) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - case CTX_FETCH_AND_NBI: \ - shmem_atomic_fetch_and_nbi(SHMEM_CTX_DEFAULT, &old, &remote, \ - ~(TYPE)(1LLU << mype), i); \ - shmem_quiet(); \ - if ((old & (TYPE)(1LLU << mype)) == 0) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; - -#define TEST_SHMEM_AND(OP, TYPE) \ - do { \ - static TYPE remote = ~(TYPE)0; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - TYPE old = (TYPE)0; \ - if ((size_t) npes-1 > sizeof(TYPE)) break; /* Avoid overflow */ \ - for (int i = 0; i < npes; i++) \ - switch (OP) { \ - case AND: \ - shmem_atomic_and(&remote, ~(TYPE)(1LLU << mype), i); \ - break; \ - case CTX_AND: \ - shmem_atomic_and(SHMEM_CTX_DEFAULT, &remote, ~(TYPE)(1LLU << mype), i); \ - break; \ - case FETCH_AND: \ - old = shmem_atomic_fetch_and(&remote, ~(TYPE)(1LLU << mype), i); \ - if ((old & (TYPE)(1LLU << mype)) == 0) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - case CTX_FETCH_AND: \ - old = shmem_atomic_fetch_and(SHMEM_CTX_DEFAULT, &remote, ~(TYPE)(1LLU << mype), i); \ - if ((old & (TYPE)(1LLU << mype)) == 0) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - SHMEM_NBI_OPS_CASES(OP, TYPE) \ - default: \ - printf("Invalid operation (%d)\n", OP); \ - shmem_global_exit(1); \ - } \ - shmem_barrier_all(); \ - if (remote != ~(TYPE)((1LLU << npes) - 1LLU)) { \ - printf("PE %i observed error with TEST_SHMEM_AND(%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (0) - -#else -#define TEST_SHMEM_AND(OP, TYPE) - -#endif - -int main(int argc, char* argv[]) { - shmem_init(); - - int rc = EXIT_SUCCESS; - TEST_SHMEM_AND(AND, unsigned int); - TEST_SHMEM_AND(AND, unsigned long); - TEST_SHMEM_AND(AND, unsigned long long); - TEST_SHMEM_AND(AND, int32_t); - TEST_SHMEM_AND(AND, int64_t); - TEST_SHMEM_AND(AND, uint32_t); - TEST_SHMEM_AND(AND, uint64_t); - - TEST_SHMEM_AND(CTX_AND, unsigned int); - TEST_SHMEM_AND(CTX_AND, unsigned long); - TEST_SHMEM_AND(CTX_AND, unsigned long long); - TEST_SHMEM_AND(CTX_AND, int32_t); - TEST_SHMEM_AND(CTX_AND, int64_t); - TEST_SHMEM_AND(CTX_AND, uint32_t); - TEST_SHMEM_AND(CTX_AND, uint64_t); - - TEST_SHMEM_AND(FETCH_AND, unsigned int); - TEST_SHMEM_AND(FETCH_AND, unsigned long); - TEST_SHMEM_AND(FETCH_AND, unsigned long long); - TEST_SHMEM_AND(FETCH_AND, int32_t); - TEST_SHMEM_AND(FETCH_AND, int64_t); - TEST_SHMEM_AND(FETCH_AND, uint32_t); - TEST_SHMEM_AND(FETCH_AND, uint64_t); - - TEST_SHMEM_AND(CTX_FETCH_AND, unsigned int); - TEST_SHMEM_AND(CTX_FETCH_AND, unsigned long); - TEST_SHMEM_AND(CTX_FETCH_AND, unsigned long long); - TEST_SHMEM_AND(CTX_FETCH_AND, int32_t); - TEST_SHMEM_AND(CTX_FETCH_AND, int64_t); - TEST_SHMEM_AND(CTX_FETCH_AND, uint32_t); - TEST_SHMEM_AND(CTX_FETCH_AND, uint64_t); - - TEST_SHMEM_AND(FETCH_AND_NBI, unsigned int); - TEST_SHMEM_AND(FETCH_AND_NBI, unsigned long); - TEST_SHMEM_AND(FETCH_AND_NBI, unsigned long long); - TEST_SHMEM_AND(FETCH_AND_NBI, int32_t); - TEST_SHMEM_AND(FETCH_AND_NBI, int64_t); - TEST_SHMEM_AND(FETCH_AND_NBI, uint32_t); - TEST_SHMEM_AND(FETCH_AND_NBI, uint64_t); - - TEST_SHMEM_AND(CTX_FETCH_AND_NBI, unsigned int); - TEST_SHMEM_AND(CTX_FETCH_AND_NBI, unsigned long); - TEST_SHMEM_AND(CTX_FETCH_AND_NBI, unsigned long long); - TEST_SHMEM_AND(CTX_FETCH_AND_NBI, int32_t); - TEST_SHMEM_AND(CTX_FETCH_AND_NBI, int64_t); - TEST_SHMEM_AND(CTX_FETCH_AND_NBI, uint32_t); - TEST_SHMEM_AND(CTX_FETCH_AND_NBI, uint64_t); - - shmem_finalize(); - return rc; -} diff --git a/test/unit/c11_test_shmem_atomic_cswap.c b/test/unit/c11_test_shmem_atomic_cswap.c deleted file mode 100644 index a6dc553d7..000000000 --- a/test/unit/c11_test_shmem_atomic_cswap.c +++ /dev/null @@ -1,179 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include - -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L - -enum op { CSWAP = 0, ATOMIC_COMPARE_SWAP, CTX_ATOMIC_COMPARE_SWAP, - ATOMIC_COMPARE_SWAP_NBI, CTX_ATOMIC_COMPARE_SWAP_NBI }; - -#ifdef ENABLE_DEPRECATED_TESTS -#define DEPRECATED_CSWAP shmem_cswap -#else -#define DEPRECATED_CSWAP shmem_atomic_compare_swap -#endif - -#define SHMEM_NBI_OPS_CASES(OP, TYPE) \ - case ATOMIC_COMPARE_SWAP_NBI: \ - shmem_atomic_compare_swap_nbi(&old, &remote, (TYPE)npes, \ - (TYPE)mype, (mype + 1) % npes); \ - break; \ - case CTX_ATOMIC_COMPARE_SWAP_NBI: \ - shmem_atomic_compare_swap_nbi(SHMEM_CTX_DEFAULT, &old, &remote, \ - (TYPE)npes, (TYPE)mype, \ - (mype + 1) % npes); \ - break; - -#define TEST_SHMEM_CSWAP(OP, TYPE) \ - do { \ - static TYPE remote; \ - TYPE old; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - remote = npes; \ - shmem_barrier_all(); \ - switch (OP) { \ - case CSWAP: \ - old = DEPRECATED_CSWAP(&remote, (TYPE)npes, (TYPE)mype, \ - (mype + 1) % npes); \ - break; \ - case ATOMIC_COMPARE_SWAP: \ - old = shmem_atomic_compare_swap(&remote, (TYPE)npes, \ - (TYPE)mype, (mype + 1) % npes); \ - break; \ - case CTX_ATOMIC_COMPARE_SWAP: \ - old = shmem_atomic_compare_swap(SHMEM_CTX_DEFAULT, &remote, \ - (TYPE)npes, (TYPE)mype, \ - (mype + 1) % npes); \ - break; \ - SHMEM_NBI_OPS_CASES(OP, TYPE) \ - default: \ - printf("invalid operation (%d)\n", OP); \ - shmem_global_exit(1); \ - } \ - shmem_barrier_all(); \ - if (remote != (TYPE)((mype + npes - 1) % npes)) { \ - printf("PE %i observed error with TEST_SHMEM_CSWAP(%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - if (old != (TYPE) npes) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (0) - -#else -#define TEST_SHMEM_CSWAP(OP, TYPE) - -#endif - -int main(int argc, char* argv[]) { - shmem_init(); - - int rc = EXIT_SUCCESS; - -#ifdef ENABLE_DEPRECATED_TESTS - TEST_SHMEM_CSWAP(CSWAP, int); - TEST_SHMEM_CSWAP(CSWAP, long); - TEST_SHMEM_CSWAP(CSWAP, long long); - TEST_SHMEM_CSWAP(CSWAP, unsigned int); - TEST_SHMEM_CSWAP(CSWAP, unsigned long); - TEST_SHMEM_CSWAP(CSWAP, unsigned long long); - TEST_SHMEM_CSWAP(CSWAP, int32_t); - TEST_SHMEM_CSWAP(CSWAP, int64_t); - TEST_SHMEM_CSWAP(CSWAP, uint32_t); - TEST_SHMEM_CSWAP(CSWAP, uint64_t); - TEST_SHMEM_CSWAP(CSWAP, size_t); - TEST_SHMEM_CSWAP(CSWAP, ptrdiff_t); -#endif /* ENABLE_DEPRECATED_TESTS */ - - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP, int); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP, long); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP, long long); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP, unsigned int); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP, unsigned long); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP, unsigned long long); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP, int32_t); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP, int64_t); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP, uint32_t); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP, uint64_t); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP, size_t); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP, ptrdiff_t); - - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP, int); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP, long); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP, long long); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP, unsigned int); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP, unsigned long); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP, unsigned long long); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP, int32_t); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP, int64_t); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP, uint32_t); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP, uint64_t); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP, size_t); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP, ptrdiff_t); - - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP_NBI, int); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP_NBI, long); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP_NBI, long long); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP_NBI, unsigned int); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP_NBI, unsigned long); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP_NBI, unsigned long long); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP_NBI, int32_t); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP_NBI, int64_t); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP_NBI, uint32_t); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP_NBI, uint64_t); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP_NBI, size_t); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP_NBI, ptrdiff_t); - - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP_NBI, int); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP_NBI, long); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP_NBI, long long); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP_NBI, unsigned int); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP_NBI, unsigned long); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP_NBI, unsigned long long); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP_NBI, int32_t); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP_NBI, int64_t); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP_NBI, uint32_t); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP_NBI, uint64_t); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP_NBI, size_t); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP_NBI, ptrdiff_t); - - shmem_finalize(); - return rc; -} diff --git a/test/unit/c11_test_shmem_atomic_fetch.c b/test/unit/c11_test_shmem_atomic_fetch.c deleted file mode 100644 index 3c7525663..000000000 --- a/test/unit/c11_test_shmem_atomic_fetch.c +++ /dev/null @@ -1,180 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include - -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L - -enum op { FETCH = 0, ATOMIC_FETCH, CTX_ATOMIC_FETCH, ATOMIC_FETCH_NBI, - CTX_ATOMIC_FETCH_NBI }; - -#ifdef ENABLE_DEPRECATED_TESTS -#define DEPRECATED_FETCH shmem_fetch -#else -#define DEPRECATED_FETCH shmem_atomic_fetch -#endif - -#define SHMEM_NBI_OPS_CASES(OP, TYPE) \ - case ATOMIC_FETCH_NBI: \ - shmem_atomic_fetch_nbi(&val, &remote, \ - (mype + 1) % npes); \ - shmem_quiet(); \ - break; \ - case CTX_ATOMIC_FETCH_NBI: \ - shmem_atomic_fetch_nbi(SHMEM_CTX_DEFAULT, &val, \ - &remote, (mype + 1) % npes); \ - shmem_quiet(); \ - break; - -#define TEST_SHMEM_FETCH(OP, TYPE) \ - do { \ - static TYPE remote; \ - TYPE val; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - remote = (TYPE)mype; \ - shmem_barrier_all(); \ - switch (OP) { \ - case FETCH: \ - val = DEPRECATED_FETCH(&remote, (mype + 1) % npes); \ - break; \ - case ATOMIC_FETCH: \ - val = shmem_atomic_fetch(&remote, (mype + 1) % npes); \ - break; \ - case CTX_ATOMIC_FETCH: \ - val = shmem_atomic_fetch(SHMEM_CTX_DEFAULT, &remote, (mype + 1) % npes); \ - break; \ - SHMEM_NBI_OPS_CASES(OP, TYPE) \ - default: \ - printf("Invalid operation (%d)\n", OP); \ - shmem_global_exit(1); \ - } \ - if (val != (TYPE)((mype + 1) % npes)) { \ - printf("PE %i received incorrect value with " \ - "TEST_SHMEM_FETCH(%s, %s)\n", mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (0) - -#else -#define TEST_SHMEM_FETCH(OP, TYPE) - -#endif - -int main(int argc, char* argv[]) { - shmem_init(); - - int rc = EXIT_SUCCESS; - -#ifdef ENABLE_DEPRECATED_TESTS - TEST_SHMEM_FETCH(FETCH, float); - TEST_SHMEM_FETCH(FETCH, double); - TEST_SHMEM_FETCH(FETCH, int); - TEST_SHMEM_FETCH(FETCH, long); - TEST_SHMEM_FETCH(FETCH, long long); - TEST_SHMEM_FETCH(FETCH, unsigned int); - TEST_SHMEM_FETCH(FETCH, unsigned long); - TEST_SHMEM_FETCH(FETCH, unsigned long long); - TEST_SHMEM_FETCH(FETCH, int32_t); - TEST_SHMEM_FETCH(FETCH, int64_t); - TEST_SHMEM_FETCH(FETCH, uint32_t); - TEST_SHMEM_FETCH(FETCH, uint64_t); - TEST_SHMEM_FETCH(FETCH, size_t); - TEST_SHMEM_FETCH(FETCH, ptrdiff_t); -#endif /* ENABLE_DEPRECATED_TESTS */ - - TEST_SHMEM_FETCH(ATOMIC_FETCH, float); - TEST_SHMEM_FETCH(ATOMIC_FETCH, double); - TEST_SHMEM_FETCH(ATOMIC_FETCH, int); - TEST_SHMEM_FETCH(ATOMIC_FETCH, long); - TEST_SHMEM_FETCH(ATOMIC_FETCH, long long); - TEST_SHMEM_FETCH(ATOMIC_FETCH, unsigned int); - TEST_SHMEM_FETCH(ATOMIC_FETCH, unsigned long); - TEST_SHMEM_FETCH(ATOMIC_FETCH, unsigned long long); - TEST_SHMEM_FETCH(ATOMIC_FETCH, int32_t); - TEST_SHMEM_FETCH(ATOMIC_FETCH, int64_t); - TEST_SHMEM_FETCH(ATOMIC_FETCH, uint32_t); - TEST_SHMEM_FETCH(ATOMIC_FETCH, uint64_t); - TEST_SHMEM_FETCH(ATOMIC_FETCH, size_t); - TEST_SHMEM_FETCH(ATOMIC_FETCH, ptrdiff_t); - - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH, float); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH, double); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH, int); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH, long); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH, long long); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH, unsigned int); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH, unsigned long); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH, unsigned long long); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH, int32_t); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH, int64_t); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH, uint32_t); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH, uint64_t); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH, size_t); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH, ptrdiff_t); - - TEST_SHMEM_FETCH(ATOMIC_FETCH_NBI, float); - TEST_SHMEM_FETCH(ATOMIC_FETCH_NBI, double); - TEST_SHMEM_FETCH(ATOMIC_FETCH_NBI, int); - TEST_SHMEM_FETCH(ATOMIC_FETCH_NBI, long); - TEST_SHMEM_FETCH(ATOMIC_FETCH_NBI, long long); - TEST_SHMEM_FETCH(ATOMIC_FETCH_NBI, unsigned int); - TEST_SHMEM_FETCH(ATOMIC_FETCH_NBI, unsigned long); - TEST_SHMEM_FETCH(ATOMIC_FETCH_NBI, unsigned long long); - TEST_SHMEM_FETCH(ATOMIC_FETCH_NBI, int32_t); - TEST_SHMEM_FETCH(ATOMIC_FETCH_NBI, int64_t); - TEST_SHMEM_FETCH(ATOMIC_FETCH_NBI, uint32_t); - TEST_SHMEM_FETCH(ATOMIC_FETCH_NBI, uint64_t); - TEST_SHMEM_FETCH(ATOMIC_FETCH_NBI, size_t); - TEST_SHMEM_FETCH(ATOMIC_FETCH_NBI, ptrdiff_t); - - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH_NBI, float); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH_NBI, double); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH_NBI, int); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH_NBI, long); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH_NBI, long long); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH_NBI, unsigned int); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH_NBI, unsigned long); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH_NBI, unsigned long long); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH_NBI, int32_t); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH_NBI, int64_t); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH_NBI, uint32_t); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH_NBI, uint64_t); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH_NBI, size_t); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH_NBI, ptrdiff_t); - - shmem_finalize(); - return rc; -} diff --git a/test/unit/c11_test_shmem_atomic_inc.c b/test/unit/c11_test_shmem_atomic_inc.c deleted file mode 100644 index 115643926..000000000 --- a/test/unit/c11_test_shmem_atomic_inc.c +++ /dev/null @@ -1,246 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include - -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L - -enum op { INC = 0, ATOMIC_INC, CTX_ATOMIC_INC, FINC, ATOMIC_FETCH_INC, - CTX_ATOMIC_FETCH_INC, ATOMIC_FETCH_INC_NBI, - CTX_ATOMIC_FETCH_INC_NBI }; - -#ifdef ENABLE_DEPRECATED_TESTS -#define DEPRECATED_INC shmem_inc -#define DEPRECATED_FINC shmem_finc -#else -#define DEPRECATED_INC shmem_atomic_inc -#define DEPRECATED_FINC shmem_atomic_fetch_inc -#endif - -#define SHMEM_NBI_OPS_CASES(OP, TYPE) \ - case ATOMIC_FETCH_INC_NBI: \ - shmem_atomic_fetch_inc_nbi(&old, &remote, i); \ - shmem_quiet(); \ - if (old > (TYPE) npes) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - case CTX_ATOMIC_FETCH_INC_NBI: \ - shmem_atomic_fetch_inc_nbi(SHMEM_CTX_DEFAULT, &old, &remote, i); \ - shmem_quiet(); \ - if (old > (TYPE) npes) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; - -#define TEST_SHMEM_INC(OP, TYPE) \ - do { \ - static TYPE remote = (TYPE)0; \ - TYPE old; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - remote = (TYPE)0; \ - shmem_barrier_all(); \ - for (int i = 0; i < npes; i++) \ - switch (OP) { \ - case INC: \ - DEPRECATED_INC(&remote, i); \ - break; \ - case ATOMIC_INC: \ - shmem_atomic_inc(&remote, i); \ - break; \ - case CTX_ATOMIC_INC: \ - shmem_atomic_inc(SHMEM_CTX_DEFAULT, &remote, i); \ - break; \ - case FINC: \ - old = DEPRECATED_FINC(&remote, i); \ - if (old > (TYPE) npes) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - case ATOMIC_FETCH_INC: \ - old = shmem_atomic_fetch_inc(&remote, i); \ - if (old > (TYPE) npes) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - case CTX_ATOMIC_FETCH_INC: \ - old = shmem_atomic_fetch_inc(SHMEM_CTX_DEFAULT, &remote, i); \ - if (old > (TYPE) npes) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - SHMEM_NBI_OPS_CASES(OP, TYPE) \ - default: \ - printf("Invalid operation (%d)\n", OP); \ - shmem_global_exit(1); \ - } \ - shmem_barrier_all(); \ - if (remote != (TYPE)npes) { \ - printf("PE %i observed error with TEST_SHMEM_INC(%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (0) - -#else -#define TEST_SHMEM_INC(OP, TYPE) - -#endif - -int main(int argc, char* argv[]) { - shmem_init(); - - int rc = EXIT_SUCCESS; - -#ifdef ENABLE_DEPRECATED_TESTS - TEST_SHMEM_INC(INC, int); - TEST_SHMEM_INC(INC, long); - TEST_SHMEM_INC(INC, long long); - TEST_SHMEM_INC(INC, unsigned int); - TEST_SHMEM_INC(INC, unsigned long); - TEST_SHMEM_INC(INC, unsigned long long); - TEST_SHMEM_INC(INC, int32_t); - TEST_SHMEM_INC(INC, int64_t); - TEST_SHMEM_INC(INC, uint32_t); - TEST_SHMEM_INC(INC, uint64_t); - TEST_SHMEM_INC(INC, size_t); - TEST_SHMEM_INC(INC, ptrdiff_t); -#endif /* ENABLE_DEPRECATED_TESTS */ - - TEST_SHMEM_INC(ATOMIC_INC, int); - TEST_SHMEM_INC(ATOMIC_INC, long); - TEST_SHMEM_INC(ATOMIC_INC, long long); - TEST_SHMEM_INC(ATOMIC_INC, unsigned int); - TEST_SHMEM_INC(ATOMIC_INC, unsigned long); - TEST_SHMEM_INC(ATOMIC_INC, unsigned long long); - TEST_SHMEM_INC(ATOMIC_INC, int32_t); - TEST_SHMEM_INC(ATOMIC_INC, int64_t); - TEST_SHMEM_INC(ATOMIC_INC, uint32_t); - TEST_SHMEM_INC(ATOMIC_INC, uint64_t); - TEST_SHMEM_INC(ATOMIC_INC, size_t); - TEST_SHMEM_INC(ATOMIC_INC, ptrdiff_t); - - TEST_SHMEM_INC(CTX_ATOMIC_INC, int); - TEST_SHMEM_INC(CTX_ATOMIC_INC, long); - TEST_SHMEM_INC(CTX_ATOMIC_INC, long long); - TEST_SHMEM_INC(CTX_ATOMIC_INC, unsigned int); - TEST_SHMEM_INC(CTX_ATOMIC_INC, unsigned long); - TEST_SHMEM_INC(CTX_ATOMIC_INC, unsigned long long); - TEST_SHMEM_INC(CTX_ATOMIC_INC, int32_t); - TEST_SHMEM_INC(CTX_ATOMIC_INC, int64_t); - TEST_SHMEM_INC(CTX_ATOMIC_INC, uint32_t); - TEST_SHMEM_INC(CTX_ATOMIC_INC, uint64_t); - TEST_SHMEM_INC(CTX_ATOMIC_INC, size_t); - TEST_SHMEM_INC(CTX_ATOMIC_INC, ptrdiff_t); - - TEST_SHMEM_INC(FINC, int); - TEST_SHMEM_INC(FINC, long); - TEST_SHMEM_INC(FINC, long long); - TEST_SHMEM_INC(FINC, unsigned int); - TEST_SHMEM_INC(FINC, unsigned long); - TEST_SHMEM_INC(FINC, unsigned long long); - TEST_SHMEM_INC(FINC, int32_t); - TEST_SHMEM_INC(FINC, int64_t); - TEST_SHMEM_INC(FINC, uint32_t); - TEST_SHMEM_INC(FINC, uint64_t); - TEST_SHMEM_INC(FINC, size_t); - TEST_SHMEM_INC(FINC, ptrdiff_t); - - TEST_SHMEM_INC(ATOMIC_FETCH_INC, int); - TEST_SHMEM_INC(ATOMIC_FETCH_INC, long); - TEST_SHMEM_INC(ATOMIC_FETCH_INC, long long); - TEST_SHMEM_INC(ATOMIC_FETCH_INC, unsigned int); - TEST_SHMEM_INC(ATOMIC_FETCH_INC, unsigned long); - TEST_SHMEM_INC(ATOMIC_FETCH_INC, unsigned long long); - TEST_SHMEM_INC(ATOMIC_FETCH_INC, int32_t); - TEST_SHMEM_INC(ATOMIC_FETCH_INC, int64_t); - TEST_SHMEM_INC(ATOMIC_FETCH_INC, uint32_t); - TEST_SHMEM_INC(ATOMIC_FETCH_INC, uint64_t); - TEST_SHMEM_INC(ATOMIC_FETCH_INC, size_t); - TEST_SHMEM_INC(ATOMIC_FETCH_INC, ptrdiff_t); - - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC, int); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC, long); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC, long long); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC, unsigned int); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC, unsigned long); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC, unsigned long long); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC, int32_t); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC, int64_t); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC, uint32_t); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC, uint64_t); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC, size_t); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC, ptrdiff_t); - - TEST_SHMEM_INC(ATOMIC_FETCH_INC_NBI, int); - TEST_SHMEM_INC(ATOMIC_FETCH_INC_NBI, long); - TEST_SHMEM_INC(ATOMIC_FETCH_INC_NBI, long long); - TEST_SHMEM_INC(ATOMIC_FETCH_INC_NBI, unsigned int); - TEST_SHMEM_INC(ATOMIC_FETCH_INC_NBI, unsigned long); - TEST_SHMEM_INC(ATOMIC_FETCH_INC_NBI, unsigned long long); - TEST_SHMEM_INC(ATOMIC_FETCH_INC_NBI, int32_t); - TEST_SHMEM_INC(ATOMIC_FETCH_INC_NBI, int64_t); - TEST_SHMEM_INC(ATOMIC_FETCH_INC_NBI, uint32_t); - TEST_SHMEM_INC(ATOMIC_FETCH_INC_NBI, uint64_t); - TEST_SHMEM_INC(ATOMIC_FETCH_INC_NBI, size_t); - TEST_SHMEM_INC(ATOMIC_FETCH_INC_NBI, ptrdiff_t); - - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC_NBI, int); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC_NBI, long); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC_NBI, long long); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC_NBI, unsigned int); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC_NBI, unsigned long); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC_NBI, unsigned long long); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC_NBI, int32_t); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC_NBI, int64_t); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC_NBI, uint32_t); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC_NBI, uint64_t); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC_NBI, size_t); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC_NBI, ptrdiff_t); - - shmem_finalize(); - return rc; -} diff --git a/test/unit/c11_test_shmem_atomic_or.c b/test/unit/c11_test_shmem_atomic_or.c deleted file mode 100644 index 750814ea0..000000000 --- a/test/unit/c11_test_shmem_atomic_or.c +++ /dev/null @@ -1,176 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include - -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L - -enum op { OR = 0, CTX_OR, FETCH_OR, CTX_FETCH_OR, FETCH_OR_NBI, - CTX_FETCH_OR_NBI }; - -/* Initially, remote = 000...b. Each PE performs an atomic OR where the - * PEth bit of the input value is set to 1 and all other bits are set to 0. - * The result has the NPES least significant bits set, 000...111...b. - */ - -#define SHMEM_NBI_OPS_CASES(OP, TYPE) \ - case FETCH_OR_NBI: \ - shmem_atomic_fetch_or_nbi(&old, &remote, \ - (TYPE)(1LLU << mype), i); \ - shmem_quiet(); \ - if ((old & (TYPE)(1LLU << mype)) != 0) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - case CTX_FETCH_OR_NBI: \ - shmem_atomic_fetch_or_nbi(SHMEM_CTX_DEFAULT, &old, &remote, \ - (TYPE)(1LLU << mype), i); \ - shmem_quiet(); \ - if ((old & (TYPE)(1LLU << mype)) != 0) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; - -#define TEST_SHMEM_OR(OP, TYPE) \ - do { \ - static TYPE remote = (TYPE)0; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - TYPE old = (TYPE)0; \ - if ((size_t) npes-1 > sizeof(TYPE)) break; /* Avoid overflow */ \ - for (int i = 0; i < npes; i++) \ - switch (OP) { \ - case OR: \ - shmem_atomic_or(&remote, (TYPE)(1LLU << mype), i); \ - break; \ - case CTX_OR: \ - shmem_atomic_or(SHMEM_CTX_DEFAULT, &remote, \ - (TYPE)(1LLU << mype), i); \ - break; \ - case FETCH_OR: \ - old = shmem_atomic_fetch_or(&remote, (TYPE)(1LLU << mype), i);\ - if ((old & (TYPE)(1LLU << mype)) != 0) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - case CTX_FETCH_OR: \ - old = shmem_atomic_fetch_or(SHMEM_CTX_DEFAULT, &remote, \ - (TYPE)(1LLU << mype), i); \ - if ((old & (TYPE)(1LLU << mype)) != 0) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - SHMEM_NBI_OPS_CASES(OP, TYPE) \ - default: \ - printf("Invalid operation (%d)\n", OP); \ - shmem_global_exit(1); \ - } \ - shmem_barrier_all(); \ - if (remote != (TYPE)((1LLU << npes) - 1LLU)) { \ - printf("PE %i observed error with TEST_SHMEM_OR(%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (0) - -#else -#define TEST_SHMEM_OR(OP, TYPE) - -#endif - -int main(int argc, char* argv[]) { - shmem_init(); - - int rc = EXIT_SUCCESS; - TEST_SHMEM_OR(OR, unsigned int); - TEST_SHMEM_OR(OR, unsigned long); - TEST_SHMEM_OR(OR, unsigned long long); - TEST_SHMEM_OR(OR, int32_t); - TEST_SHMEM_OR(OR, int64_t); - TEST_SHMEM_OR(OR, uint32_t); - TEST_SHMEM_OR(OR, uint64_t); - - TEST_SHMEM_OR(CTX_OR, unsigned int); - TEST_SHMEM_OR(CTX_OR, unsigned long); - TEST_SHMEM_OR(CTX_OR, unsigned long long); - TEST_SHMEM_OR(CTX_OR, int32_t); - TEST_SHMEM_OR(CTX_OR, int64_t); - TEST_SHMEM_OR(CTX_OR, uint32_t); - TEST_SHMEM_OR(CTX_OR, uint64_t); - - TEST_SHMEM_OR(FETCH_OR, unsigned int); - TEST_SHMEM_OR(FETCH_OR, unsigned long); - TEST_SHMEM_OR(FETCH_OR, unsigned long long); - TEST_SHMEM_OR(FETCH_OR, int32_t); - TEST_SHMEM_OR(FETCH_OR, int64_t); - TEST_SHMEM_OR(FETCH_OR, uint32_t); - TEST_SHMEM_OR(FETCH_OR, uint64_t); - - TEST_SHMEM_OR(CTX_FETCH_OR, unsigned int); - TEST_SHMEM_OR(CTX_FETCH_OR, unsigned long); - TEST_SHMEM_OR(CTX_FETCH_OR, unsigned long long); - TEST_SHMEM_OR(CTX_FETCH_OR, int32_t); - TEST_SHMEM_OR(CTX_FETCH_OR, int64_t); - TEST_SHMEM_OR(CTX_FETCH_OR, uint32_t); - TEST_SHMEM_OR(CTX_FETCH_OR, uint64_t); - - TEST_SHMEM_OR(FETCH_OR_NBI, unsigned int); - TEST_SHMEM_OR(FETCH_OR_NBI, unsigned long); - TEST_SHMEM_OR(FETCH_OR_NBI, unsigned long long); - TEST_SHMEM_OR(FETCH_OR_NBI, int32_t); - TEST_SHMEM_OR(FETCH_OR_NBI, int64_t); - TEST_SHMEM_OR(FETCH_OR_NBI, uint32_t); - TEST_SHMEM_OR(FETCH_OR_NBI, uint64_t); - - TEST_SHMEM_OR(CTX_FETCH_OR_NBI, unsigned int); - TEST_SHMEM_OR(CTX_FETCH_OR_NBI, unsigned long); - TEST_SHMEM_OR(CTX_FETCH_OR_NBI, unsigned long long); - TEST_SHMEM_OR(CTX_FETCH_OR_NBI, int32_t); - TEST_SHMEM_OR(CTX_FETCH_OR_NBI, int64_t); - TEST_SHMEM_OR(CTX_FETCH_OR_NBI, uint32_t); - TEST_SHMEM_OR(CTX_FETCH_OR_NBI, uint64_t); - - shmem_finalize(); - return rc; -} diff --git a/test/unit/c11_test_shmem_atomic_set.c b/test/unit/c11_test_shmem_atomic_set.c deleted file mode 100644 index 16dc1cea3..000000000 --- a/test/unit/c11_test_shmem_atomic_set.c +++ /dev/null @@ -1,134 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include - -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L - -enum op { SET = 0, ATOMIC_SET, CTX_ATOMIC_SET }; - -#ifdef ENABLE_DEPRECATED_TESTS -#define DEPRECATED_SET shmem_set -#else -#define DEPRECATED_SET shmem_atomic_set -#endif - -#define TEST_SHMEM_SET(OP, TYPE) \ - do { \ - static TYPE remote; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - switch (OP) { \ - case SET: \ - DEPRECATED_SET(&remote, (TYPE)mype, (mype + 1) % npes); \ - break; \ - case ATOMIC_SET: \ - shmem_atomic_set(&remote, (TYPE)mype, (mype + 1) % npes); \ - break; \ - case CTX_ATOMIC_SET: \ - shmem_atomic_set(SHMEM_CTX_DEFAULT, &remote, (TYPE)mype, (mype + 1) % npes); \ - break; \ - default: \ - printf("Invalid operation (%d)\n", OP); \ - shmem_global_exit(1); \ - } \ - shmem_barrier_all(); \ - if (remote != (TYPE)((mype + npes - 1) % npes)) { \ - printf("PE %i received incorrect value with " \ - "TEST_SHMEM_SET(%s, %s)\n", mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (0) - -#else -#define TEST_SHMEM_SET(OP, TYPE) - -#endif - -int main(int argc, char* argv[]) { - shmem_init(); - - int rc = EXIT_SUCCESS; - -#ifdef ENABLE_DEPRECATED_TESTS - TEST_SHMEM_SET(SET, float); - TEST_SHMEM_SET(SET, double); - TEST_SHMEM_SET(SET, int); - TEST_SHMEM_SET(SET, long); - TEST_SHMEM_SET(SET, long long); - TEST_SHMEM_SET(SET, unsigned int); - TEST_SHMEM_SET(SET, unsigned long); - TEST_SHMEM_SET(SET, unsigned long long); - TEST_SHMEM_SET(SET, int32_t); - TEST_SHMEM_SET(SET, int64_t); - TEST_SHMEM_SET(SET, uint32_t); - TEST_SHMEM_SET(SET, uint64_t); - TEST_SHMEM_SET(SET, size_t); - TEST_SHMEM_SET(SET, ptrdiff_t); -#endif /* ENABLE_DEPRECATED_TESTS */ - - TEST_SHMEM_SET(ATOMIC_SET, float); - TEST_SHMEM_SET(ATOMIC_SET, double); - TEST_SHMEM_SET(ATOMIC_SET, int); - TEST_SHMEM_SET(ATOMIC_SET, long); - TEST_SHMEM_SET(ATOMIC_SET, long long); - TEST_SHMEM_SET(ATOMIC_SET, unsigned int); - TEST_SHMEM_SET(ATOMIC_SET, unsigned long); - TEST_SHMEM_SET(ATOMIC_SET, unsigned long long); - TEST_SHMEM_SET(ATOMIC_SET, int32_t); - TEST_SHMEM_SET(ATOMIC_SET, int64_t); - TEST_SHMEM_SET(ATOMIC_SET, uint32_t); - TEST_SHMEM_SET(ATOMIC_SET, uint64_t); - TEST_SHMEM_SET(ATOMIC_SET, size_t); - TEST_SHMEM_SET(ATOMIC_SET, ptrdiff_t); - - TEST_SHMEM_SET(CTX_ATOMIC_SET, float); - TEST_SHMEM_SET(CTX_ATOMIC_SET, double); - TEST_SHMEM_SET(CTX_ATOMIC_SET, int); - TEST_SHMEM_SET(CTX_ATOMIC_SET, long); - TEST_SHMEM_SET(CTX_ATOMIC_SET, long long); - TEST_SHMEM_SET(CTX_ATOMIC_SET, unsigned int); - TEST_SHMEM_SET(CTX_ATOMIC_SET, unsigned long); - TEST_SHMEM_SET(CTX_ATOMIC_SET, unsigned long long); - TEST_SHMEM_SET(CTX_ATOMIC_SET, int32_t); - TEST_SHMEM_SET(CTX_ATOMIC_SET, int64_t); - TEST_SHMEM_SET(CTX_ATOMIC_SET, uint32_t); - TEST_SHMEM_SET(CTX_ATOMIC_SET, uint64_t); - TEST_SHMEM_SET(CTX_ATOMIC_SET, size_t); - TEST_SHMEM_SET(CTX_ATOMIC_SET, ptrdiff_t); - - shmem_finalize(); - return rc; -} diff --git a/test/unit/c11_test_shmem_atomic_swap.c b/test/unit/c11_test_shmem_atomic_swap.c deleted file mode 100644 index 6d8e8bdee..000000000 --- a/test/unit/c11_test_shmem_atomic_swap.c +++ /dev/null @@ -1,185 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include - -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L - -enum op { SWAP = 0, ATOMIC_SWAP, CTX_ATOMIC_SWAP, ATOMIC_SWAP_NBI, - CTX_ATOMIC_SWAP_NBI }; - -#ifdef ENABLE_DEPRECATED_TESTS -#define DEPRECATED_SWAP shmem_swap -#else -#define DEPRECATED_SWAP shmem_atomic_swap -#endif - -#define SHMEM_NBI_OPS_CASES(OP, TYPE) \ - case ATOMIC_SWAP_NBI: \ - shmem_atomic_swap_nbi(&old, &remote, \ - (TYPE)mype, (mype + 1) % npes); \ - break; \ - case CTX_ATOMIC_SWAP_NBI: \ - shmem_atomic_swap_nbi(SHMEM_CTX_DEFAULT, &old, &remote, \ - (TYPE)mype, (mype + 1) % npes); \ - break; - -#define TEST_SHMEM_SWAP(OP, TYPE) \ - do { \ - static TYPE remote; \ - TYPE old; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - remote = npes; \ - shmem_barrier_all(); \ - switch (OP) { \ - case SWAP: \ - old = DEPRECATED_SWAP(&remote, (TYPE)mype, (mype + 1) % npes); \ - break; \ - case ATOMIC_SWAP: \ - old = shmem_atomic_swap(&remote, (TYPE)mype, (mype + 1) % npes); \ - break; \ - case CTX_ATOMIC_SWAP: \ - old = shmem_atomic_swap(SHMEM_CTX_DEFAULT, &remote, \ - (TYPE)mype, (mype + 1) % npes); \ - break; \ - SHMEM_NBI_OPS_CASES(OP, TYPE) \ - default: \ - printf("invalid operation (%d)\n", OP); \ - shmem_global_exit(1); \ - } \ - shmem_barrier_all(); \ - if (remote != (TYPE)((mype + npes - 1) % npes)) { \ - printf("PE %i received incorrect value with " \ - "TEST_SHMEM_SWAP(%s, %s)\n", mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - if (old != (TYPE) npes) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (0) - -#else -#define TEST_SHMEM_SWAP(OP, TYPE) - -#endif - -int main(int argc, char* argv[]) { - shmem_init(); - - int rc = EXIT_SUCCESS; - -#ifdef ENABLE_DEPRECATED_TESTS - TEST_SHMEM_SWAP(SWAP, float); - TEST_SHMEM_SWAP(SWAP, double); - TEST_SHMEM_SWAP(SWAP, int); - TEST_SHMEM_SWAP(SWAP, long); - TEST_SHMEM_SWAP(SWAP, long long); - TEST_SHMEM_SWAP(SWAP, unsigned int); - TEST_SHMEM_SWAP(SWAP, unsigned long); - TEST_SHMEM_SWAP(SWAP, unsigned long long); - TEST_SHMEM_SWAP(SWAP, int32_t); - TEST_SHMEM_SWAP(SWAP, int64_t); - TEST_SHMEM_SWAP(SWAP, uint32_t); - TEST_SHMEM_SWAP(SWAP, uint64_t); - TEST_SHMEM_SWAP(SWAP, size_t); - TEST_SHMEM_SWAP(SWAP, ptrdiff_t); -#endif /* ENABLE_DEPRECATED_TESTS */ - - TEST_SHMEM_SWAP(ATOMIC_SWAP, float); - TEST_SHMEM_SWAP(ATOMIC_SWAP, double); - TEST_SHMEM_SWAP(ATOMIC_SWAP, int); - TEST_SHMEM_SWAP(ATOMIC_SWAP, long); - TEST_SHMEM_SWAP(ATOMIC_SWAP, long long); - TEST_SHMEM_SWAP(ATOMIC_SWAP, unsigned int); - TEST_SHMEM_SWAP(ATOMIC_SWAP, unsigned long); - TEST_SHMEM_SWAP(ATOMIC_SWAP, unsigned long long); - TEST_SHMEM_SWAP(ATOMIC_SWAP, int32_t); - TEST_SHMEM_SWAP(ATOMIC_SWAP, int64_t); - TEST_SHMEM_SWAP(ATOMIC_SWAP, uint32_t); - TEST_SHMEM_SWAP(ATOMIC_SWAP, uint64_t); - TEST_SHMEM_SWAP(ATOMIC_SWAP, size_t); - TEST_SHMEM_SWAP(ATOMIC_SWAP, ptrdiff_t); - - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP, float); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP, double); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP, int); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP, long); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP, long long); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP, unsigned int); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP, unsigned long); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP, unsigned long long); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP, int32_t); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP, int64_t); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP, uint32_t); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP, uint64_t); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP, size_t); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP, ptrdiff_t); - - TEST_SHMEM_SWAP(ATOMIC_SWAP_NBI, float); - TEST_SHMEM_SWAP(ATOMIC_SWAP_NBI, double); - TEST_SHMEM_SWAP(ATOMIC_SWAP_NBI, int); - TEST_SHMEM_SWAP(ATOMIC_SWAP_NBI, long); - TEST_SHMEM_SWAP(ATOMIC_SWAP_NBI, long long); - TEST_SHMEM_SWAP(ATOMIC_SWAP_NBI, unsigned int); - TEST_SHMEM_SWAP(ATOMIC_SWAP_NBI, unsigned long); - TEST_SHMEM_SWAP(ATOMIC_SWAP_NBI, unsigned long long); - TEST_SHMEM_SWAP(ATOMIC_SWAP_NBI, int32_t); - TEST_SHMEM_SWAP(ATOMIC_SWAP_NBI, int64_t); - TEST_SHMEM_SWAP(ATOMIC_SWAP_NBI, uint32_t); - TEST_SHMEM_SWAP(ATOMIC_SWAP_NBI, uint64_t); - TEST_SHMEM_SWAP(ATOMIC_SWAP_NBI, size_t); - TEST_SHMEM_SWAP(ATOMIC_SWAP_NBI, ptrdiff_t); - - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP_NBI, float); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP_NBI, double); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP_NBI, int); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP_NBI, long); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP_NBI, long long); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP_NBI, unsigned int); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP_NBI, unsigned long); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP_NBI, unsigned long long); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP_NBI, int32_t); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP_NBI, int64_t); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP_NBI, uint32_t); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP_NBI, uint64_t); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP_NBI, size_t); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP_NBI, ptrdiff_t); - - shmem_finalize(); - return rc; -} diff --git a/test/unit/c11_test_shmem_atomic_xor.c b/test/unit/c11_test_shmem_atomic_xor.c deleted file mode 100644 index 63f6abdf9..000000000 --- a/test/unit/c11_test_shmem_atomic_xor.c +++ /dev/null @@ -1,174 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include - -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L - -enum op { XOR = 0, CTX_XOR, FETCH_XOR, CTX_FETCH_XOR, FETCH_XOR_NBI, - CTX_FETCH_XOR_NBI }; - -/* Initially, remote = 111...b. Each PE performs an atomic XOR where the - * PEth bit of the input value is set to 1 and all other bits are set to 0. - * The result has the NPES least significant bits cleared, 111...000...b. - */ - -#define SHMEM_NBI_OPS_CASES(OP, TYPE) \ - case FETCH_XOR_NBI: \ - shmem_atomic_fetch_xor_nbi(&old, &remote, \ - (TYPE)(1LLU << mype), i); \ - shmem_quiet(); \ - if (((old ^ (TYPE)(1LLU << mype)) & (TYPE)(1LLU << mype)) != 0) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - case CTX_FETCH_XOR_NBI: \ - shmem_atomic_fetch_xor_nbi(SHMEM_CTX_DEFAULT, &old, &remote, \ - (TYPE)(1LLU << mype), i); \ - shmem_quiet(); \ - if (((old ^ (TYPE)(1LLU << mype)) & (TYPE)(1LLU << mype)) != 0) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; - -#define TEST_SHMEM_XOR(OP, TYPE) \ - do { \ - static TYPE remote = ~(TYPE)0; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - TYPE old; \ - if ((size_t) npes-1 > sizeof(TYPE)) break; /* Avoid overflow */ \ - for (int i = 0; i < npes; i++) \ - switch (OP) { \ - case XOR: \ - shmem_atomic_xor(&remote, (TYPE)(1LLU << mype), i); \ - break; \ - case CTX_XOR: \ - shmem_atomic_xor(SHMEM_CTX_DEFAULT, &remote, (TYPE)(1LLU << mype), i); \ - break; \ - case FETCH_XOR: \ - old = shmem_atomic_fetch_xor(&remote, (TYPE)(1LLU << mype), i); \ - if (((old ^ (TYPE)(1LLU << mype)) & (TYPE)(1LLU << mype)) != 0) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - case CTX_FETCH_XOR: \ - old = shmem_atomic_fetch_xor(SHMEM_CTX_DEFAULT, &remote, (TYPE)(1LLU << mype), i); \ - if (((old ^ (TYPE)(1LLU << mype)) & (TYPE)(1LLU << mype)) != 0) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - SHMEM_NBI_OPS_CASES(OP, TYPE) \ - default: \ - printf("Invalid operation (%d)\n", OP); \ - shmem_global_exit(1); \ - } \ - shmem_barrier_all(); \ - if (remote != ~(TYPE)((1LLU << npes) - 1LLU)) { \ - printf("PE %i observed error with TEST_SHMEM_XOR(%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (0) - -#else -#define TEST_SHMEM_XOR(OP, TYPE) - -#endif - -int main(int argc, char* argv[]) { - shmem_init(); - - int rc = EXIT_SUCCESS; - TEST_SHMEM_XOR(XOR, unsigned int); - TEST_SHMEM_XOR(XOR, unsigned long); - TEST_SHMEM_XOR(XOR, unsigned long long); - TEST_SHMEM_XOR(XOR, int32_t); - TEST_SHMEM_XOR(XOR, int64_t); - TEST_SHMEM_XOR(XOR, uint32_t); - TEST_SHMEM_XOR(XOR, uint64_t); - - TEST_SHMEM_XOR(CTX_XOR, unsigned int); - TEST_SHMEM_XOR(CTX_XOR, unsigned long); - TEST_SHMEM_XOR(CTX_XOR, unsigned long long); - TEST_SHMEM_XOR(CTX_XOR, int32_t); - TEST_SHMEM_XOR(CTX_XOR, int64_t); - TEST_SHMEM_XOR(CTX_XOR, uint32_t); - TEST_SHMEM_XOR(CTX_XOR, uint64_t); - - TEST_SHMEM_XOR(FETCH_XOR, unsigned int); - TEST_SHMEM_XOR(FETCH_XOR, unsigned long); - TEST_SHMEM_XOR(FETCH_XOR, unsigned long long); - TEST_SHMEM_XOR(FETCH_XOR, int32_t); - TEST_SHMEM_XOR(FETCH_XOR, int64_t); - TEST_SHMEM_XOR(FETCH_XOR, uint32_t); - TEST_SHMEM_XOR(FETCH_XOR, uint64_t); - - TEST_SHMEM_XOR(CTX_FETCH_XOR, unsigned int); - TEST_SHMEM_XOR(CTX_FETCH_XOR, unsigned long); - TEST_SHMEM_XOR(CTX_FETCH_XOR, unsigned long long); - TEST_SHMEM_XOR(CTX_FETCH_XOR, int32_t); - TEST_SHMEM_XOR(CTX_FETCH_XOR, int64_t); - TEST_SHMEM_XOR(CTX_FETCH_XOR, uint32_t); - TEST_SHMEM_XOR(CTX_FETCH_XOR, uint64_t); - - TEST_SHMEM_XOR(FETCH_XOR_NBI, unsigned int); - TEST_SHMEM_XOR(FETCH_XOR_NBI, unsigned long); - TEST_SHMEM_XOR(FETCH_XOR_NBI, unsigned long long); - TEST_SHMEM_XOR(FETCH_XOR_NBI, int32_t); - TEST_SHMEM_XOR(FETCH_XOR_NBI, int64_t); - TEST_SHMEM_XOR(FETCH_XOR_NBI, uint32_t); - TEST_SHMEM_XOR(FETCH_XOR_NBI, uint64_t); - - TEST_SHMEM_XOR(CTX_FETCH_XOR_NBI, unsigned int); - TEST_SHMEM_XOR(CTX_FETCH_XOR_NBI, unsigned long); - TEST_SHMEM_XOR(CTX_FETCH_XOR_NBI, unsigned long long); - TEST_SHMEM_XOR(CTX_FETCH_XOR_NBI, int32_t); - TEST_SHMEM_XOR(CTX_FETCH_XOR_NBI, int64_t); - TEST_SHMEM_XOR(CTX_FETCH_XOR_NBI, uint32_t); - TEST_SHMEM_XOR(CTX_FETCH_XOR_NBI, uint64_t); - - shmem_finalize(); - return rc; -} diff --git a/test/unit/c11_test_shmem_g.c b/test/unit/c11_test_shmem_g.c deleted file mode 100644 index 969dd1386..000000000 --- a/test/unit/c11_test_shmem_g.c +++ /dev/null @@ -1,121 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include - -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L - -#define TEST_SHMEM_G(USE_CTX, TYPE) \ - do { \ - static TYPE remote; \ - TYPE val; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - remote = (TYPE)mype; \ - shmem_barrier_all(); \ - if (USE_CTX) \ - val = shmem_g(SHMEM_CTX_DEFAULT, &remote, (mype + 1) % npes); \ - else \ - val = shmem_g(&remote, (mype + 1) % npes); \ - if (val != (TYPE)((mype + 1) % npes)) { \ - printf("PE %i received incorrect value with" \ - "TEST_SHMEM_G(%d, %s)\n", mype, \ - (int)(USE_CTX), #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (0) - -#else -#define TEST_SHMEM_G(USE_CTX, TYPE) - -#endif - -int main(int argc, char* argv[]) { - shmem_init(); - - int rc = EXIT_SUCCESS; - TEST_SHMEM_G(0, float); - TEST_SHMEM_G(0, double); - TEST_SHMEM_G(0, long double); - TEST_SHMEM_G(0, char); - TEST_SHMEM_G(0, signed char); - TEST_SHMEM_G(0, short); - TEST_SHMEM_G(0, int); - TEST_SHMEM_G(0, long); - TEST_SHMEM_G(0, long long); - TEST_SHMEM_G(0, unsigned char); - TEST_SHMEM_G(0, unsigned short); - TEST_SHMEM_G(0, unsigned int); - TEST_SHMEM_G(0, unsigned long); - TEST_SHMEM_G(0, unsigned long long); - TEST_SHMEM_G(0, int8_t); - TEST_SHMEM_G(0, int16_t); - TEST_SHMEM_G(0, int32_t); - TEST_SHMEM_G(0, int64_t); - TEST_SHMEM_G(0, uint8_t); - TEST_SHMEM_G(0, uint16_t); - TEST_SHMEM_G(0, uint32_t); - TEST_SHMEM_G(0, uint64_t); - TEST_SHMEM_G(0, size_t); - TEST_SHMEM_G(0, ptrdiff_t); - - TEST_SHMEM_G(1, float); - TEST_SHMEM_G(1, double); - TEST_SHMEM_G(1, long double); - TEST_SHMEM_G(1, char); - TEST_SHMEM_G(1, signed char); - TEST_SHMEM_G(1, short); - TEST_SHMEM_G(1, int); - TEST_SHMEM_G(1, long); - TEST_SHMEM_G(1, long long); - TEST_SHMEM_G(1, unsigned char); - TEST_SHMEM_G(1, unsigned short); - TEST_SHMEM_G(1, unsigned int); - TEST_SHMEM_G(1, unsigned long); - TEST_SHMEM_G(1, unsigned long long); - TEST_SHMEM_G(1, int8_t); - TEST_SHMEM_G(1, int16_t); - TEST_SHMEM_G(1, int32_t); - TEST_SHMEM_G(1, int64_t); - TEST_SHMEM_G(1, uint8_t); - TEST_SHMEM_G(1, uint16_t); - TEST_SHMEM_G(1, uint32_t); - TEST_SHMEM_G(1, uint64_t); - TEST_SHMEM_G(1, size_t); - TEST_SHMEM_G(1, ptrdiff_t); - - shmem_finalize(); - return rc; -} diff --git a/test/unit/c11_test_shmem_get.c b/test/unit/c11_test_shmem_get.c deleted file mode 100644 index 30487d37a..000000000 --- a/test/unit/c11_test_shmem_get.c +++ /dev/null @@ -1,245 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include - -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L - -enum op { GET = 0, IGET, GET_NBI }; - -#define TEST_SHMEM_GET(OP, USE_CTX, TYPE) \ - do { \ - static TYPE remote[10]; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - TYPE local[10]; \ - for (int i = 0; i < 10; i++) \ - remote[i] = (TYPE)mype; \ - shmem_barrier_all(); \ - switch (OP) { \ - case GET: \ - if (USE_CTX) \ - shmem_get(SHMEM_CTX_DEFAULT, local, remote, 10, (mype + 1) % npes); \ - else \ - shmem_get(local, remote, 10, (mype + 1) % npes); \ - break; \ - case IGET: \ - if (USE_CTX) \ - shmem_iget(SHMEM_CTX_DEFAULT, local, remote, 1, 1, 10, (mype + 1) % npes); \ - else \ - shmem_iget(local, remote, 1, 1, 10, (mype + 1) % npes); \ - break; \ - case GET_NBI: \ - if (USE_CTX) \ - shmem_get_nbi(SHMEM_CTX_DEFAULT, local, remote, 10, (mype + 1) % npes); \ - else \ - shmem_get_nbi(local, remote, 10, (mype + 1) % npes); \ - shmem_quiet(); \ - break; \ - default: \ - printf("Invalid operation (%d)\n", OP); \ - shmem_global_exit(1); \ - } \ - for (int i = 0; i < 10; i++) \ - if (local[i] != (TYPE)((mype + 1) % npes)) { \ - printf("PE %i received incorrect value with" \ - "TEST_SHMEM_GET(%s, %d, %s)\n", mype, #OP, \ - (int)(USE_CTX), #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (0) - -#else -#define TEST_SHMEM_GET(OP, USE_CTX, TYPE) - -#endif - -int main(int argc, char* argv[]) { - shmem_init(); - - int rc = EXIT_SUCCESS; - TEST_SHMEM_GET(GET, 0, float); - TEST_SHMEM_GET(GET, 0, double); - TEST_SHMEM_GET(GET, 0, long double); - TEST_SHMEM_GET(GET, 0, char); - TEST_SHMEM_GET(GET, 0, signed char); - TEST_SHMEM_GET(GET, 0, short); - TEST_SHMEM_GET(GET, 0, int); - TEST_SHMEM_GET(GET, 0, long); - TEST_SHMEM_GET(GET, 0, long long); - TEST_SHMEM_GET(GET, 0, unsigned char); - TEST_SHMEM_GET(GET, 0, unsigned short); - TEST_SHMEM_GET(GET, 0, unsigned int); - TEST_SHMEM_GET(GET, 0, unsigned long); - TEST_SHMEM_GET(GET, 0, unsigned long long); - TEST_SHMEM_GET(GET, 0, int8_t); - TEST_SHMEM_GET(GET, 0, int16_t); - TEST_SHMEM_GET(GET, 0, int32_t); - TEST_SHMEM_GET(GET, 0, int64_t); - TEST_SHMEM_GET(GET, 0, uint8_t); - TEST_SHMEM_GET(GET, 0, uint16_t); - TEST_SHMEM_GET(GET, 0, uint32_t); - TEST_SHMEM_GET(GET, 0, uint64_t); - TEST_SHMEM_GET(GET, 0, size_t); - TEST_SHMEM_GET(GET, 0, ptrdiff_t); - - TEST_SHMEM_GET(GET, 1, float); - TEST_SHMEM_GET(GET, 1, double); - TEST_SHMEM_GET(GET, 1, long double); - TEST_SHMEM_GET(GET, 1, char); - TEST_SHMEM_GET(GET, 1, signed char); - TEST_SHMEM_GET(GET, 1, short); - TEST_SHMEM_GET(GET, 1, int); - TEST_SHMEM_GET(GET, 1, long); - TEST_SHMEM_GET(GET, 1, long long); - TEST_SHMEM_GET(GET, 1, unsigned char); - TEST_SHMEM_GET(GET, 1, unsigned short); - TEST_SHMEM_GET(GET, 1, unsigned int); - TEST_SHMEM_GET(GET, 1, unsigned long); - TEST_SHMEM_GET(GET, 1, unsigned long long); - TEST_SHMEM_GET(GET, 1, int8_t); - TEST_SHMEM_GET(GET, 1, int16_t); - TEST_SHMEM_GET(GET, 1, int32_t); - TEST_SHMEM_GET(GET, 1, int64_t); - TEST_SHMEM_GET(GET, 1, uint8_t); - TEST_SHMEM_GET(GET, 1, uint16_t); - TEST_SHMEM_GET(GET, 1, uint32_t); - TEST_SHMEM_GET(GET, 1, uint64_t); - TEST_SHMEM_GET(GET, 1, size_t); - TEST_SHMEM_GET(GET, 1, ptrdiff_t); - - TEST_SHMEM_GET(IGET, 0, float); - TEST_SHMEM_GET(IGET, 0, double); - TEST_SHMEM_GET(IGET, 0, long double); - TEST_SHMEM_GET(IGET, 0, char); - TEST_SHMEM_GET(IGET, 0, signed char); - TEST_SHMEM_GET(IGET, 0, short); - TEST_SHMEM_GET(IGET, 0, int); - TEST_SHMEM_GET(IGET, 0, long); - TEST_SHMEM_GET(IGET, 0, long long); - TEST_SHMEM_GET(IGET, 0, unsigned char); - TEST_SHMEM_GET(IGET, 0, unsigned short); - TEST_SHMEM_GET(IGET, 0, unsigned int); - TEST_SHMEM_GET(IGET, 0, unsigned long); - TEST_SHMEM_GET(IGET, 0, unsigned long long); - TEST_SHMEM_GET(IGET, 0, int8_t); - TEST_SHMEM_GET(IGET, 0, int16_t); - TEST_SHMEM_GET(IGET, 0, int32_t); - TEST_SHMEM_GET(IGET, 0, int64_t); - TEST_SHMEM_GET(IGET, 0, uint8_t); - TEST_SHMEM_GET(IGET, 0, uint16_t); - TEST_SHMEM_GET(IGET, 0, uint32_t); - TEST_SHMEM_GET(IGET, 0, uint64_t); - TEST_SHMEM_GET(IGET, 0, size_t); - TEST_SHMEM_GET(IGET, 0, ptrdiff_t); - - TEST_SHMEM_GET(IGET, 1, float); - TEST_SHMEM_GET(IGET, 1, double); - TEST_SHMEM_GET(IGET, 1, long double); - TEST_SHMEM_GET(IGET, 1, char); - TEST_SHMEM_GET(IGET, 1, signed char); - TEST_SHMEM_GET(IGET, 1, short); - TEST_SHMEM_GET(IGET, 1, int); - TEST_SHMEM_GET(IGET, 1, long); - TEST_SHMEM_GET(IGET, 1, long long); - TEST_SHMEM_GET(IGET, 1, unsigned char); - TEST_SHMEM_GET(IGET, 1, unsigned short); - TEST_SHMEM_GET(IGET, 1, unsigned int); - TEST_SHMEM_GET(IGET, 1, unsigned long); - TEST_SHMEM_GET(IGET, 1, unsigned long long); - TEST_SHMEM_GET(IGET, 1, int8_t); - TEST_SHMEM_GET(IGET, 1, int16_t); - TEST_SHMEM_GET(IGET, 1, int32_t); - TEST_SHMEM_GET(IGET, 1, int64_t); - TEST_SHMEM_GET(IGET, 1, uint8_t); - TEST_SHMEM_GET(IGET, 1, uint16_t); - TEST_SHMEM_GET(IGET, 1, uint32_t); - TEST_SHMEM_GET(IGET, 1, uint64_t); - TEST_SHMEM_GET(IGET, 1, size_t); - TEST_SHMEM_GET(IGET, 1, ptrdiff_t); - - TEST_SHMEM_GET(GET_NBI, 0, float); - TEST_SHMEM_GET(GET_NBI, 0, double); - TEST_SHMEM_GET(GET_NBI, 0, long double); - TEST_SHMEM_GET(GET_NBI, 0, char); - TEST_SHMEM_GET(GET_NBI, 0, signed char); - TEST_SHMEM_GET(GET_NBI, 0, short); - TEST_SHMEM_GET(GET_NBI, 0, int); - TEST_SHMEM_GET(GET_NBI, 0, long); - TEST_SHMEM_GET(GET_NBI, 0, long long); - TEST_SHMEM_GET(GET_NBI, 0, unsigned char); - TEST_SHMEM_GET(GET_NBI, 0, unsigned short); - TEST_SHMEM_GET(GET_NBI, 0, unsigned int); - TEST_SHMEM_GET(GET_NBI, 0, unsigned long); - TEST_SHMEM_GET(GET_NBI, 0, unsigned long long); - TEST_SHMEM_GET(GET_NBI, 0, int8_t); - TEST_SHMEM_GET(GET_NBI, 0, int16_t); - TEST_SHMEM_GET(GET_NBI, 0, int32_t); - TEST_SHMEM_GET(GET_NBI, 0, int64_t); - TEST_SHMEM_GET(GET_NBI, 0, uint8_t); - TEST_SHMEM_GET(GET_NBI, 0, uint16_t); - TEST_SHMEM_GET(GET_NBI, 0, uint32_t); - TEST_SHMEM_GET(GET_NBI, 0, uint64_t); - TEST_SHMEM_GET(GET_NBI, 0, size_t); - TEST_SHMEM_GET(GET_NBI, 0, ptrdiff_t); - - TEST_SHMEM_GET(GET_NBI, 1, float); - TEST_SHMEM_GET(GET_NBI, 1, double); - TEST_SHMEM_GET(GET_NBI, 1, long double); - TEST_SHMEM_GET(GET_NBI, 1, char); - TEST_SHMEM_GET(GET_NBI, 1, signed char); - TEST_SHMEM_GET(GET_NBI, 1, short); - TEST_SHMEM_GET(GET_NBI, 1, int); - TEST_SHMEM_GET(GET_NBI, 1, long); - TEST_SHMEM_GET(GET_NBI, 1, long long); - TEST_SHMEM_GET(GET_NBI, 1, unsigned char); - TEST_SHMEM_GET(GET_NBI, 1, unsigned short); - TEST_SHMEM_GET(GET_NBI, 1, unsigned int); - TEST_SHMEM_GET(GET_NBI, 1, unsigned long); - TEST_SHMEM_GET(GET_NBI, 1, unsigned long long); - TEST_SHMEM_GET(GET_NBI, 1, int8_t); - TEST_SHMEM_GET(GET_NBI, 1, int16_t); - TEST_SHMEM_GET(GET_NBI, 1, int32_t); - TEST_SHMEM_GET(GET_NBI, 1, int64_t); - TEST_SHMEM_GET(GET_NBI, 1, uint8_t); - TEST_SHMEM_GET(GET_NBI, 1, uint16_t); - TEST_SHMEM_GET(GET_NBI, 1, uint32_t); - TEST_SHMEM_GET(GET_NBI, 1, uint64_t); - TEST_SHMEM_GET(GET_NBI, 1, size_t); - TEST_SHMEM_GET(GET_NBI, 1, ptrdiff_t); - - shmem_finalize(); - return rc; -} diff --git a/test/unit/c11_test_shmem_p.c b/test/unit/c11_test_shmem_p.c deleted file mode 100644 index 56adb0fc9..000000000 --- a/test/unit/c11_test_shmem_p.c +++ /dev/null @@ -1,119 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include - -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L - -#define TEST_SHMEM_P(USE_CTX, TYPE) \ - do { \ - static TYPE remote; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - if (USE_CTX) \ - shmem_p(SHMEM_CTX_DEFAULT, &remote, (TYPE)mype, (mype + 1) % npes); \ - else \ - shmem_p(&remote, (TYPE)mype, (mype + 1) % npes);\ - shmem_barrier_all(); \ - if (remote != (TYPE)((mype + npes - 1) % npes)) { \ - printf("PE %i received incorrect value with " \ - "TEST_SHMEM_P(%d, %s)\n", mype, \ - (int)(USE_CTX), #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (0) - -#else -#define TEST_SHMEM_P(USE_CTX, TYPE) - -#endif - -int main(int argc, char* argv[]) { - shmem_init(); - - int rc = EXIT_SUCCESS; - TEST_SHMEM_P(0, float); - TEST_SHMEM_P(0, double); - TEST_SHMEM_P(0, long double); - TEST_SHMEM_P(0, char); - TEST_SHMEM_P(0, signed char); - TEST_SHMEM_P(0, short); - TEST_SHMEM_P(0, int); - TEST_SHMEM_P(0, long); - TEST_SHMEM_P(0, long long); - TEST_SHMEM_P(0, unsigned char); - TEST_SHMEM_P(0, unsigned short); - TEST_SHMEM_P(0, unsigned int); - TEST_SHMEM_P(0, unsigned long); - TEST_SHMEM_P(0, unsigned long long); - TEST_SHMEM_P(0, int8_t); - TEST_SHMEM_P(0, int16_t); - TEST_SHMEM_P(0, int32_t); - TEST_SHMEM_P(0, int64_t); - TEST_SHMEM_P(0, uint8_t); - TEST_SHMEM_P(0, uint16_t); - TEST_SHMEM_P(0, uint32_t); - TEST_SHMEM_P(0, uint64_t); - TEST_SHMEM_P(0, size_t); - TEST_SHMEM_P(0, ptrdiff_t); - - TEST_SHMEM_P(1, float); - TEST_SHMEM_P(1, double); - TEST_SHMEM_P(1, long double); - TEST_SHMEM_P(1, char); - TEST_SHMEM_P(1, signed char); - TEST_SHMEM_P(1, short); - TEST_SHMEM_P(1, int); - TEST_SHMEM_P(1, long); - TEST_SHMEM_P(1, long long); - TEST_SHMEM_P(1, unsigned char); - TEST_SHMEM_P(1, unsigned short); - TEST_SHMEM_P(1, unsigned int); - TEST_SHMEM_P(1, unsigned long); - TEST_SHMEM_P(1, unsigned long long); - TEST_SHMEM_P(1, int8_t); - TEST_SHMEM_P(1, int16_t); - TEST_SHMEM_P(1, int32_t); - TEST_SHMEM_P(1, int64_t); - TEST_SHMEM_P(1, uint8_t); - TEST_SHMEM_P(1, uint16_t); - TEST_SHMEM_P(1, uint32_t); - TEST_SHMEM_P(1, uint64_t); - TEST_SHMEM_P(1, size_t); - TEST_SHMEM_P(1, ptrdiff_t); - - shmem_finalize(); - return rc; -} diff --git a/test/unit/c11_test_shmem_put.c b/test/unit/c11_test_shmem_put.c deleted file mode 100644 index 0f50a77ad..000000000 --- a/test/unit/c11_test_shmem_put.c +++ /dev/null @@ -1,245 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include - -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L - -enum op { PUT = 0, IPUT, PUT_NBI }; - -#define TEST_SHMEM_PUT(OP, USE_CTX, TYPE) \ - do { \ - static TYPE remote[10]; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - TYPE local[10]; \ - for (int i = 0; i < 10; i++) \ - local[i] = (TYPE)mype; \ - switch (OP) { \ - case PUT: \ - if (USE_CTX) \ - shmem_put(SHMEM_CTX_DEFAULT, remote, local, 10, (mype + 1) % npes); \ - else \ - shmem_put(remote, local, 10, (mype + 1) % npes); \ - break; \ - case IPUT: \ - if (USE_CTX) \ - shmem_iput(SHMEM_CTX_DEFAULT, remote, local, 1, 1, 10, (mype + 1) % npes); \ - else \ - shmem_iput(remote, local, 1, 1, 10, (mype + 1) % npes); \ - break; \ - case PUT_NBI: \ - if (USE_CTX) \ - shmem_put_nbi(SHMEM_CTX_DEFAULT, remote, local, 10, (mype + 1) % npes); \ - else \ - shmem_put_nbi(remote, local, 10, (mype + 1) % npes); \ - shmem_quiet(); \ - break; \ - default: \ - printf("Invalid operation (%d)\n", OP); \ - shmem_global_exit(1); \ - } \ - shmem_barrier_all(); \ - for (int i = 0; i < 10; i++) \ - if (remote[i] != (TYPE)((mype + npes - 1) % npes)) { \ - printf("PE %i received incorrect value with " \ - "TEST_SHMEM_PUT(%s, %d, %s)\n", mype, \ - #OP, (int)(USE_CTX), #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (0) - -#else -#define TEST_SHMEM_PUT(OP, USE_CTX, TYPE) - -#endif - -int main(int argc, char* argv[]) { - shmem_init(); - - int rc = EXIT_SUCCESS; - TEST_SHMEM_PUT(PUT, 0, float); - TEST_SHMEM_PUT(PUT, 0, double); - TEST_SHMEM_PUT(PUT, 0, long double); - TEST_SHMEM_PUT(PUT, 0, char); - TEST_SHMEM_PUT(PUT, 0, signed char); - TEST_SHMEM_PUT(PUT, 0, short); - TEST_SHMEM_PUT(PUT, 0, int); - TEST_SHMEM_PUT(PUT, 0, long); - TEST_SHMEM_PUT(PUT, 0, long long); - TEST_SHMEM_PUT(PUT, 0, unsigned char); - TEST_SHMEM_PUT(PUT, 0, unsigned short); - TEST_SHMEM_PUT(PUT, 0, unsigned int); - TEST_SHMEM_PUT(PUT, 0, unsigned long); - TEST_SHMEM_PUT(PUT, 0, unsigned long long); - TEST_SHMEM_PUT(PUT, 0, int8_t); - TEST_SHMEM_PUT(PUT, 0, int16_t); - TEST_SHMEM_PUT(PUT, 0, int32_t); - TEST_SHMEM_PUT(PUT, 0, int64_t); - TEST_SHMEM_PUT(PUT, 0, uint8_t); - TEST_SHMEM_PUT(PUT, 0, uint16_t); - TEST_SHMEM_PUT(PUT, 0, uint32_t); - TEST_SHMEM_PUT(PUT, 0, uint64_t); - TEST_SHMEM_PUT(PUT, 0, size_t); - TEST_SHMEM_PUT(PUT, 0, ptrdiff_t); - - TEST_SHMEM_PUT(PUT, 1, float); - TEST_SHMEM_PUT(PUT, 1, double); - TEST_SHMEM_PUT(PUT, 1, long double); - TEST_SHMEM_PUT(PUT, 1, char); - TEST_SHMEM_PUT(PUT, 1, signed char); - TEST_SHMEM_PUT(PUT, 1, short); - TEST_SHMEM_PUT(PUT, 1, int); - TEST_SHMEM_PUT(PUT, 1, long); - TEST_SHMEM_PUT(PUT, 1, long long); - TEST_SHMEM_PUT(PUT, 1, unsigned char); - TEST_SHMEM_PUT(PUT, 1, unsigned short); - TEST_SHMEM_PUT(PUT, 1, unsigned int); - TEST_SHMEM_PUT(PUT, 1, unsigned long); - TEST_SHMEM_PUT(PUT, 1, unsigned long long); - TEST_SHMEM_PUT(PUT, 1, int8_t); - TEST_SHMEM_PUT(PUT, 1, int16_t); - TEST_SHMEM_PUT(PUT, 1, int32_t); - TEST_SHMEM_PUT(PUT, 1, int64_t); - TEST_SHMEM_PUT(PUT, 1, uint8_t); - TEST_SHMEM_PUT(PUT, 1, uint16_t); - TEST_SHMEM_PUT(PUT, 1, uint32_t); - TEST_SHMEM_PUT(PUT, 1, uint64_t); - TEST_SHMEM_PUT(PUT, 1, size_t); - TEST_SHMEM_PUT(PUT, 1, ptrdiff_t); - - TEST_SHMEM_PUT(IPUT, 0, float); - TEST_SHMEM_PUT(IPUT, 0, double); - TEST_SHMEM_PUT(IPUT, 0, long double); - TEST_SHMEM_PUT(IPUT, 0, char); - TEST_SHMEM_PUT(IPUT, 0, signed char); - TEST_SHMEM_PUT(IPUT, 0, short); - TEST_SHMEM_PUT(IPUT, 0, int); - TEST_SHMEM_PUT(IPUT, 0, long); - TEST_SHMEM_PUT(IPUT, 0, long long); - TEST_SHMEM_PUT(IPUT, 0, unsigned char); - TEST_SHMEM_PUT(IPUT, 0, unsigned short); - TEST_SHMEM_PUT(IPUT, 0, unsigned int); - TEST_SHMEM_PUT(IPUT, 0, unsigned long); - TEST_SHMEM_PUT(IPUT, 0, unsigned long long); - TEST_SHMEM_PUT(IPUT, 0, int8_t); - TEST_SHMEM_PUT(IPUT, 0, int16_t); - TEST_SHMEM_PUT(IPUT, 0, int32_t); - TEST_SHMEM_PUT(IPUT, 0, int64_t); - TEST_SHMEM_PUT(IPUT, 0, uint8_t); - TEST_SHMEM_PUT(IPUT, 0, uint16_t); - TEST_SHMEM_PUT(IPUT, 0, uint32_t); - TEST_SHMEM_PUT(IPUT, 0, uint64_t); - TEST_SHMEM_PUT(IPUT, 0, size_t); - TEST_SHMEM_PUT(IPUT, 0, ptrdiff_t); - - TEST_SHMEM_PUT(IPUT, 1, float); - TEST_SHMEM_PUT(IPUT, 1, double); - TEST_SHMEM_PUT(IPUT, 1, long double); - TEST_SHMEM_PUT(IPUT, 1, char); - TEST_SHMEM_PUT(IPUT, 1, signed char); - TEST_SHMEM_PUT(IPUT, 1, short); - TEST_SHMEM_PUT(IPUT, 1, int); - TEST_SHMEM_PUT(IPUT, 1, long); - TEST_SHMEM_PUT(IPUT, 1, long long); - TEST_SHMEM_PUT(IPUT, 1, unsigned char); - TEST_SHMEM_PUT(IPUT, 1, unsigned short); - TEST_SHMEM_PUT(IPUT, 1, unsigned int); - TEST_SHMEM_PUT(IPUT, 1, unsigned long); - TEST_SHMEM_PUT(IPUT, 1, unsigned long long); - TEST_SHMEM_PUT(IPUT, 1, int8_t); - TEST_SHMEM_PUT(IPUT, 1, int16_t); - TEST_SHMEM_PUT(IPUT, 1, int32_t); - TEST_SHMEM_PUT(IPUT, 1, int64_t); - TEST_SHMEM_PUT(IPUT, 1, uint8_t); - TEST_SHMEM_PUT(IPUT, 1, uint16_t); - TEST_SHMEM_PUT(IPUT, 1, uint32_t); - TEST_SHMEM_PUT(IPUT, 1, uint64_t); - TEST_SHMEM_PUT(IPUT, 1, size_t); - TEST_SHMEM_PUT(IPUT, 1, ptrdiff_t); - - TEST_SHMEM_PUT(PUT_NBI, 0, float); - TEST_SHMEM_PUT(PUT_NBI, 0, double); - TEST_SHMEM_PUT(PUT_NBI, 0, long double); - TEST_SHMEM_PUT(PUT_NBI, 0, char); - TEST_SHMEM_PUT(PUT_NBI, 0, signed char); - TEST_SHMEM_PUT(PUT_NBI, 0, short); - TEST_SHMEM_PUT(PUT_NBI, 0, int); - TEST_SHMEM_PUT(PUT_NBI, 0, long); - TEST_SHMEM_PUT(PUT_NBI, 0, long long); - TEST_SHMEM_PUT(PUT_NBI, 0, unsigned char); - TEST_SHMEM_PUT(PUT_NBI, 0, unsigned short); - TEST_SHMEM_PUT(PUT_NBI, 0, unsigned int); - TEST_SHMEM_PUT(PUT_NBI, 0, unsigned long); - TEST_SHMEM_PUT(PUT_NBI, 0, unsigned long long); - TEST_SHMEM_PUT(PUT_NBI, 0, int8_t); - TEST_SHMEM_PUT(PUT_NBI, 0, int16_t); - TEST_SHMEM_PUT(PUT_NBI, 0, int32_t); - TEST_SHMEM_PUT(PUT_NBI, 0, int64_t); - TEST_SHMEM_PUT(PUT_NBI, 0, uint8_t); - TEST_SHMEM_PUT(PUT_NBI, 0, uint16_t); - TEST_SHMEM_PUT(PUT_NBI, 0, uint32_t); - TEST_SHMEM_PUT(PUT_NBI, 0, uint64_t); - TEST_SHMEM_PUT(PUT_NBI, 0, size_t); - TEST_SHMEM_PUT(PUT_NBI, 0, ptrdiff_t); - - TEST_SHMEM_PUT(PUT_NBI, 1, float); - TEST_SHMEM_PUT(PUT_NBI, 1, double); - TEST_SHMEM_PUT(PUT_NBI, 1, long double); - TEST_SHMEM_PUT(PUT_NBI, 1, char); - TEST_SHMEM_PUT(PUT_NBI, 1, signed char); - TEST_SHMEM_PUT(PUT_NBI, 1, short); - TEST_SHMEM_PUT(PUT_NBI, 1, int); - TEST_SHMEM_PUT(PUT_NBI, 1, long); - TEST_SHMEM_PUT(PUT_NBI, 1, long long); - TEST_SHMEM_PUT(PUT_NBI, 1, unsigned char); - TEST_SHMEM_PUT(PUT_NBI, 1, unsigned short); - TEST_SHMEM_PUT(PUT_NBI, 1, unsigned int); - TEST_SHMEM_PUT(PUT_NBI, 1, unsigned long); - TEST_SHMEM_PUT(PUT_NBI, 1, unsigned long long); - TEST_SHMEM_PUT(PUT_NBI, 1, int8_t); - TEST_SHMEM_PUT(PUT_NBI, 1, int16_t); - TEST_SHMEM_PUT(PUT_NBI, 1, int32_t); - TEST_SHMEM_PUT(PUT_NBI, 1, int64_t); - TEST_SHMEM_PUT(PUT_NBI, 1, uint8_t); - TEST_SHMEM_PUT(PUT_NBI, 1, uint16_t); - TEST_SHMEM_PUT(PUT_NBI, 1, uint32_t); - TEST_SHMEM_PUT(PUT_NBI, 1, uint64_t); - TEST_SHMEM_PUT(PUT_NBI, 1, size_t); - TEST_SHMEM_PUT(PUT_NBI, 1, ptrdiff_t); - - shmem_finalize(); - return rc; -} diff --git a/test/unit/c11_test_shmem_put_signal.c b/test/unit/c11_test_shmem_put_signal.c deleted file mode 100644 index 1a68463bd..000000000 --- a/test/unit/c11_test_shmem_put_signal.c +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright (c) 2021 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - * Validate shmem_put_signal operation through blocking and non-blocking - * APIs. -*/ - -#include -#include -#include -#include - -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L - -enum op { PUT_SIGNAL = 0, PUT_SIGNAL_NBI }; - -#define TEST_SHMEM_PUT_SIGNAL(OP, USE_CTX, SIGNAL_OP, TYPE) \ - do { \ - TYPE *remote = (TYPE *) shmem_malloc(10 * sizeof(TYPE)); \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - TYPE local[10]; \ - static uint64_t sig_addr = 0; \ - for (int i = 0; i < 10; i++) \ - local[i] = (TYPE) i; \ - int atomic_op = (SIGNAL_OP == 0) ? SHMEM_SIGNAL_SET : SHMEM_SIGNAL_ADD; \ - shmem_barrier_all(); \ - switch (OP) { \ - case PUT_SIGNAL: \ - if (USE_CTX) { \ - if (mype == 0) { \ - shmem_put_signal(SHMEM_CTX_DEFAULT, remote, local, 10, &sig_addr, (uint64_t) 1, \ - atomic_op, (mype + 1) % npes); \ - shmem_wait_until(&sig_addr, SHMEM_CMP_EQ, 1); \ - } else { \ - shmem_wait_until(&sig_addr, SHMEM_CMP_EQ, 1); \ - shmem_put_signal(SHMEM_CTX_DEFAULT, remote, remote, 10, &sig_addr, (uint64_t) 1,\ - atomic_op, (mype + 1) % npes); \ - } \ - } \ - else { \ - if (mype == 0) { \ - shmem_put_signal(remote, local, 10, &sig_addr, (uint64_t) 1, atomic_op, \ - (mype + 1) % npes); \ - shmem_wait_until(&sig_addr, SHMEM_CMP_EQ, 1); \ - } else { \ - shmem_wait_until(&sig_addr, SHMEM_CMP_EQ, 1); \ - shmem_put_signal(remote, remote, 10, &sig_addr, (uint64_t) 1, atomic_op, \ - (mype + 1) % npes); \ - } \ - } \ - break; \ - case PUT_SIGNAL_NBI: \ - if (USE_CTX) { \ - if (mype == 0) { \ - for (int i = 0; i < npes; i++) { \ - shmem_put_signal_nbi(SHMEM_CTX_DEFAULT, remote, local, 10, &sig_addr, \ - (uint64_t) 1, atomic_op, i); \ - } \ - shmem_quiet(); \ - } \ - shmem_wait_until(&sig_addr, SHMEM_CMP_EQ, 1); \ - } else { \ - if (mype == 0) { \ - for (int i = 0; i < npes; i++) { \ - shmem_put_signal_nbi(remote, local, 10, &sig_addr, (uint64_t) 1, \ - atomic_op, i); \ - } \ - shmem_quiet(); \ - } \ - shmem_wait_until(&sig_addr, SHMEM_CMP_EQ, 1); \ - } \ - break; \ - default: \ - printf("Invalid operation (%d)\n", OP); \ - shmem_global_exit(1); \ - } \ - sig_addr = 0; \ - shmem_barrier_all(); \ - for (int i = 0; i < 10; i++) \ - if (remote[i] != (TYPE)(i)) { \ - printf("PE %i received incorrect value with " \ - "TEST_SHMEM_PUT_SIGNAL(%s, %d, %s)\n", mype, \ - #OP, (int)(USE_CTX), #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - shmem_free(remote); \ - } while (0) - -#else -#define TEST_SHMEM_PUT_SIGNAL(OP, USE_CTX, SIGNAL_OP, TYPE) - -#endif - -int main(int argc, char* argv[]) { - shmem_init(); - - int rc = EXIT_SUCCESS; - - /* Loop over on context usage */ - for (int i = 0; i < 2; i++) { - /* Loop over on atomic ops */ - for (int j = 0; j < 2; j++) { - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL, i, j, float); - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL, i, j, double); - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL, i, j, long double); - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL, i, j, char); - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL, i, j, signed char); - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL, i, j, short); - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL, i, j, int); - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL, i, j, long); - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL, i, j, long long); - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL, i, j, unsigned char); - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL, i, j, unsigned short); - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL, i, j, unsigned int); - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL, i, j, unsigned long); - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL, i, j, unsigned long long); - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL, i, j, int8_t); - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL, i, j, int16_t); - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL, i, j, int32_t); - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL, i, j, int64_t); - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL, i, j, uint8_t); - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL, i, j, uint16_t); - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL, i, j, uint32_t); - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL, i, j, uint64_t); - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL, i, j, size_t); - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL, i, j, ptrdiff_t); - } - } - - /* Loop over on context usage */ - for (int i = 0; i < 2; i++) { - /* Loop over on atomic ops */ - for (int j = 0; j < 2; j++) { - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL_NBI, i, j, float); - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL_NBI, i, j, double); - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL_NBI, i, j, long double); - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL_NBI, i, j, char); - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL_NBI, i, j, signed char); - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL_NBI, i, j, short); - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL_NBI, i, j, int); - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL_NBI, i, j, long); - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL_NBI, i, j, long long); - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL_NBI, i, j, unsigned char); - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL_NBI, i, j, unsigned short); - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL_NBI, i, j, unsigned int); - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL_NBI, i, j, unsigned long); - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL_NBI, i, j, unsigned long long); - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL_NBI, i, j, int8_t); - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL_NBI, i, j, int16_t); - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL_NBI, i, j, int32_t); - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL_NBI, i, j, int64_t); - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL_NBI, i, j, uint8_t); - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL_NBI, i, j, uint16_t); - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL_NBI, i, j, uint32_t); - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL_NBI, i, j, uint64_t); - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL_NBI, i, j, size_t); - TEST_SHMEM_PUT_SIGNAL(PUT_SIGNAL_NBI, i, j, ptrdiff_t); - } - } - - shmem_finalize(); - return rc; -} diff --git a/test/unit/c11_test_shmem_test.c b/test/unit/c11_test_shmem_test.c deleted file mode 100644 index 978c6ab11..000000000 --- a/test/unit/c11_test_shmem_test.c +++ /dev/null @@ -1,80 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include - -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L - -#define TEST_SHMEM_TEST(TYPE) \ - do { \ - static TYPE remote = 0; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - shmem_p(&remote, (TYPE)mype+1, (mype + 1) % npes); \ - while (!shmem_test(&remote, SHMEM_CMP_NE, 0)) ; \ - if (remote != (TYPE)((mype + npes - 1) % npes)+1) { \ - printf("PE %i received incorrect value with " \ - "TEST_SHMEM_TEST(%s)\n", mype, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (0) - -#else -#define TEST_SHMEM_TEST(TYPE) - -#endif - -int main(int argc, char* argv[]) { - shmem_init(); - - int rc = EXIT_SUCCESS; - TEST_SHMEM_TEST(short); - TEST_SHMEM_TEST(int); - TEST_SHMEM_TEST(long); - TEST_SHMEM_TEST(long long); - TEST_SHMEM_TEST(unsigned short); - TEST_SHMEM_TEST(unsigned int); - TEST_SHMEM_TEST(unsigned long); - TEST_SHMEM_TEST(unsigned long long); - TEST_SHMEM_TEST(int32_t); - TEST_SHMEM_TEST(int64_t); - TEST_SHMEM_TEST(uint32_t); - TEST_SHMEM_TEST(uint64_t); - TEST_SHMEM_TEST(size_t); - TEST_SHMEM_TEST(ptrdiff_t); - - shmem_finalize(); - return rc; -} diff --git a/test/unit/c11_test_shmem_wait_until.c b/test/unit/c11_test_shmem_wait_until.c deleted file mode 100644 index cc8e97131..000000000 --- a/test/unit/c11_test_shmem_wait_until.c +++ /dev/null @@ -1,80 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include - -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L - -#define TEST_SHMEM_WAIT_UNTIL(TYPE) \ - do { \ - static TYPE remote = 0; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - shmem_p(&remote, (TYPE)mype+1, (mype + 1) % npes); \ - shmem_wait_until(&remote, SHMEM_CMP_NE, 0); \ - if (remote != (TYPE)((mype + npes - 1) % npes)+1) { \ - printf("PE %i received incorrect value with " \ - "TEST_SHMEM_WAIT_UNTIL(%s)\n", mype, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (0) - -#else -#define TEST_SHMEM_WAIT_UNTIL(TYPE) - -#endif - -int main(int argc, char* argv[]) { - shmem_init(); - - int rc = EXIT_SUCCESS; - TEST_SHMEM_WAIT_UNTIL(short); - TEST_SHMEM_WAIT_UNTIL(int); - TEST_SHMEM_WAIT_UNTIL(long); - TEST_SHMEM_WAIT_UNTIL(long long); - TEST_SHMEM_WAIT_UNTIL(unsigned short); - TEST_SHMEM_WAIT_UNTIL(unsigned int); - TEST_SHMEM_WAIT_UNTIL(unsigned long); - TEST_SHMEM_WAIT_UNTIL(unsigned long long); - TEST_SHMEM_WAIT_UNTIL(int32_t); - TEST_SHMEM_WAIT_UNTIL(int64_t); - TEST_SHMEM_WAIT_UNTIL(uint32_t); - TEST_SHMEM_WAIT_UNTIL(uint64_t); - TEST_SHMEM_WAIT_UNTIL(size_t); - TEST_SHMEM_WAIT_UNTIL(ptrdiff_t); - - shmem_finalize(); - return rc; -} diff --git a/test/unit/c11_test_shmem_wait_until_vector.c b/test/unit/c11_test_shmem_wait_until_vector.c deleted file mode 100644 index 36be03010..000000000 --- a/test/unit/c11_test_shmem_wait_until_vector.c +++ /dev/null @@ -1,165 +0,0 @@ -#include -#include -#include - -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L - -#define TEST_SHMEM_WAIT_UNTIL_ALL(TYPE) \ - do { \ - \ - const int my_pe = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - TYPE *ivars = shmem_calloc(npes, sizeof(TYPE)); \ - int *status = calloc(npes, sizeof(int)); \ - TYPE *cmp_values = malloc(npes * sizeof(TYPE)); \ - \ - int i = 0; \ - int expected_sum = 0; \ - int total_sum = 0; \ - \ - for(i = 0; i - -int aaa, bbb; - -int -main(int argc, char* argv[]) -{ - int me, neighbor; - int ret = 0; - - shmem_init(); - bbb = me = shmem_my_pe(); - neighbor = (me + 1) % shmem_n_pes(); - - shmem_barrier_all(); - - shmem_int_get( &aaa, &bbb, 1, neighbor ); - - shmem_barrier_all(); - - if (aaa != neighbor ) ret = 1; - - shmem_finalize(); - - return ret; -} diff --git a/test/unit/collect.c b/test/unit/collect.c deleted file mode 100644 index 0c350eeef..000000000 --- a/test/unit/collect.c +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include - -#define MAX_NPES 32 - -int32_t src[MAX_NPES]; -int32_t dst[MAX_NPES*MAX_NPES]; - -long pSync[SHMEM_COLLECT_SYNC_SIZE]; - -int main(int argc, char **argv) { - int me, npes; - int i, j, errors = 0; - - shmem_init(); - - me = shmem_my_pe(); - npes = shmem_n_pes(); - - if (npes > MAX_NPES) { - if (me == 0) - printf("Warning: npes > %d, exiting without performing test\n", MAX_NPES); - - shmem_finalize(); - return 0; - } - - for (i = 0; i < SHMEM_COLLECT_SYNC_SIZE; i++) - pSync[i] = SHMEM_SYNC_VALUE; - - for (i = 0; i < MAX_NPES; i++) - src[i] = -1; - - for (i = 0; i < MAX_NPES*MAX_NPES; i++) - dst[i] = -1; - - shmem_barrier_all(); - - /* TEST: All PEs contribute their PE id */ - src[0] = me; - - shmem_int32_collect(SHMEM_TEAM_WORLD, dst, src, 1); - - for (i = 0; i < npes; i++) { - if (dst[i] != i) { - printf("%d: Test 1 error, dst[%d] == %"PRId32", expected %d\n", - me, i, dst[i], i); - ++errors; - } - } - - shmem_barrier_all(); - - /* TEST: Even PEs contribute their PE id */ - src[0] = me; - - shmem_team_t new_team; - shmem_team_split_strided(SHMEM_TEAM_WORLD, 0, 2, npes/2 + npes%2, NULL, 0, &new_team); - if (new_team != SHMEM_TEAM_INVALID) { - shmem_int32_collect(new_team, dst, src, 1); - - for (i = 0; i < npes/2; i++) { - if (dst[i] != i*2) { - printf("%d: Test 2 error, dst[%d] == %"PRId32", expected %d\n", - me, i, dst[i], i); - ++errors; - } - } - } - - shmem_barrier_all(); - - /* TEST: All PEs contribute a number of elements equal to PE id */ - for (i = 0; i < me; i++) - src[i] = me+1; - - shmem_int32_collect(SHMEM_TEAM_WORLD, dst, src, me); - - int idx = 0; - for (i = 0; i < npes; i++) { - for (j = 0; j < i; j++) { - if (dst[idx] != i+1) { - printf("%d: Test 3 error, dst[%d] == %"PRId32", expected %d\n", - me, idx, dst[idx], i+1); - ++errors; - } - ++idx; - } - } - - shmem_finalize(); - - return errors != 0; -} diff --git a/test/unit/collect_active_set.c b/test/unit/collect_active_set.c deleted file mode 100644 index cd968c8fe..000000000 --- a/test/unit/collect_active_set.c +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include - -#define MAX_NPES 32 - -#ifdef ENABLE_DEPRECATED_TESTS -long collect_psync[SHMEM_COLLECT_SYNC_SIZE]; - -/* Note: Need to alternate psync arrays because the active set changes */ -long barrier_psync0[SHMEM_BARRIER_SYNC_SIZE]; -long barrier_psync1[SHMEM_BARRIER_SYNC_SIZE]; -#endif - -int64_t src[MAX_NPES]; -int64_t dst[MAX_NPES*MAX_NPES]; - -/* Validate broadcasted data */ -static int validate_data(int i, int me, int npes) { - int idx = 0; - int errors = 0; - /* Validate destination buffer data */ - for (int j = 0; j < npes - i; j++) { - for (int k = 0; k < i+j; k++, idx++) { - if (dst[idx] != i+j) { - printf("%d: Expected dst[%d] = %d, got dst[%d] = %"PRId64", iteration %d\n", - me, idx, i+j, idx, dst[idx], i); - errors++; - } - } - } - - /* Validate unused destination buffer */ - for ( ; idx < MAX_NPES*MAX_NPES; idx++) { - if (dst[idx] != -1) { - printf("%d: Expected dst[%d] = %d, got dst[%d] = %"PRId64", iteration %d\n", - me, idx, -1, idx, dst[idx], i); - errors++; - } - } - - /* Reset for next iteration */ - for (int j = 0; j < MAX_NPES*MAX_NPES; j++) - dst[j] = -1; - - return errors; -} - -int main(void) -{ - int i, me, npes; - int errors = 0; - - shmem_init(); - - me = shmem_my_pe(); - npes = shmem_n_pes(); - - if (npes > MAX_NPES) { - if (me == 0) - printf("Test requires fewer than %d PEs\n", MAX_NPES); - shmem_finalize(); - return 0; - } - - for (i = 0; i < MAX_NPES; i++) - src[i] = me; - - for (i = 0; i < MAX_NPES*MAX_NPES; i++) - dst[i] = -1; - -#ifdef ENABLE_DEPRECATED_TESTS - for (i = 0; i < SHMEM_COLLECT_SYNC_SIZE; i++) - collect_psync[i] = SHMEM_SYNC_VALUE; - - for (i = 0; i < SHMEM_BARRIER_SYNC_SIZE; i++) { - barrier_psync0[i] = SHMEM_SYNC_VALUE; - barrier_psync1[i] = SHMEM_SYNC_VALUE; - } -#endif - - if (me == 0) - printf("Shrinking active set test\n"); - - shmem_barrier_all(); - - /* A total of npes tests are performed, where the active set in each test - * includes PEs i..npes-1 and each PE contributes PE ID elements */ -#ifdef ENABLE_DEPRECATED_TESTS - for (i = 0; i <= me; i++) { - if (me == i) - printf(" + active set size %d\n", npes-i); - - shmem_collect64(dst, src, me, i, 0, npes-i, collect_psync); - errors += validate_data(i, me, npes); - - shmem_barrier(i, 0, npes-i, (i % 2) ? barrier_psync0 : barrier_psync1); - } -#else - shmem_team_t new_team; - for (i = 0; i < npes; i++) { - if (me == i) - printf(" + active set size %d\n", npes-i); - - shmem_team_split_strided(SHMEM_TEAM_WORLD, i, 1, npes-i, NULL, 0, &new_team); - if (new_team != SHMEM_TEAM_INVALID) { - shmem_int64_collect(new_team, dst, src, me); - errors += validate_data(i, me, npes); - } - shmem_barrier_all(); - } -#endif - - shmem_finalize(); - - return errors != 0; -} diff --git a/test/unit/complex_reductions_f.f90 b/test/unit/complex_reductions_f.f90 deleted file mode 100644 index 77e11e63f..000000000 --- a/test/unit/complex_reductions_f.f90 +++ /dev/null @@ -1,248 +0,0 @@ -! -! Copyright (c) 2017 Intel Corporation. All rights reserved. -! This software is available to you under the BSD license below: -! -! Redistribution and use in source and binary forms, with or -! without modification, are permitted provided that the following -! conditions are met: -! -! - Redistributions of source code must retain the above -! copyright notice, this list of conditions and the following -! disclaimer. -! -! - Redistributions in binary form must reproduce the above -! copyright notice, this list of conditions and the following -! disclaimer in the documentation and/or other materials -! provided with the distribution. -! -! THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -! EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -! MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -! NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -! BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -! ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -! CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -! SOFTWARE. -! - - program complex_reductions_f - implicit none - include "shmem.fh" - - integer psync(shmem_reduce_sync_size), i, j, nr - data psync /shmem_reduce_sync_size*shmem_sync_value/ - parameter (nr=10) - complex(kind=4) z_src(nr), z_target(nr) - complex(kind=4) pwrk(max(nr/2+1,shmem_reduce_min_wrkdata_size)) - complex(kind=8) zd_src(nr), zd_target(nr) - complex(kind=8) pwrkd(max(nr/2+1,shmem_reduce_min_wrkdata_size)) - common /com/ z_src, z_target, pwrk - common /com/ zd_src, zd_target, pwrkd - integer shmem_my_pe, shmem_n_pes, npes, me - complex(kind=4) exp_result(nr) - complex(kind=8) exp_result_d(nr) - - - call shmem_init() - - npes = shmem_n_pes() - me = shmem_my_pe() - - ! Set up the source buffer and calculate the expected sum reduction result: - do i=1,nr - z_src(i) = cmplx(me,me+1) - exp_result(i) = z_src(i) - do j=0,npes-1 - if (j .ne. me) then - exp_result(i) = exp_result(i) + cmplx(j,j+1) - end if - end do - end do - - ! Test single precision complex sum_to_all reductions: - call shmem_comp4_sum_to_all(z_target, z_src, nr, 0, 0, npes, pwrk, psync) - - ! Check the result: - call check_result_complex(z_target, exp_result, nr, 1) - - call shmem_barrier_all() - - ! Test single precision complex sum reduction on a PE subset with a stride of 2 - if ( mod(me,2) .eq. 0) then - if ( mod(shmem_n_pes(),2) .eq. 0) then - - call shmem_comp4_sum_to_all(z_target, z_src, nr, 0, 1, npes/2, pwrk, psync) - - do i=1,nr - exp_result(i) = z_src(i) - do j=0,npes-1,2 - if (j .ne. me) then - exp_result(i) = exp_result(i) + cmplx(j,j+1) - end if - end do - end do - - call check_result_complex(z_target, exp_result, nr, 2) - - endif - endif - - call shmem_barrier_all() - - ! Initialize the double precision buffers and expected result - do i=1,nr - zd_src(i) = dcmplx(-7.123123123123123123123, 2.32132132132132132132) - exp_result_d(i) = zd_src(i)*npes - end do - - ! Test double precision complex sum_to_all reductions: - call shmem_comp8_sum_to_all(zd_target, zd_src, nr, 0, 0, npes, pwrkd, psync) - - call check_result_complex_dbl(zd_target, exp_result_d, nr, 3) - - call shmem_barrier_all() - - ! Test double precision sum reductions on a PE subset with a stride of 2 - if ( mod(me,2) .eq. 0) then - if ( mod(shmem_n_pes(),2) .eq. 0) then - - call shmem_comp8_sum_to_all(zd_target, zd_src, nr, 0, 1, npes/2, pwrkd, psync) - - do i=1,nr - exp_result_d(i) = zd_src(i)*(npes/2) - end do - - call check_result_complex_dbl(zd_target, exp_result_d, nr, 4) - - endif - endif - - call shmem_barrier_all() - - ! Re-initialize the source and expected result buffers for single precision - do i=1,nr - z_src(i) = cmplx(me,me+1) - exp_result(i) = z_src(i) - do j=0,npes-1 - if (j .ne. me) then - exp_result(i) = exp_result(i) * cmplx(j,j+1) - end if - end do - end do - - ! Test single precision complex product_to_all reductions: - call shmem_comp4_prod_to_all(z_target, z_src, nr, 0, 0, npes, pwrk, psync) - - ! Check the result: - call check_result_complex(z_target, exp_result, nr, 5) - - call shmem_barrier_all() - - ! Test single precision product reduction on a PE subset with a stride of 2 - if ( mod(me,2) .eq. 0) then - if ( mod(shmem_n_pes(),2) .eq. 0) then - - call shmem_comp4_prod_to_all(z_target, z_src, nr, 0, 1, npes/2, pwrk, psync) - - do i=1,nr - exp_result(i) = z_src(i) - do j=0,npes-1,2 - if (j .ne. me) then - exp_result(i) = exp_result(i) * cmplx(j,j+1) - end if - end do - end do - - call check_result_complex(z_target, exp_result, nr, 6) - - endif - endif - - call shmem_barrier_all() - - ! Re-initialize the double precision buffers and expected result - do i=1,nr - zd_src(i) = dcmplx(me, me+1) - exp_result_d(i) = zd_src(i) - do j=0,npes-1 - if (j .ne. me) then - exp_result_d(i) = exp_result_d(i) * dcmplx(j,j+1) - end if - end do - end do - - ! Test double precision complex product_to_all reductions: - call shmem_comp8_prod_to_all(zd_target, zd_src, nr, 0, 0, npes, pwrkd, psync) - - call check_result_complex_dbl(zd_target, exp_result_d, nr, 7) - - call shmem_barrier_all() - - ! Test double precision product reduction on a PE subset with a stride of 2 - if ( mod(me,2) .eq. 0) then - if ( mod(shmem_n_pes(),2) .eq. 0) then - - call shmem_comp8_prod_to_all(zd_target, zd_src, nr, 0, 1, npes/2, pwrkd, psync) - - do i=1,nr - exp_result_d(i) = zd_src(i) - do j=0,npes-1,2 - if (j .ne. me) then - exp_result_d(i) = exp_result_d(i) * dcmplx(j,j+1) - end if - end do - end do - - call check_result_complex_dbl(zd_target, exp_result_d, nr, 8) - - endif - endif - - call shmem_finalize() - - contains - - ! Checks that real and imaginary components are within 1/1000th of - ! a percent of the expected value: - subroutine check_result_complex(z_target, correct, N, id) - implicit none - integer N, id, me - complex(kind=4) z_target(N), correct(N) - - me = shmem_my_pe() - do i=1,N - if ( abs(1 - real(z_target(i)) / real(correct(i))) .gt. 1e-5 ) then - print *, "fail : incorrect real component ", real(z_target(i)), & - " expected ", real(correct(i)), " on process ", me, "test #", id - call shmem_global_exit(id) - endif - if ( abs(1 - aimag(z_target(i)) / aimag(correct(i))) .gt. 1e-5 ) then - print *, "fail : incorrect imaginary component ", aimag(z_target(i)), & - " expected ", aimag(correct(i)), " on process ", me, "test #", id - call shmem_global_exit(id) - endif - end do - - end subroutine check_result_complex - - subroutine check_result_complex_dbl(zd_target, correct, N, id) - implicit none - integer N, id, me - complex(kind=8) zd_target(N), correct(N) - - me = shmem_my_pe() - do i=1,N - if ( abs(1 - real(zd_target(i)) / real(correct(i))) .gt. 1e-5 ) then - print *, "fail : incorrect real component ", real(zd_target(i)), & - " expected ", real(correct(i)), " on process ", me, "test #", id - call shmem_global_exit(id) - endif - if ( abs(1 - aimag(zd_target(i)) / aimag(correct(i))) .gt. 1e-5 ) then - print *, "fail : incorrect imaginary component ", aimag(zd_target(i)), & - " expected ", aimag(correct(i)), " on process ", me, "test #", id - call shmem_global_exit(id) - endif - end do - end subroutine check_result_complex_dbl - - end program complex_reductions_f diff --git a/test/unit/cswap.c b/test/unit/cswap.c deleted file mode 100644 index cd48d1c3f..000000000 --- a/test/unit/cswap.c +++ /dev/null @@ -1,326 +0,0 @@ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - * exercise: - * shmem_*_cswap() - * shmem_*_fadd() - * shmem_*_finc() - */ -#include - -#include -#include -#include - -#define Vprintf if (Verbose) printf - -static int *src_int; -static long *src_long; -static long long *src_llong; - -static int dst_int, itmp; -static long dst_long, ltmp; -static long long dst_llong, lltmp; - -static int loops = 5; - -int -main(int argc, char* argv[]) -{ - int me, num_pes, l, pe; - int Verbose = 0; - - shmem_init(); - me = shmem_my_pe(); - num_pes = shmem_n_pes(); - - if (num_pes == 1) { - printf("%s: Requires number of PEs > 1\n", argv[0]); - shmem_finalize(); - return 0; - } - - for (l = 0 ; l < loops ; ++l) { - - if ((src_int = shmem_malloc(sizeof(int))) == NULL) { - printf("PE-%d int shmem_malloc() failed?\n", me); - shmem_global_exit(1); - } - *src_int = 4; - dst_int = itmp = 0; - - if ((src_long = shmem_malloc(sizeof(long))) == NULL) { - printf("PE-%d long shmem_malloc() failed?\n", me); - shmem_global_exit(1); - } - *src_long = 8; - dst_long = ltmp = 0; - - if ((src_llong = shmem_malloc(sizeof(long long))) == NULL) { - printf("PE-%d long long shmem_malloc() failed?\n", me); - shmem_global_exit(1); - } - *src_llong = 16; - dst_llong = lltmp = 0; - - //printf("PE-%d malloc()s done.\n",me); - shmem_barrier_all(); - - if ( me == 0 ) { - /* integer swap */ - itmp = shmem_int_g(src_int,1); - Vprintf("PE-0 Initial Conditions(int) local %d rem(%d)\n", - dst_int,itmp); - - dst_int = shmem_int_atomic_compare_swap(src_int,*src_int,0,1); - if (dst_int != 4) { - printf("PE-%d dst_int %d != 4?\n",me,dst_int); - shmem_global_exit(1); - } - /* verify remote data */ - itmp = shmem_int_g(src_int,1); - if (itmp != 0) { - printf("PE-%d rem %d != 0?\n",me,itmp); - shmem_global_exit(1); - } - Vprintf("PE-0 1st int_cswap done: local %d rem(%d)\n",dst_int,itmp); - - dst_int = shmem_int_atomic_compare_swap(src_int,0,dst_int,1); - if (dst_int != 0) { - printf("PE-%d dst_int %d != 0?\n",me,dst_int); - shmem_global_exit(1); - } - /* verify remote data */ - itmp = shmem_int_g(src_int,1); - if (itmp != 4) { - printf("PE-%d rem %d != 4?\n",me,itmp); - shmem_global_exit(1); - } - Vprintf("PE-0 2nd int_swap done: local %d rem(%d)\n",dst_int,itmp); - - /* cswap() should not swap as cond(0) != remote(4) */ - dst_int = shmem_int_atomic_compare_swap(src_int,0,0,1); - if (dst_int != 4) { - printf("PE-%d int no-swap returned dst_int %d != 4?\n", - me,dst_int); - shmem_global_exit(1); - } - /* verify previous cswap() did not swap */ - itmp = shmem_int_g(src_int,1); - if (itmp != 4) { - printf("PE-%d failed cond int_cswap() swapped? rem(%d) != 4?\n", - me,itmp); - shmem_global_exit(1); - } - - /* long swap */ - ltmp = shmem_long_g(src_long,1); - Vprintf("PE-0 Initial Conditions(long) local %ld rem(%ld)\n", - dst_long,ltmp); - - dst_long = shmem_long_atomic_compare_swap(src_long,*src_long,0,1); - if (dst_long != 8) { - printf("PE-%d dst_long %ld != 8?\n",me,dst_long); - shmem_global_exit(1); - } - /* verify remote data */ - ltmp = shmem_long_g(src_long,1); - if (ltmp != 0) { - printf("PE-%d long rem(%ld) != 0?\n",me,ltmp); - shmem_global_exit(1); - } - Vprintf("PE-0 1st long_cswap done: local %ld rem(%ld)\n", - dst_long,ltmp); - - dst_long = shmem_long_atomic_compare_swap(src_long,0,dst_long,1); - if (dst_long != 0) { - printf("PE-%d dst_long %ld != 0?\n",me,dst_long); - shmem_global_exit(1); - } - /* verify remote data */ - ltmp = shmem_long_g(src_long,1); - if (ltmp != 8) { - printf("PE-%d long rem(%ld) != 8?\n",me,ltmp); - shmem_global_exit(1); - } - Vprintf("PE-0 2nd long_swap done: local %ld rem(%ld)\n", - dst_long,ltmp); - - /* cswap() should not swap as cond(0) != remote(8) */ - dst_long = shmem_long_atomic_compare_swap(src_long,0,0,1); - if (dst_long != 8) { - printf("PE-%d long no-swap returned dst_long %ld != 8?\n", - me,dst_long); - shmem_global_exit(1); - } - /* verify previous cswap() did not swap */ - ltmp = shmem_long_g(src_long,1); - if (ltmp != 8) { - printf("PE-%d failed cond long_cswap() swapped? rem(%ld) != 8?\n", - me,ltmp); - shmem_global_exit(1); - } - - /* long long swap */ - lltmp = shmem_longlong_g(src_llong,1); - Vprintf("PE-0 Initial Conditions(long long) local %lld rem(%lld)\n", - dst_llong,lltmp); - - dst_llong = shmem_longlong_atomic_compare_swap(src_llong,*src_llong,0,1); - if (dst_llong != 16) { - printf("PE-%d dst_llong %lld != 16?\n",me,dst_llong); - shmem_global_exit(1); - } - /* verify remote data */ - lltmp = shmem_longlong_g(src_llong,1); - if (lltmp != 0) { - printf("PE-%d longlong rem(%lld) != 0?\n",me,lltmp); - shmem_global_exit(1); - } - Vprintf("PE-0 1st longlong_cswap done: local %lld rem(%lld)\n", - dst_llong, lltmp); - - dst_llong = shmem_longlong_atomic_compare_swap(src_llong,0,dst_llong,1); - if (dst_llong != 0) { - printf("PE-%d dst_llong %lld != 0?\n",me,dst_llong); - shmem_global_exit(1); - } - /* verify remote data */ - lltmp = shmem_longlong_g(src_llong,1); - if (lltmp != 16) { - printf("PE-%d long long rem(%lld) != 16?\n",me,lltmp); - shmem_global_exit(1); - } - Vprintf("PE-0 2nd longlong_swap done: local %lld rem(%lld)\n", - dst_llong,lltmp); - - /* cswap() should not swap as cond(0) != remote(8) */ - dst_llong = shmem_longlong_atomic_compare_swap(src_llong,0,0,1); - if (dst_llong != 16) { - printf("PE-%d longlong no-swap returned dst_llong %lld != 16?\n", - me,dst_llong); - shmem_global_exit(1); - } - /* verify previous cswap() did not swap */ - lltmp = shmem_longlong_g(src_llong,1); - if (lltmp != 16) { - printf("PE-0 failed cond longlong_cswap() swapped? rem(%lld) != 16?\n", - lltmp); - shmem_global_exit(1); - } - } - else { - if (!shmem_addr_accessible(src_int,0)) { - printf("PE-%d local src_int %p not accessible from PE-%d?\n", - me, (void*)src_int, 0); - shmem_global_exit(1); - } - if (!shmem_addr_accessible(src_long,0)) { - printf("PE-%d local src_long %p not accessible from PE-%d?\n", - me, (void*)src_long, 0); - shmem_global_exit(1); - } - if (!shmem_addr_accessible(src_llong,0)) { - printf("PE-%d local src_llong %p not accessible from PE-%d?\n", - me, (void*)src_llong, 0); - shmem_global_exit(1); - } - } - shmem_barrier_all(); - - /* shmem_*fadd() exercise */ - - if (me == 0) { - itmp = 0; - ltmp = 0; - lltmp = 0; - *src_int = 0; - *src_long = 0; - *src_llong = 0; - } - shmem_barrier_all(); - - (void)shmem_int_atomic_fetch_add( &itmp, me+1, 0 ); - (void)shmem_long_atomic_fetch_add( <mp, me+1, 0 ); - (void)shmem_longlong_atomic_fetch_add( &lltmp, me+1, 0 ); - - shmem_barrier_all(); - - if (me == 0) { - int tot; - - for(pe=0,tot=0; pe < num_pes; pe++) - tot += pe+1; - - if ( itmp != tot ) - printf("fadd() total %d != expected %d?\n",itmp,tot); - - if ( ltmp != (long)tot ) - printf("fadd() total %ld != expected %d?\n",ltmp,tot); - - if ( lltmp != (long long)tot ) - printf("fadd() total %lld != expected %d?\n",lltmp,tot); - } - shmem_barrier_all(); - - (void)shmem_int_atomic_fetch_inc(src_int,0); - (void)shmem_long_atomic_fetch_inc(src_long,0); - (void)shmem_longlong_atomic_fetch_inc(src_llong,0); - - shmem_barrier_all(); - - if (me == 0) { - int tot = num_pes; - - if ( *src_int != tot ) - printf("finc() total %d != expected %d?\n",*src_int,tot); - - if ( *src_long != (long)tot ) - printf("finc() total %ld != expected %d?\n",*src_long,tot); - - if ( *src_llong != (long long)tot ) - printf("finc() total %lld != expected %d?\n",*src_llong,tot); - } - shmem_barrier_all(); - - shmem_free(src_int); - shmem_free(src_long); - shmem_free(src_llong); - } - - if (Verbose) - fprintf(stderr,"[%d] exit\n",shmem_my_pe()); - - shmem_finalize(); - - return 0; -} diff --git a/test/unit/cxx_shmem_test_all.c b/test/unit/cxx_shmem_test_all.c deleted file mode 100644 index 847fe58b9..000000000 --- a/test/unit/cxx_shmem_test_all.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2018 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * This test is derived from an example provided in the OpenSHMEM 1.4 - * specification. Additional copyrights may apply. - * - */ - -#include - -int main(void) -{ - shmem_init(); - int mype = shmem_my_pe(); - int npes = shmem_n_pes(); - - int *flags = shmem_calloc(npes, sizeof(int)); - int *status = NULL; - - for (int i = 0; i < npes; i++) - shmem_int_p(&flags[mype], 1, i); - - while (!shmem_int_test_all(flags, npes, status, SHMEM_CMP_EQ, 1)); - - /* Check the flags array */ - for (int i = 0; i < npes; i++) { - if (flags[i] != 1) - shmem_global_exit(1); - } - shmem_free(flags); - shmem_finalize(); - return 0; -} diff --git a/test/unit/cxx_test_shmem_atomic_add.cpp b/test/unit/cxx_test_shmem_atomic_add.cpp deleted file mode 100644 index b18e2e571..000000000 --- a/test/unit/cxx_test_shmem_atomic_add.cpp +++ /dev/null @@ -1,246 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include - - -enum op { ADD = 0, ATOMIC_ADD, CTX_ATOMIC_ADD, FADD, ATOMIC_FETCH_ADD, - CTX_ATOMIC_FETCH_ADD, ATOMIC_FETCH_ADD_NBI, CTX_ATOMIC_FETCH_ADD_NBI }; - -#ifdef ENABLE_DEPRECATED_TESTS -#define DEPRECATED_ADD(TYPENAME, ...) shmem_##TYPENAME##_add(__VA_ARGS__) -#define DEPRECATED_FADD(TYPENAME, ...) shmem_##TYPENAME##_fadd(__VA_ARGS__) -#else -#define DEPRECATED_ADD(TYPENAME, ...) shmem_##TYPENAME##_atomic_add(__VA_ARGS__) -#define DEPRECATED_FADD(TYPENAME, ...) shmem_##TYPENAME##_atomic_fetch_add(__VA_ARGS__) -#endif - -#define SHMEM_NBI_OPS_CASES(OP, TYPE, TYPENAME) \ - case ATOMIC_FETCH_ADD_NBI: \ - shmem_##TYPENAME##_atomic_fetch_add_nbi(&old, &remote, \ - (TYPE)(mype + 1), i); \ - shmem_quiet(); \ - if (old > (TYPE)(npes * (npes + 1) / 2)) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - case CTX_ATOMIC_FETCH_ADD_NBI: \ - shmem_ctx_##TYPENAME##_atomic_fetch_add_nbi(SHMEM_CTX_DEFAULT,\ - &old, &remote, (TYPE)(mype + 1), i);\ - shmem_quiet(); \ - if (old > (TYPE)(npes * (npes + 1) / 2)) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; - -#define TEST_SHMEM_ADD(OP, TYPE, TYPENAME) \ - do { \ - static TYPE remote; \ - TYPE old; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - remote = (TYPE)0; \ - shmem_barrier_all(); \ - for (int i = 0; i < npes; i++) \ - switch (OP) { \ - case ADD: \ - DEPRECATED_ADD(TYPENAME, &remote, (TYPE)(mype + 1), i); \ - break; \ - case ATOMIC_ADD: \ - shmem_##TYPENAME##_atomic_add(&remote, (TYPE)(mype + 1), i); \ - break; \ - case CTX_ATOMIC_ADD: \ - shmem_ctx_##TYPENAME##_atomic_add(SHMEM_CTX_DEFAULT, &remote, \ - (TYPE)(mype + 1), i); \ - break; \ - case FADD: \ - old = DEPRECATED_FADD(TYPENAME, &remote, (TYPE)(mype + 1), i);\ - if (old > (TYPE)(npes * (npes + 1) / 2)) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - case ATOMIC_FETCH_ADD: \ - old = shmem_##TYPENAME##_atomic_fetch_add(&remote, \ - (TYPE)(mype + 1), i);\ - if (old > (TYPE)(npes * (npes + 1) / 2)) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - case CTX_ATOMIC_FETCH_ADD: \ - old = shmem_ctx_##TYPENAME##_atomic_fetch_add( \ - SHMEM_CTX_DEFAULT, &remote, (TYPE)(mype + 1), i); \ - if (old > (TYPE)(npes * (npes + 1) / 2)) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - SHMEM_NBI_OPS_CASES(OP, TYPE, TYPENAME) \ - default: \ - printf("Invalid operation (%d)\n", OP); \ - shmem_global_exit(1); \ - } \ - shmem_barrier_all(); \ - if (remote != (TYPE)(npes * (npes + 1) / 2)) { \ - printf("PE %i observed error with TEST_SHMEM_ADD(%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (false) - - -int main(int argc, char* argv[]) { - shmem_init(); - - int rc = EXIT_SUCCESS; - -#ifdef ENABLE_DEPRECATED_TESTS - TEST_SHMEM_ADD(ADD, int, int); - TEST_SHMEM_ADD(ADD, long, long); - TEST_SHMEM_ADD(ADD, long long, longlong); - TEST_SHMEM_ADD(ADD, unsigned int, uint); - TEST_SHMEM_ADD(ADD, unsigned long, ulong); - TEST_SHMEM_ADD(ADD, unsigned long long, ulonglong); - TEST_SHMEM_ADD(ADD, int32_t, int32); - TEST_SHMEM_ADD(ADD, int64_t, int64); - TEST_SHMEM_ADD(ADD, uint32_t, uint32); - TEST_SHMEM_ADD(ADD, uint64_t, uint64); - TEST_SHMEM_ADD(ADD, size_t, size); - TEST_SHMEM_ADD(ADD, ptrdiff_t, ptrdiff); - - TEST_SHMEM_ADD(FADD, int, int); - TEST_SHMEM_ADD(FADD, long, long); - TEST_SHMEM_ADD(FADD, long long, longlong); - TEST_SHMEM_ADD(FADD, unsigned int, uint); - TEST_SHMEM_ADD(FADD, unsigned long, ulong); - TEST_SHMEM_ADD(FADD, unsigned long long, ulonglong); - TEST_SHMEM_ADD(FADD, int32_t, int32); - TEST_SHMEM_ADD(FADD, int64_t, int64); - TEST_SHMEM_ADD(FADD, uint32_t, uint32); - TEST_SHMEM_ADD(FADD, uint64_t, uint64); - TEST_SHMEM_ADD(FADD, size_t, size); - TEST_SHMEM_ADD(FADD, ptrdiff_t, ptrdiff); -#endif /* ENABLE_DEPRECATED_TESTS */ - - TEST_SHMEM_ADD(ATOMIC_ADD, int, int); - TEST_SHMEM_ADD(ATOMIC_ADD, long, long); - TEST_SHMEM_ADD(ATOMIC_ADD, long long, longlong); - TEST_SHMEM_ADD(ATOMIC_ADD, unsigned int, uint); - TEST_SHMEM_ADD(ATOMIC_ADD, unsigned long, ulong); - TEST_SHMEM_ADD(ATOMIC_ADD, unsigned long long, ulonglong); - TEST_SHMEM_ADD(ATOMIC_ADD, int32_t, int32); - TEST_SHMEM_ADD(ATOMIC_ADD, int64_t, int64); - TEST_SHMEM_ADD(ATOMIC_ADD, uint32_t, uint32); - TEST_SHMEM_ADD(ATOMIC_ADD, uint64_t, uint64); - TEST_SHMEM_ADD(ATOMIC_ADD, size_t, size); - TEST_SHMEM_ADD(ATOMIC_ADD, ptrdiff_t, ptrdiff); - - TEST_SHMEM_ADD(CTX_ATOMIC_ADD, int, int); - TEST_SHMEM_ADD(CTX_ATOMIC_ADD, long, long); - TEST_SHMEM_ADD(CTX_ATOMIC_ADD, long long, longlong); - TEST_SHMEM_ADD(CTX_ATOMIC_ADD, unsigned int, uint); - TEST_SHMEM_ADD(CTX_ATOMIC_ADD, unsigned long, ulong); - TEST_SHMEM_ADD(CTX_ATOMIC_ADD, unsigned long long, ulonglong); - TEST_SHMEM_ADD(CTX_ATOMIC_ADD, int32_t, int32); - TEST_SHMEM_ADD(CTX_ATOMIC_ADD, int64_t, int64); - TEST_SHMEM_ADD(CTX_ATOMIC_ADD, uint32_t, uint32); - TEST_SHMEM_ADD(CTX_ATOMIC_ADD, uint64_t, uint64); - TEST_SHMEM_ADD(CTX_ATOMIC_ADD, size_t, size); - TEST_SHMEM_ADD(CTX_ATOMIC_ADD, ptrdiff_t, ptrdiff); - - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD, int, int); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD, long, long); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD, long long, longlong); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD, unsigned int, uint); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD, unsigned long, ulong); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD, unsigned long long, ulonglong); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD, int32_t, int32); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD, int64_t, int64); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD, uint32_t, uint32); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD, uint64_t, uint64); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD, size_t, size); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD, ptrdiff_t, ptrdiff); - - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD, int, int); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD, long, long); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD, long long, longlong); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD, unsigned int, uint); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD, unsigned long, ulong); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD, unsigned long long, ulonglong); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD, int32_t, int32); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD, int64_t, int64); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD, uint32_t, uint32); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD, uint64_t, uint64); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD, size_t, size); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD, ptrdiff_t, ptrdiff); - - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD_NBI, int, int); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD_NBI, long, long); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD_NBI, long long, longlong); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD_NBI, unsigned int, uint); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD_NBI, unsigned long, ulong); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD_NBI, unsigned long long, ulonglong); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD_NBI, int32_t, int32); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD_NBI, int64_t, int64); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD_NBI, uint32_t, uint32); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD_NBI, uint64_t, uint64); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD_NBI, size_t, size); - TEST_SHMEM_ADD(ATOMIC_FETCH_ADD_NBI, ptrdiff_t, ptrdiff); - - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD_NBI, int, int); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD_NBI, long, long); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD_NBI, long long, longlong); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD_NBI, unsigned int, uint); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD_NBI, unsigned long, ulong); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD_NBI, unsigned long long, ulonglong); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD_NBI, int32_t, int32); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD_NBI, int64_t, int64); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD_NBI, uint32_t, uint32); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD_NBI, uint64_t, uint64); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD_NBI, size_t, size); - TEST_SHMEM_ADD(CTX_ATOMIC_FETCH_ADD_NBI, ptrdiff_t, ptrdiff); - - shmem_finalize(); - return rc; -} diff --git a/test/unit/cxx_test_shmem_atomic_and.cpp b/test/unit/cxx_test_shmem_atomic_and.cpp deleted file mode 100644 index 3f248507a..000000000 --- a/test/unit/cxx_test_shmem_atomic_and.cpp +++ /dev/null @@ -1,174 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include -#include - -enum op { AND = 0, CTX_AND, FETCH_AND, CTX_FETCH_AND, FETCH_AND_NBI, - CTX_FETCH_AND_NBI }; - -/* Initially, remote = 111...b. Each PE performs an atomic AND where the - * PEth bit of the input value is set to 0 and all other bits are set to 1. - * The result has the NPES least significant bits cleared, 111...000...b. - */ - -#define SHMEM_NBI_OPS_CASES(OP, TYPE, TYPENAME) \ - case FETCH_AND_NBI: \ - shmem_##TYPENAME##_atomic_fetch_and_nbi(&old, &remote, \ - ~(TYPE)(1LLU << mype), i); \ - shmem_quiet(); \ - if ((old & (TYPE)(1LLU << mype)) == 0) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - case CTX_FETCH_AND_NBI: \ - shmem_ctx_##TYPENAME##_atomic_fetch_and_nbi(SHMEM_CTX_DEFAULT,\ - &old, &remote, ~(TYPE)(1LLU << mype), i); \ - shmem_quiet(); \ - if ((old & (TYPE)(1LLU << mype)) == 0) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; - -#define TEST_SHMEM_AND(OP, TYPE, TYPENAME) \ - do { \ - static TYPE remote = ~(TYPE)0; \ - TYPE old = (TYPE)0; \ - if ((size_t) npes-1 > sizeof(TYPE)) break; /* Avoid overflow */ \ - for (int i = 0; i < npes; i++) \ - switch (OP) { \ - case AND: \ - shmem_##TYPENAME##_atomic_and(&remote, \ - ~(TYPE)(1LLU << mype), i); \ - break; \ - case CTX_AND: \ - shmem_ctx_##TYPENAME##_atomic_and(SHMEM_CTX_DEFAULT, &remote, \ - ~(TYPE)(1LLU << mype), i); \ - break; \ - case FETCH_AND: \ - old = shmem_##TYPENAME##_atomic_fetch_and(&remote, \ - ~(TYPE)(1LLU << mype), i); \ - if ((old & (TYPE)(1LLU << mype)) == 0) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - case CTX_FETCH_AND: \ - old = shmem_ctx_##TYPENAME##_atomic_fetch_and( \ - SHMEM_CTX_DEFAULT, &remote, ~(TYPE)(1LLU << mype), i); \ - if ((old & (TYPE)(1LLU << mype)) == 0) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - SHMEM_NBI_OPS_CASES(OP, TYPE, TYPENAME) \ - default: \ - printf("Invalid operation (%d)\n", OP); \ - shmem_global_exit(1); \ - } \ - shmem_barrier_all(); \ - if (remote != ~(TYPE)((1LLU << npes) - 1LLU)) { \ - printf("PE %i observed error with TEST_SHMEM_AND(%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (false) - - -int main(int argc, char* argv[]) { - shmem_init(); - - const int mype = shmem_my_pe(); - const int npes = shmem_n_pes(); - - int rc = EXIT_SUCCESS; - TEST_SHMEM_AND(AND, unsigned int, uint); - TEST_SHMEM_AND(AND, unsigned long, ulong); - TEST_SHMEM_AND(AND, unsigned long long, ulonglong); - TEST_SHMEM_AND(AND, int32_t, int32); - TEST_SHMEM_AND(AND, int64_t, int64); - TEST_SHMEM_AND(AND, uint32_t, uint32); - TEST_SHMEM_AND(AND, uint64_t, uint64); - - TEST_SHMEM_AND(CTX_AND, unsigned int, uint); - TEST_SHMEM_AND(CTX_AND, unsigned long, ulong); - TEST_SHMEM_AND(CTX_AND, unsigned long long, ulonglong); - TEST_SHMEM_AND(CTX_AND, int32_t, int32); - TEST_SHMEM_AND(CTX_AND, int64_t, int64); - TEST_SHMEM_AND(CTX_AND, uint32_t, uint32); - TEST_SHMEM_AND(CTX_AND, uint64_t, uint64); - - TEST_SHMEM_AND(FETCH_AND, unsigned int, uint); - TEST_SHMEM_AND(FETCH_AND, unsigned long, ulong); - TEST_SHMEM_AND(FETCH_AND, unsigned long long, ulonglong); - TEST_SHMEM_AND(FETCH_AND, int32_t, int32); - TEST_SHMEM_AND(FETCH_AND, int64_t, int64); - TEST_SHMEM_AND(FETCH_AND, uint32_t, uint32); - TEST_SHMEM_AND(FETCH_AND, uint64_t, uint64); - - TEST_SHMEM_AND(CTX_FETCH_AND, unsigned int, uint); - TEST_SHMEM_AND(CTX_FETCH_AND, unsigned long, ulong); - TEST_SHMEM_AND(CTX_FETCH_AND, unsigned long long, ulonglong); - TEST_SHMEM_AND(CTX_FETCH_AND, int32_t, int32); - TEST_SHMEM_AND(CTX_FETCH_AND, int64_t, int64); - TEST_SHMEM_AND(CTX_FETCH_AND, uint32_t, uint32); - TEST_SHMEM_AND(CTX_FETCH_AND, uint64_t, uint64); - - TEST_SHMEM_AND(FETCH_AND_NBI, unsigned int, uint); - TEST_SHMEM_AND(FETCH_AND_NBI, unsigned long, ulong); - TEST_SHMEM_AND(FETCH_AND_NBI, unsigned long long, ulonglong); - TEST_SHMEM_AND(FETCH_AND_NBI, int32_t, int32); - TEST_SHMEM_AND(FETCH_AND_NBI, int64_t, int64); - TEST_SHMEM_AND(FETCH_AND_NBI, uint32_t, uint32); - TEST_SHMEM_AND(FETCH_AND_NBI, uint64_t, uint64); - - TEST_SHMEM_AND(CTX_FETCH_AND_NBI, unsigned int, uint); - TEST_SHMEM_AND(CTX_FETCH_AND_NBI, unsigned long, ulong); - TEST_SHMEM_AND(CTX_FETCH_AND_NBI, unsigned long long, ulonglong); - TEST_SHMEM_AND(CTX_FETCH_AND_NBI, int32_t, int32); - TEST_SHMEM_AND(CTX_FETCH_AND_NBI, int64_t, int64); - TEST_SHMEM_AND(CTX_FETCH_AND_NBI, uint32_t, uint32); - TEST_SHMEM_AND(CTX_FETCH_AND_NBI, uint64_t, uint64); - - shmem_finalize(); - return rc; -} diff --git a/test/unit/cxx_test_shmem_atomic_cswap.cpp b/test/unit/cxx_test_shmem_atomic_cswap.cpp deleted file mode 100644 index cbef3e2c3..000000000 --- a/test/unit/cxx_test_shmem_atomic_cswap.cpp +++ /dev/null @@ -1,174 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include - -enum op { CSWAP = 0, ATOMIC_COMPARE_SWAP, CTX_ATOMIC_COMPARE_SWAP, - ATOMIC_COMPARE_SWAP_NBI, CTX_ATOMIC_COMPARE_SWAP_NBI }; - -#ifdef ENABLE_DEPRECATED_TESTS -#define DEPRECATED_CSWAP(TYPENAME,...) shmem_##TYPENAME##_cswap(__VA_ARGS__) -#else -#define DEPRECATED_CSWAP(TYPENAME,...) shmem_##TYPENAME##_atomic_compare_swap(__VA_ARGS__) -#endif - -#define SHMEM_NBI_OPS_CASES(OP, TYPE, TYPENAME) \ - case ATOMIC_COMPARE_SWAP_NBI: \ - shmem_##TYPENAME##_atomic_compare_swap_nbi(&old, &remote, \ - (TYPE)npes, (TYPE)mype, (mype + 1) % npes); \ - break; \ - case CTX_ATOMIC_COMPARE_SWAP_NBI: \ - shmem_ctx_##TYPENAME##_atomic_compare_swap_nbi(SHMEM_CTX_DEFAULT,\ - &old, &remote, (TYPE)npes, (TYPE)mype, (mype + 1) % npes);\ - break; - -#define TEST_SHMEM_CSWAP(OP, TYPE, TYPENAME) \ - do { \ - static TYPE remote; \ - TYPE old; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - remote = npes; \ - shmem_barrier_all(); \ - switch (OP) { \ - case CSWAP: \ - old = DEPRECATED_CSWAP(TYPENAME, &remote, (TYPE)npes, \ - (TYPE)mype, (mype + 1) % npes); \ - break; \ - case ATOMIC_COMPARE_SWAP: \ - old = shmem_##TYPENAME##_atomic_compare_swap(&remote, \ - (TYPE)npes, (TYPE)mype, (mype + 1) % npes); \ - break; \ - case CTX_ATOMIC_COMPARE_SWAP: \ - old = shmem_ctx_##TYPENAME##_atomic_compare_swap( \ - SHMEM_CTX_DEFAULT, &remote, \ - (TYPE)npes, (TYPE)mype, \ - (mype + 1) % npes); \ - break; \ - SHMEM_NBI_OPS_CASES(OP, TYPE, TYPENAME) \ - default: \ - printf("invalid operation (%d)\n", OP); \ - shmem_global_exit(1); \ - } \ - shmem_barrier_all(); \ - if (remote != (TYPE)((mype + npes - 1) % npes)) { \ - printf("PE %i observed error with TEST_SHMEM_CSWAP(%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - if (old != (TYPE) npes) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (false) - - -int main(int argc, char* argv[]) { - shmem_init(); - - int rc = EXIT_SUCCESS; - -#ifdef ENABLE_DEPRECATED_TESTS - TEST_SHMEM_CSWAP(CSWAP, int, int); - TEST_SHMEM_CSWAP(CSWAP, long, long); - TEST_SHMEM_CSWAP(CSWAP, long long, longlong); - TEST_SHMEM_CSWAP(CSWAP, unsigned int, uint); - TEST_SHMEM_CSWAP(CSWAP, unsigned long, ulong); - TEST_SHMEM_CSWAP(CSWAP, unsigned long long, ulonglong); - TEST_SHMEM_CSWAP(CSWAP, int32_t, int32); - TEST_SHMEM_CSWAP(CSWAP, int64_t, int64); - TEST_SHMEM_CSWAP(CSWAP, uint32_t, uint32); - TEST_SHMEM_CSWAP(CSWAP, uint64_t, uint64); - TEST_SHMEM_CSWAP(CSWAP, size_t, size); - TEST_SHMEM_CSWAP(CSWAP, ptrdiff_t, ptrdiff); -#endif /* ENABLE_DEPRECATED_TESTS */ - - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP, int, int); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP, long, long); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP, long long, longlong); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP, unsigned int, uint); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP, unsigned long, ulong); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP, unsigned long long, ulonglong); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP, int32_t, int32); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP, int64_t, int64); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP, uint32_t, uint32); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP, uint64_t, uint64); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP, size_t, size); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP, ptrdiff_t, ptrdiff); - - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP, int, int); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP, long, long); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP, long long, longlong); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP, unsigned int, uint); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP, unsigned long, ulong); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP, unsigned long long, ulonglong); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP, int32_t, int32); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP, int64_t, int64); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP, uint32_t, uint32); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP, uint64_t, uint64); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP, size_t, size); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP, ptrdiff_t, ptrdiff); - - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP_NBI, int, int); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP_NBI, long, long); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP_NBI, long long, longlong); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP_NBI, unsigned int, uint); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP_NBI, unsigned long, ulong); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP_NBI, unsigned long long, ulonglong); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP_NBI, int32_t, int32); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP_NBI, int64_t, int64); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP_NBI, uint32_t, uint32); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP_NBI, uint64_t, uint64); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP_NBI, size_t, size); - TEST_SHMEM_CSWAP(ATOMIC_COMPARE_SWAP_NBI, ptrdiff_t, ptrdiff); - - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP_NBI, int, int); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP_NBI, long, long); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP_NBI, long long, longlong); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP_NBI, unsigned int, uint); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP_NBI, unsigned long, ulong); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP_NBI, unsigned long long, ulonglong); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP_NBI, int32_t, int32); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP_NBI, int64_t, int64); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP_NBI, uint32_t, uint32); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP_NBI, uint64_t, uint64); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP_NBI, size_t, size); - TEST_SHMEM_CSWAP(CTX_ATOMIC_COMPARE_SWAP_NBI, ptrdiff_t, ptrdiff); - - shmem_finalize(); - return rc; -} diff --git a/test/unit/cxx_test_shmem_atomic_fetch.cpp b/test/unit/cxx_test_shmem_atomic_fetch.cpp deleted file mode 100644 index a066bfef0..000000000 --- a/test/unit/cxx_test_shmem_atomic_fetch.cpp +++ /dev/null @@ -1,178 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include - -enum op { FETCH = 0, ATOMIC_FETCH, CTX_ATOMIC_FETCH, ATOMIC_FETCH_NBI, - CTX_ATOMIC_FETCH_NBI }; - -#ifdef ENABLE_DEPRECATED_TESTS -#define DEPRECATED_FETCH(TYPENAME,...) shmem_##TYPENAME##_fetch(__VA_ARGS__) -#else -#define DEPRECATED_FETCH(TYPENAME,...) shmem_##TYPENAME##_atomic_fetch(__VA_ARGS__) -#endif - -#define SHMEM_NBI_OPS_CASES(OP, TYPE, TYPENAME) \ - case ATOMIC_FETCH_NBI: \ - shmem_##TYPENAME##_atomic_fetch_nbi(&val, &remote, \ - (mype + 1) % npes); \ - shmem_quiet(); \ - break; \ - case CTX_ATOMIC_FETCH_NBI: \ - shmem_ctx_##TYPENAME##_atomic_fetch_nbi(SHMEM_CTX_DEFAULT,\ - &val, &remote, (mype + 1) % npes); \ - shmem_quiet(); \ - break; - -#define TEST_SHMEM_FETCH(OP, TYPE, TYPENAME) \ - do { \ - static TYPE remote; \ - TYPE val; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - remote = (TYPE)mype; \ - shmem_barrier_all(); \ - switch (OP) { \ - case FETCH: \ - val = DEPRECATED_FETCH(TYPENAME, &remote, \ - (mype + 1) % npes); \ - break; \ - case ATOMIC_FETCH: \ - val = shmem_##TYPENAME##_atomic_fetch(&remote, \ - (mype + 1) % npes); \ - break; \ - case CTX_ATOMIC_FETCH: \ - val = shmem_ctx_##TYPENAME##_atomic_fetch( \ - SHMEM_CTX_DEFAULT, &remote, (mype + 1) % npes); \ - break; \ - SHMEM_NBI_OPS_CASES(OP, TYPE, TYPENAME) \ - default: \ - printf("Invalid operation (%d)\n", OP); \ - shmem_global_exit(1); \ - } \ - if (val != (TYPE)((mype + 1) % npes)) { \ - printf("PE %i received incorrect value with " \ - "TEST_SHMEM_FETCH(%s, %s)\n", mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (false) - - -int main(int argc, char* argv[]) { - shmem_init(); - - int rc = EXIT_SUCCESS; - -#ifdef ENABLE_DEPRECATED_TESTS - TEST_SHMEM_FETCH(FETCH, float, float); - TEST_SHMEM_FETCH(FETCH, double, double); - TEST_SHMEM_FETCH(FETCH, int, int); - TEST_SHMEM_FETCH(FETCH, long, long); - TEST_SHMEM_FETCH(FETCH, long long, longlong); - TEST_SHMEM_FETCH(FETCH, unsigned int, uint); - TEST_SHMEM_FETCH(FETCH, unsigned long, ulong); - TEST_SHMEM_FETCH(FETCH, unsigned long long, ulonglong); - TEST_SHMEM_FETCH(FETCH, int32_t, int32); - TEST_SHMEM_FETCH(FETCH, int64_t, int64); - TEST_SHMEM_FETCH(FETCH, uint32_t, uint32); - TEST_SHMEM_FETCH(FETCH, uint64_t, uint64); - TEST_SHMEM_FETCH(FETCH, size_t, size); - TEST_SHMEM_FETCH(FETCH, ptrdiff_t, ptrdiff); -#endif /* ENABLE_DEPRECATED_TESTS */ - - TEST_SHMEM_FETCH(ATOMIC_FETCH, float, float); - TEST_SHMEM_FETCH(ATOMIC_FETCH, double, double); - TEST_SHMEM_FETCH(ATOMIC_FETCH, int, int); - TEST_SHMEM_FETCH(ATOMIC_FETCH, long, long); - TEST_SHMEM_FETCH(ATOMIC_FETCH, long long, longlong); - TEST_SHMEM_FETCH(ATOMIC_FETCH, unsigned int, uint); - TEST_SHMEM_FETCH(ATOMIC_FETCH, unsigned long, ulong); - TEST_SHMEM_FETCH(ATOMIC_FETCH, unsigned long long, ulonglong); - TEST_SHMEM_FETCH(ATOMIC_FETCH, int32_t, int32); - TEST_SHMEM_FETCH(ATOMIC_FETCH, int64_t, int64); - TEST_SHMEM_FETCH(ATOMIC_FETCH, uint32_t, uint32); - TEST_SHMEM_FETCH(ATOMIC_FETCH, uint64_t, uint64); - TEST_SHMEM_FETCH(ATOMIC_FETCH, size_t, size); - TEST_SHMEM_FETCH(ATOMIC_FETCH, ptrdiff_t, ptrdiff); - - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH, float, float); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH, double, double); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH, int, int); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH, long, long); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH, long long, longlong); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH, unsigned int, uint); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH, unsigned long, ulong); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH, unsigned long long, ulonglong); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH, int32_t, int32); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH, int64_t, int64); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH, uint32_t, uint32); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH, uint64_t, uint64); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH, size_t, size); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH, ptrdiff_t, ptrdiff); - - TEST_SHMEM_FETCH(ATOMIC_FETCH_NBI, float, float); - TEST_SHMEM_FETCH(ATOMIC_FETCH_NBI, double, double); - TEST_SHMEM_FETCH(ATOMIC_FETCH_NBI, int, int); - TEST_SHMEM_FETCH(ATOMIC_FETCH_NBI, long, long); - TEST_SHMEM_FETCH(ATOMIC_FETCH_NBI, long long, longlong); - TEST_SHMEM_FETCH(ATOMIC_FETCH_NBI, unsigned int, uint); - TEST_SHMEM_FETCH(ATOMIC_FETCH_NBI, unsigned long, ulong); - TEST_SHMEM_FETCH(ATOMIC_FETCH_NBI, unsigned long long, ulonglong); - TEST_SHMEM_FETCH(ATOMIC_FETCH_NBI, int32_t, int32); - TEST_SHMEM_FETCH(ATOMIC_FETCH_NBI, int64_t, int64); - TEST_SHMEM_FETCH(ATOMIC_FETCH_NBI, uint32_t, uint32); - TEST_SHMEM_FETCH(ATOMIC_FETCH_NBI, uint64_t, uint64); - TEST_SHMEM_FETCH(ATOMIC_FETCH_NBI, size_t, size); - TEST_SHMEM_FETCH(ATOMIC_FETCH_NBI, ptrdiff_t, ptrdiff); - - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH_NBI, float, float); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH_NBI, double, double); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH_NBI, int, int); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH_NBI, long, long); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH_NBI, long long, longlong); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH_NBI, unsigned int, uint); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH_NBI, unsigned long, ulong); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH_NBI, unsigned long long, ulonglong); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH_NBI, int32_t, int32); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH_NBI, int64_t, int64); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH_NBI, uint32_t, uint32); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH_NBI, uint64_t, uint64); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH_NBI, size_t, size); - TEST_SHMEM_FETCH(CTX_ATOMIC_FETCH_NBI, ptrdiff_t, ptrdiff); - - shmem_finalize(); - return rc; -} diff --git a/test/unit/cxx_test_shmem_atomic_inc.cpp b/test/unit/cxx_test_shmem_atomic_inc.cpp deleted file mode 100644 index ef95d3390..000000000 --- a/test/unit/cxx_test_shmem_atomic_inc.cpp +++ /dev/null @@ -1,244 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include - -enum op { INC = 0, ATOMIC_INC, CTX_ATOMIC_INC, FINC, ATOMIC_FETCH_INC, - CTX_ATOMIC_FETCH_INC, ATOMIC_FETCH_INC_NBI, - CTX_ATOMIC_FETCH_INC_NBI }; - -#ifdef ENABLE_DEPRECATED_TESTS -#define DEPRECATED_INC(TYPENAME,...) shmem_##TYPENAME##_inc(__VA_ARGS__) -#define DEPRECATED_FINC(TYPENAME,...) shmem_##TYPENAME##_finc(__VA_ARGS__) -#else -#define DEPRECATED_INC(TYPENAME,...) shmem_##TYPENAME##_atomic_inc(__VA_ARGS__) -#define DEPRECATED_FINC(TYPENAME,...) shmem_##TYPENAME##_atomic_fetch_inc(__VA_ARGS__) -#endif - -#define SHMEM_NBI_OPS_CASES(OP, TYPE, TYPENAME) \ - case ATOMIC_FETCH_INC_NBI: \ - shmem_##TYPENAME##_atomic_fetch_inc_nbi(&old, &remote, i); \ - shmem_quiet(); \ - if (old > (TYPE) npes) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - case CTX_ATOMIC_FETCH_INC_NBI: \ - shmem_ctx_##TYPENAME##_atomic_fetch_inc_nbi(SHMEM_CTX_DEFAULT,\ - &old, &remote, i); \ - shmem_quiet(); \ - if (old > (TYPE) npes) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; - -#define TEST_SHMEM_INC(OP, TYPE, TYPENAME) \ - do { \ - static TYPE remote = (TYPE)0; \ - TYPE old; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - remote = (TYPE)0; \ - shmem_barrier_all(); \ - for (int i = 0; i < npes; i++) \ - switch (OP) { \ - case INC: \ - DEPRECATED_INC(TYPENAME, &remote, i); \ - break; \ - case ATOMIC_INC: \ - shmem_##TYPENAME##_atomic_inc(&remote, i); \ - break; \ - case CTX_ATOMIC_INC: \ - shmem_ctx_##TYPENAME##_atomic_inc(SHMEM_CTX_DEFAULT, \ - &remote, i); \ - break; \ - case FINC: \ - old = DEPRECATED_FINC(TYPENAME, &remote, i); \ - if (old > (TYPE) npes) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - case ATOMIC_FETCH_INC: \ - old = shmem_##TYPENAME##_atomic_fetch_inc(&remote, i); \ - if (old > (TYPE) npes) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - case CTX_ATOMIC_FETCH_INC: \ - old = shmem_ctx_##TYPENAME##_atomic_fetch_inc( \ - SHMEM_CTX_DEFAULT, &remote, i); \ - if (old > (TYPE) npes) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - SHMEM_NBI_OPS_CASES(OP, TYPE, TYPENAME) \ - default: \ - printf("Invalid operation (%d)\n", OP); \ - shmem_global_exit(1); \ - } \ - shmem_barrier_all(); \ - if (remote != (TYPE)npes) { \ - printf("PE %i observed error with TEST_SHMEM_INC(%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (false) - - -int main(int argc, char* argv[]) { - shmem_init(); - - int rc = EXIT_SUCCESS; - -#ifdef ENABLE_DEPRECATED_TESTS - TEST_SHMEM_INC(INC, int, int); - TEST_SHMEM_INC(INC, long, long); - TEST_SHMEM_INC(INC, long long, longlong); - TEST_SHMEM_INC(INC, unsigned int, uint); - TEST_SHMEM_INC(INC, unsigned long, ulong); - TEST_SHMEM_INC(INC, unsigned long long, ulonglong); - TEST_SHMEM_INC(INC, int32_t, int32); - TEST_SHMEM_INC(INC, int64_t, int64); - TEST_SHMEM_INC(INC, uint32_t, uint32); - TEST_SHMEM_INC(INC, uint64_t, uint64); - TEST_SHMEM_INC(INC, size_t, size); - TEST_SHMEM_INC(INC, ptrdiff_t, ptrdiff); - - TEST_SHMEM_INC(FINC, int, int); - TEST_SHMEM_INC(FINC, long, long); - TEST_SHMEM_INC(FINC, long long, longlong); - TEST_SHMEM_INC(FINC, unsigned int, uint); - TEST_SHMEM_INC(FINC, unsigned long, ulong); - TEST_SHMEM_INC(FINC, unsigned long long, ulonglong); - TEST_SHMEM_INC(FINC, int32_t, int32); - TEST_SHMEM_INC(FINC, int64_t, int64); - TEST_SHMEM_INC(FINC, uint32_t, uint32); - TEST_SHMEM_INC(FINC, uint64_t, uint64); - TEST_SHMEM_INC(FINC, size_t, size); - TEST_SHMEM_INC(FINC, ptrdiff_t, ptrdiff); -#endif /* ENABLE_DEPRECATED_TESTS */ - - TEST_SHMEM_INC(ATOMIC_INC, int, int); - TEST_SHMEM_INC(ATOMIC_INC, long, long); - TEST_SHMEM_INC(ATOMIC_INC, long long, longlong); - TEST_SHMEM_INC(ATOMIC_INC, unsigned int, uint); - TEST_SHMEM_INC(ATOMIC_INC, unsigned long, ulong); - TEST_SHMEM_INC(ATOMIC_INC, unsigned long long, ulonglong); - TEST_SHMEM_INC(ATOMIC_INC, int32_t, int32); - TEST_SHMEM_INC(ATOMIC_INC, int64_t, int64); - TEST_SHMEM_INC(ATOMIC_INC, uint32_t, uint32); - TEST_SHMEM_INC(ATOMIC_INC, uint64_t, uint64); - TEST_SHMEM_INC(ATOMIC_INC, size_t, size); - TEST_SHMEM_INC(ATOMIC_INC, ptrdiff_t, ptrdiff); - - TEST_SHMEM_INC(CTX_ATOMIC_INC, int, int); - TEST_SHMEM_INC(CTX_ATOMIC_INC, long, long); - TEST_SHMEM_INC(CTX_ATOMIC_INC, long long, longlong); - TEST_SHMEM_INC(CTX_ATOMIC_INC, unsigned int, uint); - TEST_SHMEM_INC(CTX_ATOMIC_INC, unsigned long, ulong); - TEST_SHMEM_INC(CTX_ATOMIC_INC, unsigned long long, ulonglong); - TEST_SHMEM_INC(CTX_ATOMIC_INC, int32_t, int32); - TEST_SHMEM_INC(CTX_ATOMIC_INC, int64_t, int64); - TEST_SHMEM_INC(CTX_ATOMIC_INC, uint32_t, uint32); - TEST_SHMEM_INC(CTX_ATOMIC_INC, uint64_t, uint64); - TEST_SHMEM_INC(CTX_ATOMIC_INC, size_t, size); - TEST_SHMEM_INC(CTX_ATOMIC_INC, ptrdiff_t, ptrdiff); - - TEST_SHMEM_INC(ATOMIC_FETCH_INC, int, int); - TEST_SHMEM_INC(ATOMIC_FETCH_INC, long, long); - TEST_SHMEM_INC(ATOMIC_FETCH_INC, long long, longlong); - TEST_SHMEM_INC(ATOMIC_FETCH_INC, unsigned int, uint); - TEST_SHMEM_INC(ATOMIC_FETCH_INC, unsigned long, ulong); - TEST_SHMEM_INC(ATOMIC_FETCH_INC, unsigned long long, ulonglong); - TEST_SHMEM_INC(ATOMIC_FETCH_INC, int32_t, int32); - TEST_SHMEM_INC(ATOMIC_FETCH_INC, int64_t, int64); - TEST_SHMEM_INC(ATOMIC_FETCH_INC, uint32_t, uint32); - TEST_SHMEM_INC(ATOMIC_FETCH_INC, uint64_t, uint64); - TEST_SHMEM_INC(ATOMIC_FETCH_INC, size_t, size); - TEST_SHMEM_INC(ATOMIC_FETCH_INC, ptrdiff_t, ptrdiff); - - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC, int, int); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC, long, long); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC, long long, longlong); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC, unsigned int, uint); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC, unsigned long, ulong); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC, unsigned long long, ulonglong); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC, int32_t, int32); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC, int64_t, int64); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC, uint32_t, uint32); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC, uint64_t, uint64); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC, size_t, size); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC, ptrdiff_t, ptrdiff); - - TEST_SHMEM_INC(ATOMIC_FETCH_INC_NBI, int, int); - TEST_SHMEM_INC(ATOMIC_FETCH_INC_NBI, long, long); - TEST_SHMEM_INC(ATOMIC_FETCH_INC_NBI, long long, longlong); - TEST_SHMEM_INC(ATOMIC_FETCH_INC_NBI, unsigned int, uint); - TEST_SHMEM_INC(ATOMIC_FETCH_INC_NBI, unsigned long, ulong); - TEST_SHMEM_INC(ATOMIC_FETCH_INC_NBI, unsigned long long, ulonglong); - TEST_SHMEM_INC(ATOMIC_FETCH_INC_NBI, int32_t, int32); - TEST_SHMEM_INC(ATOMIC_FETCH_INC_NBI, int64_t, int64); - TEST_SHMEM_INC(ATOMIC_FETCH_INC_NBI, uint32_t, uint32); - TEST_SHMEM_INC(ATOMIC_FETCH_INC_NBI, uint64_t, uint64); - TEST_SHMEM_INC(ATOMIC_FETCH_INC_NBI, size_t, size); - TEST_SHMEM_INC(ATOMIC_FETCH_INC_NBI, ptrdiff_t, ptrdiff); - - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC_NBI, int, int); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC_NBI, long, long); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC_NBI, long long, longlong); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC_NBI, unsigned int, uint); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC_NBI, unsigned long, ulong); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC_NBI, unsigned long long, ulonglong); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC_NBI, int32_t, int32); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC_NBI, int64_t, int64); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC_NBI, uint32_t, uint32); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC_NBI, uint64_t, uint64); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC_NBI, size_t, size); - TEST_SHMEM_INC(CTX_ATOMIC_FETCH_INC_NBI, ptrdiff_t, ptrdiff); - - shmem_finalize(); - return rc; -} diff --git a/test/unit/cxx_test_shmem_atomic_or.cpp b/test/unit/cxx_test_shmem_atomic_or.cpp deleted file mode 100644 index 3759c8e5a..000000000 --- a/test/unit/cxx_test_shmem_atomic_or.cpp +++ /dev/null @@ -1,174 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include -#include - -enum op { OR = 0, CTX_OR, FETCH_OR, CTX_FETCH_OR, FETCH_OR_NBI, - CTX_FETCH_OR_NBI }; - -/* Initially, remote = 000...b. Each PE performs an atomic OR where the - * PEth bit of the input value is set to 1 and all other bits are set to 0. - * The result has the NPES least significant bits set, 000...111...b. - */ - -#define SHMEM_NBI_OPS_CASES(OP, TYPE, TYPENAME) \ - case FETCH_OR_NBI: \ - shmem_##TYPENAME##_atomic_fetch_or_nbi(&old, &remote, \ - (TYPE)(1LLU << mype), i); \ - shmem_quiet(); \ - if ((old & (TYPE)(1LLU << mype)) != 0) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - case CTX_FETCH_OR_NBI: \ - shmem_ctx_##TYPENAME##_atomic_fetch_or_nbi(SHMEM_CTX_DEFAULT, \ - &old, &remote, (TYPE)(1LLU << mype), i); \ - shmem_quiet(); \ - if ((old & (TYPE)(1LLU << mype)) != 0) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; - -#define TEST_SHMEM_OR(OP, TYPE, TYPENAME) \ - do { \ - static TYPE remote = (TYPE)0; \ - TYPE old = (TYPE)0; \ - if ((size_t) npes-1 > sizeof(TYPE)) break; /* Avoid overflow */ \ - for (int i = 0; i < npes; i++) \ - switch (OP) { \ - case OR: \ - shmem_##TYPENAME##_atomic_or(&remote, \ - (TYPE)(1LLU << mype), i); \ - break; \ - case CTX_OR: \ - shmem_ctx_##TYPENAME##_atomic_or(SHMEM_CTX_DEFAULT, &remote, \ - (TYPE)(1LLU << mype), i); \ - break; \ - case FETCH_OR: \ - old = shmem_##TYPENAME##_atomic_fetch_or(&remote, \ - (TYPE)(1LLU << mype), i);\ - if ((old & (TYPE)(1LLU << mype)) != 0) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - case CTX_FETCH_OR: \ - old = shmem_ctx_##TYPENAME##_atomic_fetch_or( \ - SHMEM_CTX_DEFAULT, &remote, (TYPE)(1LLU << mype), i); \ - if ((old & (TYPE)(1LLU << mype)) != 0) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - SHMEM_NBI_OPS_CASES(OP, TYPE, TYPENAME) \ - default: \ - printf("Invalid operation (%d)\n", OP); \ - shmem_global_exit(1); \ - } \ - shmem_barrier_all(); \ - if (remote != (TYPE)((1LLU << npes) - 1LLU)) { \ - printf("PE %i observed error with TEST_SHMEM_OR(%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (false) - - -int main(int argc, char* argv[]) { - shmem_init(); - - const int mype = shmem_my_pe(); - const int npes = shmem_n_pes(); - - int rc = EXIT_SUCCESS; - TEST_SHMEM_OR(OR, unsigned int, uint); - TEST_SHMEM_OR(OR, unsigned long, ulong); - TEST_SHMEM_OR(OR, unsigned long long, ulonglong); - TEST_SHMEM_OR(OR, int32_t, int32); - TEST_SHMEM_OR(OR, int64_t, int64); - TEST_SHMEM_OR(OR, uint32_t, uint32); - TEST_SHMEM_OR(OR, uint64_t, uint64); - - TEST_SHMEM_OR(CTX_OR, unsigned int, uint); - TEST_SHMEM_OR(CTX_OR, unsigned long, ulong); - TEST_SHMEM_OR(CTX_OR, unsigned long long, ulonglong); - TEST_SHMEM_OR(CTX_OR, int32_t, int32); - TEST_SHMEM_OR(CTX_OR, int64_t, int64); - TEST_SHMEM_OR(CTX_OR, uint32_t, uint32); - TEST_SHMEM_OR(CTX_OR, uint64_t, uint64); - - TEST_SHMEM_OR(FETCH_OR, unsigned int, uint); - TEST_SHMEM_OR(FETCH_OR, unsigned long, ulong); - TEST_SHMEM_OR(FETCH_OR, unsigned long long, ulonglong); - TEST_SHMEM_OR(FETCH_OR, int32_t, int32); - TEST_SHMEM_OR(FETCH_OR, int64_t, int64); - TEST_SHMEM_OR(FETCH_OR, uint32_t, uint32); - TEST_SHMEM_OR(FETCH_OR, uint64_t, uint64); - - TEST_SHMEM_OR(CTX_FETCH_OR, unsigned int, uint); - TEST_SHMEM_OR(CTX_FETCH_OR, unsigned long, ulong); - TEST_SHMEM_OR(CTX_FETCH_OR, unsigned long long, ulonglong); - TEST_SHMEM_OR(CTX_FETCH_OR, int32_t, int32); - TEST_SHMEM_OR(CTX_FETCH_OR, int64_t, int64); - TEST_SHMEM_OR(CTX_FETCH_OR, uint32_t, uint32); - TEST_SHMEM_OR(CTX_FETCH_OR, uint64_t, uint64); - - TEST_SHMEM_OR(FETCH_OR_NBI, unsigned int, uint); - TEST_SHMEM_OR(FETCH_OR_NBI, unsigned long, ulong); - TEST_SHMEM_OR(FETCH_OR_NBI, unsigned long long, ulonglong); - TEST_SHMEM_OR(FETCH_OR_NBI, int32_t, int32); - TEST_SHMEM_OR(FETCH_OR_NBI, int64_t, int64); - TEST_SHMEM_OR(FETCH_OR_NBI, uint32_t, uint32); - TEST_SHMEM_OR(FETCH_OR_NBI, uint64_t, uint64); - - TEST_SHMEM_OR(CTX_FETCH_OR_NBI, unsigned int, uint); - TEST_SHMEM_OR(CTX_FETCH_OR_NBI, unsigned long, ulong); - TEST_SHMEM_OR(CTX_FETCH_OR_NBI, unsigned long long, ulonglong); - TEST_SHMEM_OR(CTX_FETCH_OR_NBI, int32_t, int32); - TEST_SHMEM_OR(CTX_FETCH_OR_NBI, int64_t, int64); - TEST_SHMEM_OR(CTX_FETCH_OR_NBI, uint32_t, uint32); - TEST_SHMEM_OR(CTX_FETCH_OR_NBI, uint64_t, uint64); - - shmem_finalize(); - return rc; -} diff --git a/test/unit/cxx_test_shmem_atomic_set.cpp b/test/unit/cxx_test_shmem_atomic_set.cpp deleted file mode 100644 index a06ed0265..000000000 --- a/test/unit/cxx_test_shmem_atomic_set.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include - -enum op { SET = 0, ATOMIC_SET, CTX_ATOMIC_SET }; - -#ifdef ENABLE_DEPRECATED_TESTS -#define DEPRECATED_SET(TYPENAME, ...) shmem_##TYPENAME##_set(__VA_ARGS__) -#else -#define DEPRECATED_SET(TYPENAME, ...) shmem_##TYPENAME##_atomic_set(__VA_ARGS__) -#endif - -#define TEST_SHMEM_SET(OP, TYPE, TYPENAME) \ - do { \ - static TYPE remote; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - switch (OP) { \ - case SET: \ - DEPRECATED_SET(TYPENAME, &remote, (TYPE)mype, \ - (mype + 1) % npes); \ - break; \ - case ATOMIC_SET: \ - shmem_##TYPENAME##_atomic_set(&remote, \ - (TYPE)mype, (mype + 1) % npes); \ - break; \ - case CTX_ATOMIC_SET: \ - shmem_ctx_##TYPENAME##_atomic_set(SHMEM_CTX_DEFAULT,\ - &remote, (TYPE)mype, (mype + 1) % npes); \ - break; \ - default: \ - printf("Invalid operation (%d)\n", OP); \ - shmem_global_exit(1); \ - } \ - shmem_barrier_all(); \ - if (remote != (TYPE)((mype + npes - 1) % npes)) { \ - printf("PE %i received incorrect value with " \ - "TEST_SHMEM_SET(%s, %s)\n", mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (false) - - -int main(int argc, char* argv[]) { - shmem_init(); - - int rc = EXIT_SUCCESS; - -#ifdef ENABLE_DEPRECATED_TESTS - TEST_SHMEM_SET(SET, float, float); - TEST_SHMEM_SET(SET, double, double); - TEST_SHMEM_SET(SET, int, int); - TEST_SHMEM_SET(SET, long, long); - TEST_SHMEM_SET(SET, long long, longlong); - TEST_SHMEM_SET(SET, unsigned int, uint); - TEST_SHMEM_SET(SET, unsigned long, ulong); - TEST_SHMEM_SET(SET, unsigned long long, ulonglong); - TEST_SHMEM_SET(SET, int32_t, int32); - TEST_SHMEM_SET(SET, int64_t, int64); - TEST_SHMEM_SET(SET, uint32_t, uint32); - TEST_SHMEM_SET(SET, uint64_t, uint64); - TEST_SHMEM_SET(SET, size_t, size); - TEST_SHMEM_SET(SET, ptrdiff_t, ptrdiff); -#endif /* ENABLE_DEPRECATED_TESTS */ - - TEST_SHMEM_SET(ATOMIC_SET, float, float); - TEST_SHMEM_SET(ATOMIC_SET, double, double); - TEST_SHMEM_SET(ATOMIC_SET, int, int); - TEST_SHMEM_SET(ATOMIC_SET, long, long); - TEST_SHMEM_SET(ATOMIC_SET, long long, longlong); - TEST_SHMEM_SET(ATOMIC_SET, unsigned int, uint); - TEST_SHMEM_SET(ATOMIC_SET, unsigned long, ulong); - TEST_SHMEM_SET(ATOMIC_SET, unsigned long long, ulonglong); - TEST_SHMEM_SET(ATOMIC_SET, int32_t, int32); - TEST_SHMEM_SET(ATOMIC_SET, int64_t, int64); - TEST_SHMEM_SET(ATOMIC_SET, uint32_t, uint32); - TEST_SHMEM_SET(ATOMIC_SET, uint64_t, uint64); - TEST_SHMEM_SET(ATOMIC_SET, size_t, size); - TEST_SHMEM_SET(ATOMIC_SET, ptrdiff_t, ptrdiff); - - TEST_SHMEM_SET(CTX_ATOMIC_SET, float, float); - TEST_SHMEM_SET(CTX_ATOMIC_SET, double, double); - TEST_SHMEM_SET(CTX_ATOMIC_SET, int, int); - TEST_SHMEM_SET(CTX_ATOMIC_SET, long, long); - TEST_SHMEM_SET(CTX_ATOMIC_SET, long long, longlong); - TEST_SHMEM_SET(CTX_ATOMIC_SET, unsigned int, uint); - TEST_SHMEM_SET(CTX_ATOMIC_SET, unsigned long, ulong); - TEST_SHMEM_SET(CTX_ATOMIC_SET, unsigned long long, ulonglong); - TEST_SHMEM_SET(CTX_ATOMIC_SET, int32_t, int32); - TEST_SHMEM_SET(CTX_ATOMIC_SET, int64_t, int64); - TEST_SHMEM_SET(CTX_ATOMIC_SET, uint32_t, uint32); - TEST_SHMEM_SET(CTX_ATOMIC_SET, uint64_t, uint64); - TEST_SHMEM_SET(CTX_ATOMIC_SET, size_t, size); - TEST_SHMEM_SET(CTX_ATOMIC_SET, ptrdiff_t, ptrdiff); - - shmem_finalize(); - return rc; -} diff --git a/test/unit/cxx_test_shmem_atomic_swap.cpp b/test/unit/cxx_test_shmem_atomic_swap.cpp deleted file mode 100644 index e1c573172..000000000 --- a/test/unit/cxx_test_shmem_atomic_swap.cpp +++ /dev/null @@ -1,182 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include - -enum op { SWAP = 0, ATOMIC_SWAP, CTX_ATOMIC_SWAP, ATOMIC_SWAP_NBI, - CTX_ATOMIC_SWAP_NBI }; - -#ifdef ENABLE_DEPRECATED_TESTS -#define DEPRECATED_SWAP(TYPENAME, ...) shmem_##TYPENAME##_swap(__VA_ARGS__) -#else -#define DEPRECATED_SWAP(TYPENAME, ...) shmem_##TYPENAME##_atomic_swap(__VA_ARGS__) -#endif - -#define SHMEM_NBI_OPS_CASES(OP, TYPE, TYPENAME) \ - case ATOMIC_SWAP_NBI: \ - shmem_##TYPENAME##_atomic_swap_nbi(&old, &remote, \ - (TYPE)mype, (mype + 1) % npes); \ - break; \ - case CTX_ATOMIC_SWAP_NBI: \ - shmem_ctx_##TYPENAME##_atomic_swap_nbi(SHMEM_CTX_DEFAULT, \ - &old, &remote, (TYPE)mype, (mype + 1) % npes); \ - break; - -#define TEST_SHMEM_SWAP(OP, TYPE, TYPENAME) \ - do { \ - static TYPE remote; \ - TYPE old; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - remote = npes; \ - shmem_barrier_all(); \ - switch (OP) { \ - case SWAP: \ - old = DEPRECATED_SWAP(TYPENAME, &remote, (TYPE)mype, \ - (mype + 1) % npes); \ - break; \ - case ATOMIC_SWAP: \ - old = shmem_##TYPENAME##_atomic_swap(&remote, (TYPE)mype, \ - (mype + 1) % npes); \ - break; \ - case CTX_ATOMIC_SWAP: \ - old = shmem_ctx_##TYPENAME##_atomic_swap(SHMEM_CTX_DEFAULT, \ - &remote, (TYPE)mype, (mype + 1) % npes); \ - break; \ - SHMEM_NBI_OPS_CASES(OP, TYPE, TYPENAME) \ - default: \ - printf("invalid operation (%d)\n", OP); \ - shmem_global_exit(1); \ - } \ - shmem_barrier_all(); \ - if (remote != (TYPE)((mype + npes - 1) % npes)) { \ - printf("PE %i received incorrect value with " \ - "TEST_SHMEM_SWAP(%s, %s)\n", mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - if (old != (TYPE) npes) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (false) - - -int main(int argc, char* argv[]) { - shmem_init(); - - int rc = EXIT_SUCCESS; - -#ifdef ENABLE_DEPRECATED_TESTS - TEST_SHMEM_SWAP(SWAP, float, float); - TEST_SHMEM_SWAP(SWAP, double, double); - TEST_SHMEM_SWAP(SWAP, int, int); - TEST_SHMEM_SWAP(SWAP, long, long); - TEST_SHMEM_SWAP(SWAP, long long, longlong); - TEST_SHMEM_SWAP(SWAP, unsigned int, uint); - TEST_SHMEM_SWAP(SWAP, unsigned long, ulong); - TEST_SHMEM_SWAP(SWAP, unsigned long long, ulonglong); - TEST_SHMEM_SWAP(SWAP, int32_t, int32); - TEST_SHMEM_SWAP(SWAP, int64_t, int64); - TEST_SHMEM_SWAP(SWAP, uint32_t, uint32); - TEST_SHMEM_SWAP(SWAP, uint64_t, uint64); - TEST_SHMEM_SWAP(SWAP, size_t, size); - TEST_SHMEM_SWAP(SWAP, ptrdiff_t, ptrdiff); -#endif /* ENABLE_DEPRECATED_TESTS */ - - TEST_SHMEM_SWAP(ATOMIC_SWAP, float, float); - TEST_SHMEM_SWAP(ATOMIC_SWAP, double, double); - TEST_SHMEM_SWAP(ATOMIC_SWAP, int, int); - TEST_SHMEM_SWAP(ATOMIC_SWAP, long, long); - TEST_SHMEM_SWAP(ATOMIC_SWAP, long long, longlong); - TEST_SHMEM_SWAP(ATOMIC_SWAP, unsigned int, uint); - TEST_SHMEM_SWAP(ATOMIC_SWAP, unsigned long, ulong); - TEST_SHMEM_SWAP(ATOMIC_SWAP, unsigned long long, ulonglong); - TEST_SHMEM_SWAP(ATOMIC_SWAP, int32_t, int32); - TEST_SHMEM_SWAP(ATOMIC_SWAP, int64_t, int64); - TEST_SHMEM_SWAP(ATOMIC_SWAP, uint32_t, uint32); - TEST_SHMEM_SWAP(ATOMIC_SWAP, uint64_t, uint64); - TEST_SHMEM_SWAP(ATOMIC_SWAP, size_t, size); - TEST_SHMEM_SWAP(ATOMIC_SWAP, ptrdiff_t, ptrdiff); - - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP, float, float); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP, double, double); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP, int, int); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP, long, long); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP, long long, longlong); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP, unsigned int, uint); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP, unsigned long, ulong); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP, unsigned long long, ulonglong); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP, int32_t, int32); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP, int64_t, int64); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP, uint32_t, uint32); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP, uint64_t, uint64); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP, size_t, size); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP, ptrdiff_t, ptrdiff); - - TEST_SHMEM_SWAP(ATOMIC_SWAP_NBI, float, float); - TEST_SHMEM_SWAP(ATOMIC_SWAP_NBI, double, double); - TEST_SHMEM_SWAP(ATOMIC_SWAP_NBI, int, int); - TEST_SHMEM_SWAP(ATOMIC_SWAP_NBI, long, long); - TEST_SHMEM_SWAP(ATOMIC_SWAP_NBI, long long, longlong); - TEST_SHMEM_SWAP(ATOMIC_SWAP_NBI, unsigned int, uint); - TEST_SHMEM_SWAP(ATOMIC_SWAP_NBI, unsigned long, ulong); - TEST_SHMEM_SWAP(ATOMIC_SWAP_NBI, unsigned long long, ulonglong); - TEST_SHMEM_SWAP(ATOMIC_SWAP_NBI, int32_t, int32); - TEST_SHMEM_SWAP(ATOMIC_SWAP_NBI, int64_t, int64); - TEST_SHMEM_SWAP(ATOMIC_SWAP_NBI, uint32_t, uint32); - TEST_SHMEM_SWAP(ATOMIC_SWAP_NBI, uint64_t, uint64); - TEST_SHMEM_SWAP(ATOMIC_SWAP_NBI, size_t, size); - TEST_SHMEM_SWAP(ATOMIC_SWAP_NBI, ptrdiff_t, ptrdiff); - - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP_NBI, float, float); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP_NBI, double, double); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP_NBI, int, int); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP_NBI, long, long); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP_NBI, long long, longlong); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP_NBI, unsigned int, uint); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP_NBI, unsigned long, ulong); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP_NBI, unsigned long long, ulonglong); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP_NBI, int32_t, int32); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP_NBI, int64_t, int64); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP_NBI, uint32_t, uint32); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP_NBI, uint64_t, uint64); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP_NBI, size_t, size); - TEST_SHMEM_SWAP(CTX_ATOMIC_SWAP_NBI, ptrdiff_t, ptrdiff); - - shmem_finalize(); - return rc; -} diff --git a/test/unit/cxx_test_shmem_atomic_xor.cpp b/test/unit/cxx_test_shmem_atomic_xor.cpp deleted file mode 100644 index 141c17989..000000000 --- a/test/unit/cxx_test_shmem_atomic_xor.cpp +++ /dev/null @@ -1,174 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include -#include - -enum op { XOR = 0, CTX_XOR, FETCH_XOR, CTX_FETCH_XOR, FETCH_XOR_NBI, - CTX_FETCH_XOR_NBI }; - -/* Initially, remote = 111...b. Each PE performs an atomic XOR where the - * PEth bit of the input value is set to 1 and all other bits are set to 0. - * The result has the NPES least significant bits cleared, 111...000...b. - */ - -#define SHMEM_NBI_OPS_CASES(OP, TYPE, TYPENAME) \ - case FETCH_XOR_NBI: \ - shmem_##TYPENAME##_atomic_fetch_xor_nbi(&old, &remote, \ - (TYPE)(1LLU << mype), i); \ - shmem_quiet(); \ - if (((old ^ (TYPE)(1LLU << mype)) & (TYPE)(1LLU << mype)) != 0) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - case CTX_FETCH_XOR_NBI: \ - shmem_ctx_##TYPENAME##_atomic_fetch_xor_nbi(SHMEM_CTX_DEFAULT,\ - &old, &remote, (TYPE)(1LLU << mype), i); \ - shmem_quiet(); \ - if (((old ^ (TYPE)(1LLU << mype)) & (TYPE)(1LLU << mype)) != 0) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; - -#define TEST_SHMEM_XOR(OP, TYPE, TYPENAME) \ - do { \ - static TYPE remote = ~(TYPE)0; \ - TYPE old; \ - if ((size_t) npes-1 > sizeof(TYPE)) break; /* Avoid overflow */ \ - for (int i = 0; i < npes; i++) \ - switch (OP) { \ - case XOR: \ - shmem_##TYPENAME##_atomic_xor(&remote, \ - (TYPE)(1LLU << mype), i); \ - break; \ - case CTX_XOR: \ - shmem_ctx_##TYPENAME##_atomic_xor(SHMEM_CTX_DEFAULT, &remote, \ - (TYPE)(1LLU << mype), i); \ - break; \ - case FETCH_XOR: \ - old = shmem_##TYPENAME##_atomic_fetch_xor(&remote, \ - (TYPE)(1LLU << mype), i); \ - if (((old ^ (TYPE)(1LLU << mype)) & (TYPE)(1LLU << mype)) != 0) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - case CTX_FETCH_XOR: \ - old = shmem_ctx_##TYPENAME##_atomic_fetch_xor( \ - SHMEM_CTX_DEFAULT, &remote, (TYPE)(1LLU << mype), i); \ - if (((old ^ (TYPE)(1LLU << mype)) & (TYPE)(1LLU << mype)) != 0) { \ - printf("PE %i error inconsistent value of old (%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - break; \ - SHMEM_NBI_OPS_CASES(OP, TYPE, TYPENAME) \ - default: \ - printf("Invalid operation (%d)\n", OP); \ - shmem_global_exit(1); \ - } \ - shmem_barrier_all(); \ - if (remote != ~(TYPE)((1LLU << npes) - 1LLU)) { \ - printf("PE %i observed error with TEST_SHMEM_XOR(%s, %s)\n", \ - mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (false) - - -int main(int argc, char* argv[]) { - shmem_init(); - - const int mype = shmem_my_pe(); - const int npes = shmem_n_pes(); - - int rc = EXIT_SUCCESS; - TEST_SHMEM_XOR(XOR, unsigned int, uint); - TEST_SHMEM_XOR(XOR, unsigned long, ulong); - TEST_SHMEM_XOR(XOR, unsigned long long, ulonglong); - TEST_SHMEM_XOR(XOR, int32_t, int32); - TEST_SHMEM_XOR(XOR, int64_t, int64); - TEST_SHMEM_XOR(XOR, uint32_t, uint32); - TEST_SHMEM_XOR(XOR, uint64_t, uint64); - - TEST_SHMEM_XOR(CTX_XOR, unsigned int, uint); - TEST_SHMEM_XOR(CTX_XOR, unsigned long, ulong); - TEST_SHMEM_XOR(CTX_XOR, unsigned long long, ulonglong); - TEST_SHMEM_XOR(CTX_XOR, int32_t, int32); - TEST_SHMEM_XOR(CTX_XOR, int64_t, int64); - TEST_SHMEM_XOR(CTX_XOR, uint32_t, uint32); - TEST_SHMEM_XOR(CTX_XOR, uint64_t, uint64); - - TEST_SHMEM_XOR(FETCH_XOR, unsigned int, uint); - TEST_SHMEM_XOR(FETCH_XOR, unsigned long, ulong); - TEST_SHMEM_XOR(FETCH_XOR, unsigned long long, ulonglong); - TEST_SHMEM_XOR(FETCH_XOR, int32_t, int32); - TEST_SHMEM_XOR(FETCH_XOR, int64_t, int64); - TEST_SHMEM_XOR(FETCH_XOR, uint32_t, uint32); - TEST_SHMEM_XOR(FETCH_XOR, uint64_t, uint64); - - TEST_SHMEM_XOR(CTX_FETCH_XOR, unsigned int, uint); - TEST_SHMEM_XOR(CTX_FETCH_XOR, unsigned long, ulong); - TEST_SHMEM_XOR(CTX_FETCH_XOR, unsigned long long, ulonglong); - TEST_SHMEM_XOR(CTX_FETCH_XOR, int32_t, int32); - TEST_SHMEM_XOR(CTX_FETCH_XOR, int64_t, int64); - TEST_SHMEM_XOR(CTX_FETCH_XOR, uint32_t, uint32); - TEST_SHMEM_XOR(CTX_FETCH_XOR, uint64_t, uint64); - - TEST_SHMEM_XOR(FETCH_XOR_NBI, unsigned int, uint); - TEST_SHMEM_XOR(FETCH_XOR_NBI, unsigned long, ulong); - TEST_SHMEM_XOR(FETCH_XOR_NBI, unsigned long long, ulonglong); - TEST_SHMEM_XOR(FETCH_XOR_NBI, int32_t, int32); - TEST_SHMEM_XOR(FETCH_XOR_NBI, int64_t, int64); - TEST_SHMEM_XOR(FETCH_XOR_NBI, uint32_t, uint32); - TEST_SHMEM_XOR(FETCH_XOR_NBI, uint64_t, uint64); - - TEST_SHMEM_XOR(CTX_FETCH_XOR_NBI, unsigned int, uint); - TEST_SHMEM_XOR(CTX_FETCH_XOR_NBI, unsigned long, ulong); - TEST_SHMEM_XOR(CTX_FETCH_XOR_NBI, unsigned long long, ulonglong); - TEST_SHMEM_XOR(CTX_FETCH_XOR_NBI, int32_t, int32); - TEST_SHMEM_XOR(CTX_FETCH_XOR_NBI, int64_t, int64); - TEST_SHMEM_XOR(CTX_FETCH_XOR_NBI, uint32_t, uint32); - TEST_SHMEM_XOR(CTX_FETCH_XOR_NBI, uint64_t, uint64); - - shmem_finalize(); - return rc; -} diff --git a/test/unit/cxx_test_shmem_bitwise_reduce.cpp b/test/unit/cxx_test_shmem_bitwise_reduce.cpp deleted file mode 100644 index aa2936260..000000000 --- a/test/unit/cxx_test_shmem_bitwise_reduce.cpp +++ /dev/null @@ -1,183 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2023 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#define MAX_NPES 32 - -enum op { OP_AND = 0, OP_OR, OP_XOR }; - -#define REDUCTION(OP, TYPE) \ - do { \ - switch (OP) { \ - case OP_AND: \ - ret = shmem_##TYPE##_and_reduce(SHMEM_TEAM_WORLD, dest, src, \ - npes); \ - break; \ - case OP_OR: \ - ret = shmem_##TYPE##_or_reduce(SHMEM_TEAM_WORLD, dest, src, \ - npes); \ - break; \ - case OP_XOR: \ - ret = shmem_##TYPE##_xor_reduce(SHMEM_TEAM_WORLD, dest, src, \ - npes); \ - break; \ - default: \ - printf("Invalid operation (%d)\n", OP); \ - shmem_global_exit(1); \ - } \ - } while (0) - -#define INIT_SRC_BUFFER(TYPE) \ - do { \ - for (int i = 0; i < MAX_NPES; i++) { \ - src[i] = (TYPE)1ULL; \ - } \ - } while (0) - -#define CHECK_DEST_BUFFER(OP, TYPE, CORRECT_VAL) \ - do { \ - for (int i = 0; i < npes; i++) { \ - if (dest[i] != (TYPE)CORRECT_VAL) { \ - printf("PE %i received incorrect value with " \ - "TEST_SHMEM_REDUCE(%s, %s)\n", mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } \ - } while (0) - -#define TEST_SHMEM_REDUCE(OP, TYPENAME, TYPE) \ - do { \ - static TYPE src[MAX_NPES]; \ - static TYPE dest[MAX_NPES]; \ - int ret; \ - \ - INIT_SRC_BUFFER(TYPE); \ - REDUCTION(OP, TYPENAME); \ - \ - if (ret != 0) { \ - printf("Reduction returned non-zero value (%i) on PE (%i) with " \ - "TEST_SHMEM_REDUCE(%s, %s)\n", ret, mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - \ - shmem_barrier_all(); \ - \ - switch (OP) { \ - case OP_AND: \ - CHECK_DEST_BUFFER(OP, TYPE, 1ULL); \ - break; \ - case OP_OR: \ - CHECK_DEST_BUFFER(OP, TYPE, 1ULL); \ - break; \ - case OP_XOR: \ - CHECK_DEST_BUFFER(OP, TYPE, (TYPE)(npes % 2 ? 1ULL : 0ULL)); \ - break; \ - default: \ - printf("Invalid operation (%d)\n", OP); \ - shmem_global_exit(1); \ - } \ - } while (0) - - -int main(void) { - - shmem_init(); - - int rc = EXIT_SUCCESS; - - const int mype = shmem_my_pe(); - const int npes = shmem_n_pes(); - - if (npes > MAX_NPES) { - if (mype == 0) - fprintf(stderr, "ERR - Requires less than %d PEs\n", MAX_NPES); - shmem_global_exit(1); - } - - TEST_SHMEM_REDUCE(OP_AND, uchar, unsigned char); - TEST_SHMEM_REDUCE(OP_AND, ushort, unsigned short); - TEST_SHMEM_REDUCE(OP_AND, uint, unsigned int); - TEST_SHMEM_REDUCE(OP_AND, ulong, unsigned long); - TEST_SHMEM_REDUCE(OP_AND, ulonglong, unsigned long long); - TEST_SHMEM_REDUCE(OP_AND, int8, int8_t); - TEST_SHMEM_REDUCE(OP_AND, int16, int16_t); - TEST_SHMEM_REDUCE(OP_AND, int32, int32_t); - TEST_SHMEM_REDUCE(OP_AND, int64, int64_t); - TEST_SHMEM_REDUCE(OP_AND, uint8, uint8_t); - TEST_SHMEM_REDUCE(OP_AND, uint16, uint16_t); - TEST_SHMEM_REDUCE(OP_AND, uint32, uint32_t); - TEST_SHMEM_REDUCE(OP_AND, uint64, uint64_t); - TEST_SHMEM_REDUCE(OP_AND, size, size_t); - - TEST_SHMEM_REDUCE(OP_OR, uchar, unsigned char); - TEST_SHMEM_REDUCE(OP_OR, ushort, unsigned short); - TEST_SHMEM_REDUCE(OP_OR, uint, unsigned int); - TEST_SHMEM_REDUCE(OP_OR, ulong, unsigned long); - TEST_SHMEM_REDUCE(OP_OR, ulonglong, unsigned long long); - TEST_SHMEM_REDUCE(OP_OR, int8, int8_t); - TEST_SHMEM_REDUCE(OP_OR, int16, int16_t); - TEST_SHMEM_REDUCE(OP_OR, int32, int32_t); - TEST_SHMEM_REDUCE(OP_OR, int64, int64_t); - TEST_SHMEM_REDUCE(OP_OR, uint8, uint8_t); - TEST_SHMEM_REDUCE(OP_OR, uint16, uint16_t); - TEST_SHMEM_REDUCE(OP_OR, uint32, uint32_t); - TEST_SHMEM_REDUCE(OP_OR, uint64, uint64_t); - TEST_SHMEM_REDUCE(OP_OR, size, size_t); - - TEST_SHMEM_REDUCE(OP_XOR, uchar, unsigned char); - TEST_SHMEM_REDUCE(OP_XOR, ushort, unsigned short); - TEST_SHMEM_REDUCE(OP_XOR, uint, unsigned int); - TEST_SHMEM_REDUCE(OP_XOR, ulong, unsigned long); - TEST_SHMEM_REDUCE(OP_XOR, ulonglong, unsigned long long); - TEST_SHMEM_REDUCE(OP_XOR, int8, int8_t); - TEST_SHMEM_REDUCE(OP_XOR, int16, int16_t); - TEST_SHMEM_REDUCE(OP_XOR, int32, int32_t); - TEST_SHMEM_REDUCE(OP_XOR, int64, int64_t); - TEST_SHMEM_REDUCE(OP_XOR, uint8, uint8_t); - TEST_SHMEM_REDUCE(OP_XOR, uint16, uint16_t); - TEST_SHMEM_REDUCE(OP_XOR, uint32, uint32_t); - TEST_SHMEM_REDUCE(OP_XOR, uint64, uint64_t); - TEST_SHMEM_REDUCE(OP_XOR, size, size_t); - - fprintf(stdout, "Test passed with ret = %d\n", rc); - - shmem_finalize(); - return rc; -} diff --git a/test/unit/cxx_test_shmem_complex.cpp b/test/unit/cxx_test_shmem_complex.cpp deleted file mode 100644 index dfaaee11d..000000000 --- a/test/unit/cxx_test_shmem_complex.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include - -#define MAX(a, b) ((a) > (b)) ? (a) : (b) - -#define DECLARE_FOR(TYPE) \ - extern "C" { \ - TYPE _Complex TYPE##_dest[10]; \ - TYPE _Complex TYPE##_src[10]; \ - TYPE _Complex* TYPE##_workData; \ - TYPE _Complex* TYPE##_alloc_data() { \ - size_t size = sizeof(TYPE##_src[0]); \ - size_t minData = SHMEM_REDUCE_MIN_WRKDATA_SIZE*size; \ - size_t workDataSize = MAX(sizeof(TYPE##_src),minData); \ - return (TYPE _Complex*)shmem_malloc(workDataSize); \ - } \ - } - -long syncArr[SHMEM_REDUCE_SYNC_SIZE]; - -#define TEST_COMPLEX(TYPE,LETTER,OP) \ - { \ - TYPE##_workData = TYPE##_alloc_data(); \ - \ - memset(TYPE##_src,0,sizeof(TYPE##_src)); \ - \ - shmem_complex##LETTER##_##OP##_reduce(SHMEM_TEAM_WORLD, \ - TYPE##_dest,TYPE##_src,10); \ - \ - shmem_barrier_all(); \ - \ - if(shmem_my_pe() == 0) { \ - int i; \ - for(i = 1; i < shmem_n_pes(); ++i) { \ - shmem_getmem(TYPE##_src,TYPE##_dest,sizeof(TYPE##_dest),i); \ - if(0 != memcmp(TYPE##_src,TYPE##_dest,sizeof(TYPE##_src))) { \ - ++rc; \ - } \ - } \ - } \ - \ - shmem_barrier_all(); \ - } - -DECLARE_FOR(float); -DECLARE_FOR(double); - -int main(int argc, char* argv[]) { - shmem_init(); - - int rc = 0; - - TEST_COMPLEX(float,f,sum); - TEST_COMPLEX(float,f,prod); - TEST_COMPLEX(double,d,sum); - TEST_COMPLEX(double,d,prod); - - shmem_finalize(); - return rc; -} - diff --git a/test/unit/cxx_test_shmem_g.cpp b/test/unit/cxx_test_shmem_g.cpp deleted file mode 100644 index 0ce30716a..000000000 --- a/test/unit/cxx_test_shmem_g.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include - -#define TEST_SHMEM_G(USE_CTX, TYPE, TYPENAME) \ - do { \ - static TYPE remote; \ - TYPE val; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - remote = (TYPE)mype; \ - shmem_barrier_all(); \ - if (USE_CTX) \ - val = shmem_ctx_##TYPENAME##_g( \ - SHMEM_CTX_DEFAULT, &remote, (mype + 1) % npes); \ - else \ - val = shmem_##TYPENAME##_g(&remote, \ - (mype + 1) % npes); \ - if (val != (TYPE)((mype + 1) % npes)) { \ - printf("PE %i received incorrect value with" \ - "TEST_SHMEM_G(%d, %s)\n", mype, \ - (int)(USE_CTX), #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (false) - -int main(int argc, char* argv[]) { - shmem_init(); - - int rc = EXIT_SUCCESS; - TEST_SHMEM_G(0, float, float); - TEST_SHMEM_G(0, double, double); - TEST_SHMEM_G(0, long double, longdouble); - TEST_SHMEM_G(0, char, char); - TEST_SHMEM_G(0, signed char, schar); - TEST_SHMEM_G(0, short, short); - TEST_SHMEM_G(0, int, int); - TEST_SHMEM_G(0, long, long); - TEST_SHMEM_G(0, long long, longlong); - TEST_SHMEM_G(0, unsigned char, uchar); - TEST_SHMEM_G(0, unsigned short, ushort); - TEST_SHMEM_G(0, unsigned int, uint); - TEST_SHMEM_G(0, unsigned long, ulong); - TEST_SHMEM_G(0, unsigned long long, ulonglong); - TEST_SHMEM_G(0, int8_t, int8); - TEST_SHMEM_G(0, int16_t, int16); - TEST_SHMEM_G(0, int32_t, int32); - TEST_SHMEM_G(0, int64_t, int64); - TEST_SHMEM_G(0, uint8_t, uint8); - TEST_SHMEM_G(0, uint16_t, uint16); - TEST_SHMEM_G(0, uint32_t, uint32); - TEST_SHMEM_G(0, uint64_t, uint64); - TEST_SHMEM_G(0, size_t, size); - TEST_SHMEM_G(0, ptrdiff_t, ptrdiff); - - TEST_SHMEM_G(1, float, float); - TEST_SHMEM_G(1, double, double); - TEST_SHMEM_G(1, long double, longdouble); - TEST_SHMEM_G(1, char, char); - TEST_SHMEM_G(1, signed char, schar); - TEST_SHMEM_G(1, short, short); - TEST_SHMEM_G(1, int, int); - TEST_SHMEM_G(1, long, long); - TEST_SHMEM_G(1, long long, longlong); - TEST_SHMEM_G(1, unsigned char, uchar); - TEST_SHMEM_G(1, unsigned short, ushort); - TEST_SHMEM_G(1, unsigned int, uint); - TEST_SHMEM_G(1, unsigned long, ulong); - TEST_SHMEM_G(1, unsigned long long, ulonglong); - TEST_SHMEM_G(1, int8_t, int8); - TEST_SHMEM_G(1, int16_t, int16); - TEST_SHMEM_G(1, int32_t, int32); - TEST_SHMEM_G(1, int64_t, int64); - TEST_SHMEM_G(1, uint8_t, uint8); - TEST_SHMEM_G(1, uint16_t, uint16); - TEST_SHMEM_G(1, uint32_t, uint32); - TEST_SHMEM_G(1, uint64_t, uint64); - TEST_SHMEM_G(1, size_t, size); - TEST_SHMEM_G(1, ptrdiff_t, ptrdiff); - - shmem_finalize(); - return rc; -} diff --git a/test/unit/cxx_test_shmem_get.cpp b/test/unit/cxx_test_shmem_get.cpp deleted file mode 100644 index d37762d43..000000000 --- a/test/unit/cxx_test_shmem_get.cpp +++ /dev/null @@ -1,246 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include - -enum op { GET = 0, IGET, GET_NBI }; - -#define TEST_SHMEM_GET(OP, USE_CTX, TYPE, TYPENAME) \ - do { \ - static TYPE remote[10]; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - TYPE local[10]; \ - for (int i = 0; i < 10; i++) \ - remote[i] = (TYPE)mype; \ - shmem_barrier_all(); \ - switch (OP) { \ - case GET: \ - if (USE_CTX) \ - shmem_ctx_##TYPENAME##_get(SHMEM_CTX_DEFAULT, local, \ - remote, 10, (mype + 1) % npes); \ - else \ - shmem_##TYPENAME##_get(local, remote, 10, \ - (mype + 1) % npes); \ - break; \ - case IGET: \ - if (USE_CTX) \ - shmem_ctx_##TYPENAME##_iget(SHMEM_CTX_DEFAULT, local, \ - remote, 1, 1, 10, (mype + 1) % npes); \ - else \ - shmem_##TYPENAME##_iget(local, remote, 1, 1, 10, \ - (mype + 1) % npes); \ - break; \ - case GET_NBI: \ - if (USE_CTX) \ - shmem_ctx_##TYPENAME##_get_nbi(SHMEM_CTX_DEFAULT, \ - local, remote, 10, (mype + 1) % npes); \ - else \ - shmem_##TYPENAME##_get_nbi(local, remote, 10, \ - (mype + 1) % npes); \ - shmem_quiet(); \ - break; \ - default: \ - printf("Invalid operation (%d)\n", OP); \ - shmem_global_exit(1); \ - } \ - for (int i = 0; i < 10; i++) \ - if (local[i] != (TYPE)((mype + 1) % npes)) { \ - printf("PE %i received incorrect value with" \ - "TEST_SHMEM_GET(%s, %d, %s)\n", mype, #OP, \ - (int)(USE_CTX), #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (false) - -int main(int argc, char* argv[]) { - shmem_init(); - - int rc = EXIT_SUCCESS; - - TEST_SHMEM_GET(GET, 0, float, float); - TEST_SHMEM_GET(GET, 0, double, double); - TEST_SHMEM_GET(GET, 0, long double, longdouble); - TEST_SHMEM_GET(GET, 0, char, char); - TEST_SHMEM_GET(GET, 0, signed char, schar); - TEST_SHMEM_GET(GET, 0, short, short); - TEST_SHMEM_GET(GET, 0, int, int); - TEST_SHMEM_GET(GET, 0, long, long); - TEST_SHMEM_GET(GET, 0, long long, longlong); - TEST_SHMEM_GET(GET, 0, unsigned char, uchar); - TEST_SHMEM_GET(GET, 0, unsigned short, ushort); - TEST_SHMEM_GET(GET, 0, unsigned int, uint); - TEST_SHMEM_GET(GET, 0, unsigned long, ulong); - TEST_SHMEM_GET(GET, 0, unsigned long long, ulonglong); - TEST_SHMEM_GET(GET, 0, int8_t, int8); - TEST_SHMEM_GET(GET, 0, int16_t, int16); - TEST_SHMEM_GET(GET, 0, int32_t, int32); - TEST_SHMEM_GET(GET, 0, int64_t, int64); - TEST_SHMEM_GET(GET, 0, uint8_t, uint8); - TEST_SHMEM_GET(GET, 0, uint16_t, uint16); - TEST_SHMEM_GET(GET, 0, uint32_t, uint32); - TEST_SHMEM_GET(GET, 0, uint64_t, uint64); - TEST_SHMEM_GET(GET, 0, size_t, size); - TEST_SHMEM_GET(GET, 0, ptrdiff_t, ptrdiff); - - TEST_SHMEM_GET(GET, 1, float, float); - TEST_SHMEM_GET(GET, 1, double, double); - TEST_SHMEM_GET(GET, 1, long double, longdouble); - TEST_SHMEM_GET(GET, 1, char, char); - TEST_SHMEM_GET(GET, 1, signed char, schar); - TEST_SHMEM_GET(GET, 1, short, short); - TEST_SHMEM_GET(GET, 1, int, int); - TEST_SHMEM_GET(GET, 1, long, long); - TEST_SHMEM_GET(GET, 1, long long, longlong); - TEST_SHMEM_GET(GET, 1, unsigned char, uchar); - TEST_SHMEM_GET(GET, 1, unsigned short, ushort); - TEST_SHMEM_GET(GET, 1, unsigned int, uint); - TEST_SHMEM_GET(GET, 1, unsigned long, ulong); - TEST_SHMEM_GET(GET, 1, unsigned long long, ulonglong); - TEST_SHMEM_GET(GET, 1, int8_t, int8); - TEST_SHMEM_GET(GET, 1, int16_t, int16); - TEST_SHMEM_GET(GET, 1, int32_t, int32); - TEST_SHMEM_GET(GET, 1, int64_t, int64); - TEST_SHMEM_GET(GET, 1, uint8_t, uint8); - TEST_SHMEM_GET(GET, 1, uint16_t, uint16); - TEST_SHMEM_GET(GET, 1, uint32_t, uint32); - TEST_SHMEM_GET(GET, 1, uint64_t, uint64); - TEST_SHMEM_GET(GET, 1, size_t, size); - TEST_SHMEM_GET(GET, 1, ptrdiff_t, ptrdiff); - - TEST_SHMEM_GET(IGET, 0, float, float); - TEST_SHMEM_GET(IGET, 0, double, double); - TEST_SHMEM_GET(IGET, 0, long double, longdouble); - TEST_SHMEM_GET(IGET, 0, char, char); - TEST_SHMEM_GET(IGET, 0, signed char, schar); - TEST_SHMEM_GET(IGET, 0, short, short); - TEST_SHMEM_GET(IGET, 0, int, int); - TEST_SHMEM_GET(IGET, 0, long, long); - TEST_SHMEM_GET(IGET, 0, long long, longlong); - TEST_SHMEM_GET(IGET, 0, unsigned char, uchar); - TEST_SHMEM_GET(IGET, 0, unsigned short, ushort); - TEST_SHMEM_GET(IGET, 0, unsigned int, uint); - TEST_SHMEM_GET(IGET, 0, unsigned long, ulong); - TEST_SHMEM_GET(IGET, 0, unsigned long long, ulonglong); - TEST_SHMEM_GET(IGET, 0, int8_t, int8); - TEST_SHMEM_GET(IGET, 0, int16_t, int16); - TEST_SHMEM_GET(IGET, 0, int32_t, int32); - TEST_SHMEM_GET(IGET, 0, int64_t, int64); - TEST_SHMEM_GET(IGET, 0, uint8_t, uint8); - TEST_SHMEM_GET(IGET, 0, uint16_t, uint16); - TEST_SHMEM_GET(IGET, 0, uint32_t, uint32); - TEST_SHMEM_GET(IGET, 0, uint64_t, uint64); - TEST_SHMEM_GET(IGET, 0, size_t, size); - TEST_SHMEM_GET(IGET, 0, ptrdiff_t, ptrdiff); - - TEST_SHMEM_GET(IGET, 1, float, float); - TEST_SHMEM_GET(IGET, 1, double, double); - TEST_SHMEM_GET(IGET, 1, long double, longdouble); - TEST_SHMEM_GET(IGET, 1, char, char); - TEST_SHMEM_GET(IGET, 1, signed char, schar); - TEST_SHMEM_GET(IGET, 1, short, short); - TEST_SHMEM_GET(IGET, 1, int, int); - TEST_SHMEM_GET(IGET, 1, long, long); - TEST_SHMEM_GET(IGET, 1, long long, longlong); - TEST_SHMEM_GET(IGET, 1, unsigned char, uchar); - TEST_SHMEM_GET(IGET, 1, unsigned short, ushort); - TEST_SHMEM_GET(IGET, 1, unsigned int, uint); - TEST_SHMEM_GET(IGET, 1, unsigned long, ulong); - TEST_SHMEM_GET(IGET, 1, unsigned long long, ulonglong); - TEST_SHMEM_GET(IGET, 1, int8_t, int8); - TEST_SHMEM_GET(IGET, 1, int16_t, int16); - TEST_SHMEM_GET(IGET, 1, int32_t, int32); - TEST_SHMEM_GET(IGET, 1, int64_t, int64); - TEST_SHMEM_GET(IGET, 1, uint8_t, uint8); - TEST_SHMEM_GET(IGET, 1, uint16_t, uint16); - TEST_SHMEM_GET(IGET, 1, uint32_t, uint32); - TEST_SHMEM_GET(IGET, 1, uint64_t, uint64); - TEST_SHMEM_GET(IGET, 1, size_t, size); - TEST_SHMEM_GET(IGET, 1, ptrdiff_t, ptrdiff); - - TEST_SHMEM_GET(GET_NBI, 0, float, float); - TEST_SHMEM_GET(GET_NBI, 0, double, double); - TEST_SHMEM_GET(GET_NBI, 0, long double, longdouble); - TEST_SHMEM_GET(GET_NBI, 0, char, char); - TEST_SHMEM_GET(GET_NBI, 0, signed char, schar); - TEST_SHMEM_GET(GET_NBI, 0, short, short); - TEST_SHMEM_GET(GET_NBI, 0, int, int); - TEST_SHMEM_GET(GET_NBI, 0, long, long); - TEST_SHMEM_GET(GET_NBI, 0, long long, longlong); - TEST_SHMEM_GET(GET_NBI, 0, unsigned char, uchar); - TEST_SHMEM_GET(GET_NBI, 0, unsigned short, ushort); - TEST_SHMEM_GET(GET_NBI, 0, unsigned int, uint); - TEST_SHMEM_GET(GET_NBI, 0, unsigned long, ulong); - TEST_SHMEM_GET(GET_NBI, 0, unsigned long long, ulonglong); - TEST_SHMEM_GET(GET_NBI, 0, int8_t, int8); - TEST_SHMEM_GET(GET_NBI, 0, int16_t, int16); - TEST_SHMEM_GET(GET_NBI, 0, int32_t, int32); - TEST_SHMEM_GET(GET_NBI, 0, int64_t, int64); - TEST_SHMEM_GET(GET_NBI, 0, uint8_t, uint8); - TEST_SHMEM_GET(GET_NBI, 0, uint16_t, uint16); - TEST_SHMEM_GET(GET_NBI, 0, uint32_t, uint32); - TEST_SHMEM_GET(GET_NBI, 0, uint64_t, uint64); - TEST_SHMEM_GET(GET_NBI, 0, size_t, size); - TEST_SHMEM_GET(GET_NBI, 0, ptrdiff_t, ptrdiff); - - TEST_SHMEM_GET(GET_NBI, 1, float, float); - TEST_SHMEM_GET(GET_NBI, 1, double, double); - TEST_SHMEM_GET(GET_NBI, 1, long double, longdouble); - TEST_SHMEM_GET(GET_NBI, 1, char, char); - TEST_SHMEM_GET(GET_NBI, 1, signed char, schar); - TEST_SHMEM_GET(GET_NBI, 1, short, short); - TEST_SHMEM_GET(GET_NBI, 1, int, int); - TEST_SHMEM_GET(GET_NBI, 1, long, long); - TEST_SHMEM_GET(GET_NBI, 1, long long, longlong); - TEST_SHMEM_GET(GET_NBI, 1, unsigned char, uchar); - TEST_SHMEM_GET(GET_NBI, 1, unsigned short, ushort); - TEST_SHMEM_GET(GET_NBI, 1, unsigned int, uint); - TEST_SHMEM_GET(GET_NBI, 1, unsigned long, ulong); - TEST_SHMEM_GET(GET_NBI, 1, unsigned long long, ulonglong); - TEST_SHMEM_GET(GET_NBI, 1, int8_t, int8); - TEST_SHMEM_GET(GET_NBI, 1, int16_t, int16); - TEST_SHMEM_GET(GET_NBI, 1, int32_t, int32); - TEST_SHMEM_GET(GET_NBI, 1, int64_t, int64); - TEST_SHMEM_GET(GET_NBI, 1, uint8_t, uint8); - TEST_SHMEM_GET(GET_NBI, 1, uint16_t, uint16); - TEST_SHMEM_GET(GET_NBI, 1, uint32_t, uint32); - TEST_SHMEM_GET(GET_NBI, 1, uint64_t, uint64); - TEST_SHMEM_GET(GET_NBI, 1, size_t, size); - TEST_SHMEM_GET(GET_NBI, 1, ptrdiff_t, ptrdiff); - - shmem_finalize(); - return rc; -} diff --git a/test/unit/cxx_test_shmem_max_min_reduce.cpp b/test/unit/cxx_test_shmem_max_min_reduce.cpp deleted file mode 100644 index 729668d46..000000000 --- a/test/unit/cxx_test_shmem_max_min_reduce.cpp +++ /dev/null @@ -1,206 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2023 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#define MAX_NPES 32 - -enum op { OP_MAX, OP_MIN }; - -const double FLOATING_POINT_TOLERANCE = 1e-6; - -#define REDUCTION(OP, TYPE) \ - do { \ - switch (OP) { \ - case OP_MAX: \ - ret = shmem_##TYPE##_max_reduce(SHMEM_TEAM_WORLD, dest, src, \ - npes); \ - break; \ - case OP_MIN: \ - ret = shmem_##TYPE##_min_reduce(SHMEM_TEAM_WORLD, dest, src, \ - npes); \ - break; \ - default: \ - printf("Invalid operation (%d)\n", OP); \ - shmem_global_exit(1); \ - } \ - } while (0) - -#define INIT_SRC_BUFFER(TYPE) \ - do { \ - for (int i = 0; i < MAX_NPES; i++) { \ - src[i] = (TYPE)1ULL; \ - } \ - } while (0) - -#define CHECK_DEST_BUFFER(OP, TYPE, CORRECT_VAL) \ - do { \ - for (int i = 0; i < npes; i++) { \ - if (dest[i] != (TYPE)CORRECT_VAL) { \ - printf("PE %i received incorrect value with " \ - "TEST_SHMEM_REDUCE(%s, %s)\n", mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } \ - } while (0) - -#define CHECK_DEST_BUFFER_FP(OP, TYPE, CORRECT_VAL, TOLERANCE) \ - do { \ - for (int i = 0; i < npes; i++) { \ - if (fabsl(creal(dest[i]) - creal((TYPE)CORRECT_VAL)) > TOLERANCE) { \ - printf("PE %i received incorrect real value with " \ - "TEST_SHMEM_REDUCE(%s, %s)\n", mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - if (fabsl(cimag(dest[i]) - cimag((TYPE)CORRECT_VAL)) > TOLERANCE) { \ - printf("PE %i received incorrect imaginary value with " \ - "TEST_SHMEM_REDUCE(%s, %s)\n", mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } \ - } while (0) - -#define TEST_SHMEM_REDUCE(OP, TYPENAME, TYPE) \ - do { \ - static TYPE src[MAX_NPES]; \ - static TYPE dest[MAX_NPES]; \ - int ret; \ - const bool floating_point_val = std::is_floating_point::value; \ - \ - INIT_SRC_BUFFER(TYPE); \ - REDUCTION(OP, TYPENAME); \ - \ - if (ret != 0) { \ - printf("Reduction returned non-zero value (%i) on PE (%i) with " \ - "TEST_SHMEM_REDUCE(%s, %s)\n", ret, mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - \ - shmem_barrier_all(); \ - \ - switch (OP) { \ - case OP_MAX: \ - if (floating_point_val) \ - CHECK_DEST_BUFFER_FP(OP, TYPE, 1ULL, FLOATING_POINT_TOLERANCE); \ - else \ - CHECK_DEST_BUFFER(OP, TYPE, 1ULL); \ - break; \ - case OP_MIN: \ - if (floating_point_val) \ - CHECK_DEST_BUFFER_FP(OP, TYPE, 1ULL, FLOATING_POINT_TOLERANCE); \ - else \ - CHECK_DEST_BUFFER(OP, TYPE, 1ULL); \ - break; \ - default: \ - printf("Invalid operation (%d)\n", OP); \ - shmem_global_exit(1); \ - } \ - } while (0) - - -int main(void) { - - shmem_init(); - - int rc = EXIT_SUCCESS; - - const int mype = shmem_my_pe(); - const int npes = shmem_n_pes(); - - if (npes > MAX_NPES) { - if (mype == 0) - fprintf(stderr, "ERR - Requires less than %d PEs\n", MAX_NPES); - shmem_global_exit(1); - } - - TEST_SHMEM_REDUCE(OP_MAX, char, char); - TEST_SHMEM_REDUCE(OP_MAX, schar, signed char); - TEST_SHMEM_REDUCE(OP_MAX, short, short); - TEST_SHMEM_REDUCE(OP_MAX, int, int); - TEST_SHMEM_REDUCE(OP_MAX, long, long); - TEST_SHMEM_REDUCE(OP_MAX, longlong, long long); - TEST_SHMEM_REDUCE(OP_MAX, ptrdiff, ptrdiff_t); - TEST_SHMEM_REDUCE(OP_MAX, uchar, unsigned char); - TEST_SHMEM_REDUCE(OP_MAX, ushort, unsigned short); - TEST_SHMEM_REDUCE(OP_MAX, uint, unsigned int); - TEST_SHMEM_REDUCE(OP_MAX, ulong, unsigned long); - TEST_SHMEM_REDUCE(OP_MAX, ulonglong, unsigned long long); - TEST_SHMEM_REDUCE(OP_MAX, int8, int8_t); - TEST_SHMEM_REDUCE(OP_MAX, int16, int16_t); - TEST_SHMEM_REDUCE(OP_MAX, int32, int32_t); - TEST_SHMEM_REDUCE(OP_MAX, int64, int64_t); - TEST_SHMEM_REDUCE(OP_MAX, uint8, uint8_t); - TEST_SHMEM_REDUCE(OP_MAX, uint16, uint16_t); - TEST_SHMEM_REDUCE(OP_MAX, uint32, uint32_t); - TEST_SHMEM_REDUCE(OP_MAX, uint64, uint64_t); - TEST_SHMEM_REDUCE(OP_MAX, size, size_t); - TEST_SHMEM_REDUCE(OP_MAX, float, float); - TEST_SHMEM_REDUCE(OP_MAX, double, double); - TEST_SHMEM_REDUCE(OP_MAX, longdouble, long double); - - TEST_SHMEM_REDUCE(OP_MIN, char, char); - TEST_SHMEM_REDUCE(OP_MIN, schar, signed char); - TEST_SHMEM_REDUCE(OP_MIN, short, short); - TEST_SHMEM_REDUCE(OP_MIN, int, int); - TEST_SHMEM_REDUCE(OP_MIN, long, long); - TEST_SHMEM_REDUCE(OP_MIN, longlong, long long); - TEST_SHMEM_REDUCE(OP_MIN, ptrdiff, ptrdiff_t); - TEST_SHMEM_REDUCE(OP_MIN, uchar, unsigned char); - TEST_SHMEM_REDUCE(OP_MIN, ushort, unsigned short); - TEST_SHMEM_REDUCE(OP_MIN, uint, unsigned int); - TEST_SHMEM_REDUCE(OP_MIN, ulong, unsigned long); - TEST_SHMEM_REDUCE(OP_MIN, ulonglong, unsigned long long); - TEST_SHMEM_REDUCE(OP_MIN, int8, int8_t); - TEST_SHMEM_REDUCE(OP_MIN, int16, int16_t); - TEST_SHMEM_REDUCE(OP_MIN, int32, int32_t); - TEST_SHMEM_REDUCE(OP_MIN, int64, int64_t); - TEST_SHMEM_REDUCE(OP_MIN, uint8, uint8_t); - TEST_SHMEM_REDUCE(OP_MIN, uint16, uint16_t); - TEST_SHMEM_REDUCE(OP_MIN, uint32, uint32_t); - TEST_SHMEM_REDUCE(OP_MIN, uint64, uint64_t); - TEST_SHMEM_REDUCE(OP_MIN, size, size_t); - TEST_SHMEM_REDUCE(OP_MIN, float, float); - TEST_SHMEM_REDUCE(OP_MIN, double, double); - TEST_SHMEM_REDUCE(OP_MIN, longdouble, long double); - - fprintf(stdout, "Test passed with ret = %d\n", rc); - - shmem_finalize(); - return rc; -} diff --git a/test/unit/cxx_test_shmem_p.cpp b/test/unit/cxx_test_shmem_p.cpp deleted file mode 100644 index d51a29ab7..000000000 --- a/test/unit/cxx_test_shmem_p.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include - -#define TEST_SHMEM_P(USE_CTX, TYPE, TYPENAME) \ - do { \ - static TYPE remote; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - if (USE_CTX) \ - shmem_ctx_##TYPENAME##_p(SHMEM_CTX_DEFAULT, \ - &remote, (TYPE)mype, (mype + 1) % npes); \ - else \ - shmem_##TYPENAME##_p(&remote, (TYPE)mype, \ - (mype + 1) % npes);\ - shmem_barrier_all(); \ - if (remote != (TYPE)((mype + npes - 1) % npes)) { \ - printf("PE %i received incorrect value with " \ - "TEST_SHMEM_P(%d, %s)\n", mype, \ - (int)(USE_CTX), #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (false) - -int main(int argc, char* argv[]) { - shmem_init(); - - int rc = EXIT_SUCCESS; - TEST_SHMEM_P(0, float, float); - TEST_SHMEM_P(0, double, double); - TEST_SHMEM_P(0, long double, longdouble); - TEST_SHMEM_P(0, char, char); - TEST_SHMEM_P(0, signed char, schar); - TEST_SHMEM_P(0, short, short); - TEST_SHMEM_P(0, int, int); - TEST_SHMEM_P(0, long, long); - TEST_SHMEM_P(0, long long, longlong); - TEST_SHMEM_P(0, unsigned char, uchar); - TEST_SHMEM_P(0, unsigned short, ushort); - TEST_SHMEM_P(0, unsigned int, uint); - TEST_SHMEM_P(0, unsigned long, ulong); - TEST_SHMEM_P(0, unsigned long long, ulonglong); - TEST_SHMEM_P(0, int8_t, int8); - TEST_SHMEM_P(0, int16_t, int16); - TEST_SHMEM_P(0, int32_t, int32); - TEST_SHMEM_P(0, int64_t, int64); - TEST_SHMEM_P(0, uint8_t, uint8); - TEST_SHMEM_P(0, uint16_t, uint16); - TEST_SHMEM_P(0, uint32_t, uint32); - TEST_SHMEM_P(0, uint64_t, uint64); - TEST_SHMEM_P(0, size_t, size); - TEST_SHMEM_P(0, ptrdiff_t, ptrdiff); - - TEST_SHMEM_P(1, float, float); - TEST_SHMEM_P(1, double, double); - TEST_SHMEM_P(1, long double, longdouble); - TEST_SHMEM_P(1, char, char); - TEST_SHMEM_P(1, signed char, schar); - TEST_SHMEM_P(1, short, short); - TEST_SHMEM_P(1, int, int); - TEST_SHMEM_P(1, long, long); - TEST_SHMEM_P(1, long long, longlong); - TEST_SHMEM_P(1, unsigned char, uchar); - TEST_SHMEM_P(1, unsigned short, ushort); - TEST_SHMEM_P(1, unsigned int, uint); - TEST_SHMEM_P(1, unsigned long, ulong); - TEST_SHMEM_P(1, unsigned long long, ulonglong); - TEST_SHMEM_P(1, int8_t, int8); - TEST_SHMEM_P(1, int16_t, int16); - TEST_SHMEM_P(1, int32_t, int32); - TEST_SHMEM_P(1, int64_t, int64); - TEST_SHMEM_P(1, uint8_t, uint8); - TEST_SHMEM_P(1, uint16_t, uint16); - TEST_SHMEM_P(1, uint32_t, uint32); - TEST_SHMEM_P(1, uint64_t, uint64); - TEST_SHMEM_P(1, size_t, size); - TEST_SHMEM_P(1, ptrdiff_t, ptrdiff); - - shmem_finalize(); - return rc; -} diff --git a/test/unit/cxx_test_shmem_put.cpp b/test/unit/cxx_test_shmem_put.cpp deleted file mode 100644 index ce716544d..000000000 --- a/test/unit/cxx_test_shmem_put.cpp +++ /dev/null @@ -1,245 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include - -enum op { PUT = 0, IPUT, PUT_NBI }; - -#define TEST_SHMEM_PUT(OP, USE_CTX, TYPE, TYPENAME) \ - do { \ - static TYPE remote[10]; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - TYPE local[10]; \ - for (int i = 0; i < 10; i++) \ - local[i] = (TYPE)mype; \ - switch (OP) { \ - case PUT: \ - if (USE_CTX) \ - shmem_ctx_##TYPENAME##_put(SHMEM_CTX_DEFAULT, remote, \ - local, 10, (mype + 1) % npes); \ - else \ - shmem_##TYPENAME##_put(remote, local, 10, \ - (mype + 1) % npes); \ - break; \ - case IPUT: \ - if (USE_CTX) \ - shmem_ctx_##TYPENAME##_iput(SHMEM_CTX_DEFAULT, remote,\ - local, 1, 1, 10, (mype + 1) % npes); \ - else \ - shmem_##TYPENAME##_iput(remote, local, 1, 1, 10, \ - (mype + 1) % npes); \ - break; \ - case PUT_NBI: \ - if (USE_CTX) \ - shmem_ctx_##TYPENAME##_put_nbi(SHMEM_CTX_DEFAULT, \ - remote, local, 10, (mype + 1) % npes); \ - else \ - shmem_##TYPENAME##_put_nbi(remote, local, 10, \ - (mype + 1) % npes); \ - shmem_quiet(); \ - break; \ - default: \ - printf("Invalid operation (%d)\n", OP); \ - shmem_global_exit(1); \ - } \ - shmem_barrier_all(); \ - for (int i = 0; i < 10; i++) \ - if (remote[i] != (TYPE)((mype + npes - 1) % npes)) { \ - printf("PE %i received incorrect value with " \ - "TEST_SHMEM_PUT(%s, %d, %s)\n", mype, \ - #OP, (int)(USE_CTX), #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (false) - -int main(int argc, char* argv[]) { - shmem_init(); - - int rc = EXIT_SUCCESS; - TEST_SHMEM_PUT(PUT, 0, float, float); - TEST_SHMEM_PUT(PUT, 0, double, double); - TEST_SHMEM_PUT(PUT, 0, long double, longdouble); - TEST_SHMEM_PUT(PUT, 0, char, char); - TEST_SHMEM_PUT(PUT, 0, signed char, schar); - TEST_SHMEM_PUT(PUT, 0, short, short); - TEST_SHMEM_PUT(PUT, 0, int, int); - TEST_SHMEM_PUT(PUT, 0, long, long); - TEST_SHMEM_PUT(PUT, 0, long long, longlong); - TEST_SHMEM_PUT(PUT, 0, unsigned char, uchar); - TEST_SHMEM_PUT(PUT, 0, unsigned short, ushort); - TEST_SHMEM_PUT(PUT, 0, unsigned int, uint); - TEST_SHMEM_PUT(PUT, 0, unsigned long, ulong); - TEST_SHMEM_PUT(PUT, 0, unsigned long long, ulonglong); - TEST_SHMEM_PUT(PUT, 0, int8_t, int8); - TEST_SHMEM_PUT(PUT, 0, int16_t, int16); - TEST_SHMEM_PUT(PUT, 0, int32_t, int32); - TEST_SHMEM_PUT(PUT, 0, int64_t, int64); - TEST_SHMEM_PUT(PUT, 0, uint8_t, uint8); - TEST_SHMEM_PUT(PUT, 0, uint16_t, uint16); - TEST_SHMEM_PUT(PUT, 0, uint32_t, uint32); - TEST_SHMEM_PUT(PUT, 0, uint64_t, uint64); - TEST_SHMEM_PUT(PUT, 0, size_t, size); - TEST_SHMEM_PUT(PUT, 0, ptrdiff_t, ptrdiff); - - TEST_SHMEM_PUT(PUT, 1, float, float); - TEST_SHMEM_PUT(PUT, 1, double, double); - TEST_SHMEM_PUT(PUT, 1, long double, longdouble); - TEST_SHMEM_PUT(PUT, 1, char, char); - TEST_SHMEM_PUT(PUT, 1, signed char, schar); - TEST_SHMEM_PUT(PUT, 1, short, short); - TEST_SHMEM_PUT(PUT, 1, int, int); - TEST_SHMEM_PUT(PUT, 1, long, long); - TEST_SHMEM_PUT(PUT, 1, long long, longlong); - TEST_SHMEM_PUT(PUT, 1, unsigned char, uchar); - TEST_SHMEM_PUT(PUT, 1, unsigned short, ushort); - TEST_SHMEM_PUT(PUT, 1, unsigned int, uint); - TEST_SHMEM_PUT(PUT, 1, unsigned long, ulong); - TEST_SHMEM_PUT(PUT, 1, unsigned long long, ulonglong); - TEST_SHMEM_PUT(PUT, 1, int8_t, int8); - TEST_SHMEM_PUT(PUT, 1, int16_t, int16); - TEST_SHMEM_PUT(PUT, 1, int32_t, int32); - TEST_SHMEM_PUT(PUT, 1, int64_t, int64); - TEST_SHMEM_PUT(PUT, 1, uint8_t, uint8); - TEST_SHMEM_PUT(PUT, 1, uint16_t, uint16); - TEST_SHMEM_PUT(PUT, 1, uint32_t, uint32); - TEST_SHMEM_PUT(PUT, 1, uint64_t, uint64); - TEST_SHMEM_PUT(PUT, 1, size_t, size); - TEST_SHMEM_PUT(PUT, 1, ptrdiff_t, ptrdiff); - - TEST_SHMEM_PUT(IPUT, 0, float, float); - TEST_SHMEM_PUT(IPUT, 0, double, double); - TEST_SHMEM_PUT(IPUT, 0, long double, longdouble); - TEST_SHMEM_PUT(IPUT, 0, char, char); - TEST_SHMEM_PUT(IPUT, 0, signed char, schar); - TEST_SHMEM_PUT(IPUT, 0, short, short); - TEST_SHMEM_PUT(IPUT, 0, int, int); - TEST_SHMEM_PUT(IPUT, 0, long, long); - TEST_SHMEM_PUT(IPUT, 0, long long, longlong); - TEST_SHMEM_PUT(IPUT, 0, unsigned char, uchar); - TEST_SHMEM_PUT(IPUT, 0, unsigned short, ushort); - TEST_SHMEM_PUT(IPUT, 0, unsigned int, uint); - TEST_SHMEM_PUT(IPUT, 0, unsigned long, ulong); - TEST_SHMEM_PUT(IPUT, 0, unsigned long long, ulonglong); - TEST_SHMEM_PUT(IPUT, 0, int8_t, int8); - TEST_SHMEM_PUT(IPUT, 0, int16_t, int16); - TEST_SHMEM_PUT(IPUT, 0, int32_t, int32); - TEST_SHMEM_PUT(IPUT, 0, int64_t, int64); - TEST_SHMEM_PUT(IPUT, 0, uint8_t, uint8); - TEST_SHMEM_PUT(IPUT, 0, uint16_t, uint16); - TEST_SHMEM_PUT(IPUT, 0, uint32_t, uint32); - TEST_SHMEM_PUT(IPUT, 0, uint64_t, uint64); - TEST_SHMEM_PUT(IPUT, 0, size_t, size); - TEST_SHMEM_PUT(IPUT, 0, ptrdiff_t, ptrdiff); - - TEST_SHMEM_PUT(IPUT, 1, float, float); - TEST_SHMEM_PUT(IPUT, 1, double, double); - TEST_SHMEM_PUT(IPUT, 1, long double, longdouble); - TEST_SHMEM_PUT(IPUT, 1, char, char); - TEST_SHMEM_PUT(IPUT, 1, signed char, schar); - TEST_SHMEM_PUT(IPUT, 1, short, short); - TEST_SHMEM_PUT(IPUT, 1, int, int); - TEST_SHMEM_PUT(IPUT, 1, long, long); - TEST_SHMEM_PUT(IPUT, 1, long long, longlong); - TEST_SHMEM_PUT(IPUT, 1, unsigned char, uchar); - TEST_SHMEM_PUT(IPUT, 1, unsigned short, ushort); - TEST_SHMEM_PUT(IPUT, 1, unsigned int, uint); - TEST_SHMEM_PUT(IPUT, 1, unsigned long, ulong); - TEST_SHMEM_PUT(IPUT, 1, unsigned long long, ulonglong); - TEST_SHMEM_PUT(IPUT, 1, int8_t, int8); - TEST_SHMEM_PUT(IPUT, 1, int16_t, int16); - TEST_SHMEM_PUT(IPUT, 1, int32_t, int32); - TEST_SHMEM_PUT(IPUT, 1, int64_t, int64); - TEST_SHMEM_PUT(IPUT, 1, uint8_t, uint8); - TEST_SHMEM_PUT(IPUT, 1, uint16_t, uint16); - TEST_SHMEM_PUT(IPUT, 1, uint32_t, uint32); - TEST_SHMEM_PUT(IPUT, 1, uint64_t, uint64); - TEST_SHMEM_PUT(IPUT, 1, size_t, size); - TEST_SHMEM_PUT(IPUT, 1, ptrdiff_t, ptrdiff); - - TEST_SHMEM_PUT(PUT_NBI, 0, float, float); - TEST_SHMEM_PUT(PUT_NBI, 0, double, double); - TEST_SHMEM_PUT(PUT_NBI, 0, long double, longdouble); - TEST_SHMEM_PUT(PUT_NBI, 0, char, char); - TEST_SHMEM_PUT(PUT_NBI, 0, signed char, schar); - TEST_SHMEM_PUT(PUT_NBI, 0, short, short); - TEST_SHMEM_PUT(PUT_NBI, 0, int, int); - TEST_SHMEM_PUT(PUT_NBI, 0, long, long); - TEST_SHMEM_PUT(PUT_NBI, 0, long long, longlong); - TEST_SHMEM_PUT(PUT_NBI, 0, unsigned char, uchar); - TEST_SHMEM_PUT(PUT_NBI, 0, unsigned short, ushort); - TEST_SHMEM_PUT(PUT_NBI, 0, unsigned int, uint); - TEST_SHMEM_PUT(PUT_NBI, 0, unsigned long, ulong); - TEST_SHMEM_PUT(PUT_NBI, 0, unsigned long long, ulonglong); - TEST_SHMEM_PUT(PUT_NBI, 0, int8_t, int8); - TEST_SHMEM_PUT(PUT_NBI, 0, int16_t, int16); - TEST_SHMEM_PUT(PUT_NBI, 0, int32_t, int32); - TEST_SHMEM_PUT(PUT_NBI, 0, int64_t, int64); - TEST_SHMEM_PUT(PUT_NBI, 0, uint8_t, uint8); - TEST_SHMEM_PUT(PUT_NBI, 0, uint16_t, uint16); - TEST_SHMEM_PUT(PUT_NBI, 0, uint32_t, uint32); - TEST_SHMEM_PUT(PUT_NBI, 0, uint64_t, uint64); - TEST_SHMEM_PUT(PUT_NBI, 0, size_t, size); - TEST_SHMEM_PUT(PUT_NBI, 0, ptrdiff_t, ptrdiff); - - TEST_SHMEM_PUT(PUT_NBI, 1, float, float); - TEST_SHMEM_PUT(PUT_NBI, 1, double, double); - TEST_SHMEM_PUT(PUT_NBI, 1, long double, longdouble); - TEST_SHMEM_PUT(PUT_NBI, 1, char, char); - TEST_SHMEM_PUT(PUT_NBI, 1, signed char, schar); - TEST_SHMEM_PUT(PUT_NBI, 1, short, short); - TEST_SHMEM_PUT(PUT_NBI, 1, int, int); - TEST_SHMEM_PUT(PUT_NBI, 1, long, long); - TEST_SHMEM_PUT(PUT_NBI, 1, long long, longlong); - TEST_SHMEM_PUT(PUT_NBI, 1, unsigned char, uchar); - TEST_SHMEM_PUT(PUT_NBI, 1, unsigned short, ushort); - TEST_SHMEM_PUT(PUT_NBI, 1, unsigned int, uint); - TEST_SHMEM_PUT(PUT_NBI, 1, unsigned long, ulong); - TEST_SHMEM_PUT(PUT_NBI, 1, unsigned long long, ulonglong); - TEST_SHMEM_PUT(PUT_NBI, 1, int8_t, int8); - TEST_SHMEM_PUT(PUT_NBI, 1, int16_t, int16); - TEST_SHMEM_PUT(PUT_NBI, 1, int32_t, int32); - TEST_SHMEM_PUT(PUT_NBI, 1, int64_t, int64); - TEST_SHMEM_PUT(PUT_NBI, 1, uint8_t, uint8); - TEST_SHMEM_PUT(PUT_NBI, 1, uint16_t, uint16); - TEST_SHMEM_PUT(PUT_NBI, 1, uint32_t, uint32); - TEST_SHMEM_PUT(PUT_NBI, 1, uint64_t, uint64); - TEST_SHMEM_PUT(PUT_NBI, 1, size_t, size); - TEST_SHMEM_PUT(PUT_NBI, 1, ptrdiff_t, ptrdiff); - - shmem_finalize(); - return rc; -} diff --git a/test/unit/cxx_test_shmem_sum_prod_reduce.cpp b/test/unit/cxx_test_shmem_sum_prod_reduce.cpp deleted file mode 100644 index 79b2087e1..000000000 --- a/test/unit/cxx_test_shmem_sum_prod_reduce.cpp +++ /dev/null @@ -1,210 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2023 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#define MAX_NPES 32 - -enum op { OP_SUM, OP_PROD }; - -const double FLOATING_POINT_TOLERANCE = 1e-6; - -#define REDUCTION(OP, TYPE) \ - do { \ - switch (OP) { \ - case OP_SUM: \ - ret = shmem_##TYPE##_sum_reduce(SHMEM_TEAM_WORLD, dest, src, \ - npes); \ - break; \ - case OP_PROD: \ - ret = shmem_##TYPE##_prod_reduce(SHMEM_TEAM_WORLD, dest, src, \ - npes); \ - break; \ - default: \ - printf("Invalid operation (%d)\n", OP); \ - shmem_global_exit(1); \ - } \ - } while (0) - -#define INIT_SRC_BUFFER(TYPE) \ - do { \ - for (int i = 0; i < MAX_NPES; i++) { \ - src[i] = (TYPE)1ULL; \ - } \ - } while (0) - -#define CHECK_DEST_BUFFER(OP, TYPE, CORRECT_VAL) \ - do { \ - for (int i = 0; i < npes; i++) { \ - if (dest[i] != (TYPE)CORRECT_VAL) { \ - printf("PE %i received incorrect value with " \ - "TEST_SHMEM_REDUCE(%s, %s)\n", mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } \ - } while (0) - -#define CHECK_DEST_BUFFER_FP(OP, TYPE, CORRECT_VAL, TOLERANCE) \ - do { \ - for (int i = 0; i < npes; i++) { \ - if (fabsl(creal(dest[i]) - creal((TYPE)CORRECT_VAL)) > TOLERANCE) { \ - printf("PE %i received incorrect real value with " \ - "TEST_SHMEM_REDUCE(%s, %s)\n", mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - if (fabsl(cimag(dest[i]) - cimag((TYPE)CORRECT_VAL)) > TOLERANCE) { \ - printf("PE %i received incorrect imaginary value with " \ - "TEST_SHMEM_REDUCE(%s, %s)\n", mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } \ - } while (0) - -#define TEST_SHMEM_REDUCE(OP, TYPENAME, TYPE) \ - do { \ - static TYPE src[MAX_NPES]; \ - static TYPE dest[MAX_NPES]; \ - int ret; \ - const bool floating_point_val = std::is_floating_point::value; \ - \ - INIT_SRC_BUFFER(TYPE); \ - REDUCTION(OP, TYPENAME); \ - \ - if (ret != 0) { \ - printf("Reduction returned non-zero value (%i) on PE (%i) with " \ - "TEST_SHMEM_REDUCE(%s, %s)\n", ret, mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - \ - shmem_barrier_all(); \ - \ - switch (OP) { \ - case OP_SUM: \ - if (floating_point_val) \ - CHECK_DEST_BUFFER_FP(OP, TYPE, npes, FLOATING_POINT_TOLERANCE); \ - else \ - CHECK_DEST_BUFFER(OP, TYPE, npes); \ - break; \ - case OP_PROD: \ - if (floating_point_val) \ - CHECK_DEST_BUFFER_FP(OP, TYPE, 1ULL, FLOATING_POINT_TOLERANCE); \ - else \ - CHECK_DEST_BUFFER(OP, TYPE, 1ULL); \ - break; \ - default: \ - printf("Invalid operation (%d)\n", OP); \ - shmem_global_exit(1); \ - } \ - } while (0) - - -int main(void) { - - shmem_init(); - - int rc = EXIT_SUCCESS; - - const int mype = shmem_my_pe(); - const int npes = shmem_n_pes(); - - if (npes > MAX_NPES) { - if (mype == 0) - fprintf(stderr, "ERR - Requires less than %d PEs\n", MAX_NPES); - shmem_global_exit(1); - } - - TEST_SHMEM_REDUCE(OP_SUM, char, char); - TEST_SHMEM_REDUCE(OP_SUM, schar, signed char); - TEST_SHMEM_REDUCE(OP_SUM, short, short); - TEST_SHMEM_REDUCE(OP_SUM, int, int); - TEST_SHMEM_REDUCE(OP_SUM, long, long); - TEST_SHMEM_REDUCE(OP_SUM, longlong, long long); - TEST_SHMEM_REDUCE(OP_SUM, ptrdiff, ptrdiff_t); - TEST_SHMEM_REDUCE(OP_SUM, uchar, unsigned char); - TEST_SHMEM_REDUCE(OP_SUM, ushort, unsigned short); - TEST_SHMEM_REDUCE(OP_SUM, uint, unsigned int); - TEST_SHMEM_REDUCE(OP_SUM, ulong, unsigned long); - TEST_SHMEM_REDUCE(OP_SUM, ulonglong, unsigned long long); - TEST_SHMEM_REDUCE(OP_SUM, int8, int8_t); - TEST_SHMEM_REDUCE(OP_SUM, int16, int16_t); - TEST_SHMEM_REDUCE(OP_SUM, int32, int32_t); - TEST_SHMEM_REDUCE(OP_SUM, int64, int64_t); - TEST_SHMEM_REDUCE(OP_SUM, uint8, uint8_t); - TEST_SHMEM_REDUCE(OP_SUM, uint16, uint16_t); - TEST_SHMEM_REDUCE(OP_SUM, uint32, uint32_t); - TEST_SHMEM_REDUCE(OP_SUM, uint64, uint64_t); - TEST_SHMEM_REDUCE(OP_SUM, size, size_t); - TEST_SHMEM_REDUCE(OP_SUM, float, float); - TEST_SHMEM_REDUCE(OP_SUM, double, double); - TEST_SHMEM_REDUCE(OP_SUM, longdouble, long double); - TEST_SHMEM_REDUCE(OP_SUM, complexd, double _Complex); - TEST_SHMEM_REDUCE(OP_SUM, complexf, float _Complex); - - TEST_SHMEM_REDUCE(OP_PROD, char, char); - TEST_SHMEM_REDUCE(OP_PROD, schar, signed char); - TEST_SHMEM_REDUCE(OP_PROD, short, short); - TEST_SHMEM_REDUCE(OP_PROD, int, int); - TEST_SHMEM_REDUCE(OP_PROD, long, long); - TEST_SHMEM_REDUCE(OP_PROD, longlong, long long); - TEST_SHMEM_REDUCE(OP_PROD, ptrdiff, ptrdiff_t); - TEST_SHMEM_REDUCE(OP_PROD, uchar, unsigned char); - TEST_SHMEM_REDUCE(OP_PROD, ushort, unsigned short); - TEST_SHMEM_REDUCE(OP_PROD, uint, unsigned int); - TEST_SHMEM_REDUCE(OP_PROD, ulong, unsigned long); - TEST_SHMEM_REDUCE(OP_PROD, ulonglong, unsigned long long); - TEST_SHMEM_REDUCE(OP_PROD, int8, int8_t); - TEST_SHMEM_REDUCE(OP_PROD, int16, int16_t); - TEST_SHMEM_REDUCE(OP_PROD, int32, int32_t); - TEST_SHMEM_REDUCE(OP_PROD, int64, int64_t); - TEST_SHMEM_REDUCE(OP_PROD, uint8, uint8_t); - TEST_SHMEM_REDUCE(OP_PROD, uint16, uint16_t); - TEST_SHMEM_REDUCE(OP_PROD, uint32, uint32_t); - TEST_SHMEM_REDUCE(OP_PROD, uint64, uint64_t); - TEST_SHMEM_REDUCE(OP_PROD, size, size_t); - TEST_SHMEM_REDUCE(OP_PROD, float, float); - TEST_SHMEM_REDUCE(OP_PROD, double, double); - TEST_SHMEM_REDUCE(OP_PROD, longdouble, long double); - TEST_SHMEM_REDUCE(OP_PROD, complexd, double _Complex); - TEST_SHMEM_REDUCE(OP_PROD, complexf, float _Complex); - - fprintf(stdout, "Test passed with ret = %d\n", rc); - - shmem_finalize(); - return rc; -} diff --git a/test/unit/cxx_test_shmem_test.cpp b/test/unit/cxx_test_shmem_test.cpp deleted file mode 100644 index 3127f9061..000000000 --- a/test/unit/cxx_test_shmem_test.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include - -#define TEST_SHMEM_TEST(TYPE, TYPENAME) \ - do { \ - static TYPE remote = 0; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - shmem_##TYPENAME##_p(&remote, (TYPE)mype+1, \ - (mype + 1) % npes); \ - while (!shmem_##TYPENAME##_test(&remote, \ - SHMEM_CMP_NE, 0)) ; \ - if (remote != (TYPE)((mype + npes - 1) % npes)+1) { \ - printf("PE %i received incorrect value with " \ - "TEST_SHMEM_TEST(%s)\n", mype, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (false) - -int main(int argc, char* argv[]) { - shmem_init(); - - int rc = EXIT_SUCCESS; - TEST_SHMEM_TEST(int, int); - TEST_SHMEM_TEST(long, long); - TEST_SHMEM_TEST(long long, longlong); - TEST_SHMEM_TEST(unsigned int, uint); - TEST_SHMEM_TEST(unsigned long, ulong); - TEST_SHMEM_TEST(unsigned long long, ulonglong); - TEST_SHMEM_TEST(int32_t, int32); - TEST_SHMEM_TEST(int64_t, int64); - TEST_SHMEM_TEST(uint32_t, uint32); - TEST_SHMEM_TEST(uint64_t, uint64); - TEST_SHMEM_TEST(size_t, size); - TEST_SHMEM_TEST(ptrdiff_t, ptrdiff); - - shmem_finalize(); - return rc; -} diff --git a/test/unit/cxx_test_shmem_wait_until.cpp b/test/unit/cxx_test_shmem_wait_until.cpp deleted file mode 100644 index 31b913a5c..000000000 --- a/test/unit/cxx_test_shmem_wait_until.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include - -#define TEST_SHMEM_WAIT_UNTIL(TYPE, TYPENAME) \ - do { \ - static TYPE remote = 0; \ - const int mype = shmem_my_pe(); \ - const int npes = shmem_n_pes(); \ - shmem_##TYPENAME##_p(&remote, (TYPE)mype+1, \ - (mype + 1) % npes); \ - shmem_##TYPENAME##_wait_until(&remote, \ - SHMEM_CMP_NE, 0); \ - if (remote != (TYPE)((mype + npes - 1) % npes)+1) { \ - printf("PE %i received incorrect value with " \ - "TEST_SHMEM_WAIT_UNTIL(%s)\n", mype, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } while (false) - -int main(int argc, char* argv[]) { - shmem_init(); - - int rc = EXIT_SUCCESS; - TEST_SHMEM_WAIT_UNTIL(int, int); - TEST_SHMEM_WAIT_UNTIL(long, long); - TEST_SHMEM_WAIT_UNTIL(long long, longlong); - TEST_SHMEM_WAIT_UNTIL(unsigned int, uint); - TEST_SHMEM_WAIT_UNTIL(unsigned long, ulong); - TEST_SHMEM_WAIT_UNTIL(unsigned long long, ulonglong); - TEST_SHMEM_WAIT_UNTIL(int32_t, int32); - TEST_SHMEM_WAIT_UNTIL(int64_t, int64); - TEST_SHMEM_WAIT_UNTIL(uint32_t, uint32); - TEST_SHMEM_WAIT_UNTIL(uint64_t, uint64); - TEST_SHMEM_WAIT_UNTIL(size_t, size); - TEST_SHMEM_WAIT_UNTIL(ptrdiff_t, ptrdiff); - - shmem_finalize(); - return rc; -} diff --git a/test/unit/fadd_nbi.c b/test/unit/fadd_nbi.c deleted file mode 100644 index a89dc59c6..000000000 --- a/test/unit/fadd_nbi.c +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2018 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include "tests_sos/wtime.h" - -long ctr = 0; - -int main(void) { - int me, npes, i; - long *out; - double t; - - shmem_init(); - - me = shmem_my_pe(); - npes = shmem_n_pes(); - - out = malloc(sizeof(long) * npes); - - /* Test blocking fetch-add */ - - ctr = 0; - shmem_barrier_all(); - t = tests_sos_wtime(); - - for (i = 0; i < npes; i++) { - out[i] = shmem_long_atomic_fetch_add(&ctr, 1, i); - } - - shmem_barrier_all(); - t = tests_sos_wtime() - t; - - if (me == 0) printf("fetch_add %10.2fus\n", t*1000000); - - if (ctr != npes) - shmem_global_exit(1); - - for (i = 0; i < npes; i++) - if (!(out[i] >= 0 && out[i] < npes)) - shmem_global_exit(2); - - /* Test NBI fetch-add */ - - ctr = 0; - shmem_barrier_all(); - t = tests_sos_wtime(); - - for (i = 0; i < npes; i++) { - shmem_long_atomic_fetch_add_nbi(&out[i], &ctr, 1, i); - } - - shmem_barrier_all(); - t = tests_sos_wtime() - t; - - if (me == 0) printf("fetch_add_nbi %10.2fus\n", t*1000000); - - if (ctr != npes) - shmem_global_exit(1); - - for (i = 0; i < npes; i++) - if (!(out[i] >= 0 && out[i] < npes)) - shmem_global_exit(2); - - shmem_finalize(); - return 0; -} diff --git a/test/unit/fcollect64.c b/test/unit/fcollect64.c deleted file mode 100644 index 4045e2787..000000000 --- a/test/unit/fcollect64.c +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - * shmem_collect test cat {-v -l loops} {nLongs(12)} {loopIncr(0)} - * - * For yod/mpirun -c/np X - */ -#include - -#include -#include -#include -#include -#include - -#define AMEG (1024UL*1024UL) -#define AGIG (1024UL*1024UL*1024UL) - -#ifndef TRUE -#define TRUE (1) -#define FALSE (0) -#endif - -#define Rfprintf if (shmem_my_pe() == 0) fprintf -#define Rprintf if (shmem_my_pe() == 0) printf -#define RVfprintf if (Verbose && shmem_my_pe() == 0) fprintf -#define RVprintf if (Verbose && shmem_my_pe() == 0) printf -#define Vprintf if (Verbose) printf -#define Vfprintf if (Verbose) fprintf - -#define RDprintf if (Verbose && shmem_my_pe() == 0) printf -#define RDfprintf if (Verbose && shmem_my_pe() == 0) fprintf - -/* option flags */ -int Verbose; - -#define DFLT_NWORDS 16 -#define DFLT_INCR 32 -#define DFLT_LOOPS 20 - -#define VAL 0xCafeBabe - -long *dst; -long *src; - -static int -atoi_scaled(char *s) -{ - long val; - char *e; - - val = strtol(s,&e,0); - if (e == NULL || *e =='\0') - return val; - - if (*e == 'k' || *e == 'K') - val *= 1024; - else if (*e == 'm' || *e == 'M') - val *= 1024*1024; - else if (*e == 'g' || *e == 'G') - val *= 1024*1024*1024; - - return (int) val; -} - -int -main(int argc, char* argv[]) -{ - int c, j, cloop, loops = DFLT_LOOPS; - int mpe, num_pes; - int nWords=1; - int nIncr=1; - int failures=0; - char *pgm; - - shmem_init(); - mpe = shmem_my_pe(); - num_pes = shmem_n_pes(); - - if (num_pes == 1) { - Rfprintf(stderr, - "ERR - Requires > 1 PEs\n"); - shmem_finalize(); - return 0; - } - pgm = strrchr(argv[0],'/'); - if ( pgm ) - pgm++; - else - pgm = argv[0]; - - while((c=getopt(argc,argv,"hqVvl:")) != -1) { - switch(c) { - case 'V': - case 'v': - Verbose++; - break; - case 'l': - loops = atoi(optarg); - break; - case 'h': - Rfprintf(stderr, - "usage: %s {-l loopcnt(%d)} {numLongs(%d)} {loopIncr(%d)}\n", - pgm,DFLT_LOOPS,DFLT_NWORDS,DFLT_INCR); - shmem_finalize(); - return 1; - default: - shmem_finalize(); - return 1; - } - } - - if (optind == argc) - nWords = DFLT_NWORDS; - else { - nWords = atoi_scaled(argv[optind++]); - if (nWords <= 0) { - Rfprintf(stderr, "ERR - Bad nBytes arg?\n"); - shmem_finalize(); - return 1; - } - } - - if (optind == argc) - nIncr = DFLT_INCR; - else { - loops = atoi(argv[optind++]); - if (nIncr <= 0 ) { - Rfprintf(stderr, "ERR - incLongs arg out of bounds '%d'?\n", nIncr); - shmem_finalize(); - return 1; - } - } - - if ( nWords % 8 ) { // integral multiple of longs - Rprintf("%s: nWords(%d) not a multiple of %ld?\n", - pgm,nWords,sizeof(long)); - shmem_finalize(); - return 1; - } - - if (Verbose && mpe == 0) - fprintf(stderr,"loops(%d) nWords(%d) incr-per-loop(%d)\n", - loops,nWords,nIncr); - - for(cloop=1; cloop <= loops; cloop++) { - - c = (sizeof(long)*nWords) * (num_pes + 1); // src + dst allocation. - //nWords /= sizeof(long); // convert input of bytes --> longs. - - src = (long*)shmem_malloc(c); - if ( !src ) { - Rprintf("[%d] %s: shmem_malloc(%d) failed?\n", mpe, pgm,c); - shmem_global_exit(1); - } - dst = &src[nWords]; - - for(j=0; j < nWords; j++) - src[j] = (long) (j + mpe*nWords); - - shmem_barrier_all(); - - shmem_long_fcollect(SHMEM_TEAM_WORLD, dst,src,nWords); - - // Expect dst to be consecuative integers 0 ... (nLongs*num_pes)-1 - for(j=0; j < (nWords*num_pes); j++) { - if ( dst[j] != (long) j ) { - fprintf(stderr, - "[%d] dst[%d] %ld != expected %d\n",mpe,j,dst[j],j); - shmem_global_exit(1); - } - } - shmem_barrier_all(); - - if (Verbose && mpe == 0 && loops > 1) { - fprintf(stderr,"."); - } - nWords += nIncr; - } - - if (Verbose && mpe == 0) { - fprintf(stderr,"\n");fflush(stderr); - } - shmem_free( (void*)src ); - shmem_barrier_all(); - if (Verbose) - printf("%d(%d) Exit(%d)\n", mpe, num_pes, failures); - - shmem_finalize(); - - return failures; -} diff --git a/test/unit/get1.c b/test/unit/get1.c deleted file mode 100644 index 34d28577a..000000000 --- a/test/unit/get1.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include - -#include -#include - -static long source[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; -static long target[10]; - -int -main(int argc, char* argv[]) -{ - int i; - - shmem_init(); - - if (shmem_n_pes() == 1) { - printf("%s: Requires number of PEs > 1\n", argv[0]); - shmem_finalize(); - return 0; - } - - if (shmem_my_pe() == 0) { - memset(target, 0, sizeof(target)); - /* put 10 elements into target on PE 1 */ - shmem_long_get(target, source, 10, 1); - } - - shmem_barrier_all(); /* sync sender and receiver */ - - if (shmem_my_pe() == 0) { - if (0 != memcmp(source, target, sizeof(long) * 10)) { - fprintf(stderr,"[%d] Src & Target mismatch?\n",shmem_my_pe()); - for (i = 0 ; i < 10 ; ++i) { - printf("%ld,%ld ", source[i], target[i]); - } - printf("\n"); - shmem_global_exit(1); - } - } - - shmem_finalize(); - - return 0; -} diff --git a/test/unit/get_g.c b/test/unit/get_g.c deleted file mode 100644 index 986d48bbf..000000000 --- a/test/unit/get_g.c +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include - -#include -#include -#include - -static short *src_short; -static int *src_int; -static float *src_float; -static double *src_double; -static long *src_long; - -static short dst_short; -static int dst_int; -static float dst_float; -static double dst_double; -static long dst_long; - -static int loops = 100; - -int -main(int argc, char* argv[]) -{ - int me, num_pes, pe, l; - int Verbose = 0; - char *pgm; - - if ((pgm=strrchr(argv[0],'/'))) { - pgm++; - } else { - pgm = argv[0]; - } - - if (argc > 1) { - if (strncmp(argv[1],"-v",3) == 0) { - Verbose=1; - } else if (strncmp(argv[1],"-h",3) == 0) { - fprintf(stderr,"usage: %s {-v(verbose)|h(help)}\n",pgm); - shmem_finalize(); - exit(1); - } - } - - shmem_init(); - me = shmem_my_pe(); - num_pes = shmem_n_pes(); - - // be a bit sane with total number of gets issued - loops = loops / num_pes; - if (loops < 5) loops = 5; - - for (l = 0 ; l < loops ; ++l) { - if ((src_short = shmem_malloc(sizeof(short))) == NULL) { - printf("PE-%d short shmem_malloc() failed?\n", me); - shmem_global_exit(1); - } - *src_short = 2; - - if ((src_int = shmem_malloc(sizeof(int))) == NULL) { - printf("PE-%d int shmem_malloc() failed?\n", me); - shmem_global_exit(1); - } - *src_int = 4; - - if ((src_float = shmem_malloc(sizeof(float))) == NULL) { - printf("PE-%d float shmem_malloc() failed?\n", me); - shmem_global_exit(1); - } - *src_float = 4.0; - - if ((src_double = shmem_malloc(sizeof(double))) == NULL) { - printf("PE-%d double shmem_malloc() failed?\n", me); - shmem_global_exit(1); - } - *src_double = 8.0; - - if ((src_long = shmem_malloc(sizeof(long))) == NULL) { - printf("PE-%d long shmem_malloc() failed?\n", me); - shmem_global_exit(1); - } - *src_long = 8; - - shmem_barrier_all(); - - for (pe=0 ; pe < num_pes; ++pe) { - if (!shmem_addr_accessible(src_short,pe)) { - printf("PE-%d local addr %p not accessible from PE-%d?\n", - me, (void*)src_short, pe); - shmem_global_exit(1); - } - dst_short = 0; - dst_short = shmem_short_g(src_short,pe); - if (dst_short != 2) { - printf("PE-%d dst_short %hd != 2?\n",me,dst_short); - shmem_global_exit(1); - } - dst_int = 0; - dst_int = shmem_int_g(src_int,pe); - if (dst_int != 4) { - printf("PE-%d dst_int %d != 4?\n",me,dst_int); - shmem_global_exit(1); - } - dst_float = 0.0; - dst_float = shmem_float_g(src_float,pe); - if (dst_float != 4.0) { - printf("PE-%d dst_float %f != 4.0?\n",me,dst_float); - shmem_global_exit(1); - } - dst_double = 0.0; - dst_double = shmem_double_g(src_double,pe); - if (dst_double != 8.0) { - printf("PE-%d dst_double %f != 8.0?\n",me,dst_double); - shmem_global_exit(1); - } - dst_long = 0; - dst_long = shmem_long_g(src_long,pe); - if (dst_long != 8.0) { - printf("PE-%d dst_long %ld != 8?\n",me,dst_long); - shmem_global_exit(1); - } - } - - shmem_barrier_all(); - - shmem_free(src_short); - shmem_free(src_int); - shmem_free(src_float); - shmem_free(src_double); - shmem_free(src_long); - } - - if (Verbose) - fprintf(stderr,"[%d] exit\n",shmem_my_pe()); - - shmem_finalize(); - - return 0; -} diff --git a/test/unit/get_nbi.c b/test/unit/get_nbi.c deleted file mode 100644 index ee85023ee..000000000 --- a/test/unit/get_nbi.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* Non-Blocking Get Test - * Tom St. John - * January, 2016 - * - * PE 0 uses a non-blocking get to copy an array from - * every remote PE. - */ - -#include - -#include -#include - -static long source[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; -static long target[10]; - -int -main(int argc, char* argv[]) -{ - int i, j, num_pes; - int failed = 0; - - shmem_init(); - - if (shmem_my_pe() == 0) { - num_pes=shmem_n_pes(); - - for(j = 0; j < num_pes; j++) { - memset(target, 0, sizeof(long) * 10); - shmem_long_get_nbi(target, source, 10, j); - shmem_quiet(); - - for (i = 0; i < 10; i++) { - if (source[i] != target[i]) { - fprintf(stderr,"[%d] get_nbi from PE %d: target[%d] = %ld, expected %ld\n", - shmem_my_pe(), j, i, target[i], source[i]); - failed = 1; - } - } - - if (failed) - shmem_global_exit(1); - } - } - - shmem_finalize(); - - return 0; -} diff --git a/test/unit/global_exit.c b/test/unit/global_exit.c deleted file mode 100644 index 245e13948..000000000 --- a/test/unit/global_exit.c +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include - -int -main(int argc, char* argv[]) -{ - shmem_init(); - - if (shmem_my_pe() == 0) { - shmem_global_exit(0); - abort(); - } - - /* All other PEs wait in this barrier */ - shmem_barrier_all(); - - shmem_finalize(); - - return 0; -} diff --git a/test/unit/hello.c b/test/unit/hello.c deleted file mode 100644 index c1c694b4a..000000000 --- a/test/unit/hello.c +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include - -int -main(int argc, char* argv[], char *envp[]) -{ - int me, myshmem_n_pes; - /* - ** Starts/Initializes SHMEM/OpenSHMEM - */ - shmem_init(); - /* - ** Fetch the number or processes - ** Some implementations use num_pes(); - */ - myshmem_n_pes = shmem_n_pes(); - /* - ** Assign my process ID to me - */ - me = shmem_my_pe(); - - if (NULL == getenv("MAKELEVEL")) { - printf("Hello World from %d of %d\n", me, myshmem_n_pes); - } - - shmem_finalize(); - - return 0; -} diff --git a/test/unit/hello_f.f90 b/test/unit/hello_f.f90 deleted file mode 100644 index 80166fee9..000000000 --- a/test/unit/hello_f.f90 +++ /dev/null @@ -1,43 +0,0 @@ -! -! Copyright 2011 Sandia Corporation. Under the terms of Contract -! DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government -! retains certain rights in this software. -! -! Copyright (c) 2017 Intel Corporation. All rights reserved. -! This software is available to you under the BSD license below: -! -! Redistribution and use in source and binary forms, with or -! without modification, are permitted provided that the following -! conditions are met: -! -! - Redistributions of source code must retain the above -! copyright notice, this list of conditions and the following -! disclaimer. -! -! - Redistributions in binary form must reproduce the above -! copyright notice, this list of conditions and the following -! disclaimer in the documentation and/or other materials -! provided with the distribution. -! -! THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -! EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -! MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -! NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -! BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -! ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -! CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -! SOFTWARE. -! - -program hello - include 'shmem.fh' - - integer npes, me - - call start_pes(0) - npes = num_pes() - me = my_pe() - - print *,'I am ', me, ' of ', npes - -end program hello diff --git a/test/unit/ipgm.c b/test/unit/ipgm.c deleted file mode 100644 index 5e98ff184..000000000 --- a/test/unit/ipgm.c +++ /dev/null @@ -1,373 +0,0 @@ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - * ipgm / shmem iput/iget multiple - * usage: ipgm [-rmhd] [nWords] [loops] [incWords-per-loop] - * where: - * -r == use shmem_realloc() per loop - * -n == use shmem_malloc() + shmem_free() per loop - * -h == help text. - * -d/v == enable debug. - * - * start-loop - * shmem_malloc() or shmem_realloc() src and target arrays. - * PE0 puts nWords to PE1 ... PE(num_pes-1) - * PE* validates received data - * PE* adds shmem_my_pe() to each received data element. - * PE0 pulls/iget()s data from PE* into loop/PE specific results range. - * PE0 validates received for each PE. - * if shmem_malloc() then shmem_free() - * nWords += incWords - * end-loop - */ - -#include -#include -#include -#include -#include - -#include - -#define DFLT_NWORDS 16 -#define DFLT_LOOPS 16 -#define DFLT_INCR 16 - -#define DataType long -#define IPUT shmem_long_iput -#define IGET shmem_long_iget - -static DataType *source; -static DataType *target; -static DataType *results; - -static char *pgm; -static int Debug; /* ==1 std dbg, 2==more, 3==max */ - -#define Dprintf if (Debug && me==0) printf -#define Zprintf if (me==0) printf - -void usage (void); -int getSize (char *); -int target_data_good(DataType *, int, int, int); - -void -usage (void) -{ - if (shmem_my_pe() == 0) { - fprintf (stderr, - "Usage: %s {-rmhv} [nWords(%d)] [loops(%d)] [incWords(%d)]\n", - pgm,DFLT_NWORDS,DFLT_LOOPS,DFLT_INCR); - fprintf (stderr, - " where:\n" - " -r == use shmem_realloc() instead of shmem_malloc()\n" - " -m == use shmem_malloc() instead of shmem_realloc()\n" - " -v == Verbose output\n" - " -h == help.\n"); - } - shmem_global_exit(1); -} - -int -getSize (char *str) -{ - int size; - char mod[32]; - - switch (sscanf (str, "%d%1[mMkK]", &size, mod)) - { - case 1: - return (size); - - case 2: - switch (*mod) - { - case 'm': - case 'M': - return (size << 20); - - case 'k': - case 'K': - return (size << 10); - - default: - return (size); - } - - default: - return (-1); - } -} - -int -target_data_good( DataType *data, int elements, int id, int lineno ) -{ - int j, k, rc=0; - - for(j=0,k=1; j < elements; j++,k+=2) { - if ( data[j] != ((DataType)k + id) ) { - printf("PE[%d] ERR @ line#%d data[%d] wanted %d != %ld\n", - shmem_my_pe(), lineno, j, k+id, data[j] ); - - for(rc=0,k=1; rc < elements; rc++,k++) { - printf("%ld ",data[rc]); - } - rc = 1; - break; - } - else - if (Debug > 2) printf("%ld ",data[j]); - } - if (Debug > 2 || rc) - printf("\n"); - fflush(stdout); - return rc; -} - -int -main(int argc, char **argv) -{ - int me, nProcs, workers, rc=0, l, j, c, Malloc=1; - int nWords, nWords_start, prev_sz=0, ridx, loops, incWords; - - pgm = strrchr(argv[0],'/'); - if ( pgm ) - pgm++; - else - pgm = argv[0]; - - shmem_init(); - me = shmem_my_pe(); - nProcs = shmem_n_pes(); - workers = nProcs - 1; - - if (nProcs <= 1) { - fprintf(stderr, "ERR - Requires > 1 PEs\n"); - shmem_finalize(); - return 0; - } - - while ((c = getopt (argc, argv, "hmrvdD")) != -1) - switch (c) - { - case 'm': - Malloc=1; - break; - case 'r': - Malloc=0; - break; - case 'v': - case 'd': - Debug++; - break; - case 'D': - Debug=2; - break; - case 'h': - default: - usage(); - break; - } - - if (optind == argc) - nWords = DFLT_NWORDS; - else if ((nWords = getSize (argv[optind++])) <= 0) - usage (); - - if (nWords % 2 != 0) { - if (me == 0) - fprintf(stderr," nWords(%d) not even?\n",nWords); - shmem_finalize(); - exit(1); - } - nWords_start = nWords; - - if (optind == argc) - loops = DFLT_LOOPS; - else if ((loops = getSize (argv[optind++])) < 0) - usage (); - - if (optind == argc) - incWords = DFLT_INCR; - else if ((incWords = getSize (argv[optind++])) < 0) - usage (); - - if (loops > 1 ) { - if (incWords > 0 && ((incWords % 2) != 0)) { - if (me == 0) - fprintf(stderr," incWords(%d) not even?\n",incWords); - shmem_finalize(); - exit(1); - } - } - - if (Debug && me == 0) - printf("%s: workers(%d) nWords(%d) loops(%d) nWords-incr-per-loop(%d)\n", - pgm, workers, nWords, loops, incWords); - - for(l=0,ridx=0; l < loops; l++) { - // reserve space for worker PEs to deposit data - rc = ((workers * nWords) * sizeof(DataType)) + prev_sz; - if (Debug > 2) - printf("alloc: results[%ld]\n",(rc/sizeof(DataType))); - results = (DataType *)shmem_realloc(results,rc); - if (!results) - { - perror ("Failed results memory allocation"); - shmem_global_exit(1); - } - prev_sz = rc; - - if (me==0 && Debug > 2) { - int idx = ridx; - printf("alloc: results[%ld] ridx %d psz %ld\n", - (rc/sizeof(DataType)),ridx,(prev_sz/sizeof(DataType))); - for(j=1; j < nProcs; j++) { - printf(" PE[%d] results[%d...%d]\n", - j,idx,(idx+(nWords-1))); - idx += nWords; - } - } - - rc = (2 * nWords) * sizeof(DataType); - if (Debug > 2) - printf("source %ld words\n",rc/sizeof(DataType)); - if (Malloc) - source = (DataType *)shmem_malloc(rc); - else - source = (DataType *)shmem_realloc(source,rc); - - if (! source) { - perror ("Failed source memory allocation"); - shmem_global_exit(1); - } - if (Debug > 3) - printf("shmem_malloc() source %p (%d bytes)\n",(void*)source,rc); - - /* init source data */ - for(j=0; j < nWords*2; j++) - source[j] = j+1; - - rc = nWords * sizeof(DataType); - if (Debug > 2) - printf("target %ld words\n",rc/sizeof(DataType)); - if (Malloc) - target = (DataType *)shmem_malloc(rc); - else - target = (DataType *)shmem_realloc(target,rc); - - if ( ! target ) { - perror ("Failed target memory allocation"); - shmem_global_exit(1); - } - memset(target, 0, rc); - if (Debug > 3) - printf("shmem_malloc() target %p (%d bytes)\n",(void*)target,rc); - - shmem_barrier_all(); - - if (me == 0) { - /* put nWords of DataType into target on PE's [1 to (nProcs-1)] */ - for(j=1; j < nProcs; j++) - IPUT(target, source, 1, 2, nWords, j); - } - - shmem_barrier_all(); - - if (me != 0) { - // Verify iput target data - rc = target_data_good(target, nWords, 0, __LINE__); - if (rc) - shmem_global_exit(1); - // add my PE to target data so PE0 will know I have seen the data. - for(j=0; j < nWords; j++) - target[j] += me; - } - - shmem_barrier_all(); - - if (me == 0) { - // Pull data from PE1...(nProcs-1) - // iget() target[0...nWords] --> - // results[0 ... nWords] == loop-0 PE1 results - // results[loop*PE1*nWords ... PE*nWords] == loop-0 PE1 results - - for(j=1; j < nProcs; j++) { - if (Debug > 1) - printf("PE[0] iget(%d words PE[%d]) results[%d...%d]\n", - nWords,j,ridx,(ridx+(nWords-1))); - IGET(&results[ridx], target, 1, 1, nWords, j); - rc = target_data_good( &results[ridx], nWords, j, __LINE__); - if (rc) - shmem_global_exit(1); - ridx += nWords; - } - } - - shmem_barrier_all(); - - if (Malloc) { - shmem_free(source); - shmem_free(target); - } - - nWords += incWords; - - if (Debug && me == 0 && loops > 1) - printf("End loop %d: nWords %d\n", (l+1), nWords); - - shmem_barrier_all(); - } - - if (me == 0) { - nWords = nWords_start; - for(l=0,ridx=0; l < loops; l++) { - for(j=1; j < nProcs; j++) { - if (Debug > 1) - printf(" Validate: loop %d PE-%d ridx %d nWords %d\n", - l,j,ridx,nWords); - rc = target_data_good( &results[ridx], nWords, j, __LINE__); - if (rc) - shmem_global_exit(1); - ridx += nWords; - } - nWords += incWords; - } - } - - if (Debug) - printf("PE-%d exit(0)\n",me); - - shmem_finalize(); - - return 0; -} diff --git a/test/unit/iput-iget.c b/test/unit/iput-iget.c deleted file mode 100644 index 047b3d564..000000000 --- a/test/unit/iput-iget.c +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - * adaptation of example from SGI man page for shmem_iput. - * Enhanced to not limit PE count. - */ - -#include -#include -#include - -#include - -#define WRDS 5 - -short source[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; -static short target[10]; -static short *results; - -int -main(int argc, char **argv) -{ - int me, nProcs, rc=0, j, k; - - shmem_init(); - me = shmem_my_pe(); - nProcs = shmem_n_pes(); - - if (me == 0) { - /* put words into target on PE's [1 to (nProcs-1)] */ - for(j=1; j < nProcs; j++) - shmem_short_iput(target, source, 1, 2, WRDS, j); - } - - results = (short*)shmem_malloc(nProcs * WRDS * sizeof(short)); - assert(results); - memset((void*)results, 0, (nProcs * WRDS * sizeof(short))); - - shmem_barrier_all(); /* sync sender and receiver */ - - if (me != 0) { - // Verify iput data is expected - if (target[0] != 1 || - target[1] != 3 || - target[2] != 5 || - target[3] != 7 || - target[4] != 9) - { - printf("%s ERR: target on PE %d is %hd %hd %hd %hd %hd\n" - " Expected 1,3,5,7,9?\n", argv[0], - me, target[0], target[1], target[2], - target[3], target[4] ); - rc = 1; - } - } - - shmem_barrier_all(); - - if (rc != 0) - shmem_global_exit(rc); - - if (me == 0) { - // Pull data from PE1...(nProcs-1) - // iget() nProcs target[0...4] --> results[Proc*WRDS ...Proc*WRDS+WRDS] - - for(j=1,k=0; j < nProcs; j++,k+=WRDS) - shmem_short_iget(&results[k], target, 1, 1, WRDS, j); - - for(j=1,k=0; j < nProcs; j++,k+=WRDS) { - if (results[k] != 1 || - results[k+1] != 3 || - results[k+2] != 5 || - results[k+3] != 7 || - results[k+4] != 9) - { - printf("%s [%d] ERR: results %hd %hd %hd %hd %hd\n" - " Expected 1,3,5,7,9?\n", argv[0], - me, results[k], results[k+1], results[k+2], - results[k+3], results[k+4] ); - rc = 1; - } - } - } -#if _DEBUG - else { - printf("%s [%d] target is %hd %hd %hd %hd %hd\n", argv[0], - me, target[0], target[1], target[2], - target[3], target[4] ); - } -#endif - - shmem_barrier_all(); /* sync before exiting */ - shmem_free(results); - - shmem_finalize(); - - return rc; -} diff --git a/test/unit/iput128.c b/test/unit/iput128.c deleted file mode 100644 index bf2f6a204..000000000 --- a/test/unit/iput128.c +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - * adaptation of example from SGI man page for shmem_iput. - */ - -#include -#include - -#define IPUT shmem_iput128 -#ifndef __APPLE__ -#define DataType long double -#else -#define DataType __int128 -#endif - -static DataType source[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; -static DataType target[10]; - -int main(int argc, char **argv) -{ - int me, nProcs, rc=0; - - shmem_init(); - me = shmem_my_pe(); - nProcs = shmem_n_pes(); - - if (me == 0) { - int j; - /* put 5 words into target on PE's [1 to (nProcs-1)] */ - for(j=1; j < nProcs; j++) - IPUT (target, source, 1, 2, 5, j); - } - - shmem_barrier_all(); /* sync sender and receiver */ - - if (me != 0) { - if (target[0] != 1 || - target[1] != 3 || - target[2] != 5 || - target[3] != 7 || - target[4] != 9) - { -#ifndef __APPLE__ - printf("ERR: target on PE %d is %Lf %Lf %Lf %Lf %Lf\n" - " Expected 1,3,5,7,9?\n", - me, target[0], target[1], target[2], - target[3], target[4] ); -#endif - rc = 1; - } - } - - shmem_finalize(); - - return rc; -} diff --git a/test/unit/iput32.c b/test/unit/iput32.c deleted file mode 100644 index 3c607489e..000000000 --- a/test/unit/iput32.c +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - * adaptation of example from SGI man page for shmem_iput. - */ - -#include -#include -#include - -#define _IPUT(a) shmem_##a##_iput - -//#define IPUT _IPUT(int32_t) -#define IPUT shmem_iput32 -#define DataType uint32_t - -static DataType source[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; -static DataType target[10]; - -int main(int argc, char **argv) -{ - int me, nProcs, rc=0; - - shmem_init(); - me = shmem_my_pe(); - nProcs = shmem_n_pes(); - - if (me == 0) { - int j; - /* put 5 words into target on PE's [1 to (nProcs-1)] */ - for(j=1; j < nProcs; j++) - IPUT (target, source, 1, 2, 5, j); - } - - shmem_barrier_all(); /* sync sender and receiver */ - - if (me != 0) { - if (target[0] != 1 || - target[1] != 3 || - target[2] != 5 || - target[3] != 7 || - target[4] != 9) - { - printf("ERR: target on PE %d is %u %u %u %u %u\n" - " Expected 1,3,5,7,9?\n", - me, target[0], target[1], target[2], - target[3], target[4] ); - rc = 1; - } - } - - shmem_finalize(); - - return rc; -} diff --git a/test/unit/iput64.c b/test/unit/iput64.c deleted file mode 100644 index 7d53ad259..000000000 --- a/test/unit/iput64.c +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - * adaptation of example from SGI man page for shmem_iput. - */ - -#include -#include -#include - -#define _IPUT(a) shmem_##a##_iput - -//#define IPUT _IPUT(int32_t) -#define IPUT shmem_iput64 -#define DataType uint64_t - -static DataType source[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; -static DataType target[10]; - -int main(int argc, char **argv) -{ - int me, nProcs, rc=0; - - shmem_init(); - me = shmem_my_pe(); - nProcs = shmem_n_pes(); - - if (me == 0) { - int j; - /* put 5 words into target on PE's [1 to (nProcs-1)] */ - for(j=1; j < nProcs; j++) - IPUT (target, source, 1, 2, 5, j); - } - - shmem_barrier_all(); /* sync sender and receiver */ - - if (me != 0) { - if (target[0] != 1 || - target[1] != 3 || - target[2] != 5 || - target[3] != 7 || - target[4] != 9) - { - printf("ERR: target on PE %d is %ld %ld %ld %ld %ld\n" - " Expected 1,3,5,7,9?\n", - me, - (long int) target[0], - (long int) target[1], - (long int) target[2], - (long int) target[3], - (long int) target[4] ); - rc = 1; - } - } - - shmem_finalize(); - - return rc; -} diff --git a/test/unit/iput_double.c b/test/unit/iput_double.c deleted file mode 100644 index 1b521c836..000000000 --- a/test/unit/iput_double.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - * adaptation of example from SGI man page for shmem_iput. - */ - -#include -#include -#define _IPUT(a) shmem_##a##_iput - -#define IPUT _IPUT(double) -//#define IPUT shmem_longlong_iput -#define DataType double - -static DataType source[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; -static DataType target[10]; - -int main(int argc, char **argv) -{ - int me, nProcs, rc=0; - - shmem_init(); - me = shmem_my_pe(); - nProcs = shmem_n_pes(); - - if (me == 0) { - int j; - /* put 5 words into target on PE's [1 to (nProcs-1)] */ - for(j=1; j < nProcs; j++) - IPUT (target, source, 1, 2, 5, j); - } - - shmem_barrier_all(); /* sync sender and receiver */ - - if (me != 0) { - if (target[0] != 1 || - target[1] != 3 || - target[2] != 5 || - target[3] != 7 || - target[4] != 9) - { - printf("ERR: target on PE %d is %f %f %f %f %f\n" - " Expected 1,3,5,7,9?\n", - me, target[0], target[1], target[2], - target[3], target[4] ); - rc = 1; - } - } - - shmem_finalize(); - - return rc; -} diff --git a/test/unit/iput_float.c b/test/unit/iput_float.c deleted file mode 100644 index 4de725346..000000000 --- a/test/unit/iput_float.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - * adaptation of example from SGI man page for shmem_iput. - */ - -#include -#include -#define _IPUT(a) shmem_##a##_iput - -#define IPUT _IPUT(float) -//#define IPUT shmem_longlong_iput -#define DataType float - -static DataType source[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; -static DataType target[10]; - -int main(int argc, char **argv) -{ - int me, nProcs, rc=0; - - shmem_init(); - me = shmem_my_pe(); - nProcs = shmem_n_pes(); - - if (me == 0) { - int j; - /* put 5 words into target on PE's [1 to (nProcs-1)] */ - for(j=1; j < nProcs; j++) - IPUT (target, source, 1, 2, 5, j); - } - - shmem_barrier_all(); /* sync sender and receiver */ - - if (me != 0) { - if (target[0] != 1 || - target[1] != 3 || - target[2] != 5 || - target[3] != 7 || - target[4] != 9) - { - printf("ERR: target on PE %d is %f %f %f %f %f\n" - " Expected 1,3,5,7,9?\n", - me, target[0], target[1], target[2], - target[3], target[4] ); - rc = 1; - } - } - - shmem_finalize(); - - return rc; -} diff --git a/test/unit/iput_long.c b/test/unit/iput_long.c deleted file mode 100644 index 207af756e..000000000 --- a/test/unit/iput_long.c +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - * adaptation of example from SGI man page for shmem_iput. - */ - -#include -#include -#define _IPUT(a) shmem_##a##_iput - -#define IPUT _IPUT(long) -#define DataType long - -static DataType source[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; -static DataType target[10]; - -int main(int argc, char **argv) -{ - int me, nProcs, rc=0; - - shmem_init(); - me = shmem_my_pe(); - nProcs = shmem_n_pes(); - - if (me == 0) { - int j; - /* put 5 words into target on PE's [1 to (nProcs-1)] */ - for(j=1; j < nProcs; j++) - IPUT (target, source, 1, 2, 5, j); - } - - shmem_barrier_all(); /* sync sender and receiver */ - - if (me != 0) { - if (target[0] != 1 || - target[1] != 3 || - target[2] != 5 || - target[3] != 7 || - target[4] != 9) - { - printf("ERR: target on PE %d is %ld %ld %ld %ld %ld\n" - " Expected 1,3,5,7,9?\n", - me, target[0], target[1], target[2], - target[3], target[4] ); - rc = 1; - } - } - - shmem_finalize(); - - return rc; -} diff --git a/test/unit/iput_longdouble.c b/test/unit/iput_longdouble.c deleted file mode 100644 index 753c0166e..000000000 --- a/test/unit/iput_longdouble.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - * adaptation of example from SGI man page for shmem_iput. - */ - -#include -#include -#define _IPUT(a) shmem_##a##_iput - -//#define IPUT _IPUT(double) -#define IPUT shmem_longdouble_iput -#define DataType long double - -static DataType source[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; -static DataType target[10]; - -int main(int argc, char **argv) -{ - int me, nProcs, rc=0; - - shmem_init(); - me = shmem_my_pe(); - nProcs = shmem_n_pes(); - - if (me == 0) { - int j; - /* put 5 words into target on PE's [1 to (nProcs-1)] */ - for(j=1; j < nProcs; j++) - IPUT (target, source, 1, 2, 5, j); - } - - shmem_barrier_all(); /* sync sender and receiver */ - - if (me != 0) { - if (target[0] != 1 || - target[1] != 3 || - target[2] != 5 || - target[3] != 7 || - target[4] != 9) - { - printf("ERR: target on PE %d is %Lf %Lf %Lf %Lf %Lf\n" - " Expected 1,3,5,7,9?\n", - me, target[0], target[1], target[2], - target[3], target[4] ); - rc = 1; - } - } - - shmem_finalize(); - - return rc; -} diff --git a/test/unit/iput_longlong.c b/test/unit/iput_longlong.c deleted file mode 100644 index f4feb92d8..000000000 --- a/test/unit/iput_longlong.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - * adaptation of example from SGI man page for shmem_iput. - */ - -#include -#include -#define _IPUT(a) shmem_##a##_iput - -//#define IPUT _IPUT(long) -#define IPUT shmem_longlong_iput -#define DataType long long - -static DataType source[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; -static DataType target[10]; - -int main(int argc, char **argv) -{ - int me, nProcs, rc=0; - - shmem_init(); - me = shmem_my_pe(); - nProcs = shmem_n_pes(); - - if (me == 0) { - int j; - /* put 5 words into target on PE's [1 to (nProcs-1)] */ - for(j=1; j < nProcs; j++) - IPUT (target, source, 1, 2, 5, j); - } - - shmem_barrier_all(); /* sync sender and receiver */ - - if (me != 0) { - if (target[0] != 1 || - target[1] != 3 || - target[2] != 5 || - target[3] != 7 || - target[4] != 9) - { - printf("ERR: target on PE %d is %lld %lld %lld %lld %lld\n" - " Expected 1,3,5,7,9?\n", - me, target[0], target[1], target[2], - target[3], target[4] ); - rc = 1; - } - } - - shmem_finalize(); - - return rc; -} diff --git a/test/unit/iput_short.c b/test/unit/iput_short.c deleted file mode 100644 index a0f3ce1be..000000000 --- a/test/unit/iput_short.c +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - * adaptation of example from SGI man page for shmem_iput. - */ - -#include -#include -#define _IPUT(a) shmem_##a##_iput - -#define IPUT _IPUT(short) -#define DataType short - -static DataType source[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; -static DataType target[10]; - -int main(int argc, char **argv) -{ - int me, nProcs, rc=0; - - shmem_init(); - me = shmem_my_pe(); - nProcs = shmem_n_pes(); - - if (me == 0) { - int j; - /* put 5 words into target on PE's [1 to (nProcs-1)] */ - for(j=1; j < nProcs; j++) - IPUT (target, source, 1, 2, 5, j); - } - - shmem_barrier_all(); /* sync sender and receiver */ - - if (me != 0) { - if (target[0] != 1 || - target[1] != 3 || - target[2] != 5 || - target[3] != 7 || - target[4] != 9) - { - printf("ERR: target on PE %d is %hd %hd %hd %hd %hd\n" - " Expected 1,3,5,7,9?\n", - me, target[0], target[1], target[2], - target[3], target[4] ); - rc = 1; - } - } - - shmem_finalize(); - - return rc; -} diff --git a/test/unit/lfinc.c b/test/unit/lfinc.c deleted file mode 100644 index d8599a7cc..000000000 --- a/test/unit/lfinc.c +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* long_finc neighbor - Perf test shmem_atomic_fetch_inc(); */ - -#include -#include -#include -#include -#include -#include - -#include -#include "tests_sos/wtime.h" - -#define LOOPS 25000 - -int Verbose; -double elapsed; - -int main( int argc, char *argv[]) -{ - int rc=0, my_pe, npes, neighbor; - int loops=LOOPS; - int j; - size_t data_sz=sizeof(long) * 3; - double start_time; - long *data, lval=0; - - if (argc > 1) - loops = atoi(argv[1]); - - shmem_init(); - - my_pe = shmem_my_pe(); - npes = shmem_n_pes(); - - if (loops <= 0) { - if (my_pe == 0) - printf("Error: loops must be greater than 0\n"); - - shmem_finalize(); - return 1; - } - - data = shmem_malloc(data_sz); - if (!data) { - fprintf(stderr,"[%d] shmem_malloc(%ld) failure? %d\n", - my_pe,data_sz,errno); - shmem_global_exit(1); - } - memset((void*)data,0,data_sz); - - shmem_barrier_all(); - - neighbor = (my_pe + 1) % npes; - start_time = tests_sos_wtime(); - for(j=0,elapsed=0.0; j < loops; j++) { - start_time = tests_sos_wtime(); - lval = shmem_long_atomic_fetch_inc( (void*)&data[1], neighbor ); - elapsed += tests_sos_wtime() - start_time; - if (lval != (long) j) { - fprintf(stderr,"[%d] Test: FAIL previous val %ld != %d Exit.\n", - my_pe, lval, j); - shmem_global_exit(1); - } - } - shmem_barrier_all(); - - rc = 0; - if (data[1] != (long)loops) { - fprintf(stderr,"[%d] finc neighbot: FAIL data[1](%p) %ld != %d Exit.\n", - my_pe, (void*)&data[1], data[1], loops); - rc--; - } - - /* check if adjancent memory locations distrubed */ - assert(data[0] == 0); - assert(data[2] == 0); - - if (my_pe == 0 ) { - if (rc == 0 && Verbose) - fprintf(stderr,"[%d] finc neighbor: PASSED.\n",my_pe); - fprintf(stderr,"[%d] %d loops of shmem_long_atomic_fetch_inc() in %6.4f secs\n" - " %2.6f usecs per shmem_long_atomic_fetch_inc()\n", - my_pe,loops,elapsed,((elapsed*100000.0)/(double)loops)); - } - shmem_free(data); - - shmem_finalize(); - - return rc; -} - diff --git a/test/unit/many-ctx.c b/test/unit/many-ctx.c deleted file mode 100644 index 68e692f5c..000000000 --- a/test/unit/many-ctx.c +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include - -#define NUM_CTX 32 - -long data = 0; - -int main(int argc, char **argv) { - int me, npes, i; - int errors = 0; - shmem_ctx_t ctx[NUM_CTX]; - - shmem_init(); - - me = shmem_my_pe(); - npes = shmem_n_pes(); - - for (i = 0; i < NUM_CTX; i++) { - int err = shmem_ctx_create(0, &ctx[i]); - - if (err) { - printf("%d: Warning, could not create context %d (%d)\n", me, i, err); - ctx[i] = SHMEM_CTX_DEFAULT; - } - } - - for (i = 0; i < NUM_CTX; i++) - shmem_ctx_long_atomic_inc(ctx[i], &data, (me+1) % npes); - - for (i = 0; i < NUM_CTX; i++) - shmem_ctx_quiet(ctx[i]); - - shmem_sync_all(); - - if (data != NUM_CTX) { - printf("%d: error expected %d, got %ld\n", me, NUM_CTX, data); - ++errors; - } - - shmem_finalize(); - return errors; -} diff --git a/test/unit/max_reduction.c b/test/unit/max_reduction.c deleted file mode 100644 index 57cbf114b..000000000 --- a/test/unit/max_reduction.c +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* -* reduce [0...num_pes] -*/ - -#include -#include -#include -#include - -#define N 3 - -long src[N]; -long dst[N]; - -#define MAX(a, b) ((a) > (b)) ? (a) : (b) -#define WRK_SIZE MAX(N/2+1, SHMEM_REDUCE_MIN_WRKDATA_SIZE) - -int -main(int argc, char* argv[]) -{ - int i, Verbose=0; - char *pgm; - - if ((pgm=strrchr(argv[0],'/'))) { - pgm++; - } else { - pgm = argv[0]; - } - - if (argc > 1) { - if (strncmp(argv[1],"-v",3) == 0) { - Verbose=1; - } else if (strncmp(argv[1],"-h",3) == 0) { - fprintf(stderr,"usage: %s {v(verbose)|h(help)}\n",pgm); - shmem_finalize(); - exit(1); - } - } - - shmem_init(); - - for (i = 0; i < N; i += 1) { - src[i] = shmem_my_pe() + i; - } - shmem_barrier_all(); - - shmem_long_max_reduce(SHMEM_TEAM_WORLD, dst, src, N); - - if (Verbose) { - printf("%d/%d\tdst =", shmem_my_pe(), shmem_n_pes() ); - for (i = 0; i < N; i+= 1) { - printf(" %ld", dst[i]); - } - printf("\n"); - } - - for (i = 0; i < N; i+= 1) { - if (dst[i] != shmem_n_pes() - 1 + i) { - printf("[%3d] Error: dst[%d] == %ld, expected %ld\n", - shmem_my_pe(), i, dst[i], shmem_n_pes() - 1 + (long) i); - shmem_global_exit(1); - } - } - - shmem_finalize(); - - return 0; -} diff --git a/test/unit/micro_unit_shmem.c b/test/unit/micro_unit_shmem.c deleted file mode 100644 index b6f796bf5..000000000 --- a/test/unit/micro_unit_shmem.c +++ /dev/null @@ -1,462 +0,0 @@ -/* - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - *for back to back operation testing: independent buffers for each operation - *as well as alternating PE waiting - * */ - -#include -#include -#include -#include -#include -#include -#include -#include - -typedef enum { - NUM_WRITE = 8, - NUM_READ = 5, - NUM_SYNC = 3 -} max_ops; - -int target[NUM_WRITE]; -int source[NUM_READ]; -int sync_pes[NUM_SYNC]; - -int verbose; -int debug; - - -static inline void wait_until(int *wait_var, int iterations, int pe) -{ - - if (debug) - printf("PE %d waiting...%d\n", pe, *wait_var); - - shmem_int_wait_until(wait_var, SHMEM_CMP_EQ, iterations); - - if (debug) - printf("PE %d wait_until passed\n", pe); - -} - -static inline void pre_op_check(const char *op, - int check_var, int iterations, int pe) -{ - if (verbose) - printf("SHMEM %s, performing %d iterations\n", - op, iterations); - - if (debug) - printf("BEFORE operation PE %d target = %d\n", - pe, check_var); -} - -static inline void post_op_check(const char *op, - int check_var, int iterations, int pe) -{ - - if (check_var != iterations) { - fprintf(stderr, "%s ERR: PE %d source = %d != %d\n", - op, pe, check_var, iterations); - shmem_global_exit(EXIT_FAILURE); - } -} - -static inline void putfence(int me, int iterations, int T) -{ - int i; - - if (me == 1) - pre_op_check(__func__, target[T], iterations, 1); - - if (me == 0) { - for (i = 1; i < iterations; i++) { - shmem_int_p(&target[T], i, 1); - shmem_fence(); - } - - shmem_int_p(&target[T], i, 1); - - } else - wait_until(&target[T], iterations, 1); - - if (verbose) - if (me == 0) - printf("SHMEM %s finished\n", __func__); - -} - - -static inline void gettest(int me, int iterations, int T, int S, int P) -{ - - int i; - - if (me == 1) { - pre_op_check(__func__, target[T], iterations, 1); - - shmem_int_p(&source[S], iterations, 0); - shmem_fence(); - - for (i = 0; i < iterations; i++) - target[T] = shmem_int_g(&source[S], 0); - - shmem_int_p(&sync_pes[P], iterations, 0); - - post_op_check("get", target[T], iterations, 1); - - } else - wait_until(&sync_pes[P], iterations, 0); - - if (verbose) { - if (me == 0) - printf("SHMEM %s finished\n", __func__); - } -} - -static inline void atomic_inc(int me, int iterations, int T) -{ - - int i; - - if (me == 1) - pre_op_check(__func__, target[T], iterations, 1); - - target[T] = 0; - shmem_barrier_all(); - - if (me == 0) { - for (i = 0; i < iterations; i++) { - shmem_int_atomic_inc(&target[T], 1); - shmem_fence(); - } - shmem_int_atomic_inc(&target[T], 1); - - if (debug) - printf("PE 0 done with operation\n"); - - } else - wait_until(&target[T], (iterations+1), 1); - - if (verbose) { - if (me == 1) - printf("SHMEM %s finished\n", __func__); - } -} - -static inline void atomic_add(int me, int iterations, int T) -{ - - int i; - - if (me == 0) - pre_op_check(__func__, target[T], iterations, 0); - - target[T] = 0; - shmem_barrier_all(); - - if (me == 1) { - for (i = 0; i < iterations; i++) { - shmem_int_atomic_add(&target[T], 1, 0); - shmem_fence(); - } - shmem_int_atomic_add(&target[T], 1, 0); - - if (debug) - printf("PE 1 done with operation\n"); - - } else - wait_until(&target[T], (iterations+1), 0); - - if (verbose) { - if (me == 1) - printf("SHMEM %s finished\n", __func__); - } -} - - -static inline void swaptest(int me, int iterations, int T, int S, int P) -{ - - int i; - const int tswap = 5, sswap = 2; - target[T] = tswap; - source[S] = sswap; - - shmem_barrier_all(); /* Ensure target/source initialization completed */ - - if (me == 0) - pre_op_check(__func__, source[S], iterations, 0); - - if (me == 0) { - for (i = 0; i < iterations; i++) - source[S] = shmem_int_atomic_swap(&target[T], source[S], 1); - - shmem_int_p(&sync_pes[P], i, 1); - - if (debug) - printf("AFTER flag PE 0 value of source is %d" - " = 5?\n", source[S]); - - if (((iterations % 2 == 1) && (source[S] != tswap)) || - ((iterations % 2 == 0) && - (source[S] != sswap))) { - fprintf(stderr, "swap ERR: PE 0 source = %d\n", - source[S]); - shmem_global_exit(EXIT_FAILURE); - } - - } else { - wait_until(&sync_pes[P], iterations, 1); - - if (((iterations % 2 == 1) && (target[T] != sswap)) || - ((iterations % 2 == 0) && - (target[T] != tswap))) { - fprintf(stderr, "swap ERR: PE 0 target = %d \n", - target[T]); - shmem_global_exit(EXIT_FAILURE); - } - - } - - if (verbose) { - if (me == 0) - printf("SHMEM %s finished\n", __func__); - } -} - -static inline void cswaptest(int me, int iterations, int T, int S, int P) -{ - - int i; - source[S] = -100; - - target[T] = 0; - shmem_barrier_all(); - - if (me == 1) { - pre_op_check(__func__, source[S], iterations, 1); - - for (i = 0; i < iterations; i++) - source[S] = shmem_int_atomic_compare_swap(&(target[T]), i, (i+1), 0); - - shmem_int_p(&sync_pes[P], i, 0); - - post_op_check("compare_swap", source[S], (iterations-1), 1); - - } else { - wait_until(&sync_pes[P], iterations, 0); - - if (target[T] != iterations) { - fprintf(stderr, "compare_swap ERR: PE 1 target = %d != %d\n", - target[T], iterations); - shmem_global_exit(EXIT_FAILURE); - } - } - - if (verbose) { - if (me == 1) - printf("SHMEM %s finished\n", __func__); - } -} - -static inline void fetchatomic_add(int me, int iterations, int T, int S) -{ - - int i; - - if (me == 1) - pre_op_check(__func__, target[T], iterations, 1); - - target[T] = 0; - shmem_barrier_all(); - - if (me == 0) { - if (debug) { - printf("BEFORE flag PE 0 value of source is" - " %d = 0?\n", source[S]); - } - - for (i = 0; i < iterations; i++) { - source[S] = shmem_int_atomic_fetch_add(&target[T], 1, 1); - shmem_fence(); - } - source[S] = shmem_int_atomic_fetch_add(&target[T], 1, 1); - - post_op_check("fetch_add", source[S], iterations, 0); - - } else - wait_until(&target[T], (iterations+1), 1); - - if (verbose) { - if (me == 0) - printf("SHMEM %s finished\n", __func__); - } -} - -static inline void fetchatomic_inc(int me, int iterations, int T, int S) -{ - - int i; - - if (me == 0) - pre_op_check(__func__, target[T], iterations, 0); - - target[T] = 0; - shmem_barrier_all(); - - if (me == 1) { - if (debug) { - printf("BEFORE flag PE 1 value of source is %d\n", - source[S]); - } - - for (i = 0; i < iterations; i++) { - source[S] = shmem_int_atomic_fetch_inc(&target[T], 0); - shmem_fence(); - } - - post_op_check("fetch_inc", source[S], (iterations-1), 1); - } else - wait_until(&target[T], iterations, 0); - - if (verbose) { - if (me == 1) - printf("SHMEM %s finished\n", __func__); - } - -} - -int main(int argc, char **argv) -{ - int me, nproc; - int c, all_ops = 1; - int T = 0, S = 0, P = 0; - const int DEFAULT_ITR = 7; - int iterations = DEFAULT_ITR; - - shmem_init(); - - me = shmem_my_pe(); - nproc = shmem_n_pes(); - - memset(target, -1, NUM_WRITE * sizeof(int)); - memset(source, -1, NUM_READ * sizeof(int)); - memset(sync_pes, -1, NUM_SYNC * sizeof(int)); - - shmem_barrier_all(); - - if (nproc != 2) { - if (me == 0) { - fprintf(stderr, "This is a micro test and is only " - "intended to run on exactly two processes you" - " are using %d\n", nproc); - } - shmem_finalize(); - return 0; - } - - while ((c = getopt(argc, argv, "i:vdpgaAscfFh")) != -1) { - switch (c) { - case 'i': - iterations = atoi(optarg); - assert(iterations > 0); - all_ops += 2; - break; - case 'v': - verbose = 1; - all_ops++; - break; - case 'd': - debug = 1; - break; - case 'p': - putfence(me, iterations, T++); - break; - case 'g': - gettest(me, iterations, T++, S++, P++); - break; - case 'a': - atomic_add(me, iterations, T++); - break; - case 'A': - atomic_inc(me, iterations, T++); - break; - case 's': - swaptest(me, iterations, T++, S++, P++); - break; - case 'c': - cswaptest(me, iterations, T++, S++, P++); - break; - case 'f': - fetchatomic_add(me, iterations, T++, S++); - break; - case 'F': - fetchatomic_inc(me, iterations, T++, S++); - break; - case 'h': - default: - if (me == 0) { - fprintf(stderr, "input options:\n 1) single" - " argument option will run all tests by default" - "and additionally request: -v (verbose) | " - "-i \n"); - fprintf(stderr, " 2) two argument options " - "choose any combination of the following " - "to run individual tests: -i , -v" - ", -d, -p, -g, -a, -A, -s, -c, -f, -F, -h\n"); - } - shmem_finalize(); - return 1; - } - } - - if (argc == all_ops || argc == 1) { - putfence(me, iterations, T++); - gettest(me, iterations, T++, S++, P++); - atomic_add(me, iterations, T++); - atomic_inc(me, iterations, T++); - swaptest(me, iterations, T++, S++, P++); - cswaptest(me, iterations, T++, S++, P++); - fetchatomic_add(me, iterations, T++, S++); - fetchatomic_inc(me, iterations, T++, S++); - } - - if (verbose) { - if (me == 1) - printf("PE 1: PASS: %8d iterations\n", iterations); - else - printf("PE 0 Successful exit\n"); - } - - shmem_finalize(); - - return 0; -} diff --git a/test/unit/mt_a2a.c b/test/unit/mt_a2a.c deleted file mode 100644 index c1c5a88b3..000000000 --- a/test/unit/mt_a2a.c +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* Multithreaded All-to-All Test - * James Dinan - * January, 2014 - */ - -#include -#include -#include -#include -#include - -/* For systems without the PThread barrier API (e.g. MacOS) */ -#include "pthread_barrier.h" - -#define T 8 - -int dest[T] = { 0 }; -int flag[T] = { 0 }; - -int me, npes; -int errors = 0; -pthread_barrier_t fencebar; -pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; - - -static void * thread_main(void *arg) { - int tid = * (int *) arg; - int i, val, expected; - - /* TEST CONCURRENT ATOMICS */ - val = me; - for (i = 1; i <= npes; i++) - shmem_int_atomic_add(&dest[tid], val, (me + i) % npes); - - /* Ensure that fence does not overlap with communication calls */ - pthread_barrier_wait(&fencebar); - if (tid == 0) shmem_fence(); - pthread_barrier_wait(&fencebar); - - for (i = 1; i <= npes; i++) - shmem_int_atomic_inc(&flag[tid], (me + i) % npes); - - shmem_int_wait_until(&flag[tid], SHMEM_CMP_EQ, npes); - - expected = (npes-1) * npes / 2; - if (dest[tid] != expected || flag[tid] != npes) { - printf("Atomic test error: [PE = %d | TID = %d] -- " - "dest = %d (expected %d), flag = %d (expected %d)\n", - me, tid, dest[tid], expected, flag[tid], npes); - pthread_mutex_lock(&mutex); - ++errors; - pthread_mutex_unlock(&mutex); - } - - pthread_barrier_wait(&fencebar); - if (0 == tid) shmem_barrier_all(); - pthread_barrier_wait(&fencebar); - - /* TEST CONCURRENT PUTS */ - val = -1; - shmem_int_put(&dest[tid], &val, 1, (me + 1) % npes); - - /* Ensure that all puts are issued before the shmem barrier is called. */ - pthread_barrier_wait(&fencebar); - if (0 == tid) shmem_barrier_all(); - pthread_barrier_wait(&fencebar); - - /* TEST CONCURRENT GETS */ - for (i = 1; i <= npes; i++) { - shmem_int_get(&val, &dest[tid], 1, (me + i) % npes); - - expected = -1; - if (val != expected) { - printf("Put/get test error: [PE = %d | TID = %d] -- From PE %d, got %d expected %d\n", - me, tid, (me + i) % npes, val, expected); - pthread_mutex_lock(&mutex); - ++errors; - pthread_mutex_unlock(&mutex); - } - } - - pthread_barrier_wait(&fencebar); - if (0 == tid) shmem_barrier_all(); - - return NULL; -} - - -int main(int argc, char **argv) { - int tl, i, ret; - pthread_t threads[T]; - int t_arg[T]; - - ret = shmem_init_thread(SHMEM_THREAD_MULTIPLE, &tl); - - if (tl != SHMEM_THREAD_MULTIPLE || ret != 0) { - printf("Init failed (requested thread level %d, got %d, ret %d)\n", - SHMEM_THREAD_MULTIPLE, tl, ret); - - if (ret == 0) { - shmem_global_exit(1); - } else { - return ret; - } - } - - me = shmem_my_pe(); - npes = shmem_n_pes(); - - pthread_barrier_init(&fencebar, NULL, T); - - if (me == 0) printf("Starting multithreaded test on %d PEs, %d threads/PE\n", npes, T); - - for (i = 0; i < T; i++) { - int err; - t_arg[i] = i; - err = pthread_create(&threads[i], NULL, thread_main, (void*) &t_arg[i]); - assert(0 == err); - } - - for (i = 0; i < T; i++) { - int err; - err = pthread_join(threads[i], NULL); - assert(0 == err); - } - - pthread_barrier_destroy(&fencebar); - - if (me == 0) { - if (errors) printf("Encountered %d errors\n", errors); - else printf("Success\n"); - } - - shmem_finalize(); - return (errors == 0) ? 0 : 1; -} diff --git a/test/unit/mt_contention.c b/test/unit/mt_contention.c deleted file mode 100644 index a98912545..000000000 --- a/test/unit/mt_contention.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2018 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* Multithreaded Contention Test: Overlapping AMO/quiet on a shared (default) - * context */ - -#include -#include -#include -#include -#include - -#define T 8 - -int dest; - -int me, npes; -int errors = 0; - -static void * thread_main(void *arg) { - int tid = * (int *) arg; - int i; - - /* Threads increment the counter on each PE and then performs a quiet. - * All threads use the default context; thus, this checks that quiet - * with overlapping AMOs behaves correctly. */ - - for (i = 1; i <= npes; i++) - shmem_int_atomic_add(&dest, tid, (me + i) % npes); - - shmem_quiet(); - - return NULL; -} - - -int main(int argc, char **argv) { - int tl, i, ret; - pthread_t threads[T]; - int t_arg[T]; - - ret = shmem_init_thread(SHMEM_THREAD_MULTIPLE, &tl); - - if (tl != SHMEM_THREAD_MULTIPLE || ret != 0) { - printf("Init failed (requested thread level %d, got %d, ret %d)\n", - SHMEM_THREAD_MULTIPLE, tl, ret); - - if (ret == 0) { - shmem_global_exit(1); - } else { - return ret; - } - } - - me = shmem_my_pe(); - npes = shmem_n_pes(); - - if (me == 0) printf("Starting multithreaded test on %d PEs, %d threads/PE\n", npes, T); - - for (i = 0; i < T; i++) { - int err; - t_arg[i] = i; - err = pthread_create(&threads[i], NULL, thread_main, (void*) &t_arg[i]); - assert(0 == err); - } - - for (i = 0; i < T; i++) { - int err; - err = pthread_join(threads[i], NULL); - assert(0 == err); - } - - shmem_sync_all(); - - if (dest != ((T-1)*T/2)*npes) { - printf("%d: dest = %d, expected %d\n", me, dest, ((T-1)*T/2)*npes); - errors++; - } - - shmem_finalize(); - return (errors == 0) ? 0 : 1; -} diff --git a/test/unit/mt_lock.c b/test/unit/mt_lock.c deleted file mode 100644 index 44ab935b6..000000000 --- a/test/unit/mt_lock.c +++ /dev/null @@ -1,235 +0,0 @@ -/* -*- C -*- - * - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2018 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license. - * - * This file is part of the Sandia OpenSHMEM software package. For license - * information, see the LICENSE file in the top level directory of the - * distribution. - * - */ - -#include -#include -#include -#include -#include "mt_lock.h" -#include "uthash.h" - -#define MTL_QUEUE_SIZE 4 -#define DEBUG 0 - -typedef struct { - UT_hash_handle hh; - long *key; - uint64_t next_ticket; - uint64_t cur_ticket; - pthread_mutex_t mutex; - pthread_cond_t cond[]; -} mtl_guard_t; - -static mtl_guard_t *guards = NULL; -pthread_mutex_t guards_mutex = PTHREAD_MUTEX_INITIALIZER; - -#define RAISE_ERROR(err, msg) \ - do { \ - char errmsg[256]; \ - strerror_r(err, errmsg, 256); \ - fprintf(stderr, "%d: %s - %s\n", \ - shmem_my_pe(), msg, errmsg); \ - shmem_global_exit(1); \ - } while(0) - - -/* Simple queueing lock using Lamport's bakery algorithm. Uses MTL_QUEUE_SIZE - * condition variables per lock to reduce the number of threads that are woken - * up when the lock is released. */ - -static inline void mtl_qlock_lock(mtl_guard_t *g) { - int ret; - uint64_t my_ticket; - - ret = pthread_mutex_lock(&g->mutex); - if (ret) RAISE_ERROR(ret, "pthread_mutex_lock failed"); - - my_ticket = g->next_ticket++; - while (my_ticket != g->cur_ticket) { - ret = pthread_cond_wait(&g->cond[my_ticket % MTL_QUEUE_SIZE], - &g->mutex); - if (ret) RAISE_ERROR(ret, "pthread_cond_wait failed"); - } - ret = pthread_mutex_unlock(&g->mutex); - if (ret) RAISE_ERROR(ret, "pthread_mutex_unlock failed"); -} - - -static inline void mtl_qlock_unlock(mtl_guard_t *g) { - int ret; - - ret = pthread_mutex_lock(&g->mutex); - if (ret) RAISE_ERROR(ret, "pthread_mutex_lock failed"); - - g->cur_ticket++; - ret = pthread_cond_broadcast(&g->cond[g->cur_ticket % MTL_QUEUE_SIZE]); - if (ret) RAISE_ERROR(ret, "pthread_cond_broadcast failed"); - ret = pthread_mutex_unlock(&g->mutex); - if (ret) RAISE_ERROR(ret, "pthread_mutex_unlock failed"); -} - - -static inline int mtl_qlock_trylock(mtl_guard_t *g) { - int ret; - - ret = pthread_mutex_lock(&g->mutex); - if (ret) RAISE_ERROR(ret, "pthread_mutex_lock failed"); - - if (g->next_ticket == g->cur_ticket) { - g->next_ticket++; - ret = pthread_mutex_unlock(&g->mutex); - if (ret) RAISE_ERROR(ret, "pthread_mutex_unlock failed"); - return 0; - } - else { - ret = pthread_mutex_unlock(&g->mutex); - if (ret) RAISE_ERROR(ret, "pthread_mutex_unlock failed"); - return 1; - } -} - -/** Guard Implementation **/ - -static mtl_guard_t* mtl_guard_locate(long *lockp) { - int ret, i; - mtl_guard_t *g; - - pthread_mutex_lock(&guards_mutex); - HASH_FIND_PTR(guards, &lockp, g); - - if (g == NULL) { - if (DEBUG) - printf("%d: Registering guard for lock %p\n", shmem_my_pe(), - (void*) lockp); - - g = (mtl_guard_t*) - malloc(sizeof(mtl_guard_t) + sizeof(pthread_cond_t) - * MTL_QUEUE_SIZE); - if (g == NULL) { - fprintf(stderr, "%d: Out of memory allocating lock guard\n", - shmem_my_pe()); - shmem_global_exit(2); - } - - g->key = lockp; - g->next_ticket = 0; - g->cur_ticket = 0; - ret = pthread_mutex_init(&g->mutex, NULL); - if (ret) RAISE_ERROR(ret, "pthread_mutex_init failed"); - for (i = 0; i < MTL_QUEUE_SIZE ; i++) { - ret = pthread_cond_init(&g->cond[i], NULL); - if (ret) RAISE_ERROR(ret, "pthread_cond_init failed"); - } - - HASH_ADD_PTR(guards, key, g); - } - pthread_mutex_unlock(&guards_mutex); - return g; -} - - -static void mtl_guard_enter(long *lockp) { - mtl_guard_t *g = mtl_guard_locate(lockp); - mtl_qlock_lock(g); -} - - -static int mtl_guard_test_enter(long *lockp) { - mtl_guard_t *g = mtl_guard_locate(lockp); - return mtl_qlock_trylock(g); -} - - -static void mtl_guard_exit(long *lockp) { - mtl_guard_t *g; - - pthread_mutex_lock(&guards_mutex); - HASH_FIND_PTR(guards, &lockp, g); - pthread_mutex_unlock(&guards_mutex); - - if (g == NULL) { - fprintf(stderr, "%d: Attempted to clear a lock that is not held (%p)\n", - shmem_my_pe(), (void*) lockp); - shmem_global_exit(3); - } - - mtl_qlock_unlock(g); -} - -/** User-facing API **/ - -void mtl_cleanup(void) { - int ret, i; - mtl_guard_t *g; - - for (g = guards; g != NULL ; ) { - mtl_guard_t *nextg = g->hh.next; - ret = pthread_mutex_destroy(&g->mutex); - if (ret) RAISE_ERROR(ret, "pthread_mutex_destroy failed"); - for (i = 0; i < MTL_QUEUE_SIZE; i++) { - ret = pthread_cond_destroy(&g->cond[i]); - if (ret) RAISE_ERROR(ret, "pthread_cond_destroy failed"); - } - free(g); - g = nextg; - } -} - - -void mtl_clear_lock(long *lockp) { - int prov; - - shmem_clear_lock(lockp); - shmem_query_thread(&prov); - - if (prov == SHMEM_THREAD_SERIALIZED || prov == SHMEM_THREAD_MULTIPLE) - mtl_guard_exit(lockp); -} - - -void mtl_set_lock(long *lockp) { - int prov; - - /* Guards use a local mutex to prevent concurrent requests on the same - * lock. The guard is "entered" when the SHMEM lock is acquired and - * "exited" when the SHMEM lock is released. */ - shmem_query_thread(&prov); - - if (prov == SHMEM_THREAD_SERIALIZED || prov == SHMEM_THREAD_MULTIPLE) - mtl_guard_enter(lockp); - - shmem_set_lock(lockp); -} - - -int mtl_test_lock(long *lockp) { - int status, prov; - - shmem_query_thread(&prov); - - if (prov == SHMEM_THREAD_SERIALIZED || prov == SHMEM_THREAD_MULTIPLE) { - if (mtl_guard_test_enter(lockp)) - return 1; - } - - status = shmem_test_lock(lockp); - if (status == 0) - return status; - - if (prov == SHMEM_THREAD_SERIALIZED || prov == SHMEM_THREAD_MULTIPLE) - mtl_guard_exit(lockp); - - return 1; -} diff --git a/test/unit/mt_lock.h b/test/unit/mt_lock.h deleted file mode 100644 index 8e183be07..000000000 --- a/test/unit/mt_lock.h +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- C -*- - * - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2018 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license. - * - * This file is part of the Sandia OpenSHMEM software package. For license - * information, see the LICENSE file in the top level directory of the - * distribution. - * - */ - -/* MTL -- MultiThreaded Lock library for OpenSHMEM - * - * Wraps the OpenSHMEM lock API, allowing multiple threads at each PE to - * request the same SHMEM lock concurrently. */ - -#ifndef MT_LOCK_H -#define MT_LOCK_H - -#include "shmem.h" - -void mtl_clear_lock(long *lockp); -void mtl_set_lock(long *lockp); -int mtl_test_lock(long *lockp); - -/* When finished using MTL, the following routine can be used to free memory - * used by the library. */ -void mtl_cleanup(void); - -#endif /* #ifndef MT_LOCK_H */ diff --git a/test/unit/mt_lock_test.c b/test/unit/mt_lock_test.c deleted file mode 100644 index db7342cf9..000000000 --- a/test/unit/mt_lock_test.c +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (c) 2018 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* Multithreaded locking test -- Ensure the SHMEM lock API behaves correctly - * when used in a multithreaded setting. */ - -#include -#include -#include -#include -#include -#include "mt_lock.h" - -#define T 4 -#define N 4 - -long dest = 0; -long *locks; - -int me, npes; -int errors = 0; - -static void * thread_main(void *arg) { - int i, j; - - for (j = 0; j < N; j++) { - for (i = 0 ; i < npes; i++) { - /* Alternate even/odd PEs using set_lock versus a test_lock loop to - * acquire the lock */ - if ((me+j) % 2 == 0) { - mtl_set_lock(&locks[i]); - long d = shmem_long_g(&dest, i); - shmem_long_p(&dest, d+1, i); - mtl_clear_lock(&locks[i]); - } else { - while (mtl_test_lock(&locks[i])) ; - long d = shmem_long_g(&dest, i); - shmem_long_p(&dest, d+1, i); - mtl_clear_lock(&locks[i]); - } - } - } - - return NULL; -} - - -int main(int argc, char **argv) { - int tl, i, ret; - pthread_t threads[T]; - int t_arg[T]; - - ret = shmem_init_thread(SHMEM_THREAD_MULTIPLE, &tl); - - if (tl != SHMEM_THREAD_MULTIPLE || ret != 0) { - printf("Init failed (requested thread level %d, got %d, ret %d)\n", - SHMEM_THREAD_MULTIPLE, tl, ret); - - if (ret == 0) { - shmem_global_exit(1); - } else { - return ret; - } - } - - me = shmem_my_pe(); - npes = shmem_n_pes(); - locks = shmem_calloc(npes, sizeof(long)); - - if (me == 0) printf("Starting MT locking test on %d PEs, %d threads/PE\n", npes, T); - - for (i = 0; i < T; i++) { - int err; - t_arg[i] = i; - err = pthread_create(&threads[i], NULL, thread_main, (void*) &t_arg[i]); - assert(0 == err); - } - - for (i = 0; i < T; i++) { - int err; - err = pthread_join(threads[i], NULL); - assert(0 == err); - } - - mtl_cleanup(); - shmem_barrier_all(); - - if (dest != npes*T*N) { - printf("%d: Error expected %d, got %ld\n", me, npes*T*N, dest); - errors++; - } - - if (me == 0) { - if (errors) printf("Encountered %d errors\n", errors); - else printf("Success\n"); - } - - shmem_finalize(); - return (errors == 0) ? 0 : 1; -} diff --git a/test/unit/mt_membar.c b/test/unit/mt_membar.c deleted file mode 100644 index 4505e775e..000000000 --- a/test/unit/mt_membar.c +++ /dev/null @@ -1,236 +0,0 @@ -/* - * Copyright (c) 2018 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* Multi-threaded tests for validation of memory barrier implemented in - * different synchronization routines. -*/ - -#include -#include -#include -#include - -/* For systems without the PThread barrier API (e.g. MacOS) */ -#include "pthread_barrier.h" - -#define T 2 -#define ITER 100 - -#ifndef MAX -#define MAX(A,B) (((A)>(B)) ? (A) : (B)) -#endif - -int shared_dest_1 = 0, shared_dest_2 = 0, result = 0; -int me, npes, errors = 0, sum_error = 0; -long lock = 0; - -pthread_barrier_t fencebar; - -long pSync[SHMEM_REDUCE_SYNC_SIZE]; -int pWrk[MAX(1, SHMEM_REDUCE_MIN_WRKDATA_SIZE)]; - -static void * thread_main(void *arg) { - int tid = *(int *) arg; - int one = 1, zero = 0; - int i; - - /* TEST WAIT */ - for (i = 0; i < ITER; i++) { - shmem_int_wait_until(&shared_dest_1, SHMEM_CMP_EQ, tid); - shmem_int_atomic_add(&result, one, me); - shared_dest_1 = (tid + 1) % T; - } - - pthread_barrier_wait(&fencebar); - if (0 == tid) shmem_barrier_all(); - pthread_barrier_wait(&fencebar); - - if (tid == 0) { - errors += ((result == (T * ITER)) ? 0 : 1); - if (result != T * ITER) { - printf("ERROR in WAIT test from %d : result = %d, expected = %d\n", - me, result, T * ITER); - } - result = 0; - shared_dest_1 = 0; - } - - pthread_barrier_wait(&fencebar); - if (0 == tid) shmem_barrier_all(); - pthread_barrier_wait(&fencebar); - - /* TEST WAIT & FENCE WITH NON-ATOMIC READ-WRITE */ - for (i = 0; i < ITER; i++) { - shmem_int_wait_until(&shared_dest_1, SHMEM_CMP_EQ, tid); - result++; - shmem_fence(); - shared_dest_1 = (tid + 1) % T; - } - - pthread_barrier_wait(&fencebar); - if (0 == tid) shmem_barrier_all(); - pthread_barrier_wait(&fencebar); - - if (tid == 0) { - errors += ((result == (T * ITER)) ? 0 : 1); - if (result != T * ITER) { - printf("ERROR in WAIT test from %d : result = %d, expected = %d\n", - me, result, T * ITER); - } - result = 0; - shared_dest_1 = 0; - } - - pthread_barrier_wait(&fencebar); - if (0 == tid) shmem_barrier_all(); - pthread_barrier_wait(&fencebar); - - /* TEST FENCE */ - for (i = 0; i < ITER; i++) { - if (tid == 0) { - shared_dest_1 += 1; - shared_dest_2 += 1; - shmem_fence(); - shmem_int_wait_until(&shared_dest_1, SHMEM_CMP_EQ, zero); - } - - if (tid == 1) { - shmem_int_wait_until(&shared_dest_2, SHMEM_CMP_EQ, one); - shmem_int_atomic_add(&result, shared_dest_1 + shared_dest_2, me); - shared_dest_2 = 0; - shared_dest_1 = 0; - shmem_fence(); - } - } - - pthread_barrier_wait(&fencebar); - if (0 == tid) shmem_barrier_all(); - pthread_barrier_wait(&fencebar); - - if (tid == 0) { - errors += ((result == (T * ITER)) ? 0 : 1); - if (result != T * ITER) { - printf("ERROR in FENCE test from %d : result = %d, expected = %d\n", - me, result, T * ITER); - } - result = 0; - shared_dest_1 = 0; - shared_dest_2 = 0; - } - - pthread_barrier_wait(&fencebar); - if (0 == tid) shmem_barrier_all(); - pthread_barrier_wait(&fencebar); - - /* TEST LOCK */ - for (i = 0; i < ITER; i++) { - if (tid == 0) { - shmem_set_lock(&lock); - shared_dest_1 = 1; - shmem_clear_lock(&lock); - shared_dest_2 = 1; - shmem_int_wait_until(&shared_dest_2, SHMEM_CMP_EQ, zero); - } - - if (tid == 1) { - shmem_int_wait_until(&shared_dest_2, SHMEM_CMP_EQ, one); - result += shared_dest_1; - shared_dest_1 = 0; - shared_dest_2 = 0; - } - } - - pthread_barrier_wait(&fencebar); - if (0 == tid) shmem_barrier_all(); - pthread_barrier_wait(&fencebar); - - if (tid == 0) { - errors += ((result == ITER) ? 0 : 1); - if (result != ITER) { - printf("ERROR in LOCK test from %d : result = %d, expected = %d\n", - me, result, T * ITER); - } - result = 0; - } - - pthread_barrier_wait(&fencebar); - if (0 == tid) shmem_barrier_all(); - - return NULL; -} - -int main(int argc, char **argv) { - int tl, i, ret; - pthread_t threads[T]; - int t_arg[T]; - - ret = shmem_init_thread(SHMEM_THREAD_MULTIPLE, &tl); - - if (tl != SHMEM_THREAD_MULTIPLE || ret != 0) { - printf("Init failed (requested thread level %d, got %d, ret %d)\n", - SHMEM_THREAD_MULTIPLE, tl, ret); - if (ret == 0) { - shmem_global_exit(1); - } else { - return ret; - } - } - - me = shmem_my_pe(); - npes = shmem_n_pes(); - - for (i = 0; i < SHMEM_REDUCE_SYNC_SIZE; i++) { - pSync[i] = SHMEM_SYNC_VALUE; - } - - pthread_barrier_init(&fencebar, NULL, T); - - if (me == 0) { - printf("Starting multi-threaded test on %d PEs, %d threads/PE\n", npes, T); - } - - for (i = 0; i < T; i++) { - int err; - t_arg[i] = i; - err = pthread_create(&threads[i], NULL, thread_main, (void *) &t_arg[i]); - assert(0 == err); - } - - for (i = 0; i < T; i++) { - int err; - err = pthread_join(threads[i], NULL); - assert(0 == err); - } - - pthread_barrier_destroy(&fencebar); - - shmem_barrier_all(); - shmem_int_sum_reduce(SHMEM_TEAM_WORLD, &sum_error, &errors, 1); - - shmem_finalize(); - return (sum_error == 0) ? 0 : 1; -} diff --git a/test/unit/nop_collectives.c b/test/unit/nop_collectives.c deleted file mode 100644 index 13e887f99..000000000 --- a/test/unit/nop_collectives.c +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include - -long bcast_psync[SHMEM_BCAST_SYNC_SIZE]; -long collect_psync[SHMEM_COLLECT_SYNC_SIZE]; -long reduce_psync[SHMEM_REDUCE_SYNC_SIZE]; -long alltoall_psync[SHMEM_ALLTOALL_SYNC_SIZE]; -long alltoalls_psync[SHMEM_ALLTOALLS_SYNC_SIZE]; - -int pwrk[SHMEM_REDUCE_MIN_WRKDATA_SIZE]; - -int main(void) { - int me; - -#ifdef ENABLE_DEPRECATED_TESTS - int i, npes; - - for (i = 0; i < SHMEM_BCAST_SYNC_SIZE; i++) - bcast_psync[i] = SHMEM_SYNC_VALUE; - - for (i = 0; i < SHMEM_COLLECT_SYNC_SIZE; i++) - collect_psync[i] = SHMEM_SYNC_VALUE; - - for (i = 0; i < SHMEM_REDUCE_SYNC_SIZE; i++) - reduce_psync[i] = SHMEM_SYNC_VALUE; - - for (i = 0; i < SHMEM_ALLTOALL_SYNC_SIZE; i++) - alltoall_psync[i] = SHMEM_SYNC_VALUE; - - for (i = 0; i < SHMEM_ALLTOALLS_SYNC_SIZE; i++) - alltoalls_psync[i] = SHMEM_SYNC_VALUE; - - for (i = 0; i < SHMEM_REDUCE_MIN_WRKDATA_SIZE; i++) - pwrk[i] = 0; -#endif - - shmem_init(); - - me = shmem_my_pe(); - -#ifdef ENABLE_DEPRECATED_TESTS - npes = shmem_n_pes(); -#endif - - if (me == 0) printf("Testing zero length collectives\n"); - - if (me == 0) printf(" + broadcast\n"); -#ifdef ENABLE_DEPRECATED_TESTS - shmem_broadcast32(NULL, NULL, 0, 0, 0, 0, npes, bcast_psync); -#else - shmem_int_broadcast(SHMEM_TEAM_WORLD, NULL, NULL, 0, 0); -#endif - shmem_barrier_all(); -#ifdef ENABLE_DEPRECATED_TESTS - shmem_broadcast64(NULL, NULL, 0, 0, 0, 0, npes, bcast_psync); -#else - shmem_long_broadcast(SHMEM_TEAM_WORLD, NULL, NULL, 0, 0); -#endif - shmem_barrier_all(); - - if (me == 0) printf(" + collect\n"); -#ifdef ENABLE_DEPRECATED_TESTS - shmem_fcollect32(NULL, NULL, 0, 0, 0, npes, collect_psync); -#else - shmem_int_fcollect(SHMEM_TEAM_WORLD, NULL, NULL, 0); -#endif - shmem_barrier_all(); -#ifdef ENABLE_DEPRECATED_TESTS - shmem_fcollect64(NULL, NULL, 0, 0, 0, npes, collect_psync); -#else - shmem_long_fcollect(SHMEM_TEAM_WORLD, NULL, NULL, 0); -#endif - shmem_barrier_all(); - -#ifdef ENABLE_DEPRECATED_TESTS - shmem_collect32(NULL, NULL, 0, 0, 0, npes, collect_psync); -#else - shmem_int_collect(SHMEM_TEAM_WORLD, NULL, NULL, 0); -#endif - shmem_barrier_all(); -#ifdef ENABLE_DEPRECATED_TESTS - shmem_collect64(NULL, NULL, 0, 0, 0, npes, collect_psync); -#else - shmem_long_collect(SHMEM_TEAM_WORLD, NULL, NULL, 0); -#endif - shmem_barrier_all(); - - if (me == 0) printf(" + reduction\n"); -#ifdef ENABLE_DEPRECATED_TESTS - shmem_int_and_to_all(NULL, NULL, 0, 0, 0, npes, pwrk, reduce_psync); -#else - shmem_uint_and_reduce(SHMEM_TEAM_WORLD, NULL, NULL, 0); -#endif - shmem_barrier_all(); -#ifdef ENABLE_DEPRECATED_TESTS - shmem_int_or_to_all(NULL, NULL, 0, 0, 0, npes, pwrk, reduce_psync); -#else - shmem_uint_or_reduce(SHMEM_TEAM_WORLD, NULL, NULL, 0); -#endif - shmem_barrier_all(); -#ifdef ENABLE_DEPRECATED_TESTS - shmem_int_xor_to_all(NULL, NULL, 0, 0, 0, npes, pwrk, reduce_psync); -#else - shmem_uint_xor_reduce(SHMEM_TEAM_WORLD, NULL, NULL, 0); -#endif - shmem_barrier_all(); -#ifdef ENABLE_DEPRECATED_TESTS - shmem_int_min_to_all(NULL, NULL, 0, 0, 0, npes, pwrk, reduce_psync); -#else - shmem_int_min_reduce(SHMEM_TEAM_WORLD, NULL, NULL, 0); -#endif - shmem_barrier_all(); -#ifdef ENABLE_DEPRECATED_TESTS - shmem_int_max_to_all(NULL, NULL, 0, 0, 0, npes, pwrk, reduce_psync); -#else - shmem_int_max_reduce(SHMEM_TEAM_WORLD, NULL, NULL, 0); -#endif - shmem_barrier_all(); -#ifdef ENABLE_DEPRECATED_TESTS - shmem_int_sum_to_all(NULL, NULL, 0, 0, 0, npes, pwrk, reduce_psync); -#else - shmem_int_sum_reduce(SHMEM_TEAM_WORLD, NULL, NULL, 0); -#endif - shmem_barrier_all(); -#ifdef ENABLE_DEPRECATED_TESTS - shmem_int_prod_to_all(NULL, NULL, 0, 0, 0, npes, pwrk, reduce_psync); -#else - shmem_int_prod_reduce(SHMEM_TEAM_WORLD, NULL, NULL, 0); -#endif - shmem_barrier_all(); - - if (me == 0) printf(" + all-to-all\n"); -#ifdef ENABLE_DEPRECATED_TESTS - shmem_alltoall32(NULL, NULL, 0, 0, 0, npes, alltoall_psync); -#else - shmem_int_alltoall(SHMEM_TEAM_WORLD, NULL, NULL, 0); -#endif - shmem_barrier_all(); -#ifdef ENABLE_DEPRECATED_TESTS - shmem_alltoall64(NULL, NULL, 0, 0, 0, npes, alltoall_psync); -#else - shmem_long_alltoall(SHMEM_TEAM_WORLD, NULL, NULL, 0); -#endif - shmem_barrier_all(); - -#ifdef ENABLE_DEPRECATED_TESTS - shmem_alltoalls32(NULL, NULL, 1, 1, 0, 0, 0, npes, alltoalls_psync); -#else - shmem_int_alltoalls(SHMEM_TEAM_WORLD, NULL, NULL, 1, 1, 0); -#endif - shmem_barrier_all(); -#ifdef ENABLE_DEPRECATED_TESTS - shmem_alltoalls64(NULL, NULL, 1, 1, 0, 0, 0, npes, alltoalls_psync); -#else - shmem_long_alltoalls(SHMEM_TEAM_WORLD, NULL, NULL, 1, 1, 0); -#endif - - if (me == 0) printf("Done\n"); - - shmem_finalize(); - - return 0; -} diff --git a/test/unit/ns.c b/test/unit/ns.c deleted file mode 100644 index 331d5fe59..000000000 --- a/test/unit/ns.c +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - - -/* - * Neighbor swap: - * swap between odd numbered PEs and their right neighbor (modulo num_pes) - */ - -#include -#include -#include -#include - -#include - -static int atoi_scaled(char *s); -static void usage(char *pgm); - -int Verbose; - -#define DFLT_LAPS 50 - - -int -main(int argc, char *argv[]) -{ - char *pgm; - int l, laps = DFLT_LAPS; - long *target; - int me, npes; - long swapped_val, new_val; - - shmem_init(); - me = shmem_my_pe(); - npes = shmem_n_pes(); - - if ((pgm=strrchr(argv[0],'/'))) - pgm++; - else - pgm = argv[0]; - - while ((l = getopt (argc, argv, "l:vh")) != EOF) { - switch (l) - { - case 'l': - if ((laps = atoi_scaled(optarg)) <= 0) { - fprintf(stderr,"ERR: Bad loop count %d\n",laps); - shmem_finalize(); - return 1; - } - break; - case 'v': - Verbose++; - break; - case 'h': - usage(pgm); - shmem_finalize(); - return 0; - default: - if (me == 0) { - fprintf(stderr,"%s: unknown switch '-%c'?\n",pgm,l); - usage(pgm); - } - shmem_finalize(); - return 1; - } - } - - for (l=0; l < laps; l++) { - target = (long *) shmem_malloc(sizeof (*target)); - if (!target) { - fprintf(stderr,"[%d] shmem_malloc() failed?\n",me); - shmem_global_exit(1); - } - - *target = me; - new_val = me; - - shmem_barrier_all(); - - if (me & 1) { - swapped_val = shmem_long_atomic_swap(target, new_val, (me + 1) % npes); - if (Verbose > 1) - printf("[%d] target %ld, swapped %ld\n", - me, *target, swapped_val); - } - shmem_barrier_all(); - shmem_free (target); - if (Verbose == 1 && me == 0) fprintf(stderr,"."); - } - if (Verbose && me == 0) fprintf(stderr,"\n"); - - shmem_finalize(); - - return 0; -} - - -static int -atoi_scaled(char *s) -{ - long val; - char *e; - - val = strtol(s,&e,0); - if (e == NULL || *e =='\0') - return (int)val; - - if (*e == 'k' || *e == 'K') - val *= 1024; - else if (*e == 'm' || *e == 'M') - val *= 1024*1024; - else if (*e == 'g' || *e == 'G') - val *= 1024*1024*1024; - - return (int)val; -} - -static void -usage(char *pgm) -{ - fprintf(stderr, - "usage: %s -{lhv}\n" - " where:\n" - " -l loops (%d) loop count.\n" - " -v be verbose, multiple 'v' more verbose\n" - " -h this text.\n", - pgm,DFLT_LAPS); -} - diff --git a/test/unit/pcontrol.c b/test/unit/pcontrol.c deleted file mode 100644 index 75eb4975f..000000000 --- a/test/unit/pcontrol.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include - -int -main(int argc, char* argv[], char *envp[]) -{ - shmem_init(); - - shmem_pcontrol(1, "Region 1"); - shmem_barrier_all(); - - shmem_pcontrol(1, "Region 2"); - shmem_barrier_all(); - - shmem_finalize(); - - return 0; -} diff --git a/test/unit/pi.c b/test/unit/pi.c deleted file mode 100644 index 5dec99626..000000000 --- a/test/unit/pi.c +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include -#include - -#define NUM_POINTS 10000 - - -long long inside = 0, total = 0; - -int -main(int argc, char* argv[], char *envp[]) -{ - int me, myshmem_n_pes; - /* - ** Starts/Initializes SHMEM/OpenSHMEM - */ - shmem_init(); - /* - ** Fetch the number or processes - ** Some implementations use num_pes(); - */ - myshmem_n_pes = shmem_n_pes(); - /* - ** Assign my process ID to me - */ - me = shmem_my_pe(); - - srand(1+me); - - for(total = 0; total < NUM_POINTS; ++total) { - double x,y; - x = rand()/(double)RAND_MAX; - y = rand()/(double)RAND_MAX; - - if(x*x + y*y < 1) { - ++inside; - } - } - - shmem_barrier_all(); - - int errors = 0; - - if(me == 0) { - for(int i = 1; i < myshmem_n_pes; ++i) { - long long remoteInside,remoteTotal; - shmem_longlong_get(&remoteInside,&inside,1,i); - shmem_longlong_get(&remoteTotal,&total,1,i); - total += remoteTotal; - inside += remoteInside; - } - - double approx_pi = 4.0*inside/(double)total; - - if(fabs(M_PI-approx_pi) > 0.1) { - ++errors; - } - - if (NULL == getenv("MAKELEVEL")) { - printf("Pi from %llu points on %d PEs: %lf\n", total, myshmem_n_pes, approx_pi); - } - } - - shmem_finalize(); - - return errors; -} - diff --git a/test/unit/ping.c b/test/unit/ping.c deleted file mode 100644 index 15c2c0e28..000000000 --- a/test/unit/ping.c +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - * ping test usage: ping {-V} {longs-per-put(128)} {loop-cnt(10)} - * - * For yod -c X ./ping - * Proc0 puts nWords to Proc1 ... Proc(X-1) - */ -#include -#include -#include -#include -#include -#include - -#define Rfprintf if (shmem_my_pe() == 0) fprintf -#define Rprintf if (shmem_my_pe() == 0) printf - -#define RDprintf if (Verbose && shmem_my_pe() == 0) printf -#define RDfprintf if (Verbose && shmem_my_pe() == 0) fprintf - -/* option flags */ -#define OUTPUT_MOD 1 // output debug every X loops -int output_mod = OUTPUT_MOD; -int Verbose; -int Slow; - -#define DFLT_NWORDS 128 -#define TARGET_SZ 8192 -#define VAL 0xCafeBabe - -long Target[TARGET_SZ]; -long src[TARGET_SZ]; - -int -main(int argc, char* argv[]) -{ - int c, j, loops, k; - int proc, num_procs; - int nWords=1; - int failures=0; - char *prog_name; - - shmem_init(); - proc = shmem_my_pe(); - num_procs = shmem_n_pes(); - - if (num_procs == 1) { - Rfprintf(stderr, - "ERR - Requires > 1 PEs\n"); - shmem_finalize(); - return 0; - } - - prog_name = strrchr(argv[0],'/'); - if ( prog_name ) - prog_name++; - else - prog_name = argv[0]; - - while((c=getopt(argc,argv,"hVM:s")) != -1) { - switch(c) { - case 's': - Slow++; - break; - case 'V': - Verbose++; - break; - case 'M': - output_mod = atoi(optarg); - if (output_mod <= 0) { - Rfprintf(stderr, "ERR - output modulo arg out of " - "bounds '%d'?]\n", output_mod); - shmem_finalize(); - return 1; - } - Rfprintf(stderr,"%s: output modulo %d\n", - prog_name,output_mod); - break; - case 'h': - Rfprintf(stderr, - "usage: %s {nWords-2-put} {Loop-count}\n", - prog_name); - shmem_finalize(); - return 1; - default: - shmem_finalize(); - return 1; - } - } - - if (optind == argc) - nWords = DFLT_NWORDS; - else { - nWords = atoi(argv[optind++]); - if (nWords <= 0 || nWords > TARGET_SZ) { - Rfprintf(stderr, - "ERR - nWords arg out of bounds '%d' [1..%d]?\n", - nWords, TARGET_SZ); - shmem_finalize(); - return 1; - } - } - - if (optind == argc) - loops = 10; - else { - loops = atoi(argv[optind++]); - if (loops <= 0 || loops > 1000000) { - Rfprintf(stderr, - "ERR - loops arg out of bounds '%d'?\n", loops); - shmem_finalize(); - return 1; - } - } - - //Rprintf("%s: %d loops of %d longs per put\n",prog_name,loops,nWords); - - for(j=0; j < nWords; j++) - src[j] = VAL; - - for(j=0; j < loops; j++) { - - shmem_barrier_all(); - - if ( Verbose && (j==0 || (j % output_mod) == 0) ) - fprintf(stderr,"[%d] +(%d)\n", shmem_my_pe(),j); - - if ( proc == 0 ) { - int p; - for(p=1; p < num_procs; p++) - shmem_long_put(Target, src, nWords, p); - } - else { - if (Slow) { - /* wait for each put to complete */ - for(k=0; k < nWords; k++) - shmem_long_wait_until(&Target[k], SHMEM_CMP_NE, proc); - } else { - /* wait for last word to be written */ - shmem_long_wait_until(&Target[nWords-1], SHMEM_CMP_NE, proc); - } - } - - if ( Verbose && (j==0 || (j % output_mod) == 0) ) - fprintf(stderr,"[%d] -(%d)\n", shmem_my_pe(),j); - - shmem_barrier_all(); - - if ( proc != 0 ) { - for(k=0; k < nWords; k++) { - if (Target[k] != VAL) { - fprintf(stderr, "[%d] Target[%d] %#lx " - "!= %#x\?\n", - proc,k,Target[k],VAL); - failures++; - } - //assert(Target[proc] == VAL); - Target[k] = 0; - } - } - else - memset(Target, 0, sizeof(Target)); - } - - shmem_barrier_all(); - - if (failures || Verbose) - Rprintf ("%d(%d) Exit(%d)\n", proc, num_procs, failures); - - shmem_finalize(); - - return failures; -} diff --git a/test/unit/pingpong-short.c b/test/unit/pingpong-short.c deleted file mode 100644 index df32b89b5..000000000 --- a/test/unit/pingpong-short.c +++ /dev/null @@ -1,315 +0,0 @@ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - * pingpong test pingpong-short {-v} {numShorts-2-put(128)} {loop-cnt(10)} - * - * For yod -c X - * Proc0 puts nShorts to Proc1 ... Proc(X-1) - * Proc1 ... Proc(X-1) verify put data to be correct. - * Proc1 ... Proc(X-1) put nShorts(proc_ID) back to proc0 in - * work[proc_ID*nLongs] ... work[proc_ID*(nLongs-1)] - * Proc 0 verifes data - */ -#include - -#include -#include -#include -#include -#include -#include - -static int atoi_scaled(char *s); - -#define Rfprintf if (shmem_my_pe() == 0) fprintf -#define Rprintf if (shmem_my_pe() == 0) printf - -#define RDprintf if (Verbose && shmem_my_pe() == 0) printf -#define RDfprintf if (Verbose && shmem_my_pe() == 0) fprintf - -/* option flags */ -#define OUTPUT_MOD 1 // output debug every X loops on -V -int output_mod = OUTPUT_MOD; -int Verbose; -int Slow; - -#define DFLT_NWORDS 128 -#define DFLT_LOOPS 100 - -#define VAL 0xCafe - -#define DataType short - -DataType *Target; -DataType *src; -DataType *work; - -int -main(int argc, char* argv[]) -{ - int c, j, loops, k, l; - int my_pe, nProcs, nWorkers; - int nWords=1; - int failures=0; - char *prog_name; - DataType *wp; - long work_sz; - - shmem_init(); - my_pe = shmem_my_pe(); - nProcs = shmem_n_pes(); - nWorkers = nProcs - 1; - - if (nProcs == 1) { - Rfprintf(stderr, - "ERR - Requires > 1 PEs\n"); - shmem_finalize(); - return 0; - } - - for(j=0; j < nProcs; j++) - if ( shmem_pe_accessible(j) != 1 ) { - fprintf(stderr, - "ERR - pe %d not accessible from pe %d\n", - j, my_pe); - } - - prog_name = strrchr(argv[0],'/'); - if ( prog_name ) - prog_name++; - else - prog_name = argv[0]; - - while((c=getopt(argc,argv,"hvM:s")) != -1) { - switch(c) { - case 's': - Slow++; - break; - case 'v': - Verbose++; - break; - case 'M': - output_mod = atoi(optarg); - if (output_mod <= 0) { - Rfprintf(stderr, "ERR - output modulo arg out of " - "bounds '%d'?\n", output_mod); - shmem_finalize(); - return 1; - } - Rfprintf(stderr,"%s: output modulo %d\n", - prog_name,output_mod); - break; - case 'h': - Rfprintf(stderr, - "usage: %s {nWords-2-put(%d)K/M} {Loop-count(%d)K/M}\n", - prog_name, DFLT_NWORDS, DFLT_LOOPS); - shmem_finalize(); - return 1; - default: - shmem_finalize(); - return 1; - } - } - - if (optind == argc) - nWords = DFLT_NWORDS; - else { - nWords = atoi_scaled(argv[optind++]); - if (nWords <= 0) { - Rfprintf(stderr, "ERR - Bad nWords '%d'?\n", nWords); - shmem_finalize(); - return 1; - } - } - - if (optind == argc) - loops = DFLT_LOOPS; - else { - loops = atoi_scaled(argv[optind++]); - if (loops <= 0 || loops > 1000000) { - Rfprintf(stderr, - "ERR - loops arg out of bounds '%d'?\n", loops); - shmem_finalize(); - return 1; - } - } - - work_sz = (nProcs*nWords) * sizeof(DataType); - work = shmem_malloc( work_sz ); - if ( !work ) { - fprintf(stderr,"[%d] ERR - work = shmem_malloc(%ld) ?\n",my_pe,work_sz); - shmem_global_exit(1); - } - - Target = shmem_malloc( 2 * nWords * sizeof(DataType) ); // Target & src - if ( !Target ) { - fprintf(stderr,"[%d] ERR - Target = shmem_malloc(%ld) ?\n", - my_pe, (nWords * sizeof(DataType))); - shmem_global_exit(1); - } - src = &Target[nWords]; - - if (Verbose) Rprintf("%s: %d loops of %d shorts per put/get cycle\n", - prog_name,loops,nWords); - - for(j=0; j < nWords; j++) - src[j] = (DataType)VAL; - - for(j=0; j < loops; j++) { - -#if _DEBUG - if ( Verbose && (j==0 || (j % output_mod) == 0) ) - fprintf(stderr,"[%d] +(%d)\n", shmem_my_pe(),j); -#endif - shmem_barrier_all(); - if ( my_pe == 0 ) { - int p; - for(p=1; p < nProcs; p++) - shmem_short_put(Target, src, nWords, p); - } - else { - if (Slow) { - /* wait for each put to complete */ - for(k=0; k < nWords; k++) - shmem_short_wait_until(&Target[k], SHMEM_CMP_NE, my_pe); - } else { - /* wait for last word to be written */ - shmem_short_wait_until(&Target[nWords-1], SHMEM_CMP_NE, my_pe); - } - } -#if _DEBUG - if ( Verbose && (j==0 || (j % output_mod) == 0) ) - fprintf(stderr,"[%d] -(%d)\n", my_pe,j); -#endif - shmem_barrier_all(); - - RDprintf("Workers[1 ... %d] verify Target data put by my_pe 0\n", - nWorkers); - - /* workers verify put data is expected */ - if ( my_pe != 0 ) { - for(k=0; k < nWords; k++) { - if (Target[k] != (DataType)VAL) { - fprintf(stderr, "[%d] Target[%d] %#hx " - "!= %#hx?\n", - my_pe,k,Target[k],(DataType)VAL); - failures++; - } - assert(Target[k] == (DataType)VAL); - Target[k] = my_pe; - } - } - else /* clear results buffer, workers will put here */ - memset(work, 0, work_sz); - - shmem_barrier_all(); - - RDprintf("Workers[1 ... %d] put Target data to PE0 work " - "vector\n",nWorkers); - - if ( my_pe != 0 ) { - /* push nWords of val my_pe back to PE zero */ - shmem_short_put(&work[my_pe*nWords], Target, nWords, 0); - } - else { - /* wait for procs 1 ... nProcs to complete put()s */ - for(l=1; l < nProcs; l++) { - wp = &work[ l*nWords ]; // procs nWords chunk -#if 1 - /* wait for last DataType to be written from each PE */ - shmem_short_wait_until(&wp[nWords-1], SHMEM_CMP_NE, 0); -#else - for(k=0; k < nWords; k++) - shmem_short_wait_until(&wp[k], SHMEM_CMP_NE, 0); -#endif - } - } - - shmem_barrier_all(); - - if ( my_pe == 0 ) { - RDprintf("Loop(%d) PE0 verifing work data.\n",j); - for(l=1; l < nProcs; l++) { - wp = &work[ l*nWords ]; // procs nWords chunk - for(k=0; k < nWords; k++) { - if (wp[k] != l) { - fprintf(stderr, - "[0] PE(%d)_work[%d] %hd " - "!= %hd?\n", - l,k,work[k],(DataType)l); - failures++; - } - } - if (failures) - break; - } - } - shmem_barrier_all(); - - if (loops > 1) { - RDfprintf(stderr,"."); - RDprintf("Loop(%d) Pass.\n",j); - } - } - RDfprintf(stderr,"\n");fflush(stderr); - - shmem_free( work ); - shmem_free( Target ); - - shmem_barrier_all(); - - RDprintf("%d(%d) Exit(%d)\n", my_pe, nProcs, failures); - - shmem_finalize(); - - return failures; -} - -static int -atoi_scaled(char *s) -{ - long val; - char *e; - - val = strtol(s,&e,0); - if (e == NULL || *e =='\0') - return (int)val; - - if (*e == 'k' || *e == 'K') - val *= 1024; - else if (*e == 'm' || *e == 'M') - val *= 1024*1024; - else if (*e == 'g' || *e == 'G') - val *= 1024*1024*1024; - - return (int)val; -} diff --git a/test/unit/pingpong.c b/test/unit/pingpong.c deleted file mode 100644 index 8f6efff44..000000000 --- a/test/unit/pingpong.c +++ /dev/null @@ -1,317 +0,0 @@ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - * pingpong test pingpong {-v} {nLongs-2-put(128)} {loop-cnt(10)} - * - * For yod -c X - * Proc0 puts nLongs to Proc1 ... Proc(X-1) - * Proc1 ... Proc(X-1) verify put data to be correct. - * Proc1 ... Proc(X-1) put nLongs(proc_ID) back to proc0 in - * work[proc_ID*nLongs] ... work[proc_ID*(nLongs-1)] - * Proc 0 verifes data - */ -#include - -#include -#include -#include -#include -#include - -static int atoi_scaled(char *s); - -#define Rfprintf if (shmem_my_pe() == 0) fprintf -#define Rprintf if (shmem_my_pe() == 0) printf - -#define RDprintf if (Verbose && shmem_my_pe() == 0) printf -#define RDfprintf if (Verbose && shmem_my_pe() == 0) fprintf - -/* option flags */ -#define OUTPUT_MOD 1 // output debug every X loops on -V -int output_mod = OUTPUT_MOD; -int Verbose; -int Slow; - -#define DFLT_NWORDS 128 -#define DFLT_LOOPS 10 - -#define VAL 0xCafeBabe - -long *Target; -long *src; -long *work; - -int -main(int argc, char* argv[]) -{ - int c, j, loops, k, l; - int my_pe, nProcs, nWorkers; - int nWords=1; - int failures=0; - char *prog_name; - long *wp,work_sz; - - shmem_init(); - my_pe = shmem_my_pe(); - nProcs = shmem_n_pes(); - nWorkers = nProcs - 1; - - if (nProcs == 1) { - Rfprintf(stderr, - "ERR - Requires > 1 PEs\n"); - shmem_finalize(); - return 0; - } - - for(j=0; j < nProcs; j++) - if ( shmem_pe_accessible(j) != 1 ) { - fprintf(stderr, - "ERR - pe %d not accessible from pe %d\n", - j, my_pe); - } - - prog_name = strrchr(argv[0],'/'); - if ( prog_name ) - prog_name++; - else - prog_name = argv[0]; - - while((c=getopt(argc,argv,"hvM:s")) != -1) { - switch(c) { - case 's': - Slow++; - break; - case 'v': - Verbose++; - break; - case 'M': - output_mod = atoi(optarg); - if (output_mod <= 0) { - Rfprintf(stderr, "ERR - output modulo arg out of " - "bounds '%d'?\n", output_mod); - shmem_finalize(); - return 1; - } - Rfprintf(stderr,"%s: output modulo %d\n", - prog_name,output_mod); - break; - case 'h': - Rfprintf(stderr, - "usage: %s {nWords-2-put(%d)K/M} {Loop-count(%d)K/M}\n", - prog_name, DFLT_NWORDS, DFLT_LOOPS); - shmem_finalize(); - return 1; - default: - shmem_finalize(); - return 1; - } - } - - if (optind == argc) - nWords = DFLT_NWORDS; - else { - nWords = atoi_scaled(argv[optind++]); - if (nWords <= 0) { - Rfprintf(stderr, "ERR - Bad nWords arg '%d'?\n", nWords); - shmem_finalize(); - return 1; - } - } - - if (optind == argc) - loops = DFLT_LOOPS; - else { - loops = atoi_scaled(argv[optind++]); - if (loops <= 0 || loops > 1000000) { - Rfprintf(stderr, - "ERR - loops arg out of bounds '%d'?\n", loops); - shmem_finalize(); - return 1; - } - } - - work_sz = (nProcs*nWords) * sizeof(long); - work = shmem_malloc( work_sz ); - if ( !work ) { - fprintf(stderr,"[%d] ERR - work = shmem_malloc(%ld) ?\n",my_pe,work_sz); - shmem_global_exit(1); - } - - Target = shmem_malloc( 2 * nWords * sizeof(long) ); - if ( !Target ) { - fprintf(stderr,"[%d] ERR - Target = shmem_malloc(%ld) ?\n", - my_pe, (nWords * sizeof(long))); - shmem_global_exit(1); - } - src = &Target[nWords]; - -#if _DEBUG - Rprintf("%s: %d loops of %d longs per put\n",prog_name,loops,nWords); -#endif - - for(j=0; j < nWords; j++) - src[j] = VAL; - - for(j=0; j < loops; j++) { - -#if _DEBUG - if ( Verbose && (j==0 || (j % output_mod) == 0) ) - fprintf(stderr,"[%d] +(%d)\n", my_pe,j); -#endif - shmem_barrier_all(); - if ( my_pe == 0 ) { - int p; - for(p=1; p < nProcs; p++) - shmem_long_put(Target, src, nWords, p); - } - else { - if (Slow) { - /* wait for each put to complete */ - for(k=0; k < nWords; k++) - shmem_long_wait_until(&Target[k], SHMEM_CMP_NE, my_pe); - } else { - /* wait for last word to be written */ - shmem_long_wait_until(&Target[nWords-1], SHMEM_CMP_NE, my_pe); - } - } -#if _DEBUG - if ( Verbose && (j==0 || (j % output_mod) == 0) ) - fprintf(stderr,"[%d] -(%d)\n", shmem_my_pe(),j); -#endif - shmem_barrier_all(); - - RDprintf("Workers[1 ... %d] verify Target data put by proc0\n", - nWorkers); - - /* workers verify put data is expected */ - if ( my_pe != 0 ) { - for(k=0; k < nWords; k++) { - if (Target[k] != VAL) { - fprintf(stderr, "[%d] Target[%d] %#lx " - "!= %#x?\n", - my_pe,k,Target[k],VAL); - failures++; - } - assert(Target[k] == VAL); - Target[k] = my_pe; - } - } - else /* clear results buffer, workers will put here */ - memset(work, 0, work_sz); - - shmem_barrier_all(); - - RDprintf("Workers[1 ... %d] put Target data to PE0 work " - "vector\n",nWorkers); - - if ( my_pe != 0 ) { - /* push nWords of val my_pe back to PE zero */ - shmem_long_put(&work[my_pe * nWords], Target, nWords, 0); - } - else { - /* wait for procs 1 ... nProcs to complete put()s */ - for(l=1; l < nProcs; l++) { - wp = &work[ l*nWords ]; // procs nWords chunk -#if 1 - /* wait for last long to be written from each PE */ - shmem_long_wait_until(&wp[nWords-1], SHMEM_CMP_NE, 0); -#else - for(k=0; k < nWords; k++) - shmem_long_wait_until(&wp[k], SHMEM_CMP_NE, 0); -#endif - } - } - - shmem_barrier_all(); - - if ( my_pe == 0 ) { - RDprintf("Loop(%d) PE0 verifing work data.\n",j); - for(l=1; l < nProcs; l++) { - wp = &work[ l*nWords ]; // procs nWords chunk - for(k=0; k < nWords; k++) { - if (wp[k] != l) { - fprintf(stderr, - "[0] PE(%d)_work[%d] %ld " - "!= %d?\n", - l,k,work[k],l); - failures++; - } - assert(wp[k] == l); - break; - } - if (failures) - break; - } - } - shmem_barrier_all(); -#if _DEBUG - if (loops > 1) { - Rfprintf(stderr,"."); - RDprintf("Loop(%d) Pass.\n",j); - } -#endif - } - - shmem_free( work ); - shmem_free( Target ); - -#if _DEBUG - Rfprintf(stderr,"\n");fflush(stderr); - shmem_barrier_all(); - RDprintf("%d(%d) Exit(%d)\n", my_pe, nProcs, failures); -#endif - - shmem_finalize(); - - return failures; -} - - -static int -atoi_scaled(char *s) -{ - long val; - char *e; - - val = strtol(s,&e,0); - if (e == NULL || *e =='\0') - return (int)val; - - if (*e == 'k' || *e == 'K') - val *= 1024; - else if (*e == 'm' || *e == 'M') - val *= 1024*1024; - else if (*e == 'g' || *e == 'G') - val *= 1024*1024*1024; - - return (int)val; -} diff --git a/test/unit/put1.c b/test/unit/put1.c deleted file mode 100644 index ad895b5e7..000000000 --- a/test/unit/put1.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include - -int -main(int argc, char* argv[]) -{ - long source[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; - static long target[10]; - - shmem_init(); - - if (shmem_n_pes() == 1) { - printf("%s: Requires number of PEs > 1\n", argv[0]); - shmem_finalize(); - return 0; - } - - if (shmem_my_pe() == 0) { - /* put 10 elements into target on PE 1 */ - shmem_long_put(target, source, 10, 1); - } - - shmem_barrier_all(); /* sync sender and receiver */ - - if (shmem_my_pe() == 1) { - if (0 != memcmp(source, target, sizeof(long) * 10)) { - int i; - fprintf(stderr,"[%d] Src & Target mismatch?\n",shmem_my_pe()); - for (i = 0 ; i < 10 ; ++i) { - printf("%ld,%ld ", source[i], target[i]); - } - printf("\n"); - shmem_global_exit(1); - } - } - - shmem_finalize(); - - return 0; -} diff --git a/test/unit/put_nbi.c b/test/unit/put_nbi.c deleted file mode 100644 index 69459dd4e..000000000 --- a/test/unit/put_nbi.c +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2016 Intel COrporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modfiication, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* Non-Blocking Put Test - * Tom St. John - * January, 2016 - * - * PE 0 uses non-blocking put to write a message followed by a - * notification flag to every remote PE, - */ - -#include -#include -#include - -int -main(int argc, char* argv[]) -{ - long source[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; - long *target; - int *flag; - int i, num_pes; - int failed = 0; - - shmem_init(); - - target = (long*) shmem_malloc(sizeof(long) * 10); - flag = (int*) shmem_malloc(sizeof(int)); - if (!flag) { - fprintf(stderr, "ERR - null flag pointer\n"); - shmem_global_exit(1); - } - *flag = 0; - - num_pes=shmem_n_pes(); - - if (target) { - memset(target, 0, sizeof(long)*10); - } else { - fprintf(stderr, "ERR - null target pointer\n"); - shmem_global_exit(1); - } - - shmem_barrier_all(); - - if (shmem_my_pe() == 0) { - for(i = 0; i < num_pes; i++) { - shmem_long_put_nbi(target, source, 10, i); - shmem_fence(); - shmem_int_atomic_inc(flag, i); - } - } - - shmem_int_wait_until(flag, SHMEM_CMP_EQ, 1); - - for (i = 0; i < 10; i++) { - if (target[i] != source[i]) { - fprintf(stderr,"[%d] target[%d] = %ld, expected %ld\n", - shmem_my_pe(), i, target[i], source[i]); - failed = 1; - } - } - - shmem_free(target); - shmem_free(flag); - - shmem_finalize(); - - return failed; -} diff --git a/test/unit/put_signal.c b/test/unit/put_signal.c deleted file mode 100644 index b4323034b..000000000 --- a/test/unit/put_signal.c +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) 2018 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - * Validate shmem_put_signal operation through blocking API - * It mimics the broadcast operation through a ring-based algorithm - * using shmem_put_signal. -*/ - -#include -#include -#include - -#define MSG_SZ 10 - -int main(int argc, char *argv[]) -{ - long source[MSG_SZ]; - long *target; - int me, npes, dest, i; - int errors = 0; - - static uint64_t sig_addr = 0; - - shmem_init(); - - me = shmem_my_pe(); - npes = shmem_n_pes(); - dest = (me + 1) % npes; - - for (i = 0; i < MSG_SZ; i++) - source[i] = i; - - target = (long *) shmem_calloc(MSG_SZ, sizeof(long)); - if (!target) { - fprintf(stderr, "Failed to allocate target pointer\n"); - shmem_global_exit(1); - } - - if (me == 0) { - shmem_long_put_signal(target, source, MSG_SZ, &sig_addr, 1, SHMEM_SIGNAL_SET, dest); -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L - shmem_wait_until(&sig_addr, SHMEM_CMP_EQ, 1); -#else - shmem_uint64_wait_until(&sig_addr, SHMEM_CMP_EQ, 1); -#endif - } else { -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L - shmem_wait_until(&sig_addr, SHMEM_CMP_EQ, 1); -#else - shmem_uint64_wait_until(&sig_addr, SHMEM_CMP_EQ, 1); -#endif - shmem_long_put_signal(target, target, MSG_SZ, &sig_addr, 1, SHMEM_SIGNAL_SET, dest); - } - - for (i = 0; i < MSG_SZ; i++) { - if (target[i] != source[i]) { - fprintf(stderr, "%10d: target[%d] = %ld not matching %ld with SHMEM_SIGNAL_SET\n", - me, i, target[i], source[i]); - errors++; - } - } - - shmem_barrier_all(); - - for (i = 0; i < MSG_SZ; i++) - target[i] = 0; - - sig_addr = 0; - int one = 1; - - shmem_barrier_all(); - if (me == 0) { - shmem_long_put_signal(target, source, MSG_SZ, &sig_addr, one, SHMEM_SIGNAL_ADD, dest); -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L - shmem_wait_until(&sig_addr, SHMEM_CMP_EQ, one); -#else - shmem_uint64_wait_until(&sig_addr, SHMEM_CMP_EQ, one); -#endif - } else { -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L - shmem_wait_until(&sig_addr, SHMEM_CMP_EQ, one); -#else - shmem_uint64_wait_until(&sig_addr, SHMEM_CMP_EQ, one); -#endif - shmem_long_put_signal(target, target, MSG_SZ, &sig_addr, one, SHMEM_SIGNAL_ADD, dest); - } - - for (i = 0; i < MSG_SZ; i++) { - if (target[i] != source[i]) { - fprintf(stderr, "%10d: target[%d] = %ld not matching %ld with SHMEM_SIGNAL_ADD\n", - me, i, target[i], source[i]); - errors++; - } - } - - shmem_free(target); - shmem_finalize(); - - return errors; -} diff --git a/test/unit/put_signal_nbi.c b/test/unit/put_signal_nbi.c deleted file mode 100644 index 37de7c3bd..000000000 --- a/test/unit/put_signal_nbi.c +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2018 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - * Validate put_signal operation through non-blocking API - * PE 0 uses shmem_put_signal_nbi to send data and signal across all PES -*/ - -#include -#include -#include - -#define MSG_SZ 10 - -int main(int argc, char *argv[]) -{ - long source[MSG_SZ]; - long *target; - int me, npes, i; - int errors = 0; - - static uint64_t sig_addr = 0; - - shmem_init(); - - me = shmem_my_pe(); - npes = shmem_n_pes(); - - for (i = 0; i < MSG_SZ; i++) - source[i] = i; - - target = (long *) shmem_calloc(MSG_SZ, sizeof(long)); - if (!target) { - fprintf(stderr, "Failed to allocate target pointer\n"); - shmem_global_exit(1); - } - - if (me == 0) { - for (i = 0; i < npes; i++) { - shmem_long_put_signal_nbi(target, source, MSG_SZ, &sig_addr, 1, SHMEM_SIGNAL_SET, i); - } - } - -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L - shmem_wait_until(&sig_addr, SHMEM_CMP_EQ, 1); -#else - shmem_uint64_wait_until(&sig_addr, SHMEM_CMP_EQ, 1); -#endif - - for (i = 0; i < MSG_SZ; i++) { - if (target[i] != source[i]) { - fprintf(stderr, "%10d: target[%d] = %ld not matching %ld with SHMEM_SIGNAL_SET\n", - me, i, target[i], source[i]); - errors++; - } - } - - shmem_barrier_all(); - - for (i = 0; i < MSG_SZ; i++) - target[i] = 0; - - sig_addr = 0; - - shmem_barrier_all(); - if (me == 0) { - for (i = 0; i < npes; i++) { - shmem_long_put_signal_nbi(target, source, MSG_SZ, &sig_addr, i + 1, SHMEM_SIGNAL_ADD, i); - } - } - -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L - shmem_wait_until(&sig_addr, SHMEM_CMP_EQ, me + 1); -#else - shmem_uint64_wait_until(&sig_addr, SHMEM_CMP_EQ, me + 1); -#endif - - for (i = 0; i < MSG_SZ; i++) { - if (target[i] != source[i]) { - fprintf(stderr, "%10d: target[%d] = %ld not matching %ld with SHMEM_SIGNAL_ADD\n", - me, i, target[i], source[i]); - errors++; - } - } - - shmem_free(target); - shmem_finalize(); - - return errors; -} diff --git a/test/unit/query_thread.c b/test/unit/query_thread.c deleted file mode 100644 index 9926d8ff6..000000000 --- a/test/unit/query_thread.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2018 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include - -int -main(int argc, char* argv[]) -{ - int provided; - -#if defined(ENABLE_THREADS) - int tl, ret; - ret = shmem_init_thread(SHMEM_THREAD_FUNNELED, &tl); - - if (tl < SHMEM_THREAD_FUNNELED || ret != 0) { - printf("Init failed (requested thread level %d, got %d, ret %d)\n", - SHMEM_THREAD_FUNNELED, tl, ret); - if (ret == 0) { - shmem_global_exit(1); - } else { - return ret; - } - } -#else - shmem_init(); -#endif - - shmem_query_thread(&provided); - printf("%d: Query result for thread level %d\n", shmem_my_pe(), provided); - -#if defined(ENABLE_THREADS) - if (provided < SHMEM_THREAD_FUNNELED) - shmem_global_exit(1); -#else - if (provided != SHMEM_THREAD_SINGLE && provided != SHMEM_THREAD_FUNNELED && - provided != SHMEM_THREAD_SERIALIZED && provided != SHMEM_THREAD_MULTIPLE) - shmem_global_exit(1); -#endif - - shmem_finalize(); - return 0; -} diff --git a/test/unit/reduce_active_set.c b/test/unit/reduce_active_set.c deleted file mode 100644 index d5767e858..000000000 --- a/test/unit/reduce_active_set.c +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include - -#define NELEM 10 - -#ifdef ENABLE_DEPRECATED_TESTS -long max_psync[SHMEM_REDUCE_SYNC_SIZE]; -long min_psync[SHMEM_REDUCE_SYNC_SIZE]; - -long min_pwrk[NELEM/2 + SHMEM_REDUCE_MIN_WRKDATA_SIZE]; -long max_pwrk[NELEM/2 + SHMEM_REDUCE_MIN_WRKDATA_SIZE]; -#endif - -long src[NELEM]; -long dst_max[NELEM]; -long dst_min[NELEM]; - -static int validate_max(int i, int me, int npes) { - int errors = 0; - /* Validate reduced max data */ - for (int j = 0; j < NELEM; j++) { - long expected = npes-1; - if (dst_max[j] != expected) { - printf("%d: Max expected dst_max[%d] = %ld, got dst_max[%d] = %ld, iteration %d\n", - me, j, expected, j, dst_max[j], i); - errors++; - } - } - return errors; -} - -static int validate_min(int i, int me, int npes) { - int errors = 0; - /* Validate reduced min data */ - for (int j = 0; j < NELEM; j++) { - long expected = i; - if (dst_min[j] != expected) { - printf("%d: Min expected dst_min[%d] = %ld, got dst_min[%d] = %ld, iteration %d\n", - me, j, expected, j, dst_min[j], i); - errors++; - } - } - return errors; -} - -int main(void) -{ - int i, me, npes; - int errors = 0; - - shmem_init(); - - me = shmem_my_pe(); - npes = shmem_n_pes(); - - for (i = 0; i < NELEM; i++) { - src[i] = me; - dst_max[i] = -1; - dst_min[i] = -1; - } - -#ifdef ENABLE_DEPRECATED_TESTS - for (i = 0; i < SHMEM_REDUCE_SYNC_SIZE; i++) { - max_psync[i] = SHMEM_SYNC_VALUE; - min_psync[i] = SHMEM_SYNC_VALUE; - } -#endif - - if (me == 0) - printf("Shrinking active set test\n"); - - shmem_barrier_all(); - - /* A total of npes tests are performed, where the active set in each test - * includes PEs i..npes-1 */ -#ifdef ENABLE_DEPRECATED_TESTS - for (i = 0; i <= me; i++) { - - if (me == i) - printf(" + PE_start=%d, logPE_stride=0, PE_size=%d\n", i, npes-i); - - shmem_long_max_to_all(dst_max, src, NELEM, i, 0, npes-i, max_pwrk, max_psync); - errors += validate_max(i, me, npes); - - shmem_long_min_to_all(dst_min, src, NELEM, i, 0, npes-i, min_pwrk, min_psync); - errors += validate_min(i, me, npes); - - } -#else - shmem_team_t new_team; - for (i = 0; i < npes; i++) { - - if (me == i) - printf(" + PE_start=%d, PE_stride=1, PE_size=%d\n", i, npes-i); - - shmem_team_split_strided(SHMEM_TEAM_WORLD, i, 1, npes-i, NULL, 0, &new_team); - if (new_team != SHMEM_TEAM_INVALID) { - shmem_long_max_reduce(new_team, dst_max, src, NELEM); - errors += validate_max(i, me, npes); - - shmem_long_min_reduce(new_team, dst_min, src, NELEM); - errors += validate_min(i, me, npes); - } - } -#endif - - - shmem_finalize(); - - return errors != 0; -} diff --git a/test/unit/reduce_in_place.c b/test/unit/reduce_in_place.c deleted file mode 100644 index 66ac5d2e7..000000000 --- a/test/unit/reduce_in_place.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include - -#define NELEM 10 - -long src[NELEM]; - -int main(void) -{ - int me, npes; - int errors = 0; - - shmem_init(); - - me = shmem_my_pe(); - npes = shmem_n_pes(); - - for (int i = 0; i < NELEM; i++) - src[i] = me; - - shmem_barrier_all(); - - shmem_long_max_reduce(SHMEM_TEAM_WORLD, src, src, NELEM); - - /* Validate reduced data */ - for (int j = 0; j < NELEM; j++) { - long expected = npes-1; - if (src[j] != expected) { - printf("%d: Expected src[%d] = %ld, got src[%d] = %ld\n", me, j, expected, j, src[j]); - errors++; - } - } - - shmem_finalize(); - - return errors != 0; -} diff --git a/test/unit/repeated_barriers.c b/test/unit/repeated_barriers.c deleted file mode 100644 index 5584adab1..000000000 --- a/test/unit/repeated_barriers.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include - -#define NREPS 50 - -#ifdef ENABLE_DEPRECATED_TESTS -long barrier_psync0[SHMEM_BARRIER_SYNC_SIZE]; -long barrier_psync1[SHMEM_BARRIER_SYNC_SIZE]; -#endif - -int main(void) -{ - int i, me, npes; - - shmem_init(); - - me = shmem_my_pe(); - npes = shmem_n_pes(); - -#ifdef ENABLE_DEPRECATED_TESTS - for (i = 0; i < SHMEM_BARRIER_SYNC_SIZE; i++) { - barrier_psync0[i] = SHMEM_SYNC_VALUE; - barrier_psync1[i] = SHMEM_SYNC_VALUE; - } -#endif - - shmem_barrier_all(); - - /* A total of npes tests are performed, where the active set in each test - * includes PEs i..npes-1 */ -#ifdef ENABLE_DEPRECATED_TESTS - for (i = 0; i <= me; i++) { - int j; - - if (me == i) - printf(" + iteration %d\n", i); - - /* Test that barrier can be called repeatedly with the *same* pSync */ - for (j = 0; j < NREPS; j++) - shmem_barrier(i, 0, npes-i, (i % 2) ? barrier_psync0 : barrier_psync1); - } -#else - shmem_team_t new_team; - for (i = 0; i <= npes; i++) { - int j; - - if (me == i) - printf(" + iteration %d\n", i); - - /* Test that quiet + sync can be called repeatedly*/ - shmem_team_split_strided(SHMEM_TEAM_WORLD, i, 1, npes-i, NULL, 0, &new_team); - if (new_team != SHMEM_TEAM_INVALID) { - for (j = 0; j < NREPS; j++) { - shmem_quiet(); - shmem_team_sync(new_team); - } - } - } -#endif - - shmem_finalize(); - - return 0; -} diff --git a/test/unit/repeated_syncs.c b/test/unit/repeated_syncs.c deleted file mode 100644 index 909370123..000000000 --- a/test/unit/repeated_syncs.c +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include - -#define NREPS 50 - -long sync_psync0[SHMEM_BARRIER_SYNC_SIZE]; -long sync_psync1[SHMEM_BARRIER_SYNC_SIZE]; - -int main(void) -{ - int i, me, npes; - - shmem_init(); - - me = shmem_my_pe(); - npes = shmem_n_pes(); - - for (i = 0; i < SHMEM_BARRIER_SYNC_SIZE; i++) { - sync_psync0[i] = SHMEM_SYNC_VALUE; - sync_psync1[i] = SHMEM_SYNC_VALUE; - } - - shmem_sync_all(); - - /* A total of npes tests are performed, where the active set in each test - * includes PEs i..npes-1 */ - for (i = 0; i <= me; i++) { - int j; - - if (me == i) - printf(" + iteration %d\n", i); - - /* Test that sync can be called repeatedly with the *same* pSync */ - for (j = 0; j < NREPS; j++) - shmem_sync(i, 0, npes-i, (i % 2) ? sync_psync0 : sync_psync1); - } - - shmem_finalize(); - - return 0; -} diff --git a/test/unit/rma_coverage.c b/test/unit/rma_coverage.c deleted file mode 100644 index f60b2fea4..000000000 --- a/test/unit/rma_coverage.c +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include - -#ifdef TEST_PSHMEM -#include -#define SHFN(fn) pshmem_##fn -#else -#define SHFN(fn) shmem_##fn -#endif - -#define CHUNK_SIZE 10 -#define ARR_SIZE (4*(CHUNK_SIZE)) - -#define EVAL_MACRO_FOR_RMA(DECL,END) \ - DECL(float, float) END \ - DECL(double, double) END \ - DECL(longdouble, long double) END \ - DECL(char, char) END \ - DECL(short, short) END \ - DECL(int, int) END \ - DECL(long, long) END \ - DECL(longlong, long long) END - -#define DECLARE_TEST(TYPENAME,TYPE) \ - TYPE TYPENAME##_shared[ARR_SIZE]; \ - \ - static int TYPENAME##_rmaTest(int target_pe, int verbose) { \ - TYPE* shared = TYPENAME##_shared; \ - TYPE myvals[ARR_SIZE]; \ - TYPE result[ARR_SIZE]; \ - size_t i; \ - \ - for(i = 0; i < ARR_SIZE; ++i) { \ - myvals[i] = (TYPE)rand(); \ - } \ - \ - SHFN(TYPENAME##_put)(shared, myvals, CHUNK_SIZE, target_pe); \ - for(i = 0; i < CHUNK_SIZE; ++i) { \ - SHFN(TYPENAME##_p)(&shared[CHUNK_SIZE+i], \ - myvals[CHUNK_SIZE+i], target_pe); \ - } \ - SHFN(TYPENAME##_iput)(shared+2*CHUNK_SIZE,myvals+2*CHUNK_SIZE, \ - 1, 2, CHUNK_SIZE/2, target_pe); \ - SHFN(TYPENAME##_iput)(shared+2*CHUNK_SIZE+CHUNK_SIZE/2, \ - myvals+2*CHUNK_SIZE+1, 1, 2, CHUNK_SIZE/2, target_pe); \ - SHFN(TYPENAME##_put_nbi)(shared+3*CHUNK_SIZE, \ - myvals+3*CHUNK_SIZE, CHUNK_SIZE, target_pe); \ - \ - SHFN(quiet)(); \ - SHFN(barrier_all)(); \ - \ - SHFN(TYPENAME##_get)(result,shared,CHUNK_SIZE,target_pe); \ - for(i = 0; i < CHUNK_SIZE; ++i) { \ - result[CHUNK_SIZE+i] = SHFN(TYPENAME##_g)( \ - &shared[CHUNK_SIZE+i], target_pe); \ - } \ - SHFN(TYPENAME##_iget)(result+2*CHUNK_SIZE, shared+2*CHUNK_SIZE, \ - 2, 1, CHUNK_SIZE/2, target_pe); \ - SHFN(TYPENAME##_iget)(result+2*CHUNK_SIZE+1, \ - shared+2*CHUNK_SIZE+CHUNK_SIZE/2, 2, 1, CHUNK_SIZE/2, \ - target_pe); \ - SHFN(TYPENAME##_get_nbi)(result+3*CHUNK_SIZE, \ - shared+3*CHUNK_SIZE, CHUNK_SIZE, target_pe); \ - \ - SHFN(quiet)(); \ - SHFN(barrier_all)(); \ - int ret = 0; \ - for(i = 0; i < ARR_SIZE; ++i) { \ - if(result[i] != myvals[i]) { \ - ++ret; \ - if(verbose) { \ - fprintf(stderr,"result[%lu] != myvals[%lu]", i, i); \ - } \ - } \ - } \ - if(verbose) { \ - fprintf(stderr,"%s (type '%s') %s: %d\n",#TYPENAME, \ - #TYPE,ret ? "Failed" : "Succeeded",ret); \ - } \ - return ret; \ - } - -EVAL_MACRO_FOR_RMA(DECLARE_TEST,) - -int main(int argc, char* argv[]) { - int verbose = 0; - if(argc > 1) { - verbose = !strcmp("-v",argv[1]); - } - - int errors = 0; - - int me, myshmem_n_pes; - SHFN(init)(); - myshmem_n_pes = SHFN(n_pes)(); - me = SHFN(my_pe)(); - - srand(1+me); - - int nextpe = (me+1)%myshmem_n_pes; - -#define RUN_TEST(TYPENAME,TYPE) do { \ - errors += (TYPENAME##_rmaTest(nextpe,verbose)); \ - } while(0) - - EVAL_MACRO_FOR_RMA(RUN_TEST,;) - - SHFN(finalize)(); - - return errors; -} diff --git a/test/unit/self_collectives.c b/test/unit/self_collectives.c deleted file mode 100644 index a692e3828..000000000 --- a/test/unit/self_collectives.c +++ /dev/null @@ -1,296 +0,0 @@ -/* - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include - -long bcast_psync[SHMEM_BCAST_SYNC_SIZE]; -long collect_psync[SHMEM_COLLECT_SYNC_SIZE]; -long reduce_psync[SHMEM_REDUCE_SYNC_SIZE]; -long alltoall_psync[SHMEM_ALLTOALL_SYNC_SIZE]; -long alltoalls_psync[SHMEM_ALLTOALLS_SYNC_SIZE]; - -int pwrk[SHMEM_REDUCE_MIN_WRKDATA_SIZE]; - -#define CHECK(func, in, out) \ - do { \ - if (out != in) { \ - printf("[%02d] Error: %s expected=%ld out=%ld\n", me, func, \ - (long) in, (long) out); \ - ++errors; \ - } \ - } while (0) - -int in, out; -unsigned int uin, uout; -int32_t in_32, out_32; -int64_t in_64, out_64; - -int main(void) { - int i, errors = 0; - int me; - - for (i = 0; i < SHMEM_BCAST_SYNC_SIZE; i++) - bcast_psync[i] = SHMEM_SYNC_VALUE; - - for (i = 0; i < SHMEM_COLLECT_SYNC_SIZE; i++) - collect_psync[i] = SHMEM_SYNC_VALUE; - - for (i = 0; i < SHMEM_REDUCE_SYNC_SIZE; i++) - reduce_psync[i] = SHMEM_SYNC_VALUE; - - for (i = 0; i < SHMEM_ALLTOALL_SYNC_SIZE; i++) - alltoall_psync[i] = SHMEM_SYNC_VALUE; - - for (i = 0; i < SHMEM_ALLTOALLS_SYNC_SIZE; i++) - alltoalls_psync[i] = SHMEM_SYNC_VALUE; - - for (i = 0; i < SHMEM_REDUCE_MIN_WRKDATA_SIZE; i++) - pwrk[i] = 0; - - shmem_init(); - - me = shmem_my_pe(); - - if (me == 0) printf("Testing single PE active set collectives\n"); - - /* Broadcast */ - /* Note: Broadcast does not modify the output buffer at the root */ - if (me == 0) printf(" + broadcast\n"); - -#ifndef ENABLE_DEPRECATED_TESTS - /* Set up active set team (start=me, stride=1, size=1) for all tests*/ - shmem_team_t new_team; - shmem_team_split_strided(SHMEM_TEAM_WORLD, me, 1, 1, NULL, 0, &new_team); -#endif - - in_32 = me; out_32 = -1; -#ifdef ENABLE_DEPRECATED_TESTS - shmem_broadcast32(&in_32, &out_32, 1, 0, me, 0, 1, bcast_psync); - CHECK("shmem_broadcast32", -1, out_32); -#else - if (new_team != SHMEM_TEAM_INVALID) - shmem_int32_broadcast(new_team, &in_32, &out_32, 1, 0); - CHECK("shmem_int32_broadcast", -1, out_32); -#endif - shmem_barrier_all(); - - in_64 = me; out_64 = -1; -#ifdef ENABLE_DEPRECATED_TESTS - shmem_broadcast64(&in_64, &out_64, 1, 0, me, 0, 1, bcast_psync); - CHECK("shmem_broadcast64", -1, out_64); -#else - if (new_team != SHMEM_TEAM_INVALID) - shmem_int64_broadcast(new_team, &in_64, &out_64, 1, 0); - CHECK("shmem_int64_broadcast", -1, out_64); -#endif - shmem_barrier_all(); - - /* Collect */ - if (me == 0) printf(" + collect\n"); - - in_32 = me; out_32 = -1; -#ifdef ENABLE_DEPRECATED_TESTS - shmem_fcollect32(&in_32, &out_32, 1, me, 0, 1, collect_psync); - CHECK("shmem_fcollect32", in_32, out_32); -#else - if (new_team != SHMEM_TEAM_INVALID) - shmem_int32_fcollect(new_team, &in_32, &out_32, 1); - CHECK("shmem_int32_fcollect", in_32, out_32); -#endif - shmem_barrier_all(); - - in_64 = me; out_64 = -1; -#ifdef ENABLE_DEPRECATED_TESTS - shmem_fcollect64(&in_64, &out_64, 1, me, 0, 1, collect_psync); - CHECK("shmem_fcollect64", in_64, out_64); -#else - if (new_team != SHMEM_TEAM_INVALID) - shmem_int64_fcollect(new_team, &in_64, &out_64, 1); - CHECK("shmem_int64_fcollect", in_64, out_64); -#endif - shmem_barrier_all(); - - in_32 = me; out_32 = -1; -#ifdef ENABLE_DEPRECATED_TESTS - shmem_collect32(&in_32, &out_32, 1, me, 0, 1, collect_psync); - CHECK("shmem_collect32", in_32, out_32); -#else - if (new_team != SHMEM_TEAM_INVALID) - shmem_int32_collect(new_team, &in_32, &out_32, 1); - CHECK("shmem_int32_collect", in_32, out_32); -#endif - shmem_barrier_all(); - - in_64 = me; out_64 = -1; -#ifdef ENABLE_DEPRECATED_TESTS - shmem_collect64(&in_64, &out_64, 1, me, 0, 1, collect_psync); - CHECK("shmem_collect64", in_64, out_64); -#else - if (new_team != SHMEM_TEAM_INVALID) - shmem_int64_collect(new_team, &in_64, &out_64, 1); - CHECK("shmem_int64_collect", in_64, out_64); -#endif - shmem_barrier_all(); - - /* Reduction */ - if (me == 0) printf(" + reduction\n"); - - in = me; out = -1; -#ifdef ENABLE_DEPRECATED_TESTS - shmem_int_and_to_all(&in, &out, 1, me, 0, 1, pwrk, reduce_psync); - CHECK("shmem_int_and_to_all", in, out); -#else - uin = (unsigned int) me; uout = -1U; - if (new_team != SHMEM_TEAM_INVALID) - shmem_uint_and_reduce(new_team, &uin, &uout, 1); - CHECK("shmem_uint_and_reduce", uin, uout); -#endif - shmem_barrier_all(); - - in = me; out = -1; -#ifdef ENABLE_DEPRECATED_TESTS - shmem_int_or_to_all(&in, &out, 1, me, 0, 1, pwrk, reduce_psync); - CHECK("shmem_int_or_to_all", in, out); -#else - uin = (unsigned int) me; uout = -1U; - if (new_team != SHMEM_TEAM_INVALID) - shmem_uint_or_reduce(new_team, &uin, &uout, 1); - CHECK("shmem_uint_or_reduce", uin, uout); -#endif - shmem_barrier_all(); - - in = me; out = -1; -#ifdef ENABLE_DEPRECATED_TESTS - shmem_int_xor_to_all(&in, &out, 1, me, 0, 1, pwrk, reduce_psync); - CHECK("shmem_int_xor_to_all", in, out); -#else - uin = (unsigned int) me; uout = -1U; - if (new_team != SHMEM_TEAM_INVALID) - shmem_uint_xor_reduce(new_team, &uin, &uout, 1); - CHECK("shmem_uint_xor_reduce", uin, uout); -#endif - shmem_barrier_all(); - - in = me; out = -1; -#ifdef ENABLE_DEPRECATED_TESTS - shmem_int_min_to_all(&in, &out, 1, me, 0, 1, pwrk, reduce_psync); - CHECK("shmem_int_min_to_all", in, out); -#else - if (new_team != SHMEM_TEAM_INVALID) - shmem_int_min_reduce(new_team, &in, &out, 1); - CHECK("shmem_int_min_reduce", in, out); -#endif - shmem_barrier_all(); - - in = me; out = -1; -#ifdef ENABLE_DEPRECATED_TESTS - shmem_int_max_to_all(&in, &out, 1, me, 0, 1, pwrk, reduce_psync); - CHECK("shmem_int_max_to_all", in, out); -#else - if (new_team != SHMEM_TEAM_INVALID) - shmem_int_max_reduce(new_team, &in, &out, 1); - CHECK("shmem_int_max_to_all", in, out); -#endif - shmem_barrier_all(); - - in = me; out = -1; -#ifdef ENABLE_DEPRECATED_TESTS - shmem_int_sum_to_all(&in, &out, 1, me, 0, 1, pwrk, reduce_psync); - CHECK("shmem_int_sum_to_all", in, out); -#else - if (new_team != SHMEM_TEAM_INVALID) - shmem_int_sum_reduce(new_team, &in, &out, 1); - CHECK("shmem_int_sum_reduce", in, out); -#endif - shmem_barrier_all(); - - in = me; out = -1; -#ifdef ENABLE_DEPRECATED_TESTS - shmem_int_prod_to_all(&in, &out, 1, me, 0, 1, pwrk, reduce_psync); - CHECK("shmem_int_prod_to_all", in, out); -#else - if (new_team != SHMEM_TEAM_INVALID) - shmem_int_prod_reduce(new_team, &in, &out, 1); - CHECK("shmem_int_prod_reduce", in, out); -#endif - shmem_barrier_all(); - - /* All-to-all */ - if (me == 0) printf(" + all-to-all\n"); - - in_32 = me; out_32 = -1; -#ifdef ENABLE_DEPRECATED_TESTS - shmem_alltoall32(&in_32, &out_32, 1, me, 0, 1, alltoall_psync); - CHECK("shmem_alltoall32", in_32, out_32); -#else - if (new_team != SHMEM_TEAM_INVALID) - shmem_int32_alltoall(new_team, &in_32, &out_32, 1); - CHECK("shmem_int32_alltoall", in_32, out_32); -#endif - shmem_barrier_all(); - - in_64 = me; out_64 = -1; -#ifdef ENABLE_DEPRECATED_TESTS - shmem_alltoall64(&in_64, &out_64, 1, me, 0, 1, alltoall_psync); - CHECK("shmem_alltoall64", in_64, out_64); -#else - if (new_team != SHMEM_TEAM_INVALID) - shmem_int64_alltoall(new_team, &in_64, &out_64, 1); - CHECK("shmem_int64_alltoall", in_64, out_64); -#endif - shmem_barrier_all(); - - in_32 = me; out_32 = -1; -#ifdef ENABLE_DEPRECATED_TESTS - shmem_alltoalls32(&in_32, &out_32, 1, 1, 1, me, 0, 1, alltoalls_psync); - CHECK("shmem_alltoalls32", in_32, out_32); -#else - if (new_team != SHMEM_TEAM_INVALID) - shmem_int32_alltoalls(new_team, &in_32, &out_32, 1, 1, 1); - CHECK("shmem_int32_alltoalls", in_32, out_32); -#endif - shmem_barrier_all(); - - in_64 = me; out_64 = -1; -#ifdef ENABLE_DEPRECATED_TESTS - shmem_alltoalls64(&in_64, &out_64, 1, 1, 1, me, 0, 1, alltoalls_psync); - CHECK("shmem_alltoalls64", in_64, out_64); -#else - if (new_team != SHMEM_TEAM_INVALID) - shmem_int64_alltoalls(new_team, &in_64, &out_64, 1, 1, 1); - CHECK("shmem_int64_alltoalls", in_64, out_64); -#endif - shmem_barrier_all(); - - if (me == 0) printf("Done\n"); - - shmem_finalize(); - - return errors; -} diff --git a/test/unit/set_fetch.c b/test/unit/set_fetch.c deleted file mode 100644 index 97123bbc5..000000000 --- a/test/unit/set_fetch.c +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - - -/* Synopsis: Use atomic fetch to spin on var until it changes, then release - * neighbor process. - */ - -#include -#include - -int var_int = -1; -long var_long = -1; -long long var_longlong = -1; -float var_float = -1; -double var_double = -1; - -#define SPIN_TEST(typename, fmt) \ -do { \ - printf("%d: Entering %s test\n", me, #typename); \ - if (me == 0) \ - shmem_##typename##_atomic_set(&var_##typename, nproc-1, me); \ - \ - while (0 > shmem_##typename##_atomic_fetch(&var_##typename, me)) ; \ - \ - shmem_##typename##_atomic_set(&var_##typename, me, (me+1) % nproc); \ - \ - if (var_##typename - ((me + (nproc-1)) % nproc) > 0.01) { \ - printf("[%d] Type '%s' expected %d, got " fmt "\n", me, \ - #typename, me + (nproc-1) % nproc, var_##typename); \ - shmem_global_exit(1); \ - } \ - printf("%d: Finished %s test\n", me, #typename);\ -} while (0) - -int main(int argc, char **argv) { - int me, nproc; - - shmem_init(); - - me = shmem_my_pe(); - nproc = shmem_n_pes(); - - SPIN_TEST(int, "%d"); - SPIN_TEST(long, "%ld"); - SPIN_TEST(longlong, "%lld"); - SPIN_TEST(float, "%f"); - SPIN_TEST(double, "%lf"); - - shmem_finalize(); - - return 0; -} diff --git a/test/unit/set_fetch_f.f90 b/test/unit/set_fetch_f.f90 deleted file mode 100644 index 5ad811741..000000000 --- a/test/unit/set_fetch_f.f90 +++ /dev/null @@ -1,101 +0,0 @@ -! -! Copyright 2011 Sandia Corporation. Under the terms of Contract -! DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government -! retains certain rights in this software. -! -! Copyright (c) 2017 Intel Corporation. All rights reserved. -! This software is available to you under the BSD license below: -! -! Redistribution and use in source and binary forms, with or -! without modification, are permitted provided that the following -! conditions are met: -! -! - Redistributions of source code must retain the above -! copyright notice, this list of conditions and the following -! disclaimer. -! -! - Redistributions in binary form must reproduce the above -! copyright notice, this list of conditions and the following -! disclaimer in the documentation and/or other materials -! provided with the distribution. -! -! THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -! EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -! MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -! NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -! BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -! ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -! CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -! SOFTWARE. -! - -program set_fetch - implicit none - include 'shmem.fh' - - integer*4 :: var_i4, val_i4 - integer*8 :: var_i8, val_i8 - real*4 :: var_r4, val_r4 - real*8 :: var_r8, val_r8 - - integer npes, me - - common /symmetricvars/ var_i4, var_r4, var_i8, var_r8 - - integer shmem_my_pe, shmem_n_pes - integer*4 shmem_int4_fetch - integer*8 shmem_int8_fetch - real*4 shmem_real4_fetch - real*8 shmem_real8_fetch - - call shmem_init() - - me = shmem_my_pe() - npes = shmem_n_pes() - - var_i4 = 0 - var_i8 = 0 - var_r4 = 0.0 - var_r8 = 0.0 - - val_i4 = me + 1 - val_i8 = me + 1 - val_r4 = me + 1.0 - val_r8 = me + 1.0 - - call shmem_barrier_all() - - call shmem_int4_set(var_i4, val_i4, MOD(me+1, npes)) - call shmem_int8_set(var_i8, val_i8, MOD(me+1, npes)) - call shmem_real4_set(var_r4, val_r4, MOD(me+1, npes)) - call shmem_real8_set(var_r8, val_r8, MOD(me+1, npes)) - - call shmem_barrier_all() - - val_i4 = shmem_int4_fetch(var_i4, MOD(me+1, npes)) - val_i8 = shmem_int8_fetch(var_i8, MOD(me+1, npes)) - val_r4 = shmem_real4_fetch(var_r4, MOD(me+1, npes)) - val_r8 = shmem_real8_fetch(var_r8, MOD(me+1, npes)) - - if (val_i4 .ne. me + 1) then - write (*,*) "PE ", me, " int4 test failed: ", val_i4 - call shmem_global_exit(1) - endif - - if (val_i8 .ne. me + 1) then - write (*,*) "PE ", me, " int8 test failed: ", val_i8 - call shmem_global_exit(2) - endif - - if (val_r4 - (me + 1) .gt. epsilon(val_r4)) then - write (*,*) "PE ", me, " real4 test failed: ", val_r4 - call shmem_global_exit(3) - endif - - if (val_r8 - (me + 1) .gt. epsilon(val_r8)) then - write (*,*) "PE ", me, " real8 test failed: ", val_r8 - call shmem_global_exit(4) - endif - - call shmem_finalize() -end program set_fetch diff --git a/test/unit/set_lock.c b/test/unit/set_lock.c deleted file mode 100644 index 1a9e73112..000000000 --- a/test/unit/set_lock.c +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - * test shmem_set_lock() set_lock {-v|q} {loop-cnt} - * where: -q == quiet, -v == verbose/debug - * Loop for loop-cnt - * all pes call shmem_set_lock(), in fifo order a pe will return from - * shmem_set_lock() holding the lock and increment the global lock count. - * - */ - -#include -#include -#include -#include -#include - -#define Rfprintf if (shmem_my_pe() == 0) fprintf -#define Rprintf if (shmem_my_pe() == 0) printf -#define RDfprintf if (Verbose && shmem_my_pe() == 0) fprintf -#define RDprintf if (Verbose && shmem_my_pe() == 0) printf -#define Vprintf if (Verbose) printf -#define Vfprintf if (Verbose) fprintf - -int Verbose; -int lock_cnt; -long lock; - -int -main(int argc, char* argv[]) -{ - int pe, c, cloop, loops; - int my_rank, num_ranks; - int Announce = (NULL == getenv("MAKELEVEL")) ? 1 : 0; - - shmem_init(); - my_rank = shmem_my_pe(); - num_ranks = shmem_n_pes(); - if (num_ranks == 1) { - fprintf(stderr, "ERR - Requires > 1 PEs\n"); - shmem_finalize(); - return 0; - } - - while((c=getopt(argc,argv,"vq")) != -1) { - switch(c) { - case 'v': - Verbose++; - break; - case 'q': - Announce = 0; - break; - default: - Rfprintf(stderr,"ERR - unknown -%c ?\n",c); - shmem_finalize(); - return 1; - } - } - - if (optind == argc) - loops = 40; - else { - loops = atoi(argv[optind++]); - if (loops <= 0 || loops > 1000000) { - Rfprintf(stderr, - "ERR - loops arg out of bounds '%d'?\n", loops); - shmem_finalize(); - return 1; - } - } - - for(cloop=1; cloop <= loops; cloop++) { - - lock_cnt = 0; - lock = 0; - - shmem_barrier_all(); /* sync all ranks */ - - shmem_set_lock(&lock); - - for(pe=0; pe < num_ranks; pe++) { - shmem_int_atomic_add( &lock_cnt, 1, pe ); - } - if (Verbose) - printf("[%d] locked: lock_cnt(%d)\n", my_rank, lock_cnt); - - shmem_clear_lock( &lock ); - - shmem_int_wait_until( &lock_cnt, SHMEM_CMP_GE, num_ranks ); - - shmem_barrier_all(); /* sync all ranks */ - - if ( (cloop % 10) == 0 ) { - if (my_rank == 0 && Announce) - printf("%d ranks completed %d loops\n", num_ranks, cloop); - } - - if (lock_cnt != num_ranks) - printf ("[%d] loop %d: bad lock_cnt %d, expected %d?\n", - my_rank, cloop, lock_cnt, num_ranks); - } - Vprintf ("[%d] of %d, Exit: lock_cnt %d\n", my_rank, num_ranks, lock_cnt); - - shmem_finalize(); - - return 0; -} diff --git a/test/unit/shmalloc.c b/test/unit/shmalloc.c deleted file mode 100644 index 7726bf1d3..000000000 --- a/test/unit/shmalloc.c +++ /dev/null @@ -1,271 +0,0 @@ -/* :vim:sw=4:ts=4: */ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - * usage: shmalloc [-p] [nWords] [loops] [incWords-per-loop] - * where: -p == power-of-two allocation bump per loop - * [nWords] # of longs to shmem_malloc()\n" - * [loops(1)] # of loops\n" - * [incWords(2)] nWords += incWords per loop\n"); - * Loop: - * PE* shmem_malloc(nWords) - * set *DataType = 1 - * PE* shmem_malloc(nWords) - * set *DataType = 2 - * PE* shmem_malloc(nWords) - * set *DataType = 3 - * - * for(1...3) allocated ranges - * verify - * shmem_free() - * end-loop - */ - -#include -#include -#include -#include -#include - -#include - -#define DFLT_NWORDS 32 -#define DFLT_INCR 1025 -#define DFLT_LOOPS 50 - -#define DataType long - -static DataType *source; -static DataType *target; -static DataType *result; - -static int source_sz; -static int target_sz; -static int result_sz; - -static char *pgm; - -void usage (void); -int getSize (char *); - -void -usage (void) -{ - if (shmem_my_pe() == 0 ) { - fprintf (stderr, - "Usage: %s [-p] [nWords(%d)] [loops(%d)] [incWords(%d)]\n", - pgm, DFLT_NWORDS, DFLT_LOOPS, DFLT_INCR); - fprintf (stderr, - " -p == (2**0 ... 2**22) shmem_malloc(), other args ignored\n" - " -v == Verbose output\n" - " [nWords] # of longs to shmem_malloc()\n" - " [loops] # of loops\n" - " [incWords] nWords += incWords per loop\n"); - } - shmem_finalize(); - exit (1); -} - -int -getSize (char *str) -{ - int size; - char mod[32]; - - switch (sscanf (str, "%d%1[mMkK]", &size, mod)) - { - case 1: - return (size); - - case 2: - switch (*mod) - { - case 'm': - case 'M': - return (size << 20); - - case 'k': - case 'K': - return (size << 10); - - default: - return (size); - } - - default: - return (-1); - } -} - -int -main(int argc, char **argv) -{ - int me, nProcs, c, l; - int nWords, loops, incWords; - int Verbose = 0, power2 = 0, modulo = 5; - DataType *dp; - - pgm = strrchr(argv[0],'/'); - if ( pgm ) - pgm++; - else - pgm = argv[0]; - - shmem_init(); - me = shmem_my_pe(); - nProcs = shmem_n_pes(); - - while ((c = getopt (argc, argv, "hpv")) != -1) - switch (c) - { - case 'p': - power2++; - break; - case 'v': - Verbose++; - break; - case 'h': - default: - usage(); - break; - } - - if (optind == argc) - nWords = DFLT_NWORDS; - else if ((nWords = getSize (argv[optind++])) <= 0) - usage (); - - if (optind == argc) - loops = DFLT_LOOPS; - else if ((loops = getSize (argv[optind++])) < 0) - usage (); - - if (optind == argc) - incWords = DFLT_INCR; - else if ((incWords = getSize (argv[optind++])) < 0) - usage (); - - if (power2) { - nWords = 1; - modulo = 1; - loops = 21; - } - - if (Verbose && me == 0) { - if (power2) { - printf("%s: nWords(1) << 1 per loop.\n", pgm); - } - else - printf("%s: nWords(%d) loops(%d) nWords-incr-per-loop(%d)\n", - pgm, nWords, loops, incWords); - } - - for(l=0; l < loops; l++) { - - result = (DataType *)shmem_malloc(0); - if (result != NULL) { - perror ("Zero-length memory allocation has non-null result"); - shmem_finalize(); - exit (1); - } - - result_sz = nProcs * (nWords * sizeof(DataType)); - result = (DataType *)shmem_malloc(result_sz); - if (! result) - { - perror ("Failed result memory allocation"); - shmem_finalize(); - exit (1); - } - for(dp=result; dp < &result[(result_sz/sizeof(DataType))];) - *dp++ = 1; - - - target_sz = nWords * sizeof(DataType); - if (!(target = (DataType *)shmem_malloc(target_sz))) - { - perror ("Failed target memory allocation"); - shmem_finalize(); - exit (1); - } - for(dp=target; dp < &target[(target_sz / sizeof(DataType))];) - *dp++ = 2; - - source_sz = 2 * nWords * sizeof(DataType); - if (!(source = (DataType *)shmem_malloc(source_sz))) - { - perror ("Failed source memory allocation"); - shmem_finalize(); - exit (1); - } - for(dp=source; dp < &source[(source_sz / sizeof(DataType))];) - *dp++ = 3; - - shmem_barrier_all(); /* sync sender and receiver */ - - for(dp=source; dp < &source[(source_sz / sizeof(DataType))]; dp++) - if (*dp != 3 ) { - printf("source not consistent @ 3?\n"); - break; - } - shmem_free(source); - - for(dp=target; dp < &target[(target_sz / sizeof(DataType))]; dp++) - if (*dp != 2 ) { - printf("target not consistent @ 2?\n"); - break; - } - shmem_free(target); - - for(dp=result; dp < &result[(result_sz / sizeof(DataType))]; dp++) - if (*dp != 1 ) { - printf("result not consistent @ 1?\n"); - break; - } - shmem_free(result); - - if (loops > 1) { - if (Verbose && me == 0) { - if (l == 0 || (l % modulo == 0)) - printf("End loop %3d nWords(%d)\n",(l+1),nWords); - } - if (power2) - nWords <<= 1; - else - nWords += incWords; // watch for double inc. - } - } - - shmem_finalize(); - - return 0; -} diff --git a/test/unit/shmem_calloc.c b/test/unit/shmem_calloc.c deleted file mode 100644 index 45b3201ea..000000000 --- a/test/unit/shmem_calloc.c +++ /dev/null @@ -1,271 +0,0 @@ -/* :vim:sw=4:ts=4: */ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - * usage: shmem_calloc [-p] [nWords] [loops] [incWords-per-loop] - * where: -p == power-of-two allocation bump per loop - * [nWords] # of longs to shmem_calloc()\n" - * [loops(1)] # of loops\n" - * [incWords(2)] nWords += incWords per loop\n"); - * Loop: - * PE* shmem_calloc(nWords) - * set *DataType = 1 - * PE* shmem_calloc(nWords) - * set *DataType = 2 - * PE* shmem_calloc(nWords) - * set *DataType = 3 - * - * for(1...3) allocated ranges - * verify - * shmem_free() - * end-loop - */ - -#include -#include -#include -#include -#include - -#include - -#define DFLT_NWORDS 32 -#define DFLT_INCR 1025 -#define DFLT_LOOPS 50 - -#define DataType long - -static DataType *source; -static DataType *target; -static DataType *result; - -static int source_sz; -static int target_sz; -static int result_sz; - -static char *pgm; - -void usage (void); -int getSize (char *); - -void -usage (void) -{ - if (shmem_my_pe() == 0 ) { - fprintf (stderr, - "Usage: %s [-p] [nWords(%d)] [loops(%d)] [incWords(%d)]\n", - pgm, DFLT_NWORDS, DFLT_LOOPS, DFLT_INCR); - fprintf (stderr, - " -p == (2**0 ... 2**22) shmem_calloc(), other args ignored\n" - " -v == Verbose output\n" - " [nWords] # of longs to shmem_calloc()\n" - " [loops] # of loops\n" - " [incWords] nWords += incWords per loop\n"); - } - shmem_finalize(); - exit (1); -} - -int -getSize (char *str) -{ - int size; - char mod[32]; - - switch (sscanf (str, "%d%1[mMkK]", &size, mod)) - { - case 1: - return (size); - - case 2: - switch (*mod) - { - case 'm': - case 'M': - return (size << 20); - - case 'k': - case 'K': - return (size << 10); - - default: - return (size); - } - - default: - return (-1); - } -} - -int -main(int argc, char **argv) -{ - int me, nProcs, c, l; - int nWords, loops, incWords; - int Verbose = 0, power2 = 0, modulo = 5; - DataType *dp; - - pgm = strrchr(argv[0],'/'); - if ( pgm ) - pgm++; - else - pgm = argv[0]; - - shmem_init(); - me = shmem_my_pe(); - nProcs = shmem_n_pes(); - - while ((c = getopt (argc, argv, "hpv")) != -1) - switch (c) - { - case 'p': - power2++; - break; - case 'v': - Verbose++; - break; - case 'h': - default: - usage(); - break; - } - - if (optind == argc) - nWords = DFLT_NWORDS; - else if ((nWords = getSize (argv[optind++])) <= 0) - usage (); - - if (optind == argc) - loops = DFLT_LOOPS; - else if ((loops = getSize (argv[optind++])) < 0) - usage (); - - if (optind == argc) - incWords = DFLT_INCR; - else if ((incWords = getSize (argv[optind++])) < 0) - usage (); - - if (power2) { - nWords = 1; - modulo = 1; - loops = 21; - } - - if (Verbose && me == 0) { - if (power2) { - printf("%s: nWords(1) << 1 per loop.\n", pgm); - } - else - printf("%s: nWords(%d) loops(%d) nWords-incr-per-loop(%d)\n", - pgm, nWords, loops, incWords); - } - - for(l=0; l < loops; l++) { - - result = (DataType *)shmem_calloc(0, sizeof(DataType)); - if (result != NULL) { - perror ("Zero-length memory allocation has non-null result"); - shmem_finalize(); - exit (1); - } - - result_sz = nProcs * (nWords * sizeof(DataType)); - result = (DataType *)shmem_calloc(nProcs * nWords, sizeof(DataType)); - if (! result) - { - perror ("Failed result memory allocation"); - shmem_finalize(); - exit (1); - } - for(dp=result; dp < &result[(result_sz/sizeof(DataType))];) - *dp++ += 1; - - - target_sz = nWords * sizeof(DataType); - if (!(target = (DataType *)shmem_calloc(nWords, sizeof(DataType)))) - { - perror ("Failed target memory allocation"); - shmem_finalize(); - exit (1); - } - for(dp=target; dp < &target[(target_sz / sizeof(DataType))];) - *dp++ += 2; - - source_sz = 2 * nWords * sizeof(DataType); - if (!(source = (DataType *)shmem_calloc(2*nWords, sizeof(DataType)))) - { - perror ("Failed source memory allocation"); - shmem_finalize(); - exit (1); - } - for(dp=source; dp < &source[(source_sz / sizeof(DataType))];) - *dp++ += 3; - - shmem_barrier_all(); /* sync sender and receiver */ - - for(dp=source; dp < &source[(source_sz / sizeof(DataType))]; dp++) - if (*dp != 3 ) { - printf("source not consistent @ 3?\n"); - break; - } - shmem_free(source); - - for(dp=target; dp < &target[(target_sz / sizeof(DataType))]; dp++) - if (*dp != 2 ) { - printf("target not consistent @ 2?\n"); - break; - } - shmem_free(target); - - for(dp=result; dp < &result[(result_sz / sizeof(DataType))]; dp++) - if (*dp != 1 ) { - printf("result not consistent @ 1?\n"); - break; - } - shmem_free(result); - - if (loops > 1) { - if (Verbose && me == 0) { - if (l == 0 || (l % modulo == 0)) - printf("End loop %3d nWords(%d)\n",(l+1),nWords); - } - if (power2) - nWords <<= 1; - else - nWords += incWords; // watch for double inc. - } - } - - shmem_finalize(); - - return 0; -} diff --git a/test/unit/shmem_ctx_get_team.c b/test/unit/shmem_ctx_get_team.c deleted file mode 100644 index 489d5a2b4..000000000 --- a/test/unit/shmem_ctx_get_team.c +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2022 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include - -int main(void) { - int ret; - shmem_team_t retrieved_team; - - shmem_init(); - - if (shmem_n_pes() < 2) { - fprintf(stderr, "ERR - Requires at least 2 PEs\n"); - shmem_finalize(); - return 0; - } - - /* test for invalid context */ - ret = shmem_ctx_get_team(SHMEM_CTX_INVALID, &retrieved_team); - if (ret == 0 || retrieved_team != SHMEM_TEAM_INVALID) { - fprintf(stderr, "Error in return values for SHMEM_CTX_INVALID\n"); - shmem_global_exit(1); - } - - /* test for default context */ - ret = shmem_ctx_get_team(SHMEM_CTX_DEFAULT, &retrieved_team); - if (ret != 0 || retrieved_team != SHMEM_TEAM_WORLD) { - fprintf(stderr, "Error in return values for SHMEM_CTX_DEFAULT\n"); - shmem_global_exit(2); - } - - /* test for a created context on a user defined team*/ - shmem_team_t new_team; - shmem_team_config_t *config; - - config = NULL; - int npes = shmem_n_pes(); - - ret = shmem_team_split_strided(SHMEM_TEAM_WORLD, 0, 2, (npes + 1) / 2, - config, 0, &new_team); - if (new_team != SHMEM_TEAM_INVALID) { - shmem_ctx_t team_ctx; - if (!shmem_team_create_ctx(new_team, 0L, &team_ctx)) { - ret = shmem_ctx_get_team(team_ctx, &retrieved_team); - if (ret != 0 || retrieved_team != new_team) { - fprintf(stderr, "Error in return values for a team context\n"); - shmem_global_exit(3); - } - } - } - - shmem_finalize(); - - return 0; -} diff --git a/test/unit/shmem_info.c b/test/unit/shmem_info.c deleted file mode 100644 index 4686ed974..000000000 --- a/test/unit/shmem_info.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include - -int -main(int argc, char* argv[]) -{ - int major_ver, minor_ver; - char name[SHMEM_MAX_NAME_LEN]; - - shmem_init(); - - shmem_info_get_version(&major_ver, &minor_ver); - shmem_info_get_name(name); - - assert(strlen(name) <= SHMEM_MAX_NAME_LEN); - assert(major_ver == SHMEM_MAJOR_VERSION); - assert(minor_ver == SHMEM_MINOR_VERSION); - assert(major_ver >= 1); - assert(minor_ver >= 0); - assert(strcmp(name, SHMEM_VENDOR_STRING) == 0); - - printf("%d: OpenSHMEM %d.%d -- \"%s\"\n", shmem_my_pe(), major_ver, - minor_ver, name); - - shmem_finalize(); - return 0; -} diff --git a/test/unit/shmem_info_f.f90 b/test/unit/shmem_info_f.f90 deleted file mode 100644 index c1e2ba231..000000000 --- a/test/unit/shmem_info_f.f90 +++ /dev/null @@ -1,61 +0,0 @@ -! -! Copyright (c) 2017 Intel Corporation. All rights reserved. -! This software is available to you under the BSD license below: -! -! Redistribution and use in source and binary forms, with or -! without modification, are permitted provided that the following -! conditions are met: -! -! - Redistributions of source code must retain the above -! copyright notice, this list of conditions and the following -! disclaimer. -! -! - Redistributions in binary form must reproduce the above -! copyright notice, this list of conditions and the following -! disclaimer in the documentation and/or other materials -! provided with the distribution. -! -! THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -! EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -! MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -! NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -! BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -! ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -! CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -! SOFTWARE. -! - -program shmem_info - include 'shmem.fh' - - integer me, major_ver, minor_ver - integer shmem_my_pe - character (len=SHMEM_MAX_NAME_LEN) lib_name - - call shmem_init() - me = shmem_my_pe() - - call shmem_info_get_version(major_ver, minor_ver) - call shmem_info_get_name(lib_name) - - ! Note: The spec does not require these strings to be identical. - ! They are implemented this way in SOS, and we take advantage - ! of that property to check the C/Fortran bindings linkage. - if (lib_name .ne. SHMEM_VENDOR_STRING) then - print *, me, "Vendor strings did not match!" - print *, me, "shmem_info_get_name: ", lib_name - print *, me, "SHMEM_VENDOR_STRING: ", SHMEM_VENDOR_STRING - call shmem_global_exit(1) - endif - - if ((major_ver .ne. SHMEM_MAJOR_VERSION) .OR. & - (minor_ver .ne. SHMEM_MINOR_VERSION)) then - print *, me, "Version numbers did not match!" - print *, me, "shmem_info_get_version: ", major_ver, minor_ver - print *, me, "Library constants : ", SHMEM_MAJOR_VERSION, & - SHMEM_MINOR_VERSION - call shmem_global_exit(1) - end if - - call shmem_finalize() -end program shmem_info diff --git a/test/unit/shmem_malloc_with_hints.c b/test/unit/shmem_malloc_with_hints.c deleted file mode 100644 index 7ae4046a6..000000000 --- a/test/unit/shmem_malloc_with_hints.c +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2020 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include - -#define N 128 -#define MAX(a,b) ((a) > (b)) ? a : b -#define WRK_SIZE MAX(N/2+1, SHMEM_REDUCE_MIN_WRKDATA_SIZE) - -#define NUM_TESTS 5 - -#define SHMEM_MALLOC_INVALID_HINT ~(SHMEM_MALLOC_ATOMICS_REMOTE) - -static int sumtoall_with_malloc_hint(long hint, int mype, int npes) -{ - int failed = 0; - int i; - int *dst, *src; - - if (mype == 0) - printf("Sum reduction operation started\n"); - - dst = (int *)shmem_malloc_with_hints(N * sizeof(*dst), hint); - src = (int *)shmem_malloc_with_hints(N * sizeof(*src), hint); - - for (i = 0; i < N; i++) { - src[i] = mype; - dst[i] = -1; - } - - shmem_barrier_all(); - shmem_int_sum_reduce(SHMEM_TEAM_WORLD, dst, src, N); - - if (mype == 0) { - for (i = 0; i < N; i++) { - int expected; - expected = npes * (npes-1)/2; - if (dst[i] != expected) { - printf("[%d] dst[%d] = %d, expected %d\n", mype, i, dst[i], expected); - failed = 1; - } - } - } - - return (!failed); -} - - -int main(int argc, char **argv) { - int npes, mype; - int passed = 0; - int fail = 0; - - shmem_init(); - - npes = shmem_n_pes(); - mype = shmem_my_pe(); - - passed = sumtoall_with_malloc_hint(0, mype, npes); - passed += sumtoall_with_malloc_hint(SHMEM_MALLOC_ATOMICS_REMOTE, mype, npes); - passed += sumtoall_with_malloc_hint(SHMEM_MALLOC_SIGNAL_REMOTE, mype, npes); - passed += sumtoall_with_malloc_hint(SHMEM_MALLOC_ATOMICS_REMOTE | SHMEM_MALLOC_SIGNAL_REMOTE, mype, npes); - passed += sumtoall_with_malloc_hint(SHMEM_MALLOC_INVALID_HINT, mype, npes); - - fail = NUM_TESTS - passed; - - if (mype == 0) { - if (passed != NUM_TESTS) { - printf("%d out of %d tests failed\n", fail, NUM_TESTS); - shmem_global_exit(fail); - } - else - printf("All %d tests passed\n", passed); - } - - shmem_finalize(); - return 0; -} diff --git a/test/unit/shmem_ptr.c b/test/unit/shmem_ptr.c deleted file mode 100644 index bcdc877a0..000000000 --- a/test/unit/shmem_ptr.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2019 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include - -int main(void) { - int i, n, available, errors = 0; - int me, npes; - - static int shr_data = -1; - int * shr_heap; - - shmem_init(); - - me = shmem_my_pe(); - npes = shmem_n_pes(); - - shr_heap = shmem_malloc(sizeof(int)); - - shr_data = me; - *shr_heap = me; - - shmem_barrier_all(); - - /* Check shmem_ptr on data segment */ - - for (i = n = available = 0; i < npes; i++) { - int * ptr = (int *) shmem_ptr(&shr_data, i); - - if (ptr != NULL) { - int shr_peer = *ptr; - ++n; - - if (shr_peer != i) { - printf("%2d: Error, shr_data(%d) = %d, expected %d\n", me, i, shr_peer, i); - errors++; - } - } - else if (i == me) { - printf("%2d: Error, shmem_ptr(data) returned NULL for my PE\n", me); - errors++; - } - else { - /* NULL is returned for remotely inaccessible data objects. - Enabling XPMEM / CMA will allow non-NULL value for on-node PEs */ - ++available; - } - } - - printf("%2d: Found %d data segment peer(s) (%d were inaccessible)\n", me, n, available); - fflush(NULL); - shmem_barrier_all(); - - /* Check shmem_ptr on heap segment */ - - for (i = n = available = 0; i < npes; i++) { - int * ptr = (int *) shmem_ptr(shr_heap, i); - - if (ptr != NULL) { - int shr_peer = *ptr; - ++n; - - if (shr_peer != i) { - printf("%2d: Error, shr_heap(%d) = %d, expected %d\n", me, i, shr_peer, i); - errors++; - } - } - else if (i == me) { - printf("%2d: Error, shmem_ptr(heap) returned NULL for my PE\n", me); - errors++; - } - else { - /* NULL is returned for remotely inaccessible data objects. - Enabling XPMEM / CMA will allow non-NULL value for on-node PEs */ - ++available; - } - } - - printf("%2d: Found %d heap segment peer(s) (%d were inaccessible)\n", me, n, available); - - shmem_finalize(); - - return errors != 0; -} diff --git a/test/unit/shmem_team_b2b_collectives.c b/test/unit/shmem_team_b2b_collectives.c deleted file mode 100644 index e796e663d..000000000 --- a/test/unit/shmem_team_b2b_collectives.c +++ /dev/null @@ -1,79 +0,0 @@ -/* Copyright (c) 2019 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include - -#define NITERS 100 -#define NELEMS 10 - -#define TEST_B2B_COLLECTIVE(NAME, ROUTINE, ...) \ - do { \ - if (me == 0) printf("%s... ", NAME); \ - int i; \ - for (i = 0; i < NITERS; i++) { \ - errors += ROUTINE(__VA_ARGS__); \ - } \ - error_check(&errors, &total_errors, NAME, me); \ - } while (0) - -static void error_check(int *errors, int *total_errors, char *routine, int me) { - if (*errors == 0) { - if (me == 0) printf("passed.\n"); - } else { - printf("%s error on PE %d\n", routine, me); - *total_errors += *errors; - *errors = 0; - } - return; -} - - -int main(void) -{ - int errors = 0, total_errors = 0; - shmem_init(); - int me = shmem_my_pe(); - - long *dest = shmem_malloc(NELEMS * sizeof(long)); - long *src = shmem_malloc(NELEMS * sizeof(long)); - - size_t i; - for (i = 0; i < NELEMS; i++) { - src[i] = me; - } - - TEST_B2B_COLLECTIVE("broadcast", shmem_long_broadcast, SHMEM_TEAM_WORLD, dest, src, NELEMS, 0); - TEST_B2B_COLLECTIVE("reduce", shmem_long_sum_reduce, SHMEM_TEAM_WORLD, dest, src, NELEMS); - TEST_B2B_COLLECTIVE("collect", shmem_long_collect, SHMEM_TEAM_WORLD, dest, src, NELEMS); - TEST_B2B_COLLECTIVE("fcollect", shmem_long_fcollect, SHMEM_TEAM_WORLD, dest, src, NELEMS); - TEST_B2B_COLLECTIVE("alltoall", shmem_long_alltoall, SHMEM_TEAM_WORLD, dest, src, NELEMS); - TEST_B2B_COLLECTIVE("alltoalls", shmem_long_alltoalls, SHMEM_TEAM_WORLD, dest, src, 1, 1, NELEMS); - - shmem_finalize(); - return total_errors; -} diff --git a/test/unit/shmem_team_collect_active_set.c b/test/unit/shmem_team_collect_active_set.c deleted file mode 100644 index 7902c4427..000000000 --- a/test/unit/shmem_team_collect_active_set.c +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 2019 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include - -#define MAX_NPES 32 - -int64_t src[MAX_NPES]; -int64_t dst[MAX_NPES*MAX_NPES]; - -int main(void) -{ - int i, me, npes; - int errors = 0; - - shmem_init(); - - me = shmem_my_pe(); - npes = shmem_n_pes(); - - if (npes > MAX_NPES) { - if (me == 0) - printf("Test requires fewer than %d PEs\n", MAX_NPES); - shmem_finalize(); - return 0; - } - - for (i = 0; i < MAX_NPES; i++) - src[i] = me; - - for (i = 0; i < MAX_NPES*MAX_NPES; i++) - dst[i] = -1; - - if (me == 0) - printf("Shrinking team size test\n"); - - shmem_team_t old_team, new_team; - shmem_team_split_strided(SHMEM_TEAM_WORLD, 0, 1, npes, NULL, 0, &old_team); - - /* A total of npes-1 tests are performed, where the active set in each test - * includes PEs i..npes-1, and each PE contributes PE ID elements. The size - * of the team decreases by 1 each iteration. */ - for (i = 1; i < npes; i++) { - int j, k; - int idx = 0; - - if (me == i) - printf(" + team size %d\n", shmem_team_n_pes(old_team)-1); - - shmem_team_split_strided(old_team, 1, 1, shmem_team_n_pes(old_team)-1, NULL, 0, &new_team); - - if (new_team != SHMEM_TEAM_INVALID) { - - - shmem_int64_collect(new_team, dst, src, me); - - /* Validate destination buffer data */ - for (j = 0; j < npes - i; j++) { - for (k = 0; k < i+j; k++, idx++) { - if (dst[idx] != i+j) { - printf("%d: Expected dst[%d] = %d, got dst[%d] = %"PRId64", iteration %d\n", - me, idx, i+j, idx, dst[idx], i); - errors++; - } - } - } - - /* Validate unused destination buffer */ - for ( ; idx < MAX_NPES*MAX_NPES; idx++) { - if (dst[idx] != -1) { - printf("%d: Expected dst[%d] = %d, got dst[%d] = %"PRId64", iteration %d\n", - me, idx, -1, idx, dst[idx], i); - errors++; - } - } - - /* Reset for next iteration */ - for (j = 0; j < MAX_NPES*MAX_NPES; j++) - dst[j] = -1; - -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L - shmem_sync(new_team); -#else - shmem_team_sync(new_team); -#endif - } - - old_team = new_team; - } - - shmem_team_destroy(old_team); - shmem_finalize(); - - return errors != 0; -} diff --git a/test/unit/shmem_team_get_config.c b/test/unit/shmem_team_get_config.c deleted file mode 100644 index 10c6c6a82..000000000 --- a/test/unit/shmem_team_get_config.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2021 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include - -int main(void) -{ - int my_pe, npes, ret, errors = 0; - shmem_team_t even_team; - shmem_team_config_t config; - shmem_team_config_t new_config; - - shmem_init(); - my_pe = shmem_my_pe(); - npes = shmem_n_pes(); - - - ret = shmem_team_get_config(SHMEM_TEAM_WORLD, SHMEM_TEAM_NUM_CONTEXTS, &config); - - if (ret != 0) { - printf("PE %d: unexpected return value (%d)\n", my_pe, ret); - ++errors; - } - - ret = shmem_team_get_config(SHMEM_TEAM_INVALID, 0, &config); - - if (ret == 0) { - printf("PE %d: unexpected (SHMEM_TEAM_INVALID) return value (%d)\n", my_pe, ret); - ++errors; - } - - config.num_contexts = 3; - - shmem_team_split_strided(SHMEM_TEAM_WORLD, 0, 2, ((npes-1)/2)+1, &config, 0, &even_team); - - ret = shmem_team_get_config(even_team, SHMEM_TEAM_NUM_CONTEXTS, &new_config); - - if (shmem_team_my_pe(even_team) != -1 && - (new_config.num_contexts != 3 || ret != 0)) { - printf("PE %d: unexpected num_contexts (%d)\n", my_pe, new_config.num_contexts); - ++errors; - } - - if (shmem_team_my_pe(even_team) == -1 && ret == 0) { - printf("PE %d: unexpected return value from non-team members (%d)\n", my_pe, ret); - ++errors; - } - - shmem_finalize(); - return errors != 0; -} diff --git a/test/unit/shmem_team_max.c b/test/unit/shmem_team_max.c deleted file mode 100644 index 574c62850..000000000 --- a/test/unit/shmem_team_max.c +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2019 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include - -#define NUM_TEAMS 64 - -int ret = 0; -int dest_ret = 0; - -int main(void) -{ - int me, npes, i, j; - int team_count = 0; - - shmem_init(); - - me = shmem_my_pe(); - npes = shmem_n_pes(); - - shmem_team_t new_team[NUM_TEAMS]; - - for (i = j = 0; i < NUM_TEAMS; ) { - ret = shmem_team_split_strided(SHMEM_TEAM_WORLD, 0, 1, 1 + i % npes, - NULL, 0, &new_team[i]); - - /* Wait for all PEs to fill in ret before starting the reduction */ -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L - shmem_sync(SHMEM_TEAM_WORLD); -#else - shmem_team_sync(SHMEM_TEAM_WORLD); -#endif - shmem_int_sum_reduce(SHMEM_TEAM_WORLD, &dest_ret, &ret, 1); - - /* If success was not global, free a team and retry */ - if (dest_ret != 0) { - if (ret == 0) { - printf("%d: Local success and global failure on iteration %d\n", - me, i); - shmem_global_exit(1); - } - - /* No more teams to free */ - if (i == j) - break; - - shmem_team_destroy(new_team[j]); - j++; - } else { - i++; - team_count++; - } - } - - printf("The number of teams created for PE %d is : %d\n", me, team_count); - - shmem_finalize(); - - return 0; -} diff --git a/test/unit/shmem_team_negative_stride.c b/test/unit/shmem_team_negative_stride.c deleted file mode 100644 index 0e0366616..000000000 --- a/test/unit/shmem_team_negative_stride.c +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2022 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include - -int main(void) -{ - int i, me, npes; - int errors = 0; - - shmem_init(); - - me = shmem_my_pe(); - npes = shmem_n_pes(); - - if (npes < 2) { - if (me == 0) - printf("Test requires 2 or more PEs\n"); - shmem_finalize(); - return 0; - } - - int *src = shmem_malloc(npes * sizeof(int)); - int *dst = shmem_malloc(npes * sizeof(int)); - - for (i = 0; i < npes; i++) - src[i] = i; - - for (i = 0; i < npes; i++) - dst[i] = -1; - - if (me == 0) - printf("-1 stride:\n"); - - shmem_team_t new_team; - shmem_team_split_strided(SHMEM_TEAM_WORLD, npes - 1, -1, npes, NULL, 0, &new_team); - - if (new_team != SHMEM_TEAM_INVALID) { - int new_team_id = shmem_team_translate_pe(SHMEM_TEAM_WORLD, me, new_team); - - if (new_team_id != -1 && new_team_id == abs(me - npes + 1)) { - printf("world team ID = %d, new team ID = %d\n", me, new_team_id); - } else { - errors++; - } - - shmem_int_sum_reduce(new_team, dst, src, npes); - - for (i = 0; i < npes; i++) { - if (dst[i] != i * npes) { - printf("ERROR: dst[i] = %d, expected %d\n", dst[i], i * npes); - errors++; - } - } - } - - shmem_team_destroy(new_team); - - for (i = 0; i < npes; i++) - dst[i] = -1; - - if (me == 0) - printf("-2 stride:\n"); - - shmem_team_split_strided(SHMEM_TEAM_WORLD, npes - 1, -2, npes/2, NULL, 0, &new_team); - - if (new_team != SHMEM_TEAM_INVALID) { - int new_team_id = shmem_team_translate_pe(SHMEM_TEAM_WORLD, me, new_team); - - if (new_team_id != -1 && new_team_id == abs((npes - me - 1)/2)) { - printf("world team ID = %d, new team ID = %d\n", me, new_team_id); - } else { - errors++; - } - - shmem_int_sum_reduce(new_team, dst, src, npes); - - for (i = 0; i < npes; i++) { - if (dst[i] != i * (npes/2)) { - printf("ERROR: dst[i] = %d, expected %d\n", dst[i], i * (npes/2)); - errors++; - } - } - } - - shmem_team_destroy(new_team); - shmem_free(src); - shmem_free(dst); - shmem_finalize(); - - return errors != 0; -} diff --git a/test/unit/shmem_team_ptr.c b/test/unit/shmem_team_ptr.c deleted file mode 100644 index e456371ea..000000000 --- a/test/unit/shmem_team_ptr.c +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Copyright (c) 2022 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include - -int main(void) { - int i, n, available, errors = 0; - int me, team_me, npes; - - static int shr_world_data, shr_team_data = -1; - int * shr_heap; - - shmem_init(); - - me = shmem_my_pe(); - npes = shmem_n_pes(); - - if (npes == 1) { - if (me == 0) { - printf("Error, this test requires more than 1 process\n"); - } - shmem_finalize(); - return 0; - } - - shr_world_data = me; - - shmem_barrier_all(); - - /* Check shmem_team_ptr on data segment */ - for (i = n = available = 0; i < npes; i++) { - int * world_ptr = (int *) shmem_team_ptr(SHMEM_TEAM_WORLD, &shr_world_data, i); - - if (world_ptr != NULL) { - - int shr_world_peer = *world_ptr; - ++n; - - if (shr_world_peer != i) { - printf("%2d: Error, shr_world_data(%d) = %d, expected %d\n", me, i, shr_world_peer, i); - errors++; - } - } - else if (i == me) { - printf("%2d: Error, shmem_world_ptr(data) returned NULL for my PE\n", me); - errors++; - } - else { - /* NULL is returned for remotely inaccessible data objects. - Enabling XPMEM / CMA will allow non-NULL value for on-node PEs */ - ++available; - } - } - - printf("%2d: Found %d world team data segment peer(s) (%d were inaccessible)\n", me, n, available); - fflush(NULL); - shmem_barrier_all(); - - /* Check shmem_team_ptr on heap segment */ - shr_heap = shmem_malloc(sizeof(int)); - *shr_heap = me; - shmem_sync_all(); - - for (i = n = available = 0; i < npes; i++) { - int * world_ptr = (int *) shmem_team_ptr(SHMEM_TEAM_WORLD, shr_heap, i); - - if (world_ptr != NULL) { - int shr_world_peer = *world_ptr; - ++n; - - if (shr_world_peer != i) { - printf("%2d: Error, shr_world_heap(%d) = %d, expected %d\n", me, i, shr_world_peer, i); - errors++; - } - } - else if (i == me) { - printf("%2d: Error, shmem_team_ptr(heap) returned NULL for my PE\n", me); - errors++; - } - else { - /* NULL is returned for remotely inaccessible data objects. - Enabling XPMEM / CMA will allow non-NULL value for on-node PEs */ - ++available; - } - } - - printf("%2d: Found %d world team heap segment peer(s) (%d were inaccessible)\n", me, n, available); - fflush(NULL); - shmem_barrier_all(); - - // Create a team of PEs w/ odd numbered id's - shmem_team_t new_team; - shmem_team_split_strided(SHMEM_TEAM_WORLD, 1, 2, npes / 2, NULL, 0, &new_team); - if (new_team != SHMEM_TEAM_INVALID) { - team_me = shmem_team_my_pe(new_team); - shr_team_data = team_me; - shmem_team_sync(new_team); - - /* Check shmem_team_ptr on data segment */ - for (i = n = available = 0; i < npes / 2; i++) { - int * team_ptr = (int *) shmem_team_ptr(new_team, &shr_team_data, i); - - if (team_ptr != NULL) { - int shr_team_peer = *team_ptr; - ++n; - - if (shr_team_peer != i) { - printf("%2d: Error, shr_team_data(%d) = %d, expected %d\n", team_me, i, shr_team_peer, i); - errors++; - } - } - else if (i == team_me) { - printf("%2d: Error, i = %d, shmem_team_ptr(data) returned NULL for my PE\n", team_me, i); - errors++; - } - else { - /* NULL is returned for remotely inaccessible data objects. - Enabling XPMEM / CMA will allow non-NULL value for on-node PEs */ - ++available; - } - } - printf("%2d: Found %d world team data segment peer(s) (%d were inaccessible)\n", me, n, available); - fflush(NULL); - } - - /* Check shmem_team_ptr on heap segment */ - int * shr_team_heap = shmem_malloc(sizeof(int)); - if (new_team != SHMEM_TEAM_INVALID) { - team_me = shmem_team_my_pe(new_team); - *shr_team_heap = team_me; - shmem_team_sync(new_team); - - for (i = n = available = 0; i < npes / 2; i++) { - int * team_ptr = (int *) shmem_team_ptr(new_team, shr_team_heap, i); - - if (team_ptr != NULL) { - int shr_team_peer = *team_ptr; - ++n; - - if (shr_team_peer != i) { - printf("%2d: Error, shr_team_heap(%d) = %d, expected %d\n", me, i, shr_team_peer, i); - errors++; - } - } - else if (i == team_me) { - printf("%2d: Error, shmem_team_ptr(heap) returned NULL for my PE\n", team_me); - errors++; - } - else { - /* NULL is returned for remotely inaccessible data objects. - Enabling XPMEM / CMA will allow non-NULL value for on-node PEs */ - ++available; - } - } - printf("%2d: Found %d world team heap segment peer(s) (%d were inaccessible)\n", me, n, available); - } - - shmem_team_destroy(new_team); - shmem_finalize(); - - return errors != 0; -} diff --git a/test/unit/shmem_team_reduce.c b/test/unit/shmem_team_reduce.c deleted file mode 100644 index 69cbc6911..000000000 --- a/test/unit/shmem_team_reduce.c +++ /dev/null @@ -1,319 +0,0 @@ -/* - * This test program is derived from a unit test created by Nick Park. - * The original unit test is a work of the U.S. Government and is not subject - * to copyright protection in the United States. Foreign copyrights may - * apply. - * - * Copyright (c) 2021 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include -#include -#include - -#define MAX_NPES 32 - -enum op { and = 0, or, xor, max, min, sum, prod }; - -const double FLOATING_POINT_TOLERANCE = 1e-6; - -#define REDUCTION(OP, TYPE) \ - do { ret = shmem_##TYPE##_##OP##_reduce(SHMEM_TEAM_WORLD, dest, src, npes); } while (0) - -#define is_floating_point(X) _Generic((X), \ - float: true, \ - double: true, \ - long double: true, \ - float _Complex: true, \ - double _Complex: true, \ - default: false \ -) - -#define INIT_SRC_BUFFER(TYPE) \ - do { \ - for (int i = 0; i < MAX_NPES; i++) { \ - src[i] = (TYPE)1ULL; \ - } \ - } while (0) - -#define CHECK_DEST_BUFFER(OP, TYPE, CORRECT_VAL) \ - do { \ - for (int i = 0; i < npes; i++) { \ - if (dest[i] != (TYPE)CORRECT_VAL) { \ - printf("PE %i received incorrect value with " \ - "TEST_SHMEM_REDUCE(%s, %s)\n", mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } \ - } while (0) - -#define CHECK_DEST_BUFFER_FP(OP, TYPE, CORRECT_VAL, TOLERANCE) \ - do { \ - for (int i = 0; i < npes; i++) { \ - if (fabsl(creal(dest[i]) - creal((TYPE)CORRECT_VAL)) > TOLERANCE) { \ - printf("PE %i received incorrect real value with " \ - "TEST_SHMEM_REDUCE(%s, %s)\n", mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - if (fabsl(cimag(dest[i]) - cimag((TYPE)CORRECT_VAL)) > TOLERANCE) { \ - printf("PE %i received incorrect imaginary value with " \ - "TEST_SHMEM_REDUCE(%s, %s)\n", mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - } \ - } while (0) - -#define TEST_SHMEM_REDUCE(OP, TYPENAME, TYPE) \ - do { \ - static TYPE src[MAX_NPES]; \ - static TYPE dest[MAX_NPES]; \ - int ret; \ - const bool floating_point_val = is_floating_point((TYPE)0); \ - \ - INIT_SRC_BUFFER(TYPE); \ - \ - REDUCTION(OP, TYPENAME); \ - \ - if (ret != 0) { \ - printf("Reduction returned non-zero value (%i) on PE (%i) with " \ - "TEST_SHMEM_REDUCE(%s, %s)\n", ret, mype, #OP, #TYPE); \ - rc = EXIT_FAILURE; \ - } \ - \ - shmem_barrier_all(); \ - \ - switch (OP) { \ - case and: \ - CHECK_DEST_BUFFER(OP, TYPE, 1ULL); \ - break; \ - case or: \ - CHECK_DEST_BUFFER(OP, TYPE, 1ULL); \ - break; \ - case xor: \ - CHECK_DEST_BUFFER(OP, TYPE, (TYPE)(npes % 2 ? 1ULL : 0ULL)); \ - break; \ - case max: \ - if (floating_point_val) \ - CHECK_DEST_BUFFER_FP(OP, TYPE, 1ULL, FLOATING_POINT_TOLERANCE); \ - else \ - CHECK_DEST_BUFFER(OP, TYPE, 1ULL); \ - break; \ - case min: \ - if (floating_point_val) \ - CHECK_DEST_BUFFER_FP(OP, TYPE, 1ULL, FLOATING_POINT_TOLERANCE); \ - else \ - CHECK_DEST_BUFFER(OP, TYPE, 1ULL); \ - break; \ - case sum: \ - if (floating_point_val) \ - CHECK_DEST_BUFFER_FP(OP, TYPE, npes, FLOATING_POINT_TOLERANCE); \ - else \ - CHECK_DEST_BUFFER(OP, TYPE, npes); \ - break; \ - case prod: \ - if (floating_point_val) \ - CHECK_DEST_BUFFER_FP(OP, TYPE, 1ULL, FLOATING_POINT_TOLERANCE); \ - else \ - CHECK_DEST_BUFFER(OP, TYPE, 1ULL); \ - break; \ - default: \ - printf("Invalid operation (%d)\n", OP); \ - shmem_global_exit(1); \ - } \ - } while (0) - - -int main(void) { - - shmem_init(); - - int rc = EXIT_SUCCESS; - - const int mype = shmem_my_pe(); - const int npes = shmem_n_pes(); - - if (npes > MAX_NPES) { - if (mype == 0) - fprintf(stderr, "ERR - Requires less than %d PEs\n", MAX_NPES); - shmem_global_exit(1); - } - - TEST_SHMEM_REDUCE(and, uchar, unsigned char); - TEST_SHMEM_REDUCE(and, ushort, unsigned short); - TEST_SHMEM_REDUCE(and, uint, unsigned int); - TEST_SHMEM_REDUCE(and, ulong, unsigned long); - TEST_SHMEM_REDUCE(and, ulonglong, unsigned long long); - TEST_SHMEM_REDUCE(and, int8, int8_t); - TEST_SHMEM_REDUCE(and, int16, int16_t); - TEST_SHMEM_REDUCE(and, int32, int32_t); - TEST_SHMEM_REDUCE(and, int64, int64_t); - TEST_SHMEM_REDUCE(and, uint8, uint8_t); - TEST_SHMEM_REDUCE(and, uint16, uint16_t); - TEST_SHMEM_REDUCE(and, uint32, uint32_t); - TEST_SHMEM_REDUCE(and, uint64, uint64_t); - TEST_SHMEM_REDUCE(and, size, size_t); - - TEST_SHMEM_REDUCE(or, uchar, unsigned char); - TEST_SHMEM_REDUCE(or, ushort, unsigned short); - TEST_SHMEM_REDUCE(or, uint, unsigned int); - TEST_SHMEM_REDUCE(or, ulong, unsigned long); - TEST_SHMEM_REDUCE(or, ulonglong, unsigned long long); - TEST_SHMEM_REDUCE(or, int8, int8_t); - TEST_SHMEM_REDUCE(or, int16, int16_t); - TEST_SHMEM_REDUCE(or, int32, int32_t); - TEST_SHMEM_REDUCE(or, int64, int64_t); - TEST_SHMEM_REDUCE(or, uint8, uint8_t); - TEST_SHMEM_REDUCE(or, uint16, uint16_t); - TEST_SHMEM_REDUCE(or, uint32, uint32_t); - TEST_SHMEM_REDUCE(or, uint64, uint64_t); - TEST_SHMEM_REDUCE(or, size, size_t); - - TEST_SHMEM_REDUCE(xor, uchar, unsigned char); - TEST_SHMEM_REDUCE(xor, ushort, unsigned short); - TEST_SHMEM_REDUCE(xor, uint, unsigned int); - TEST_SHMEM_REDUCE(xor, ulong, unsigned long); - TEST_SHMEM_REDUCE(xor, ulonglong, unsigned long long); - TEST_SHMEM_REDUCE(xor, int8, int8_t); - TEST_SHMEM_REDUCE(xor, int16, int16_t); - TEST_SHMEM_REDUCE(xor, int32, int32_t); - TEST_SHMEM_REDUCE(xor, int64, int64_t); - TEST_SHMEM_REDUCE(xor, uint8, uint8_t); - TEST_SHMEM_REDUCE(xor, uint16, uint16_t); - TEST_SHMEM_REDUCE(xor, uint32, uint32_t); - TEST_SHMEM_REDUCE(xor, uint64, uint64_t); - TEST_SHMEM_REDUCE(xor, size, size_t); - - TEST_SHMEM_REDUCE(max, char, char); - TEST_SHMEM_REDUCE(max, schar, signed char); - TEST_SHMEM_REDUCE(max, short, short); - TEST_SHMEM_REDUCE(max, int, int); - TEST_SHMEM_REDUCE(max, long, long); - TEST_SHMEM_REDUCE(max, longlong, long long); - TEST_SHMEM_REDUCE(max, ptrdiff, ptrdiff_t); - TEST_SHMEM_REDUCE(max, uchar, unsigned char); - TEST_SHMEM_REDUCE(max, ushort, unsigned short); - TEST_SHMEM_REDUCE(max, uint, unsigned int); - TEST_SHMEM_REDUCE(max, ulong, unsigned long); - TEST_SHMEM_REDUCE(max, ulonglong, unsigned long long); - TEST_SHMEM_REDUCE(max, int8, int8_t); - TEST_SHMEM_REDUCE(max, int16, int16_t); - TEST_SHMEM_REDUCE(max, int32, int32_t); - TEST_SHMEM_REDUCE(max, int64, int64_t); - TEST_SHMEM_REDUCE(max, uint8, uint8_t); - TEST_SHMEM_REDUCE(max, uint16, uint16_t); - TEST_SHMEM_REDUCE(max, uint32, uint32_t); - TEST_SHMEM_REDUCE(max, uint64, uint64_t); - TEST_SHMEM_REDUCE(max, size, size_t); - TEST_SHMEM_REDUCE(max, float, float); - TEST_SHMEM_REDUCE(max, double, double); - TEST_SHMEM_REDUCE(max, longdouble, long double); - - TEST_SHMEM_REDUCE(min, char, char); - TEST_SHMEM_REDUCE(min, schar, signed char); - TEST_SHMEM_REDUCE(min, short, short); - TEST_SHMEM_REDUCE(min, int, int); - TEST_SHMEM_REDUCE(min, long, long); - TEST_SHMEM_REDUCE(min, longlong, long long); - TEST_SHMEM_REDUCE(min, ptrdiff, ptrdiff_t); - TEST_SHMEM_REDUCE(min, uchar, unsigned char); - TEST_SHMEM_REDUCE(min, ushort, unsigned short); - TEST_SHMEM_REDUCE(min, uint, unsigned int); - TEST_SHMEM_REDUCE(min, ulong, unsigned long); - TEST_SHMEM_REDUCE(min, ulonglong, unsigned long long); - TEST_SHMEM_REDUCE(min, int8, int8_t); - TEST_SHMEM_REDUCE(min, int16, int16_t); - TEST_SHMEM_REDUCE(min, int32, int32_t); - TEST_SHMEM_REDUCE(min, int64, int64_t); - TEST_SHMEM_REDUCE(min, uint8, uint8_t); - TEST_SHMEM_REDUCE(min, uint16, uint16_t); - TEST_SHMEM_REDUCE(min, uint32, uint32_t); - TEST_SHMEM_REDUCE(min, uint64, uint64_t); - TEST_SHMEM_REDUCE(min, size, size_t); - TEST_SHMEM_REDUCE(min, float, float); - TEST_SHMEM_REDUCE(min, double, double); - TEST_SHMEM_REDUCE(min, longdouble, long double); - - TEST_SHMEM_REDUCE(sum, char, char); - TEST_SHMEM_REDUCE(sum, schar, signed char); - TEST_SHMEM_REDUCE(sum, short, short); - TEST_SHMEM_REDUCE(sum, int, int); - TEST_SHMEM_REDUCE(sum, long, long); - TEST_SHMEM_REDUCE(sum, longlong, long long); - TEST_SHMEM_REDUCE(sum, ptrdiff, ptrdiff_t); - TEST_SHMEM_REDUCE(sum, uchar, unsigned char); - TEST_SHMEM_REDUCE(sum, ushort, unsigned short); - TEST_SHMEM_REDUCE(sum, uint, unsigned int); - TEST_SHMEM_REDUCE(sum, ulong, unsigned long); - TEST_SHMEM_REDUCE(sum, ulonglong, unsigned long long); - TEST_SHMEM_REDUCE(sum, int8, int8_t); - TEST_SHMEM_REDUCE(sum, int16, int16_t); - TEST_SHMEM_REDUCE(sum, int32, int32_t); - TEST_SHMEM_REDUCE(sum, int64, int64_t); - TEST_SHMEM_REDUCE(sum, uint8, uint8_t); - TEST_SHMEM_REDUCE(sum, uint16, uint16_t); - TEST_SHMEM_REDUCE(sum, uint32, uint32_t); - TEST_SHMEM_REDUCE(sum, uint64, uint64_t); - TEST_SHMEM_REDUCE(sum, size, size_t); - TEST_SHMEM_REDUCE(sum, float, float); - TEST_SHMEM_REDUCE(sum, double, double); - TEST_SHMEM_REDUCE(sum, longdouble, long double); - TEST_SHMEM_REDUCE(sum, complexd, double _Complex); - TEST_SHMEM_REDUCE(sum, complexf, float _Complex); - - TEST_SHMEM_REDUCE(prod, char, char); - TEST_SHMEM_REDUCE(prod, schar, signed char); - TEST_SHMEM_REDUCE(prod, short, short); - TEST_SHMEM_REDUCE(prod, int, int); - TEST_SHMEM_REDUCE(prod, long, long); - TEST_SHMEM_REDUCE(prod, longlong, long long); - TEST_SHMEM_REDUCE(prod, ptrdiff, ptrdiff_t); - TEST_SHMEM_REDUCE(prod, uchar, unsigned char); - TEST_SHMEM_REDUCE(prod, ushort, unsigned short); - TEST_SHMEM_REDUCE(prod, uint, unsigned int); - TEST_SHMEM_REDUCE(prod, ulong, unsigned long); - TEST_SHMEM_REDUCE(prod, ulonglong, unsigned long long); - TEST_SHMEM_REDUCE(prod, int8, int8_t); - TEST_SHMEM_REDUCE(prod, int16, int16_t); - TEST_SHMEM_REDUCE(prod, int32, int32_t); - TEST_SHMEM_REDUCE(prod, int64, int64_t); - TEST_SHMEM_REDUCE(prod, uint8, uint8_t); - TEST_SHMEM_REDUCE(prod, uint16, uint16_t); - TEST_SHMEM_REDUCE(prod, uint32, uint32_t); - TEST_SHMEM_REDUCE(prod, uint64, uint64_t); - TEST_SHMEM_REDUCE(prod, size, size_t); - TEST_SHMEM_REDUCE(prod, float, float); - TEST_SHMEM_REDUCE(prod, double, double); - TEST_SHMEM_REDUCE(prod, longdouble, long double); - TEST_SHMEM_REDUCE(prod, complexd, double _Complex); - TEST_SHMEM_REDUCE(prod, complexf, float _Complex); - - shmem_finalize(); - return rc; -} diff --git a/test/unit/shmem_team_reuse_teams.c b/test/unit/shmem_team_reuse_teams.c deleted file mode 100644 index d157e3294..000000000 --- a/test/unit/shmem_team_reuse_teams.c +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2019 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include - -int main(void) -{ - int i, me, npes; - int ret = 0, errors = 0; - - shmem_init(); - - me = shmem_my_pe(); - npes = shmem_n_pes(); - - if (me == 0) - printf("Reuse teams test\n"); - - shmem_team_t old_team, new_team; - ret = shmem_team_split_strided(SHMEM_TEAM_WORLD, 0, 1, npes, NULL, 0, &old_team); - if (ret) ++errors; - - /* A total of npes-1 iterations are performed, where the active set in iteration i - * includes PEs i..npes-1. The size of the team decreases by 1 each iteration. */ - for (i = 1; i < npes; i++) { - - if (me == i) { - printf("%3d: creating new team (start, stride, size): %3d, %3d, %3d\n", me, - shmem_team_translate_pe(old_team, 1, SHMEM_TEAM_WORLD), 1, shmem_team_n_pes(old_team)-1); - } - - ret = shmem_team_split_strided(old_team, 1, 1, shmem_team_n_pes(old_team)-1, NULL, 0, &new_team); - if (old_team != SHMEM_TEAM_INVALID && ret) ++errors; - - shmem_team_destroy(old_team); - old_team = new_team; - } - - shmem_team_destroy(old_team); - shmem_finalize(); - - return errors != 0; -} diff --git a/test/unit/shmem_team_shared.c b/test/unit/shmem_team_shared.c deleted file mode 100644 index 62e151306..000000000 --- a/test/unit/shmem_team_shared.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2019 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include - - -int main(void) -{ - static long lock = 0; - - shmem_init(); - int me = shmem_my_pe(); - int npes = shmem_n_pes(); - - int team_shared_npes = shmem_team_n_pes(SHMEM_TEAM_SHARED); - - int *peers = malloc(team_shared_npes * sizeof(int)); - int num_peers = 0; - - /* Print the team members on SHMEM_TEAM_SHARED */ - /* Use a lock for cleaner output */ - shmem_set_lock(&lock); - - printf("[PE: %d] SHMEM_TEAM_SHARED peers: { ", me); - for (int i = 0; i < npes; i++) { - if (shmem_team_translate_pe(SHMEM_TEAM_WORLD, i, - SHMEM_TEAM_SHARED) != -1) { - peers[num_peers++] = i; - printf("%d ", i); - } - } - - printf("} (num_peers: %d)\n", num_peers); - - fflush(NULL); - - shmem_clear_lock(&lock); - - if (num_peers != team_shared_npes) { - shmem_global_exit(1); - } - - free(peers); - shmem_finalize(); - return 0; -} - diff --git a/test/unit/shmem_team_split_2d.c b/test/unit/shmem_team_split_2d.c deleted file mode 100644 index 0210d4dfd..000000000 --- a/test/unit/shmem_team_split_2d.c +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (c) 2019 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include - -static int check_2d(shmem_team_t parent_team, int xdim) { - int me = shmem_team_my_pe(parent_team); - - shmem_team_t xteam = SHMEM_TEAM_INVALID; - shmem_team_t yteam = SHMEM_TEAM_INVALID; - - int ret = shmem_team_split_2d(parent_team, xdim, NULL, 0, &xteam, NULL, 0, &yteam); - int errors = 0; - - if (ret == 0) { - int me_x = shmem_team_my_pe(xteam); - int me_y = shmem_team_my_pe(yteam); - int npes_x = shmem_team_n_pes(xteam); - int npes_y = shmem_team_n_pes(yteam); - - if (xteam == SHMEM_TEAM_INVALID || yteam == SHMEM_TEAM_INVALID) { - printf("%d: Error, received an invalid team\n", shmem_my_pe()); - ++errors; - } - - /* Try converting the PE ids from xteam and yteam to parent and global - * PE indices and compare with the expected indices */ - for (int i = 0; i < npes_x; i++) { - int expected_parent = me_y * xdim + i; /* row (fixed) + column */ - int pe_parent = shmem_team_translate_pe(xteam, i, parent_team); - int pe_world = shmem_team_translate_pe(xteam, i, SHMEM_TEAM_WORLD); - int expected_world = shmem_team_translate_pe(parent_team, expected_parent, SHMEM_TEAM_WORLD); - - if (expected_parent != pe_parent) { - printf("%d: xteam[%d] expected parent PE id %d, got %d\n", - me, i, expected_parent, pe_parent); - errors++; - } - - if (expected_world != pe_world) { - printf("%d: xteam[%d] expected world PE id %d, got %d\n", - me, i, expected_world, pe_world); - errors++; - } - } - - for (int i = 0; i < npes_y; i++) { - int expected_parent = i * xdim + me_x; /* row + column (fixed) */ - int pe_parent = shmem_team_translate_pe(yteam, i, parent_team); - int pe_world = shmem_team_translate_pe(yteam, i, SHMEM_TEAM_WORLD); - int expected_world = shmem_team_translate_pe(parent_team, expected_parent, SHMEM_TEAM_WORLD); - - if (expected_parent != pe_parent) { - printf("%d: yteam[%d] expected parent PE id %d, got %d\n", - me, i, expected_parent, pe_parent); - errors++; - } - - if (expected_world != pe_world) { - printf("%d: yteam[%d] expected world PE id %d, got %d\n", - me, i, expected_world, pe_world); - errors++; - } - } - } - else { - printf("%d: 2d split failed\n", shmem_my_pe()); - } - - if (xteam != SHMEM_TEAM_INVALID) - shmem_team_destroy(xteam); - if (yteam != SHMEM_TEAM_INVALID) - shmem_team_destroy(yteam); - - return errors != 0; -} - -int main(void) { - int errors = 0, me, npes, ret; - shmem_team_t even_team; - - shmem_init(); - - me = shmem_my_pe(); - npes = shmem_n_pes(); - - if (me == 0) printf("Performing 2d split test on SHMEM_TEAM_WORLD\n"); - - errors += check_2d(SHMEM_TEAM_WORLD, 1); - errors += check_2d(SHMEM_TEAM_WORLD, 2); - errors += check_2d(SHMEM_TEAM_WORLD, 3); - - ret = shmem_team_split_strided(SHMEM_TEAM_WORLD, 0, 2, (npes-1)/2 + 1, - NULL, 0, &even_team); - - if (ret == 0) { - if (me == 0) printf("Performing 2d split test on even team\n"); - - errors += check_2d(even_team, 1); - errors += check_2d(even_team, 2); - errors += check_2d(even_team, 3); - } else { - if (me == 0) printf("Unable to create even team\n"); - } - - shmem_finalize(); - return errors != 0; -} diff --git a/test/unit/shmem_team_translate.c b/test/unit/shmem_team_translate.c deleted file mode 100644 index da70e99d5..000000000 --- a/test/unit/shmem_team_translate.c +++ /dev/null @@ -1,61 +0,0 @@ -/* - * OpenSHMEM shmem_team_translate example to verify the team formed by even - * ranked PEs from SHMEM_TEAM_WORLD using the team created from - * shmem_team_split_stride operation - */ - -#include -#include - -int main(void) -{ - int my_pe, npes, errors = 0; - int t_pe_2, t_pe_3, t_pe_2_to_3, t_pe_3_to_2; - shmem_team_t team_2s; - shmem_team_t team_3s; - shmem_team_config_t *config; - - shmem_init(); - config = NULL; - my_pe = shmem_my_pe(); - npes = shmem_n_pes(); - - shmem_team_split_strided(SHMEM_TEAM_WORLD, 0, 2, ((npes-1)/2)+1, config, 0, - &team_2s); - shmem_team_split_strided(SHMEM_TEAM_WORLD, 0, 3, ((npes-1)/3)+1, config, 0, - &team_3s); - - t_pe_3 = shmem_team_my_pe(team_3s); - t_pe_2 = shmem_team_my_pe(team_2s); - t_pe_3_to_2 = shmem_team_translate_pe(team_3s, t_pe_3, team_2s); - t_pe_2_to_3 = shmem_team_translate_pe(team_2s, t_pe_2, team_3s); - - if (my_pe % 2 == 0 && my_pe % 3 == 0) { - if (t_pe_2 == -1 || t_pe_3 == -1 || t_pe_2_to_3 == -1 || t_pe_3_to_2 == -1) { - printf("ERROR: PE %d, t_pe_2=%d, t_pe_3=%d, t_pe_3_to_2=%d, t_pe_2_to_3=%d\n", - my_pe, t_pe_2, t_pe_3, t_pe_3_to_2, t_pe_2_to_3); - ++errors; - } - } else if (my_pe % 2 == 0) { - if (t_pe_2 == -1 || t_pe_3 != -1 || t_pe_2_to_3 != -1 || t_pe_3_to_2 != -1) { - printf("ERROR: PE %d, t_pe_2=%d, t_pe_3=%d, t_pe_3_to_2=%d, t_pe_2_to_3=%d\n", - my_pe, t_pe_2, t_pe_3, t_pe_3_to_2, t_pe_2_to_3); - ++errors; - } - } else if (my_pe % 3 == 0){ - if (t_pe_2 != -1 || t_pe_3 == -1 || t_pe_2_to_3 != -1 || t_pe_3_to_2 != -1) { - printf("ERROR: PE %d, t_pe_2=%d, t_pe_3=%d, t_pe_3_to_2=%d, t_pe_2_to_3=%d\n", - my_pe, t_pe_2, t_pe_3, t_pe_3_to_2, t_pe_2_to_3); - ++errors; - } - } else { - if (t_pe_2 != -1 || t_pe_3 != -1 || t_pe_2_to_3 != -1 || t_pe_3_to_2 != -1) { - printf("ERROR: PE %d, t_pe_2=%d, t_pe_3=%d, t_pe_3_to_2=%d, t_pe_2_to_3=%d\n", - my_pe, t_pe_2, t_pe_3, t_pe_3_to_2, t_pe_2_to_3); - ++errors; - } - } - - shmem_finalize(); - return errors != 0; -} diff --git a/test/unit/shmem_test.c b/test/unit/shmem_test.c deleted file mode 100644 index 1831e401c..000000000 --- a/test/unit/shmem_test.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -/* Each PE sends a message to every PE. PEs wait for all messages to - * arrive using shmem_test to poll the array. */ - -#include -#include - -/* Wait for any entry in the given ivar array to match the wait criteria and - * return the index of the entry that satisfied the test. */ -static int wait_any(long *ivar, int count, int cmp, long value) -{ - int idx = 0; - while (!shmem_long_test(&ivar[idx], cmp, value)) - idx = (idx + 1) % count; - return idx; -} - -int main(void) -{ - shmem_init(); - const int mype = shmem_my_pe(); - const int npes = shmem_n_pes(); - - long *wait_vars = shmem_calloc(npes, sizeof(long)); - - /* Put mype+1 to every PE */ - for (int i = 0; i < npes; i++) - shmem_long_p(&wait_vars[mype], mype+1, i); - - int nrecv = 0, errors = 0; - - /* Wait for all messages to arrive */ - while (nrecv < npes) { - int who = wait_any(wait_vars, npes, SHMEM_CMP_NE, 0); - if (wait_vars[who] != who+1) { - printf("%d: wait_vars[%d] = %ld, expected %d\n", - mype, who, wait_vars[who], who+1); - errors++; - } - wait_vars[who] = 0; - nrecv++; - } - - shmem_free(wait_vars); - shmem_finalize(); - return errors; -} diff --git a/test/unit/shmemalign.c b/test/unit/shmemalign.c deleted file mode 100644 index 30285be58..000000000 --- a/test/unit/shmemalign.c +++ /dev/null @@ -1,186 +0,0 @@ -/* :vim:sw=4:ts=4: */ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - * usage: shmemalign [-v] - * where: -v == Verbose display - */ - -#include -#include -#include -#include -#include - -#include - -#define DFLT_NWORDS 257 -#define DFLT_INCR 31 -#define DFLT_LOOPS 1 - -#define DataType long - -static DataType *target; -static int target_sz; - -static char *pgm; -static int Verbose = 0; - -void usage (void); -int getSize (char *); - -void -usage (void) -{ - if (shmem_my_pe() == 0 ) { - fprintf (stderr, - "Usage: %s [-p] [nWords(%d)] [loops(%d)] [incWords(%d)]\n", - pgm, DFLT_NWORDS, DFLT_LOOPS, DFLT_INCR); - fprintf (stderr, - " -v == Verbose output\n" - " [nWords] # of longs to shmem_malloc()\n" - " [loops] # of loops\n" - " [incWords] nWords += incWords per loop\n"); - } - exit (1); -} - -int -getSize (char *str) -{ - int size; - char mod[32]; - - switch (sscanf (str, "%d%1[mMkK]", &size, mod)) - { - case 1: - return (size); - - case 2: - switch (*mod) - { - case 'm': - case 'M': - return (size << 20); - - case 'k': - case 'K': - return (size << 10); - - default: - return (size); - } - - default: - return (-1); - } -} - -int -main(int argc, char **argv) -{ - int me, c, l, j; - int nWords, loops, incWords; - - pgm = strrchr(argv[0],'/'); - if ( pgm ) - pgm++; - else - pgm = argv[0]; - - shmem_init(); - me = shmem_my_pe(); - - while ((c = getopt (argc, argv, "hpv")) != -1) - switch (c) - { - case 'v': - Verbose++; - break; - case 'h': - default: - usage(); - break; - } - - if (optind == argc) - nWords = DFLT_NWORDS; - else if ((nWords = getSize (argv[optind++])) <= 0) - usage (); - - if (optind == argc) - loops = DFLT_LOOPS; - else if ((loops = getSize (argv[optind++])) < 0) - usage (); - - if (optind == argc) - incWords = DFLT_INCR; - else if ((incWords = getSize (argv[optind++])) < 0) - usage (); - - if (Verbose && me == 0) - fprintf (stderr, "nWords(%d) loops(%d) incWords(%d)]\n", - nWords, loops, incWords); - - for(l=0; l < loops; l++) - { - /* align 2**2 ... 2**23; 24 exceeds symetric heap max */ - for(j=0,c=2; j < 23; j++,c<<=1) - { - target_sz = nWords * sizeof(DataType); - if (!(target = (DataType *)shmem_align(c,target_sz))) { - perror ("Failed target memory allocation"); - exit (1); - } - - if ( (unsigned long)target & (c-1) ) { - fprintf(stdout,"PE%d Unaligned? ",me); - fflush(stdout); - fprintf(stdout,"align[%#09x]target %p\n", - c, (void*)target); - shmem_global_exit(1); - } - else if (Verbose > 1 && me == 0) - fprintf(stdout,"align[%#09x]target %p\n", - c, (void*)target); - shmem_barrier_all(); - shmem_free(target); - } - nWords += incWords; - if (Verbose && me == 0) - fprintf(stdout,"Fini loop %d\n",(l+1)); - } - - shmem_finalize(); - - return 0; -} diff --git a/test/unit/shrealloc.c b/test/unit/shrealloc.c deleted file mode 100644 index 9a273dca5..000000000 --- a/test/unit/shrealloc.c +++ /dev/null @@ -1,284 +0,0 @@ -/* :vim:sw=4:ts=4:expandtab: */ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - * usage: shrealloc [-p] [nWords] [loops] [incWords-per-loop] - * where: -p == power-of-two allocation size bump per loop - * [nWords] # of longs to shmem_realloc()\n" - * [loops(1)] # of loops\n" - * [incWords(2)] nWords += incWords per loop\n"); - * Loop: - * PE* shmem_realloc(nWords) - * set *DataType = 1 - * PE* shmem_realloc(nWords) - * set *DataType = 2 - * PE* shmem_realloc(nWords) - * set *DataType = 3 - * - * for(1...3) allocated ranges - * verify - * end-loop - * shmem_free(3 allocations) - */ - -#include -#include -#include -#include -#include - -#include - -#define DFLT_NWORDS 32 -#define DFLT_INCR 1025 -#define DFLT_LOOPS 50 -#define DFLT_PLOOPS 21 // reduced to stay under shmem_malloc() stack limit. - -#define DataType int - -static DataType *source; -static DataType *target; -static DataType *result; - -static int source_sz; -static int target_sz; -static int result_sz; - -static int prev_source_idx = 0; -static int prev_target_idx = 0; -static int prev_result_idx = 0; - -static char *pgm; - -void usage (void); -int getSize (char *); - -void -usage (void) -{ - if (shmem_my_pe() == 0 ) { - fprintf (stderr, - "Usage: %s [-p] [nWords(%d)] [loops(%d)] [incWords(%d)]\n", - pgm, DFLT_NWORDS, DFLT_LOOPS, DFLT_INCR); - fprintf (stderr, - " -p == (2**0 ... 2**22) shmem_realloc(), other args ignored\n" - " -v == verbose output\n" - " [nWords] # of longs to shmem_realloc()\n" - " [loops] # of loops\n" - " [incWords] nWords += incWords per loop\n"); - } - exit (1); -} - -int -getSize (char *str) -{ - int size; - char mod[32]; - - switch (sscanf (str, "%d%1[mMkK]", &size, mod)) - { - case 1: - return (size); - - case 2: - switch (*mod) - { - case 'm': - case 'M': - return (size << 20); - - case 'k': - case 'K': - return (size << 10); - - default: - return (size); - } - - default: - return (-1); - } -} - -int -main(int argc, char **argv) -{ - int me, nProcs, c, l; - int nWords, loops, incWords; - int Verbose = 0, power2 = 0, modulo = 5; - DataType *dp; - - pgm = strrchr(argv[0],'/'); - if ( pgm ) - pgm++; - else - pgm = argv[0]; - - shmem_init(); - me = shmem_my_pe(); - nProcs = shmem_n_pes(); - - if (nProcs <= 1) { - fprintf(stderr, "ERR - Requires > 1 PEs\n"); - shmem_finalize(); - return 0; - } - - while ((c = getopt (argc, argv, "hpv")) != -1) - switch (c) - { - case 'p': - power2++; - break; - case 'v': - Verbose++; - break; - case 'h': - default: - usage(); - break; - } - - if (optind == argc) - nWords = DFLT_NWORDS; - else if ((nWords = getSize (argv[optind++])) <= 0) - usage (); - - if (optind == argc) - loops = DFLT_LOOPS; - else if ((loops = getSize (argv[optind++])) < 0) - usage (); - - if (optind == argc) - incWords = DFLT_INCR; - else if ((incWords = getSize (argv[optind++])) < 0) - usage (); - - if (power2) { - nWords = 1; - modulo = 1; - loops = DFLT_PLOOPS; - } - - if (Verbose && me == 0) { - if (power2) { - printf("%s: nWords(1) << 1 per loop(%d).\n", pgm, DFLT_PLOOPS); - } - else - printf("%s: nWords(%d) loops(%d) nWords-incr-per-loop(%d)\n", - pgm, nWords, loops, incWords); - } - - for(l=0; l < loops; l++) - { - result_sz = (nProcs-1) * (nWords * sizeof(DataType)); - result = (DataType *)shmem_realloc(result,result_sz); - if (! result) - { - perror ("Failed result memory allocation"); - exit (1); - } - if (prev_result_idx == 0) - for(dp=result; dp < &result[(result_sz/sizeof(DataType))];) - *dp++ = 1; - else - for(dp=&result[prev_result_idx]; - dp < &result[(result_sz/sizeof(DataType))];) *dp++ = 1; - prev_result_idx = result_sz / sizeof(DataType); - - target_sz = nWords * sizeof(DataType); - if (!(target = (DataType *)shmem_realloc(target,target_sz))) - { - perror ("Failed target memory allocation"); - exit (1); - } - if (prev_target_idx == 0) - for(dp=target; dp < &target[(target_sz / sizeof(DataType))];) - *dp++ = 2; - else - for(dp=&target[prev_target_idx]; - dp < &target[(target_sz/sizeof(DataType))];) *dp++ = 2; - prev_target_idx = target_sz / sizeof(DataType); - - source_sz = 2 * nWords * sizeof(DataType); - if (!(source = (DataType *)shmem_realloc(source,source_sz))) - { - perror ("Failed source memory allocation"); - exit (1); - } - if (prev_source_idx == 0) - for(dp=source; dp < &source[(source_sz / sizeof(DataType))];) - *dp++ = 3; - else - for(dp=&source[prev_source_idx]; - dp < &source[(source_sz/sizeof(DataType))];) *dp++ = 3; - prev_source_idx = source_sz / sizeof(DataType); - - for(dp=source; dp < &source[(source_sz / sizeof(DataType))]; dp++) - if (*dp != 3 ) { - printf("source not consistent @ 3?\n"); - break; - } - - for(dp=target; dp < &target[(target_sz / sizeof(DataType))]; dp++) - if (*dp != 2 ) { - printf("target not consistent @ 2?\n"); - break; - } - - for(dp=result; dp < &result[(result_sz / sizeof(DataType))]; dp++) - if (*dp != 1 ) { - printf("result not consistent @ 1?\n"); - break; - } - - if (loops > 1) { - if (Verbose && me == 0) { - if (l == 0 || (l % modulo == 0)) - printf("End loop %3d nWords(%d)\n",(l+1),nWords); - } - if (power2) - nWords <<= 1; - else - nWords += incWords; // watch for double inc. - } - } - - shmem_free(source); - shmem_free(target); - shmem_free(result); - - shmem_finalize(); - - return 0; -} diff --git a/test/unit/signal_fetch.c b/test/unit/signal_fetch.c deleted file mode 100644 index 50d76e9ae..000000000 --- a/test/unit/signal_fetch.c +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2020 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - * Validate signal_fetch operation using blocking put_signal -*/ - -#include -#include -#include - -#define MSG_SZ 10 - -int main(int argc, char *argv[]) -{ - long source[MSG_SZ]; - long *target; - int me, npes, i; - int errors = 0; - - static uint64_t sig_addr = 0; - - shmem_init(); - - me = shmem_my_pe(); - npes = shmem_n_pes(); - - for (i = 0; i < MSG_SZ; i++) - source[i] = i; - - target = (long *) shmem_calloc(MSG_SZ, sizeof(long)); - if (!target) { - fprintf(stderr, "Failed to allocate target pointer\n"); - shmem_global_exit(1); - } - - shmem_barrier_all(); - for (i = 0; i < npes; i++) { - shmem_long_put_signal(target, source, MSG_SZ, &sig_addr, me, SHMEM_SIGNAL_ADD, i); - } - - uint64_t sig_value = shmem_signal_fetch(&sig_addr); - while (sig_value != (uint64_t) ((npes * (npes - 1)) / 2)) { -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L - shmem_wait_until(&sig_addr, SHMEM_CMP_NE, 0); -#else - shmem_uint64_wait_until(&sig_addr, SHMEM_CMP_NE, 0); -#endif - sig_value = shmem_signal_fetch(&sig_addr); - } - - for (i = 0; i < MSG_SZ; i++) { - if (target[i] != source[i]) { - fprintf(stderr, "%10d: target[%d] = %ld not matching %ld with SHMEM_SIGNAL_ADD\n", - me, i, target[i], source[i]); - errors++; - } - } - - shmem_free(target); - shmem_finalize(); - - return errors; -} diff --git a/test/unit/signal_wait_until.c b/test/unit/signal_wait_until.c deleted file mode 100644 index 8fee385d5..000000000 --- a/test/unit/signal_wait_until.c +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (c) 2021 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - * Validate signal_wait_until operation using blocking put_signal -*/ - -#include -#include -#include - -#define MSG_SZ 10 - -int main(int argc, char *argv[]) -{ - long source[MSG_SZ]; - long *target; - int me, npes, i; - int errors = 0; - - static uint64_t sig_addr = 0; - - shmem_init(); - - me = shmem_my_pe(); - npes = shmem_n_pes(); - - for (i = 0; i < MSG_SZ; i++) - source[i] = i; - - target = (long *) shmem_calloc(MSG_SZ, sizeof(long)); - if (!target) { - fprintf(stderr, "Failed to allocate target pointer\n"); - shmem_global_exit(1); - } - - shmem_barrier_all(); - - for (i = 0; i < npes; i++) { - shmem_long_put_signal(target, source, MSG_SZ, &sig_addr, 1, SHMEM_SIGNAL_ADD, i); - } - - uint64_t retval = shmem_signal_wait_until(&sig_addr, SHMEM_CMP_LE, npes); - - if (retval > (uint64_t) npes) - errors++; - - retval = shmem_signal_wait_until(&sig_addr, SHMEM_CMP_EQ, npes); - if (retval != (uint64_t) npes) - errors++; - - retval = shmem_signal_wait_until(&sig_addr, SHMEM_CMP_LT, npes + 1); - if (retval != (uint64_t) npes) - errors++; - - for (i = 0; i < MSG_SZ; i++) { - if (target[i] != source[i]) { - fprintf(stderr, "%10d: target[%d] = %ld not matching %ld with SHMEM_SIGNAL_ADD\n", - me, i, target[i], source[i]); - errors++; - } - } - - for (i = 0; i < MSG_SZ; i++) - target[i] = 0; - - shmem_barrier_all(); - - for (i = 0; i < npes; i++) { - shmem_long_put_signal(target, source, MSG_SZ, &sig_addr, npes + 1, SHMEM_SIGNAL_SET, i); - } - - retval = shmem_signal_wait_until(&sig_addr, SHMEM_CMP_GE, npes); - if (retval < (uint64_t) npes) - errors++; - - retval = shmem_signal_wait_until(&sig_addr, SHMEM_CMP_EQ, npes + 1); - if (retval != (uint64_t) npes + 1) - errors++; - - shmem_barrier_all(); - - for (i = 0; i < MSG_SZ; i++) { - if (target[i] != source[i]) { - fprintf(stderr, "%10d: target[%d] = %ld not matching %ld with SHMEM_SIGNAL_SET\n", - me, i, target[i], source[i]); - errors++; - } - } - - shmem_free(target); - shmem_finalize(); - - return errors; -} diff --git a/test/unit/spam.c b/test/unit/spam.c deleted file mode 100644 index 0cc8a72af..000000000 --- a/test/unit/spam.c +++ /dev/null @@ -1,561 +0,0 @@ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* spam - shmem performance amalgamation - * - * one2many - timed loops of [PE-0 put 2048 bytes to 1..(npes-1) PEs - * many2one - timed loops of [PE-0 get 2048 bytes to 1..(npes-1) PEs - * all2all_get - timed loops of get 2048 bytes all-2-all. - * all2all_put - timed loops of put 2048 bytes all-2-all. - * neighbor_put - timed loops of put 2048 bytes to next neighbor. - * neighbor_get - timed loops of get 2048 bytes to next neighbor. - * bcast - timed loops of broadcast 2048 bytes to all. - * collect - timed loops of collect 2048 bytes from all PEs to 0. - * fcollect - timed loops of fcollect 2048 bytes from all PEs to 0. - */ - -#include -#include -#include -#include -#include -#include - -#include -#include "tests_sos/wtime.h" - -void one2many_put(int *dst, int *src, int Elems, int me, int npe, int laps); -void many2one_get(int *dst, int *src, int Elems, int me, int npe, int laps); -void all2all_get(int *dst, int *src, int Elems, int me, int npes, int laps); -void all2all_put(int *dst, int *src, int Elems, int me, int npes, int laps); -void neighbor_put(int *dst, int *src, int Elems, int me, int npes, int laps); -void neighbor_get(int *dst, int *src, int Elems, int me, int npes, int laps); -void bcast(int *dst, int *src, int Elems, int me, int npes, int laps); -void collect(int *dst, int *src, int Elems, int me, int npes, int laps); -void fcollect(int *dst, int *src, int Elems, int me, int npes, int laps); - -static int atoi_scaled(char *s); -static void usage(char *pgm); - -int Verbose=1; -int All2=0; -int Bcast=0; -int Collect=0; -int Many=0; -int Neighbor=0; - -#define DFLT_LOOPS 20000 - -#define N_ELEMENTS 512 /* # ints */ - -int -main(int argc, char **argv) -{ - int i; - int *target; - int *source; - int me, npes, elements=N_ELEMENTS, loops=DFLT_LOOPS; - char *pgm; - - shmem_init(); - me = shmem_my_pe(); - npes = shmem_n_pes(); - - if ((pgm=strrchr(argv[0],'/'))) - pgm++; - else - pgm = argv[0]; - - /* lower-case switch enable only a specific test; otherwise run all tests */ - while ((i = getopt (argc, argv, "hvqe:l:abcmn")) != EOF) { - switch (i) - { - case 'a': - All2++; - break; - case 'b': - Bcast++; - break; - case 'c': - Collect++; - break; - case 'm': - Many++; - break; - case 'n': - Neighbor++; - break; - case 'q': - Verbose=0; - break; - case 'v': - Verbose++; - break; - case 'e': - if ((elements = atoi_scaled(optarg)) <= 0) { - fprintf(stderr,"ERR: Bad elements count %d\n",elements); - shmem_finalize(); - return 1; - } - break; - case 'l': - if ((loops = atoi_scaled(optarg)) <= 0) { - fprintf(stderr,"ERR: Bad loop count %d\n",loops); - shmem_finalize(); - return 1; - } - break; - case 'h': - if (me == 0) - usage(pgm); - shmem_finalize(); - return 0; - default: - if (me == 0) { - fprintf(stderr,"%s: unknown switch '-%c'?\n",pgm,i); - usage(pgm); - } - shmem_finalize(); - return 1; - } - } - - if (All2==0 && Bcast==0 && Collect==0 && Many==0 && Neighbor==0) - All2 = Bcast = Collect = Many = Neighbor = 1; - - source = (int *) shmem_malloc( elements * sizeof(*source) ); - target = (int *) shmem_malloc( elements * sizeof(*target) ); - - for (i = 0; i < elements; i += 1) { - source[i] = i + 1; - target[i] = -90; - } - - shmem_barrier_all(); - - if (Neighbor) { - neighbor_put( target, source, elements, me, npes, loops ); - neighbor_get( target, source, elements, me, npes, loops ); - } - - if (All2) { - all2all_put( target, source, elements, me, npes, loops ); - all2all_get( target, source, elements, me, npes, loops ); - } - - if (Many) { - one2many_put( target, source, elements, me, npes, loops ); - many2one_get( target, source, elements, me, npes, loops ); - } - - if (Bcast) bcast( target, source, elements, me, npes, loops ); - - if (Collect) { - collect( NULL, source, elements, me, npes, loops ); - fcollect( NULL, source, elements, me, npes, loops ); - } - - shmem_barrier_all(); - - shmem_free(target); - shmem_free(source); - - shmem_finalize(); - - return 0; -} - -void -one2many_put(int *target, int *src, int elements, int me, int npes, int loops) -{ - int i, pe; - double start_time, elapsed_time; - long total_bytes = loops * elements * sizeof(*src) * (npes - 1); - - if (me == 0) { - fprintf(stdout,"%s: %d loops of put(%ld bytes) to %d PEs: ", - __FUNCTION__, loops, (elements*sizeof(*src)), npes-1); - fflush(stdout); - } - shmem_barrier_all(); - - if (me == 0) { - start_time = tests_sos_wtime(); - for(i = 0; i < loops; i++) { - for(pe = 1; pe < npes; pe++) - shmem_int_put(target, src, elements, pe); - } - elapsed_time = tests_sos_wtime() - start_time; - - if (Verbose) { - printf("%7.3f secs\n", elapsed_time); - printf(" %7.5f usecs / put(), %ld Kbytes @ %7.4f MB/sec\n\n", - (elapsed_time/((double)loops*(npes-1)))*1000000.0, - (total_bytes/1024), - ((double)total_bytes/(1024.0*1024.0)) / elapsed_time ); - } - } - shmem_barrier_all(); -} - -void -many2one_get(int *target, int *src, int elements, int me, int npes, int loops) -{ - int i, pe; - double start_time, elapsed_time; - long total_bytes = loops * elements * sizeof(*src) * (npes - 1); - - if (me == 0) { - fprintf(stdout,"%s: %d loops of get(%ld bytes) from %d PEs: ", - __FUNCTION__, loops, (elements*sizeof(*src)), npes-1); - fflush(stdout); - } - - shmem_barrier_all(); - - if (me == 0) { - start_time = tests_sos_wtime(); - for(i = 0; i < loops; i++) { - for(pe = 1; pe < npes; pe++) - shmem_int_get(target, src, elements, pe); - } - elapsed_time = tests_sos_wtime() - start_time; - - if (Verbose) { - printf("%7.3f secs\n", elapsed_time); - printf(" %7.5f usecs / get(), %ld Kbytes @ %7.4f MB/sec\n\n", - (elapsed_time/((double)loops*(npes-1)))*1000000.0, - (total_bytes/1024), - ((double)total_bytes/(1024.0*1024.0)) / elapsed_time ); - } - } - shmem_barrier_all(); -} - -void -all2all_get(int *target, int *src, int elements, int me, int npes, int loops) -{ - int i, pe; - double start_time, elapsed_time; - long total_bytes = loops * elements * sizeof(*src) * npes; - - if (me==0 && Verbose) { - fprintf(stdout, "%s: %d loops of get(%ld bytes) from all %d PEs: ", - __FUNCTION__, loops, (elements*sizeof(*src)), npes); - fflush(stdout); - } - shmem_barrier_all(); - - start_time = tests_sos_wtime(); - for(i = 0; i < loops; i++) { - for(pe = 0; pe < npes; pe++) - shmem_int_get(target, src, elements, pe); - } - elapsed_time = tests_sos_wtime() - start_time; - - if (me==0 && Verbose) { - printf("%7.3f secs\n", elapsed_time); - printf(" %7.5f usecs / get(), %ld Kbytes @ %7.4f MB/sec\n\n", - (elapsed_time/((double)loops*npes))*1000000.0, - (total_bytes/1024), - ((double)total_bytes/(1024.0*1024.0)) / elapsed_time ); - } - - shmem_barrier_all(); -} - - -void -all2all_put(int *target, int *src, int elements, int me, int npes, int loops) -{ - int i, pe; - double start_time, elapsed_time; - long total_bytes = loops * elements * sizeof(*src) * npes; - - if (me==0 && Verbose) { - fprintf(stdout, "%s: %d loops of put(%ld bytes) to all %d PEs: ", - __FUNCTION__, loops, (elements*sizeof(*src)), npes); - fflush(stdout); - } - - shmem_barrier_all(); - - start_time = tests_sos_wtime(); - for(i = 0; i < loops; i++) { - for(pe = 0; pe < npes; pe++) - shmem_int_put(target, src, elements, pe); - } - elapsed_time = tests_sos_wtime() - start_time; - - if (me==0 && Verbose) { - printf("%7.3f secs\n", elapsed_time); - printf(" %7.5f usecs / put(), %ld Kbytes @ %7.4f MB/sec\n\n", - (elapsed_time/((double)loops*npes))*1000000.0, - (total_bytes/1024), - ((double)total_bytes/(1024.0*1024.0)) / elapsed_time ); - } - - shmem_barrier_all(); -} - -void -neighbor_put(int *target, int *src, int elements, int me, int npes, int loops) -{ - int i, neighbor_pe; - double start_time, elapsed_time; - long total_bytes = loops * elements * sizeof(*src); - - if (me==0 && Verbose) { - fprintf(stdout, "%s: %d loops of put(%ld bytes) to neighbor, %d PEs: ", - __FUNCTION__, loops, (elements*sizeof(*src)), npes); - fflush(stdout); - } - - shmem_barrier_all(); - - neighbor_pe = (me + 1) % npes; - - start_time = tests_sos_wtime(); - for(i = 0; i < loops; i++) - shmem_int_put(target, src, elements, neighbor_pe); - elapsed_time = tests_sos_wtime() - start_time; - - if (me==0 && Verbose) { - printf("%7.3f secs\n", elapsed_time); - printf(" %7.5f usecs / put(), %ld Kbytes @ %7.4f MB/sec\n\n", - (elapsed_time/((double)loops*npes))*1000000.0, - (total_bytes/1024), - ((double)total_bytes/(1024.0*1024.0)) / elapsed_time ); - } - shmem_barrier_all(); -} - -void -neighbor_get(int *target, int *src, int elements, int me, int npes, int loops) -{ - int i, neighbor_pe; - double start_time, elapsed_time; - long total_bytes = loops * elements * sizeof(*src); - - if (me==0 && Verbose) { - fprintf(stdout, "%s: %d loops of get(%ld bytes) from neighbor, %d PEs: ", - __FUNCTION__, loops, (elements*sizeof(*src)), npes); - fflush(stdout); - } - - shmem_barrier_all(); - - neighbor_pe = (me + 1) % npes; - - start_time = tests_sos_wtime(); - for(i = 0; i < loops; i++) - shmem_int_get(target, src, elements, neighbor_pe); - elapsed_time = tests_sos_wtime() - start_time; - - if (me==0 && Verbose) { - printf("%7.3f secs\n", elapsed_time); - printf(" %7.5f usecs / get(), %ld Kbytes @ %7.4f MB/sec\n\n", - (elapsed_time/((double)loops*npes))*1000000.0, - (total_bytes/1024), - ((double)total_bytes/(1024.0*1024.0)) / elapsed_time ); - } - shmem_barrier_all(); -} - - -void -bcast(int *target, int *src, int elements, int me, int npes, int loops) -{ - int i; - double start_time, elapsed_time; - long *ps, *pSync, *pSync1; - long total_bytes = loops * elements * sizeof(*src); - - pSync = (long*)shmem_malloc( 2 * sizeof(long) * SHMEM_BCAST_SYNC_SIZE ); - pSync1 = &pSync[SHMEM_BCAST_SYNC_SIZE]; - for (i = 0; i < SHMEM_BCAST_SYNC_SIZE; i++) { - pSync[i] = pSync1[i] = SHMEM_SYNC_VALUE; - } - - if (me==0 && Verbose) { - fprintf(stdout, "%s: %d loops of broadcast32(%ld bytes) over %d PEs: ", - __FUNCTION__,loops,(elements*sizeof(*src)),npes); - fflush(stdout); - } - - shmem_barrier_all(); - - start_time = tests_sos_wtime(); - for(i = 0; i < loops; i++) { - ps = (i & 1) ? pSync1 : pSync; - shmem_broadcast32( target, src, elements, 0, 0, 0, npes, ps ); - } - elapsed_time = tests_sos_wtime() - start_time; - - if (me==0 && Verbose) { - printf("%7.3f secs\n", elapsed_time); - printf(" %7.5f usecs / broadcast32(), %ld Kbytes @ %7.4f MB/sec\n\n", - (elapsed_time/((double)loops*npes))*1000000.0, - (total_bytes/1024), - ((double)total_bytes/(1024.0*1024.0)) / elapsed_time ); - } - shmem_barrier_all(); - shmem_free( pSync ); -} - - -void -collect(int *target, int *src, int elements, int me, int npes, int loops) -{ - int i; - double start_time, elapsed_time; - long total_bytes = loops * elements * sizeof(*src); - long *ps, *pSync, *pSync1; - - pSync = (long*) shmem_malloc( 2 * sizeof(long) * SHMEM_COLLECT_SYNC_SIZE ); - pSync1 = &pSync[SHMEM_COLLECT_SYNC_SIZE]; - for (i = 0; i < SHMEM_COLLECT_SYNC_SIZE; i++) { - pSync[i] = pSync1[i] = SHMEM_SYNC_VALUE; - } - target = (int *) shmem_malloc( elements * sizeof(*target) * npes ); - - if (me==0 && Verbose) { - fprintf(stdout,"%s: %d loops of collect32(%ld bytes) over %d PEs: ", - __FUNCTION__,loops,(elements*sizeof(*src)),npes); - fflush(stdout); - } - - shmem_barrier_all(); - - start_time = tests_sos_wtime(); - for(i = 0; i < loops; i++) { - ps = (i & 1) ? pSync1 : pSync; - shmem_collect32( target, src, elements, 0, 0, npes, ps ); - } - elapsed_time = tests_sos_wtime() - start_time; - - if (me==0 && Verbose) { - printf("%7.3f secs\n", elapsed_time); - printf(" %7.5f usecs / collect32(), %ld Kbytes @ %7.4f MB/sec\n\n", - (elapsed_time/((double)loops*npes))*1000000.0, - (total_bytes/1024), - ((double)total_bytes/(1024.0*1024.0)) / elapsed_time ); - } - shmem_barrier_all(); - shmem_free(target); - shmem_free( pSync ); - shmem_barrier_all(); -} - - - -void -fcollect(int *target, int *src, int elements, int me, int npes, int loops) -{ - int i; - double start_time, elapsed_time; - long total_bytes = loops * elements * sizeof(*src); - long *ps, *pSync, *pSync1; - - pSync = (long*) shmem_malloc( 2 * sizeof(long) * SHMEM_COLLECT_SYNC_SIZE ); - pSync1 = &pSync[SHMEM_COLLECT_SYNC_SIZE]; - for (i = 0; i < SHMEM_COLLECT_SYNC_SIZE; i++) { - pSync[i] = pSync1[i] = SHMEM_SYNC_VALUE; - } - target = (int *) shmem_malloc( elements * sizeof(*target) * npes ); - - if (me==0 && Verbose) { - fprintf(stdout,"%s: %d loops of fcollect32(%ld bytes) over %d PEs: ", - __FUNCTION__,loops,(elements*sizeof(*src)),npes); - fflush(stdout); - } - - shmem_barrier_all(); - - start_time = tests_sos_wtime(); - for(i = 0; i < loops; i++) { - ps = &pSync[(i&1)]; - shmem_fcollect32( target, src, elements, 0, 0, npes, ps ); - } - elapsed_time = tests_sos_wtime() - start_time; - - if (me==0 && Verbose) { - printf("%7.3f secs\n", elapsed_time); - printf(" %7.5f usecs / fcollect32(), %ld Kbytes @ %7.4f MB/sec\n\n", - (elapsed_time/((double)loops*npes))*1000000.0, - (total_bytes/1024), - ((double)total_bytes/(1024.0*1024.0)) / elapsed_time ); - } - shmem_barrier_all(); - shmem_free(target); - shmem_free( pSync ); - shmem_barrier_all(); -} - -static int -atoi_scaled(char *s) -{ - long val; - char *e; - - val = strtol(s,&e,0); - if (e == NULL || *e =='\0') - return (int)val; - - if (*e == 'k' || *e == 'K') - val *= 1024; - else if (*e == 'm' || *e == 'M') - val *= 1024*1024; - else if (*e == 'g' || *e == 'G') - val *= 1024*1024*1024; - - return (int)val; -} - - -static void -usage(char *pgm) -{ - fprintf(stderr, - "usage: %s -{lhv}\n" - " where:\n" - " -l loops (%d) loop count.\n" - " -e ints (%d) # of integers to Tx\n" - " -a enable all-2-all tests\n" - " -b enable broadcast tests\n" - " -c enable collective tests\n" - " -m enable Many-2-one, one-2-many tests\n" - " -n enable put/get to neighbor PEtests\n" - " -v be verbose, multiple 'v' more verbose\n" - " -q be quite\n" - " -h this text.\n", - pgm,DFLT_LOOPS, N_ELEMENTS); -} diff --git a/test/unit/sping.c b/test/unit/sping.c deleted file mode 100644 index 3004901d3..000000000 --- a/test/unit/sping.c +++ /dev/null @@ -1,258 +0,0 @@ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - * SHMEM PingPong test - * :vim:sw=4:ts=4: - */ -#include -#include -#include -#include -#include - -int getSize (char *); -double gettime(void); -double dt (double *, double *); -void usage (char *); -void help (char *); -void printStats (int, int, int, int, double); - -#define dprint if (Verbose) printf -#define DFLT_MIN_WORDS 128 -#define DFLT_REPS 1000; - -int Verbose=0; - -#include - -int getSize (char *str) -{ - int size; - char mod[32]; - - switch (sscanf (str, "%d%1[mMkK]", &size, mod)) - { - case 1: - return (size); - - case 2: - switch (*mod) - { - case 'm': - case 'M': - return (size << 20); - - case 'k': - case 'K': - return (size << 10); - - default: - return (size); - } - - default: - return (-1); - } -} - -double gettime() -{ - struct timeval tv; - gettimeofday(&tv, 0); - return (tv.tv_sec * 1000000 + tv.tv_usec); -} - -double dt (double *tv1, double *tv2) -{ - return (*tv1 - *tv2); -} - -void usage (char *name) -{ - fprintf (stderr, "Usage: %s [flags] nwords [maxWords] [incWords]\n", name); - fprintf (stderr, " %s -h\n", name); - exit (1); -} - -void help (char *name) -{ - if (shmem_my_pe() == 0) { - printf ("Usage: %s [flags] nwords [maxWords] [incWords]\n\n", name); - printf (" Flags may be any of\n"); - printf (" -n number repititions\n"); - printf (" -e everyone print timing info\n"); - printf (" -h print this info\n\n"); - printf (" Numbers may be postfixed with 'k' or 'm'\n\n"); - } - shmem_barrier_all(); - exit (0); -} - -void printStats (int proc, int peer, int doprint, int now, double t) -{ - if (doprint || (proc & 1)) - printf("%3d pinged %3d: %8d words %9.2f uSec %8.2f MB/s\n", - proc, peer, now, t, sizeof(long)*now/(t)); -} - -int main (int argc, char *argv[]) -{ - double t,tv[2]; - int reps = DFLT_REPS; - int doprint = 1/*0*/; - char *progName; - int minWords; - int maxWords; - int incWords, nwords, nproc, proc, peer, c, r, i; - long *rbuf; /* remote buffer - sink */ - long *tbuf; /* transmit buffer - src */ - - shmem_init(); - proc = shmem_my_pe(); - nproc = shmem_n_pes(); - if (nproc == 1) { - fprintf(stderr, "ERR - Requires > 1 Processing Elements\n"); - shmem_finalize(); - return 0; - } - - for (progName = argv[0] + strlen(argv[0]); - progName > argv[0] && *(progName - 1) != '/'; - progName--) - ; - - while ((c = getopt (argc, argv, "n:evh")) != -1) - switch (c) - { - case 'n': - if ((reps = getSize (optarg)) <= 0) - usage (progName); - break; - case 'e': - doprint++; - break; - case 'v': - Verbose++; - break; - case 'h': - help (progName); - default: - usage (progName); - } - - if (optind == argc) - minWords = DFLT_MIN_WORDS; - else if ((minWords = getSize (argv[optind++])) <= 0) - usage (progName); - - if (optind == argc) - maxWords = minWords; - else if ((maxWords = getSize (argv[optind++])) < minWords) - usage (progName); - - if (optind == argc) - incWords = 0; - else if ((incWords = getSize (argv[optind++])) < 0) - usage (progName); - - if (!(rbuf = (long *)shmem_malloc(maxWords * sizeof(long)))) - { - perror ("Failed memory allocation"); - exit (1); - } - memset (rbuf, 0, maxWords * sizeof (long)); - - if (!(tbuf = (long *)shmem_malloc(maxWords * sizeof(long)))) - { - perror ("Failed memory allocation"); - exit (1); - } - - for (i = 0; i < maxWords; i++) - tbuf[i] = 1000 + (i & 255); - - if (doprint) - printf ("%d(%d): Shmem PING reps %d minWords %d maxWords %d " - "incWords %d\n", - proc, nproc, reps, minWords, maxWords, incWords); - - dprint("[%d] rbuf: %ld\n", proc, (unsigned long) rbuf); - - shmem_barrier_all(); - - peer = proc ^ 1; - if (peer >= nproc) - doprint = 0; - - for (nwords = minWords; - nwords <= maxWords; - nwords = incWords ? nwords + incWords : nwords ? 2 * nwords : 1) - { - r = reps; - shmem_barrier_all(); - tv[0] = gettime(); - if (peer < nproc) - { - if (proc & 1) - { - r--; - shmem_long_wait_until(&rbuf[nwords-1], SHMEM_CMP_NE, 0); - rbuf[nwords-1] = 0; - } - - while (r-- > 0) - { - shmem_long_put(rbuf, tbuf, nwords, peer); - shmem_long_wait_until(&rbuf[nwords-1], SHMEM_CMP_NE, 0); - rbuf[nwords-1] = 0; - } - - if (proc & 1) - { - shmem_long_put(rbuf, tbuf, nwords, peer); - } - } - tv[1] = gettime(); - t = dt (&tv[1], &tv[0]) / (2 * reps); - - shmem_barrier_all(); - - printStats (proc, peer, doprint, nwords, t); - } - - shmem_free(rbuf); - shmem_free(tbuf); - - shmem_finalize(); - - return 0; -} diff --git a/test/unit/strided_put.c b/test/unit/strided_put.c deleted file mode 100644 index ac49ebbc1..000000000 --- a/test/unit/strided_put.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* -* adaptation of example from SGI man page for shmem_iput. -* -* Code slightly cleaned up (removed cache call, fixed % format) -* -*/ -#include -#include - -int -main(int argc, char* argv[]) -{ - short source[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; - static short target[10]; - int me, num_pes; - int ret = 0; - - shmem_init(); - me = shmem_my_pe(); - num_pes = shmem_n_pes(); - - if (num_pes != 2) { - printf("%s: Requires 2 PEs\n", argv[0]); - shmem_finalize(); - return 0; - } - - if (me == 0) { - /* put 10 words into target on PE 1 */ - shmem_short_iput(target, source, 1, 2, 5, 1); - } - - shmem_barrier_all(); /* sync sender and receiver */ - - if (me == 1) { - if (! (target[0] == source[0] && - target[1] == source[2] && - target[2] == source[4] && - target[3] == source[6] && - target[4] == source[8])) { - printf("target on PE %d is %hd %hd %hd %hd %hd\n", me, - target[0], target[1], target[2], - target[3], target[4] ); - ret = 1; - } - } - - shmem_finalize(); - - return ret; -} diff --git a/test/unit/swap1.c b/test/unit/swap1.c deleted file mode 100644 index 8b2e4f615..000000000 --- a/test/unit/swap1.c +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include - -int -main(int argc, char* argv[]) -{ - long source[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; - static long target[10] = { 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 }; - int i, bad = 0; - - shmem_init(); - - if (shmem_n_pes() == 1) { - printf("%s: Requires number of PEs > 1\n", argv[0]); - shmem_finalize(); - return 0; - } - - if (shmem_my_pe() == 0) { - for (i = 0 ; i < 10 ; ++i) { - source[i] = shmem_long_atomic_swap(target + i, source[i], 1); - } - } - - shmem_barrier_all(); /* sync sender and receiver */ - - if (shmem_my_pe() == 0) { - for (i = 0 ; i < 10 ; ++i) { - if (source[i] != i + 11) bad = 1; - } - } else if (shmem_my_pe() == 1) { - for (i = 0 ; i < 10 ; ++i) { - if (target[i] != i + 1) bad = 1; - } - } - - if (bad) { - fprintf(stderr, "[%02d] error: ", shmem_my_pe()); - for (i = 0 ; i < 10 ; ++i) { - fprintf(stderr, "%ld ", (shmem_my_pe() == 0) ? source[i] : target[i]); - } - fprintf(stderr, "\n"); - } - - shmem_finalize(); - - return bad; -} diff --git a/test/unit/swapm.c b/test/unit/swapm.c deleted file mode 100644 index 17a3e24be..000000000 --- a/test/unit/swapm.c +++ /dev/null @@ -1,325 +0,0 @@ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - * swapm - exercise shmem_*_swap() - */ - -#include - -#include -#include -#include - -#define Vprintf if (Verbose) printf - -static int *src_int; -static float *src_float; -static double *src_double; -static long *src_long; -static long long *src_llong; - -static int *dst_int, itmp; -static float *dst_float, ftmp; -static double *dst_double, dtmp; -static long *dst_long, ltmp; -static long long *dst_llong, lltmp; - -static int loops = 10; - -int -main(int argc, char* argv[]) -{ - int me, num_procs, l, j; - int Verbose = 0; - - shmem_init(); - me = shmem_my_pe(); - num_procs = shmem_n_pes(); - if ( num_procs < 2 ) { - if (me ==0) - printf("PE[0] requires 2 or more PEs?\n"); - shmem_finalize(); - return 0; - } - - for (l = 0 ; l < loops ; ++l) { - - if ((src_int = shmem_malloc(2*num_procs*sizeof(int))) == NULL) { - printf("PE-%d int shmem_malloc() failed?\n", me); - shmem_global_exit(1); - } - dst_int = &src_int[num_procs]; - for(j=0; j < num_procs; j++) { - src_int[j] = 4; - dst_int[j] = 0; - } - - if ((src_float = shmem_malloc(2*num_procs*sizeof(float))) == NULL) { - printf("PE-%d float shmem_malloc() failed?\n", me); - shmem_global_exit(1); - } - dst_float = &src_float[num_procs]; - for(j=0; j < num_procs; j++) { - src_float[j] = 4.0; - dst_float[j] = 0.0; - } - - if ((src_double = shmem_malloc(2*num_procs*sizeof(double))) == NULL) { - printf("PE-%d double shmem_malloc() failed?\n", me); - shmem_global_exit(1); - } - dst_double = &src_double[num_procs]; - for(j=0; j < num_procs; j++) { - src_double[j] = 8.0; - dst_double[j] = 0.0; - } - - if ((src_long = shmem_malloc(2*num_procs*sizeof(long))) == NULL) { - printf("PE-%d long shmem_malloc() failed?\n", me); - shmem_global_exit(1); - } - dst_long = &src_long[num_procs]; - for(j=0; j < num_procs; j++) { - src_long[j] = 8; - dst_long[j] = 0; - } - - if ((src_llong = shmem_malloc(2*num_procs*sizeof(long long))) == NULL) { - printf("PE-%d long shmem_malloc() failed?\n", me); - shmem_global_exit(1); - } - dst_llong = &src_llong[num_procs]; - for(j=0; j < num_procs; j++) { - src_llong[j] = 16; - dst_llong[j] = 0; - } - - shmem_barrier_all(); - - if ( me != 0 ) { - /* is 'src_*' accessible from PE0? should be. */ - if (!shmem_addr_accessible(src_int,0)) { - printf("PE-%d local src_int %p not accessible from PE-%d?\n", - me, (void*)src_int, 0); - shmem_global_exit(1); - } - if (!shmem_addr_accessible(src_float,0)) { - printf("PE-%d local src_float %p not accessible from PE-%d?\n", - me, (void*)src_float, 0); - shmem_global_exit(1); - } - if (!shmem_addr_accessible(src_double,0)) { - printf("PE-%d local src_double %p not accessible from PE-%d?\n", - me, (void*)src_double, 0); - shmem_global_exit(1); - } - if (!shmem_addr_accessible(src_long,0)) { - printf("PE-%d local src_long %p not accessible from PE-%d?\n", - me, (void*)src_long, 0); - shmem_global_exit(1); - } - if (!shmem_addr_accessible(src_llong,0)) { - printf("PE-%d local src_llong %p not accessible from PE-%d?\n", - me, (void*)src_llong, 0); - shmem_global_exit(1); - } - } - shmem_barrier_all(); - - if ( me == 0 ) { - shmem_quiet(); - for(j=1; j < num_procs; j++) { - dst_int[j] = shmem_int_atomic_swap(src_int+j,0,j); - if (dst_int[j] != 4) { - printf("PE-%d dst_int[%d] %d != 4?\n",me,j,dst_int[j]); - shmem_global_exit(1); - } - } - shmem_barrier_all(); - - /* verify remote data */ - for(j=1; j < num_procs; j++) { - itmp = shmem_int_g(src_int+j,j); - if (itmp != 0) { - printf("PE-0 int PE[%d] rem(%d) != 0?\n",j,itmp); - shmem_global_exit(1); - } - - /* swap back */ - dst_int[j] = shmem_int_atomic_swap(src_int+j,dst_int[j],j); - if (dst_int[j] != 0) { - printf("PE-0 dst_int[%d] %d != 0?\n",j,dst_int[j]); - shmem_global_exit(1); - } - - itmp = shmem_int_g(src_int+j,j); - if (itmp != 4) { - printf("PE-0 PE[%d] rem %d != 4?\n",j,itmp); - shmem_global_exit(1); - } - } - - for(j=1; j < num_procs; j++) { - dst_float[j] = shmem_float_atomic_swap(src_float+j,0.0,j); - if (dst_float[j] != 4.0) { - printf("PE-0 dst_float[%d] %f != 4.0?\n",j,dst_float[j]); - shmem_global_exit(1); - } - - /* verify remote data */ - ftmp = shmem_float_g(src_float+j,j); - if (ftmp != 0.0) { - printf("PE-0 float rem(%f) != 0.0?\n",ftmp); - shmem_global_exit(1); - } - /* swap back */ - dst_float[j] = shmem_float_atomic_swap(src_float+j,dst_float[j],j); - if (dst_float[j] != 0.0) { - printf("PE-0 dst_float[%d] %f != 0.0?\n",j,dst_float[j]); - shmem_global_exit(1); - } - ftmp = shmem_float_g(src_float+j,j); - if (ftmp != 4.0) { - printf("PE-%d float rem(%f) != 4.0?\n",me,ftmp); - shmem_global_exit(1); - } - } - - for(j=1; j < num_procs; j++) { - dst_double[j] = shmem_double_atomic_swap(src_double+j,0.0,j); - if (dst_double[j] != 8.0) { - printf("PE-0 dst_double[%d] %f != 8.0?\n",j,dst_double[j]); - shmem_global_exit(1); - } - /* verify remote data */ - dtmp = shmem_double_g(src_double+j,j); - if (dtmp != 0.0) { - printf("PE-0 float rem(%f) != 0.0?\n",dtmp); - shmem_global_exit(1); - } - dst_double[j] = shmem_double_atomic_swap(src_double+j,dst_double[j],j); - if (dst_double[j] != 0.0) { - printf("PE-0 dst_double[%d] %f != 0.0?\n",j,dst_double[j]); - shmem_global_exit(1); - } - dtmp = shmem_double_g(src_double+j,j); - if (dtmp != 8.0) { - printf("PE-0 double rem(%f) != 8.0?\n",dtmp); - shmem_global_exit(1); - } - } - - for(j=1; j < num_procs; j++) { - dst_long[j] = shmem_long_atomic_swap(src_long+j,0,j); - if (dst_long[j] != 8) { - printf("PE-0 dst_long[%d] %ld != 8?\n",j,dst_long[j]); - shmem_global_exit(1); - } - } - shmem_barrier_all(); - - /* verify remote data */ - for(j=1; j < num_procs; j++) { - ltmp = shmem_long_g(src_long+j,j); - if (ltmp != 0) { - printf("PE-0 PE[%d]long rem(%ld) != 0?\n",j,ltmp); - shmem_global_exit(1); - } - /* swap back */ - dst_long[j] = shmem_long_atomic_swap(src_long+j,dst_long[j],j); - if (dst_long[j] != 0) { - printf("PE-%d dst_long[%d] %ld != 0?\n",me,j,dst_long[j]); - shmem_global_exit(1); - } - ltmp = shmem_long_g(src_long+j,j); - if (ltmp != 8) { - printf("PE-%d long rem(%ld) != 8?\n",me,ltmp); - shmem_global_exit(1); - } - } - - for(j=1; j < num_procs; j++) { - dst_llong[j] = shmem_longlong_atomic_swap(src_llong+j,0,j); - if (dst_llong[j] != 16) { - printf("PE-%d dst_llong[%d] %lld != 16?\n",me,j,dst_llong[j]); - shmem_global_exit(1); - } - } - shmem_barrier_all(); - - /* verify remote data */ - for(j=1; j < num_procs; j++) { - lltmp = shmem_longlong_g(src_llong+j,j); - if (lltmp != 0) { - printf("PE-%d long long rem(%lld) != 0?\n",me,lltmp); - shmem_global_exit(1); - } - /* swap back */ - dst_llong[j] = shmem_longlong_atomic_swap(src_llong+j,dst_llong[j],j); - if (dst_llong[j] != 0) { - printf("PE-%d dst_llong[%d] %lld != 0?\n", me,j,dst_llong[j]); - shmem_global_exit(1); - } - lltmp = shmem_longlong_g(src_llong+j,j); - if (lltmp != 16) { - printf("PE-%d longlong rem(%lld) != 16?\n",me,lltmp); - shmem_global_exit(1); - } - } - } - else { - shmem_int_wait_until(&src_int[me],SHMEM_CMP_EQ,0); - shmem_barrier_all(); - - shmem_long_wait_until(&src_long[me],SHMEM_CMP_EQ,0); - shmem_barrier_all(); - - shmem_longlong_wait_until(&src_llong[me],SHMEM_CMP_EQ,0); - shmem_barrier_all(); - } - - shmem_barrier_all(); - - shmem_free(src_int); - shmem_free(src_float); - shmem_free(src_double); - shmem_free(src_long); - shmem_free(src_llong); - } - - if (Verbose) - fprintf(stderr,"[%d] exit\n",shmem_my_pe()); - - shmem_finalize(); - - return 0; -} diff --git a/test/unit/sync-size.c b/test/unit/sync-size.c deleted file mode 100644 index 090cdf7b1..000000000 --- a/test/unit/sync-size.c +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include - -#define N 3 -#define MAX(A,B) ((A) > (B)) ? (A) : (B) - -long src[N]; -long dst[N]; - -int main(int argc, char* argv[]) { - int i, j, me, npes; - int errors = 0; - - shmem_init(); - - me = shmem_my_pe(); - npes = shmem_n_pes(); - - for (i = 0; i < N; i += 1) { - src[i] = me; - dst[i] = -1; - } - - /* Barrier */ - - shmem_barrier_all(); - - /* Broadcast */ - - shmem_long_broadcast(SHMEM_TEAM_WORLD, dst, src, N, 0); - - for (i = 0; i < N && me > 0; i++) { - if (dst[i] != 0) { - printf("[%d] Broadcast: got %ld, expected %d\n", me, dst[i], 0); - ++errors; - } - } - - shmem_barrier_all(); - - /* Collect */ - - long *dst_all = shmem_malloc(npes * N * sizeof(long)); - - shmem_long_fcollect(SHMEM_TEAM_WORLD, dst_all, src, N); - - for (i = 0; i < npes; i++) { - for (j = 0; j < N; j++) { - if (dst_all[i*N+j] != i) { - printf("[%d] Fcollect: got %ld, expected %d\n", me, dst_all[i], j); - ++errors; - } - } - } - - shmem_free(dst_all); - shmem_barrier_all(); - - /* Reduction */ - - shmem_long_max_reduce(SHMEM_TEAM_WORLD, dst, src, N); - - for (i = 0; i < N; i++) { - if (dst[i] != npes-1) { - printf("[%d] Reduction: got %ld, expected %d\n", npes-1, dst[i], 0); - ++errors; - } - } - - shmem_finalize(); - - return errors; -} diff --git a/test/unit/test_lock.c b/test/unit/test_lock.c deleted file mode 100644 index ab31ccfa0..000000000 --- a/test/unit/test_lock.c +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - * shmem_test_lock() test_lock {-v|q|n} {loop-cnt} - * where: - * -v == verbose/debug - * -q == quiet - * -n x x == Spin count threshold to announce excessive spin counts. - * - * For n loops: - * Each pe attempts to lock the global lock, if lock is taken, increment the - * lock count on all pes and then waits until the lock count reaches num_pes() - * which is the exit condition. - * On a failed lock attempt, increment local lock_tries counter and repeat. - */ -#include -#include -#include -#include -#include - -#define Rfprintf if (shmem_my_pe() == 0) fprintf -#define Rprintf if (shmem_my_pe() == 0) printf -#define Vfprintf if (Verbose) fprintf -#define Vprintf if (Verbose) printf - -int Verbose; -int Stats; -int Noise = 500; - -int lock_cnt; -long lock; - -typedef struct _lock_stat { - int attempts; -} lock_stat_t; - -lock_stat_t *lock_stats; - -int -main(int argc, char* argv[]) -{ - int pe, c, rc, cloop, loops; - int tries, lock_stats_sz; - int my_rank, num_ranks; - int Announce = (NULL == getenv("MAKELEVEL")) ? 1 : 0; - - shmem_init(); - my_rank = shmem_my_pe(); - num_ranks = shmem_n_pes(); - if (num_ranks == 1) { - fprintf(stderr, "ERR - Requires > 1 PEs\n"); - shmem_finalize(); - return 0; - } - - while((c=getopt(argc,argv,"n:qv")) != -1) { - switch(c) { - case 'n': - Noise = atoi(optarg); // threshold to announce spinloops - break; - case 'v': - Verbose++; - break; - case 'q': - Announce = 0; - break; - default: - Rfprintf(stderr,"ERR - unknown -%c ?\n",c); - shmem_finalize(); - return 1; - } - } - - if (optind == argc) - loops = 40; - else { - loops = atoi(argv[optind++]); - if (loops <= 0 || loops > 1000000) { - Rfprintf(stderr, - "ERR - loops arg out of bounds '%d'?\n", loops); - shmem_finalize(); - return 1; - } - } - if (Announce) - Stats++; - else - Stats = 0; - - if (Stats) { - lock_stats_sz = sizeof(lock_stat_t) * num_ranks; // lock stats - lock_stats = shmem_malloc(lock_stats_sz); - if ( !lock_stats ) { - fprintf(stderr,"[%d] ERR: shmem_malloc(%d)\n",my_rank,lock_stats_sz); - shmem_global_exit(1); - } - memset( lock_stats, 0, lock_stats_sz ); - } - - for(cloop=1; cloop <= loops; cloop++) { - lock = 0; - lock_cnt = 0; - tries = 0; - - shmem_barrier_all(); /* sync all ranks */ - - while( *(&lock_cnt) < num_ranks ) { - rc = shmem_test_lock(&lock); - if ( rc == 0 ) { - /* incr lock_cnt on all ranks */ - for(pe=0; pe < num_ranks; pe++) { - shmem_int_atomic_add( &lock_cnt, 1, pe ); - } - Vprintf("[%d] locked: lock_cnt(%d)\n", my_rank, lock_cnt); - shmem_clear_lock( &lock ); - shmem_int_wait_until( &lock_cnt, SHMEM_CMP_GE, num_ranks ); - } - else { - tries++; - if ( Announce && ((tries % (num_ranks*Noise)) == 0) ) - printf("[%d] unsuccessful lock attempts %d lock_cnt %d\n", - my_rank, tries, lock_cnt); - } - } - shmem_barrier_all(); /* sync all ranks */ - - if ( (cloop % 10) == 0 ) { - if (my_rank == 0 && Announce) - printf("%d ranks completed %d loops\n", num_ranks, cloop); - } - - if (Stats) - lock_stats[my_rank].attempts += tries; - } - - if ( Stats && my_rank != 0 ) { - shmem_int_put( &lock_stats[my_rank].attempts, - &lock_stats[my_rank].attempts, 1, 0 ); - shmem_fence(); - } - shmem_barrier_all(); /* sync all ranks */ - - if (Stats && my_rank == 0) { - for(c=0; c < num_ranks; c++) { - printf("[%d] lock attempts %d\n", c, - lock_stats[c].attempts); - } - } - shmem_barrier_all(); /* sync all ranks */ - - if (Stats) - shmem_free(lock_stats); - - Vprintf ("[%d] of %d, Exit\n", my_rank, num_ranks); - - shmem_finalize(); - - return 0; -} diff --git a/test/unit/test_lock_cswap.c b/test/unit/test_lock_cswap.c deleted file mode 100644 index 9c2bb3a77..000000000 --- a/test/unit/test_lock_cswap.c +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - * shmem_test_lock_cswap() test_lock {-v|n} - * where: - * -v Enable debugging messages - * -n x Period with which to announce spin count - * - * For n loops: - * Each PE repeatedly attempts to take a simple spinlock on rank 0 using - * cswap, upon success the lock is released and the PE enters a barrier. - * On a failed lock attempt, increment local lock_tries counter and repeat. - */ - -#include -#include -#include -#include -#include - -#define Rfprintf if (shmem_my_pe() == 0) fprintf -#define Rprintf if (shmem_my_pe() == 0) printf -#define Vfprintf if (Verbose) fprintf -#define Vprintf if (Verbose) printf - -int Verbose = 0; -int Announce = 0; -int Noise = 500; -int Loops = 40; - -long lock; - -int -main(int argc, char* argv[]) -{ - int c, cloop; - int my_rank, num_ranks; - - shmem_init(); - my_rank = shmem_my_pe(); - num_ranks = shmem_n_pes(); - - if (num_ranks == 1) { - fprintf(stderr, "ERR - Requires > 1 PEs\n"); - shmem_finalize(); - return 0; - } - - while ((c = getopt(argc,argv,"n:v")) != -1) { - switch (c) { - case 'n': - Noise = atoi(optarg); - break; - case 'v': - Verbose++; - Announce = 1; - break; - default: - Rfprintf(stderr,"ERR - unknown -%c ?\n",c); - shmem_finalize(); - return 1; - } - } - - for (cloop=1; cloop <= Loops; cloop++) { - int got_lock = 0; - int lock_cnt = 0; - int tries = 0; - - lock = 0; - - shmem_barrier_all(); /* sync all ranks */ - - while (!got_lock) { - long lockval = shmem_long_atomic_compare_swap(&lock, 0, my_rank+1, 0); - - if (lockval == 0) { - long unlockval; - got_lock = 1; - - Vprintf("[%d] locked: lock_cnt(%d) lock(%lx)\n", my_rank, lock_cnt, lock); - - unlockval = shmem_long_atomic_compare_swap(&lock, my_rank+1, 0, 0); /* RACE: PE 1 hangs here */ - if (unlockval != my_rank+1) { - printf("[%d] unlock failed, expected %lx got %lx\n", my_rank, (long) my_rank+1, unlockval); - shmem_global_exit(1); - } - - Vprintf("[%d] finished unlock\n", my_rank); - } - else { - tries++; - if ( Announce && ((tries % (num_ranks*Noise)) == 0) ) { - printf("[%d] unsuccessful lock attempts %d lock_cnt %d lock %lx\n", - my_rank, tries, lock_cnt, lock); - } - } - } - shmem_barrier_all(); /* sync all ranks */ - - if ((cloop % 10) == 0) { - if (Announce) { - Rprintf("%d ranks completed %d loops\n", num_ranks, cloop); - } - } - } - - shmem_barrier_all(); /* sync all ranks */ - - Vprintf ("[%d] of %d, Exit\n", my_rank, num_ranks); - shmem_finalize(); - return 0; -} diff --git a/test/unit/thread_wait.c b/test/unit/thread_wait.c deleted file mode 100644 index 2d9843128..000000000 --- a/test/unit/thread_wait.c +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* Thread wait test: Test whether a store performed by one thead will wake up a - * second thread from a call to shmem_wait. */ - -#include -#include -#include -#include - -static long shr_var = 0; - -static void* src_thread_fn(void *arg) { - /* Try to get the dst thread to enter wait before the call to sleep */ - sleep(1); - - /* This should wake up the waiting dst thread */ - shr_var = 1; - - /* Quiet should provide a store fence */ - shmem_quiet(); - return NULL; -} - -static void* dst_thread_fn(void *arg) { - shmem_long_wait_until(&shr_var, SHMEM_CMP_NE, 0); - return NULL; -} - -int main(int argc, char* argv[]) { - int tl, ret; - pthread_t src_thread, dst_thread; - - ret = shmem_init_thread(SHMEM_THREAD_MULTIPLE, &tl); - - if (tl != SHMEM_THREAD_MULTIPLE || ret != 0) { - printf("Init failed (requested thread level %d, got %d, ret %d)\n", - SHMEM_THREAD_MULTIPLE, tl, ret); - - if (ret == 0) { - shmem_global_exit(1); - } else { - return ret; - } - } - - pthread_create(&dst_thread, NULL, &dst_thread_fn, NULL); - pthread_create(&src_thread, NULL, &src_thread_fn, NULL); - - pthread_join(dst_thread, NULL); - pthread_join(src_thread, NULL); - - shmem_finalize(); - - return 0; -} diff --git a/test/unit/threading.c b/test/unit/threading.c deleted file mode 100644 index 06b547549..000000000 --- a/test/unit/threading.c +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include - -/* For systems without the PThread barrier API (e.g. MacOS) */ -#include "pthread_barrier.h" - -#define N_THREADS 8 -#define N_ELEMS 10 - -static long source[N_THREADS*N_ELEMS]; -static long target[N_THREADS*N_ELEMS]; -pthread_barrier_t fencebar; - -static void* roundrobin(void* tparam) { - ptrdiff_t tid = (ptrdiff_t)tparam; - int offset = tid*N_ELEMS; - /* fprintf(stderr,"Starting thread %lu with offset %d\n",tid,offset); */ - - int nextpe = (shmem_my_pe()+1)%shmem_n_pes(); - int prevpe = (shmem_my_pe()-1 + shmem_n_pes())%shmem_n_pes(); - shmem_long_put(target+offset, source+offset, N_ELEMS, nextpe); - - /* fprintf(stderr,"Thread %lu done first put\n",tid); */ - pthread_barrier_wait(&fencebar); - if(tid == 0) shmem_barrier_all(); - pthread_barrier_wait(&fencebar); - - shmem_long_get(source+offset, target+offset, N_ELEMS, prevpe); - - /* fprintf(stderr,"Thread %lu done first get\n",tid); */ - pthread_barrier_wait(&fencebar); - if(tid == 0) shmem_barrier_all(); - pthread_barrier_wait(&fencebar); - - shmem_long_get(target+offset, source+offset, N_ELEMS, nextpe); - - /* fprintf(stderr,"Thread %lu done second get\n",tid); */ - pthread_barrier_wait(&fencebar); - if(tid == 0) shmem_barrier_all(); - pthread_barrier_wait(&fencebar); - /* fprintf(stderr,"Done thread %lu\n",tid); */ - - return 0; -} - -int -main(int argc, char* argv[]) -{ - int i; - for(i = 0; i < N_THREADS*N_ELEMS; ++i) { - source[i] = i+1; - } - - int tl; - int ret = shmem_init_thread(SHMEM_THREAD_MULTIPLE, &tl); - - if (tl != SHMEM_THREAD_MULTIPLE || ret != 0) { - printf("Init failed (requested thread level %d, got %d, ret %d)\n", - SHMEM_THREAD_MULTIPLE, tl, ret); - - if (ret == 0) { - shmem_global_exit(1); - } else { - return ret; - } - } - - if (shmem_n_pes() == 1) { - printf("%s: Requires number of PEs > 1\n", argv[0]); - shmem_finalize(); - return 0; - } - - pthread_t threads[N_THREADS]; - - pthread_barrier_init(&fencebar,NULL,N_THREADS); - - fprintf(stderr,"Starting threads\n"); - for(i = 0; i < N_THREADS; ++i) { - /* fprintf(stderr,"Starting thread %d\n",i); */ - ptrdiff_t tid = i; - pthread_create(&threads[i],NULL,&roundrobin,(void*)tid); - } - - for(i = 0; i < N_THREADS; ++i) { - pthread_join(threads[i],NULL); - } - pthread_barrier_destroy(&fencebar); - - if (0 != memcmp(source, target, sizeof(long) * N_THREADS*N_ELEMS)) { - fprintf(stderr,"[%d] Src & Target mismatch?\n",shmem_my_pe()); - for (i = 0 ; i < 10 ; ++i) { - printf("%ld,%ld ", source[i], target[i]); - } - printf("\n"); - shmem_global_exit(1); - } - - shmem_finalize(); - - return 0; -} - diff --git a/test/unit/to_all.c b/test/unit/to_all.c deleted file mode 100644 index 22f92474c..000000000 --- a/test/unit/to_all.c +++ /dev/null @@ -1,834 +0,0 @@ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* -* to_all - exercise SHMEM max,min,or,prod,sum,or,xor_to_all() reduction calls. -* Each reduction is invoked for all data types: -* short, int, long, float, double, long double, long long. -* Point being numerous SHMEM atomics and synchronizations in flight. -* From OpenSHMEM_specification_v1.0-final doc: -* -* frank @ SystemFabric Works identified an interesting overflow issue in the -* prod_to_all test. In the presence of slightly larger PE counts (>=14), -* overflow is encountered in short, int and float, double and long double. -* The short and int both wrap correctly and are both uniformly wrong...uniformly -* being the salient point. float, double and long double all suffer from -* floating point rounding errors, hence the FP test results are ignored -* (assumed to pass)when FP rounding is encountered. -* -* usage: to_all {-amopsSv|h} -* where: -* -a do not run and_to_all -* -m do not run min_to_all, max_to_all() always run. -* -o do not run or_to_all -* -p do not run prod_to_all -* -s do not run sum_to_all -* -x do not run xor_to_all -* -S Serialize *_to_all() calls with barriers. -* -v verbose(additional -v, more verbose) -* -h this text. -*/ -#include -#include -#include -#include -#include - -#include - -#define Rprintf if (shmem_my_pe() == 0) printf -#define Rfprintf if (shmem_my_pe() == 0) fprintf -#define Vprintf if (Verbose > 1) printf - -int sum_reduce(int me, int npes); -int min_reduce(int me, int npes); -int max_reduce(int me, int npes); -int prod_reduce(int me, int npes); -int and_reduce(int me, int npes); -int or_reduce(int me, int npes); -int xor_reduce(int me, int npes); - -int Verbose; -int Serialize; -int Min, And, Sum, Prod, Or, Xor; -int Passed; - -#define N 128 - -#define MAX(a, b) ((a) > (b)) ? (a) : (b) -#define WRK_SIZE MAX(N/2+1, SHMEM_REDUCE_MIN_WRKDATA_SIZE) - -short src0[N], dst0[N]; -int src1[N], dst1[N]; -long src2[N], dst2[N]; -float src3[N], dst3[N]; -double src4[N], dst4[N]; -long double src5[N], dst5[N]; -long long src6[N], dst6[N]; - -/* bitwise reduction types */ -unsigned short src7[N], dst7[N]; -unsigned int src8[N], dst8[N]; -unsigned long src9[N], dst9[N]; -unsigned long long src10[N], dst10[N]; - -short expected_result0; -int expected_result1; -long expected_result2; -float expected_result3; -double expected_result4; -long double expected_result5; -long long expected_result6; - -int ok[7]; - -int -max_reduce(int me, int npes) -{ - int i, j, pass=0; - - memset(ok,0,sizeof(ok)); - - for (i = 0; i < N; i++) { - src0[i] = src1[i] = src2[i] = src3[i] = src4[i] = src5[i] = src6[i] - = me + i; - } - shmem_barrier_all(); - - shmem_short_max_reduce( SHMEM_TEAM_WORLD, dst0, src0, N); - shmem_int_max_reduce( SHMEM_TEAM_WORLD, dst1, src1, N); - shmem_long_max_reduce( SHMEM_TEAM_WORLD, dst2, src2, N); - shmem_float_max_reduce( SHMEM_TEAM_WORLD, dst3, src3, N); - shmem_double_max_reduce( SHMEM_TEAM_WORLD, dst4, src4, N); - shmem_longdouble_max_reduce(SHMEM_TEAM_WORLD, dst5, src5, N); - shmem_longlong_max_reduce( SHMEM_TEAM_WORLD, dst6, src6, N); - - if (me == 0) { - for (i = 0,j=-1; i < N; i++,j++) { - if(dst0[i] != npes+j) ok[0] = 1; - if(dst1[i] != npes+j) ok[1] = 1; - if(dst2[i] != npes+j) ok[2] = 1; - if(dst3[i] != npes+j) ok[3] = 1; - if(dst4[i] != npes+j) ok[4] = 1; - if(dst5[i] != npes+j) ok[5] = 1; - if(dst6[i] != npes+j) ok[6] = 1; - } - - if(ok[0]==1){ - printf("Reduction operation shmem_short_max_reduce: Failed\n"); - } - else{ - Vprintf("Reduction operation shmem_short_max_reduce: Passed\n"); - pass++; - } - if(ok[1]==1){ - printf("Reduction operation shmem_int_max_reduce: Failed\n"); - } - else{ - Vprintf("Reduction operation shmem_int_max_reduce: Passed\n"); - pass++; - } - if(ok[2]==1){ - printf("Reduction operation shmem_long_max_reduce: Failed\n"); - } - else{ - Vprintf("Reduction operation shmem_long_max_reduce: Passed\n"); - pass++; - } - if(ok[3]==1){ - printf("Reduction operation shmem_float_max_reduce: Failed\n"); - } - else{ - Vprintf("Reduction operation shmem_float_max_reduce: Passed\n"); - pass++; - } - if(ok[4]==1){ - printf("Reduction operation shmem_double_max_reduce: Failed\n"); - } - else{ - Vprintf("Reduction operation shmem_double_max_reduce: Passed\n"); - pass++; - } - if(ok[5]==1){ - printf("Reduction operation shmem_longdouble_max_reduce: Failed\n"); - } - else{ - Vprintf("Reduction operation shmem_longdouble_max_reduce: Passed\n"); - pass++; - } - if(ok[6]==1){ - printf("Reduction operation shmem_longlong_max_reduce: Failed\n"); - } - else{ - Vprintf("Reduction operation shmem_longlong_max_reduce: Passed\n"); - pass++; - } - Vprintf("\n"); - } - if (Serialize) shmem_barrier_all(); - - return (pass == 7 ? 1 : 0); -} - -int -min_reduce(int me, int npes) -{ - int i, pass=0; - - memset(ok,0,sizeof(ok)); - - for (i = 0; i < N; i++) { - src0[i] = src1[i] = src2[i] = src3[i] = src4[i] = src5[i] = src6[i] - = me + i; - dst0[i] = -9; - dst1[i] = -9; - dst2[i] = -9; - dst3[i] = -9; - dst4[i] = -9; - dst5[i] = -9; - dst6[i] = -9; - } - - shmem_barrier_all(); - - shmem_short_min_reduce( SHMEM_TEAM_WORLD, dst0, src0, N); - shmem_int_min_reduce( SHMEM_TEAM_WORLD, dst1, src1, N); - shmem_long_min_reduce( SHMEM_TEAM_WORLD, dst2, src2, N); - shmem_float_min_reduce( SHMEM_TEAM_WORLD, dst3, src3, N); - shmem_double_min_reduce( SHMEM_TEAM_WORLD, dst4, src4, N); - shmem_longdouble_min_reduce(SHMEM_TEAM_WORLD, dst5, src5, N); - shmem_longlong_min_reduce( SHMEM_TEAM_WORLD, dst6, src6, N); - - if(me == 0) { - for (i = 0; i < N; i++) { - if(dst0[i] != i) ok[0] = 1; - if(dst1[i] != i) ok[1] = 1; - if(dst2[i] != i) ok[2] = 1; - if(dst3[i] != i) ok[3] = 1; - if(dst4[i] != i) ok[4] = 1; - if(dst5[i] != i) ok[5] = 1; - if(dst6[i] != i) ok[6] = 1; - } - if(ok[0]==1){ - printf("Reduction operation shmem_short_min_reduce: Failed\n"); - } - else{ - Vprintf("Reduction operation shmem_short_min_reduce: Passed\n"); - pass++; - } - if(ok[1]==1){ - printf("Reduction operation shmem_int_min_reduce: Failed\n"); - } - else{ - Vprintf("Reduction operation shmem_int_min_reduce: Passed\n"); - pass++; - } - if(ok[2]==1){ - printf("Reduction operation shmem_long_min_reduce: Failed\n"); - } - else{ - Vprintf("Reduction operation shmem_long_min_reduce: Passed\n"); - pass++; - } - if(ok[3]==1){ - printf("Reduction operation shmem_float_min_reduce: Failed\n"); - } - else{ - Vprintf("Reduction operation shmem_float_min_reduce: Passed\n"); - pass++; - } - if(ok[4]==1){ - printf("Reduction operation shmem_double_min_reduce: Failed\n"); - } - else{ - Vprintf("Reduction operation shmem_double_min_reduce: Passed\n"); - pass++; - } - if(ok[5]==1){ - printf("Reduction operation shmem_longdouble_min_reduce: Failed\n"); - } - else{ - Vprintf("Reduction operation shmem_longdouble_min_reduce: Passed\n"); - pass++; - } - if(ok[6]==1){ - printf("Reduction operation shmem_longlong_min_reduce: Failed\n"); - } - else{ - Vprintf("Reduction operation shmem_longlong_min_reduce: Passed\n"); - pass++; - } - Vprintf("\n"); - } - if (Serialize) shmem_barrier_all(); - - return (pass == 7 ? 1 : 0); -} - - -int -sum_reduce(int me, int npes) -{ - int i, pass=0; - - memset(ok,0,sizeof(ok)); - - for (i = 0; i < N; i++) { - src0[i] = src1[i] = src2[i] = src3[i] = src4[i] = src5[i] = src6[i] = me; - dst0[i] = -9; - dst1[i] = -9; - dst2[i] = -9; - dst3[i] = -9; - dst4[i] = -9; - dst5[i] = -9; - dst6[i] = -9; - } - - shmem_barrier_all(); - - shmem_short_sum_reduce( SHMEM_TEAM_WORLD, dst0, src0, N); - shmem_int_sum_reduce( SHMEM_TEAM_WORLD, dst1, src1, N); - shmem_long_sum_reduce( SHMEM_TEAM_WORLD, dst2, src2, N); - shmem_float_sum_reduce( SHMEM_TEAM_WORLD, dst3, src3, N); - shmem_double_sum_reduce( SHMEM_TEAM_WORLD, dst4, src4, N); - shmem_longdouble_sum_reduce(SHMEM_TEAM_WORLD, dst5, src5, N); - shmem_longlong_sum_reduce( SHMEM_TEAM_WORLD, dst6, src6, N); - - if(me == 0) { - for (i = 0; i < N; i++) { - if(dst0[i] != (short) (npes * (npes-1)/2)) ok[0] = 1; - if(dst1[i] != (int) (npes * (npes-1)/2)) ok[1] = 1; - if(dst2[i] != (long) (npes * (npes-1)/2)) ok[2] = 1; - if(dst3[i] != (float) (npes * (npes-1)/2)) ok[3] = 1; - if(dst4[i] != (double) (npes * (npes-1)/2)) ok[4] = 1; - if(dst5[i] != (long double) (npes * (npes-1)/2)) ok[5] = 1; - if(dst6[i] != (long long) (npes * (npes-1)/2)) ok[6] = 1; - } - if(ok[0]==1){ - printf("Reduction operation shmem_short_sum_reduce: Failed\n"); - } - else{ - Vprintf("Reduction operation shmem_short_sum_reduce: Passed\n"); - pass++; - } - if(ok[1]==1){ - printf("Reduction operation shmem_int_sum_reduce: Failed\n"); - } - else{ - Vprintf("Reduction operation shmem_int_sum_reduce: Passed\n"); - pass++; - } - if(ok[2]==1){ - printf("Reduction operation shmem_long_sum_reduce: Failed\n"); - } - else{ - Vprintf("Reduction operation shmem_long_sum_reduce: Passed\n"); - pass++; - } - if(ok[3]==1){ - printf("Reduction operation shmem_float_sum_reduce: Failed\n"); - } - else{ - Vprintf("Reduction operation shmem_float_sum_reduce: Passed\n"); - pass++; - } - if(ok[4]==1){ - printf("Reduction operation shmem_double_sum_reduce: Failed\n"); - } - else{ - Vprintf("Reduction operation shmem_double_sum_reduce: Passed\n"); - pass++; - } - if(ok[5]==1){ - printf("Reduction operation shmem_longdouble_sum_reduce: Failed\n"); - } - else{ - Vprintf("Reduction operation shmem_longdouble_sum_reduce: Passed\n"); - pass++; - } - if(ok[6]==1){ - printf("Reduction operation shmem_longlong_sum_reduce: Failed\n"); - } - else{ - Vprintf("Reduction operation shmem_longlong_sum_reduce: Passed\n"); - pass++; - } - Vprintf("\n"); fflush(stdout); - } - if (Serialize) shmem_barrier_all(); - - return (pass == 7 ? 1 : 0); -} - - -int -prod_reduce(int me, int npes) -{ - int i, pass=0; - int float_rounding_err=0; - int double_rounding_err=0; - int ldouble_rounding_err=0; - - memset(ok,0,sizeof(ok)); - - for (i = 0; i < N; i++) { - src0[i] = src1[i] = src2[i] = src3[i] = src4[i] = src5[i] = src6[i] - = me + 1; - dst0[i] = -9; - dst1[i] = -9; - dst2[i] = -9; - dst3[i] = -9; - dst4[i] = -9; - dst5[i] = -9; - dst6[i] = -9; - } - - expected_result0 = expected_result1 = expected_result2 = - expected_result6 = 1; - expected_result3 = expected_result4 = expected_result5 = 1.0; - - - for(i=1; i <= npes; i++) { - expected_result0 *= i; - expected_result1 *= i; - expected_result2 *= i; - expected_result3 *= (float)i; - expected_result4 *= (double)i; - if ((double)expected_result3 != expected_result4) { - if (!float_rounding_err && Verbose > 2 && me == 0) - printf("float_err @ npes %d\n",i); - float_rounding_err = 1; - } - expected_result5 *= (long double)i; - if ((long double)expected_result4 != expected_result5) { - if (!double_rounding_err && Verbose > 2 && me == 0) - printf("double_err @ npes %d\n",i); - ldouble_rounding_err = double_rounding_err = 1; - } - expected_result6 *= i; - } - - shmem_barrier_all(); - - shmem_short_prod_reduce( SHMEM_TEAM_WORLD, dst0, src0, N); - shmem_int_prod_reduce( SHMEM_TEAM_WORLD, dst1, src1, N); - shmem_long_prod_reduce( SHMEM_TEAM_WORLD, dst2, src2, N); - shmem_float_prod_reduce( SHMEM_TEAM_WORLD, dst3, src3, N); - shmem_double_prod_reduce( SHMEM_TEAM_WORLD, dst4, src4, N); - shmem_longdouble_prod_reduce(SHMEM_TEAM_WORLD, dst5, src5, N); - shmem_longlong_prod_reduce( SHMEM_TEAM_WORLD, dst6, src6, N); - - if(me == 0) { - for (i = 0; i < N; i++) { - if(dst0[i] != expected_result0) ok[0] = 1; - if(dst1[i] != expected_result1) ok[1] = 1; - if(dst2[i] != expected_result2) ok[2] = 1; - - /* check for overflow */ - if(!float_rounding_err && dst3[i] != expected_result3) { ok[3] = 1; - printf("dst3[%d]: %f, expected val: %f\n",i, dst3[i], expected_result3); - } - if(!double_rounding_err && dst4[i] != expected_result4) {ok[4] = 1; - printf("dst4[%d]: %f, expected val: %f\n",i, dst4[i], expected_result4); - } - if(!ldouble_rounding_err && dst5[i] != expected_result5) {ok[5] = 1; - printf("dst5[%d]: %Lf, expected val: %Lf T4 %f\n",i, dst5[i], expected_result5,dst4[i]); - } - if(dst6[i] != expected_result6) ok[6] = 1; - } - - if(ok[0]==1) - printf("Reduction operation shmem_short_prod_reduce: Failed\n"); - else { - Vprintf("Reduction operation shmem_short_prod_reduce: Passed\n"); - pass++; - } - - if(ok[1]==1) - printf("Reduction operation shmem_int_prod_reduce: Failed\n"); - else { - Vprintf("Reduction operation shmem_int_prod_reduce: Passed\n"); - pass++; - } - - if(ok[2]==1) - printf("Reduction operation shmem_long_prod_reduce: Failed\n"); - else { - Vprintf("Reduction operation shmem_long_prod_reduce: Passed\n"); - pass++; - } - - if(ok[3]==1) - printf("Reduction operation shmem_float_prod_reduce: Failed\n"); - else { - if (float_rounding_err) { - Vprintf("Reduction operation shmem_float_prod_reduce: skipped due to float rounding error\n"); - } - else { - Vprintf("Reduction operation shmem_float_prod_reduce: Passed\n"); - } - pass++; - } - - if(ok[4]==1) - printf("Reduction operation shmem_double_prod_reduce: Failed\n"); - else { - if (double_rounding_err) { - Vprintf("Reduction operation shmem_double_prod_reduce: skipped due to double rounding error\n"); - } - else { - Vprintf("Reduction operation shmem_double_prod_reduce: Passed\n"); - } - pass++; - } - - if(ok[5]==1) - printf("Reduction operation shmem_longdouble_prod_reduce: Failed\n"); - else { - if (double_rounding_err) { - Vprintf("Reduction operation shmem_longdouble_prod_reduce: skipped due to long double rounding error\n"); - } - else { - Vprintf("Reduction operation shmem_longdouble_prod_reduce: Passed\n"); - } - pass++; - } - - if(ok[6]==1) - printf("Reduction operation shmem_longlong_prod_reduce: Failed\n"); - else { - Vprintf("Reduction operation shmem_longlong_prod_reduce: Passed\n"); - pass++; - } - Vprintf("\n"); - } - if (Serialize) shmem_barrier_all(); - - return (pass == 7 ? 1 : 0); -} - - -int -and_reduce(int me, int num_pes) -{ - int i, pass=0; - - memset(ok,0,sizeof(ok)); - - for (i = 0; i < N; i++) { - src0[i] = src1[i] = src2[i] = src6[i] = me; - dst0[i] = dst1[i] = dst2[i] = dst6[i] = -9; - } - - shmem_barrier_all(); - - shmem_ushort_and_reduce( SHMEM_TEAM_WORLD, dst7, src7, N); - shmem_uint_and_reduce( SHMEM_TEAM_WORLD, dst8, src8, N); - shmem_ulong_and_reduce( SHMEM_TEAM_WORLD, dst9, src9, N); - shmem_ulonglong_and_reduce(SHMEM_TEAM_WORLD, dst10, src10, N); - - if (me==0) { - for (i = 0; i < N; i++) { - if(dst7[i] != 0) ok[0] = 1; - if(dst8[i] != 0) ok[1] = 1; - if(dst9[i] != 0) ok[2] = 1; - if(dst10[i] != 0) ok[3] = 1; - } - - if(ok[0]==1){ - printf("Reduction operation shmem_ushort_and_reduce: Failed\n"); - } - else{ - Vprintf("Reduction operation shmem_ushort_and_reduce: Passed\n"); - pass++; - } - if(ok[1]==1){ - printf("Reduction operation shmem_uint_and_reduce: Failed\n"); - } - else{ - Vprintf("Reduction operation shmem_uint_and_reduce: Passed\n"); - pass++; - } - if(ok[2]==1){ - printf("Reduction operation shmem_ulong_and_reduce: Failed\n"); - } - else{ - Vprintf("Reduction operation shmem_ulong_and_reduce: Passed\n"); - pass++; - } - if(ok[3]==1){ - printf("Reduction operation shmem_ulonglong_and_reduce: Failed\n"); - } - else{ - Vprintf("Reduction operation shmem_ulonglong_and_reduce: Passed\n"); - pass++; - } - Vprintf("\n"); fflush(stdout); - } - if (Serialize) shmem_barrier_all(); - - return (pass == 4 ? 1 : 0); -} - - -int -or_reduce(int me, int npes) -{ - int i, pass=0; - - memset(ok,0,sizeof(ok)); - - for (i = 0; i < N; i++) { - src7[i] = src8[i] = src9[i] = src10[i] = (me + 1)%4; - dst7[i] = -9; - dst8[i] = -9; - dst9[i] = -9; - dst10[i] = -9; - } - - shmem_barrier_all(); - - shmem_ushort_or_reduce( SHMEM_TEAM_WORLD, dst7, src7, N); - shmem_uint_or_reduce( SHMEM_TEAM_WORLD, dst8, src8, N); - shmem_ulong_or_reduce( SHMEM_TEAM_WORLD, dst9, src9, N); - shmem_ulonglong_or_reduce(SHMEM_TEAM_WORLD, dst10, src10, N); - - if (me==0) { - for (i = 0; i < N; i++) { - int expected = (npes == 1) ? 1 : 3; - - if(dst7[i] != expected) ok[0] = 1; - if(dst8[i] != expected) ok[1] = 1; - if(dst9[i] != expected) ok[2] = 1; - if(dst10[i] != expected) ok[6] = 1; - } - - if(ok[0]==1) - printf("Reduction operation shmem_ushort_or_reduce: Failed\n"); - else { - Vprintf("Reduction operation shmem_ushort_or_reduce: Passed\n"); - pass++; - } - - if(ok[1]==1) - printf("Reduction operation shmem_uint_or_reduce: Failed\n"); - else { - Vprintf("Reduction operation shmem_uint_or_reduce: Passed\n"); - pass++; - } - - if(ok[2]==1) - printf("Reduction operation shmem_ulong_or_reduce: Failed\n"); - else { - Vprintf("Reduction operation shmem_ulong_or_reduce: Passed\n"); - pass++; - } - - if(ok[6]==1) - printf("Reduction operation shmem_ulonglong_or_reduce: Failed\n"); - else { - Vprintf("Reduction operation shmem_ulonglong_or_reduce: Passed\n"); - pass++; - } - Vprintf("\n"); - } - if (Serialize) shmem_barrier_all(); - - return (pass == 4 ? 1 : 0); -} - - -int -xor_reduce(int me, int npes) -{ - int i, pass=0; - int expected_result = ((int)(npes/2) % 2); - - memset(ok,0,sizeof(ok)); - - for (i = 0; i < N; i++) { - src7[i] = src8[i] = src9[i] = src10[i] = me%2; - dst7[i] = -9; - dst8[i] = -9; - dst9[i] = -9; - dst10[i] = -9; - } - - shmem_barrier_all(); - - shmem_ushort_xor_reduce( SHMEM_TEAM_WORLD, dst7, src7, N); - shmem_uint_xor_reduce( SHMEM_TEAM_WORLD, dst8, src8, N); - shmem_ulong_xor_reduce( SHMEM_TEAM_WORLD, dst9, src9, N); - shmem_ulonglong_xor_reduce(SHMEM_TEAM_WORLD, dst10, src10, N); - - if (me==0) { - for (i = 0; i < N; i++) { - if(dst7[i] != expected_result) ok[0] = 1; - if(dst8[i] != expected_result) ok[1] = 1; - if(dst9[i] != expected_result) ok[2] = 1; - if(dst10[i] != expected_result) ok[6] = 1; - } - - if(ok[0]==1) - printf("Reduction operation shmem_ushort_xor_reduce: Failed\n"); - else { - Vprintf("Reduction operation shmem_ushort_xor_reduce: Passed\n"); - pass++; - } - - if(ok[1]==1) - printf("Reduction operation shmem_uint_xor_reduce: Failed\n"); - else { - Vprintf("Reduction operation shmem_uint_xor_reduce: Passed\n"); - pass++; - } - - if(ok[2]==1) - printf("Reduction operation shmem_ulong_xor_reduce: Failed\n"); - else { - Vprintf("Reduction operation shmem_ulong_xor_reduce: Passed\n"); - pass++; - } - - if(ok[6]==1) - printf("Reduction operation shmem_ulonglong_xor_reduce: Failed\n"); - else { - Vprintf("Reduction operation shmem_ulonglong_xor_reduce: Passed\n"); - pass++; - } - - Vprintf("\n"); - } - if (Serialize) shmem_barrier_all(); - - return (pass == 4 ? 1 : 0); -} - - -int -main(int argc, char* argv[]) -{ - int c, mype, num_pes, tests, passed; - char *pgm; - - shmem_init(); - mype = shmem_my_pe(); - num_pes = shmem_n_pes(); - - if ((pgm=strrchr(argv[0],'/'))) { - pgm++; - } else { - pgm = argv[0]; - } - - while((c=getopt(argc,argv,"ampsSoxhv")) != -1) { - switch(c) { - case 'a': - And++; // do not run and_reduce - break; - case 'm': - Min++; // do not run min_reduce - break; - case 'o': - Or++; // do not run or_reduce - break; - case 'p': - Prod++; // do not run prod_reduce - break; - case 's': - Sum++; // do not run sum_reduce - break; - case 'x': - Xor++; // do not run xor_reduce - break; - case 'S': - Serialize++; - break; - case 'v': - Verbose++; - break; - case 'h': - default: - Rfprintf(stderr,"usage: %s {-v(verbose)|h(help)}\n",pgm); - shmem_finalize(); - return 1; - } - } - - tests = passed = 0; - - shmem_barrier_all(); - - passed += max_reduce(mype, num_pes); - tests++; - - if (!Min) { - passed += min_reduce(mype, num_pes); - tests++; - } - - if (!Sum) { - passed += sum_reduce(mype, num_pes); - tests++; - } - - if (!And) { - passed += and_reduce(mype, num_pes); - tests++; - } - - if (!Prod) { - passed += prod_reduce(mype, num_pes); - tests++; - } - - if (!Or) { - passed += or_reduce(mype, num_pes); - tests++; - } - - if (!Xor) { - passed += xor_reduce(mype, num_pes); - tests++; - } - - c = 0; - if (mype == 0) { - if ((Verbose || tests != passed)) - fprintf(stderr,"to_all[%d] %d of %d tests passed\n", - mype,passed,tests); - c = (tests == passed ? 0 : 1); - } - - shmem_finalize(); - - return c; -} diff --git a/test/unit/waituntil.c b/test/unit/waituntil.c deleted file mode 100644 index ca52c3cd9..000000000 --- a/test/unit/waituntil.c +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright 2011 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government - * retains certain rights in this software. - * - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - * exercise shmem_short_wait() and shmem_short_wait_until() functions. - */ - -#include -#include -#include -#include - -#include - -#define DataType long - -#define SHM_PUT shmem_long_put -#define SHM_PUTP shmem_long_p -#define SHM_GETP shmem_long_g - -#define SHM_WAITU shmem_long_wait_until -#define PF "%ld" - -#define Vprintf if (Verbose) printf - -int -main(int argc, char* argv[]) -{ - DataType source[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; - static DataType target[10]; - static DataType pong=666; - DataType *t2=NULL; - int me, num_pes, pe, Verbose=0; - - if (argc > 1 && (strcmp(argv[1],"-v") == 0)) { - Verbose++; - } - - shmem_init(); - me = shmem_my_pe(); - num_pes = shmem_n_pes(); - - if (num_pes == 1) { - printf("%s: Requires number of PEs > 1\n", argv[0]); - shmem_finalize(); - return 0; - } - - t2 = shmem_malloc(10*sizeof(DataType)); - if (!t2) { - if (me==0) printf("shmem_malloc() failed?\n"); - shmem_global_exit(1); - } - t2[9] = target[9] = 0xFF; - - shmem_barrier_all(); - - if (me == 0) { - DataType zeros[10]; - memset(zeros, 0, sizeof(zeros)); - for(pe=1; pe < num_pes; pe++) - SHM_PUT(target, zeros, 10, pe); - - shmem_fence(); - - for(pe=1; pe < num_pes; pe++) /* put 10 elements into target on PE 1 */ - SHM_PUT(target, source, 10, pe); - - SHM_WAITU( &pong, SHMEM_CMP_GT, 666 ); - Vprintf("PE[%d] pong now "PF"\n",me,pong); - - for(pe=1; pe < num_pes; pe++) /* put 1 element into t2 on PE 1 */ - SHM_PUTP(&t2[9], 0xDD, pe); - } - else { - /* wait for 10th element write of 'target' */ - SHM_WAITU( &target[9], SHMEM_CMP_NE, 0xFF ); - Vprintf("PE[%d] target[9] was 255 now "PF", success.\n",me,target[9]); - - SHM_WAITU( &target[9], SHMEM_CMP_EQ, 10 ); - Vprintf("PE[%d] expected target[9] == 10 now "PF"\n",me,target[9]); - - if (me == 1) { - if (Verbose) { - DataType tmp = SHM_GETP( &pong, 0); - printf("PE[%d] @ PE[0] pong == "PF", setting to 999\n",me,tmp); - } - SHM_PUTP( &pong, 999, 0); - } - - SHM_WAITU( &t2[9], SHMEM_CMP_NE, 0xFF ); - } - - //shmem_barrier_all(); /* sync sender and receiver */ - - if (me != 0) { - if (memcmp(source, target, sizeof(DataType) * 10) != 0) { - int i; - fprintf(stderr,"[%d] Src & Target mismatch?\n",me); - for (i = 0 ; i < 10 ; ++i) { - printf(PF","PF" ", source[i], target[i]); - } - printf("\n"); - shmem_global_exit(1); - } - } - shmem_free(t2); - - if (Verbose) - fprintf(stderr,"[%d] exit\n",shmem_my_pe()); - - shmem_finalize(); - return 0; -} diff --git a/test/unit/web.c b/test/unit/web.c deleted file mode 100644 index 4a0e87e71..000000000 --- a/test/unit/web.c +++ /dev/null @@ -1,236 +0,0 @@ -/* - * Copyright (c) 2017 Intel Corporation. All rights reserved. - * This software is available to you under the BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include -#include - -#define CHECK_ASSERT(cond) do { \ - if (!(cond)) { \ - fprintf(stderr, "[%d] Assertion failed: %s\n", shmem_my_pe(), #cond); \ - shmem_global_exit(10); \ - } \ - } while(0) - -#define CHECK_ERROR(num,...) do { \ - if((num)) { \ - fprintf(stderr,__VA_ARGS__); \ - return (num); \ - } \ - } while(0) - -#define NUM_UNSAFE_CTX 10 -#define NUM_CONTEXTS 20 - -typedef struct { - int idx; - unsigned seed; - long received; - long can_send; - long rec_val; - long send_val; - int stride; -} channel; - -shmem_ctx_t contexts[NUM_CONTEXTS]; -int ctx_is_safe[NUM_CONTEXTS]; -pthread_mutex_t ctx_locks[NUM_CONTEXTS]; -channel* channels; -int me,n_pes,n_threads; -int max_steps; - -// naive LCM of 1..numPes -static int get_max_steps(int numPes) { - int i; - int ret = 0; - int done = 0; - while(!done) { - ++ret; - done = 1; - for(i = 1; i < numPes; ++i) { - if((ret*i)%numPes != 0) { - done = 0; - break; - } - } - } - - return ret; -} - -static void* runchannel(void* chan) { - channel *c = chan; - int nextpe = (me + c->stride)%n_pes; - int prevpe = (me + n_pes - c->stride)%n_pes; - int i; - - /* printf("[%d:%d] prevpe = %d, nextpe = %d\n",me,c->idx,prevpe, nextpe); */ - - for(i = 0; i < max_steps; ++i) { - unsigned ctxind = ((unsigned)rand_r(&c->seed))%NUM_CONTEXTS; - /* printf("[%d:%d] %d\n",me,c->idx,ctxind); */ - int safe = ctx_is_safe[ctxind]; - if(!safe) { - pthread_mutex_lock(&ctx_locks[ctxind]); - } - shmem_ctx_long_p(contexts[ctxind],&c->can_send,1L,prevpe); - if(!safe) { - pthread_mutex_unlock(&ctx_locks[ctxind]); - } - - shmem_wait_until(&c->can_send,SHMEM_CMP_NE,0L); - c->can_send = 0; - - ctxind = ((unsigned)rand_r(&c->seed))%NUM_CONTEXTS; - safe = ctx_is_safe[ctxind]; - - if(!safe) { - pthread_mutex_lock(&ctx_locks[ctxind]); - } - shmem_ctx_long_p(contexts[ctxind],&c->rec_val,c->send_val,nextpe); - shmem_ctx_fence(contexts[ctxind]); - shmem_ctx_long_p(contexts[ctxind],&c->received,1L,nextpe); - if(!safe) { - pthread_mutex_unlock(&ctx_locks[ctxind]); - } - - shmem_wait_until(&c->received,SHMEM_CMP_NE,0L); - c->received = 0; - c->send_val = c->rec_val; - } - - /* printf("[%d:%d] done\n",me,c->idx); */ - - return 0; -} - -int main(int argc, char* argv[]) { - int i; - for(i = 0; i < NUM_CONTEXTS; ++i) { - int err; - err = pthread_mutex_init(&ctx_locks[i],NULL); - if (err) { - perror("Mutex initialization failed"); - return 1; - } - } - - int err, tl, ret; - int errors = 0; - - ret = shmem_init_thread(SHMEM_THREAD_MULTIPLE, &tl); - - if (tl != SHMEM_THREAD_MULTIPLE || ret != 0) { - printf("Init failed (requested thread level %d, got %d, ret %d)\n", - SHMEM_THREAD_MULTIPLE, tl, ret); - - if (ret == 0) { - shmem_global_exit(1); - } else { - return ret; - } - } - - n_pes = shmem_n_pes(); - me = shmem_my_pe(); - - if (n_pes < 2) { - if (me == 0) - printf("web: Requires 2 or more PEs\n"); - shmem_finalize(); - return 0; - } - - srand(1+me); - - n_threads = 4; - channels = shmem_malloc(n_threads*sizeof(channel)); - memset(channels,0,n_threads*sizeof(channel)); - - long* vals = malloc(sizeof(long)*n_threads); - for(i = 0; i < n_threads; ++i) { - channels[i].idx = i; - channels[i].received = 0; - channels[i].can_send = 0; - channels[i].rec_val = 0; - channels[i].send_val = vals[i] = rand(); - - channels[i].stride = (i)%(n_pes-1) + 1; - channels[i].seed = 1 + rand() + i; - } - - max_steps = get_max_steps(n_pes); - - for(i = 0; i < NUM_CONTEXTS; ++i) { - ctx_is_safe[i] = (i >= NUM_UNSAFE_CTX); - err = shmem_ctx_create(ctx_is_safe[i] ? 0 : SHMEM_CTX_SERIALIZED,&contexts[i]); - if (err) contexts[i] = SHMEM_CTX_DEFAULT; - } - - shmem_barrier_all(); - - pthread_t* threads = calloc(sizeof(pthread_t),n_threads); - for(i = 0; i < n_threads; ++i) { - int err; - err = pthread_create(&threads[i],NULL,runchannel,&channels[i]); - CHECK_ASSERT(0 == err); - } - - for (i = 0; i < n_threads; i++) { - int err; - err = pthread_join(threads[i], NULL); - CHECK_ASSERT(0 == err); - } - free(threads); - - for(i = 0; i < NUM_CONTEXTS; ++i) { - shmem_ctx_quiet(contexts[i]); - if (contexts[i] != SHMEM_CTX_DEFAULT) shmem_ctx_destroy(contexts[i]); - int err; - err = pthread_mutex_destroy(&ctx_locks[i]); - CHECK_ASSERT(!err); - } - - for(i = 0; i < n_threads; ++i) { - if(vals[i] != channels[i].rec_val) { - ++errors; - fprintf(stderr, - "PE %d, Thread %d (stride %d): got %ld, expected %ld\n", - me,i,channels[i].stride,channels[i].rec_val,vals[i]); - } - } - shmem_free(channels); - free(vals); - - shmem_finalize(); - - return errors; -} - diff --git a/test/unit/zero_comm.c b/test/unit/zero_comm.c deleted file mode 100644 index 0374f3943..000000000 --- a/test/unit/zero_comm.c +++ /dev/null @@ -1,18 +0,0 @@ -#include -#include - -int main(void) { - shmem_init(); - - shmem_putmem(NULL, NULL, 0, 0); - shmem_getmem(NULL, NULL, 0, 0); - - shmem_putmem_nbi(NULL, NULL, 0, 0); - shmem_getmem_nbi(NULL, NULL, 0, 0); - - shmem_int_iget(NULL, NULL, 1, 1, 0, 0); - shmem_int_iput(NULL, NULL, 1, 1, 0, 0); - - shmem_finalize(); - return 0; -}