2024-07-01 09:57:08 -05:00
|
|
|
/******************************************************************************
|
2025-04-15 15:37:53 -05:00
|
|
|
* Copyright (c) Advanced Micro Devices, Inc. All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
2024-07-01 09:57:08 -05:00
|
|
|
*
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
|
* of this software and associated documentation files (the "Software"), to
|
|
|
|
|
* deal in the Software without restriction, including without limitation the
|
|
|
|
|
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
|
|
|
* sell copies of the Software, and to permit persons to whom the Software is
|
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
|
*
|
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
2025-04-15 15:37:53 -05:00
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
2024-07-01 09:57:08 -05:00
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
|
|
|
* IN THE SOFTWARE.
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "barrier_all_tester.hpp"
|
|
|
|
|
|
2024-11-25 14:12:15 -06:00
|
|
|
#include <rocshmem/rocshmem.hpp>
|
2024-07-01 09:57:08 -05:00
|
|
|
|
|
|
|
|
using namespace rocshmem;
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
|
* DEVICE TEST KERNEL
|
|
|
|
|
*****************************************************************************/
|
2025-02-17 06:18:46 +00:00
|
|
|
__global__ void BarrierAllTest(int loop, int skip, long long int *start_time,
|
2025-04-02 11:58:55 -05:00
|
|
|
long long int *end_time, TestType type,
|
|
|
|
|
int wf_size) {
|
2024-11-25 14:12:15 -06:00
|
|
|
__shared__ rocshmem_ctx_t ctx;
|
2025-04-02 11:58:55 -05:00
|
|
|
int t_id = get_flat_block_id();
|
2025-02-17 06:18:46 +00:00
|
|
|
int wg_id = get_flat_grid_id();
|
2025-04-02 11:58:55 -05:00
|
|
|
int wf_id = t_id / wf_size;
|
2024-07-01 09:57:08 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < loop + skip; i++) {
|
|
|
|
|
if (hipThreadIdx_x == 0 && i == skip) {
|
2025-02-17 06:18:46 +00:00
|
|
|
start_time[wg_id] = wall_clock64();
|
2024-07-01 09:57:08 -05:00
|
|
|
}
|
|
|
|
|
|
2025-06-17 11:16:18 -05:00
|
|
|
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;
|
|
|
|
|
}
|
2025-02-19 10:31:53 -06:00
|
|
|
}
|
2025-04-02 11:58:55 -05:00
|
|
|
__syncthreads();
|
2024-07-01 09:57:08 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (hipThreadIdx_x == 0) {
|
2025-02-17 06:18:46 +00:00
|
|
|
end_time[wg_id] = wall_clock64();
|
2024-07-01 09:57:08 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
|
* HOST TESTER CLASS METHODS
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
BarrierAllTester::BarrierAllTester(TesterArguments args) : Tester(args) {}
|
|
|
|
|
|
|
|
|
|
BarrierAllTester::~BarrierAllTester() {}
|
|
|
|
|
|
|
|
|
|
void BarrierAllTester::launchKernel(dim3 gridSize, dim3 blockSize, int loop,
|
2025-07-03 13:26:54 -05:00
|
|
|
size_t size) {
|
2024-07-01 09:57:08 -05:00
|
|
|
size_t shared_bytes = 0;
|
|
|
|
|
|
|
|
|
|
hipLaunchKernelGGL(BarrierAllTest, gridSize, blockSize, shared_bytes, stream,
|
2025-04-02 11:58:55 -05:00
|
|
|
loop, args.skip, start_time, end_time, _type, wf_size);
|
2024-07-01 09:57:08 -05:00
|
|
|
|
2025-06-17 11:16:18 -05:00
|
|
|
num_msgs = (loop + args.skip);
|
|
|
|
|
num_timed_msgs = loop;
|
2024-07-01 09:57:08 -05:00
|
|
|
}
|
|
|
|
|
|
2025-07-03 13:26:54 -05:00
|
|
|
void BarrierAllTester::resetBuffers(size_t size) {}
|
2024-07-01 09:57:08 -05:00
|
|
|
|
2025-07-03 13:26:54 -05:00
|
|
|
void BarrierAllTester::verifyResults(size_t size) {}
|