void gasnete_extref_get_reph_inner(gasnet_token_t token, void *addr, size_t nbytes, void *dest, void *op) { GASNETE_FAST_UNALIGNED_MEMCPY(dest, addr, nbytes); gasneti_sync_writes(); gasnete_op_markdone((gasnete_op_t *)op, 1); }
void gasnete_amref_put_reqh_inner(gasnet_token_t token, void *addr, size_t nbytes, void *dest, void *done) { GASNETE_FAST_UNALIGNED_MEMCPY(dest, addr, nbytes); gasneti_sync_writes(); GASNETI_SAFE( SHORT_REP(1,2,(token, gasneti_handleridx(gasnete_amref_markdone_reph), PACK(done)))); }
void smp_coll_broadcast_flat(smp_coll_t handle, int num_addrs, void * const dstlist[], const void *src, size_t nbytes, int flags){ int idx = 0; if(!(flags & SMP_COLL_NO_SYNC)) smp_coll_barrier(handle, flags); if(handle->MYTHREAD==0) { for(idx=0; idx<num_addrs; idx++) { GASNETE_FAST_UNALIGNED_MEMCPY(dstlist[idx], src, nbytes); } } if(!(flags & SMP_COLL_NO_SYNC)) smp_coll_barrier(handle, flags); }
void smp_coll_broadcast_tree_atomic(smp_coll_t handle, int num_addrs, void * const dstlist[], const void *src, size_t nbytes, int flags, int radix){ int num_digits = smp_coll_mylogn(handle->THREADS, radix); int radixlog2 = smp_coll_mylogn(radix,2); int i,j,k; int parent=-1; if((flags & SMP_COLL_ALL_SYNC)) smp_coll_barrier(handle, flags); for(i=0; i<num_digits; i++) { if(SMP_COLL_GET_ITH_DIGIT_POWER2RADIX(handle->MYTHREAD, i, radix, radixlog2)!=0) { parent = SMP_COLL_MAKE_NUM_POWER2RADIX(handle->MYTHREAD, i, 0, radix, radixlog2); break; } } if(parent!=-1) { gasneti_waitwhile(SMP_COLL_READ_ATOMIC(handle, handle->MYTHREAD, 0, handle->curr_atomic_set)!=1); SMP_COLL_DEC_ATOMIC(handle, handle->MYTHREAD, 0, handle->curr_atomic_set); gasnett_local_rmb(); } else { memcpy(dstlist[0], src, nbytes); } for(i=num_digits-1,j=0; i>=0; i--,j++) { /*if my i^th digit is 0 that means that i am a sender for this round*/ if(SMP_COLL_GET_ITH_DIGIT_POWER2RADIX(handle->MYTHREAD, i, radix, radixlog2)==0 && SMP_COLL_GET_LOWER_K_DIGITS_POWER2RADIX(handle->MYTHREAD, i, radix, radixlog2)==0) { for(k=1;k<radix;k++) { int dest = SMP_COLL_MAKE_NUM_POWER2RADIX(handle->MYTHREAD, i, k, radix, radixlog2); if(dest<handle->THREADS) { GASNETE_FAST_UNALIGNED_MEMCPY(dstlist[dest], dstlist[handle->MYTHREAD], nbytes); gasnett_local_wmb(); SMP_COLL_INC_ATOMIC(handle, dest, 0, handle->curr_atomic_set); } } } } if((flags & SMP_COLL_ALL_SYNC)) smp_coll_barrier(handle, flags); handle->curr_atomic_set = !handle->curr_atomic_set; }
void gasnete_amref_get_reph_inner(gasnet_token_t token, void *addr, size_t nbytes, void *dest, void *done) { GASNETE_FAST_UNALIGNED_MEMCPY(dest, addr, nbytes); MARK_DONE(done,1); }
static void gasnete_coll_pami_allgavi(const gasnet_team_handle_t team, void *dst, const void *src, size_t nbytes, int flags GASNETE_THREAD_FARG) { int i_am_leader = gasnete_coll_pami_images_barrier(team); /* XXX: over-synced for IN_NO and IN_MY */ const gasnete_coll_threaddata_t * const td = GASNETE_COLL_MYTHREAD_NOALLOC; if (flags & GASNET_COLL_IN_ALLSYNC) { if (i_am_leader) gasnetc_fast_barrier(); (void) gasnete_coll_pami_images_barrier(team); } GASNETE_FAST_UNALIGNED_MEMCPY(gasnete_coll_scale_ptr(team->pami.scratch_space, td->my_local_image, nbytes), src, nbytes); (void) gasnete_coll_pami_images_barrier(team); if (i_am_leader) { volatile unsigned int done = 0; pami_result_t rc; pami_xfer_t op; op = gasnete_op_template_allgavi; /* allgatherv_int */ op.cookie = (void *)&done; op.algorithm = team->pami.allgavi_alg; op.cmd.xfer_allgatherv_int.sndbuf = team->pami.scratch_space; op.cmd.xfer_allgatherv_int.stypecount = nbytes * team->my_images; op.cmd.xfer_allgatherv_int.rcvbuf = dst; op.cmd.xfer_allgatherv_int.rtypecounts = team->pami.counts; op.cmd.xfer_allgatherv_int.rdispls = team->pami.displs; if (team->pami.prev_nbytes != nbytes) { int i; for (i = 0; i < team->total_ranks; ++i) { op.cmd.xfer_allgatherv_int.rtypecounts[i] = nbytes * team->all_images[i]; op.cmd.xfer_allgatherv_int.rdispls[i] = nbytes * team->all_offset[i]; } team->pami.prev_nbytes = nbytes; } GASNETC_PAMI_LOCK(gasnetc_context); rc = PAMI_Collective(gasnetc_context, &op); GASNETC_PAMI_UNLOCK(gasnetc_context); GASNETC_PAMI_CHECK(rc, "initiating blocking allgatherv_int"); gasneti_polluntil(done); gasneti_assert(NULL == team->pami.tmp_addr); gasneti_sync_writes(); /* XXX: is this necessary? */ team->pami.tmp_addr = dst; /* wakes pollers, below */ (void) gasnete_coll_pami_images_barrier(team); /* matches instance below vvvv */ team->pami.tmp_addr = NULL; } else { gasneti_waitwhile(NULL == team->pami.tmp_addr); GASNETE_FAST_UNALIGNED_MEMCPY(dst, team->pami.tmp_addr, nbytes * team->total_images); (void) gasnete_coll_pami_images_barrier(team); /* matches instance above ^^^^ */ } if (flags & GASNET_COLL_OUT_ALLSYNC) { if (i_am_leader) gasnetc_fast_barrier(); (void) gasnete_coll_pami_images_barrier(team); } }
static void gasnete_coll_pami_scattvi(const gasnet_team_handle_t team, void *dst, gasnet_image_t srcimage, const void *src, size_t nbytes, int flags GASNETE_THREAD_FARG) { const int i_am_root = gasnete_coll_image_is_local(team, srcimage); int i_am_leader = gasnete_coll_pami_images_barrier(team); /* XXX: over-synced for IN_NO and IN_MY */ const gasnete_coll_threaddata_t * const td = GASNETE_COLL_MYTHREAD_NOALLOC; if ((flags & GASNET_COLL_LOCAL) && i_am_root) { /* root thread must be leader for its node */ i_am_leader = (srcimage == td->my_image); } if (i_am_leader) { volatile unsigned int done = 0; pami_result_t rc; pami_xfer_t op; if (flags & GASNET_COLL_IN_ALLSYNC) gasnetc_fast_barrier(); op = gasnete_op_template_scattvi; /* scatterv_int */ op.cookie = (void *)&done; op.algorithm = team->pami.scattvi_alg; op.cmd.xfer_scatterv_int.root = gasnetc_endpoint(GASNETE_COLL_REL2ACT(team,gasnete_coll_image_node(team, srcimage))); op.cmd.xfer_scatterv_int.rcvbuf = team->pami.scratch_space; op.cmd.xfer_scatterv_int.rtypecount = nbytes * team->my_images; if (i_am_root) { op.cmd.xfer_scatterv_int.sndbuf = (/*not-const*/ void *)src; op.cmd.xfer_scatterv_int.stypecounts = team->pami.counts; op.cmd.xfer_scatterv_int.sdispls = team->pami.displs; if (team->pami.prev_nbytes != nbytes) { int i; for (i = 0; i < team->total_ranks; ++i) { op.cmd.xfer_scatterv_int.stypecounts[i] = nbytes * team->all_images[i]; op.cmd.xfer_scatterv_int.sdispls[i] = nbytes * team->all_offset[i]; } team->pami.prev_nbytes = nbytes; } } GASNETC_PAMI_LOCK(gasnetc_context); rc = PAMI_Collective(gasnetc_context, &op); GASNETC_PAMI_UNLOCK(gasnetc_context); GASNETC_PAMI_CHECK(rc, "initiating blocking scatterv_int"); gasneti_polluntil(done); gasneti_assert(NULL == team->pami.tmp_addr); gasneti_sync_writes(); team->pami.tmp_addr = team->pami.scratch_space; /* wakes pollers, below */ } else { gasneti_waitwhile(NULL == team->pami.tmp_addr); } GASNETE_FAST_UNALIGNED_MEMCPY(dst, gasnete_coll_scale_ptr(team->pami.tmp_addr, td->my_local_image, nbytes), nbytes); (void) gasnete_coll_pami_images_barrier(team); if (i_am_leader) { team->pami.tmp_addr = NULL; } if (flags & GASNET_COLL_OUT_ALLSYNC) { if (i_am_leader) gasnetc_fast_barrier(); (void) gasnete_coll_pami_images_barrier(team); } }