@@ -2572,12 +2572,21 @@ LZT_TEST_P(
25722572 auto context = lzt::get_default_context ();
25732573 const size_t size = 16 ;
25742574
2575+ std::vector<ze_device_handle_t > device_svm;
2576+ uint32_t svm_count = 0 ;
25752577 for (auto driver : lzt::get_all_driver_handles ()) {
25762578 for (auto device : lzt::get_devices (driver)) {
2577- if (! lzt::supports_shared_system_alloc (device)) {
2578- LOG_WARNING << " Device does not support shared system allocation " ;
2579- continue ;
2579+ if (lzt::supports_shared_system_alloc (device)) {
2580+ device_svm. push_back (device) ;
2581+ svm_count++ ;
25802582 }
2583+ }
2584+ }
2585+
2586+ if (!svm_count) {
2587+ GTEST_SKIP () << " No devices on any driver support shared system allocation" ;
2588+ } else {
2589+ for (auto device : device_svm) {
25812590 int *src_memory = nullptr ;
25822591 int *dst_memory = nullptr ;
25832592
@@ -2677,6 +2686,89 @@ void free_aligned(void *ptr) {
26772686#endif
26782687}
26792688
2689+ class zeCommandListAppendMemoryCopySharedSystemUsmHostUserPtr
2690+ : public ::testing::Test,
2691+ public ::testing::WithParamInterface<std::tuple<size_t , bool >> {
2692+ public:
2693+ void launchHostUsrPtrAppendMemCopy (ze_device_handle_t device,
2694+ char *src_memory, char *dst_memory,
2695+ size_t size, bool is_immediate) {
2696+
2697+ auto cmd_bundle = lzt::create_command_bundle (device, is_immediate);
2698+ const int8_t src_pattern = 0x55 ;
2699+ const int8_t dst_pattern = 0 ;
2700+
2701+ char *expected_data = static_cast <char *>(lzt::allocate_host_memory (size));
2702+ char *verify_data = static_cast <char *>(lzt::allocate_host_memory (size));
2703+
2704+ memset (expected_data, src_pattern, size);
2705+ memset (verify_data, dst_pattern, size);
2706+
2707+ EXPECT_NE (expected_data, nullptr );
2708+ EXPECT_NE (verify_data, nullptr );
2709+
2710+ memset (src_memory, src_pattern, size);
2711+ memset (dst_memory, dst_pattern, size);
2712+
2713+ lzt::append_memory_copy (cmd_bundle.list , static_cast <void *>(dst_memory),
2714+ static_cast <void *>(src_memory), size);
2715+
2716+ lzt::append_barrier (cmd_bundle.list , nullptr , 0 , nullptr );
2717+ lzt::append_memory_copy (cmd_bundle.list , verify_data,
2718+ static_cast <void *>(dst_memory), size);
2719+ lzt::append_barrier (cmd_bundle.list , nullptr , 0 , nullptr );
2720+ lzt::close_command_list (cmd_bundle.list );
2721+ lzt::execute_and_sync_command_bundle (cmd_bundle, UINT64_MAX);
2722+
2723+ EXPECT_EQ (0 , memcmp (expected_data, verify_data, size));
2724+
2725+ lzt::destroy_command_bundle (cmd_bundle);
2726+ lzt::free_memory (expected_data);
2727+ lzt::free_memory (verify_data);
2728+ }
2729+ };
2730+
2731+ LZT_TEST_P (
2732+ zeCommandListAppendMemoryCopySharedSystemUsmHostUserPtr,
2733+ GivenSourceAndDestinationSharedSystemUsmWhenAppendingMemoryCopyThenSuccessIsReturnedAndCopyIsCorrect) {
2734+ size_t size = std::get<0 >(GetParam ());
2735+ bool is_immediate = std::get<1 >(GetParam ());
2736+
2737+ auto context = lzt::get_default_context ();
2738+
2739+ for (auto driver : lzt::get_all_driver_handles ()) {
2740+ for (auto device : lzt::get_devices (driver)) {
2741+
2742+ char *src_memory = nullptr ;
2743+ char *dst_memory = nullptr ;
2744+
2745+ src_memory = static_cast <char *>(
2746+ lzt::allocate_device_memory_with_allocator_selector (size, true ));
2747+ dst_memory = static_cast <char *>(
2748+ lzt::allocate_device_memory_with_allocator_selector (size, true ));
2749+
2750+ EXPECT_NE (src_memory, nullptr );
2751+ EXPECT_NE (dst_memory, nullptr );
2752+
2753+ launchHostUsrPtrAppendMemCopy (device, src_memory, dst_memory, size,
2754+ is_immediate);
2755+
2756+ if (dst_memory) {
2757+ lzt::free_memory_with_allocator_selector (dst_memory, true );
2758+ }
2759+ if (src_memory) {
2760+ lzt::free_memory_with_allocator_selector (src_memory, true );
2761+ }
2762+ }
2763+ }
2764+ }
2765+
2766+ INSTANTIATE_TEST_SUITE_P (
2767+ ParamAppendMemCopyHostUserPtr,
2768+ zeCommandListAppendMemoryCopySharedSystemUsmHostUserPtr,
2769+ ::testing::Combine (::testing::Values(1 , 16 , 128 , 4096 , 65536 ),
2770+ ::testing::Bool()));
2771+
26802772class zeSharedSystemMemoryCopyTests
26812773 : public ::testing::Test,
26822774 public ::testing::WithParamInterface<
0 commit comments