Skip to content

Commit

Permalink
Merge pull request #27 from davidozog/pr/SOS_v1.5.2_sync
Browse files Browse the repository at this point in the history
Sync with SOS v1.5.2
  • Loading branch information
davidozog authored Aug 28, 2023
2 parents 2e4e2de + 2839b08 commit 5f7905f
Show file tree
Hide file tree
Showing 14 changed files with 618 additions and 17 deletions.
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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)')])])
Expand Down
4 changes: 2 additions & 2 deletions test/performance/shmem_perf_suite/round_t_latency.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
}
}

Expand Down
8 changes: 7 additions & 1 deletion test/shmemx/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ endif

if SHMEMX_TESTS
check_PROGRAMS += \
perf_counter
perf_counter \
shmem_malloc_with_hints

if HAVE_PTHREADS
check_PROGRAMS += \
Expand Down Expand Up @@ -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
Expand Down
101 changes: 101 additions & 0 deletions test/shmemx/shmem_malloc_with_hints.c
Original file line number Diff line number Diff line change
@@ -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 <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <shmem.h>
#include <shmemx.h>

#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;
}
9 changes: 9 additions & 0 deletions test/unit/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -105,6 +106,7 @@ check_PROGRAMS = \
many-ctx \
shmem_test \
shmem_ptr \
shmem_team_ptr \
shmem_malloc_with_hints \
put_signal \
put_signal_nbi \
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down
63 changes: 63 additions & 0 deletions test/unit/bcast_in_place.c
Original file line number Diff line number Diff line change
@@ -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 <stdio.h>
#include <shmem.h>

#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;
}
8 changes: 6 additions & 2 deletions test/unit/iput128.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@

#include <stdio.h>
#include <shmem.h>
#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];
Expand Down Expand Up @@ -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;
}
}
Expand Down
80 changes: 80 additions & 0 deletions test/unit/shmem_ctx_get_team.c
Original file line number Diff line number Diff line change
@@ -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 <stdio.h>
#include <shmem.h>

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;
}
7 changes: 4 additions & 3 deletions test/unit/shmem_malloc_with_hints.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Loading

0 comments on commit 5f7905f

Please sign in to comment.