/* * Copyright (c) Advanced Micro Devices, Inc., or its affiliates. * * SPDX-License-Identifier: MIT */ #include "min_max_common.hh" #include /** * @addtogroup atomicMin_system atomicMin_system * @{ * @ingroup AtomicsTest * `atomicMin_system(TestType* address, TestType* val)` - * performs system-wide atomic minimum between address and val, returns old value. */ // Helper function to run atomicMin_system tests for same address template static void runAtomicMinSystemSameAddressTest() { for (auto current = 0; current < 1; ++current) { DYNAMIC_SECTION("Same address " << current) { MinMax::MultipleDeviceMultipleKernelTest( 2, 2, 1, sizeof(TestType)); } } } // Helper function to run atomicMin_system tests for adjacent addresses template static void runAtomicMinSystemAdjacentAddressesTest() { int warp_size = 0; HIP_CHECK(hipDeviceGetAttribute(&warp_size, hipDeviceAttributeWarpSize, 0)); for (auto current = 0; current < 1; ++current) { DYNAMIC_SECTION("Adjacent address " << current) { MinMax::MultipleDeviceMultipleKernelTest( 2, 2, warp_size, sizeof(TestType)); } } } // Helper function to run atomicMin_system tests for scattered addresses template static void runAtomicMinSystemScatteredAddressesTest() { int warp_size = 0; HIP_CHECK(hipDeviceGetAttribute(&warp_size, hipDeviceAttributeWarpSize, 0)); const auto cache_line_size = 128u; for (auto current = 0; current < 1; ++current) { DYNAMIC_SECTION("Scattered address " << current) { MinMax::MultipleDeviceMultipleKernelTest( 2, 2, warp_size, cache_line_size); } } } /** * Test Description * ------------------------ * - Performs atomicMin_system from multiple threads on the same address. * - Uses multiple devices and launches multiple kernels. * Test source * ------------------------ * - unit/atomics/atomicMin_system.cc * Test requirements * ------------------------ * - Multi-device * - HIP_VERSION >= 5.2 */ HIP_TEST_CASE(Unit_atomicMin_system_Positive_Peer_GPUs_Same_Address) { SECTION("int") { runAtomicMinSystemSameAddressTest(); } SECTION("unsigned int") { runAtomicMinSystemSameAddressTest(); } SECTION("unsigned long") { runAtomicMinSystemSameAddressTest(); } SECTION("unsigned long long") { runAtomicMinSystemSameAddressTest(); } #ifdef HT_AMD SECTION("float") { runAtomicMinSystemSameAddressTest(); } SECTION("double") { runAtomicMinSystemSameAddressTest(); } #endif } /** * Test Description * ------------------------ * - Performs atomicMin_system from multiple threads on adjacent addresses. * - Uses multiple devices and launches multiple kernels. * Test source * ------------------------ * - unit/atomics/atomicMin_system.cc * Test requirements * ------------------------ * - Multi-device * - HIP_VERSION >= 5.2 */ HIP_TEST_CASE(Unit_atomicMin_system_Positive_Peer_GPUs_Adjacent_Addresses) { SECTION("int") { runAtomicMinSystemAdjacentAddressesTest(); } SECTION("unsigned int") { runAtomicMinSystemAdjacentAddressesTest(); } SECTION("unsigned long") { runAtomicMinSystemAdjacentAddressesTest(); } SECTION("unsigned long long") { runAtomicMinSystemAdjacentAddressesTest(); } #ifdef HT_AMD SECTION("float") { runAtomicMinSystemAdjacentAddressesTest(); } SECTION("double") { runAtomicMinSystemAdjacentAddressesTest(); } #endif } /** * Test Description * ------------------------ * - Performs atomicMin_system from multiple threads on scaterred addresses. * - Uses multiple devices and launches multiple kernels. * Test source * ------------------------ * - unit/atomics/atomicMin_system.cc * Test requirements * ------------------------ * - Multi-device * - HIP_VERSION >= 5.2 */ HIP_TEST_CASE(Unit_atomicMin_system_Positive_Peer_GPUs_Scattered_Addresses) { SECTION("int") { runAtomicMinSystemScatteredAddressesTest(); } SECTION("unsigned int") { runAtomicMinSystemScatteredAddressesTest(); } SECTION("unsigned long") { runAtomicMinSystemScatteredAddressesTest(); } SECTION("unsigned long long") { runAtomicMinSystemScatteredAddressesTest(); } #ifdef HT_AMD SECTION("float") { runAtomicMinSystemScatteredAddressesTest(); } SECTION("double") { runAtomicMinSystemScatteredAddressesTest(); } #endif } /** * End doxygen group AtomicsTest. * @} */