From 704ffd012e9a8891b7f7579fdff46e815b5e3ebc Mon Sep 17 00:00:00 2001 From: John Kesapides <46718829+JohnKesapidesARM@users.noreply.github.com> Date: Mon, 15 Sep 2025 18:08:56 +0100 Subject: [PATCH] Unified SVM Memcpy and check_for_common_memory_type (#2524) * Refactor check_for_common_memory_type to only check for device access. * rename check_for_common_memory_type to caps_compatibility_check * Update test_unified_svm_mem_cpy and test_unified_svm_mem_fill. fixes #2517 Signed-off-by: John Kesapides --- .../SVM/test_unified_svm_mem_cpy.cpp | 29 ++----------- .../SVM/test_unified_svm_mem_fill.cpp | 42 +++++-------------- 2 files changed, 15 insertions(+), 56 deletions(-) diff --git a/test_conformance/SVM/test_unified_svm_mem_cpy.cpp b/test_conformance/SVM/test_unified_svm_mem_cpy.cpp index f97a5c1a..e67d7684 100644 --- a/test_conformance/SVM/test_unified_svm_mem_cpy.cpp +++ b/test_conformance/SVM/test_unified_svm_mem_cpy.cpp @@ -167,7 +167,7 @@ struct UnifiedSVMOPs : UnifiedSVMBase { for (cl_uint dst_ti = 0; dst_ti < max_ti; dst_ti++) { - if (check_for_common_memory_type(src_ti, dst_ti)) + if (caps_compatibility_check(src_ti, dst_ti)) { log_info( " testing clEnqueueSVMMemcpy() SVM type %u -> SVM " @@ -210,35 +210,14 @@ struct UnifiedSVMOPs : UnifiedSVMBase 0, nullptr, nullptr, nullptr, nullptr)); } - bool check_for_common_memory_type(cl_uint srcTypeIndex, - cl_uint dstTypeIndex) + bool caps_compatibility_check(cl_uint srcTypeIndex, cl_uint dstTypeIndex) { const auto srcCaps = deviceUSVMCaps[srcTypeIndex]; const auto dstCaps = deviceUSVMCaps[dstTypeIndex]; - // Is either allocation a system allocation - if ((srcCaps & CL_SVM_CAPABILITY_SYSTEM_ALLOCATED_KHR) - || (dstCaps & CL_SVM_CAPABILITY_SYSTEM_ALLOCATED_KHR)) - { - return true; - } - - // Is it possible to use the host - if ((srcCaps & CL_SVM_CAPABILITY_HOST_READ_KHR) - && (dstCaps & CL_SVM_CAPABILITY_HOST_WRITE_KHR)) - { - return true; - } - - // Is it posible to use the device - if ((srcCaps & CL_SVM_CAPABILITY_DEVICE_READ_KHR) - && (dstCaps & CL_SVM_CAPABILITY_DEVICE_WRITE_KHR)) - { - return true; - } - - return false; + return (srcCaps & CL_SVM_CAPABILITY_DEVICE_READ_KHR) + && (dstCaps & CL_SVM_CAPABILITY_DEVICE_WRITE_KHR); } static constexpr size_t alloc_count = 1024; diff --git a/test_conformance/SVM/test_unified_svm_mem_fill.cpp b/test_conformance/SVM/test_unified_svm_mem_fill.cpp index 7062c7ce..a00bef42 100644 --- a/test_conformance/SVM/test_unified_svm_mem_fill.cpp +++ b/test_conformance/SVM/test_unified_svm_mem_fill.cpp @@ -130,11 +130,15 @@ struct UnifiedSVMMemFill : UnifiedSVMBase // possible pattern sizes for (cl_uint ti = 0; ti < max_ti; ti++) { - log_info(" testing clEnqueueSVMMemFill() SVM type %u \n", ti); - err = test_svm_memfill(ti); - if (CL_SUCCESS != err) + if (caps_compatibility_check(ti)) { - return err; + + log_info(" testing clEnqueueSVMMemFill() SVM type %u \n", ti); + err = test_svm_memfill(ti); + if (CL_SUCCESS != err) + { + return err; + } } } return CL_SUCCESS; @@ -151,35 +155,11 @@ struct UnifiedSVMMemFill : UnifiedSVMBase 0, nullptr, nullptr, nullptr, nullptr)); } - bool check_for_common_memory_type(cl_uint srcTypeIndex, - cl_uint dstTypeIndex) + bool caps_compatibility_check(cl_uint TypeIndex) { - const auto srcCaps = deviceUSVMCaps[srcTypeIndex]; - const auto dstCaps = deviceUSVMCaps[dstTypeIndex]; - - // Is either allocation a system allocation - if ((srcCaps & CL_SVM_CAPABILITY_SYSTEM_ALLOCATED_KHR) - || (dstCaps & CL_SVM_CAPABILITY_SYSTEM_ALLOCATED_KHR)) - { - return true; - } - - // Is it possible to use the host - if ((srcCaps & CL_SVM_CAPABILITY_HOST_READ_KHR) - && (dstCaps & CL_SVM_CAPABILITY_HOST_WRITE_KHR)) - { - return true; - } - - // Is it posible to use the device - if ((srcCaps & CL_SVM_CAPABILITY_DEVICE_READ_KHR) - && (dstCaps & CL_SVM_CAPABILITY_DEVICE_WRITE_KHR)) - { - return true; - } - - return false; + const auto caps = deviceUSVMCaps[TypeIndex]; + return caps & CL_SVM_CAPABILITY_DEVICE_WRITE_KHR; } static constexpr size_t alloc_count = 1024;