From d26d5cf992970a72eff13eb055ebef434ba8f2f8 Mon Sep 17 00:00:00 2001 From: Tao Sang Date: Wed, 1 Nov 2023 16:12:33 -0400 Subject: [PATCH] SWDEV-428198 - Improve vector operator test Add back hipVectorTypesDeviceTest.cc Rename hipVectorTypes.cc as hipVectorTypesHost.cc Fix some bugs in compiling. Related to SWDEV-426270 as well. Change-Id: I95af838136b114d776423442253e8c742a8d69e5 --- catch/unit/deviceLib/CMakeLists.txt | 3 ++- ...rTypesDevice.cc => hipVectorTypesDevice.cc} | 18 +++++++----------- ...hipVectorTypes.cc => hipVectorTypesHost.cc} | 2 +- 3 files changed, 10 insertions(+), 13 deletions(-) rename catch/unit/deviceLib/{vectorTypesDevice.cc => hipVectorTypesDevice.cc} (92%) rename catch/unit/deviceLib/{hipVectorTypes.cc => hipVectorTypesHost.cc} (99%) diff --git a/catch/unit/deviceLib/CMakeLists.txt b/catch/unit/deviceLib/CMakeLists.txt index 3e4c6321ed..67dd75e094 100644 --- a/catch/unit/deviceLib/CMakeLists.txt +++ b/catch/unit/deviceLib/CMakeLists.txt @@ -78,7 +78,8 @@ set(AMD_TEST_SRC hipMathFunctions.cc hmax_hmin.cc hipBfloat16.cc - hipVectorTypes.cc + hipVectorTypesHost.cc + hipVectorTypesDevice.cc hipTestHalf.cc hipComplex.cc hipTestFMA.cc diff --git a/catch/unit/deviceLib/vectorTypesDevice.cc b/catch/unit/deviceLib/hipVectorTypesDevice.cc similarity index 92% rename from catch/unit/deviceLib/vectorTypesDevice.cc rename to catch/unit/deviceLib/hipVectorTypesDevice.cc index cc1cbdcda1..af869fcbd9 100644 --- a/catch/unit/deviceLib/vectorTypesDevice.cc +++ b/catch/unit/deviceLib/hipVectorTypesDevice.cc @@ -30,12 +30,12 @@ using namespace std; template __device__ typename std::add_rvalue_reference::type _declval() noexcept; -template ().x)>{}>* = nullptr> +template ().x)>{}>* = nullptr> __device__ constexpr bool integer_unary_tests(const V&, const V&) { return true; } -template ().x)>{}>* = nullptr> +template ().x)>{}>* = nullptr> __device__ bool integer_unary_tests(V& f1, V& f2) { f1 %= f2; if (f1 != V{0}) return false; @@ -57,12 +57,12 @@ __device__ bool integer_unary_tests(V& f1, V& f2) { return true; } -template ().x)>{}>* = nullptr> +template ().x)>{}>* = nullptr> __device__ constexpr bool integer_binary_tests(const V&, const V&, const V&) { return true; } -template ().x)>{}>* = nullptr> +template ().x)>{}>* = nullptr> __device__ bool integer_binary_tests(V& f1, V& f2, V& f3) { f3 = f1 % f2; if (f3 != V{0}) return false; @@ -145,7 +145,7 @@ template __device__ bool TestVectorType() { return true; } -template * = nullptr> +template * = nullptr> __device__ bool TestVectorTypes() { return true; } @@ -230,7 +230,7 @@ template bool run_CheckSharedVectorType() { return passed; } -template * = nullptr> +template * = nullptr> bool run_CheckSharedVectorTypes() { return true; } @@ -239,7 +239,7 @@ template bool run_CheckSharedVectorTypes() { return run_CheckSharedVectorType() && run_CheckSharedVectorTypes(); } -TEST_CASE("Unit_vectorTypes_CompileTest") { +TEST_CASE("Unit_hipVectorTypes_test_on_device") { static_assert(sizeof(float1) == 4, ""); static_assert(sizeof(float2) >= 8, ""); static_assert(sizeof(float3) >= 12, ""); @@ -267,7 +267,3 @@ TEST_CASE("Unit_vectorTypes_CompileTest") { HIP_CHECK(hipFree(ptr)); REQUIRE(passed == true); } -//Test to check __half2_raw can be initialized without designator -TEST_CASE("Unit_half2_raw_def") { - constexpr __half2_raw inf = {0x7C00,0x7C00}; -} \ No newline at end of file diff --git a/catch/unit/deviceLib/hipVectorTypes.cc b/catch/unit/deviceLib/hipVectorTypesHost.cc similarity index 99% rename from catch/unit/deviceLib/hipVectorTypes.cc rename to catch/unit/deviceLib/hipVectorTypesHost.cc index 09d19b0397..f275230916 100644 --- a/catch/unit/deviceLib/hipVectorTypes.cc +++ b/catch/unit/deviceLib/hipVectorTypesHost.cc @@ -192,7 +192,7 @@ bool CheckVectorTypes() { float1, float2, float3, float4, double1, double2, double3, double4>(); } -TEST_CASE("Unit_TestVectorTypes") { +TEST_CASE("Unit_hipVectorTypes_test_on_host") { REQUIRE(sizeof(float1) == 4); REQUIRE(sizeof(float2) >= 8); REQUIRE(sizeof(float3) == 12);