diff --git a/conformance_tests/core/test_copy/src/test_copy.cpp b/conformance_tests/core/test_copy/src/test_copy.cpp index ff97f490..cf158816 100644 --- a/conformance_tests/core/test_copy/src/test_copy.cpp +++ b/conformance_tests/core/test_copy/src/test_copy.cpp @@ -2572,12 +2572,21 @@ LZT_TEST_P( auto context = lzt::get_default_context(); const size_t size = 16; + std::vector device_svm; + uint32_t svm_count = 0; for (auto driver : lzt::get_all_driver_handles()) { for (auto device : lzt::get_devices(driver)) { - if (!lzt::supports_shared_system_alloc(device)) { - LOG_WARNING << "Device does not support shared system allocation"; - continue; + if (lzt::supports_shared_system_alloc(device)) { + device_svm.push_back(device); + svm_count++; } + } + } + + if (!svm_count) { + GTEST_SKIP() << "No devices on any driver support shared system allocation"; + } else { + for (auto device : device_svm) { int *src_memory = nullptr; int *dst_memory = nullptr; @@ -2677,6 +2686,89 @@ void free_aligned(void *ptr) { #endif } +class zeCommandListAppendMemoryCopySharedSystemUsmHostUserPtr + : public ::testing::Test, + public ::testing::WithParamInterface> { +public: + void launchHostUsrPtrAppendMemCopy(ze_device_handle_t device, + char *src_memory, char *dst_memory, + size_t size, bool is_immediate) { + + auto cmd_bundle = lzt::create_command_bundle(device, is_immediate); + const int8_t src_pattern = 0x55; + const int8_t dst_pattern = 0; + + char *expected_data = static_cast(lzt::allocate_host_memory(size)); + char *verify_data = static_cast(lzt::allocate_host_memory(size)); + + memset(expected_data, src_pattern, size); + memset(verify_data, dst_pattern, size); + + EXPECT_NE(expected_data, nullptr); + EXPECT_NE(verify_data, nullptr); + + memset(src_memory, src_pattern, size); + memset(dst_memory, dst_pattern, size); + + lzt::append_memory_copy(cmd_bundle.list, static_cast(dst_memory), + static_cast(src_memory), size); + + lzt::append_barrier(cmd_bundle.list, nullptr, 0, nullptr); + lzt::append_memory_copy(cmd_bundle.list, verify_data, + static_cast(dst_memory), size); + lzt::append_barrier(cmd_bundle.list, nullptr, 0, nullptr); + lzt::close_command_list(cmd_bundle.list); + lzt::execute_and_sync_command_bundle(cmd_bundle, UINT64_MAX); + + EXPECT_EQ(0, memcmp(expected_data, verify_data, size)); + + lzt::destroy_command_bundle(cmd_bundle); + lzt::free_memory(expected_data); + lzt::free_memory(verify_data); + } +}; + +LZT_TEST_P( + zeCommandListAppendMemoryCopySharedSystemUsmHostUserPtr, + GivenSourceAndDestinationSharedSystemUsmWhenAppendingMemoryCopyThenSuccessIsReturnedAndCopyIsCorrect) { + size_t size = std::get<0>(GetParam()); + bool is_immediate = std::get<1>(GetParam()); + + auto context = lzt::get_default_context(); + + for (auto driver : lzt::get_all_driver_handles()) { + for (auto device : lzt::get_devices(driver)) { + + char *src_memory = nullptr; + char *dst_memory = nullptr; + + src_memory = static_cast( + lzt::allocate_device_memory_with_allocator_selector(size, true)); + dst_memory = static_cast( + lzt::allocate_device_memory_with_allocator_selector(size, true)); + + EXPECT_NE(src_memory, nullptr); + EXPECT_NE(dst_memory, nullptr); + + launchHostUsrPtrAppendMemCopy(device, src_memory, dst_memory, size, + is_immediate); + + if (dst_memory) { + lzt::free_memory_with_allocator_selector(dst_memory, true); + } + if (src_memory) { + lzt::free_memory_with_allocator_selector(src_memory, true); + } + } + } +} + +INSTANTIATE_TEST_SUITE_P( + ParamAppendMemCopyHostUserPtr, + zeCommandListAppendMemoryCopySharedSystemUsmHostUserPtr, + ::testing::Combine(::testing::Values(1, 16, 128, 4096, 65536), + ::testing::Bool())); + class zeSharedSystemMemoryCopyTests : public ::testing::Test, public ::testing::WithParamInterface<