Skip to content

Commit

Permalink
Merge pull request #1123 from wrrobin/pr/set-add
Browse files Browse the repository at this point in the history
Signal set add
  • Loading branch information
wrrobin authored May 3, 2024
2 parents e3ba48e + b1bdcc8 commit 7857a35
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "modules/tests-sos"]
path = modules/tests-sos
url = ../../ronawho/tests-sos.git
branch = fix_team_get_config_test
url = ../../openshmem-org/tests-sos.git
branch = main
12 changes: 12 additions & 0 deletions mpp/shmemx.h4
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,18 @@ SHMEM_BIND_C11_RMA(`SHMEM_CTX_C11_GEN_IBGET', `, \') \
SHMEM_BIND_C11_RMA(`SHMEM_C11_GEN_IBGET', `, \') \
)(__VA_ARGS__)

#define shmemx_signal_set(...) \
_Generic(SHMEM_C11_TYPE_EVAL_PTR_OR_SCALAR(SHMEM_C11_ARG0(__VA_ARGS__)), \
shmem_ctx_t: shmemx_ctx_signal_set, \
uint64_t*: shmemx_signal_set \
)(__VA_ARGS__)

#define shmemx_signal_add(...) \
_Generic(SHMEM_C11_TYPE_EVAL_PTR_OR_SCALAR(SHMEM_C11_ARG0(__VA_ARGS__)), \
shmem_ctx_t: shmemx_ctx_signal_add, \
uint64_t*: shmemx_signal_add \
)(__VA_ARGS__)

#endif /* C11 */

#endif /* SHMEMX_H */
6 changes: 6 additions & 0 deletions mpp/shmemx_c_func.h4
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ 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);

/* Signal extensions */
SHMEM_FUNCTION_ATTRIBUTES void SHPRE()shmemx_signal_add(uint64_t *sig_addr, uint64_t signal, int pe);
SHMEM_FUNCTION_ATTRIBUTES void SHPRE()shmemx_ctx_signal_add(shmem_ctx_t ctx, uint64_t *sig_addr, uint64_t signal, int pe);
SHMEM_FUNCTION_ATTRIBUTES void SHPRE()shmemx_signal_set(uint64_t *sig_addr, uint64_t signal, int pe);
SHMEM_FUNCTION_ATTRIBUTES void SHPRE()shmemx_ctx_signal_set(shmem_ctx_t ctx, uint64_t *sig_addr, uint64_t signal, int pe);

/* Separate initializers */
SHMEM_FUNCTION_ATTRIBUTES void SHPRE()shmemx_heap_create(void *base, size_t size, int device_type, int device_index);
SHMEM_FUNCTION_ATTRIBUTES void SHPRE()shmemx_heap_preinit();
Expand Down
54 changes: 54 additions & 0 deletions src/data_c.c4
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,14 @@ SHMEM_PROF_DEF_CTX_PUT_N_SIGNAL_NBI(`mem')
#define shmemx_ct_wait pshmemx_ct_wait
#pragma weak shmem_signal_fetch = pshmem_signal_fetch
#define shmem_signal_fetch pshmem_signal_fetch
#pragma weak shmemx_signal_add = pshmemx_signal_add
#define shmemx_signal_add pshmemx_signal_add
#pragma weak shmemx_signal_set = pshmemx_signal_set
#define shmemx_signal_set pshmemx_signal_set
#pragma weak shmemx_ctx_signal_add = pshmemx_ctx_signal_add
#define shmemx_ctx_signal_add pshmemx_ctx_signal_add
#pragma weak shmemx_ctx_signal_set = pshmemx_ctx_signal_set
#define shmemx_ctx_signal_set pshmemx_ctx_signal_set

#endif /* ENABLE_PROFILING */

Expand Down Expand Up @@ -870,6 +878,52 @@ shmem_signal_fetch(const uint64_t* sig_addr)
return val;
}

void SHMEM_FUNCTION_ATTRIBUTES
shmemx_signal_add(uint64_t *sig_addr, uint64_t signal, int pe)
{
SHMEM_ERR_CHECK_INITIALIZED();
SHMEM_ERR_CHECK_PE(pe);
SHMEM_ERR_CHECK_SYMMETRIC(sig_addr, sizeof(uint64_t));

shmem_internal_atomic(SHMEM_CTX_DEFAULT, sig_addr, &signal, sizeof(uint64_t),
pe, SHM_INTERNAL_SUM, SHM_INTERNAL_UINT64);
}

void SHMEM_FUNCTION_ATTRIBUTES
shmemx_ctx_signal_add(shmem_ctx_t ctx, uint64_t *sig_addr, uint64_t signal, int pe)
{
SHMEM_ERR_CHECK_INITIALIZED();
SHMEM_ERR_CHECK_PE(pe);
SHMEM_ERR_CHECK_CTX(ctx);
SHMEM_ERR_CHECK_SYMMETRIC(sig_addr, sizeof(uint64_t));

shmem_internal_atomic(ctx, sig_addr, &signal, sizeof(uint64_t),
pe, SHM_INTERNAL_SUM, SHM_INTERNAL_UINT64);
}

void SHMEM_FUNCTION_ATTRIBUTES
shmemx_signal_set(uint64_t *sig_addr, uint64_t signal, int pe)
{
SHMEM_ERR_CHECK_INITIALIZED();
SHMEM_ERR_CHECK_PE(pe);
SHMEM_ERR_CHECK_SYMMETRIC(sig_addr, sizeof(uint64_t));

shmem_internal_atomic_set(SHMEM_CTX_DEFAULT, (void *) sig_addr, &signal,
sizeof(uint64_t), pe, SHM_INTERNAL_UINT64);
}

void SHMEM_FUNCTION_ATTRIBUTES
shmemx_ctx_signal_set(shmem_ctx_t ctx, uint64_t *sig_addr, uint64_t signal, int pe)
{
SHMEM_ERR_CHECK_INITIALIZED();
SHMEM_ERR_CHECK_PE(pe);
SHMEM_ERR_CHECK_CTX(ctx);
SHMEM_ERR_CHECK_SYMMETRIC(sig_addr, sizeof(uint64_t));

shmem_internal_atomic_set(ctx, (void *) sig_addr, &signal,
sizeof(uint64_t), pe, SHM_INTERNAL_UINT64);
}

void SHMEM_FUNCTION_ATTRIBUTES
shmemx_getmem_ct(shmemx_ct_t ct, void *target, const void *source, size_t nelems, int pe)
{
Expand Down

0 comments on commit 7857a35

Please sign in to comment.