diff --git a/config/opal_check_pmi.m4 b/config/opal_check_pmi.m4 index a1297d427..74bfc8f34 100644 --- a/config/opal_check_pmi.m4 +++ b/config/opal_check_pmi.m4 @@ -13,7 +13,7 @@ # Copyright (c) 2009-2015 Cisco Systems, Inc. All rights reserved. # Copyright (c) 2011-2016 Los Alamos National Security, LLC. All rights # reserved. -# Copyright (c) 2014 Intel, Inc. All rights reserved. +# Copyright (c) 2014-2018 Intel, Inc. All rights reserved. # Copyright (c) 2014 Research Organization for Information Science # and Technology (RIST). All rights reserved. # $COPYRIGHT$ @@ -303,6 +303,19 @@ AC_DEFUN([OPAL_CHECK_PMIX],[ # if it does exist, then we need to parse it to find # the actual release series + AS_IF([test "$opal_external_pmix_version_found" = "0"], + [AC_MSG_CHECKING([version 4x]) + AC_PREPROC_IFELSE([AC_LANG_PROGRAM([ + #include + #if (PMIX_VERSION_MAJOR < 4L) + #error "not version 4" + #endif + ], [])], + [AC_MSG_RESULT([found]) + opal_external_pmix_version=4x + opal_external_pmix_version_found=1], + [AC_MSG_RESULT([not found])])]) + AS_IF([test "$opal_external_pmix_version_found" = "0"], [AC_MSG_CHECKING([version 3x]) AC_PREPROC_IFELSE([AC_LANG_PROGRAM([ diff --git a/configure.ac b/configure.ac index 074c823b0..060457e42 100755 --- a/configure.ac +++ b/configure.ac @@ -789,16 +789,16 @@ AS_IF([test "$transport_portals4" != "yes" -a "$transport_ofi" != "yes"], [AC_MSG_WARN([No transport found, resulting library will be unable to exchange messages])]) AS_IF([test "$shmem_cv_c11_works" != "yes"], - [AC_MSG_WARN([C compiler does not support _Generic, unabled to verify and test C11 bindings])]) + [AC_MSG_WARN([C compiler does not support _Generic, unable to verify and test C11 bindings])]) AS_IF([test "$enable_c11_checks" == "no"], [AC_MSG_WARN([C11 _Generic type checks disabled, not verifying type coverage of C11 bindings])]) AS_IF([test "$enable_cxx" == "no"], - [AC_MSG_WARN([No C++ compiler or C++ disabled, unabled to verify and test C++ bindings])]) + [AC_MSG_WARN([No C++ compiler or C++ disabled, unable to verify and test C++ bindings])]) AS_IF([test "$enable_fortran" == "no"], - [AC_MSG_WARN([No Fortran compiler or Fortran disabled, unabled to test Fortran bindings])]) + [AC_MSG_WARN([No Fortran compiler or Fortran disabled, unable to test Fortran bindings])]) AS_IF([test "$enable_fortran" != "no"], [AC_MSG_WARN([Fortran bindings have been deprecated as of OpenSHMEM v1.4])]) diff --git a/mpp/shmemx.h4.in b/mpp/shmemx.h4.in index 397280f99..4937e710c 100644 --- a/mpp/shmemx.h4.in +++ b/mpp/shmemx.h4.in @@ -55,6 +55,42 @@ include(shmemx_c_func.h4)dnl #ifdef __cplusplus } /* extern "C" */ +define(`SHMEM_CXX_WAIT_UNTIL_ALL', +`static inline void shmemx_wait_until_all($2 *ivars, size_t nelems, int cmp, $2 cmp_value) { + shmemx_$1_wait_until_all(ivars, nelems, cmp, cmp_value); +}')dnl +SHMEM_CXX_DEFINE_FOR_SYNC(`SHMEM_CXX_WAIT_UNTIL_ALL') + +define(`SHMEM_CXX_WAIT_UNTIL_ANY', +`static inline size_t shmemx_wait_until_any($2 *ivars, size_t nelems, int *status, int cmp, $2 cmp_value) { + return shmemx_$1_wait_until_any(ivars, nelems, status, cmp, cmp_value); +}')dnl +SHMEM_CXX_DEFINE_FOR_SYNC(`SHMEM_CXX_WAIT_UNTIL_ANY') + +define(`SHMEM_CXX_WAIT_UNTIL_SOME', +`static inline size_t shmemx_wait_until_some($2 *ivars, size_t nelems, size_t *indices, int *status, int cmp, $2 cmp_value) { + return shmemx_$1_wait_until_some(ivars, nelems, indices, status, cmp, cmp_value); +}')dnl +SHMEM_CXX_DEFINE_FOR_SYNC(`SHMEM_CXX_WAIT_UNTIL_SOME') + +define(`SHMEM_CXX_TEST_ALL', +`static inline int shmemx_test_all($2 *ivars, size_t nelems, int cmp, $2 cmp_value) { + return shmemx_$1_test_all(ivars, nelems, cmp, cmp_value); +}')dnl +SHMEM_CXX_DEFINE_FOR_SYNC(`SHMEM_CXX_TEST_ALL') + +define(`SHMEM_CXX_TEST_ANY', +`static inline size_t shmemx_test_any($2 *ivars, size_t nelems, int *status, int cmp, $2 cmp_value) { + return shmemx_$1_test_any(ivars, nelems, status, cmp, cmp_value); +}')dnl +SHMEM_CXX_DEFINE_FOR_SYNC(`SHMEM_CXX_TEST_ANY') + +define(`SHMEM_CXX_TEST_SOME', +`static inline size_t shmemx_test_some($2 *ivars, size_t nelems, size_t *indices, int *status, int cmp, $2 cmp_value) { + return shmemx_$1_test_some(ivars, nelems, indices, status, cmp, cmp_value); +}')dnl +SHMEM_CXX_DEFINE_FOR_SYNC(`SHMEM_CXX_TEST_SOME') + define(`SHMEM_CXX_ATOMIC_SWAP', `static inline void shmemx_atomic_swap_nbi($2 *fetch, $2 *target, $2 value, int pe) { shmemx_$1_atomic_swap_nbi(fetch, target, value, pe); @@ -154,8 +190,50 @@ SHMEM_CXX_DEFINE_FOR_RMA(`SHMEM_CXX_PUT_SIGNAL_NBI') /* C11 Generic Macros */ #elif (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && !defined(SHMEM_INTERNAL_INCLUDE)) -/* Nonblocking fetching AMOs */ +/* Wait_until and test any/all/some point-to-point API */ +define(`SHMEM_C11_GEN_WAIT_UNTIL_ALL', ` $2*: shmemx_$1_wait_until_all')dnl +#define shmemx_wait_until_all(...) \ + _Generic(SHMEM_C11_TYPE_EVAL_PTR(SHMEM_C11_ARG0(__VA_ARGS__)), \ + default: shmem_ctx_c11_generic_selection_failed, \ +SHMEM_BIND_C11_SYNC(`SHMEM_C11_GEN_WAIT_UNTIL_ALL', `, \') \ + )(__VA_ARGS__) +define(`SHMEM_C11_GEN_WAIT_UNTIL_ANY', ` $2*: shmemx_$1_wait_until_any')dnl +#define shmemx_wait_until_any(...) \ + _Generic(SHMEM_C11_TYPE_EVAL_PTR(SHMEM_C11_ARG0(__VA_ARGS__)), \ + default: shmem_ctx_c11_generic_selection_failed, \ +SHMEM_BIND_C11_SYNC(`SHMEM_C11_GEN_WAIT_UNTIL_ANY', `, \') \ + )(__VA_ARGS__) + +define(`SHMEM_C11_GEN_WAIT_UNTIL_SOME', ` $2*: shmemx_$1_wait_until_some')dnl +#define shmemx_wait_until_some(...) \ + _Generic(SHMEM_C11_TYPE_EVAL_PTR(SHMEM_C11_ARG0(__VA_ARGS__)), \ + default: shmem_ctx_c11_generic_selection_failed, \ +SHMEM_BIND_C11_SYNC(`SHMEM_C11_GEN_WAIT_UNTIL_SOME', `, \') \ + )(__VA_ARGS__) + +define(`SHMEM_C11_GEN_TEST_ALL', ` $2*: shmemx_$1_test_all')dnl +#define shmemx_test_all(...) \ + _Generic(SHMEM_C11_TYPE_EVAL_PTR(SHMEM_C11_ARG0(__VA_ARGS__)), \ + default: shmem_ctx_c11_generic_selection_failed, \ +SHMEM_BIND_C11_SYNC(`SHMEM_C11_GEN_TEST_ALL', `, \') \ + )(__VA_ARGS__) + +define(`SHMEM_C11_GEN_TEST_ANY', ` $2*: shmemx_$1_test_any')dnl +#define shmemx_test_any(...) \ + _Generic(SHMEM_C11_TYPE_EVAL_PTR(SHMEM_C11_ARG0(__VA_ARGS__)), \ + default: shmem_ctx_c11_generic_selection_failed, \ +SHMEM_BIND_C11_SYNC(`SHMEM_C11_GEN_TEST_ANY', `, \') \ + )(__VA_ARGS__) + +define(`SHMEM_C11_GEN_TEST_SOME', ` $2*: shmemx_$1_test_some')dnl +#define shmemx_test_some(...) \ + _Generic(SHMEM_C11_TYPE_EVAL_PTR(SHMEM_C11_ARG0(__VA_ARGS__)), \ + default: shmem_ctx_c11_generic_selection_failed, \ +SHMEM_BIND_C11_SYNC(`SHMEM_C11_GEN_TEST_SOME', `, \') \ + )(__VA_ARGS__) + +/* Nonblocking fetching AMOs */ define(`SHMEM_C11_GEN_ATOMIC_SWAP_NBI', ` $2*: shmemx_$1_atomic_swap_nbi')dnl define(`SHMEM_CTX_C11_GEN_ATOMIC_SWAP_NBI', ` $2*: shmemx_ctx_$1_atomic_swap_nbi')dnl #define shmemx_atomic_swap_nbi(...) \ diff --git a/mpp/shmemx_c_func.h4.in b/mpp/shmemx_c_func.h4.in index ec4e1aede..4d427f2c8 100644 --- a/mpp/shmemx_c_func.h4.in +++ b/mpp/shmemx_c_func.h4.in @@ -39,6 +39,31 @@ SHMEM_FUNCTION_ATTRIBUTES void SHPRE()shmemx_pcntr_get_completed_read(shmem_ctx_ SHMEM_FUNCTION_ATTRIBUTES void SHPRE()shmemx_pcntr_get_completed_target(uint64_t *cntr_value); SHMEM_FUNCTION_ATTRIBUTES void SHPRE()shmemx_pcntr_get_all(shmem_ctx_t ctx, shmemx_pcntr_t *pcntr); +/* Wait_until and test any/all/some point-to-point API, proposed for OpenSHMEM 1.5 */ +define(`SHMEM_C_WAIT_UNTIL_ALL', +`SHMEM_FUNCTION_ATTRIBUTES void SHPRE()shmemx_$1_wait_until_all($2 *vars, size_t nelems, int cmp, $2 value);')dnl +SHMEM_BIND_C_SYNC(`SHMEM_C_WAIT_UNTIL_ALL') + +define(`SHMEM_C_WAIT_UNTIL_ANY', +`SHMEM_FUNCTION_ATTRIBUTES size_t SHPRE()shmemx_$1_wait_until_any($2 *vars, size_t nelems, int *status, int cmp, $2 value);')dnl +SHMEM_BIND_C_SYNC(`SHMEM_C_WAIT_UNTIL_ANY') + +define(`SHMEM_C_WAIT_UNTIL_SOME', +`SHMEM_FUNCTION_ATTRIBUTES size_t SHPRE()shmemx_$1_wait_until_some($2 *vars, size_t nelems, size_t *indices, int *status, int cmp, $2 value);')dnl +SHMEM_BIND_C_SYNC(`SHMEM_C_WAIT_UNTIL_SOME') + +define(`SHMEM_C_TEST_ALL', +`SHMEM_FUNCTION_ATTRIBUTES int SHPRE()shmemx_$1_test_all($2 *vars, size_t nelems, int cmp, $2 value);')dnl +SHMEM_BIND_C_SYNC(`SHMEM_C_TEST_ALL') + +define(`SHMEM_C_TEST_ANY', +`SHMEM_FUNCTION_ATTRIBUTES size_t SHPRE()shmemx_$1_test_any($2 *vars, size_t nelems, int *status, int cmp, $2 value);')dnl +SHMEM_BIND_C_SYNC(`SHMEM_C_TEST_ANY') + +define(`SHMEM_C_TEST_SOME', +`SHMEM_FUNCTION_ATTRIBUTES size_t SHPRE()shmemx_$1_test_some($2 *vars, size_t nelems, size_t *indices, int *status, int cmp, $2 value);')dnl +SHMEM_BIND_C_SYNC(`SHMEM_C_TEST_SOME') + /* Nonblocking swap operations, proposed for OpenSHMEM 1.5 */ define(`SHMEM_C_ATOMIC_SWAP_NBI', `SHMEM_FUNCTION_ATTRIBUTES void SHPRE()shmemx_$1_atomic_swap_nbi($2 *fetch, $2 *dest, $2 value, int pe)')dnl diff --git a/scripts/travis/cray_tests.sh b/scripts/travis/cray_tests.sh index 003a71347..1c7e1c1fe 100755 --- a/scripts/travis/cray_tests.sh +++ b/scripts/travis/cray_tests.sh @@ -2,7 +2,7 @@ #export CUSTOM_SHMEM_DIR="" #export CRAY_TESTS_DIR=" +#include +#include +#include +#include + +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L + +#define TEST_SHMEM_TEST_ALL(TYPE) \ + do { \ + static TYPE remote = 0; \ + const int mype = shmem_my_pe(); \ + const int npes = shmem_n_pes(); \ + shmem_p(&remote, (TYPE)mype+1, (mype + 1) % npes); \ + while (!shmemx_test_all(&remote, 1, SHMEM_CMP_NE, 0)) ; \ + if (remote != (TYPE)((mype + npes - 1) % npes)+1) { \ + printf("PE %i received incorrect value with " \ + "TEST_SHMEM_TEST_ALL(%s)\n", mype, #TYPE); \ + rc = EXIT_FAILURE; \ + } \ + } while (0) + +#define TEST_SHMEM_TEST_ANY(TYPE) \ + do { \ + static TYPE remote = 0; \ + const int mype = shmem_my_pe(); \ + const int npes = shmem_n_pes(); \ + int status = 0; \ + shmem_p(&remote, (TYPE)mype+1, (mype + 1) % npes); \ + while (shmemx_test_any(&remote, 1, &status, SHMEM_CMP_NE, 0) == SIZE_MAX); \ + if (remote != (TYPE)((mype + npes - 1) % npes)+1) { \ + printf("PE %i received incorrect value with " \ + "TEST_SHMEM_TEST_ANY(%s)\n", mype, #TYPE); \ + rc = EXIT_FAILURE; \ + } \ + } while (0) + +#define TEST_SHMEM_TEST_SOME(TYPE) \ + do { \ + static TYPE remote = 0; \ + const int mype = shmem_my_pe(); \ + const int npes = shmem_n_pes(); \ + int status = 0; \ + size_t indices; \ + shmem_p(&remote, (TYPE)mype+1, (mype + 1) % npes); \ + while (!shmemx_test_some(&remote, 1, &indices, &status, SHMEM_CMP_NE, 0)); \ + if (remote != (TYPE)((mype + npes - 1) % npes)+1) { \ + printf("PE %i received incorrect value with " \ + "TEST_SHMEM_TEST_SOME(%s)\n", mype, #TYPE); \ + rc = EXIT_FAILURE; \ + } \ + } while (0) + +#else +#define TEST_SHMEM_TEST_ALL(TYPE) +#define TEST_SHMEM_TEST_ANY(TYPE) +#define TEST_SHMEM_TEST_SOME(TYPE) + +#endif + +int main(int argc, char* argv[]) { + shmem_init(); + + int rc = EXIT_SUCCESS; + TEST_SHMEM_TEST_ALL(short); + TEST_SHMEM_TEST_ALL(int); + TEST_SHMEM_TEST_ALL(long); + TEST_SHMEM_TEST_ALL(long long); + TEST_SHMEM_TEST_ALL(unsigned short); + TEST_SHMEM_TEST_ALL(unsigned int); + TEST_SHMEM_TEST_ALL(unsigned long); + TEST_SHMEM_TEST_ALL(unsigned long long); + TEST_SHMEM_TEST_ALL(int32_t); + TEST_SHMEM_TEST_ALL(int64_t); + TEST_SHMEM_TEST_ALL(uint32_t); + TEST_SHMEM_TEST_ALL(uint64_t); + TEST_SHMEM_TEST_ALL(size_t); + TEST_SHMEM_TEST_ALL(ptrdiff_t); + + TEST_SHMEM_TEST_ANY(short); + TEST_SHMEM_TEST_ANY(int); + TEST_SHMEM_TEST_ANY(long); + TEST_SHMEM_TEST_ANY(long long); + TEST_SHMEM_TEST_ANY(unsigned short); + TEST_SHMEM_TEST_ANY(unsigned int); + TEST_SHMEM_TEST_ANY(unsigned long); + TEST_SHMEM_TEST_ANY(unsigned long long); + TEST_SHMEM_TEST_ANY(int32_t); + TEST_SHMEM_TEST_ANY(int64_t); + TEST_SHMEM_TEST_ANY(uint32_t); + TEST_SHMEM_TEST_ANY(uint64_t); + TEST_SHMEM_TEST_ANY(size_t); + TEST_SHMEM_TEST_ANY(ptrdiff_t); + + TEST_SHMEM_TEST_SOME(short); + TEST_SHMEM_TEST_SOME(int); + TEST_SHMEM_TEST_SOME(long); + TEST_SHMEM_TEST_SOME(long long); + TEST_SHMEM_TEST_SOME(unsigned short); + TEST_SHMEM_TEST_SOME(unsigned int); + TEST_SHMEM_TEST_SOME(unsigned long); + TEST_SHMEM_TEST_SOME(unsigned long long); + TEST_SHMEM_TEST_SOME(int32_t); + TEST_SHMEM_TEST_SOME(int64_t); + TEST_SHMEM_TEST_SOME(uint32_t); + TEST_SHMEM_TEST_SOME(uint64_t); + TEST_SHMEM_TEST_SOME(size_t); + TEST_SHMEM_TEST_SOME(ptrdiff_t); + shmem_finalize(); + return rc; +} diff --git a/test/shmemx/c11_test_shmemx_wait_until.c b/test/shmemx/c11_test_shmemx_wait_until.c new file mode 100644 index 000000000..a6b17ef23 --- /dev/null +++ b/test/shmemx/c11_test_shmemx_wait_until.c @@ -0,0 +1,144 @@ +/* + * This test program is derived from a unit test created by Nick Park. + * The original unit test is a work of the U.S. Government and is not subject + * to copyright protection in the United States. Foreign copyrights may + * apply. + * + * Copyright (c) 2017 Intel Corporation. All rights reserved. + * This software is available to you under the BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include +#include +#include +#include + +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L + +#define TEST_SHMEM_WAIT_UNTIL_ALL(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); \ + shmemx_wait_until_all(&remote, 1, SHMEM_CMP_NE, 0); \ + if (remote != (TYPE)((mype + npes - 1) % npes)+1) { \ + printf("PE %i received incorrect value with " \ + "TEST_SHMEM_WAIT_UNTIL_ALL(%s)\n", mype, #TYPE); \ + rc = EXIT_FAILURE; \ + } \ + } while (0) + +#define TEST_SHMEM_WAIT_UNTIL_ANY(TYPE) \ + do { \ + static TYPE remote = 0; \ + const int mype = shmem_my_pe(); \ + const int npes = shmem_n_pes(); \ + int status = 0; \ + shmem_p(&remote, (TYPE)mype+1, (mype + 1) % npes); \ + shmemx_wait_until_any(&remote, 1, &status, SHMEM_CMP_NE, 0); \ + if (remote != (TYPE)((mype + npes - 1) % npes)+1) { \ + printf("PE %i received incorrect value with " \ + "TEST_SHMEM_WAIT_UNTIL_ANY(%s)\n", mype, #TYPE); \ + rc = EXIT_FAILURE; \ + } \ + } while (0) + +#define TEST_SHMEM_WAIT_UNTIL_SOME(TYPE) \ + do { \ + static TYPE remote = 0; \ + const int mype = shmem_my_pe(); \ + const int npes = shmem_n_pes(); \ + int status = 0; \ + size_t indices; \ + shmem_p(&remote, (TYPE)mype+1, (mype + 1) % npes); \ + shmemx_wait_until_some(&remote, 1, &indices, &status, SHMEM_CMP_NE, 0); \ + if (remote != (TYPE)((mype + npes - 1) % npes)+1) { \ + printf("PE %i received incorrect value with " \ + "TEST_SHMEM_WAIT_UNTIL_SOME(%s)\n", mype, #TYPE); \ + rc = EXIT_FAILURE; \ + } \ + } while (0) + +#else +#define TEST_SHMEM_WAIT_UNTIL_ALL(TYPE) +#define TEST_SHMEM_WAIT_UNTIL_ANY(TYPE) +#define TEST_SHMEM_WAIT_UNTIL_SOME(TYPE) + +#endif + +int main(int argc, char* argv[]) { + shmem_init(); + + int rc = EXIT_SUCCESS; + TEST_SHMEM_WAIT_UNTIL_ALL(short); + TEST_SHMEM_WAIT_UNTIL_ALL(int); + TEST_SHMEM_WAIT_UNTIL_ALL(long); + TEST_SHMEM_WAIT_UNTIL_ALL(long long); + TEST_SHMEM_WAIT_UNTIL_ALL(unsigned short); + TEST_SHMEM_WAIT_UNTIL_ALL(unsigned int); + TEST_SHMEM_WAIT_UNTIL_ALL(unsigned long); + TEST_SHMEM_WAIT_UNTIL_ALL(unsigned long long); + TEST_SHMEM_WAIT_UNTIL_ALL(int32_t); + TEST_SHMEM_WAIT_UNTIL_ALL(int64_t); + TEST_SHMEM_WAIT_UNTIL_ALL(uint32_t); + TEST_SHMEM_WAIT_UNTIL_ALL(uint64_t); + TEST_SHMEM_WAIT_UNTIL_ALL(size_t); + TEST_SHMEM_WAIT_UNTIL_ALL(ptrdiff_t); + + TEST_SHMEM_WAIT_UNTIL_ANY(short); + TEST_SHMEM_WAIT_UNTIL_ANY(int); + TEST_SHMEM_WAIT_UNTIL_ANY(long); + TEST_SHMEM_WAIT_UNTIL_ANY(long long); + TEST_SHMEM_WAIT_UNTIL_ANY(unsigned short); + TEST_SHMEM_WAIT_UNTIL_ANY(unsigned int); + TEST_SHMEM_WAIT_UNTIL_ANY(unsigned long); + TEST_SHMEM_WAIT_UNTIL_ANY(unsigned long long); + TEST_SHMEM_WAIT_UNTIL_ANY(int32_t); + TEST_SHMEM_WAIT_UNTIL_ANY(int64_t); + TEST_SHMEM_WAIT_UNTIL_ANY(uint32_t); + TEST_SHMEM_WAIT_UNTIL_ANY(uint64_t); + TEST_SHMEM_WAIT_UNTIL_ANY(size_t); + TEST_SHMEM_WAIT_UNTIL_ANY(ptrdiff_t); + + TEST_SHMEM_WAIT_UNTIL_SOME(short); + TEST_SHMEM_WAIT_UNTIL_SOME(int); + TEST_SHMEM_WAIT_UNTIL_SOME(long); + TEST_SHMEM_WAIT_UNTIL_SOME(long long); + TEST_SHMEM_WAIT_UNTIL_SOME(unsigned short); + TEST_SHMEM_WAIT_UNTIL_SOME(unsigned int); + TEST_SHMEM_WAIT_UNTIL_SOME(unsigned long); + TEST_SHMEM_WAIT_UNTIL_SOME(unsigned long long); + TEST_SHMEM_WAIT_UNTIL_SOME(int32_t); + TEST_SHMEM_WAIT_UNTIL_SOME(int64_t); + TEST_SHMEM_WAIT_UNTIL_SOME(uint32_t); + TEST_SHMEM_WAIT_UNTIL_SOME(uint64_t); + TEST_SHMEM_WAIT_UNTIL_SOME(size_t); + TEST_SHMEM_WAIT_UNTIL_SOME(ptrdiff_t); + + shmem_finalize(); + return rc; +} diff --git a/test/shmemx/cxx_test_shmem_atomic_add.cpp b/test/shmemx/cxx_test_shmem_atomic_add.cpp new file mode 100644 index 000000000..3c8f73d00 --- /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 000000000..d84cce7e2 --- /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 000000000..d81c4d4cc --- /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 000000000..41c6700d8 --- /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 000000000..ecd642259 --- /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 000000000..5463f02c9 --- /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 000000000..9cb15077b --- /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 000000000..ef9e278ff --- /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 000000000..6d5144d92 --- /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 000000000..a7912a789 --- /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 000000000..437c27977 --- /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 000000000..9dfbd7ece --- /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 000000000..196df8d0b --- /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 000000000..8c9019921 --- /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 000000000..92315a649 --- /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/shmemx/shmemx_test_all.c b/test/shmemx/shmemx_test_all.c new file mode 100644 index 000000000..6a6425007 --- /dev/null +++ b/test/shmemx/shmemx_test_all.c @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2018 Intel Corporation. All rights reserved. + * This software is available to you under the BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * This test is derived from an example provided in the OpenSHMEM 1.4 + * specification. Additional copyrights may apply. + * + */ + +#include +#include + +int main(void) +{ + shmem_init(); + int mype = shmem_my_pe(); + int npes = shmem_n_pes(); + + int *flags = shmem_calloc(npes, sizeof(int)); + + for (int i = 0; i < npes; i++) + shmem_int_p(&flags[mype], 1, i); + + while (!shmemx_int_test_all(flags, npes, SHMEM_CMP_EQ, 1)); + + /* Check the flags array */ + for (int i = 0; i < npes; i++) { + if (flags[i] != 1) + shmem_global_exit(1); + } + shmem_free(flags); + shmem_finalize(); + return 0; +} diff --git a/test/shmemx/shmemx_test_any.c b/test/shmemx/shmemx_test_any.c new file mode 100644 index 000000000..d6fee17f3 --- /dev/null +++ b/test/shmemx/shmemx_test_any.c @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2018 Intel Corporation. All rights reserved. + * This software is available to you under the BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * This test is derived from an example provided in the OpenSHMEM 1.4 + * specification. Additional copyrights may apply. + * + */ + +#include +#include +#include + +int main(void) +{ + shmem_init(); + int mype = shmem_my_pe(); + int npes = shmem_n_pes(); + + int *flags = shmem_calloc(npes, sizeof(int)); + int *status = calloc(npes, sizeof(int)); + + for (int i = 0; i < npes; i++) + shmem_int_p(&flags[mype], 1, i); + + int ncompleted = 0; + size_t completed_idx; + + while (ncompleted < npes) { + completed_idx = shmemx_int_test_any(flags, npes, status, SHMEM_CMP_EQ, 1); + if (completed_idx != SIZE_MAX) { + ncompleted++; + } else { + /* Overlap some computation here */ + } + } + + /* Check the flags array */ + for (int i = 0; i < npes; i++) { + if (flags[i] != 1) + shmem_global_exit(1); + } + + /* Sanity check of shmem_test_any's fairness */ + ncompleted = 0; + int *found = calloc(npes, sizeof(int)); + + while (ncompleted < npes) { + int idx = shmemx_int_test_any(flags, npes, NULL, SHMEM_CMP_EQ, 1); + if (found[idx] == 0) { + found[idx] = 1; + ncompleted++; + } + } + + for (int i = 0; i < npes; i++) { + if (found[i] != 1) { + shmem_global_exit(2); + } + } + + /* Sanity check case with NULL status array */ + completed_idx = shmemx_int_test_any(flags, npes, NULL, SHMEM_CMP_EQ, 1); + + if (completed_idx >= npes) + shmem_global_exit(3); + + + free(found); + free(status); + shmem_free(flags); + shmem_finalize(); + return 0; +} diff --git a/test/shmemx/shmemx_test_some.c b/test/shmemx/shmemx_test_some.c new file mode 100644 index 000000000..35598b2e4 --- /dev/null +++ b/test/shmemx/shmemx_test_some.c @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2018 Intel Corporation. All rights reserved. + * This software is available to you under the BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * This test is derived from an example provided in the OpenSHMEM 1.4 + * specification. Additional copyrights may apply. + * + */ + +#include +#include +#include + +#define N 100 + +int main(void) +{ + int total_sum = 0; + + shmem_init(); + int mype = shmem_my_pe(); + int npes = shmem_n_pes(); + + int *my_data = malloc(N * sizeof(int)); + int *all_data = shmem_malloc(N * npes * sizeof(int)); + + int *flags = shmem_calloc(npes, sizeof(int)); + size_t *indices = calloc(npes, sizeof(size_t)); + int *status = calloc(npes, sizeof(int)); + + for (int i = 0; i < N; i++) + my_data[i] = mype*N + i; + + for (int i = 0; i < npes; i++) + shmem_int_put_nbi(&all_data[mype*N], my_data, N, i); + + shmem_fence(); + + for (int i = 0; i < npes; i++) + shmem_int_p(&flags[mype], 1, i); + + int ncompleted = 0; + + while (ncompleted < npes) { + int ntested = shmemx_int_test_some(flags, npes, indices, status, SHMEM_CMP_NE, 0); + if (ntested > 0) { + for (int i = 0; i < ntested; i++) { + for (int j = 0; j < N; j++) + total_sum += all_data[indices[i]*N + j]; + } + ncompleted += ntested; + } else { + /* Overlap some computation here */ + } + } + + /* Check the flags array */ + for (int i = 0; i < npes; i++) { + if (flags[i] != 1) + shmem_global_exit(0); + } + + /* check result */ + int M = N * npes - 1; + if (total_sum != M * (M + 1) / 2) { + shmem_global_exit(1); + } + + /* Sanity check case with NULL status array */ + ncompleted = shmemx_int_test_some(flags, npes, indices, NULL, SHMEM_CMP_EQ, 1); + + if (ncompleted != npes) + shmem_global_exit(2); + + shmem_finalize(); + return 0; +} diff --git a/test/shmemx/shmemx_wait_until_all.c b/test/shmemx/shmemx_wait_until_all.c new file mode 100644 index 000000000..f79a9146e --- /dev/null +++ b/test/shmemx/shmemx_wait_until_all.c @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2018 Intel Corporation. All rights reserved. + * This software is available to you under the BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * This test is derived from an example provided in the OpenSHMEM 1.4 + * specification. Additional copyrights may apply. + * + */ + +#include +#include + +int main(void) +{ + shmem_init(); + int mype = shmem_my_pe(); + int npes = shmem_n_pes(); + + int *flags = shmem_calloc(npes, sizeof(int)); + + for (int i = 0; i < npes; i++) + shmem_int_p(&flags[mype], 1, i); + + shmemx_int_wait_until_all(flags, npes, SHMEM_CMP_EQ, 1); + + /* Check the flags array */ + for (int i = 0; i < npes; i++) { + if (flags[i] != 1) + shmem_global_exit(1); + } + + shmem_free(flags); + shmem_finalize(); + return 0; +} diff --git a/test/shmemx/shmemx_wait_until_any.c b/test/shmemx/shmemx_wait_until_any.c new file mode 100644 index 000000000..ed64d8862 --- /dev/null +++ b/test/shmemx/shmemx_wait_until_any.c @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2018 Intel Corporation. All rights reserved. + * This software is available to you under the BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * This test is derived from an example provided in the OpenSHMEM 1.4 + * specification. Additional copyrights may apply. + * + */ + +#include +#include +#include + +#define N 100 + +int main(void) +{ + int total_sum = 0; + + shmem_init(); + int mype = shmem_my_pe(); + int npes = shmem_n_pes(); + + int *my_data = malloc(N * sizeof(int)); + int *all_data = shmem_malloc(N * npes * sizeof(int)); + + int *flags = shmem_calloc(npes, sizeof(int)); + int *status = calloc(npes, sizeof(int)); + + for (int i = 0; i < N; i++) + my_data[i] = mype*N + i; + + for (int i = 0; i < npes; i++) + shmem_int_put_nbi(&all_data[mype*N], my_data, N, i); + + shmem_fence(); + + for (int i = 0; i < npes; i++) + shmem_int_p(&flags[mype], 1, i); + + size_t completed_idx; + for (int i = 0; i < npes; i++) { + completed_idx = shmemx_int_wait_until_any(flags, npes, status, SHMEM_CMP_NE, 0); + for (int j = 0; j < N; j++) + total_sum += all_data[completed_idx * N + j]; + } + + /* Check the flags array */ + for (int i = 0; i < npes; i++) { + if (flags[i] != 1) + shmem_global_exit(0); + } + + /* check result */ + int M = N * npes - 1; + if (total_sum != M * (M + 1) / 2) { + shmem_global_exit(1); + } + + /* Sanity check the case with NULL status array */ + completed_idx = shmemx_int_wait_until_any(flags, npes, NULL, SHMEM_CMP_EQ, 1); + + if (completed_idx >= npes) + shmem_global_exit(2); + + shmem_finalize(); + return 0; +} diff --git a/test/shmemx/shmemx_wait_until_some.c b/test/shmemx/shmemx_wait_until_some.c new file mode 100644 index 000000000..b806bf4f1 --- /dev/null +++ b/test/shmemx/shmemx_wait_until_some.c @@ -0,0 +1,62 @@ +#include +#include +#include + +#define N 100 + +int main(void) +{ + int total_sum = 0; + + shmem_init(); + int mype = shmem_my_pe(); + int npes = shmem_n_pes(); + + int *my_data = malloc(N * sizeof(int)); + int *all_data = shmem_malloc(N * npes * sizeof(int)); + + int *flags = shmem_calloc(npes, sizeof(int)); + size_t *indices = malloc(npes * sizeof(size_t)); + int *status = calloc(npes, sizeof(int)); + + for (int i = 0; i < N; i++) + my_data[i] = mype*N + i; + + for (int i = 0; i < npes; i++) + shmem_int_put_nbi(&all_data[mype*N], my_data, N, i); + + shmem_fence(); + + for (int i = 0; i < npes; i++) + shmem_int_p(&flags[mype], 1, i); + + size_t ncompleted; + while ((ncompleted = shmemx_int_wait_until_some(flags, npes, indices, + status, SHMEM_CMP_NE, 0))) { + for (size_t i = 0; i < ncompleted; i++) { + for (size_t j = 0; j < N; j++) + total_sum += all_data[indices[i]*N + j]; + } + } + + /* Check the flags array */ + for (int i = 0; i < npes; i++) { + if (flags[i] != 1) + shmem_global_exit(0); + } + + /* check result */ + int M = N * npes - 1; + if (total_sum != M * (M + 1) / 2) { + shmem_global_exit(1); + } + + /* Sanity check the case with NULL status array */ + ncompleted = shmemx_int_wait_until_some(flags, npes, indices, NULL, SHMEM_CMP_EQ, 1); + + if (ncompleted != npes) + shmem_global_exit(2); + + shmem_finalize(); + return 0; +} diff --git a/test/unit/Makefile.am b/test/unit/Makefile.am index 3271fccab..2f78bcdaa 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/c11_test_shmem_atomic_add.c b/test/unit/c11_test_shmem_atomic_add.c index 5484fd277..58686d5ff 100644 --- a/test/unit/c11_test_shmem_atomic_add.c +++ b/test/unit/c11_test_shmem_atomic_add.c @@ -32,7 +32,6 @@ #include #include -#include #include #include @@ -132,7 +131,7 @@ enum op { ADD = 0, ATOMIC_ADD, CTX_ATOMIC_ADD, FADD, ATOMIC_FETCH_ADD, mype, #OP, #TYPE); \ rc = EXIT_FAILURE; \ } \ - } while (false) + } while (0) #else #define TEST_SHMEM_ADD(OP, TYPE) diff --git a/test/unit/c11_test_shmem_atomic_and.c b/test/unit/c11_test_shmem_atomic_and.c index 1fd4513f0..1484fed2a 100644 --- a/test/unit/c11_test_shmem_atomic_and.c +++ b/test/unit/c11_test_shmem_atomic_and.c @@ -33,7 +33,6 @@ #include #include #include -#include #include #include @@ -119,7 +118,7 @@ enum op { AND = 0, CTX_AND, FETCH_AND, CTX_FETCH_AND, FETCH_AND_NBI, mype, #OP, #TYPE); \ rc = EXIT_FAILURE; \ } \ - } while (false) + } while (0) #else #define TEST_SHMEM_AND(OP, TYPE) diff --git a/test/unit/c11_test_shmem_atomic_cswap.c b/test/unit/c11_test_shmem_atomic_cswap.c index 55f6396fa..d2d0c079e 100644 --- a/test/unit/c11_test_shmem_atomic_cswap.c +++ b/test/unit/c11_test_shmem_atomic_cswap.c @@ -32,7 +32,6 @@ #include #include -#include #include #include @@ -104,7 +103,7 @@ enum op { CSWAP = 0, ATOMIC_COMPARE_SWAP, CTX_ATOMIC_COMPARE_SWAP, mype, #OP, #TYPE); \ rc = EXIT_FAILURE; \ } \ - } while (false) + } while (0) #else #define TEST_SHMEM_CSWAP(OP, TYPE) diff --git a/test/unit/c11_test_shmem_atomic_fetch.c b/test/unit/c11_test_shmem_atomic_fetch.c index 93ae82bcb..30affff02 100644 --- a/test/unit/c11_test_shmem_atomic_fetch.c +++ b/test/unit/c11_test_shmem_atomic_fetch.c @@ -32,7 +32,6 @@ #include #include -#include #include #include @@ -95,7 +94,7 @@ enum op { FETCH = 0, ATOMIC_FETCH, CTX_ATOMIC_FETCH, ATOMIC_FETCH_NBI, "TEST_SHMEM_FETCH(%s, %s)\n", mype, #OP, #TYPE); \ rc = EXIT_FAILURE; \ } \ - } while (false) + } while (0) #else #define TEST_SHMEM_FETCH(OP, TYPE) diff --git a/test/unit/c11_test_shmem_atomic_inc.c b/test/unit/c11_test_shmem_atomic_inc.c index 4363701d4..4fab8c293 100644 --- a/test/unit/c11_test_shmem_atomic_inc.c +++ b/test/unit/c11_test_shmem_atomic_inc.c @@ -32,7 +32,6 @@ #include #include -#include #include #include @@ -132,7 +131,7 @@ enum op { INC = 0, ATOMIC_INC, CTX_ATOMIC_INC, FINC, ATOMIC_FETCH_INC, mype, #OP, #TYPE); \ rc = EXIT_FAILURE; \ } \ - } while (false) + } while (0) #else #define TEST_SHMEM_INC(OP, TYPE) diff --git a/test/unit/c11_test_shmem_atomic_or.c b/test/unit/c11_test_shmem_atomic_or.c index 6b1484c92..05117454b 100644 --- a/test/unit/c11_test_shmem_atomic_or.c +++ b/test/unit/c11_test_shmem_atomic_or.c @@ -33,7 +33,6 @@ #include #include #include -#include #include #include @@ -121,7 +120,7 @@ enum op { OR = 0, CTX_OR, FETCH_OR, CTX_FETCH_OR, FETCH_OR_NBI, mype, #OP, #TYPE); \ rc = EXIT_FAILURE; \ } \ - } while (false) + } while (0) #else #define TEST_SHMEM_OR(OP, TYPE) diff --git a/test/unit/c11_test_shmem_atomic_set.c b/test/unit/c11_test_shmem_atomic_set.c index 453f35b57..16dc1cea3 100644 --- a/test/unit/c11_test_shmem_atomic_set.c +++ b/test/unit/c11_test_shmem_atomic_set.c @@ -32,7 +32,6 @@ #include #include -#include #include #include @@ -71,7 +70,7 @@ enum op { SET = 0, ATOMIC_SET, CTX_ATOMIC_SET }; "TEST_SHMEM_SET(%s, %s)\n", mype, #OP, #TYPE); \ rc = EXIT_FAILURE; \ } \ - } while (false) + } while (0) #else #define TEST_SHMEM_SET(OP, TYPE) diff --git a/test/unit/c11_test_shmem_atomic_swap.c b/test/unit/c11_test_shmem_atomic_swap.c index 32af2057f..de12c84b9 100644 --- a/test/unit/c11_test_shmem_atomic_swap.c +++ b/test/unit/c11_test_shmem_atomic_swap.c @@ -32,7 +32,6 @@ #include #include -#include #include #include @@ -100,7 +99,7 @@ enum op { SWAP = 0, ATOMIC_SWAP, CTX_ATOMIC_SWAP, ATOMIC_SWAP_NBI, mype, #OP, #TYPE); \ rc = EXIT_FAILURE; \ } \ - } while (false) + } while (0) #else #define TEST_SHMEM_SWAP(OP, TYPE) diff --git a/test/unit/c11_test_shmem_atomic_xor.c b/test/unit/c11_test_shmem_atomic_xor.c index cf2d9aa5f..286d9acb4 100644 --- a/test/unit/c11_test_shmem_atomic_xor.c +++ b/test/unit/c11_test_shmem_atomic_xor.c @@ -33,7 +33,6 @@ #include #include #include -#include #include #include @@ -119,7 +118,7 @@ enum op { XOR = 0, CTX_XOR, FETCH_XOR, CTX_FETCH_XOR, FETCH_XOR_NBI, mype, #OP, #TYPE); \ rc = EXIT_FAILURE; \ } \ - } while (false) + } while (0) #else #define TEST_SHMEM_XOR(OP, TYPE) diff --git a/test/unit/c11_test_shmem_g.c b/test/unit/c11_test_shmem_g.c index 4c6153306..969dd1386 100644 --- a/test/unit/c11_test_shmem_g.c +++ b/test/unit/c11_test_shmem_g.c @@ -32,7 +32,6 @@ #include #include -#include #include #include @@ -56,7 +55,7 @@ (int)(USE_CTX), #TYPE); \ rc = EXIT_FAILURE; \ } \ - } while (false) + } while (0) #else #define TEST_SHMEM_G(USE_CTX, TYPE) diff --git a/test/unit/c11_test_shmem_get.c b/test/unit/c11_test_shmem_get.c index 278a924ec..30487d37a 100644 --- a/test/unit/c11_test_shmem_get.c +++ b/test/unit/c11_test_shmem_get.c @@ -32,7 +32,6 @@ #include #include -#include #include #include @@ -80,7 +79,7 @@ enum op { GET = 0, IGET, GET_NBI }; (int)(USE_CTX), #TYPE); \ rc = EXIT_FAILURE; \ } \ - } while (false) + } while (0) #else #define TEST_SHMEM_GET(OP, USE_CTX, TYPE) diff --git a/test/unit/c11_test_shmem_p.c b/test/unit/c11_test_shmem_p.c index 2a40cc6ac..56adb0fc9 100644 --- a/test/unit/c11_test_shmem_p.c +++ b/test/unit/c11_test_shmem_p.c @@ -32,7 +32,6 @@ #include #include -#include #include #include @@ -54,7 +53,7 @@ (int)(USE_CTX), #TYPE); \ rc = EXIT_FAILURE; \ } \ - } while (false) + } while (0) #else #define TEST_SHMEM_P(USE_CTX, TYPE) diff --git a/test/unit/c11_test_shmem_put.c b/test/unit/c11_test_shmem_put.c index adf194220..0f50a77ad 100644 --- a/test/unit/c11_test_shmem_put.c +++ b/test/unit/c11_test_shmem_put.c @@ -32,7 +32,6 @@ #include #include -#include #include #include @@ -80,7 +79,7 @@ enum op { PUT = 0, IPUT, PUT_NBI }; #OP, (int)(USE_CTX), #TYPE); \ rc = EXIT_FAILURE; \ } \ - } while (false) + } while (0) #else #define TEST_SHMEM_PUT(OP, USE_CTX, TYPE) diff --git a/test/unit/c11_test_shmem_test.c b/test/unit/c11_test_shmem_test.c index 2a6dfcfeb..978c6ab11 100644 --- a/test/unit/c11_test_shmem_test.c +++ b/test/unit/c11_test_shmem_test.c @@ -32,7 +32,6 @@ #include #include -#include #include #include @@ -50,7 +49,7 @@ "TEST_SHMEM_TEST(%s)\n", mype, #TYPE); \ rc = EXIT_FAILURE; \ } \ - } while (false) + } while (0) #else #define TEST_SHMEM_TEST(TYPE) diff --git a/test/unit/c11_test_shmem_wait_until.c b/test/unit/c11_test_shmem_wait_until.c index c152765cf..cc8e97131 100644 --- a/test/unit/c11_test_shmem_wait_until.c +++ b/test/unit/c11_test_shmem_wait_until.c @@ -32,7 +32,6 @@ #include #include -#include #include #include @@ -50,7 +49,7 @@ "TEST_SHMEM_WAIT_UNTIL(%s)\n", mype, #TYPE); \ rc = EXIT_FAILURE; \ } \ - } while (false) + } while (0) #else #define TEST_SHMEM_WAIT_UNTIL(TYPE) diff --git a/test/unit/cxx_test_shmem_atomic_add.cpp b/test/unit/cxx_test_shmem_atomic_add.cpp index 3c8f73d00..96e673a97 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 d84cce7e2..1d8550ac8 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 d81c4d4cc..0a3983c94 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 41c6700d8..981edb3eb 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 ecd642259..820023d17 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 5463f02c9..cd0704615 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 9cb15077b..a06ed0265 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 ef9e278ff..817a7d8ca 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 6d5144d92..e44fb03c4 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 a7912a789..0ce30716a 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 437c27977..d37762d43 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 9dfbd7ece..d51a29ab7 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 196df8d0b..ce716544d 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 8c9019921..b424ed7db 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 92315a649..61bf29b9c 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;