EXSWHTEC-348 - Implement tests for hipArrayGetInfo, hipArrayGetDescriptor, and hipArray3DGetDescriptor #428
Change-Id: I08a7c96c971f5ee82be4e69343600530a214a117
Этот коммит содержится в:
коммит произвёл
Rakesh Roy
родитель
20a3811696
Коммит
39bd6bcac6
@@ -164,10 +164,49 @@ set(TEST_SRC
|
||||
hipStreamAttachMemAsync.cc
|
||||
hipMemRangeGetAttributes_old.cc
|
||||
hipMemGetAddressRange.cc
|
||||
hipArrayGetDescriptor.cc
|
||||
hipMallocMipmappedArray.cc
|
||||
hipFreeMipmappedArray.cc)
|
||||
|
||||
if(HIP_PLATFORM MATCHES "amd")
|
||||
set(TEST_SRC
|
||||
${TEST_SRC}
|
||||
# Below 3 tests should be compiled for NVIDIA as well after EXSWHTEC-349 is addressed
|
||||
hipArrayGetInfo.cc
|
||||
hipArrayGetDescriptor.cc
|
||||
hipArray3DGetDescriptor.cc)
|
||||
endif()
|
||||
|
||||
set(NOT_FOR_MI200_AND_ABOVE_TEST hipMallocArray.cc hipArrayCreate.cc) # tests not for MI200+
|
||||
set(MI200_AND_ABOVE_TARGETS gfx90a gfx940 gfx941 gfx942)
|
||||
function(CheckRejectedArchs OFFLOAD_ARCH_STR_LOCAL)
|
||||
set(ARCH_CHECK -1 PARENT_SCOPE)
|
||||
string(REGEX MATCHALL "--offload-arch=gfx[0-9a-z]+" OFFLOAD_ARCH_LIST ${OFFLOAD_ARCH_STR_LOCAL})
|
||||
foreach(OFFLOAD_ARCH IN LISTS OFFLOAD_ARCH_LIST)
|
||||
string(REGEX MATCHALL "--offload-arch=(gfx[0-9a-z]+)" matches ${OFFLOAD_ARCH})
|
||||
if (CMAKE_MATCH_COUNT EQUAL 1)
|
||||
if (CMAKE_MATCH_1 IN_LIST MI200_AND_ABOVE_TARGETS)
|
||||
set(ARCH_CHECK 1 PARENT_SCOPE)
|
||||
endif() # CMAKE_MATCH_1
|
||||
endif() # CMAKE_MATCH_COUNT
|
||||
endforeach() # OFFLOAD_ARCH_LIST
|
||||
endfunction() # CheckAcceptedArchs
|
||||
|
||||
if(HIP_PLATFORM MATCHES "amd")
|
||||
if (DEFINED OFFLOAD_ARCH_STR)
|
||||
CheckRejectedArchs(${OFFLOAD_ARCH_STR})
|
||||
elseif(DEFINED $ENV{HCC_AMDGPU_TARGET})
|
||||
CheckRejectedArchs($ENV{HCC_AMDGPU_TARGET})
|
||||
else()
|
||||
set(ARCH_CHECK -1)
|
||||
endif()
|
||||
if(${ARCH_CHECK} EQUAL -1)
|
||||
message(STATUS "Adding test: ${NOT_FOR_MI200_AND_ABOVE_TEST}")
|
||||
set(TEST_SRC ${TEST_SRC} ${NOT_FOR_MI200_AND_ABOVE_TEST})
|
||||
endif()
|
||||
else()
|
||||
set(TEST_SRC ${TEST_SRC} ${NOT_FOR_MI200_AND_ABOVE_TEST})
|
||||
endif()
|
||||
|
||||
hip_add_exe_to_target(NAME MemoryTest2
|
||||
TEST_SRC ${TEST_SRC}
|
||||
TEST_TARGET_NAME build_tests COMMON_SHARED_SRC ${COMMON_SHARED_SRC})
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup hipArray3DGetDescriptor hipArray3DGetDescriptor
|
||||
* @{
|
||||
* @ingroup MemoryTest
|
||||
* `hipArray3DGetDescriptor(HIP_ARRAY3D_DESCRIPTOR* pArrayDescriptor, hipArray* array)` -
|
||||
* Gets a 3D array descriptor.
|
||||
*/
|
||||
|
||||
#include <hip_test_common.hh>
|
||||
#include <resource_guards.hh>
|
||||
|
||||
/**
|
||||
* Test Description
|
||||
* ------------------------
|
||||
* - Basic sanity test for `hipArray3DGetDescriptor`.
|
||||
* Test source
|
||||
* ------------------------
|
||||
* - unit/memory/hipArray3DGetDescriptor.cc
|
||||
* Test requirements
|
||||
* ------------------------
|
||||
* - HIP_VERSION >= 5.7
|
||||
*/
|
||||
TEST_CASE("Unit_hipArray3DGetDescriptor_Positive_Basic") {
|
||||
DrvArrayAllocGuard<float> array(make_hipExtent(1024, 4, 2));
|
||||
|
||||
HIP_ARRAY3D_DESCRIPTOR desc;
|
||||
HIP_CHECK(hipArray3DGetDescriptor(&desc, array.ptr()));
|
||||
|
||||
using vec_info = vector_info<float>;
|
||||
REQUIRE(desc.Format == vec_info::format);
|
||||
REQUIRE(desc.NumChannels == vec_info::size);
|
||||
REQUIRE(desc.Width == 1024 / sizeof(float));
|
||||
REQUIRE(desc.Height == 4);
|
||||
REQUIRE(desc.Depth == 2);
|
||||
REQUIRE(desc.Flags == 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Description
|
||||
* ------------------------
|
||||
* - Negative parameters test for `hipArray3DGetDescriptor`.
|
||||
* Test source
|
||||
* ------------------------
|
||||
* - unit/memory/hipArray3DGetDescriptor.cc
|
||||
* Test requirements
|
||||
* ------------------------
|
||||
* - HIP_VERSION >= 5.7
|
||||
*/
|
||||
TEST_CASE("Unit_hipArray3DGetDescriptor_Negative_Parameters") {
|
||||
DrvArrayAllocGuard<float> array(make_hipExtent(1024, 4, 2));
|
||||
|
||||
HIP_ARRAY3D_DESCRIPTOR desc;
|
||||
|
||||
SECTION("desc is nullptr") {
|
||||
HIP_CHECK_ERROR(hipArray3DGetDescriptor(nullptr, array.ptr()), hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
SECTION("array is nullptr") {
|
||||
HIP_CHECK_ERROR(hipArray3DGetDescriptor(&desc, nullptr), hipErrorInvalidHandle);
|
||||
}
|
||||
|
||||
SECTION("array is freed") {
|
||||
HIP_CHECK(hipArrayDestroy(array.ptr()));
|
||||
HIP_CHECK_ERROR(hipArray3DGetDescriptor(&desc, array.ptr()), hipErrorInvalidHandle);
|
||||
}
|
||||
}
|
||||
@@ -16,12 +16,16 @@ 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 <hip_test_common.hh>
|
||||
#include <hip_test_defgroups.hh>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
|
||||
#include <hip_test_common.hh>
|
||||
#include <hip_test_defgroups.hh>
|
||||
#include <resource_guards.hh>
|
||||
|
||||
static bool testPassed1D = false;
|
||||
static bool testPassed2D = false;
|
||||
static constexpr auto NUM_ELM{1024};
|
||||
@@ -459,3 +463,83 @@ TEST_CASE("Unit_hipArrayGetDescriptor_Negative_Scenarios") {
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @addtogroup hipArrayGetDescriptor hipArrayGetDescriptor
|
||||
* @{
|
||||
* @ingroup MemoryTest
|
||||
* `hipArrayGetDescriptor(HIP_ARRAY_DESCRIPTOR* pArrayDescriptor, hipArray* array)` -
|
||||
* Gets a 1D or 2D array descriptor.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Test Description
|
||||
* ------------------------
|
||||
* - Basic sanity test for `hipArrayGetDescriptor`.
|
||||
* Test source
|
||||
* ------------------------
|
||||
* - unit/memory/hipArrayGetDescriptor.cc
|
||||
* Test requirements
|
||||
* ------------------------
|
||||
* - HIP_VERSION >= 5.7
|
||||
*/
|
||||
TEST_CASE("Unit_hipArrayGetDescriptor_Positive_Basic") {
|
||||
HIP_ARRAY_DESCRIPTOR expected_desc{};
|
||||
using vec_info = vector_info<float>;
|
||||
expected_desc.Format = vec_info::format;
|
||||
expected_desc.NumChannels = vec_info::size;
|
||||
expected_desc.Width = 1024 / sizeof(float);
|
||||
expected_desc.Height = 4;
|
||||
|
||||
hipArray_t ptr;
|
||||
HIP_CHECK(hipArrayCreate(&ptr, &expected_desc));
|
||||
|
||||
HIP_ARRAY_DESCRIPTOR desc;
|
||||
HIP_CHECK(hipArrayGetDescriptor(&desc, ptr));
|
||||
|
||||
REQUIRE(desc.Format == expected_desc.Format);
|
||||
REQUIRE(desc.NumChannels == expected_desc.NumChannels);
|
||||
REQUIRE(desc.Width == expected_desc.Width);
|
||||
REQUIRE(desc.Height == expected_desc.Height);
|
||||
|
||||
HIP_CHECK(hipArrayDestroy(ptr));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Description
|
||||
* ------------------------
|
||||
* - Negative parameters test for `hipArrayGetDescriptor`.
|
||||
* Test source
|
||||
* ------------------------
|
||||
* - unit/memory/hipArrayGetDescriptor.cc
|
||||
* Test requirements
|
||||
* ------------------------
|
||||
* - HIP_VERSION >= 5.7
|
||||
*/
|
||||
TEST_CASE("Unit_hipArrayGetDescriptor_Negative_Parameters") {
|
||||
HIP_ARRAY_DESCRIPTOR expected_desc{};
|
||||
using vec_info = vector_info<float>;
|
||||
expected_desc.Format = vec_info::format;
|
||||
expected_desc.NumChannels = vec_info::size;
|
||||
expected_desc.Width = 1024 / sizeof(float);
|
||||
expected_desc.Height = 4;
|
||||
|
||||
hipArray_t ptr;
|
||||
HIP_CHECK(hipArrayCreate(&ptr, &expected_desc));
|
||||
|
||||
HIP_ARRAY_DESCRIPTOR desc;
|
||||
|
||||
SECTION("desc is nullptr") {
|
||||
HIP_CHECK_ERROR(hipArrayGetDescriptor(nullptr, ptr), hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
SECTION("array is nullptr") {
|
||||
HIP_CHECK_ERROR(hipArrayGetDescriptor(&desc, nullptr), hipErrorInvalidHandle);
|
||||
}
|
||||
|
||||
SECTION("array is freed") {
|
||||
HIP_CHECK(hipArrayDestroy(ptr));
|
||||
HIP_CHECK_ERROR(hipArrayGetDescriptor(&desc, ptr), hipErrorInvalidHandle);
|
||||
}
|
||||
|
||||
static_cast<void>(hipArrayDestroy(ptr));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup hipArrayGetInfo hipArrayGetInfo
|
||||
* @{
|
||||
* @ingroup MemoryTest
|
||||
* `hipArrayGetInfo(hipChannelFormatDesc* desc, hipExtent* extent, unsigned int* flags, hipArray*
|
||||
* array)` - Gets info about the specified array.
|
||||
*/
|
||||
|
||||
#include <hip_test_common.hh>
|
||||
#include <resource_guards.hh>
|
||||
|
||||
/**
|
||||
* Test Description
|
||||
* ------------------------
|
||||
* - Basic sanity test for `hipArrayGetInfo`.
|
||||
* Test source
|
||||
* ------------------------
|
||||
* - unit/memory/hipArrayGetInfo.cc
|
||||
* Test requirements
|
||||
* ------------------------
|
||||
* - HIP_VERSION >= 5.7
|
||||
*/
|
||||
TEST_CASE("Unit_hipArrayGetInfo_Positive_Basic") {
|
||||
ArrayAllocGuard<float> array(make_hipExtent(1024, 4, 2));
|
||||
|
||||
hipChannelFormatDesc desc;
|
||||
hipExtent extent;
|
||||
unsigned int flags = 1;
|
||||
|
||||
HIP_CHECK(hipArrayGetInfo(&desc, &extent, &flags, array.ptr()));
|
||||
|
||||
REQUIRE(extent.width == 1024);
|
||||
REQUIRE(extent.height == 4);
|
||||
REQUIRE(extent.depth == 2);
|
||||
|
||||
REQUIRE(flags == 0);
|
||||
|
||||
auto expected_desc = hipCreateChannelDesc<float>();
|
||||
REQUIRE(desc.x == expected_desc.x);
|
||||
REQUIRE(desc.y == expected_desc.y);
|
||||
REQUIRE(desc.z == expected_desc.z);
|
||||
REQUIRE(desc.w == expected_desc.w);
|
||||
REQUIRE(desc.f == expected_desc.f);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Description
|
||||
* ------------------------
|
||||
* - Negative parameters test for `hipArrayGetInfo`.
|
||||
* Test source
|
||||
* ------------------------
|
||||
* - unit/memory/hipArrayGetInfo.cc
|
||||
* Test requirements
|
||||
* ------------------------
|
||||
* - HIP_VERSION >= 5.7
|
||||
*/
|
||||
TEST_CASE("Unit_hipArrayGetInfo_Negative_Parameters") {
|
||||
ArrayAllocGuard<float> array(make_hipExtent(1024, 4, 4));
|
||||
|
||||
hipChannelFormatDesc desc;
|
||||
hipExtent extent;
|
||||
unsigned int flags;
|
||||
|
||||
SECTION("array is nullptr") {
|
||||
HIP_CHECK_ERROR(hipArrayGetInfo(&desc, &extent, &flags, nullptr), hipErrorInvalidHandle);
|
||||
}
|
||||
|
||||
SECTION("array is freed") {
|
||||
HIP_CHECK(hipFreeArray(array.ptr()));
|
||||
HIP_CHECK_ERROR(hipArrayGetInfo(&desc, &extent, &flags, array.ptr()), hipErrorInvalidHandle);
|
||||
}
|
||||
}
|
||||
Ссылка в новой задаче
Block a user