From 9094d8ef038640f4da5454ae779946424fd2fb69 Mon Sep 17 00:00:00 2001 From: David Ozog Date: Wed, 16 Aug 2023 16:52:44 -0400 Subject: [PATCH 1/2] Add .gitignore reflecting some SOS autotools files --- .gitignore | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7725ef2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,16 @@ +Makefile.in +aclocal.m4 +autom4te.cache +configure + +config/compile +config/config.guess +config/config.sub +config/depcomp +config/install-sh +config/libtool.m4 +config/ltmain.sh +config/lt*.m4 +config/missing + +config/test-driver From 2839b08c61858e4752c60f56d73cb7d9131fc72c Mon Sep 17 00:00:00 2001 From: David Ozog Date: Wed, 16 Aug 2023 17:14:13 -0400 Subject: [PATCH 2/2] Sync with SOS v1.5.2 --- configure.ac | 5 + .../shmem_perf_suite/round_t_latency.h | 4 +- test/shmemx/Makefile.am | 8 +- test/shmemx/shmem_malloc_with_hints.c | 101 ++++++++++ test/unit/Makefile.am | 9 + test/unit/bcast_in_place.c | 63 ++++++ test/unit/iput128.c | 8 +- test/unit/shmem_ctx_get_team.c | 80 ++++++++ test/unit/shmem_malloc_with_hints.c | 7 +- test/unit/shmem_ptr.c | 24 ++- test/unit/shmem_team_negative_stride.c | 118 +++++++++++ test/unit/shmem_team_ptr.c | 187 ++++++++++++++++++ test/unit/waituntil.c | 5 +- 13 files changed, 602 insertions(+), 17 deletions(-) create mode 100644 test/shmemx/shmem_malloc_with_hints.c create mode 100644 test/unit/bcast_in_place.c create mode 100644 test/unit/shmem_ctx_get_team.c create mode 100644 test/unit/shmem_team_negative_stride.c create mode 100644 test/unit/shmem_team_ptr.c diff --git a/configure.ac b/configure.ac index 16b04ff..4c8b6da 100755 --- a/configure.ac +++ b/configure.ac @@ -44,6 +44,11 @@ AC_ARG_ENABLE([debug], [AC_HELP_STRING([--enable-debug], [Include debugging symbols (default: disabled)])]) +AC_ARG_ENABLE([deprecated-tests], + [AC_HELP_STRING([--enable-deprecated-tests], + [Enable deprecated SHMEM API calls in tests (default:disabled)])]) +AM_CONDITIONAL([ENABLE_DEPRECATED_TESTS], [test "$enable_deprecated_tests" = "yes"]) + AC_ARG_WITH([test-runner], [AC_HELP_STRING([--with-test-runner], [Command used to run tests (default: 'oshrun -np $(NPROCS)')])]) diff --git a/test/performance/shmem_perf_suite/round_t_latency.h b/test/performance/shmem_perf_suite/round_t_latency.h index 4910e2d..bcfa9a8 100644 --- a/test/performance/shmem_perf_suite/round_t_latency.h +++ b/test/performance/shmem_perf_suite/round_t_latency.h @@ -110,7 +110,7 @@ void long_element_round_trip_latency_put(perf_metrics_t * const metric_info) if(i == metric_info->warmup) start = perf_shmemx_wtime(); - shmem_long_p(metric_info->target, ++tmp, dest); + shmem_long_atomic_set(metric_info->target, ++tmp, dest); shmem_long_wait_until(metric_info->target, SHMEM_CMP_EQ, tmp); } end = perf_shmemx_wtime(); @@ -120,7 +120,7 @@ void long_element_round_trip_latency_put(perf_metrics_t * const metric_info) } else { for (i = 0; i < metric_info->trials + metric_info->warmup; i++) { shmem_long_wait_until(metric_info->target, SHMEM_CMP_EQ, ++tmp); - shmem_long_p(metric_info->target, tmp, dest); + shmem_long_atomic_set(metric_info->target, tmp, dest); } } diff --git a/test/shmemx/Makefile.am b/test/shmemx/Makefile.am index df57831..c709ce8 100644 --- a/test/shmemx/Makefile.am +++ b/test/shmemx/Makefile.am @@ -20,7 +20,8 @@ endif if SHMEMX_TESTS check_PROGRAMS += \ - perf_counter + perf_counter \ + shmem_malloc_with_hints if HAVE_PTHREADS check_PROGRAMS += \ @@ -78,6 +79,11 @@ gettid_register_LDADD = $(LDADD) $(PTHREAD_CFLAGS) AM_CPPFLAGS += -DENABLE_SHMEMX_TESTS +if ENABLE_DEPRECATED_TESTS +AM_CPPFLAGS += -DENABLE_DEPRECATED_TESTS +AM_CFLAGS = -DENABLE_DEPRECATED_TESTS +endif + # C++ Tests cxx_test_shmem_g_SOURCES = cxx_test_shmem_g.cpp cxx_test_shmem_get_SOURCES = cxx_test_shmem_get.cpp diff --git a/test/shmemx/shmem_malloc_with_hints.c b/test/shmemx/shmem_malloc_with_hints.c new file mode 100644 index 0000000..6fe78ee --- /dev/null +++ b/test/shmemx/shmem_malloc_with_hints.c @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2022 Intel Corporation. All rights reserved. + * This software is available to you under the BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include +#include +#include +#include + +#define N 128 +#define SHMEM_MALLOC_INVALID_HINT ~(SHMEM_MALLOC_ATOMICS_REMOTE) + +int main(int argc, char **argv) { + int npes, mype; + int errors = 0; + + shmem_init(); + + npes = shmem_n_pes(); + mype = shmem_my_pe(); + + int *src[N]; + + /* Allocate an array of N buffers on the symmeytric heap */ + for (int i = 0; i < N; i++) + src[i] = (int *)shmem_malloc_with_hints(N * sizeof(int), SHMEMX_MALLOC_NO_BARRIER); + + shmem_barrier_all(); /* Synchronization is required after using the SHMEMX_MALLOC_NO_BARRIER hint */ + int *dst = (int *)malloc(N * sizeof(int)); + + for (int i = 0; i < N; i++) { + for (int j = 0; j < N; j++) { + src[i][j] = -1; + } + } + + /* src is initialized to become a diagonal matrix */ + for (int i = 0; i < N; i++) { + src[i][i] = i; + dst[i] = -1; + } + + shmem_sync_all(); /* sync sender and receiver */ + + if (mype == 0) { + for (int i = 0; i < N; i++) { + /* get elements from src's diagonal on each PE and copy into dst on PE 0 */ + shmem_int_get(&dst[i], &src[i][i], 1, i % npes); + } + } + + shmem_barrier_all(); /* sync sender and receiver */ + + if (mype == 0) { + for (int i = 0 ; i < N ; ++i) { + if (src[i][i] != dst[i]) { + printf("%d,%d ", src[i][i], dst[i]); + ++errors; + } + } + if(errors) { + printf("\nFailed with %d errors\n", errors); + shmem_global_exit(errors); + } + } + + for (int i = 0; i < N; i++) + shmem_free(src[i]); + free(dst); + + if (mype == 0) + printf("Passed with 0 errors\n"); + + shmem_finalize(); + + return 0; +} diff --git a/test/unit/Makefile.am b/test/unit/Makefile.am index e7fbb80..9d7e752 100644 --- a/test/unit/Makefile.am +++ b/test/unit/Makefile.am @@ -96,6 +96,7 @@ check_PROGRAMS = \ broadcast_active_set \ reduce_active_set \ reduce_in_place \ + bcast_in_place \ collect_active_set \ atomic_bitwise \ nop_collectives \ @@ -105,6 +106,7 @@ check_PROGRAMS = \ many-ctx \ shmem_test \ shmem_ptr \ + shmem_team_ptr \ shmem_malloc_with_hints \ put_signal \ put_signal_nbi \ @@ -119,6 +121,8 @@ check_PROGRAMS = \ shmem_team_translate \ shmem_team_reduce \ shmem_team_get_config \ + shmem_team_negative_stride \ + shmem_ctx_get_team \ atomic_nbi \ fadd_nbi @@ -206,6 +210,11 @@ AM_CFLAGS = -DENABLE_SHMEMX_TESTS AM_CPPFLAGS += -DENABLE_SHMEMX_TESTS endif +if ENABLE_DEPRECATED_TESTS +AM_CFLAGS = -DENABLE_DEPRECATED_TESTS +AM_CPPFLAGS += -DENABLE_DEPRECATED_TESTS +endif + # C Tests with special flags rma_coverage_pshmem_SOURCES = rma_coverage.c rma_coverage_pshmem_CFLAGS = -DTEST_PSHMEM diff --git a/test/unit/bcast_in_place.c b/test/unit/bcast_in_place.c new file mode 100644 index 0000000..c10bd50 --- /dev/null +++ b/test/unit/bcast_in_place.c @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2022 Intel Corporation. All rights reserved. + * This software is available to you under the BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include + +#define NELEM 10 + +long src[NELEM]; + +int main(void) +{ + int me; + int errors = 0; + + shmem_init(); + + me = shmem_my_pe(); + + for (int i = 0; i < NELEM; i++) + src[i] = me + i; + + shmem_barrier_all(); + + shmem_long_broadcast(SHMEM_TEAM_WORLD, src, src, NELEM, 0); + + /* Validate broadcast data */ + for (int j = 0; j < NELEM; j++) { + long expected = j; + if (src[j] != expected) { + printf("%d: Expected src[%d] = %ld, got src[%d] = %ld\n", me, j, expected, j, src[j]); + errors++; + } + } + + shmem_finalize(); + + return errors != 0; +} diff --git a/test/unit/iput128.c b/test/unit/iput128.c index 8a32c57..bf2f6a2 100644 --- a/test/unit/iput128.c +++ b/test/unit/iput128.c @@ -35,11 +35,13 @@ #include #include -#define _IPUT(a) shmem_##a##_iput -//#define IPUT _IPUT(double) #define IPUT shmem_iput128 +#ifndef __APPLE__ #define DataType long double +#else +#define DataType __int128 +#endif static DataType source[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; static DataType target[10]; @@ -68,10 +70,12 @@ int main(int argc, char **argv) target[3] != 7 || target[4] != 9) { +#ifndef __APPLE__ printf("ERR: target on PE %d is %Lf %Lf %Lf %Lf %Lf\n" " Expected 1,3,5,7,9?\n", me, target[0], target[1], target[2], target[3], target[4] ); +#endif rc = 1; } } diff --git a/test/unit/shmem_ctx_get_team.c b/test/unit/shmem_ctx_get_team.c new file mode 100644 index 0000000..489d5a2 --- /dev/null +++ b/test/unit/shmem_ctx_get_team.c @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2022 Intel Corporation. All rights reserved. + * This software is available to you under the BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include + +int main(void) { + int ret; + shmem_team_t retrieved_team; + + shmem_init(); + + if (shmem_n_pes() < 2) { + fprintf(stderr, "ERR - Requires at least 2 PEs\n"); + shmem_finalize(); + return 0; + } + + /* test for invalid context */ + ret = shmem_ctx_get_team(SHMEM_CTX_INVALID, &retrieved_team); + if (ret == 0 || retrieved_team != SHMEM_TEAM_INVALID) { + fprintf(stderr, "Error in return values for SHMEM_CTX_INVALID\n"); + shmem_global_exit(1); + } + + /* test for default context */ + ret = shmem_ctx_get_team(SHMEM_CTX_DEFAULT, &retrieved_team); + if (ret != 0 || retrieved_team != SHMEM_TEAM_WORLD) { + fprintf(stderr, "Error in return values for SHMEM_CTX_DEFAULT\n"); + shmem_global_exit(2); + } + + /* test for a created context on a user defined team*/ + shmem_team_t new_team; + shmem_team_config_t *config; + + config = NULL; + int npes = shmem_n_pes(); + + ret = shmem_team_split_strided(SHMEM_TEAM_WORLD, 0, 2, (npes + 1) / 2, + config, 0, &new_team); + if (new_team != SHMEM_TEAM_INVALID) { + shmem_ctx_t team_ctx; + if (!shmem_team_create_ctx(new_team, 0L, &team_ctx)) { + ret = shmem_ctx_get_team(team_ctx, &retrieved_team); + if (ret != 0 || retrieved_team != new_team) { + fprintf(stderr, "Error in return values for a team context\n"); + shmem_global_exit(3); + } + } + } + + shmem_finalize(); + + return 0; +} diff --git a/test/unit/shmem_malloc_with_hints.c b/test/unit/shmem_malloc_with_hints.c index 5cf142b..7ae4046 100644 --- a/test/unit/shmem_malloc_with_hints.c +++ b/test/unit/shmem_malloc_with_hints.c @@ -88,12 +88,13 @@ int main(int argc, char **argv) { passed += sumtoall_with_malloc_hint(SHMEM_MALLOC_ATOMICS_REMOTE | SHMEM_MALLOC_SIGNAL_REMOTE, mype, npes); passed += sumtoall_with_malloc_hint(SHMEM_MALLOC_INVALID_HINT, mype, npes); - fail = NUM_TESTS - passed; if (mype == 0) { - if (passed != NUM_TESTS) - printf("%d out of %d tests passed\n", fail, NUM_TESTS); + if (passed != NUM_TESTS) { + printf("%d out of %d tests failed\n", fail, NUM_TESTS); + shmem_global_exit(fail); + } else printf("All %d tests passed\n", passed); } diff --git a/test/unit/shmem_ptr.c b/test/unit/shmem_ptr.c index cb2c5fa..bcdc877 100644 --- a/test/unit/shmem_ptr.c +++ b/test/unit/shmem_ptr.c @@ -29,7 +29,7 @@ #include int main(void) { - int i, n, errors = 0; + int i, n, available, errors = 0; int me, npes; static int shr_data = -1; @@ -49,7 +49,7 @@ int main(void) { /* Check shmem_ptr on data segment */ - for (i = n = 0; i < npes; i++) { + for (i = n = available = 0; i < npes; i++) { int * ptr = (int *) shmem_ptr(&shr_data, i); if (ptr != NULL) { @@ -62,18 +62,23 @@ int main(void) { } } else if (i == me) { - printf("%2d: Error, shmem_ptr(data) returned NULL for my PE\n", me); - errors++; + printf("%2d: Error, shmem_ptr(data) returned NULL for my PE\n", me); + errors++; + } + else { + /* NULL is returned for remotely inaccessible data objects. + Enabling XPMEM / CMA will allow non-NULL value for on-node PEs */ + ++available; } } - printf("%2d: Found %d data segment peer(s)\n", me, n); + printf("%2d: Found %d data segment peer(s) (%d were inaccessible)\n", me, n, available); fflush(NULL); shmem_barrier_all(); /* Check shmem_ptr on heap segment */ - for (i = n = 0; i < npes; i++) { + for (i = n = available = 0; i < npes; i++) { int * ptr = (int *) shmem_ptr(shr_heap, i); if (ptr != NULL) { @@ -89,9 +94,14 @@ int main(void) { printf("%2d: Error, shmem_ptr(heap) returned NULL for my PE\n", me); errors++; } + else { + /* NULL is returned for remotely inaccessible data objects. + Enabling XPMEM / CMA will allow non-NULL value for on-node PEs */ + ++available; + } } - printf("%2d: Found %d heap segment peer(s)\n", me, n); + printf("%2d: Found %d heap segment peer(s) (%d were inaccessible)\n", me, n, available); shmem_finalize(); diff --git a/test/unit/shmem_team_negative_stride.c b/test/unit/shmem_team_negative_stride.c new file mode 100644 index 0000000..0e03666 --- /dev/null +++ b/test/unit/shmem_team_negative_stride.c @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2022 Intel Corporation. All rights reserved. + * This software is available to you under the BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include +#include + +int main(void) +{ + int i, me, npes; + int errors = 0; + + shmem_init(); + + me = shmem_my_pe(); + npes = shmem_n_pes(); + + if (npes < 2) { + if (me == 0) + printf("Test requires 2 or more PEs\n"); + shmem_finalize(); + return 0; + } + + int *src = shmem_malloc(npes * sizeof(int)); + int *dst = shmem_malloc(npes * sizeof(int)); + + for (i = 0; i < npes; i++) + src[i] = i; + + for (i = 0; i < npes; i++) + dst[i] = -1; + + if (me == 0) + printf("-1 stride:\n"); + + shmem_team_t new_team; + shmem_team_split_strided(SHMEM_TEAM_WORLD, npes - 1, -1, npes, NULL, 0, &new_team); + + if (new_team != SHMEM_TEAM_INVALID) { + int new_team_id = shmem_team_translate_pe(SHMEM_TEAM_WORLD, me, new_team); + + if (new_team_id != -1 && new_team_id == abs(me - npes + 1)) { + printf("world team ID = %d, new team ID = %d\n", me, new_team_id); + } else { + errors++; + } + + shmem_int_sum_reduce(new_team, dst, src, npes); + + for (i = 0; i < npes; i++) { + if (dst[i] != i * npes) { + printf("ERROR: dst[i] = %d, expected %d\n", dst[i], i * npes); + errors++; + } + } + } + + shmem_team_destroy(new_team); + + for (i = 0; i < npes; i++) + dst[i] = -1; + + if (me == 0) + printf("-2 stride:\n"); + + shmem_team_split_strided(SHMEM_TEAM_WORLD, npes - 1, -2, npes/2, NULL, 0, &new_team); + + if (new_team != SHMEM_TEAM_INVALID) { + int new_team_id = shmem_team_translate_pe(SHMEM_TEAM_WORLD, me, new_team); + + if (new_team_id != -1 && new_team_id == abs((npes - me - 1)/2)) { + printf("world team ID = %d, new team ID = %d\n", me, new_team_id); + } else { + errors++; + } + + shmem_int_sum_reduce(new_team, dst, src, npes); + + for (i = 0; i < npes; i++) { + if (dst[i] != i * (npes/2)) { + printf("ERROR: dst[i] = %d, expected %d\n", dst[i], i * (npes/2)); + errors++; + } + } + } + + shmem_team_destroy(new_team); + shmem_free(src); + shmem_free(dst); + shmem_finalize(); + + return errors != 0; +} diff --git a/test/unit/shmem_team_ptr.c b/test/unit/shmem_team_ptr.c new file mode 100644 index 0000000..e456371 --- /dev/null +++ b/test/unit/shmem_team_ptr.c @@ -0,0 +1,187 @@ +/* + * Copyright (c) 2022 Intel Corporation. All rights reserved. + * This software is available to you under the BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include + +int main(void) { + int i, n, available, errors = 0; + int me, team_me, npes; + + static int shr_world_data, shr_team_data = -1; + int * shr_heap; + + shmem_init(); + + me = shmem_my_pe(); + npes = shmem_n_pes(); + + if (npes == 1) { + if (me == 0) { + printf("Error, this test requires more than 1 process\n"); + } + shmem_finalize(); + return 0; + } + + shr_world_data = me; + + shmem_barrier_all(); + + /* Check shmem_team_ptr on data segment */ + for (i = n = available = 0; i < npes; i++) { + int * world_ptr = (int *) shmem_team_ptr(SHMEM_TEAM_WORLD, &shr_world_data, i); + + if (world_ptr != NULL) { + + int shr_world_peer = *world_ptr; + ++n; + + if (shr_world_peer != i) { + printf("%2d: Error, shr_world_data(%d) = %d, expected %d\n", me, i, shr_world_peer, i); + errors++; + } + } + else if (i == me) { + printf("%2d: Error, shmem_world_ptr(data) returned NULL for my PE\n", me); + errors++; + } + else { + /* NULL is returned for remotely inaccessible data objects. + Enabling XPMEM / CMA will allow non-NULL value for on-node PEs */ + ++available; + } + } + + printf("%2d: Found %d world team data segment peer(s) (%d were inaccessible)\n", me, n, available); + fflush(NULL); + shmem_barrier_all(); + + /* Check shmem_team_ptr on heap segment */ + shr_heap = shmem_malloc(sizeof(int)); + *shr_heap = me; + shmem_sync_all(); + + for (i = n = available = 0; i < npes; i++) { + int * world_ptr = (int *) shmem_team_ptr(SHMEM_TEAM_WORLD, shr_heap, i); + + if (world_ptr != NULL) { + int shr_world_peer = *world_ptr; + ++n; + + if (shr_world_peer != i) { + printf("%2d: Error, shr_world_heap(%d) = %d, expected %d\n", me, i, shr_world_peer, i); + errors++; + } + } + else if (i == me) { + printf("%2d: Error, shmem_team_ptr(heap) returned NULL for my PE\n", me); + errors++; + } + else { + /* NULL is returned for remotely inaccessible data objects. + Enabling XPMEM / CMA will allow non-NULL value for on-node PEs */ + ++available; + } + } + + printf("%2d: Found %d world team heap segment peer(s) (%d were inaccessible)\n", me, n, available); + fflush(NULL); + shmem_barrier_all(); + + // Create a team of PEs w/ odd numbered id's + shmem_team_t new_team; + shmem_team_split_strided(SHMEM_TEAM_WORLD, 1, 2, npes / 2, NULL, 0, &new_team); + if (new_team != SHMEM_TEAM_INVALID) { + team_me = shmem_team_my_pe(new_team); + shr_team_data = team_me; + shmem_team_sync(new_team); + + /* Check shmem_team_ptr on data segment */ + for (i = n = available = 0; i < npes / 2; i++) { + int * team_ptr = (int *) shmem_team_ptr(new_team, &shr_team_data, i); + + if (team_ptr != NULL) { + int shr_team_peer = *team_ptr; + ++n; + + if (shr_team_peer != i) { + printf("%2d: Error, shr_team_data(%d) = %d, expected %d\n", team_me, i, shr_team_peer, i); + errors++; + } + } + else if (i == team_me) { + printf("%2d: Error, i = %d, shmem_team_ptr(data) returned NULL for my PE\n", team_me, i); + errors++; + } + else { + /* NULL is returned for remotely inaccessible data objects. + Enabling XPMEM / CMA will allow non-NULL value for on-node PEs */ + ++available; + } + } + printf("%2d: Found %d world team data segment peer(s) (%d were inaccessible)\n", me, n, available); + fflush(NULL); + } + + /* Check shmem_team_ptr on heap segment */ + int * shr_team_heap = shmem_malloc(sizeof(int)); + if (new_team != SHMEM_TEAM_INVALID) { + team_me = shmem_team_my_pe(new_team); + *shr_team_heap = team_me; + shmem_team_sync(new_team); + + for (i = n = available = 0; i < npes / 2; i++) { + int * team_ptr = (int *) shmem_team_ptr(new_team, shr_team_heap, i); + + if (team_ptr != NULL) { + int shr_team_peer = *team_ptr; + ++n; + + if (shr_team_peer != i) { + printf("%2d: Error, shr_team_heap(%d) = %d, expected %d\n", me, i, shr_team_peer, i); + errors++; + } + } + else if (i == team_me) { + printf("%2d: Error, shmem_team_ptr(heap) returned NULL for my PE\n", team_me); + errors++; + } + else { + /* NULL is returned for remotely inaccessible data objects. + Enabling XPMEM / CMA will allow non-NULL value for on-node PEs */ + ++available; + } + } + printf("%2d: Found %d world team heap segment peer(s) (%d were inaccessible)\n", me, n, available); + } + + shmem_team_destroy(new_team); + shmem_finalize(); + + return errors != 0; +} diff --git a/test/unit/waituntil.c b/test/unit/waituntil.c index 66ffd20..ca52c3c 100644 --- a/test/unit/waituntil.c +++ b/test/unit/waituntil.c @@ -84,9 +84,10 @@ main(int argc, char* argv[]) shmem_barrier_all(); if (me == 0) { - memset(target, 0, sizeof(target)); + DataType zeros[10]; + memset(zeros, 0, sizeof(zeros)); for(pe=1; pe < num_pes; pe++) - SHM_PUT(target, target, 10, pe); + SHM_PUT(target, zeros, 10, pe); shmem_fence();