int main(int argc, char *argv[]) { gaspi_rank_t numranks, myrank; gaspi_rank_t rankSend; gaspi_size_t segSize; const gaspi_offset_t localOff_r= 0; const gaspi_offset_t remOff_r = 0; const gaspi_offset_t localOff_w = _128MB / 2 ; const gaspi_offset_t remOff_w = _128MB / 2; gaspi_number_t queueSize, qmax; const gaspi_size_t commSize = _8MB; int i; gaspi_gpu_t gpus[8]; gaspi_gpu_num nGPUs; TSUITE_INIT(argc, argv); ASSERT (gaspi_proc_init(GASPI_BLOCK)); ASSERT (gaspi_proc_num(&numranks)); ASSERT (gaspi_proc_rank(&myrank)); ASSERT (gaspi_init_GPUs()); ASSERT (gaspi_number_of_GPUs(&nGPUs)); ASSERT (gaspi_GPU_ids(gpus)); ASSERT (gaspi_segment_create(0, _128MB, GASPI_GROUP_ALL, GASPI_BLOCK, GASPI_MEM_INITIALIZED|GASPI_MEM_GPU)); ASSERT( gaspi_segment_size(0, myrank, &segSize)); ASSERT (gaspi_barrier(GASPI_GROUP_ALL, GASPI_BLOCK)); ASSERT (gaspi_queue_size_max(&qmax)); for(i = 0; i < 100; i++ ) { for(rankSend = 0; rankSend < numranks; rankSend++) { if(rankSend == myrank) continue; gaspi_printf("partner rank: %d - %lu bytes (%d)\n", rankSend, commSize, i); ASSERT (gaspi_queue_size(1, &queueSize)); if (queueSize > qmax - 24) ASSERT (gaspi_wait(1, GASPI_BLOCK)); ASSERT (gaspi_read(0, localOff_r, rankSend, 0, remOff_r, commSize, 1, GASPI_BLOCK)); } } for(i = 0; i < 100; i++ ) { for(rankSend = 0; rankSend < numranks; rankSend++) { if(rankSend == myrank) continue; ASSERT (gaspi_gpu_write(0, localOff_r, rankSend, 0, remOff_r, commSize, 1, GASPI_BLOCK)); } } ASSERT (gaspi_wait(1, GASPI_BLOCK)); ASSERT (gaspi_barrier(GASPI_GROUP_ALL, GASPI_BLOCK)); ASSERT (gaspi_proc_term(GASPI_BLOCK)); return EXIT_SUCCESS; }
int main(int argc, char *argv[]) { TSUITE_INIT(argc, argv); gaspi_gpu_t gpus[8]; gaspi_gpu_num nGPUs; ASSERT (gaspi_proc_init(GASPI_BLOCK)); ASSERT (gaspi_init_GPUs()); ASSERT (gaspi_number_of_GPUs(&nGPUs)); ASSERT (gaspi_GPU_ids(gpus)); gaspi_notification_id_t n=0; gaspi_number_t notif_num; gaspi_rank_t rank, nprocs, i; const gaspi_segment_id_t seg_id = 0; ASSERT(gaspi_proc_num(&nprocs)); ASSERT (gaspi_proc_rank(&rank)); ASSERT (gaspi_segment_create(seg_id, 1024, GASPI_GROUP_ALL, GASPI_BLOCK, GASPI_MEM_GPU|GASPI_MEM_UNINITIALIZED)); ASSERT( gaspi_notification_num(¬if_num)); gaspi_printf("max num notifications %u\n", notif_num); if(rank == 0) { gaspi_number_t queue_size; gaspi_number_t queue_max; ASSERT (gaspi_queue_size_max(&queue_max)); for(n = 0; n < notif_num; n++) { for(i = 1; i < nprocs; i++) { ASSERT (gaspi_queue_size(0, &queue_size)); if(queue_size > queue_max - 1) ASSERT (gaspi_wait(0, GASPI_BLOCK)); ASSERT (gaspi_notify( seg_id, i, n, 1, 0, GASPI_BLOCK)); } } } else { do { gaspi_notification_id_t id; ASSERT (gaspi_notify_waitsome(seg_id, 0, notif_num, &id, GASPI_BLOCK)); gaspi_notification_t notification_val; ASSERT( gaspi_notify_reset(seg_id, id, ¬ification_val)); assert(notification_val == 1); n++; } while(n < notif_num); } ASSERT (gaspi_barrier(GASPI_GROUP_ALL, GASPI_BLOCK)); ASSERT (gaspi_proc_term(GASPI_BLOCK)); return EXIT_SUCCESS; }