Skip to content

Commit

Permalink
src: Pass NIC index to transport layer functions
Browse files Browse the repository at this point in the history
  • Loading branch information
philipmarshall21 committed May 14, 2024
1 parent 864fbb2 commit fcb71e3
Show file tree
Hide file tree
Showing 10 changed files with 315 additions and 219 deletions.
25 changes: 19 additions & 6 deletions src/atomic_c.c4
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,11 @@ shmem_swap(long *target, long value, int pe)
SHMEM_ERR_CHECK_PE(pe); \
SHMEM_ERR_CHECK_CTX(ctx); \
SHMEM_ERR_CHECK_SYMMETRIC(target, sizeof(TYPE)); \
\
size_t nic_idx = 0; \
SHMEM_GET_TRANSMIT_NIC_IDX(nic_idx); \
shmem_internal_atomic(ctx, target, &tmp, sizeof(TYPE), \
pe, SHM_INTERNAL_SUM, ITYPE); \
pe, SHM_INTERNAL_SUM, ITYPE, nic_idx); \
}


Expand Down Expand Up @@ -361,8 +364,10 @@ shmem_swap(long *target, long value, int pe)
SHMEM_ERR_CHECK_CTX(ctx); \
SHMEM_ERR_CHECK_SYMMETRIC(target, sizeof(TYPE)); \
\
size_t nic_idx = 0; \
SHMEM_GET_TRANSMIT_NIC_IDX(nic_idx); \
shmem_internal_atomic(ctx, target, &value, sizeof(TYPE), \
pe, SHM_INTERNAL_SUM, ITYPE); \
pe, SHM_INTERNAL_SUM, ITYPE, nic_idx); \
}


Expand Down Expand Up @@ -432,8 +437,10 @@ shmem_swap(long *target, long value, int pe)
SHMEM_ERR_CHECK_CTX(ctx); \
SHMEM_ERR_CHECK_SYMMETRIC(dest, sizeof(TYPE)); \
\
size_t nic_idx = 0; \
SHMEM_GET_TRANSMIT_NIC_IDX(nic_idx); \
shmem_internal_atomic_set(ctx, (void *) dest, &value, \
sizeof(TYPE), pe, ITYPE); \
sizeof(TYPE), pe, ITYPE, nic_idx); \
}


Expand All @@ -445,8 +452,10 @@ shmem_swap(long *target, long value, int pe)
SHMEM_ERR_CHECK_CTX(ctx); \
SHMEM_ERR_CHECK_SYMMETRIC(target, sizeof(TYPE)); \
\
size_t nic_idx = 0; \
SHMEM_GET_TRANSMIT_NIC_IDX(nic_idx); \
shmem_internal_atomic(ctx, target, &value, sizeof(TYPE), \
pe, SHM_INTERNAL_BXOR, ITYPE); \
pe, SHM_INTERNAL_BXOR, ITYPE, nic_idx); \
}


Expand All @@ -458,8 +467,10 @@ shmem_swap(long *target, long value, int pe)
SHMEM_ERR_CHECK_CTX(ctx); \
SHMEM_ERR_CHECK_SYMMETRIC(target, sizeof(TYPE)); \
\
size_t nic_idx = 0; \
SHMEM_GET_TRANSMIT_NIC_IDX(nic_idx); \
shmem_internal_atomic(ctx, target, &value, sizeof(TYPE), \
pe, SHM_INTERNAL_BAND, ITYPE); \
pe, SHM_INTERNAL_BAND, ITYPE, nic_idx); \
}


Expand All @@ -471,8 +482,10 @@ shmem_swap(long *target, long value, int pe)
SHMEM_ERR_CHECK_CTX(ctx); \
SHMEM_ERR_CHECK_SYMMETRIC(target, sizeof(TYPE)); \
\
size_t nic_idx = 0; \
SHMEM_GET_TRANSMIT_NIC_IDX(nic_idx); \
shmem_internal_atomic(ctx, target, &value, sizeof(TYPE), \
pe, SHM_INTERNAL_BOR, ITYPE); \
pe, SHM_INTERNAL_BOR, ITYPE, nic_idx); \
}


Expand Down
99 changes: 72 additions & 27 deletions src/data_c.c4
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,11 @@ SHMEM_PROF_DEF_CTX_PUT_N_SIGNAL_NBI(`mem')
SHMEM_ERR_CHECK_PE(pe); \
SHMEM_ERR_CHECK_CTX(ctx); \
SHMEM_ERR_CHECK_SYMMETRIC(addr, sizeof(TYPE)); \
\
size_t nic_idx = 0; \
SHMEM_GET_TRANSMIT_NIC_IDX(nic_idx); \
shmem_internal_put_scalar(ctx, addr, &value, sizeof(TYPE), \
pe); \
pe, nic_idx); \
}

#define SHMEM_DEF_G(STYPE,TYPE) \
Expand Down Expand Up @@ -340,10 +343,13 @@ SHMEM_PROF_DEF_CTX_PUT_N_SIGNAL_NBI(`mem')
SHMEM_ERR_CHECK_OVERLAP(target, source, sizeof(TYPE) * \
nelems, sizeof(TYPE) * nelems, 0, \
(shmem_internal_my_pe == pe)); \
\
size_t nic_idx = 0; \
SHMEM_GET_TRANSMIT_NIC_IDX(nic_idx); \
shmem_internal_put_nb(ctx, target, source, \
sizeof(TYPE) * nelems, pe, \
&completion); \
shmem_internal_put_wait(ctx, &completion); \
&completion, nic_idx); \
shmem_internal_put_wait(ctx, &completion, nic_idx); \
}


Expand All @@ -361,9 +367,12 @@ SHMEM_PROF_DEF_CTX_PUT_N_SIGNAL_NBI(`mem')
SHMEM_ERR_CHECK_OVERLAP(target, source, (SIZE) * nelems, \
(SIZE) * nelems, 0, \
(shmem_internal_my_pe == pe)); \
\
size_t nic_idx = 0; \
SHMEM_GET_TRANSMIT_NIC_IDX(nic_idx); \
shmem_internal_put_nb(ctx, target, source, (SIZE) * nelems,\
pe, &completion); \
shmem_internal_put_wait(ctx, &completion); \
pe, &completion, nic_idx); \
shmem_internal_put_wait(ctx, &completion, nic_idx); \
}


Expand All @@ -379,9 +388,12 @@ SHMEM_PROF_DEF_CTX_PUT_N_SIGNAL_NBI(`mem')
SHMEM_ERR_CHECK_OVERLAP(target, source, sizeof(TYPE) * \
nelems, sizeof(TYPE) * nelems, 0, \
(shmem_internal_my_pe == pe)); \
\
size_t nic_idx = 0; \
SHMEM_GET_TRANSMIT_NIC_IDX(nic_idx); \
shmem_internal_put_nbi(ctx, target, source, \
sizeof(TYPE)*nelems, \
pe); \
pe, nic_idx); \
}


Expand All @@ -398,8 +410,11 @@ SHMEM_PROF_DEF_CTX_PUT_N_SIGNAL_NBI(`mem')
SHMEM_ERR_CHECK_OVERLAP(target, source, (SIZE) * nelems, \
(SIZE) * nelems, 0, \
(shmem_internal_my_pe == pe)); \
\
size_t nic_idx = 0; \
SHMEM_GET_TRANSMIT_NIC_IDX(nic_idx); \
shmem_internal_put_nbi(ctx, target, source, (SIZE)*nelems, \
pe); \
pe, nic_idx); \
}


Expand Down Expand Up @@ -502,9 +517,12 @@ SHMEM_PROF_DEF_CTX_PUT_N_SIGNAL_NBI(`mem')
sizeof(TYPE) * ((nelems-1) * tst + 1), \
sizeof(TYPE) * ((nelems-1) * sst + 1), 0, \
(shmem_internal_my_pe == pe)); \
\
size_t nic_idx = 0; \
SHMEM_GET_TRANSMIT_NIC_IDX(nic_idx); \
for ( ; nelems > 0 ; --nelems) { \
shmem_internal_put_scalar(ctx, target, source, \
sizeof(TYPE), pe); \
sizeof(TYPE), pe, nic_idx); \
target += tst; \
source += sst; \
} \
Expand All @@ -527,14 +545,17 @@ SHMEM_PROF_DEF_CTX_PUT_N_SIGNAL_NBI(`mem')
sizeof(TYPE) * ((nblocks-1) * tst + bsize), \
sizeof(TYPE) * ((nblocks-1) * sst + bsize), \
0, (shmem_internal_my_pe == pe)); \
\
size_t nic_idx = 0; \
SHMEM_GET_TRANSMIT_NIC_IDX(nic_idx); \
for ( ; nblocks > 0 ; --nblocks) { \
shmem_internal_put_nb(ctx, target, source, \
bsize * sizeof(TYPE), pe, \
&completion); \
&completion, nic_idx); \
target += tst; \
source += sst; \
} \
shmem_internal_put_wait(ctx, &completion); \
shmem_internal_put_wait(ctx, &completion, nic_idx); \
}

#define SHMEM_DEF_IPUT_N(NAME,SIZE) \
Expand All @@ -554,9 +575,12 @@ SHMEM_PROF_DEF_CTX_PUT_N_SIGNAL_NBI(`mem')
(SIZE) * ((nelems-1) * tst + 1), \
(SIZE) * ((nelems-1) * sst + 1), 0, \
(shmem_internal_my_pe == pe)); \
\
size_t nic_idx = 0; \
SHMEM_GET_TRANSMIT_NIC_IDX(nic_idx); \
for ( ; nelems > 0 ; --nelems) { \
shmem_internal_put_scalar(ctx, target, source, (SIZE), \
pe); \
pe, nic_idx); \
target = (uint8_t *) target + tst * (SIZE); \
source = (uint8_t *) source + sst * (SIZE); \
} \
Expand All @@ -580,14 +604,17 @@ SHMEM_PROF_DEF_CTX_PUT_N_SIGNAL_NBI(`mem')
(SIZE) * ((nblocks-1) * tst + bsize), \
(SIZE) * ((nblocks-1) * sst + bsize), \
0, (shmem_internal_my_pe == pe)); \
\
size_t nic_idx = 0; \
SHMEM_GET_TRANSMIT_NIC_IDX(nic_idx); \
for ( ; nblocks > 0 ; --nblocks) { \
shmem_internal_put_nb(ctx, target, source, \
bsize * (SIZE), pe, \
&completion); \
&completion, nic_idx); \
target = (uint8_t *) target + tst * (SIZE); \
source = (uint8_t *) source + sst * (SIZE); \
} \
shmem_internal_put_wait(ctx, &completion); \
shmem_internal_put_wait(ctx, &completion, nic_idx); \
}

#define SHMEM_DEF_IGET(STYPE,TYPE) \
Expand Down Expand Up @@ -698,7 +725,7 @@ SHMEM_PROF_DEF_CTX_PUT_N_SIGNAL_NBI(`mem')
0, (shmem_internal_my_pe == pe)); \
\
size_t nic_idx = 0; \
SHMEM_GET_TRANSMIT_NIC_IDX(nic_idx); \
SHMEM_GET_TRANSMIT_NIC_IDX(nic_idx); \
for ( ; nblocks > 0 ; --nblocks) { \
shmem_internal_get(ctx, target, source, \
bsize * (SIZE), pe, nic_idx); \
Expand All @@ -724,19 +751,22 @@ SHMEM_PROF_DEF_CTX_PUT_N_SIGNAL_NBI(`mem')
sizeof(uint64_t), 0, \
(shmem_internal_my_pe == pe)); \
SHMEM_ERR_CHECK_SIG_OP(sig_op); \
\
size_t nic_idx = 0; \
SHMEM_GET_TRANSMIT_NIC_IDX(nic_idx); \
shmem_internal_put_nb(ctx, target, source, \
sizeof(TYPE) * nelems, pe, \
&completion); \
shmem_internal_put_wait(ctx, &completion); \
&completion, nic_idx); \
shmem_internal_put_wait(ctx, &completion, nic_idx); \
shmem_internal_fence(ctx); \
if (sig_op == SHMEM_SIGNAL_ADD) \
shmem_internal_atomic(ctx, sig_addr, &signal, sizeof(uint64_t), \
pe, SHM_INTERNAL_SUM, \
SHM_INTERNAL_UINT64); \
SHM_INTERNAL_UINT64, nic_idx); \
else \
shmem_internal_atomic_set(ctx, sig_addr, &signal, \
sizeof(uint64_t), pe, \
SHM_INTERNAL_UINT64); \
SHM_INTERNAL_UINT64, nic_idx); \
}


Expand All @@ -756,18 +786,21 @@ SHMEM_PROF_DEF_CTX_PUT_N_SIGNAL_NBI(`mem')
sizeof(uint64_t), 0, \
(shmem_internal_my_pe == pe)); \
SHMEM_ERR_CHECK_SIG_OP(sig_op); \
\
size_t nic_idx = 0; \
SHMEM_GET_TRANSMIT_NIC_IDX(nic_idx); \
shmem_internal_put_nb(ctx, target, source, (SIZE) * nelems, \
pe, &completion); \
shmem_internal_put_wait(ctx, &completion); \
pe, &completion, nic_idx); \
shmem_internal_put_wait(ctx, &completion, nic_idx); \
shmem_internal_fence(ctx); \
if (sig_op == SHMEM_SIGNAL_ADD) \
shmem_internal_atomic(ctx, sig_addr, &signal, sizeof(uint64_t), \
pe, SHM_INTERNAL_SUM, \
SHM_INTERNAL_UINT64); \
SHM_INTERNAL_UINT64, nic_idx); \
else \
shmem_internal_atomic_set(ctx, sig_addr, &signal, \
sizeof(uint64_t), pe, \
SHM_INTERNAL_UINT64); \
SHM_INTERNAL_UINT64, nic_idx); \
}

#define SHMEM_DEF_PUT_SIGNAL_NBI(STYPE,TYPE) \
Expand Down Expand Up @@ -806,8 +839,12 @@ SHMEM_PROF_DEF_CTX_PUT_N_SIGNAL_NBI(`mem')
sizeof(uint64_t), 0, \
(shmem_internal_my_pe == pe)); \
SHMEM_ERR_CHECK_SIG_OP(sig_op); \
\
size_t nic_idx = 0; \
SHMEM_GET_TRANSMIT_NIC_IDX(nic_idx); \
shmem_internal_put_signal_nbi(ctx, target, source, (SIZE) * nelems, \
sig_addr, signal, sig_op, pe); \
sig_addr, signal, sig_op, \
pe, nic_idx); \
}


Expand Down Expand Up @@ -914,8 +951,10 @@ shmemx_signal_add(uint64_t *sig_addr, uint64_t signal, int pe)
SHMEM_ERR_CHECK_PE(pe);
SHMEM_ERR_CHECK_SYMMETRIC(sig_addr, sizeof(uint64_t));

size_t nic_idx = 0;
SHMEM_GET_TRANSMIT_NIC_IDX(nic_idx);
shmem_internal_atomic(SHMEM_CTX_DEFAULT, sig_addr, &signal, sizeof(uint64_t),
pe, SHM_INTERNAL_SUM, SHM_INTERNAL_UINT64);
pe, SHM_INTERNAL_SUM, SHM_INTERNAL_UINT64, nic_idx);
}

void SHMEM_FUNCTION_ATTRIBUTES
Expand All @@ -926,8 +965,10 @@ shmemx_ctx_signal_add(shmem_ctx_t ctx, uint64_t *sig_addr, uint64_t signal, int
SHMEM_ERR_CHECK_CTX(ctx);
SHMEM_ERR_CHECK_SYMMETRIC(sig_addr, sizeof(uint64_t));

size_t nic_idx = 0;
SHMEM_GET_TRANSMIT_NIC_IDX(nic_idx);
shmem_internal_atomic(ctx, sig_addr, &signal, sizeof(uint64_t),
pe, SHM_INTERNAL_SUM, SHM_INTERNAL_UINT64);
pe, SHM_INTERNAL_SUM, SHM_INTERNAL_UINT64, nic_idx);
}

void SHMEM_FUNCTION_ATTRIBUTES
Expand All @@ -937,8 +978,10 @@ shmemx_signal_set(uint64_t *sig_addr, uint64_t signal, int pe)
SHMEM_ERR_CHECK_PE(pe);
SHMEM_ERR_CHECK_SYMMETRIC(sig_addr, sizeof(uint64_t));

size_t nic_idx = 0;
SHMEM_GET_TRANSMIT_NIC_IDX(nic_idx);
shmem_internal_atomic_set(SHMEM_CTX_DEFAULT, (void *) sig_addr, &signal,
sizeof(uint64_t), pe, SHM_INTERNAL_UINT64);
sizeof(uint64_t), pe, SHM_INTERNAL_UINT64, nic_idx);
}

void SHMEM_FUNCTION_ATTRIBUTES
Expand All @@ -949,8 +992,10 @@ shmemx_ctx_signal_set(shmem_ctx_t ctx, uint64_t *sig_addr, uint64_t signal, int
SHMEM_ERR_CHECK_CTX(ctx);
SHMEM_ERR_CHECK_SYMMETRIC(sig_addr, sizeof(uint64_t));

size_t nic_idx = 0;
SHMEM_GET_TRANSMIT_NIC_IDX(nic_idx);
shmem_internal_atomic_set(ctx, (void *) sig_addr, &signal,
sizeof(uint64_t), pe, SHM_INTERNAL_UINT64);
sizeof(uint64_t), pe, SHM_INTERNAL_UINT64, nic_idx);
}

void SHMEM_FUNCTION_ATTRIBUTES
Expand Down
Loading

0 comments on commit fcb71e3

Please sign in to comment.