diff --git a/catch/DoxyfileTests b/catch/DoxyfileTests index d703ed8b9e..b731fc0c13 100644 --- a/catch/DoxyfileTests +++ b/catch/DoxyfileTests @@ -2160,7 +2160,8 @@ PREDEFINED = TEMPLATE_TEST_CASE(x)=x() \ __linux__ \ HT_AMD \ HT_NVIDIA \ - __HIP_PLATFORM_NVCC__ + __HIP_PLATFORM_NVCC__ \ + __GNUC__ # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this # tag can be used to specify a list of macro names that should be expanded. The diff --git a/catch/hipTestMain/config/config_amd_linux_common.json b/catch/hipTestMain/config/config_amd_linux_common.json index 1a3df8cc4c..4d26b020ae 100644 --- a/catch/hipTestMain/config/config_amd_linux_common.json +++ b/catch/hipTestMain/config/config_amd_linux_common.json @@ -46,6 +46,7 @@ "Unit_hipGraphAddMemcpyNode1D_Negative_Basic", "intermittent issue: corrupted double-linked list", "Unit_hipGraphRetainUserObject_Functional_2", + "Unit_ChannelDescriptor_Positive_16BitFloatingPoint", "intermittent issue: failure expected but sucess returned", "Unit_hipMemAdvise_NegtveTsts", "Note: Following four tests disabled due to defect - EXSWHTEC-203", @@ -98,6 +99,16 @@ "Unit_hipStreamValue_Write - TestParams", "Unit_hipMemcpyParam2DAsync_multiDevice-StreamOnDiffDevice", "=== Below tests fail in external CI for PR https://github.com/ROCm-Developer-Tools/hip-tests/pull/96 ===", - "Unit_hipHostGetDevicePointer_Negative" + "Unit_hipHostGetDevicePointer_Negative", + "=== Below tests fail in external CI for PR https://github.com/ROCm-Developer-Tools/hip-tests/pull/215 ===", + "Unit_ChannelDescriptor_Positive_Basic_1D - long", + "Unit_ChannelDescriptor_Positive_Basic_1D - unsigned long", + "Unit_ChannelDescriptor_Positive_Basic_1D - ulong1", + "Unit_ChannelDescriptor_Positive_Basic_1D - signed long", + "Unit_ChannelDescriptor_Positive_Basic_1D - long1", + "Unit_ChannelDescriptor_Positive_Basic_2D - ulong2", + "Unit_ChannelDescriptor_Positive_Basic_2D - long2", + "Unit_ChannelDescriptor_Positive_Basic_4D - ulong4", + "Unit_ChannelDescriptor_Positive_Basic_4D - long4" ] } diff --git a/catch/hipTestMain/config/config_amd_windows_common.json b/catch/hipTestMain/config/config_amd_windows_common.json index 87d534cfd8..d5faf9b538 100644 --- a/catch/hipTestMain/config/config_amd_windows_common.json +++ b/catch/hipTestMain/config/config_amd_windows_common.json @@ -150,6 +150,7 @@ "Unit_hipStreamQuery_WithFinishedWork", "Unit_hipLaunchHostFunc_Graph", "Unit_hipLaunchHostFunc_KernelHost", + "Unit_ChannelDescriptor_Positive_16BitFloatingPoint", "Unit_hipStreamSetCaptureDependencies_Positive_Functional", "Note: Following four tests disabled due to defect - EXSWHTEC-203", "Unit_hipGraphAddMemsetNode_Positive_Basic - uint16_t", @@ -186,6 +187,18 @@ "Note: UUID returned empty on some windows nodes", "Unit_hipDeviceGetUuid_Positive", "=== Below tests fail in external CI for PR https://github.com/ROCm-Developer-Tools/hip-tests/pull/96 ===", - "Unit_hipHostGetDevicePointer_Negative" + "Unit_hipHostGetDevicePointer_Negative", + "=== Below tests fail in external CI for PR https://github.com/ROCm-Developer-Tools/hip-tests/pull/215 ===", + "Unit_ChannelDescriptor_Positive_Basic_1D - long", + "Unit_ChannelDescriptor_Positive_Basic_1D - unsigned long", + "Unit_ChannelDescriptor_Positive_Basic_1D - ulong1", + "Unit_ChannelDescriptor_Positive_Basic_1D - signed long", + "Unit_ChannelDescriptor_Positive_Basic_1D - long1", + "Unit_ChannelDescriptor_Positive_Basic_2D - ulong2", + "Unit_ChannelDescriptor_Positive_Basic_2D - long2", + "Unit_ChannelDescriptor_Positive_Basic_3D - ulong3", + "Unit_ChannelDescriptor_Positive_Basic_3D - long3", + "Unit_ChannelDescriptor_Positive_Basic_4D - ulong4", + "Unit_ChannelDescriptor_Positive_Basic_4D - long4" ] } diff --git a/catch/hipTestMain/config/config_nvidia_linux_common.json b/catch/hipTestMain/config/config_nvidia_linux_common.json index 7766cbe28d..84df4337fb 100644 --- a/catch/hipTestMain/config/config_nvidia_linux_common.json +++ b/catch/hipTestMain/config/config_nvidia_linux_common.json @@ -6,6 +6,18 @@ "Unit_hipFuncSetAttribute_Positive_MaxDynamicSharedMemorySize_Not_Supported", "Unit_hipFuncSetAttribute_Positive_PreferredSharedMemoryCarveout_Not_Supported", "=== Below test fails in external CI for PR https://github.com/ROCm-Developer-Tools/hip-tests/pull/85 ===", - "Unit_hipFuncSetAttribute_Negative_Parameters" + "Unit_hipFuncSetAttribute_Negative_Parameters", + "=== Below test fails in external CI for PR https://github.com/ROCm-Developer-Tools/hip-tests/pull/215 ===", + "Unit_ChannelDescriptor_Positive_Basic_1D - long", + "Unit_ChannelDescriptor_Positive_Basic_1D - unsigned long", + "Unit_ChannelDescriptor_Positive_Basic_1D - ulong1", + "Unit_ChannelDescriptor_Positive_Basic_1D - signed long", + "Unit_ChannelDescriptor_Positive_Basic_1D - long1", + "Unit_ChannelDescriptor_Positive_Basic_2D - ulong2", + "Unit_ChannelDescriptor_Positive_Basic_2D - long2", + "Unit_ChannelDescriptor_Positive_Basic_3D - ulong3", + "Unit_ChannelDescriptor_Positive_Basic_3D - long3", + "Unit_ChannelDescriptor_Positive_Basic_4D - ulong4", + "Unit_ChannelDescriptor_Positive_Basic_4D - long4" ] } diff --git a/catch/hipTestMain/config/config_nvidia_windows_common.json b/catch/hipTestMain/config/config_nvidia_windows_common.json index 8247b49e3a..771113cc69 100644 --- a/catch/hipTestMain/config/config_nvidia_windows_common.json +++ b/catch/hipTestMain/config/config_nvidia_windows_common.json @@ -4,6 +4,18 @@ "Unit_hipFuncSetCacheConfig_Negative_Not_Supported", "Unit_hipFuncSetSharedMemConfig_Negative_Not_Supported", "Unit_hipFuncSetAttribute_Positive_MaxDynamicSharedMemorySize_Not_Supported", - "Unit_hipFuncSetAttribute_Positive_PreferredSharedMemoryCarveout_Not_Supported" + "Unit_hipFuncSetAttribute_Positive_PreferredSharedMemoryCarveout_Not_Supported", + "=== Below test fails in external CI for PR https://github.com/ROCm-Developer-Tools/hip-tests/pull/215 ===", + "Unit_ChannelDescriptor_Positive_Basic_1D - long", + "Unit_ChannelDescriptor_Positive_Basic_1D - unsigned long", + "Unit_ChannelDescriptor_Positive_Basic_1D - ulong1", + "Unit_ChannelDescriptor_Positive_Basic_1D - signed long", + "Unit_ChannelDescriptor_Positive_Basic_1D - long1", + "Unit_ChannelDescriptor_Positive_Basic_2D - ulong2", + "Unit_ChannelDescriptor_Positive_Basic_2D - long2", + "Unit_ChannelDescriptor_Positive_Basic_3D - ulong3", + "Unit_ChannelDescriptor_Positive_Basic_3D - long3", + "Unit_ChannelDescriptor_Positive_Basic_4D - ulong4", + "Unit_ChannelDescriptor_Positive_Basic_4D - long4" ] } diff --git a/catch/include/hip_test_defgroups.hh b/catch/include/hip_test_defgroups.hh index d8fdc5b26d..590f680880 100644 --- a/catch/include/hip_test_defgroups.hh +++ b/catch/include/hip_test_defgroups.hh @@ -72,6 +72,13 @@ THE SOFTWARE. * @} */ +/** + * @defgroup DeviceLanguageTest Device Language + * @{ + * This section describes tests for the Device Language API. + * @} + */ + /** * @defgroup ExecutionTest Execution Control * @{ diff --git a/catch/unit/CMakeLists.txt b/catch/unit/CMakeLists.txt index 5b3bbf66b6..e0b1f5a1b2 100644 --- a/catch/unit/CMakeLists.txt +++ b/catch/unit/CMakeLists.txt @@ -39,6 +39,8 @@ add_subdirectory(context) add_subdirectory(dynamicLoading) add_subdirectory(g++) add_subdirectory(module) +add_subdirectory(channelDescriptor) +add_subdirectory(executionControl) if(HIP_PLATFORM STREQUAL "amd") add_subdirectory(callback) @@ -46,4 +48,3 @@ add_subdirectory(callback) # Vulkan interop APIs currently undefined for Nvidia add_subdirectory(vulkan_interop) endif() -add_subdirectory(executionControl) diff --git a/catch/unit/channelDescriptor/CMakeLists.txt b/catch/unit/channelDescriptor/CMakeLists.txt new file mode 100644 index 0000000000..50970c6cec --- /dev/null +++ b/catch/unit/channelDescriptor/CMakeLists.txt @@ -0,0 +1,27 @@ +# Copyright (c) 2022 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. + +set(TEST_SRC + channel_descriptor.cc +) + +hip_add_exe_to_target(NAME ChannelDescriptorTest + TEST_SRC ${TEST_SRC} + TEST_TARGET_NAME build_tests) diff --git a/catch/unit/channelDescriptor/channel_descriptor.cc b/catch/unit/channelDescriptor/channel_descriptor.cc new file mode 100644 index 0000000000..60f68817bc --- /dev/null +++ b/catch/unit/channelDescriptor/channel_descriptor.cc @@ -0,0 +1,194 @@ +/* +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 "channel_descriptor_common.hh" + +/** + * @addtogroup hipCreateChannelDesc hipCreateChannelDesc + * @{ + * @ingroup DeviceLanguageTest + * `hipCreateChannelDesc()` - + * Creates a dedicated channel descriptor based on passed built-in or vector type T. + */ + +/** + * Test Description + * ------------------------ + * - Validates that 1D channel descriptor is created as expected. + * - Compares channel descriptor with the manually created one. + * - Takes into consideration following 1D built-in and vector types: + * -# char (signed and unsigned) + * -# short (signed and unsigned) + * -# int (signed and unsigned) + * -# float + * -# long (signed and unsigned) + * Test source + * ------------------------ + * - unit/channelDescriptor/channel_descriptor.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ +TEMPLATE_TEST_CASE("Unit_ChannelDescriptor_Positive_Basic_1D", "", char, unsigned char, uchar1, + signed char, char1, unsigned short, ushort1, short, signed short, short1, int, + unsigned int, uint1, signed int, int1, float, float1, long, unsigned long, + ulong1, signed long, long1) { + ChannelDescriptorTest1D channel_desc_test; + channel_desc_test.Run(); +} + +/** + * Test Description + * ------------------------ + * - Validates that 2D channel descriptor is created as expected. + * - Compares channel descriptor with the manually created one. + * - Takes into consideration following 2D built-in and vector types: + * -# char (signed and unsigned) + * -# short (signed and unsigned) + * -# int (signed and unsigned) + * -# float + * -# long (signed and unsigned) + * Test source + * ------------------------ + * - unit/channelDescriptor/channel_descriptor.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ +TEMPLATE_TEST_CASE("Unit_ChannelDescriptor_Positive_Basic_2D", "", uchar2, char2, ushort2, short2, + uint2, int2, float2, ulong2, long2) { + ChannelDescriptorTest2D channel_desc_test; + channel_desc_test.Run(); +} + +#ifndef __GNUC__ +/** + * Test Description + * ------------------------ + * - Validates that 3D channel descriptor is created as expected. + * - Compares channel descriptor with the manually created one. + * - Takes into consideration following 3D built-in and vector types: + * -# char (signed and unsigned) + * -# short (signed and unsigned) + * -# int (signed and unsigned) + * -# float + * -# long (signed and unsigned) + * Test source + * ------------------------ + * - unit/channelDescriptor/channel_descriptor.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + * - Available for non-GNUC compilers. + */ +TEMPLATE_TEST_CASE("Unit_ChannelDescriptor_Positive_Basic_3D", "", uchar3, char3, ushort3, short3, + uint3, int3, float3, ulong3, long3) { + ChannelDescriptorTest3D channel_desc_test; + channel_desc_test.Run(); +} +#endif + +/** + * Test Description + * ------------------------ + * - Validates that 4D channel descriptor is created as expected. + * - Compares channel descriptor with the manually created one. + * - Takes into consideration following 4D built-in and vector types: + * -# char (signed and unsigned) + * -# short (signed and unsigned) + * -# int (signed and unsigned) + * -# float + * -# long (signed and unsigned) + * Test source + * ------------------------ + * - unit/channelDescriptor/channel_descriptor.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ +TEMPLATE_TEST_CASE("Unit_ChannelDescriptor_Positive_Basic_4D", "", uchar4, char4, ushort4, short4, + uint4, int4, float4, ulong4, long4) { + ChannelDescriptorTest4D channel_desc_test; + channel_desc_test.Run(); +} + +/** + * Test Description + * ------------------------ + * - Validates that an empty channel descriptor is created as expected. + * - Compares channel descriptor with the manually created one. + * - Takes into consideration all dimensions of the following built-in and vector types: + * -# long long (signed and unsigned) + * -# double + * Test source + * ------------------------ + * - unit/channelDescriptor/channel_descriptor.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ +TEMPLATE_TEST_CASE("Unit_ChannelDescriptor_Positive_FormatNone", "", long long, signed long long, + unsigned long long, longlong1, longlong2, longlong3, longlong4, ulonglong1, + ulonglong2, ulonglong3, ulonglong4, double1, double2, double3, double4) { + ChannelDescriptorTestNone channel_desc_test; + channel_desc_test.Run(); +} + +#if HT_AMD +/** + * Test Description + * ------------------------ + * - Validates that the channel descriptor is created as expected. + * - Compares channel descriptor with the manually created one. + * - Takes into consideration 16-bit floating-point type. + * -# Creates 1D channel descriptor. + * -# Creates 2D channel descriptor. + * Test source + * ------------------------ + * - unit/channelDescriptor/channel_descriptor.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ +TEST_CASE("Unit_ChannelDescriptor_Positive_16BitFloatingPoint") { + int size = static_cast(sizeof(unsigned short) * 8); + hipChannelFormatKind kind = hipChannelFormatKindFloat; + hipChannelFormatDesc channel_desc{}; + hipChannelFormatDesc referent_channel_desc{}; + + SECTION("hipCreateChannelDescHalf") { + referent_channel_desc = {size, 0, 0, 0, kind}; + channel_desc = hipCreateChannelDescHalf(); + } + SECTION("hipCreateChannelDescHalf1") { + referent_channel_desc = {size, 0, 0, 0, kind}; + channel_desc = hipCreateChannelDescHalf1(); + } + SECTION("hipCreateChannelDescHalf2") { + referent_channel_desc = {size, size, 0, 0, kind}; + channel_desc = hipCreateChannelDescHalf2(); + } + + REQUIRE(channel_desc.x == referent_channel_desc.x); + REQUIRE(channel_desc.y == referent_channel_desc.y); + REQUIRE(channel_desc.z == referent_channel_desc.z); + REQUIRE(channel_desc.w == referent_channel_desc.w); + REQUIRE(channel_desc.f == referent_channel_desc.f); +} +#endif diff --git a/catch/unit/channelDescriptor/channel_descriptor_common.hh b/catch/unit/channelDescriptor/channel_descriptor_common.hh new file mode 100644 index 0000000000..47e87025be --- /dev/null +++ b/catch/unit/channelDescriptor/channel_descriptor_common.hh @@ -0,0 +1,221 @@ +/* +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 + +enum class ChannelDimension { OneDim, TwoDim, ThreeDim, FourDim }; + +template class ChannelDescriptorTestShell { + protected: + int size; + hipChannelFormatKind kind; + ChannelDimension dimension; + virtual void SetSizeAndKind() = 0; + + public: + void Run() { + hipChannelFormatDesc channel_desc{}; + SetSizeAndKind(); + hipChannelFormatDesc referent_channel_desc{0, 0, 0, 0, kind}; + switch (dimension) { + case ChannelDimension::FourDim: + referent_channel_desc.w = size; + case ChannelDimension::ThreeDim: + referent_channel_desc.z = size; + case ChannelDimension::TwoDim: + referent_channel_desc.y = size; + default: + referent_channel_desc.x = size; + } + channel_desc = hipCreateChannelDesc(); + REQUIRE(channel_desc.x == referent_channel_desc.x); + REQUIRE(channel_desc.y == referent_channel_desc.y); + REQUIRE(channel_desc.z == referent_channel_desc.z); + REQUIRE(channel_desc.w == referent_channel_desc.w); + REQUIRE(channel_desc.f == referent_channel_desc.f); + } + + ChannelDescriptorTestShell(const ChannelDimension dimension) + : size(0), kind(hipChannelFormatKindNone), dimension(dimension) {} + ChannelDescriptorTestShell(const ChannelDescriptorTestShell&) = delete; + ChannelDescriptorTestShell(ChannelDescriptorTestShell&&) = delete; +}; + +template class ChannelDescriptorTest1D : public ChannelDescriptorTestShell { + public: + ChannelDescriptorTest1D() : ChannelDescriptorTestShell(ChannelDimension::OneDim) {} + + protected: + void SetSizeAndKind() { + if (std::is_same_v) { + this->size = static_cast(sizeof(char) * 8); + this->kind = hipChannelFormatKindSigned; + } else if (std::is_same_v || std::is_same_v) { + this->size = static_cast(sizeof(unsigned char) * 8); + this->kind = hipChannelFormatKindUnsigned; + } else if (std::is_same_v || std::is_same_v) { + this->size = static_cast(sizeof(signed char) * 8); + this->kind = hipChannelFormatKindSigned; + } else if (std::is_same_v || std::is_same_v) { + this->size = static_cast(sizeof(unsigned short) * 8); + this->kind = hipChannelFormatKindUnsigned; + } else if (std::is_same_v || std::is_same_v || + std::is_same_v) { + this->size = static_cast(sizeof(signed short) * 8); + this->kind = hipChannelFormatKindSigned; + } else if (std::is_same_v || std::is_same_v) { + this->size = static_cast(sizeof(unsigned int) * 8); + this->kind = hipChannelFormatKindUnsigned; + } else if (std::is_same_v || std::is_same_v || std::is_same_v) { + this->size = static_cast(sizeof(signed int) * 8); + this->kind = hipChannelFormatKindSigned; + } else if (std::is_same_v || std::is_same_v) { + this->size = static_cast(sizeof(float) * 8); + this->kind = hipChannelFormatKindFloat; + } else if (std::is_same_v || std::is_same_v) { + this->size = static_cast(sizeof(unsigned long) * 8); + this->kind = hipChannelFormatKindUnsigned; + } else if (std::is_same_v || std::is_same_v || + std::is_same_v) { + this->size = static_cast(sizeof(signed long) * 8); + this->kind = hipChannelFormatKindSigned; + } + } +}; + +template class ChannelDescriptorTest2D : public ChannelDescriptorTestShell { + public: + ChannelDescriptorTest2D() : ChannelDescriptorTestShell(ChannelDimension::TwoDim) {} + + protected: + void SetSizeAndKind() { + if (std::is_same_v) { + this->size = static_cast(sizeof(unsigned char) * 8); + this->kind = hipChannelFormatKindUnsigned; + } else if (std::is_same_v) { + this->size = static_cast(sizeof(signed char) * 8); + this->kind = hipChannelFormatKindSigned; + } else if (std::is_same_v) { + this->size = static_cast(sizeof(unsigned short) * 8); + this->kind = hipChannelFormatKindUnsigned; + } else if (std::is_same_v) { + this->size = static_cast(sizeof(signed short) * 8); + this->kind = hipChannelFormatKindSigned; + } else if (std::is_same_v) { + this->size = static_cast(sizeof(unsigned int) * 8); + this->kind = hipChannelFormatKindUnsigned; + } else if (std::is_same_v) { + this->size = static_cast(sizeof(signed int) * 8); + this->kind = hipChannelFormatKindSigned; + } else if (std::is_same_v) { + this->size = static_cast(sizeof(float) * 8); + this->kind = hipChannelFormatKindFloat; + } else if (std::is_same_v) { + this->size = static_cast(sizeof(unsigned long) * 8); + this->kind = hipChannelFormatKindUnsigned; + } else if (std::is_same_v) { + this->size = static_cast(sizeof(signed long) * 8); + this->kind = hipChannelFormatKindSigned; + } + } +}; + +#ifndef __GNUC__ +template class ChannelDescriptorTest3D : public ChannelDescriptorTestShell { + public: + ChannelDescriptorTest3D() : ChannelDescriptorTestShell(ChannelDimension::ThreeDim) {} + + protected: + void SetSizeAndKind() { + if (std::is_same_v) { + this->size = static_cast(sizeof(unsigned char) * 8); + this->kind = hipChannelFormatKindUnsigned; + } else if (std::is_same_v) { + this->size = static_cast(sizeof(signed char) * 8); + this->kind = hipChannelFormatKindSigned; + } else if (std::is_same_v) { + this->size = static_cast(sizeof(unsigned short) * 8); + this->kind = hipChannelFormatKindUnsigned; + } else if (std::is_same_v) { + this->size = static_cast(sizeof(signed short) * 8); + this->kind = hipChannelFormatKindSigned; + } else if (std::is_same_v) { + this->size = static_cast(sizeof(unsigned int) * 8); + this->kind = hipChannelFormatKindUnsigned; + } else if (std::is_same_v) { + this->size = static_cast(sizeof(signed int) * 8); + this->kind = hipChannelFormatKindSigned; + } else if (std::is_same_v) { + this->size = static_cast(sizeof(float) * 8); + this->kind = hipChannelFormatKindFloat; + } else if (std::is_same_v) { + this->size = static_cast(sizeof(unsigned long) * 8); + this->kind = hipChannelFormatKindUnsigned; + } else if (std::is_same_v) { + this->size = static_cast(sizeof(signed long) * 8); + this->kind = hipChannelFormatKindSigned; + } + } +}; +#endif + +template class ChannelDescriptorTest4D : public ChannelDescriptorTestShell { + public: + ChannelDescriptorTest4D() : ChannelDescriptorTestShell(ChannelDimension::FourDim) {} + + protected: + void SetSizeAndKind() { + if (std::is_same_v) { + this->size = static_cast(sizeof(unsigned char) * 8); + this->kind = hipChannelFormatKindUnsigned; + } else if (std::is_same_v) { + this->size = static_cast(sizeof(signed char) * 8); + this->kind = hipChannelFormatKindSigned; + } else if (std::is_same_v) { + this->size = static_cast(sizeof(unsigned short) * 8); + this->kind = hipChannelFormatKindUnsigned; + } else if (std::is_same_v) { + this->size = static_cast(sizeof(signed short) * 8); + this->kind = hipChannelFormatKindSigned; + } else if (std::is_same_v) { + this->size = static_cast(sizeof(unsigned int) * 8); + this->kind = hipChannelFormatKindUnsigned; + } else if (std::is_same_v) { + this->size = static_cast(sizeof(signed int) * 8); + this->kind = hipChannelFormatKindSigned; + } else if (std::is_same_v) { + this->size = static_cast(sizeof(float) * 8); + this->kind = hipChannelFormatKindFloat; + } else if (std::is_same_v) { + this->size = static_cast(sizeof(unsigned long) * 8); + this->kind = hipChannelFormatKindUnsigned; + } else if (std::is_same_v) { + this->size = static_cast(sizeof(signed long) * 8); + this->kind = hipChannelFormatKindSigned; + } + } +}; + +template class ChannelDescriptorTestNone : public ChannelDescriptorTestShell { + public: + ChannelDescriptorTestNone() : ChannelDescriptorTestShell(ChannelDimension::OneDim) {} + + protected: + void SetSizeAndKind() {} +};