SWDEV-1 - Merge github PRs to amd-staging

Change-Id: I2944a63ddc2eec8dc1403d9790ffffbaec343385
Этот коммит содержится в:
Rakesh Roy
2024-03-04 11:51:34 +05:30
родитель 010f4bb0b0 147601aff2
Коммит 57bc68acb1
366 изменённых файлов: 55399 добавлений и 2073 удалений
+17 -4
Просмотреть файл
@@ -93,7 +93,13 @@ if(HIP_PLATFORM MATCHES "amd")
hipMemAddressFree.cc
hipMemAddressReserve.cc
hipMemRelease.cc
hipMemGetAllocationPropertiesFromHandle.cc)
hipMemGetAllocationPropertiesFromHandle.cc
hipArray.cc)
if(UNIX)
# Should be compiled for NVIDIA as well after EXSWHTEC-346 is addressed
# For windows build error occurs undefined symbol: hipPointerSetAttribute
set(TEST_SRC ${TEST_SRC} hipPointerSetAttribute.cc)
endif()
else()
set(TEST_SRC ${TEST_SRC} hipGetSymbolSizeAddress.cc)
endif()
@@ -161,10 +167,18 @@ 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)
@@ -179,7 +193,6 @@ function(CheckRejectedArchs OFFLOAD_ARCH_STR_LOCAL)
endif() # CMAKE_MATCH_COUNT
endforeach() # OFFLOAD_ARCH_LIST
endfunction() # CheckAcceptedArchs
if(HIP_PLATFORM MATCHES "amd")
if (DEFINED OFFLOAD_ARCH_STR)
CheckRejectedArchs(${OFFLOAD_ARCH_STR})
@@ -213,4 +226,4 @@ if(HIP_PLATFORM MATCHES "amd")
TEST_TARGET_NAME build_tests COMMON_SHARED_SRC ${COMMON_SHARED_SRC})
add_dependencies(build_tests hipHostRegisterPerf)
endif()
endif()
+88
Просмотреть файл
@@ -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);
}
}
+86 -2
Просмотреть файл
@@ -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));
}
+94
Просмотреть файл
@@ -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);
}
}
+1 -1
Просмотреть файл
@@ -32,7 +32,7 @@ THE SOFTWARE.
#include <hip_test_common.hh>
#include <hip_test_helper.hh>
#include <hip_test_process.hh>
#include <hip_test_defgroups.hh>
#include <utils.hh>
#define OFFSET 128
-26
Просмотреть файл
@@ -1,26 +0,0 @@
#include <hip_test_common.hh>
static int HmmAttrPrint() {
int managed = 0;
INFO(
"The following are the attribute values related to HMM for"
" device 0:\n");
HIP_CHECK(hipDeviceGetAttribute(&managed, hipDeviceAttributeDirectManagedMemAccessFromHost, 0));
INFO("hipDeviceAttributeDirectManagedMemAccessFromHost: " << managed);
HIP_CHECK(hipDeviceGetAttribute(&managed, hipDeviceAttributeConcurrentManagedAccess, 0));
INFO("hipDeviceAttributeConcurrentManagedAccess: " << managed);
HIP_CHECK(hipDeviceGetAttribute(&managed, hipDeviceAttributePageableMemoryAccess, 0));
INFO("hipDeviceAttributePageableMemoryAccess: " << managed);
HIP_CHECK(
hipDeviceGetAttribute(&managed, hipDeviceAttributePageableMemoryAccessUsesHostPageTables, 0));
INFO("hipDeviceAttributePageableMemoryAccessUsesHostPageTables:" << managed);
HIP_CHECK(hipDeviceGetAttribute(&managed, hipDeviceAttributeManagedMemory, 0));
INFO("hipDeviceAttributeManagedMemory: " << managed);
if (managed != 1) {
WARN(
"GPU 0 doesn't support hipDeviceAttributeManagedMemory attribute so defaulting to system "
"memory.");
}
return managed;
}
+1 -1
Просмотреть файл
@@ -30,7 +30,7 @@ Following scenarios are verified for hipPointerGetAttributes API
*/
#include <inttypes.h>
#include <hip_test_common.hh>
#include <hip_test_defgroups.hh>
#ifdef __linux__
#include <sys/mman.h>
#endif
+108
Просмотреть файл
@@ -0,0 +1,108 @@
/*
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 hipPointerSetAttribute hipPointerSetAttribute
* @{
* @ingroup MemoryTest
* `hipPointerSetAttribute(const void* value, hipPointer_attribute attribute, hipDeviceptr_t ptr)` -
* Set attributes on a previously allocated memory region.
*/
#include <hip_test_common.hh>
#include <resource_guards.hh>
#include <utils.hh>
/**
* Test Description
* ------------------------
* - Sets pointer attribute `HIP_POINTER_ATTRIBUTE_SYNC_MEMOPS` and verifies behavior.
* Test source
* ------------------------
* - unit/memory/hipPointerSetAttribute.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.5
*/
TEST_CASE("Unit_hipPointerSetAttribute_Positive_SyncMemops") {
LinearAllocGuard<int> src(LinearAllocs::hipMalloc, 1024);
LinearAllocGuard<int> dst(LinearAllocs::hipMalloc, 1024);
StreamGuard stream(Streams::created);
LaunchDelayKernel(std::chrono::milliseconds{100}, stream.stream());
HIP_CHECK(hipMemcpy(dst.ptr(), src.ptr(), 1024, hipMemcpyDeviceToDevice));
HIP_CHECK_ERROR(hipStreamQuery(stream.stream()), hipErrorNotReady);
bool value = true;
HIP_CHECK(hipPointerSetAttribute(&value, HIP_POINTER_ATTRIBUTE_SYNC_MEMOPS,
reinterpret_cast<hipDeviceptr_t>(src.ptr())));
HIP_CHECK(hipPointerSetAttribute(&value, HIP_POINTER_ATTRIBUTE_SYNC_MEMOPS,
reinterpret_cast<hipDeviceptr_t>(dst.ptr())));
LaunchDelayKernel(std::chrono::milliseconds{100}, stream.stream());
HIP_CHECK(hipMemcpy(dst.ptr(), src.ptr(), 1024, hipMemcpyDeviceToDevice));
HIP_CHECK(hipStreamQuery(stream.stream()));
}
/**
* Test Description
* ------------------------
* - Negative parameters test for `hipPointerSetAttribute`.
* Test source
* ------------------------
* - unit/memory/hipPointerSetAttribute.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.5
*/
TEST_CASE("Unit_hipPointerSetAttribute_Negative_Parameters") {
LinearAllocGuard<int> mem(LinearAllocs::hipMalloc, 4);
bool value = false;
SECTION("value is nullptr") {
HIP_CHECK_ERROR(hipPointerSetAttribute(nullptr, HIP_POINTER_ATTRIBUTE_SYNC_MEMOPS, mem.ptr()),
hipErrorInvalidValue);
}
SECTION("invalid attribute") {
HIP_CHECK_ERROR(
hipPointerSetAttribute(&value, static_cast<hipPointer_attribute>(-1), mem.ptr()),
hipErrorInvalidValue);
}
SECTION("ptr is nullptr") {
HIP_CHECK_ERROR(hipPointerSetAttribute(&value, HIP_POINTER_ATTRIBUTE_SYNC_MEMOPS, nullptr),
hipErrorInvalidValue);
}
SECTION("host pointer") {
int mem_host;
HIP_CHECK_ERROR(hipPointerSetAttribute(&value, HIP_POINTER_ATTRIBUTE_SYNC_MEMOPS, &mem_host),
hipErrorInvalidDevicePointer);
}
SECTION("freed pointer") {
HIP_CHECK(hipFree(mem.ptr()));
HIP_CHECK_ERROR(hipPointerSetAttribute(&value, HIP_POINTER_ATTRIBUTE_SYNC_MEMOPS, mem.ptr()),
hipErrorInvalidDevicePointer);
}
}