diff --git a/test/shmemx/Makefile.am b/test/shmemx/Makefile.am index 98c0e67..49e0db5 100644 --- a/test/shmemx/Makefile.am +++ b/test/shmemx/Makefile.am @@ -38,6 +38,27 @@ check_PROGRAMS += \ 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 @@ -65,4 +86,23 @@ gettid_register_LDFLAGS = $(AM_LDFLAGS) $(PTHREAD_LIBS) gettid_register_CFLAGS = $(PTHREAD_CFLAGS) gettid_register_LDADD = $(LDADD) $(PTHREAD_CFLAGS) +AM_CPPFLAGS += -DENABLE_SHMEMX_TESTS + +# 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 new file mode 100644 index 0000000..3c8f73d --- /dev/null +++ b/test/shmemx/cxx_test_shmem_atomic_add.cpp @@ -0,0 +1,251 @@ +/* + * 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 + +#ifdef ENABLE_SHMEMX_TESTS +#include +#endif + +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 + +#ifdef ENABLE_SHMEMX_TESTS +#define SHMEMX_NBI_OPS_CASES(OP, TYPE) \ + case ATOMIC_FETCH_ADD_NBI: \ + shmemx_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: \ + shmemx_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; +#else +#define SHMEMX_NBI_OPS_CASES(OP, TYPE) +#endif + +#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; \ + SHMEMX_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); + +#ifdef ENABLE_SHMEMX_TESTS + 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); +#endif + + shmem_finalize(); + return rc; +} diff --git a/test/shmemx/cxx_test_shmem_atomic_and.cpp b/test/shmemx/cxx_test_shmem_atomic_and.cpp new file mode 100644 index 0000000..d84cce7 --- /dev/null +++ b/test/shmemx/cxx_test_shmem_atomic_and.cpp @@ -0,0 +1,179 @@ +/* + * 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 + +#ifdef ENABLE_SHMEMX_TESTS +#include +#endif + +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. + */ + +#ifdef ENABLE_SHMEMX_TESTS +#define SHMEMX_NBI_OPS_CASES(OP, TYPE) \ + case FETCH_AND_NBI: \ + shmemx_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: \ + shmemx_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; +#else +#define SHMEMX_NBI_OPS_CASES(OP, TYPE) +#endif + +#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; \ + SHMEMX_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); + +#ifdef ENABLE_SHMEMX_TESTS + 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); +#endif + + shmem_finalize(); + return rc; +} diff --git a/test/shmemx/cxx_test_shmem_atomic_cswap.cpp b/test/shmemx/cxx_test_shmem_atomic_cswap.cpp new file mode 100644 index 0000000..d81c4d4 --- /dev/null +++ b/test/shmemx/cxx_test_shmem_atomic_cswap.cpp @@ -0,0 +1,184 @@ +/* + * 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 + +#ifdef ENABLE_SHMEMX_TESTS +#include +#endif + +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 + +#ifdef ENABLE_SHMEMX_TESTS +#define SHMEMX_NBI_OPS_CASES(OP, TYPE) \ + case ATOMIC_COMPARE_SWAP_NBI: \ + shmemx_atomic_compare_swap_nbi(&old, &remote, (TYPE)npes, \ + (TYPE)mype, (mype + 1) % npes); \ + break; \ + case CTX_ATOMIC_COMPARE_SWAP_NBI: \ + shmemx_atomic_compare_swap_nbi(SHMEM_CTX_DEFAULT, &old, &remote, \ + (TYPE)npes, (TYPE)mype, \ + (mype + 1) % npes); \ + break; +#else +#define SHMEMX_NBI_OPS_CASES(OP, TYPE) +#endif + +#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; \ + SHMEMX_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); + +#ifdef ENABLE_SHMEMX_TESTS + 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); +#endif + + shmem_finalize(); + return rc; +} diff --git a/test/shmemx/cxx_test_shmem_atomic_fetch.cpp b/test/shmemx/cxx_test_shmem_atomic_fetch.cpp new file mode 100644 index 0000000..41c6700 --- /dev/null +++ b/test/shmemx/cxx_test_shmem_atomic_fetch.cpp @@ -0,0 +1,185 @@ +/* + * 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 + +#ifdef ENABLE_SHMEMX_TESTS +#include +#endif + +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 + +#ifdef ENABLE_SHMEMX_TESTS +#define SHMEMX_NBI_OPS_CASES(OP, TYPE) \ + case ATOMIC_FETCH_NBI: \ + shmemx_atomic_fetch_nbi(&val, &remote, \ + (mype + 1) % npes); \ + shmem_quiet(); \ + break; \ + case CTX_ATOMIC_FETCH_NBI: \ + shmemx_atomic_fetch_nbi(SHMEM_CTX_DEFAULT, &val, \ + &remote, (mype + 1) % npes); \ + shmem_quiet(); \ + break; +#else +#define SHMEMX_NBI_OPS_CASES(OP, TYPE) +#endif + +#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; \ + SHMEMX_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); + +#ifdef ENABLE_SHMEMX_TESTS + 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); +#endif + + shmem_finalize(); + return rc; +} diff --git a/test/shmemx/cxx_test_shmem_atomic_inc.cpp b/test/shmemx/cxx_test_shmem_atomic_inc.cpp new file mode 100644 index 0000000..ecd6422 --- /dev/null +++ b/test/shmemx/cxx_test_shmem_atomic_inc.cpp @@ -0,0 +1,251 @@ +/* + * 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 + +#ifdef ENABLE_SHMEMX_TESTS +#include +#endif + +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 + +#ifdef ENABLE_SHMEMX_TESTS +#define SHMEMX_NBI_OPS_CASES(OP, TYPE) \ + case ATOMIC_FETCH_INC_NBI: \ + shmemx_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: \ + shmemx_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; +#else +#define SHMEMX_NBI_OPS_CASES(OP, TYPE) +#endif + +#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; \ + SHMEMX_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); + +#ifdef ENABLE_SHMEMX_TESTS + 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); +#endif + + shmem_finalize(); + return rc; +} diff --git a/test/shmemx/cxx_test_shmem_atomic_or.cpp b/test/shmemx/cxx_test_shmem_atomic_or.cpp new file mode 100644 index 0000000..5463f02 --- /dev/null +++ b/test/shmemx/cxx_test_shmem_atomic_or.cpp @@ -0,0 +1,181 @@ +/* + * 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 + +#ifdef ENABLE_SHMEMX_TESTS +#include +#endif + +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. + */ + +#ifdef ENABLE_SHMEMX_TESTS +#define SHMEMX_NBI_OPS_CASES(OP, TYPE) \ + case FETCH_OR_NBI: \ + shmemx_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: \ + shmemx_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; +#else +#define SHMEMX_NBI_OPS_CASES(OP, TYPE) +#endif + +#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; \ + SHMEMX_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); + +#ifdef ENABLE_SHMEMX_TESTS + 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); +#endif + + shmem_finalize(); + return rc; +} diff --git a/test/shmemx/cxx_test_shmem_atomic_set.cpp b/test/shmemx/cxx_test_shmem_atomic_set.cpp new file mode 100644 index 0000000..9cb1507 --- /dev/null +++ b/test/shmemx/cxx_test_shmem_atomic_set.cpp @@ -0,0 +1,129 @@ +/* + * 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 new file mode 100644 index 0000000..ef9e278 --- /dev/null +++ b/test/shmemx/cxx_test_shmem_atomic_swap.cpp @@ -0,0 +1,190 @@ +/* + * 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 + +#ifdef ENABLE_SHMEMX_TESTS +#include +#endif + +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 + +#ifdef ENABLE_SHMEMX_TESTS +#define SHMEMX_NBI_OPS_CASES(OP, TYPE) \ + case ATOMIC_SWAP_NBI: \ + shmemx_atomic_swap_nbi(&old, &remote, \ + (TYPE)mype, (mype + 1) % npes); \ + break; \ + case CTX_ATOMIC_SWAP_NBI: \ + shmemx_atomic_swap_nbi(SHMEM_CTX_DEFAULT, &old, &remote, \ + (TYPE)mype, (mype + 1) % npes); \ + break; +#else +#define SHMEMX_NBI_OPS_CASES(OP, TYPE) +#endif + +#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; \ + SHMEMX_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); + +#ifdef ENABLE_SHMEMX_TESTS + 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); +#endif + + shmem_finalize(); + return rc; +} diff --git a/test/shmemx/cxx_test_shmem_atomic_xor.cpp b/test/shmemx/cxx_test_shmem_atomic_xor.cpp new file mode 100644 index 0000000..6d5144d --- /dev/null +++ b/test/shmemx/cxx_test_shmem_atomic_xor.cpp @@ -0,0 +1,179 @@ +/* + * 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 + +#ifdef ENABLE_SHMEMX_TESTS +#include +#endif + +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. + */ + +#ifdef ENABLE_SHMEMX_TESTS +#define SHMEMX_NBI_OPS_CASES(OP, TYPE) \ + case FETCH_XOR_NBI: \ + shmemx_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: \ + shmemx_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; +#else +#define SHMEMX_NBI_OPS_CASES(OP, TYPE) +#endif + +#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; \ + SHMEMX_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); + +#ifdef ENABLE_SHMEMX_TESTS + 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); +#endif + + shmem_finalize(); + return rc; +} diff --git a/test/shmemx/cxx_test_shmem_g.cpp b/test/shmemx/cxx_test_shmem_g.cpp new file mode 100644 index 0000000..a7912a7 --- /dev/null +++ b/test/shmemx/cxx_test_shmem_g.cpp @@ -0,0 +1,115 @@ +/* + * 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 new file mode 100644 index 0000000..437c279 --- /dev/null +++ b/test/shmemx/cxx_test_shmem_get.cpp @@ -0,0 +1,239 @@ +/* + * 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 new file mode 100644 index 0000000..9dfbd7e --- /dev/null +++ b/test/shmemx/cxx_test_shmem_p.cpp @@ -0,0 +1,113 @@ +/* + * 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 new file mode 100644 index 0000000..196df8d --- /dev/null +++ b/test/shmemx/cxx_test_shmem_put.cpp @@ -0,0 +1,239 @@ +/* + * 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 new file mode 100644 index 0000000..8c90199 --- /dev/null +++ b/test/shmemx/cxx_test_shmem_test.cpp @@ -0,0 +1,74 @@ +/* + * 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(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/shmemx/cxx_test_shmem_wait_until.cpp b/test/shmemx/cxx_test_shmem_wait_until.cpp new file mode 100644 index 0000000..92315a6 --- /dev/null +++ b/test/shmemx/cxx_test_shmem_wait_until.cpp @@ -0,0 +1,74 @@ +/* + * 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(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/Makefile.am b/test/unit/Makefile.am index 3271fcc..2f78bcd 100644 --- a/test/unit/Makefile.am +++ b/test/unit/Makefile.am @@ -111,10 +111,7 @@ endif if HAVE_CXX check_PROGRAMS += \ - cxx_test_shmem_complex - -if SHMEMX_TESTS -check_PROGRAMS += \ + cxx_test_shmem_complex \ cxx_test_shmem_g \ cxx_test_shmem_get \ cxx_test_shmem_p \ @@ -131,7 +128,6 @@ check_PROGRAMS += \ cxx_test_shmem_wait_until \ cxx_test_shmem_test endif -endif if HAVE_FORTRAN check_PROGRAMS += \ @@ -169,10 +165,6 @@ LOG_COMPILER = $(TEST_RUNNER) AM_LDFLAGS = $(LIBTOOL_WRAPPER_LDFLAGS) -if SHMEMX_TESTS -AM_CFLAGS = -DENABLE_SHMEMX_TESTS -endif - if EXTERNAL_TESTS bin_PROGRAMS = $(check_PROGRAMS) AM_CPPFLAGS = -I$(top_srcdir)/test/include @@ -188,6 +180,11 @@ 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 + # C Tests with special flags rma_coverage_pshmem_SOURCES = rma_coverage.c rma_coverage_pshmem_CFLAGS = -DTEST_PSHMEM diff --git a/test/unit/cxx_test_shmem_atomic_add.cpp b/test/unit/cxx_test_shmem_atomic_add.cpp index 3c8f73d..96e673a 100644 --- a/test/unit/cxx_test_shmem_atomic_add.cpp +++ b/test/unit/cxx_test_shmem_atomic_add.cpp @@ -44,17 +44,18 @@ 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 +#define DEPRECATED_ADD(TYPENAME, ...) shmem_##TYPENAME##_add(__VA_ARGS__) +#define DEPRECATED_FADD(TYPENAME, ...) shmem_##TYPENAME##_fadd(__VA_ARGS__) #else -#define DEPRECATED_ADD shmem_atomic_add -#define DEPRECATED_FADD shmem_atomic_fetch_add +#define DEPRECATED_ADD(TYPENAME, ...) shmem_##TYPENAME##_atomic_add(__VA_ARGS__) +#define DEPRECATED_FADD(TYPENAME, ...) shmem_##TYPENAME##_atomic_fetch_add(__VA_ARGS__) #endif #ifdef ENABLE_SHMEMX_TESTS -#define SHMEMX_NBI_OPS_CASES(OP, TYPE) \ +#define SHMEMX_NBI_OPS_CASES(OP, TYPE, TYPENAME) \ case ATOMIC_FETCH_ADD_NBI: \ - shmemx_atomic_fetch_add_nbi(&old, &remote, (TYPE)(mype + 1), i); \ + shmemx_##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", \ @@ -63,8 +64,8 @@ enum op { ADD = 0, ATOMIC_ADD, CTX_ATOMIC_ADD, FADD, ATOMIC_FETCH_ADD, } \ break; \ case CTX_ATOMIC_FETCH_ADD_NBI: \ - shmemx_atomic_fetch_add_nbi(SHMEM_CTX_DEFAULT, &old, &remote, \ - (TYPE)(mype + 1), i); \ + shmemx_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", \ @@ -73,10 +74,10 @@ enum op { ADD = 0, ATOMIC_ADD, CTX_ATOMIC_ADD, FADD, ATOMIC_FETCH_ADD, } \ break; #else -#define SHMEMX_NBI_OPS_CASES(OP, TYPE) +#define SHMEMX_NBI_OPS_CASES(OP, TYPE, TYPENAME) #endif -#define TEST_SHMEM_ADD(OP, TYPE) \ +#define TEST_SHMEM_ADD(OP, TYPE, TYPENAME) \ do { \ static TYPE remote; \ TYPE old; \ @@ -87,16 +88,17 @@ enum op { ADD = 0, ATOMIC_ADD, CTX_ATOMIC_ADD, FADD, ATOMIC_FETCH_ADD, for (int i = 0; i < npes; i++) \ switch (OP) { \ case ADD: \ - DEPRECATED_ADD(&remote, (TYPE)(mype + 1), i); \ + DEPRECATED_ADD(TYPENAME, &remote, (TYPE)(mype + 1), i); \ break; \ case ATOMIC_ADD: \ - shmem_atomic_add(&remote, (TYPE)(mype + 1), i); \ + shmem_##TYPENAME##_atomic_add(&remote, (TYPE)(mype + 1), i); \ break; \ case CTX_ATOMIC_ADD: \ - shmem_atomic_add(SHMEM_CTX_DEFAULT, &remote, (TYPE)(mype + 1), i); \ + shmem_ctx_##TYPENAME##_atomic_add(SHMEM_CTX_DEFAULT, &remote, \ + (TYPE)(mype + 1), i); \ break; \ case FADD: \ - old = DEPRECATED_FADD(&remote, (TYPE)(mype + 1), i); \ + 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); \ @@ -104,7 +106,8 @@ enum op { ADD = 0, ATOMIC_ADD, CTX_ATOMIC_ADD, FADD, ATOMIC_FETCH_ADD, } \ break; \ case ATOMIC_FETCH_ADD: \ - old = shmem_atomic_fetch_add(&remote, (TYPE)(mype + 1), i); \ + 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); \ @@ -112,14 +115,15 @@ enum op { ADD = 0, ATOMIC_ADD, CTX_ATOMIC_ADD, FADD, ATOMIC_FETCH_ADD, } \ break; \ case CTX_ATOMIC_FETCH_ADD: \ - old = shmem_atomic_fetch_add(SHMEM_CTX_DEFAULT, &remote, (TYPE)(mype + 1), i); \ + 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; \ - SHMEMX_NBI_OPS_CASES(OP, TYPE) \ + SHMEMX_NBI_OPS_CASES(OP, TYPE, TYPENAME) \ default: \ printf("Invalid operation (%d)\n", OP); \ shmem_global_exit(1); \ @@ -139,111 +143,111 @@ int main(int argc, char* argv[]) { 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); + 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); #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_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(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); + + 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); #ifdef ENABLE_SHMEMX_TESTS - 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); + 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); #endif shmem_finalize(); diff --git a/test/unit/cxx_test_shmem_atomic_and.cpp b/test/unit/cxx_test_shmem_atomic_and.cpp index d84cce7..1d8550a 100644 --- a/test/unit/cxx_test_shmem_atomic_and.cpp +++ b/test/unit/cxx_test_shmem_atomic_and.cpp @@ -50,9 +50,9 @@ enum op { AND = 0, CTX_AND, FETCH_AND, CTX_FETCH_AND, FETCH_AND_NBI, */ #ifdef ENABLE_SHMEMX_TESTS -#define SHMEMX_NBI_OPS_CASES(OP, TYPE) \ +#define SHMEMX_NBI_OPS_CASES(OP, TYPE, TYPENAME) \ case FETCH_AND_NBI: \ - shmemx_atomic_fetch_and_nbi(&old, &remote, \ + shmemx_##TYPENAME##_atomic_fetch_and_nbi(&old, &remote, \ ~(TYPE)(1LLU << mype), i); \ shmem_quiet(); \ if ((old & (TYPE)(1LLU << mype)) == 0) { \ @@ -62,8 +62,8 @@ enum op { AND = 0, CTX_AND, FETCH_AND, CTX_FETCH_AND, FETCH_AND_NBI, } \ break; \ case CTX_FETCH_AND_NBI: \ - shmemx_atomic_fetch_and_nbi(SHMEM_CTX_DEFAULT, &old, &remote, \ - ~(TYPE)(1LLU << mype), i); \ + shmemx_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", \ @@ -72,26 +72,27 @@ enum op { AND = 0, CTX_AND, FETCH_AND, CTX_FETCH_AND, FETCH_AND_NBI, } \ break; #else -#define SHMEMX_NBI_OPS_CASES(OP, TYPE) +#define SHMEMX_NBI_OPS_CASES(OP, TYPE, TYPENAME) #endif -#define TEST_SHMEM_AND(OP, TYPE) \ +#define TEST_SHMEM_AND(OP, TYPE, TYPENAME) \ 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); \ + shmem_##TYPENAME##_atomic_and(&remote, \ + ~(TYPE)(1LLU << mype), i); \ break; \ case CTX_AND: \ - shmem_atomic_and(SHMEM_CTX_DEFAULT, &remote, ~(TYPE)(1LLU << mype), i); \ + shmem_ctx_##TYPENAME##_atomic_and(SHMEM_CTX_DEFAULT, &remote, \ + ~(TYPE)(1LLU << mype), i); \ break; \ case FETCH_AND: \ - old = shmem_atomic_fetch_and(&remote, ~(TYPE)(1LLU << mype), i); \ + 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); \ @@ -99,14 +100,15 @@ enum op { AND = 0, CTX_AND, FETCH_AND, CTX_FETCH_AND, FETCH_AND_NBI, } \ break; \ case CTX_FETCH_AND: \ - old = shmem_atomic_fetch_and(SHMEM_CTX_DEFAULT, &remote, ~(TYPE)(1LLU << mype), i); \ + 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; \ - SHMEMX_NBI_OPS_CASES(OP, TYPE) \ + SHMEMX_NBI_OPS_CASES(OP, TYPE, TYPENAME) \ default: \ printf("Invalid operation (%d)\n", OP); \ shmem_global_exit(1); \ @@ -123,57 +125,59 @@ enum op { AND = 0, CTX_AND, FETCH_AND, CTX_FETCH_AND, FETCH_AND_NBI, 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); - 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(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); - 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(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); - 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(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); - 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(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); #ifdef ENABLE_SHMEMX_TESTS - 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(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); - 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); + 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); #endif - shmem_finalize(); return rc; } diff --git a/test/unit/cxx_test_shmem_atomic_cswap.cpp b/test/unit/cxx_test_shmem_atomic_cswap.cpp index d81c4d4..0a3983c 100644 --- a/test/unit/cxx_test_shmem_atomic_cswap.cpp +++ b/test/unit/cxx_test_shmem_atomic_cswap.cpp @@ -44,27 +44,26 @@ 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 +#define DEPRECATED_CSWAP(TYPENAME,...) shmem_##TYPENAME##_cswap(__VA_ARGS__) #else -#define DEPRECATED_CSWAP shmem_atomic_compare_swap +#define DEPRECATED_CSWAP(TYPENAME,...) shmem_##TYPENAME##_atomic_compare_swap(__VA_ARGS__) #endif #ifdef ENABLE_SHMEMX_TESTS -#define SHMEMX_NBI_OPS_CASES(OP, TYPE) \ +#define SHMEMX_NBI_OPS_CASES(OP, TYPE, TYPENAME) \ case ATOMIC_COMPARE_SWAP_NBI: \ - shmemx_atomic_compare_swap_nbi(&old, &remote, (TYPE)npes, \ - (TYPE)mype, (mype + 1) % npes); \ + shmemx_##TYPENAME##_atomic_compare_swap_nbi(&old, &remote, \ + (TYPE)npes, (TYPE)mype, (mype + 1) % npes); \ break; \ case CTX_ATOMIC_COMPARE_SWAP_NBI: \ - shmemx_atomic_compare_swap_nbi(SHMEM_CTX_DEFAULT, &old, &remote, \ - (TYPE)npes, (TYPE)mype, \ - (mype + 1) % npes); \ + shmemx_ctx_##TYPENAME##_atomic_compare_swap_nbi(SHMEM_CTX_DEFAULT,\ + &old, &remote, (TYPE)npes, (TYPE)mype, (mype + 1) % npes);\ break; #else -#define SHMEMX_NBI_OPS_CASES(OP, TYPE) +#define SHMEMX_NBI_OPS_CASES(OP, TYPE, TYPENAME) #endif -#define TEST_SHMEM_CSWAP(OP, TYPE) \ +#define TEST_SHMEM_CSWAP(OP, TYPE, TYPENAME) \ do { \ static TYPE remote; \ TYPE old; \ @@ -74,19 +73,20 @@ enum op { CSWAP = 0, ATOMIC_COMPARE_SWAP, CTX_ATOMIC_COMPARE_SWAP, shmem_barrier_all(); \ switch (OP) { \ case CSWAP: \ - old = DEPRECATED_CSWAP(&remote, (TYPE)npes, (TYPE)mype, \ - (mype + 1) % npes); \ + old = DEPRECATED_CSWAP(TYPENAME, &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); \ + old = shmem_##TYPENAME##_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, \ + old = shmem_ctx_##TYPENAME##_atomic_compare_swap( \ + SHMEM_CTX_DEFAULT, &remote, \ (TYPE)npes, (TYPE)mype, \ (mype + 1) % npes); \ break; \ - SHMEMX_NBI_OPS_CASES(OP, TYPE) \ + SHMEMX_NBI_OPS_CASES(OP, TYPE, TYPENAME) \ default: \ printf("invalid operation (%d)\n", OP); \ shmem_global_exit(1); \ @@ -111,72 +111,73 @@ int main(int argc, char* argv[]) { 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); + 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); - 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, 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); + #ifdef ENABLE_SHMEMX_TESTS - 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); + 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); #endif shmem_finalize(); diff --git a/test/unit/cxx_test_shmem_atomic_fetch.cpp b/test/unit/cxx_test_shmem_atomic_fetch.cpp index 41c6700..981edb3 100644 --- a/test/unit/cxx_test_shmem_atomic_fetch.cpp +++ b/test/unit/cxx_test_shmem_atomic_fetch.cpp @@ -44,28 +44,28 @@ 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 +#define DEPRECATED_FETCH(TYPENAME,...) shmem_##TYPENAME##_fetch(__VA_ARGS__) #else -#define DEPRECATED_FETCH shmem_atomic_fetch +#define DEPRECATED_FETCH(TYPENAME,...) shmem_##TYPENAME##_atomic_fetch(__VA_ARGS__) #endif #ifdef ENABLE_SHMEMX_TESTS -#define SHMEMX_NBI_OPS_CASES(OP, TYPE) \ +#define SHMEMX_NBI_OPS_CASES(OP, TYPE, TYPENAME) \ case ATOMIC_FETCH_NBI: \ - shmemx_atomic_fetch_nbi(&val, &remote, \ + shmemx_##TYPENAME##_atomic_fetch_nbi(&val, &remote, \ (mype + 1) % npes); \ shmem_quiet(); \ break; \ case CTX_ATOMIC_FETCH_NBI: \ - shmemx_atomic_fetch_nbi(SHMEM_CTX_DEFAULT, &val, \ - &remote, (mype + 1) % npes); \ + shmemx_ctx_##TYPENAME##_atomic_fetch_nbi(SHMEM_CTX_DEFAULT,\ + &val, &remote, (mype + 1) % npes); \ shmem_quiet(); \ break; #else -#define SHMEMX_NBI_OPS_CASES(OP, TYPE) +#define SHMEMX_NBI_OPS_CASES(OP, TYPE, TYPENAME) #endif -#define TEST_SHMEM_FETCH(OP, TYPE) \ +#define TEST_SHMEM_FETCH(OP, TYPE, TYPENAME) \ do { \ static TYPE remote; \ TYPE val; \ @@ -75,15 +75,18 @@ enum op { FETCH = 0, ATOMIC_FETCH, CTX_ATOMIC_FETCH, ATOMIC_FETCH_NBI, shmem_barrier_all(); \ switch (OP) { \ case FETCH: \ - val = DEPRECATED_FETCH(&remote, (mype + 1) % npes); \ + val = DEPRECATED_FETCH(TYPENAME, &remote, \ + (mype + 1) % npes); \ break; \ case ATOMIC_FETCH: \ - val = shmem_atomic_fetch(&remote, (mype + 1) % npes); \ + val = shmem_##TYPENAME##_atomic_fetch(&remote, \ + (mype + 1) % npes); \ break; \ case CTX_ATOMIC_FETCH: \ - val = shmem_atomic_fetch(SHMEM_CTX_DEFAULT, &remote, (mype + 1) % npes); \ + val = shmem_ctx_##TYPENAME##_atomic_fetch( \ + SHMEM_CTX_DEFAULT, &remote, (mype + 1) % npes); \ break; \ - SHMEMX_NBI_OPS_CASES(OP, TYPE) \ + SHMEMX_NBI_OPS_CASES(OP, TYPE, TYPENAME) \ default: \ printf("Invalid operation (%d)\n", OP); \ shmem_global_exit(1); \ @@ -102,82 +105,83 @@ int main(int argc, char* argv[]) { 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); + 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); - 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, 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); + #ifdef ENABLE_SHMEMX_TESTS - 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); + 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); #endif shmem_finalize(); diff --git a/test/unit/cxx_test_shmem_atomic_inc.cpp b/test/unit/cxx_test_shmem_atomic_inc.cpp index ecd6422..820023d 100644 --- a/test/unit/cxx_test_shmem_atomic_inc.cpp +++ b/test/unit/cxx_test_shmem_atomic_inc.cpp @@ -45,17 +45,17 @@ enum op { INC = 0, ATOMIC_INC, CTX_ATOMIC_INC, FINC, ATOMIC_FETCH_INC, CTX_ATOMIC_FETCH_INC_NBI }; #ifdef ENABLE_DEPRECATED_TESTS -#define DEPRECATED_INC shmem_inc -#define DEPRECATED_FINC shmem_finc +#define DEPRECATED_INC(TYPENAME,...) shmem_##TYPENAME##_inc(__VA_ARGS__) +#define DEPRECATED_FINC(TYPENAME,...) shmem_##TYPENAME##_finc(__VA_ARGS__) #else -#define DEPRECATED_INC shmem_atomic_inc -#define DEPRECATED_FINC shmem_atomic_fetch_inc +#define DEPRECATED_INC(TYPENAME,...) shmem_##TYPENAME##_atomic_inc(__VA_ARGS__) +#define DEPRECATED_FINC(TYPENAME,...) shmem_##TYPENAME##_atomic_fetch_inc(__VA_ARGS__) #endif #ifdef ENABLE_SHMEMX_TESTS -#define SHMEMX_NBI_OPS_CASES(OP, TYPE) \ +#define SHMEMX_NBI_OPS_CASES(OP, TYPE, TYPENAME) \ case ATOMIC_FETCH_INC_NBI: \ - shmemx_atomic_fetch_inc_nbi(&old, &remote, i); \ + shmemx_##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", \ @@ -64,7 +64,8 @@ enum op { INC = 0, ATOMIC_INC, CTX_ATOMIC_INC, FINC, ATOMIC_FETCH_INC, } \ break; \ case CTX_ATOMIC_FETCH_INC_NBI: \ - shmemx_atomic_fetch_inc_nbi(SHMEM_CTX_DEFAULT, &old, &remote, i); \ + shmemx_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", \ @@ -73,10 +74,10 @@ enum op { INC = 0, ATOMIC_INC, CTX_ATOMIC_INC, FINC, ATOMIC_FETCH_INC, } \ break; #else -#define SHMEMX_NBI_OPS_CASES(OP, TYPE) +#define SHMEMX_NBI_OPS_CASES(OP, TYPE, TYPENAME) #endif -#define TEST_SHMEM_INC(OP, TYPE) \ +#define TEST_SHMEM_INC(OP, TYPE, TYPENAME) \ do { \ static TYPE remote = (TYPE)0; \ TYPE old; \ @@ -87,16 +88,17 @@ enum op { INC = 0, ATOMIC_INC, CTX_ATOMIC_INC, FINC, ATOMIC_FETCH_INC, for (int i = 0; i < npes; i++) \ switch (OP) { \ case INC: \ - DEPRECATED_INC(&remote, i); \ + DEPRECATED_INC(TYPENAME, &remote, i); \ break; \ case ATOMIC_INC: \ - shmem_atomic_inc(&remote, i); \ + shmem_##TYPENAME##_atomic_inc(&remote, i); \ break; \ case CTX_ATOMIC_INC: \ - shmem_atomic_inc(SHMEM_CTX_DEFAULT, &remote, i); \ + shmem_ctx_##TYPENAME##_atomic_inc(SHMEM_CTX_DEFAULT, \ + &remote, i); \ break; \ case FINC: \ - old = DEPRECATED_FINC(&remote, i); \ + old = DEPRECATED_FINC(TYPENAME, &remote, i); \ if (old > (TYPE) npes) { \ printf("PE %i error inconsistent value of old (%s, %s)\n", \ mype, #OP, #TYPE); \ @@ -104,7 +106,7 @@ enum op { INC = 0, ATOMIC_INC, CTX_ATOMIC_INC, FINC, ATOMIC_FETCH_INC, } \ break; \ case ATOMIC_FETCH_INC: \ - old = shmem_atomic_fetch_inc(&remote, i); \ + 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); \ @@ -112,14 +114,15 @@ enum op { INC = 0, ATOMIC_INC, CTX_ATOMIC_INC, FINC, ATOMIC_FETCH_INC, } \ break; \ case CTX_ATOMIC_FETCH_INC: \ - old = shmem_atomic_fetch_inc(SHMEM_CTX_DEFAULT, &remote, i); \ + 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; \ - SHMEMX_NBI_OPS_CASES(OP, TYPE) \ + SHMEMX_NBI_OPS_CASES(OP, TYPE, TYPENAME) \ default: \ printf("Invalid operation (%d)\n", OP); \ shmem_global_exit(1); \ @@ -139,111 +142,111 @@ int main(int argc, char* argv[]) { 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); + 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); #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_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(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); + + 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); #ifdef ENABLE_SHMEMX_TESTS - 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); + 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); #endif shmem_finalize(); diff --git a/test/unit/cxx_test_shmem_atomic_or.cpp b/test/unit/cxx_test_shmem_atomic_or.cpp index 5463f02..cd07046 100644 --- a/test/unit/cxx_test_shmem_atomic_or.cpp +++ b/test/unit/cxx_test_shmem_atomic_or.cpp @@ -50,9 +50,9 @@ enum op { OR = 0, CTX_OR, FETCH_OR, CTX_FETCH_OR, FETCH_OR_NBI, */ #ifdef ENABLE_SHMEMX_TESTS -#define SHMEMX_NBI_OPS_CASES(OP, TYPE) \ +#define SHMEMX_NBI_OPS_CASES(OP, TYPE, TYPENAME) \ case FETCH_OR_NBI: \ - shmemx_atomic_fetch_or_nbi(&old, &remote, \ + shmemx_##TYPENAME##_atomic_fetch_or_nbi(&old, &remote, \ (TYPE)(1LLU << mype), i); \ shmem_quiet(); \ if ((old & (TYPE)(1LLU << mype)) != 0) { \ @@ -62,8 +62,8 @@ enum op { OR = 0, CTX_OR, FETCH_OR, CTX_FETCH_OR, FETCH_OR_NBI, } \ break; \ case CTX_FETCH_OR_NBI: \ - shmemx_atomic_fetch_or_nbi(SHMEM_CTX_DEFAULT, &old, &remote, \ - (TYPE)(1LLU << mype), i); \ + shmemx_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", \ @@ -72,27 +72,27 @@ enum op { OR = 0, CTX_OR, FETCH_OR, CTX_FETCH_OR, FETCH_OR_NBI, } \ break; #else -#define SHMEMX_NBI_OPS_CASES(OP, TYPE) +#define SHMEMX_NBI_OPS_CASES(OP, TYPE, TYPENAME) #endif -#define TEST_SHMEM_OR(OP, TYPE) \ +#define TEST_SHMEM_OR(OP, TYPE, TYPENAME) \ 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); \ + shmem_##TYPENAME##_atomic_or(&remote, \ + (TYPE)(1LLU << mype), i); \ break; \ case CTX_OR: \ - shmem_atomic_or(SHMEM_CTX_DEFAULT, &remote, \ - (TYPE)(1LLU << mype), i); \ + shmem_ctx_##TYPENAME##_atomic_or(SHMEM_CTX_DEFAULT, &remote, \ + (TYPE)(1LLU << mype), i); \ break; \ case FETCH_OR: \ - old = shmem_atomic_fetch_or(&remote, (TYPE)(1LLU << mype), i);\ + 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); \ @@ -100,15 +100,15 @@ enum op { OR = 0, CTX_OR, FETCH_OR, CTX_FETCH_OR, FETCH_OR_NBI, } \ break; \ case CTX_FETCH_OR: \ - old = shmem_atomic_fetch_or(SHMEM_CTX_DEFAULT, &remote, \ - (TYPE)(1LLU << mype), i); \ + 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; \ - SHMEMX_NBI_OPS_CASES(OP, TYPE) \ + SHMEMX_NBI_OPS_CASES(OP, TYPE, TYPENAME) \ default: \ printf("Invalid operation (%d)\n", OP); \ shmem_global_exit(1); \ @@ -125,55 +125,58 @@ enum op { OR = 0, CTX_OR, FETCH_OR, CTX_FETCH_OR, FETCH_OR_NBI, 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); - 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(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); #ifdef ENABLE_SHMEMX_TESTS - 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); + 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); #endif shmem_finalize(); diff --git a/test/unit/cxx_test_shmem_atomic_set.cpp b/test/unit/cxx_test_shmem_atomic_set.cpp index 9cb1507..a06ed02 100644 --- a/test/unit/cxx_test_shmem_atomic_set.cpp +++ b/test/unit/cxx_test_shmem_atomic_set.cpp @@ -39,25 +39,28 @@ enum op { SET = 0, ATOMIC_SET, CTX_ATOMIC_SET }; #ifdef ENABLE_DEPRECATED_TESTS -#define DEPRECATED_SET shmem_set +#define DEPRECATED_SET(TYPENAME, ...) shmem_##TYPENAME##_set(__VA_ARGS__) #else -#define DEPRECATED_SET shmem_atomic_set +#define DEPRECATED_SET(TYPENAME, ...) shmem_##TYPENAME##_atomic_set(__VA_ARGS__) #endif -#define TEST_SHMEM_SET(OP, TYPE) \ +#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(&remote, (TYPE)mype, (mype + 1) % npes); \ + DEPRECATED_SET(TYPENAME, &remote, (TYPE)mype, \ + (mype + 1) % npes); \ break; \ case ATOMIC_SET: \ - shmem_atomic_set(&remote, (TYPE)mype, (mype + 1) % npes); \ + shmem_##TYPENAME##_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); \ + shmem_ctx_##TYPENAME##_atomic_set(SHMEM_CTX_DEFAULT,\ + &remote, (TYPE)mype, (mype + 1) % npes); \ break; \ default: \ printf("Invalid operation (%d)\n", OP); \ @@ -78,51 +81,51 @@ int main(int argc, char* argv[]) { 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); + 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); - 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(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); - 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); + 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 index ef9e278..817a7d8 100644 --- a/test/unit/cxx_test_shmem_atomic_swap.cpp +++ b/test/unit/cxx_test_shmem_atomic_swap.cpp @@ -44,26 +44,26 @@ 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 +#define DEPRECATED_SWAP(TYPENAME, ...) shmem_##TYPENAME##_swap(__VA_ARGS__) #else -#define DEPRECATED_SWAP shmem_atomic_swap +#define DEPRECATED_SWAP(TYPENAME, ...) shmem_##TYPENAME##_atomic_swap(__VA_ARGS__) #endif #ifdef ENABLE_SHMEMX_TESTS -#define SHMEMX_NBI_OPS_CASES(OP, TYPE) \ +#define SHMEMX_NBI_OPS_CASES(OP, TYPE, TYPENAME) \ case ATOMIC_SWAP_NBI: \ - shmemx_atomic_swap_nbi(&old, &remote, \ + shmemx_##TYPENAME##_atomic_swap_nbi(&old, &remote, \ (TYPE)mype, (mype + 1) % npes); \ break; \ case CTX_ATOMIC_SWAP_NBI: \ - shmemx_atomic_swap_nbi(SHMEM_CTX_DEFAULT, &old, &remote, \ - (TYPE)mype, (mype + 1) % npes); \ + shmemx_ctx_##TYPENAME##_atomic_swap_nbi(SHMEM_CTX_DEFAULT, \ + &old, &remote, (TYPE)mype, (mype + 1) % npes); \ break; #else -#define SHMEMX_NBI_OPS_CASES(OP, TYPE) +#define SHMEMX_NBI_OPS_CASES(OP, TYPE, TYPENAME) #endif -#define TEST_SHMEM_SWAP(OP, TYPE) \ +#define TEST_SHMEM_SWAP(OP, TYPE, TYPENAME) \ do { \ static TYPE remote; \ TYPE old; \ @@ -73,16 +73,18 @@ enum op { SWAP = 0, ATOMIC_SWAP, CTX_ATOMIC_SWAP, ATOMIC_SWAP_NBI, shmem_barrier_all(); \ switch (OP) { \ case SWAP: \ - old = DEPRECATED_SWAP(&remote, (TYPE)mype, (mype + 1) % npes); \ + old = DEPRECATED_SWAP(TYPENAME, &remote, (TYPE)mype, \ + (mype + 1) % npes); \ break; \ case ATOMIC_SWAP: \ - old = shmem_atomic_swap(&remote, (TYPE)mype, (mype + 1) % npes); \ + old = shmem_##TYPENAME##_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); \ + old = shmem_ctx_##TYPENAME##_atomic_swap(SHMEM_CTX_DEFAULT, \ + &remote, (TYPE)mype, (mype + 1) % npes); \ break; \ - SHMEMX_NBI_OPS_CASES(OP, TYPE) \ + SHMEMX_NBI_OPS_CASES(OP, TYPE, TYPENAME) \ default: \ printf("invalid operation (%d)\n", OP); \ shmem_global_exit(1); \ @@ -107,82 +109,82 @@ int main(int argc, char* argv[]) { 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); + 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); - 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(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); - 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(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); #ifdef ENABLE_SHMEMX_TESTS - 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(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); - 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); + 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); #endif shmem_finalize(); diff --git a/test/unit/cxx_test_shmem_atomic_xor.cpp b/test/unit/cxx_test_shmem_atomic_xor.cpp index 6d5144d..e44fb03 100644 --- a/test/unit/cxx_test_shmem_atomic_xor.cpp +++ b/test/unit/cxx_test_shmem_atomic_xor.cpp @@ -50,9 +50,9 @@ enum op { XOR = 0, CTX_XOR, FETCH_XOR, CTX_FETCH_XOR, FETCH_XOR_NBI, */ #ifdef ENABLE_SHMEMX_TESTS -#define SHMEMX_NBI_OPS_CASES(OP, TYPE) \ +#define SHMEMX_NBI_OPS_CASES(OP, TYPE, TYPENAME) \ case FETCH_XOR_NBI: \ - shmemx_atomic_fetch_xor_nbi(&old, &remote, \ + shmemx_##TYPENAME##_atomic_fetch_xor_nbi(&old, &remote, \ (TYPE)(1LLU << mype), i); \ shmem_quiet(); \ if (((old ^ (TYPE)(1LLU << mype)) & (TYPE)(1LLU << mype)) != 0) { \ @@ -62,8 +62,8 @@ enum op { XOR = 0, CTX_XOR, FETCH_XOR, CTX_FETCH_XOR, FETCH_XOR_NBI, } \ break; \ case CTX_FETCH_XOR_NBI: \ - shmemx_atomic_fetch_xor_nbi(SHMEM_CTX_DEFAULT, &old, &remote, \ - (TYPE)(1LLU << mype), i); \ + shmemx_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", \ @@ -72,26 +72,27 @@ enum op { XOR = 0, CTX_XOR, FETCH_XOR, CTX_FETCH_XOR, FETCH_XOR_NBI, } \ break; #else -#define SHMEMX_NBI_OPS_CASES(OP, TYPE) +#define SHMEMX_NBI_OPS_CASES(OP, TYPE, TYPENAME) #endif -#define TEST_SHMEM_XOR(OP, TYPE) \ +#define TEST_SHMEM_XOR(OP, TYPE, TYPENAME) \ 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); \ + shmem_##TYPENAME##_atomic_xor(&remote, \ + (TYPE)(1LLU << mype), i); \ break; \ case CTX_XOR: \ - shmem_atomic_xor(SHMEM_CTX_DEFAULT, &remote, (TYPE)(1LLU << mype), i); \ + shmem_ctx_##TYPENAME##_atomic_xor(SHMEM_CTX_DEFAULT, &remote, \ + (TYPE)(1LLU << mype), i); \ break; \ case FETCH_XOR: \ - old = shmem_atomic_fetch_xor(&remote, (TYPE)(1LLU << mype), i); \ + 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); \ @@ -99,14 +100,15 @@ enum op { XOR = 0, CTX_XOR, FETCH_XOR, CTX_FETCH_XOR, FETCH_XOR_NBI, } \ break; \ case CTX_FETCH_XOR: \ - old = shmem_atomic_fetch_xor(SHMEM_CTX_DEFAULT, &remote, (TYPE)(1LLU << mype), i); \ + 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; \ - SHMEMX_NBI_OPS_CASES(OP, TYPE) \ + SHMEMX_NBI_OPS_CASES(OP, TYPE, TYPENAME) \ default: \ printf("Invalid operation (%d)\n", OP); \ shmem_global_exit(1); \ @@ -123,55 +125,58 @@ enum op { XOR = 0, CTX_XOR, FETCH_XOR, CTX_FETCH_XOR, FETCH_XOR_NBI, 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); - 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(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); #ifdef ENABLE_SHMEMX_TESTS - 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); + 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); #endif shmem_finalize(); diff --git a/test/unit/cxx_test_shmem_g.cpp b/test/unit/cxx_test_shmem_g.cpp index a7912a7..0ce3071 100644 --- a/test/unit/cxx_test_shmem_g.cpp +++ b/test/unit/cxx_test_shmem_g.cpp @@ -36,7 +36,7 @@ #include #include -#define TEST_SHMEM_G(USE_CTX, TYPE) \ +#define TEST_SHMEM_G(USE_CTX, TYPE, TYPENAME) \ do { \ static TYPE remote; \ TYPE val; \ @@ -45,9 +45,11 @@ remote = (TYPE)mype; \ shmem_barrier_all(); \ if (USE_CTX) \ - val = shmem_g(SHMEM_CTX_DEFAULT, &remote, (mype + 1) % npes); \ + val = shmem_ctx_##TYPENAME##_g( \ + SHMEM_CTX_DEFAULT, &remote, (mype + 1) % npes); \ else \ - val = shmem_g(&remote, (mype + 1) % npes); \ + 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, \ @@ -60,55 +62,55 @@ 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(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); - 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); + 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 index 437c279..d37762d 100644 --- a/test/unit/cxx_test_shmem_get.cpp +++ b/test/unit/cxx_test_shmem_get.cpp @@ -38,7 +38,7 @@ enum op { GET = 0, IGET, GET_NBI }; -#define TEST_SHMEM_GET(OP, USE_CTX, TYPE) \ +#define TEST_SHMEM_GET(OP, USE_CTX, TYPE, TYPENAME) \ do { \ static TYPE remote[10]; \ const int mype = shmem_my_pe(); \ @@ -50,21 +50,27 @@ enum op { GET = 0, IGET, GET_NBI }; switch (OP) { \ case GET: \ if (USE_CTX) \ - shmem_get(SHMEM_CTX_DEFAULT, local, remote, 10, (mype + 1) % npes); \ + shmem_ctx_##TYPENAME##_get(SHMEM_CTX_DEFAULT, local, \ + remote, 10, (mype + 1) % npes); \ else \ - shmem_get(local, remote, 10, (mype + 1) % npes); \ + shmem_##TYPENAME##_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); \ + shmem_ctx_##TYPENAME##_iget(SHMEM_CTX_DEFAULT, local, \ + remote, 1, 1, 10, (mype + 1) % npes); \ else \ - shmem_iget(local, remote, 1, 1, 10, (mype + 1) % npes); \ + shmem_##TYPENAME##_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); \ + shmem_ctx_##TYPENAME##_get_nbi(SHMEM_CTX_DEFAULT, \ + local, remote, 10, (mype + 1) % npes); \ else \ - shmem_get_nbi(local, remote, 10, (mype + 1) % npes); \ + shmem_##TYPENAME##_get_nbi(local, remote, 10, \ + (mype + 1) % npes); \ shmem_quiet(); \ break; \ default: \ @@ -84,155 +90,156 @@ 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(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(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(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, 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(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(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(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, 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); + 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_p.cpp b/test/unit/cxx_test_shmem_p.cpp index 9dfbd7e..d51a29a 100644 --- a/test/unit/cxx_test_shmem_p.cpp +++ b/test/unit/cxx_test_shmem_p.cpp @@ -36,15 +36,17 @@ #include #include -#define TEST_SHMEM_P(USE_CTX, TYPE) \ +#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_p(SHMEM_CTX_DEFAULT, &remote, (TYPE)mype, (mype + 1) % npes); \ + shmem_ctx_##TYPENAME##_p(SHMEM_CTX_DEFAULT, \ + &remote, (TYPE)mype, (mype + 1) % npes); \ else \ - shmem_p(&remote, (TYPE)mype, (mype + 1) % npes);\ + 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 " \ @@ -58,55 +60,55 @@ 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(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); - 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); + 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 index 196df8d..ce71654 100644 --- a/test/unit/cxx_test_shmem_put.cpp +++ b/test/unit/cxx_test_shmem_put.cpp @@ -38,7 +38,7 @@ enum op { PUT = 0, IPUT, PUT_NBI }; -#define TEST_SHMEM_PUT(OP, USE_CTX, TYPE) \ +#define TEST_SHMEM_PUT(OP, USE_CTX, TYPE, TYPENAME) \ do { \ static TYPE remote[10]; \ const int mype = shmem_my_pe(); \ @@ -49,21 +49,27 @@ enum op { PUT = 0, IPUT, PUT_NBI }; switch (OP) { \ case PUT: \ if (USE_CTX) \ - shmem_put(SHMEM_CTX_DEFAULT, remote, local, 10, (mype + 1) % npes); \ + shmem_ctx_##TYPENAME##_put(SHMEM_CTX_DEFAULT, remote, \ + local, 10, (mype + 1) % npes); \ else \ - shmem_put(remote, local, 10, (mype + 1) % npes); \ + shmem_##TYPENAME##_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); \ + shmem_ctx_##TYPENAME##_iput(SHMEM_CTX_DEFAULT, remote,\ + local, 1, 1, 10, (mype + 1) % npes); \ else \ - shmem_iput(remote, local, 1, 1, 10, (mype + 1) % npes); \ + shmem_##TYPENAME##_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); \ + shmem_ctx_##TYPENAME##_put_nbi(SHMEM_CTX_DEFAULT, \ + remote, local, 10, (mype + 1) % npes); \ else \ - shmem_put_nbi(remote, local, 10, (mype + 1) % npes); \ + shmem_##TYPENAME##_put_nbi(remote, local, 10, \ + (mype + 1) % npes); \ shmem_quiet(); \ break; \ default: \ @@ -84,155 +90,155 @@ 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, 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); - 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(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); - 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, 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); - 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(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); - 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, 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); - 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); + 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_test.cpp b/test/unit/cxx_test_shmem_test.cpp index 8c90199..b424ed7 100644 --- a/test/unit/cxx_test_shmem_test.cpp +++ b/test/unit/cxx_test_shmem_test.cpp @@ -36,13 +36,15 @@ #include #include -#define TEST_SHMEM_TEST(TYPE) \ +#define TEST_SHMEM_TEST(TYPE, TYPENAME) \ 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)) ; \ + 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); \ @@ -54,20 +56,20 @@ 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); + TEST_SHMEM_TEST(short, short); + TEST_SHMEM_TEST(int, int); + TEST_SHMEM_TEST(long, long); + TEST_SHMEM_TEST(long long, longlong); + TEST_SHMEM_TEST(unsigned short, ushort); + 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 index 92315a6..61bf29b 100644 --- a/test/unit/cxx_test_shmem_wait_until.cpp +++ b/test/unit/cxx_test_shmem_wait_until.cpp @@ -36,13 +36,15 @@ #include #include -#define TEST_SHMEM_WAIT_UNTIL(TYPE) \ +#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_p(&remote, (TYPE)mype+1, (mype + 1) % npes); \ - shmem_wait_until(&remote, SHMEM_CMP_NE, 0); \ + 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); \ @@ -54,20 +56,20 @@ 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); + TEST_SHMEM_WAIT_UNTIL(short, short); + TEST_SHMEM_WAIT_UNTIL(int, int); + TEST_SHMEM_WAIT_UNTIL(long, long); + TEST_SHMEM_WAIT_UNTIL(long long, longlong); + TEST_SHMEM_WAIT_UNTIL(unsigned short, ushort); + 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;