Refactor Barrier_all and Sync_all APIs to use default context (#159)
* Refactor `Barrier_all` and `Sync_all` to use default context - Removed context-specific implementations of barrier_all and sync_all - Added barrier_all and sync_all to the default context implementation - Updated functional tests to use the default context for barrier_all and sync_all * Update `Barrier_all` and `Sync_all` API usage in documentation * Update `CHANGELOG` --------- Co-authored-by: Yiltan <ytemucin@amd.com>
This commit is contained in:
committed by
GitHub
parent
551603829c
commit
bf48bcabf2
@@ -40,29 +40,42 @@ __global__ void BarrierAllTest(int loop, int skip, long long int *start_time,
|
||||
int wf_id = t_id / wf_size;
|
||||
|
||||
rocshmem_wg_init();
|
||||
rocshmem_wg_ctx_create(ROCSHMEM_CTX_WG_PRIVATE, &ctx);
|
||||
|
||||
for (int i = 0; i < loop + skip; i++) {
|
||||
if (hipThreadIdx_x == 0 && i == skip) {
|
||||
start_time[wg_id] = wall_clock64();
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case BarrierAllTestType:
|
||||
if(t_id == 0) {
|
||||
rocshmem_ctx_barrier_all(ctx);
|
||||
}
|
||||
break;
|
||||
case WAVEBarrierAllTestType:
|
||||
if(wf_id == 0) {
|
||||
rocshmem_ctx_barrier_all_wave(ctx);
|
||||
}
|
||||
break;
|
||||
case WGBarrierAllTestType:
|
||||
rocshmem_ctx_barrier_all_wg(ctx);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
if (is_block_zero_in_grid()) {
|
||||
switch (type) {
|
||||
case BarrierAllTestType:
|
||||
if(t_id == 0) {
|
||||
/**
|
||||
* The function `rocshmem_barrier_all` should be called from only
|
||||
* one thread within the grid to avoid undefined behavior.
|
||||
*/
|
||||
rocshmem_barrier_all();
|
||||
}
|
||||
break;
|
||||
case WAVEBarrierAllTestType:
|
||||
if(wf_id == 0) {
|
||||
/**
|
||||
* The function `rocshmem_barrier_all_wave` should be called from only
|
||||
* one wavefront within the grid to avoid undefined behavior.
|
||||
*/
|
||||
rocshmem_barrier_all_wave();
|
||||
}
|
||||
break;
|
||||
case WGBarrierAllTestType:
|
||||
/**
|
||||
* The function `rocshmem_barrier_all_wg` should be called from only
|
||||
* one workgroup within the grid to avoid undefined behavior.
|
||||
*/
|
||||
rocshmem_barrier_all_wg();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
__syncthreads();
|
||||
}
|
||||
@@ -71,7 +84,6 @@ __global__ void BarrierAllTest(int loop, int skip, long long int *start_time,
|
||||
end_time[wg_id] = wall_clock64();
|
||||
}
|
||||
|
||||
rocshmem_wg_ctx_destroy(&ctx);
|
||||
rocshmem_wg_finalize();
|
||||
}
|
||||
|
||||
@@ -89,8 +101,8 @@ void BarrierAllTester::launchKernel(dim3 gridSize, dim3 blockSize, int loop,
|
||||
hipLaunchKernelGGL(BarrierAllTest, gridSize, blockSize, shared_bytes, stream,
|
||||
loop, args.skip, start_time, end_time, _type, wf_size);
|
||||
|
||||
num_msgs = (loop + args.skip) * gridSize.x;
|
||||
num_timed_msgs = loop * gridSize.x;
|
||||
num_msgs = (loop + args.skip);
|
||||
num_timed_msgs = loop;
|
||||
}
|
||||
|
||||
void BarrierAllTester::resetBuffers(uint64_t size) {}
|
||||
|
||||
@@ -40,38 +40,50 @@ __global__ void SyncAllTest(int loop, int skip, long long int *start_time,
|
||||
int wf_id = t_id / wf_size;
|
||||
|
||||
rocshmem_wg_init();
|
||||
rocshmem_wg_ctx_create(ROCSHMEM_CTX_WG_PRIVATE, &ctx);
|
||||
|
||||
for (int i = 0; i < loop + skip; i++) {
|
||||
if (hipThreadIdx_x == 0 && i == skip) {
|
||||
start_time[wg_id] = wall_clock64();
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case SyncAllTestType:
|
||||
if(t_id == 0) {
|
||||
rocshmem_ctx_sync_all(ctx);
|
||||
}
|
||||
break;
|
||||
case WAVESyncAllTestType:
|
||||
if(wf_id == 0) {
|
||||
rocshmem_ctx_sync_all_wave(ctx);
|
||||
}
|
||||
break;
|
||||
case WGSyncAllTestType:
|
||||
rocshmem_ctx_sync_all_wg(ctx);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
if (is_block_zero_in_grid()) {
|
||||
switch (type) {
|
||||
case SyncAllTestType:
|
||||
if(t_id == 0) {
|
||||
/**
|
||||
* The function `rocshmem_sync_all` should be called from only
|
||||
* one thread within the grid to avoid undefined behavior.
|
||||
*/
|
||||
rocshmem_sync_all();
|
||||
}
|
||||
break;
|
||||
case WAVESyncAllTestType:
|
||||
if(wf_id == 0) {
|
||||
/**
|
||||
* The function `rocshmem_sync_all_wave` should be called from only
|
||||
* one thread within the grid to avoid undefined behavior.
|
||||
*/
|
||||
rocshmem_sync_all_wave();
|
||||
}
|
||||
break;
|
||||
case WGSyncAllTestType:
|
||||
/**
|
||||
* The function `rocshmem_sync_all_wg` should be called from only
|
||||
* one thread within the grid to avoid undefined behavior.
|
||||
*/
|
||||
rocshmem_sync_all_wg();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
__syncthreads();
|
||||
}
|
||||
__syncthreads();
|
||||
}
|
||||
|
||||
if (hipThreadIdx_x == 0) {
|
||||
end_time[wg_id] = wall_clock64();
|
||||
}
|
||||
|
||||
rocshmem_wg_ctx_destroy(&ctx);
|
||||
rocshmem_wg_finalize();
|
||||
}
|
||||
|
||||
@@ -89,8 +101,8 @@ void SyncAllTester::launchKernel(dim3 gridSize, dim3 blockSize, int loop,
|
||||
hipLaunchKernelGGL(SyncAllTest, gridSize, blockSize, shared_bytes, stream,
|
||||
loop, args.skip, start_time, end_time, _type, wf_size);
|
||||
|
||||
num_msgs = (loop + args.skip) * gridSize.x;
|
||||
num_timed_msgs = loop * gridSize.x;
|
||||
num_msgs = (loop + args.skip);
|
||||
num_timed_msgs = loop;
|
||||
}
|
||||
|
||||
void SyncAllTester::resetBuffers(uint64_t size) {}
|
||||
|
||||
@@ -95,7 +95,6 @@ __global__ void TeamReductionTest(int loop, int skip, long long int *start_time,
|
||||
start_time[wg_id] = wall_clock64();
|
||||
}
|
||||
wg_team_reduce<T1, T2>(ctx, team, r_buf, s_buf, size);
|
||||
rocshmem_ctx_barrier_all_wg(ctx);
|
||||
}
|
||||
|
||||
__syncthreads();
|
||||
|
||||
Reference in New Issue
Block a user