SWDEV-491279 - add stream capture test for ExternalMemory APIs (#570)
Co-authored-by: Li, Todd tiantuo <Toddtiantuo.Li@amd.com>
This commit is contained in:
committed by
GitHub
parent
e7a26594b7
commit
ffb380a710
@@ -45,3 +45,31 @@ TEST_CASE("Unit_hipDestroyExternalMemory_Vulkan_Negative_Parameters") {
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Description
|
||||
* ------------------------
|
||||
* - Test hipDestroyExternalMemory while stream is capturing.
|
||||
* Test source
|
||||
* ------------------------
|
||||
* - unit/vulkan_interop/hipDestroyExternalMemory.cc
|
||||
* Test requirements
|
||||
* ------------------------
|
||||
* - HIP_VERSION >= 6.0
|
||||
*/
|
||||
TEST_CASE("Unit_hipDestroyExternalMemory_Vulkan_Capture") {
|
||||
// Segfaults in CUDA
|
||||
// Disabled on AMD due to defect - EXSWHTEC-187
|
||||
#if HT_AMD && 0
|
||||
VulkanTest vkt(enable_validation);
|
||||
const auto storage = vkt.CreateMappedStorage<int>(1, VK_BUFFER_USAGE_TRANSFER_DST_BIT, true);
|
||||
auto desc = vkt.BuildMemoryDescriptor(storage.memory, sizeof(*storage.host_ptr));
|
||||
hipExternalMemory_t ext_memory;
|
||||
HIP_CHECK(hipImportExternalMemory(&ext_memory, &desc));
|
||||
|
||||
hipError_t memcpy_err = hipSuccess;
|
||||
BEGIN_CAPTURE_SYNC(memcpy_err, true);
|
||||
HIP_CHECK_ERROR(hipDestroyExternalMemory(ext_memory), memcpy_err);
|
||||
END_CAPTURE_SYNC(memcpy_err);
|
||||
#endif
|
||||
}
|
||||
@@ -157,3 +157,41 @@ TEST_CASE("Unit_hipExternalMemoryGetMappedBuffer_Vulkan_Negative_Parameters") {
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Description
|
||||
* ------------------------
|
||||
* - Test hipExternalMemoryGetMappedBuffer while stream is capturing.
|
||||
* Test source
|
||||
* ------------------------
|
||||
* - unit/vulkan_interop/hipExternalMemoryGetMappedBuffer.cc
|
||||
* Test requirements
|
||||
* ------------------------
|
||||
* - HIP_VERSION >= 6.0
|
||||
*/
|
||||
TEST_CASE("Unit_hipExternalMemoryGetMappedBuffer_Vulkan_Capture") {
|
||||
VulkanTest vkt(enable_validation);
|
||||
using type = uint8_t;
|
||||
constexpr uint32_t count = 3;
|
||||
|
||||
const auto vk_storage =
|
||||
vkt.CreateMappedStorage<type>(count, VK_BUFFER_USAGE_TRANSFER_DST_BIT, true);
|
||||
if (vk_storage.memory == nullptr) {
|
||||
return;
|
||||
}
|
||||
const auto hip_ext_mem_desc = vkt.BuildMemoryDescriptor(vk_storage.memory, vk_storage.size);
|
||||
hipExternalMemory_t hip_ext_memory;
|
||||
HIP_CHECK(hipImportExternalMemory(&hip_ext_memory, &hip_ext_mem_desc));
|
||||
|
||||
hipExternalMemoryBufferDesc external_mem_buffer_desc = {};
|
||||
external_mem_buffer_desc.size = vk_storage.size;
|
||||
type* hip_dev_ptr = nullptr;
|
||||
|
||||
hipError_t memcpy_err = hipSuccess;
|
||||
BEGIN_CAPTURE_SYNC(memcpy_err, true);
|
||||
HIP_CHECK_ERROR(hipExternalMemoryGetMappedBuffer(reinterpret_cast<void**>(&hip_dev_ptr),
|
||||
hip_ext_memory, &external_mem_buffer_desc),
|
||||
memcpy_err);
|
||||
END_CAPTURE_SYNC(memcpy_err);
|
||||
REQUIRE(nullptr != hip_dev_ptr);
|
||||
}
|
||||
+52
@@ -212,3 +212,55 @@ TEST_CASE("Unit_hipExternalMemoryGetMappedMipmappedArray_Vulkan_Negative_Paramet
|
||||
|
||||
HIP_CHECK(hipDestroyExternalMemory(ext_memory));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Description
|
||||
* ------------------------
|
||||
* - Test hipExternalMemoryGetMappedMipmappedArray while stream is capturing.
|
||||
* Test source
|
||||
* ------------------------
|
||||
* - unit/vulkan_interop/hipExternalMemoryGetMappedMipmappedArray.cc
|
||||
* Test requirements
|
||||
* ------------------------
|
||||
* - HIP_VERSION >= 6.0
|
||||
*/
|
||||
TEST_CASE("Unit_hipExternalMemoryGetMappedMipmappedArray_Vulkan_Capture") {
|
||||
VulkanTest vkt(enable_validation);
|
||||
using type = uint8_t;
|
||||
// cubemap HIP array is allocated if all three extents are non-zero and the hipArrayCubemap
|
||||
// flag is set. Width must be equal to height, and depth must be six
|
||||
constexpr uint32_t cube_size = 32;
|
||||
constexpr uint32_t depth = 6;
|
||||
constexpr uint32_t ext_mem_size = cube_size * cube_size * depth;
|
||||
|
||||
const auto vk_storage =
|
||||
vkt.CreateMappedStorage<type>(ext_mem_size, VK_BUFFER_USAGE_TRANSFER_DST_BIT, true);
|
||||
if (vk_storage.memory == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto ext_mem_desc = vkt.BuildMemoryDescriptor(vk_storage.memory, vk_storage.size);
|
||||
hipExternalMemory_t ext_memory;
|
||||
HIP_CHECK(hipImportExternalMemory(&ext_memory, &ext_mem_desc));
|
||||
|
||||
hipExternalMemoryMipmappedArrayDesc mipmapped_arr_desc = {};
|
||||
mipmapped_arr_desc.extent = {};
|
||||
mipmapped_arr_desc.extent.width = cube_size;
|
||||
mipmapped_arr_desc.extent.height = cube_size;
|
||||
mipmapped_arr_desc.extent.depth = depth;
|
||||
mipmapped_arr_desc.flags = hipArrayCubemap;
|
||||
mipmapped_arr_desc.formatDesc = hipCreateChannelDesc<type>();
|
||||
mipmapped_arr_desc.numLevels = GENERATE(1, 2, 4);
|
||||
mipmapped_arr_desc.offset = 0;
|
||||
hipMipmappedArray_t mipmapped_arr = nullptr;
|
||||
|
||||
hipError_t memcpy_err = hipSuccess;
|
||||
BEGIN_CAPTURE_SYNC(memcpy_err, true);
|
||||
HIP_CHECK_ERROR(
|
||||
hipExternalMemoryGetMappedMipmappedArray(&mipmapped_arr, ext_memory, &mipmapped_arr_desc),
|
||||
memcpy_err);
|
||||
END_CAPTURE_SYNC(memcpy_err);
|
||||
|
||||
HIP_CHECK(hipFreeMipmappedArray(mipmapped_arr));
|
||||
HIP_CHECK(hipDestroyExternalMemory(ext_memory));
|
||||
}
|
||||
@@ -78,3 +78,35 @@ TEST_CASE("Unit_hipImportExternalMemory_Vulkan_Negative_Parameters") {
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Description
|
||||
* ------------------------
|
||||
* - Test hipImportExternalMemory while stream is capturing.
|
||||
* Test source
|
||||
* ------------------------
|
||||
* - unit/vulkan_interop/hipImportExternalMemory.cc
|
||||
* Test requirements
|
||||
* ------------------------
|
||||
* - HIP_VERSION >= 6.0
|
||||
*/
|
||||
TEST_CASE("Unit_hipImportExternalMemory_Vulkan_Capture") {
|
||||
VulkanTest vkt(enable_validation);
|
||||
using type = uint8_t;
|
||||
constexpr uint32_t count = 2;
|
||||
|
||||
const auto vk_storage =
|
||||
vkt.CreateMappedStorage<type>(count, VK_BUFFER_USAGE_TRANSFER_DST_BIT, true);
|
||||
if (vk_storage.memory == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto hip_ext_mem_desc = vkt.BuildMemoryDescriptor(vk_storage.memory, vk_storage.size);
|
||||
hipExternalMemory_t hip_ext_memory;
|
||||
|
||||
hipError_t memcpy_err = hipSuccess;
|
||||
BEGIN_CAPTURE_SYNC(memcpy_err, true);
|
||||
HIP_CHECK_ERROR(hipImportExternalMemory(&hip_ext_memory, &hip_ext_mem_desc),
|
||||
memcpy_err);
|
||||
END_CAPTURE_SYNC(memcpy_err);
|
||||
}
|
||||
Reference in New Issue
Block a user