2
0
Ficheiros
rocm-systems/catch/unit/atomics/__hip_atomic_fetch_max.cc
T
Mirza Halilčević 9d52facc34 EXSWHTEC-301 - Extend tests for atomic min/max operations #289
Change-Id: Ie9690b7986b22be9b6abdbd33ebf0e2d5fb56d66
2024-02-26 12:40:56 +05:30

187 linhas
7.2 KiB
C++

/*
Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
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,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
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 "min_max_common.hh"
#include <hip_test_common.hh>
/**
* @addtogroup __hip_atomic_fetch_max __hip_atomic_fetch_max
* @{
* @ingroup AtomicsTest
*/
/**
* Test Description
* ------------------------
* - Performs a builtin atomic MAX with memory scope WAVEFRONT from multiple threads on the same
* address.
* - Uses only one device and launches one kernel.
* Test source
* ------------------------
* - unit/atomics/__hip_atomic_fetch_max.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
TEMPLATE_TEST_CASE("Unit___hip_atomic_fetch_max_Positive_Wavefront_SameAddress", "", int,
unsigned int, unsigned long, unsigned long long, float, double) {
for (auto current = 0; current < cmd_options.iterations; ++current) {
DYNAMIC_SECTION("Same address " << current) {
MinMax::SingleDeviceSingleKernelTest<TestType, MinMax::AtomicOperation::kBuiltinMax,
__HIP_MEMORY_SCOPE_WAVEFRONT>(1, sizeof(TestType));
}
}
}
/**
* Test Description
* ------------------------
* - Performs a builtin atomic MAX with memory scope WAVEFRONT from multiple threads on adjacent
* addresses.
* - Uses only one device and launches one kernel.
* Test source
* ------------------------
* - unit/atomics/__hip_atomic_fetch_max.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
TEMPLATE_TEST_CASE("Unit___hip_atomic_fetch_max_Positive_Wavefront_Adjacent_Addresses", "", int,
unsigned int, unsigned long, unsigned long long, float, double) {
int warp_size = 0;
HIP_CHECK(hipDeviceGetAttribute(&warp_size, hipDeviceAttributeWarpSize, 0));
for (auto current = 0; current < cmd_options.iterations; ++current) {
DYNAMIC_SECTION("Adjacent address " << current) {
MinMax::SingleDeviceSingleKernelTest<TestType, MinMax::AtomicOperation::kBuiltinMax,
__HIP_MEMORY_SCOPE_WAVEFRONT>(warp_size,
sizeof(TestType));
}
}
}
/**
* Test Description
* ------------------------
* - Performs a builtin atomic MAX with memory scope WAVEFRONT from multiple threads on scattered
* addresses.
* - Uses only one device and launches one kernel.
* Test source
* ------------------------
* - unit/atomics/__hip_atomic_fetch_max.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
TEMPLATE_TEST_CASE("Unit___hip_atomic_fetch_max_Positive_Wavefront_Scattered_Addresses", "", int,
unsigned int, unsigned long, unsigned long long, float, double) {
int warp_size = 0;
HIP_CHECK(hipDeviceGetAttribute(&warp_size, hipDeviceAttributeWarpSize, 0));
const auto cache_line_size = 128u;
for (auto current = 0; current < cmd_options.iterations; ++current) {
DYNAMIC_SECTION("Scattered address " << current) {
MinMax::SingleDeviceSingleKernelTest<TestType, MinMax::AtomicOperation::kBuiltinMax,
__HIP_MEMORY_SCOPE_WAVEFRONT>(warp_size,
cache_line_size);
}
}
}
/**
* Test Description
* ------------------------
* - Performs a builtin atomic MAX with memory scope WORKGROUP from multiple threads on the same
* address.
* - Uses only one device and launches one kernel.
* Test source
* ------------------------
* - unit/atomics/__hip_atomic_fetch_max.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
TEMPLATE_TEST_CASE("Unit___hip_atomic_fetch_max_Positive_Workgroup_SameAddress", "", int,
unsigned int, unsigned long, unsigned long long, float, double) {
for (auto current = 0; current < cmd_options.iterations; ++current) {
DYNAMIC_SECTION("Same address " << current) {
MinMax::SingleDeviceSingleKernelTest<TestType, MinMax::AtomicOperation::kBuiltinMax,
__HIP_MEMORY_SCOPE_WORKGROUP>(1, sizeof(TestType));
}
}
}
/**
* Test Description
* ------------------------
* - Performs a builtin atomic MAX with memory scope WORKGROUP from multiple threads on adjacent
* addresses.
* - Uses only one device and launches one kernel.
* Test source
* ------------------------
* - unit/atomics/__hip_atomic_fetch_max.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
TEMPLATE_TEST_CASE("Unit___hip_atomic_fetch_max_Positive_Workgroup_Adjacent_Addresses", "", int,
unsigned int, unsigned long, unsigned long long, float, double) {
int warp_size = 0;
HIP_CHECK(hipDeviceGetAttribute(&warp_size, hipDeviceAttributeWarpSize, 0));
for (auto current = 0; current < cmd_options.iterations; ++current) {
DYNAMIC_SECTION("Adjacent address " << current) {
MinMax::SingleDeviceSingleKernelTest<TestType, MinMax::AtomicOperation::kBuiltinMax,
__HIP_MEMORY_SCOPE_WORKGROUP>(warp_size,
sizeof(TestType));
}
}
}
/**
* Test Description
* ------------------------
* - Performs a builtin atomic MAX with memory scope WORKGROUP from multiple threads on scattered
* addresses.
* - Uses only one device and launches one kernel.
* Test source
* ------------------------
* - unit/atomics/__hip_atomic_fetch_max.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
TEMPLATE_TEST_CASE("Unit___hip_atomic_fetch_max_Positive_Workgroup_Scattered_Addresses", "", int,
unsigned int, unsigned long, unsigned long long, float, double) {
int warp_size = 0;
HIP_CHECK(hipDeviceGetAttribute(&warp_size, hipDeviceAttributeWarpSize, 0));
const auto cache_line_size = 128u;
for (auto current = 0; current < cmd_options.iterations; ++current) {
DYNAMIC_SECTION("Scattered address " << current) {
MinMax::SingleDeviceSingleKernelTest<TestType, MinMax::AtomicOperation::kBuiltinMax,
__HIP_MEMORY_SCOPE_WORKGROUP>(warp_size,
cache_line_size);
}
}
}