Skip to content

Commit

Permalink
Fix for XPMEM test failure
Browse files Browse the repository at this point in the history
  • Loading branch information
avincigu committed Jan 16, 2025
1 parent 013731a commit aa60eec
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 80 deletions.
8 changes: 4 additions & 4 deletions src/collectives.c
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ shmem_internal_op_to_all_linear(void *target, const void *source, size_t count,
SHMEM_WAIT_UNTIL(pSync, SHMEM_CMP_EQ, 0);

/* send data, ack, and wait for completion */
shmem_internal_atomicv(SHMEM_CTX_DEFAULT, target, source, count * type_size,
shmem_internal_atomicv(SHMEM_CTX_DEFAULT, target, source, count, type_size,
PE_start, op, datatype, &completion);
shmem_internal_put_wait(SHMEM_CTX_DEFAULT, &completion);
shmem_internal_fence(SHMEM_CTX_DEFAULT);
Expand Down Expand Up @@ -833,7 +833,7 @@ shmem_internal_op_to_all_tree(void *target, const void *source, size_t count, si
/* send data, ack, and wait for completion */
shmem_internal_atomicv(SHMEM_CTX_DEFAULT, target,
(num_children == 0) ? source : target,
count * type_size, parent,
count, type_size, parent,
op, datatype, &completion);
shmem_internal_put_wait(SHMEM_CTX_DEFAULT, &completion);
shmem_internal_fence(SHMEM_CTX_DEFAULT);
Expand Down Expand Up @@ -1086,7 +1086,7 @@ shmem_internal_scan_linear(void *target, const void *source, size_t count, size_
i < PE_size;
i++, pe += PE_stride) {

shmem_internal_atomicv(SHMEM_CTX_DEFAULT, target, source, count * type_size,
shmem_internal_atomicv(SHMEM_CTX_DEFAULT, target, source, count, type_size,
pe, op, datatype, &completion);
shmem_internal_put_wait(SHMEM_CTX_DEFAULT, &completion);
shmem_internal_fence(SHMEM_CTX_DEFAULT);
Expand Down Expand Up @@ -1193,7 +1193,7 @@ shmem_internal_scan_ring(void *target, const void *source, size_t count, size_t
i < PE_size;
i++, pe += PE_stride) {

shmem_internal_atomicv(SHMEM_CTX_DEFAULT, target, source, count * type_size,
shmem_internal_atomicv(SHMEM_CTX_DEFAULT, target, source, count, type_size,
pe, op, datatype, &completion);
shmem_internal_put_wait(SHMEM_CTX_DEFAULT, &completion);
shmem_internal_fence(SHMEM_CTX_DEFAULT);
Expand Down
12 changes: 7 additions & 5 deletions src/shmem_comm.h
Original file line number Diff line number Diff line change
Expand Up @@ -321,17 +321,16 @@ shmem_internal_fetch_atomic(shmem_ctx_t ctx, void *target, void *source, void *d
static inline
void
shmem_internal_atomicv(shmem_ctx_t ctx, void *target, const void *source,
size_t len, int pe, shm_internal_op_t op,
size_t count, size_t type_size, int pe, shm_internal_op_t op,
shm_internal_datatype_t datatype, long *completion)
{
size_t len = type_size * count;
shmem_internal_assert(len > 0);

#ifdef DISABLE_NONFETCH_AMO
/* FIXME: This is a temporary workaround to resolve a known issue with non-fetching AMOs when using
the CXI provider */
unsigned long long tmp_fetch = 0;
size_t type_size = SHMEM_Dtsize[SHMEM_TRANSPORT_DTYPE(datatype)];
size_t count = len / type_size;
for (size_t i = 0; i < count; i++) {
shmem_internal_fetch_atomic(ctx, ((uint8_t *) target) + (i * type_size),
((uint8_t *) source) + (i * type_size), &tmp_fetch, type_size,
Expand All @@ -341,8 +340,11 @@ shmem_internal_atomicv(shmem_ctx_t ctx, void *target, const void *source,
*completion += 1;
#else
if (shmem_shr_transport_use_atomic(ctx, target, len, pe, datatype)) {
shmem_shr_transport_atomicv(ctx, target, source, len, pe, op, datatype);
shmem_transport_quiet(ctx);
for (size_t i = 0; i < count; i++) {
shmem_shr_transport_atomic(ctx, ((uint8_t *) target) + (i * type_size),
((uint8_t *) source) + (i * type_size), type_size,
pe, op, datatype);
}
} else {
shmem_transport_atomicv((shmem_transport_ctx_t *)ctx, target, source, len,
pe, op, datatype, completion);
Expand Down
72 changes: 1 addition & 71 deletions src/shr_transport.h4
Original file line number Diff line number Diff line change
Expand Up @@ -467,77 +467,7 @@ shmem_shr_transport_atomicv(shmem_ctx_t ctx, void *target, const void *source,
shm_internal_datatype_t datatype)
{
#if USE_SHR_ATOMICS
int noderank = shmem_internal_get_shr_rank(pe);
void *remote_ptr;

if (noderank == -1)
RAISE_ERROR_MSG("No shared memory path to peer %d\n", pe);

shmem_shr_transport_ptr(target, noderank, &remote_ptr);

#define SHMEM_DEF_BAND_OP(STYPE,TYPE,ITYPE) \
case ITYPE: \
__atomic_fetch_and((TYPE *)remote_ptr, *((TYPE *)source), __ATOMIC_RELEASE);\
break;

#define SHMEM_DEF_BOR_OP(STYPE,TYPE,ITYPE) \
case ITYPE: \
__atomic_fetch_or((TYPE *)remote_ptr, *((TYPE *)source), __ATOMIC_RELEASE); \
break;

#define SHMEM_DEF_BXOR_OP(STYPE,TYPE,ITYPE) \
case ITYPE: \
__atomic_fetch_xor((TYPE *)remote_ptr, *((TYPE *)source), __ATOMIC_RELEASE);\
break;

#define SHMEM_DEF_SUM_OP(STYPE,TYPE,ITYPE) \
case ITYPE: \
__atomic_fetch_add((TYPE *)remote_ptr, *((TYPE *)source), __ATOMIC_RELEASE);\
break;

switch (op) {
case SHM_INTERNAL_BAND:
switch(datatype) {
SHMEM_DEFINE_FOR_BITWISE_AMO(SHMEM_DEF_BAND_OP)
default:
RAISE_ERROR_MSG("Unsupported datatype op=%d, dtype=%d\n", op, datatype);
}
break;
case SHM_INTERNAL_BOR:
switch(datatype) {
SHMEM_DEFINE_FOR_BITWISE_AMO(SHMEM_DEF_BOR_OP)
default:
RAISE_ERROR_MSG("Unsupported datatype op=%d, dtype=%d\n", op, datatype);
}
break;
case SHM_INTERNAL_BXOR:
switch(datatype) {
SHMEM_DEFINE_FOR_BITWISE_AMO(SHMEM_DEF_BXOR_OP)
default:
RAISE_ERROR_MSG("Unsupported datatype op=%d, dtype=%d\n", op, datatype);
}
break;
case SHM_INTERNAL_SUM:
switch(datatype) {
SHMEM_DEFINE_FOR_AMO(SHMEM_DEF_SUM_OP)
default:
RAISE_ERROR_MSG("Unsupported datatype op=%d, dtype=%d\n", op, datatype);
}
break;
/* Note: The following ops are only used by AMO reductions, which are
* presently disabled when shared memory AMOs are enabled. */
case SHM_INTERNAL_PROD:
case SHM_INTERNAL_MIN:
case SHM_INTERNAL_MAX:
default:
RAISE_ERROR_MSG("Unsupported op op=%d, dtype=%d\n", op, datatype);
}

#undef SHMEM_DEF_BAND_OP
#undef SHMEM_DEF_BOR_OP
#undef SHMEM_DEF_BXOR_OP
#undef SHMEM_DEF_SUM_OP

RAISE_ERROR_STR("No path to peer");
#else
RAISE_ERROR_STR("No path to peer");
#endif
Expand Down

0 comments on commit aa60eec

Please sign in to comment.