static void gasnete_coll_pami_scatt(const gasnet_team_handle_t team, void *dst, gasnet_image_t srcimage, const void *src, size_t nbytes, int flags GASNETI_THREAD_FARG) { const int i_am_root = gasnete_coll_image_is_local(team, srcimage); #if GASNET_PAR int i_am_leader = gasnete_coll_pami_images_barrier(team); /* XXX: over-synced for IN_NO and IN_MY */ if ((flags & GASNET_COLL_LOCAL) && i_am_root) { /* root thread must be leader for its node */ const gasnete_coll_threaddata_t * const td = GASNETE_COLL_MYTHREAD_NOALLOC; i_am_leader = (srcimage == td->my_image); } #else const int i_am_leader = 1; #endif 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_scatt; op.cookie = (void *)&done; op.algorithm = team->pami.scatt_alg; op.cmd.xfer_scatter.root = gasnetc_endpoint(GASNETE_COLL_REL2ACT(team,gasnete_coll_image_node(team, srcimage))); op.cmd.xfer_scatter.sndbuf = (/*not-const*/ void *)src; op.cmd.xfer_scatter.stypecount = nbytes; op.cmd.xfer_scatter.rcvbuf = dst; op.cmd.xfer_scatter.rtypecount = nbytes; GASNETC_PAMI_LOCK(gasnetc_context); rc = PAMI_Collective(gasnetc_context, &op); GASNETC_PAMI_UNLOCK(gasnetc_context); GASNETC_PAMI_CHECK(rc, "initiating blocking scatter"); gasneti_polluntil(done); } if (flags & GASNET_COLL_OUT_ALLSYNC) { if (i_am_leader) gasnetc_fast_barrier(); (void) gasnete_coll_pami_images_barrier(team); } }
static void native_collective(pami_xfer_t *op_p, int need_lock) { pami_result_t rc; volatile unsigned int counter = 0; op_p->cb_done = &gasnetc_cb_inc_uint; op_p->cookie = (void *)&counter; op_p->options.multicontext = PAMI_HINT_DISABLE; if (need_lock) GASNETC_PAMI_LOCK(gasnetc_context); rc = PAMI_Collective(gasnetc_context, op_p); GASNETC_PAMI_CHECK(rc, "initiating a native collective"); if (need_lock) GASNETC_PAMI_UNLOCK(gasnetc_context); if (gasneti_attach_done) { gasneti_polluntil(counter); } else { rc = gasnetc_wait_uint(gasnetc_context, &counter, 1); GASNETC_PAMI_CHECK(rc, "polling a native collective"); } }
static void gasnete_coll_pami_allga(const gasnet_team_handle_t team, void *dst, const void *src, size_t nbytes, int flags GASNETE_THREAD_FARG) { #if GASNET_PAR int i_am_leader = gasnete_coll_pami_images_barrier(team); /* XXX: over-synced for IN_NO and IN_MY */ #else const int i_am_leader = 1; #endif 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_allga; op.cookie = (void *)&done; op.algorithm = team->pami.allga_alg; op.cmd.xfer_allgather.sndbuf = (/*not-const*/ void *)src; op.cmd.xfer_allgather.stypecount = nbytes; op.cmd.xfer_allgather.rcvbuf = dst; op.cmd.xfer_allgather.rtypecount = nbytes; GASNETC_PAMI_LOCK(gasnetc_context); rc = PAMI_Collective(gasnetc_context, &op); GASNETC_PAMI_UNLOCK(gasnetc_context); GASNETC_PAMI_CHECK(rc, "initiating blocking allgather"); gasneti_polluntil(done); } 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_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 GASNETI_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); } GASNETI_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); } }