From 348d06b77e13bade870b640f52e984fc4e21c74c Mon Sep 17 00:00:00 2001 From: Deepak Raj H R Date: Tue, 7 Jan 2025 14:06:37 +0800 Subject: [PATCH 1/3] Add migration for CU_DEVICE_ATTRIBUTE_ASYNC_ENGINE_COUNT --- clang/lib/DPCT/RuleInfra/MapNames.cpp | 3 +++ clang/runtime/dpct-rt/include/dpct/device.hpp | 3 +++ clang/test/dpct/driver_device.cu | 6 +++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/clang/lib/DPCT/RuleInfra/MapNames.cpp b/clang/lib/DPCT/RuleInfra/MapNames.cpp index 7028ce5376b7..2dd608b76054 100644 --- a/clang/lib/DPCT/RuleInfra/MapNames.cpp +++ b/clang/lib/DPCT/RuleInfra/MapNames.cpp @@ -1157,6 +1157,9 @@ void MapNames::setExplicitNamespaceMap( {"CU_DEVICE_ATTRIBUTE_MAX_PITCH", std::make_shared("get_max_pitch", HelperFeatureEnum::device_ext)}, + {"CU_DEVICE_ATTRIBUTE_ASYNC_ENGINE_COUNT", + std::make_shared("get_async_engine_count", + HelperFeatureEnum::device_ext)}, {"CU_CTX_MAP_HOST", std::make_shared("0")}, {"CU_CTX_SCHED_BLOCKING_SYNC", std::make_shared("0")}, {"CU_CTX_SCHED_SPIN", std::make_shared("0")}, diff --git a/clang/runtime/dpct-rt/include/dpct/device.hpp b/clang/runtime/dpct-rt/include/dpct/device.hpp index ce48707e9f62..06379affb348 100644 --- a/clang/runtime/dpct-rt/include/dpct/device.hpp +++ b/clang/runtime/dpct-rt/include/dpct/device.hpp @@ -519,6 +519,9 @@ class device_ext : public sycl::device { int get_max_pitch() const { return INT_MAX; } + // CU_DEVICE_ATTRIBUTE_ASYNC_ENGINE_COUNT is irrelevant in SYCL + int get_async_engine_count() const { return 0; } + /// Get the number of bytes of free and total memory on the SYCL device. /// \param [out] free_memory The number of bytes of free memory on the SYCL device. /// \param [out] total_memory The number of bytes of total memory on the SYCL device. diff --git a/clang/test/dpct/driver_device.cu b/clang/test/dpct/driver_device.cu index 323ec1dd7b38..7491e2ecc0db 100644 --- a/clang/test/dpct/driver_device.cu +++ b/clang/test/dpct/driver_device.cu @@ -57,7 +57,11 @@ void test() { // CHECK: result7 = dpct::get_device(device).get_max_pitch(); cuDeviceGetAttribute(&result7,CU_DEVICE_ATTRIBUTE_MAX_PITCH, device); - std::cout << " result7 " << result5 << std::endl; + std::cout << " result7 " << result7 << std::endl; + + // CHECK: result1 = dpct::get_device(device).get_async_engine_count(); + cuDeviceGetAttribute(&result1,CU_DEVICE_ATTRIBUTE_ASYNC_ENGINE_COUNT, device); + std::cout << " result1 " << result1 << std::endl; } int main(){ From 52bd6016112b832720289cc8733c31abf874ed30 Mon Sep 17 00:00:00 2001 From: Deepak Raj H R Date: Tue, 7 Jan 2025 13:19:22 +0530 Subject: [PATCH 2/3] Remove CUDA related info --- clang/runtime/dpct-rt/include/dpct/device.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/clang/runtime/dpct-rt/include/dpct/device.hpp b/clang/runtime/dpct-rt/include/dpct/device.hpp index 06379affb348..a6aa1ed398f5 100644 --- a/clang/runtime/dpct-rt/include/dpct/device.hpp +++ b/clang/runtime/dpct-rt/include/dpct/device.hpp @@ -519,7 +519,6 @@ class device_ext : public sycl::device { int get_max_pitch() const { return INT_MAX; } - // CU_DEVICE_ATTRIBUTE_ASYNC_ENGINE_COUNT is irrelevant in SYCL int get_async_engine_count() const { return 0; } /// Get the number of bytes of free and total memory on the SYCL device. From 7edf229f2cfbb4230ed70fe0c9928c18543bee97 Mon Sep 17 00:00:00 2001 From: Deepak Raj H R Date: Wed, 15 Jan 2025 14:34:05 +0800 Subject: [PATCH 3/3] Using C++ int max --- clang/runtime/dpct-rt/include/dpct/device.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clang/runtime/dpct-rt/include/dpct/device.hpp b/clang/runtime/dpct-rt/include/dpct/device.hpp index 06379affb348..7c5bd445888b 100644 --- a/clang/runtime/dpct-rt/include/dpct/device.hpp +++ b/clang/runtime/dpct-rt/include/dpct/device.hpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -517,7 +518,7 @@ class device_ext : public sycl::device { return get_device_info().get_local_mem_size(); } - int get_max_pitch() const { return INT_MAX; } + int get_max_pitch() const { return std::numeric_limits::max(); } // CU_DEVICE_ATTRIBUTE_ASYNC_ENGINE_COUNT is irrelevant in SYCL int get_async_engine_count() const { return 0; }