From 46d411ef37f7c8a5d599ceca78547eac0bcbbfd4 Mon Sep 17 00:00:00 2001 From: Florent Li <1508269885@qq.com> Date: Thu, 5 Nov 2026 12:35:09 +0800 Subject: [PATCH] fix(hygon): resolve CUDA runtime overloads in device compilation --- src/native/cuda/hygon/runtime_.h | 16 ++++++++++++---- tests/CMakeLists.txt | 5 +++++ tests/test_hygon_cuda_runtime.cu | 2 ++ 3 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 tests/test_hygon_cuda_runtime.cu diff --git a/src/native/cuda/hygon/runtime_.h b/src/native/cuda/hygon/runtime_.h index df88c44..be10a62 100644 --- a/src/native/cuda/hygon/runtime_.h +++ b/src/native/cuda/hygon/runtime_.h @@ -36,11 +36,17 @@ struct Runtime static constexpr auto SetDevice = cudaSetDevice; - static constexpr auto GetDevice = cudaGetDevice; + static constexpr auto GetDevice = [](auto&&... args) { + return cudaGetDevice(std::forward(args)...); + }; - static constexpr auto GetDeviceCount = cudaGetDeviceCount; + static constexpr auto GetDeviceCount = [](auto&&... args) { + return cudaGetDeviceCount(std::forward(args)...); + }; - static constexpr auto DeviceSynchronize = cudaDeviceSynchronize; + static constexpr auto DeviceSynchronize = [](auto&&... args) { + return cudaDeviceSynchronize(std::forward(args)...); + }; static constexpr auto Malloc = [](auto&&... args) { return cudaMalloc(std::forward(args)...); @@ -72,7 +78,9 @@ struct Runtime static constexpr auto Memcpy = cudaMemcpy; - static constexpr auto MemcpyAsync = cudaMemcpyAsync; + static constexpr auto MemcpyAsync = [](auto&&... args) { + return cudaMemcpyAsync(std::forward(args)...); + }; static constexpr auto kMemcpyHostToHost = cudaMemcpyHostToHost; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 6bb2dba..0961918 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -87,6 +87,11 @@ if(WITH_HYGON) HYGON infini::rt::Device::Type::kHygon infini/rt/hygon/runtime_.h 1 1 1 1 1 1 1 1) + add_infini_rt_test(test_hygon_cuda_runtime test_hygon_cuda_runtime.cu) + get_target_property(_hygon_runtime_definitions test_hygon_runtime + COMPILE_DEFINITIONS) + target_compile_definitions(test_hygon_cuda_runtime + PRIVATE ${_hygon_runtime_definitions}) add_infini_rt_backend_graph_test( HYGON infini::rt::Device::Type::kHygon 1) endif() diff --git a/tests/test_hygon_cuda_runtime.cu b/tests/test_hygon_cuda_runtime.cu new file mode 100644 index 0000000..7253e3c --- /dev/null +++ b/tests/test_hygon_cuda_runtime.cu @@ -0,0 +1,2 @@ +// Exercise the runtime headers with DTK's device compiler as well as C++. +#include "test_native_runtime.cc"