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:
Avinash Kethineedi
2025-06-17 11:16:18 -05:00
zatwierdzone przez GitHub
rodzic 551603829c
commit bf48bcabf2
10 zmienionych plików z 115 dodań i 130 usunięć
@@ -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) {}