diff --git a/modules/tests-sos b/modules/tests-sos index d1adb71b..5e2d2053 160000 --- a/modules/tests-sos +++ b/modules/tests-sos @@ -1 +1 @@ -Subproject commit d1adb71bcf68e61ab800cefb238e4e05e3102ef9 +Subproject commit 5e2d205355db8482779d9fc458bfafe59849f8a8 diff --git a/mpp/shmem-def.h.in b/mpp/shmem-def.h.in index 0d8277ee..4ea3393b 100644 --- a/mpp/shmem-def.h.in +++ b/mpp/shmem-def.h.in @@ -99,6 +99,10 @@ typedef struct { int num_contexts; } shmem_team_config_t; +typedef struct { + size_t total_ops; +} shmem_session_config_t; + #if SHMEM_HAVE_ATTRIBUTE_VISIBILITY == 1 __attribute__((visibility("default"))) extern shmem_team_t SHMEM_TEAM_WORLD; __attribute__((visibility("default"))) extern shmem_team_t SHMEM_TEAM_SHARED; @@ -116,13 +120,9 @@ typedef struct { #define SHMEM_SIGNAL_SET 0 #define SHMEM_SIGNAL_ADD 1 -#define SHMEM_SESSION_OP_PUT (1l<<0) -#define SHMEM_SESSION_OP_GET (1l<<1) -#define SHMEM_SESSION_OP_PUT_SIGNAL (1l<<2) -#define SHMEM_SESSION_OP_AMO (1l<<3) -#define SHMEM_SESSION_OP_AMO_FETCH (1l<<4) -#define SHMEM_SESSION_CHAIN (1l<<5) -#define SHMEM_SESSION_UNIFORM_AMO (1l<<6) +#define SHMEM_SESSION_TOTAL_OPS (1l<<0) +#define SHMEM_SESSION_BATCH (1l<<0) +#define SHMEM_SESSION_SAME_AMO (1l<<1) #ifdef __cplusplus } /* extern "C" */ diff --git a/mpp/shmem_c_func.h4 b/mpp/shmem_c_func.h4 index cb9aace5..0b36ba8a 100644 --- a/mpp/shmem_c_func.h4 +++ b/mpp/shmem_c_func.h4 @@ -639,7 +639,7 @@ define(`SHMEM_C_CTX_FETCH_OR_NBI', SHMEM_DECLARE_FOR_BITWISE_AMO(`SHMEM_C_CTX_FETCH_OR_NBI') /* Session Routines */ -SHMEM_FUNCTION_ATTRIBUTES void SHPRE()shmem_session_start(long options, shmem_ctx_t ctx); +SHMEM_FUNCTION_ATTRIBUTES void SHPRE()shmem_session_start(shmem_ctx_t ctx, long options, const shmem_session_config_t *config, long config_mask); SHMEM_FUNCTION_ATTRIBUTES void SHPRE()shmem_session_stop(shmem_ctx_t ctx); /* Team Management Routines */ diff --git a/src/sessions_c.c b/src/sessions_c.c index 5d85a861..0fa14bac 100644 --- a/src/sessions_c.c +++ b/src/sessions_c.c @@ -1,6 +1,6 @@ /* -*- C -*- * - * Copyright (c) 2022 Intel Corporation. All rights reserved. + * Copyright (c) 2024 Intel Corporation. All rights reserved. * This software is available to you under the BSD license. * * This file is part of the Sandia OpenSHMEM software package. For license @@ -28,11 +28,11 @@ #endif /* ENABLE_PROFILING */ SHMEM_FUNCTION_ATTRIBUTES void -shmem_session_start(long options, shmem_ctx_t ctx) +shmem_session_start(shmem_ctx_t ctx, long options, const shmem_session_config_t *config, long config_mask) { SHMEM_ERR_CHECK_INITIALIZED(); - int ret = shmem_transport_session_start(options, (shmem_transport_ctx_t *) ctx); + int ret = shmem_transport_session_start((shmem_transport_ctx_t *) ctx, options, config, config_mask); if (0 != ret) { DEBUG_MSG("Session did not start correctly (%d)\n", ret); } else { diff --git a/src/transport_none.h b/src/transport_none.h index 19b558e7..74a8d914 100644 --- a/src/transport_none.h +++ b/src/transport_none.h @@ -372,7 +372,7 @@ void shmem_transport_pcntr_get_all(shmem_transport_ctx_t *ctx, shmemx_pcntr_t *p static inline int -shmem_transport_session_start(long options, shmem_transport_ctx_t *ctx) +shmem_transport_session_start(shmem_transport_ctx_t *ctx, long options, const shmem_session_config_t *config, long config_mask) { return 0; } diff --git a/src/transport_ofi.c b/src/transport_ofi.c index 0bf4e9dd..7f6a16e2 100644 --- a/src/transport_ofi.c +++ b/src/transport_ofi.c @@ -2123,7 +2123,7 @@ void shmem_transport_ctx_destroy(shmem_transport_ctx_t *ctx) } } -int shmem_transport_session_start(long options, shmem_transport_ctx_t *ctx) +int shmem_transport_session_start(shmem_transport_ctx_t *ctx, long options, const shmem_session_config_t *config, long config_mask) { return 0; } diff --git a/src/transport_ofi.h b/src/transport_ofi.h index b112fb23..cfb4abd9 100644 --- a/src/transport_ofi.h +++ b/src/transport_ofi.h @@ -348,7 +348,7 @@ void shmem_transport_probe(void) int shmem_transport_ctx_create(struct shmem_internal_team_t *team, long options, shmem_transport_ctx_t **ctx); void shmem_transport_ctx_destroy(shmem_transport_ctx_t *ctx); -int shmem_transport_session_start(long options, shmem_transport_ctx_t *ctx); +int shmem_transport_session_start(shmem_transport_ctx_t *ctx, long options, const shmem_session_config_t *config, long config_mask); int shmem_transport_session_stop(shmem_transport_ctx_t *ctx); int shmem_transport_init(void); diff --git a/src/transport_portals4.c b/src/transport_portals4.c index fc0252dc..2cd2f2a2 100644 --- a/src/transport_portals4.c +++ b/src/transport_portals4.c @@ -350,7 +350,7 @@ shmem_transport_ctx_destroy(shmem_transport_ctx_t *ctx) } int -shmem_transport_session_start(long options, shmem_transport_ctx_t *ctx) +shmem_transport_session_start(shmem_transport_ctx_t *ctx, long options, const shmem_session_config_t *config, long config_mask) { return 0; } diff --git a/src/transport_portals4.h b/src/transport_portals4.h index aba06cd4..3f860b94 100644 --- a/src/transport_portals4.h +++ b/src/transport_portals4.h @@ -150,7 +150,7 @@ extern shmem_transport_ctx_t shmem_transport_ctx_default; int shmem_transport_ctx_create(struct shmem_internal_team_t *team, long options, shmem_transport_ctx_t **ctx); void shmem_transport_ctx_destroy(shmem_transport_ctx_t *ctx); -int shmem_transport_session_start(long options, shmem_transport_ctx_t *ctx); +int shmem_transport_session_start(shmem_transport_ctx_t *ctx, long options, const shmem_session_config_t *config, long config_mask) int shmem_transport_session_stop(shmem_transport_ctx_t *ctx); /* diff --git a/src/transport_ucx.h b/src/transport_ucx.h index 1e0f1e0f..d34f127f 100644 --- a/src/transport_ucx.h +++ b/src/transport_ucx.h @@ -200,7 +200,7 @@ shmem_transport_ctx_destroy(shmem_transport_ctx_t *ctx) static inline int -shmem_transport_session_start(long options, shmem_transport_ctx_t *ctx) +shmem_transport_session_start(shmem_transport_ctx_t *ctx, long options, const shmem_session_config_t *config, long config_mask) { return 0; } diff --git a/test/spec-example/shmem_session_example.c b/test/spec-example/shmem_session_example.c index 8dc95bcd..12b4faa7 100644 --- a/test/spec-example/shmem_session_example.c +++ b/test/spec-example/shmem_session_example.c @@ -1,8 +1,12 @@ +/* * This test program is derived from an example program in the + * OpenSHMEM specification. + */ + #include #include #include -#define N_UPDATES (1lu << 17) +#define N_UPDATES (1lu << 18) #define N_INDICES (1lu << 10) #define N_VALUES (1lu << 31) @@ -16,17 +20,34 @@ int main(void) { int npes = shmem_n_pes(); srand(mype); - shmem_session_start(SHMEM_SESSION_UNIFORM_AMO, SHMEM_CTX_DEFAULT); + shmem_ctx_t ctx; + int ret = shmem_ctx_create(0, &ctx); + if (ret != 0) { + printf("%d: Error creating context (%d)\n", mype, ret); + shmem_global_exit(1); + } + + shmem_config_t config; + long config_mask; + config.total_ops = N_UPDATES; + config_mask = SHMEM_SESSION_TOTAL_OPS; + + shmem_session_start(ctx, SHMEM_SESSION_SAME_AMO, config, config_mask); for (size_t i = 0; i < N_UPDATES; i++) { int random_pe = rand() % npes; size_t random_idx = rand() % N_INDICES; uint64_t random_val = rand() % N_VALUES; - shmem_uint64_atomic_xor(&table[random_idx], random_val, random_pe); + shmem_uint64_atomic_xor(ctx, &table[random_idx], random_val, random_pe); } - shmem_session_stop(SHMEM_CTX_DEFAULT); + shmem_session_stop(ctx); + shmem_ctx_quiet(ctx); /* shmem_session_stop() does not quiet the context. */ + shmem_sync_all(); /* shmem_session_stop() does not synchronize. */ + + /* At this point, it is safe to check and/or validate the table result... */ + shmem_ctx_destroy(ctx); shmem_free(table); shmem_finalize(); return 0;