From 9893726343f273102b86e07423d6ae1b95e305eb Mon Sep 17 00:00:00 2001 From: Vladana Stojiljkovic Date: Tue, 17 Sep 2024 15:56:39 +0200 Subject: [PATCH] SWDEV-453145 - Enable _sync tests on nvidia * _sync tests that use warp match functions (__match_any_sync and __match_all_sync) were disabled for nvidia because those functions are supported only on devices with compute capability 7.x or higher. In this solution, tests are always build (with specifying appropriate compile flag) and in in the runtime it is decided weather they should be skipped or not. Change-Id: Ifa9e55f3b47aa3a00027cb986cd6ae46aed45ebd --- catch/include/hip_test_common.hh | 22 ++++++++++++++++++++ catch/unit/warp/CMakeLists.txt | 27 ++++++++++++++++--------- catch/unit/warp/hipMatchSyncAllTests.cc | 2 ++ catch/unit/warp/hipMatchSyncAnyTests.cc | 2 ++ catch/unit/warp/hipShflSyncDownTests.cc | 2 ++ catch/unit/warp/hipShflSyncTests.cc | 2 ++ catch/unit/warp/hipShflSyncUpTests.cc | 2 ++ catch/unit/warp/hipShflSyncXorTests.cc | 2 ++ catch/unit/warp/hipVoteSyncTests.cc | 6 ++++++ 9 files changed, 57 insertions(+), 10 deletions(-) diff --git a/catch/include/hip_test_common.hh b/catch/include/hip_test_common.hh index 07819ee270..c801d0f1c1 100644 --- a/catch/include/hip_test_common.hh +++ b/catch/include/hip_test_common.hh @@ -313,6 +313,20 @@ inline bool isImageSupported() { return imageSupport != 0; } +inline bool areWarpMatchFunctionsSupported() { + int matchFunctionsSupported = 1; +#if HT_NVIDIA + int device; + hipDeviceProp_t prop; + HIP_CHECK(hipGetDevice(&device)); + HIP_CHECK(hipGetDeviceProperties(&prop, device)); + if (prop.major < 7) { + matchFunctionsSupported = 0; + } +#endif + return matchFunctionsSupported != 0; +} + /** * Causes the test to stop and be skipped at runtime. * reason: Message describing the reason the test has been skipped. @@ -485,6 +499,14 @@ class BlockingContext { return; \ } +// This must be called in the beginning of warp test app's main() to indicate warp match functions +// are supported. +#define CHECK_WARP_MATCH_FUNCTIONS_SUPPORT \ + if (!HipTest::areWarpMatchFunctionsSupported()) { \ + INFO("Warp Match Functions are not support on the device. Skipped."); \ + return; \ + } + // Call GENERATE_CAPTURE macro at the start of the test, before using BEGIN/END_CAPTURE. // Use BEGIN/END_CAPTURE macros to execute APIs in both stream capturing and non-capturing modes. // Place BEGIN_CAPTURE before the API call and END_CAPTURE after the call. diff --git a/catch/unit/warp/CMakeLists.txt b/catch/unit/warp/CMakeLists.txt index 1cab1f2080..8b957d3304 100644 --- a/catch/unit/warp/CMakeLists.txt +++ b/catch/unit/warp/CMakeLists.txt @@ -3,6 +3,13 @@ set(TEST_SRC warp_ballot.cc warp_any.cc warp_all.cc + hipMatchSyncAllTests.cc + hipMatchSyncAnyTests.cc + hipShflSyncDownTests.cc + hipShflSyncUpTests.cc + hipShflSyncXorTests.cc + hipShflSyncTests.cc + hipVoteSyncTests.cc ) if(HIP_PLATFORM MATCHES "amd") @@ -13,19 +20,19 @@ if(HIP_PLATFORM MATCHES "amd") warp_shfl_down.cc hipShflUpDownTest.cc hipShflTests.cc - # FIXME: The tests for sync intrinsics are temporarily disabled on CUDA - # because they depend on __match_any_sync, which is not available on older - # NVIDIA devices. (SWDEV-453145) - hipMatchSyncAllTests.cc - hipMatchSyncAnyTests.cc - hipShflSyncDownTests.cc - hipShflSyncUpTests.cc - hipShflSyncXorTests.cc - hipShflSyncTests.cc - hipVoteSyncTests.cc ) endif() + if(HIP_PLATFORM MATCHES "nvidia") + set_source_files_properties(hipMatchSyncAllTests.cc PROPERTIES COMPILE_FLAGS "-arch=sm_70") + set_source_files_properties(hipMatchSyncAnyTests.cc PROPERTIES COMPILE_FLAGS "-arch=sm_70") + set_source_files_properties(hipShflSyncDownTests.cc PROPERTIES COMPILE_FLAGS "-arch=sm_70") + set_source_files_properties(hipShflSyncUpTests.cc PROPERTIES COMPILE_FLAGS "-arch=sm_70") + set_source_files_properties(hipShflSyncXorTests.cc PROPERTIES COMPILE_FLAGS "-arch=sm_70") + set_source_files_properties(hipShflSyncTests.cc PROPERTIES COMPILE_FLAGS "-arch=sm_70") + set_source_files_properties(hipVoteSyncTests.cc PROPERTIES COMPILE_FLAGS "-arch=sm_70") + endif() + hip_add_exe_to_target(NAME WarpTest TEST_SRC ${TEST_SRC} TEST_TARGET_NAME build_tests) diff --git a/catch/unit/warp/hipMatchSyncAllTests.cc b/catch/unit/warp/hipMatchSyncAllTests.cc index dddf7959d4..3d8e925649 100644 --- a/catch/unit/warp/hipMatchSyncAllTests.cc +++ b/catch/unit/warp/hipMatchSyncAllTests.cc @@ -238,6 +238,8 @@ static void runTestMatchAll_3() { */ TEST_CASE("Unit_hipMatchSync_All") { + CHECK_WARP_MATCH_FUNCTIONS_SUPPORT + SECTION("run test for int") { runTestMatchAll_1(); runTestMatchAll_2(); diff --git a/catch/unit/warp/hipMatchSyncAnyTests.cc b/catch/unit/warp/hipMatchSyncAnyTests.cc index 341d55619e..12e7d5a600 100644 --- a/catch/unit/warp/hipMatchSyncAnyTests.cc +++ b/catch/unit/warp/hipMatchSyncAnyTests.cc @@ -161,6 +161,8 @@ static void runTestMatchAny_2() { */ TEST_CASE("Unit_hipMatchSync_Any") { + CHECK_WARP_MATCH_FUNCTIONS_SUPPORT + SECTION("run test for int") { runTestMatchAny_1(); runTestMatchAny_2(); diff --git a/catch/unit/warp/hipShflSyncDownTests.cc b/catch/unit/warp/hipShflSyncDownTests.cc index 75b8acddac..12cfba61c9 100644 --- a/catch/unit/warp/hipShflSyncDownTests.cc +++ b/catch/unit/warp/hipShflSyncDownTests.cc @@ -188,6 +188,8 @@ static void runTestShflDown_3() { */ TEST_CASE("Unit_hipShflSync_Down") { + CHECK_WARP_MATCH_FUNCTIONS_SUPPORT + SECTION("run test for short") { runTestShflDown_1(); runTestShflDown_2(); diff --git a/catch/unit/warp/hipShflSyncTests.cc b/catch/unit/warp/hipShflSyncTests.cc index 1fb240edbc..6a37c30727 100644 --- a/catch/unit/warp/hipShflSyncTests.cc +++ b/catch/unit/warp/hipShflSyncTests.cc @@ -133,6 +133,8 @@ static void runTestShfl_2() { */ TEST_CASE("Unit_hipShflSync") { + CHECK_WARP_MATCH_FUNCTIONS_SUPPORT + SECTION("run test for short") { runTestShfl_1(); runTestShfl_2(); diff --git a/catch/unit/warp/hipShflSyncUpTests.cc b/catch/unit/warp/hipShflSyncUpTests.cc index 586a44ab76..ed4c4a640d 100644 --- a/catch/unit/warp/hipShflSyncUpTests.cc +++ b/catch/unit/warp/hipShflSyncUpTests.cc @@ -180,6 +180,8 @@ static void runTestShflUp_3() { */ TEST_CASE("Unit_hipShflSync_Up") { + CHECK_WARP_MATCH_FUNCTIONS_SUPPORT + SECTION("run test for short") { runTestShflUp_1(); runTestShflUp_2(); diff --git a/catch/unit/warp/hipShflSyncXorTests.cc b/catch/unit/warp/hipShflSyncXorTests.cc index 9f07824168..9a48c612e1 100644 --- a/catch/unit/warp/hipShflSyncXorTests.cc +++ b/catch/unit/warp/hipShflSyncXorTests.cc @@ -171,6 +171,8 @@ static void runTestShflXor_3() { */ TEST_CASE("Unit_hipShflSync_Xor") { + CHECK_WARP_MATCH_FUNCTIONS_SUPPORT + SECTION("run test for short") { runTestShflXor_1(); runTestShflXor_2(); diff --git a/catch/unit/warp/hipVoteSyncTests.cc b/catch/unit/warp/hipVoteSyncTests.cc index 53cf56b594..6044d0f234 100644 --- a/catch/unit/warp/hipVoteSyncTests.cc +++ b/catch/unit/warp/hipVoteSyncTests.cc @@ -573,6 +573,8 @@ static void runTestBallot_3() { */ TEST_CASE("Unit_hipVoteSync_Any") { + CHECK_WARP_MATCH_FUNCTIONS_SUPPORT + runTestAny_1(); runTestAny_2_w64(); runTestAny_2_w32(); @@ -581,6 +583,8 @@ TEST_CASE("Unit_hipVoteSync_Any") { } TEST_CASE("Unit_hipVoteSync_All") { + CHECK_WARP_MATCH_FUNCTIONS_SUPPORT + runTestAll_1_w64(); runTestAll_1_w32(); runTestAll_2(); @@ -589,6 +593,8 @@ TEST_CASE("Unit_hipVoteSync_All") { } TEST_CASE("Unit_hipVoteSync_Ballot") { + CHECK_WARP_MATCH_FUNCTIONS_SUPPORT + runTestBallot_1(); runTestBallot_2(); runTestBallot_3();