From 95d30fe80c7be6cbc8090e1596688709626865ea Mon Sep 17 00:00:00 2001 From: Ceng23333 <441651826@qq.com> Date: Sat, 10 Oct 2026 09:31:53 +0800 Subject: [PATCH] feat(qy): enable QY CUDA runtime device backend Add Denglin/QY native CUDA runtime stubs, dlcc wrapper, and CMake/test wiring so InfiniRT builds and dispatches on DEVICE_TYPE_QY. --- CMakeLists.txt | 58 +++++++- cmake/InfiniRTConfig.cmake.in | 27 ++++ scripts/dlcc_wrapper.sh | 78 +++++++++++ scripts/generate_public_headers.py | 7 + scripts/run_performance_tests.py | 1 + src/CMakeLists.txt | 7 + src/device.h | 5 +- src/native/cuda/qy/data_type_.h | 30 ++++ src/native/cuda/qy/device_.h | 13 ++ src/native/cuda/qy/runtime_.h | 188 ++++++++++++++++++++++++++ tests/CMakeLists.txt | 18 +++ tests/install_consumer/CMakeLists.txt | 2 +- tests/install_consumer_smoke.cc | 6 +- tests/performance/CMakeLists.txt | 2 + tests/test_runtime_dispatch.cc | 5 + 15 files changed, 440 insertions(+), 7 deletions(-) create mode 100755 scripts/dlcc_wrapper.sh create mode 100644 src/native/cuda/qy/data_type_.h create mode 100644 src/native/cuda/qy/device_.h create mode 100644 src/native/cuda/qy/runtime_.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 270f4bd..d5b6ed5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,6 +39,7 @@ option(WITH_MARS "Enable Mars backend" OFF) option(WITH_CAMBRICON "Enable Cambricon backend" OFF) option(WITH_MOORE "Enable Moore backend" OFF) option(WITH_ASCEND "Enable Ascend backend" OFF) +option(WITH_QY "Enable Denglin QY GPU backend" OFF) option(AUTO_DETECT_DEVICES "Automatically detect available devices" OFF) option(INFINI_RT_BUILD_TESTING "Build InfiniRT tests" OFF) @@ -121,9 +122,24 @@ if(AUTO_DETECT_DEVICES) message(STATUS "Auto-detected Ascend environment.") endif() + set(_qy_root_detect "") + foreach(_qy_env QY_ROOT QY_HOME QY_PATH) + if(NOT _qy_root_detect AND DEFINED ENV{${_qy_env}} AND + NOT "$ENV{${_qy_env}}" STREQUAL "") + set(_qy_root_detect "$ENV{${_qy_env}}") + endif() + endforeach() + if(NOT _qy_root_detect AND EXISTS "/usr/local/denglin/sdk/bin/dlcc") + set(_qy_root_detect "/usr/local/denglin") + endif() + if(_qy_root_detect AND EXISTS "${_qy_root_detect}/sdk/bin/dlcc") + set(WITH_QY ON) + message(STATUS "Auto-detected Denglin QY environment from ${_qy_root_detect}.") + endif() + if(WITH_NVIDIA) set(_non_nvidia_gpu_detected FALSE) - foreach(_gpu_backend WITH_ILUVATAR WITH_HYGON WITH_THEAD WITH_METAX WITH_MARS WITH_CAMBRICON WITH_MOORE WITH_ASCEND) + foreach(_gpu_backend WITH_ILUVATAR WITH_HYGON WITH_THEAD WITH_METAX WITH_MARS WITH_CAMBRICON WITH_MOORE WITH_ASCEND WITH_QY) if(${_gpu_backend}) set(_non_nvidia_gpu_detected TRUE) endif() @@ -140,7 +156,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src) # Only one CUDA-like GPU backend can be enabled at a time. set(_gpu_backend_count 0) -foreach(_gpu_backend WITH_NVIDIA WITH_ILUVATAR WITH_HYGON WITH_THEAD WITH_METAX WITH_MARS WITH_MOORE WITH_CAMBRICON WITH_ASCEND) +foreach(_gpu_backend WITH_NVIDIA WITH_ILUVATAR WITH_HYGON WITH_THEAD WITH_METAX WITH_MARS WITH_MOORE WITH_CAMBRICON WITH_ASCEND WITH_QY) if(${_gpu_backend}) math(EXPR _gpu_backend_count "${_gpu_backend_count} + 1") endif() @@ -348,8 +364,39 @@ if(WITH_ASCEND) message(STATUS "Using Ascend from `${ASCEND_HOME}`.") endif() +if(WITH_QY) + add_compile_definitions(WITH_QY=1) + + set(QY_ROOT "") + foreach(_qy_env QY_ROOT QY_HOME QY_PATH) + if(NOT QY_ROOT AND DEFINED ENV{${_qy_env}} AND NOT "$ENV{${_qy_env}}" STREQUAL "") + set(QY_ROOT "$ENV{${_qy_env}}") + endif() + endforeach() + if(NOT QY_ROOT AND EXISTS "/usr/local/denglin/sdk/bin/dlcc") + set(QY_ROOT "/usr/local/denglin") + endif() + if(NOT QY_ROOT OR NOT EXISTS "${QY_ROOT}/sdk/bin/dlcc") + message(FATAL_ERROR + "`WITH_QY` is `ON` but Denglin QY SDK was not found. " + "Set `QY_ROOT` (expected `${QY_ROOT}/sdk/bin/dlcc`).") + endif() + set(QY_ROOT "${QY_ROOT}" CACHE PATH "Denglin QY SDK root" FORCE) + set(QY_SDK "${QY_ROOT}/sdk") + + # InfiniRT QY is header-only against the Denglin CUDA-compatible runtime. + # Link `curt` directly (MetaX-style) rather than requiring CMake CUDA + nvcc. + include_directories("${QY_SDK}/include") + link_directories("${QY_SDK}/lib") + find_library(QY_CURT_LIB NAMES curt HINTS "${QY_SDK}/lib" REQUIRED) + set(ENV{QY_ROOT} "${QY_ROOT}") + set(ENV{CUDA_HOME} "${QY_SDK}") + set(ENV{CUDA_PATH} "${QY_SDK}") + message(STATUS "QY: SDK ${QY_SDK}, runtime ${QY_CURT_LIB}") +endif() + # If all other platforms are not enabled, CPU is enabled by default. -if(NOT WITH_NVIDIA AND NOT WITH_ILUVATAR AND NOT WITH_HYGON AND NOT WITH_THEAD AND NOT WITH_METAX AND NOT WITH_MARS AND NOT WITH_MOORE AND NOT WITH_CAMBRICON AND NOT WITH_ASCEND) +if(NOT WITH_NVIDIA AND NOT WITH_ILUVATAR AND NOT WITH_HYGON AND NOT WITH_THEAD AND NOT WITH_METAX AND NOT WITH_MARS AND NOT WITH_MOORE AND NOT WITH_CAMBRICON AND NOT WITH_ASCEND AND NOT WITH_QY) set(WITH_CPU ON) add_compile_definitions(WITH_CPU=1) endif() @@ -385,6 +432,9 @@ endif() if(WITH_ASCEND) list(APPEND INFINI_RT_PUBLIC_HEADER_DEVICES ascend) endif() +if(WITH_QY) + list(APPEND INFINI_RT_PUBLIC_HEADER_DEVICES qy) +endif() find_package(Python COMPONENTS Interpreter REQUIRED) execute_process( @@ -408,7 +458,7 @@ if(WITH_NVIDIA OR WITH_ILUVATAR OR WITH_HYGON OR WITH_THEAD) endif() set(INFINI_RT_PACKAGE_VENDOR_BACKEND "") -foreach(_backend METAX MARS MOORE CAMBRICON ASCEND) +foreach(_backend METAX MARS MOORE CAMBRICON ASCEND QY) if(WITH_${_backend}) set(INFINI_RT_PACKAGE_VENDOR_BACKEND "${_backend}") endif() diff --git a/cmake/InfiniRTConfig.cmake.in b/cmake/InfiniRTConfig.cmake.in index 051e315..9a22740 100644 --- a/cmake/InfiniRTConfig.cmake.in +++ b/cmake/InfiniRTConfig.cmake.in @@ -15,6 +15,7 @@ set(InfiniRT_WITH_MARS @WITH_MARS@) set(InfiniRT_WITH_MOORE @WITH_MOORE@) set(InfiniRT_WITH_CAMBRICON @WITH_CAMBRICON@) set(InfiniRT_WITH_ASCEND @WITH_ASCEND@) +set(InfiniRT_WITH_QY @WITH_QY@) if(@INFINI_RT_PACKAGE_NEEDS_CUDATOOLKIT@) find_dependency(CUDAToolkit) @@ -186,6 +187,32 @@ elseif(_InfiniRT_VENDOR_BACKEND STREQUAL "ASCEND") _infinirt_define_backend_runtime( "${_InfiniRT_ASCEND_INCLUDE_DIRS}" "${_InfiniRT_BACKEND_RUNTIME_LIBRARY};${_InfiniRT_BACKEND_DRIVER_LIBRARY};${CMAKE_DL_LIBS}") +elseif(_InfiniRT_VENDOR_BACKEND STREQUAL "QY") + set(_InfiniRT_ROOT_HINTS "${InfiniRT_QY_ROOT}") + foreach(_InfiniRT_ENV QY_ROOT QY_HOME QY_PATH) + if(DEFINED ENV{${_InfiniRT_ENV}}) + list(APPEND _InfiniRT_ROOT_HINTS "$ENV{${_InfiniRT_ENV}}") + endif() + endforeach() + list(APPEND _InfiniRT_ROOT_HINTS /usr/local/denglin) + find_path(_InfiniRT_BACKEND_INCLUDE_DIR + NAMES cuda_runtime.h + HINTS ${_InfiniRT_ROOT_HINTS} + PATH_SUFFIXES sdk/include include) + find_library(_InfiniRT_BACKEND_RUNTIME_LIBRARY + NAMES curt + HINTS ${_InfiniRT_ROOT_HINTS} + PATH_SUFFIXES sdk/lib lib lib64) + if(NOT _InfiniRT_BACKEND_INCLUDE_DIR OR + NOT _InfiniRT_BACKEND_RUNTIME_LIBRARY) + set(InfiniRT_FOUND FALSE) + set(InfiniRT_NOT_FOUND_MESSAGE + "Denglin QY SDK not found. Set InfiniRT_QY_ROOT or QY_ROOT.") + return() + endif() + _infinirt_define_backend_runtime( + "${_InfiniRT_BACKEND_INCLUDE_DIR}" + "${_InfiniRT_BACKEND_RUNTIME_LIBRARY}") endif() include("${CMAKE_CURRENT_LIST_DIR}/InfiniRTTargets.cmake") diff --git a/scripts/dlcc_wrapper.sh b/scripts/dlcc_wrapper.sh new file mode 100755 index 0000000..c1b8aab --- /dev/null +++ b/scripts/dlcc_wrapper.sh @@ -0,0 +1,78 @@ +#!/bin/bash +# Filter CMake/host flags unsupported or harmful when invoking Denglin `dlcc` +# as CMAKE_CUDA_COMPILER. Emulate enough of `nvcc -v` for CMake 3.22 Clang +# CUDA detection (TOP / NVVMIR_LIBRARY_DIR). +set -euo pipefail + +QY_ROOT="${QY_ROOT:-${QY_HOME:-${QY_PATH:-/usr/local/denglin}}}" +DLCC="${QY_ROOT}/sdk/bin/dlcc" +SDK="${QY_ROOT}/sdk" + +if [[ ! -x "${DLCC}" ]]; then + # Container image layout. + if [[ -x /usr/local/dlgpu/sdk/bin/dlcc ]]; then + QY_ROOT=/usr/local/dlgpu + DLCC=/usr/local/dlgpu/sdk/bin/dlcc + SDK=/usr/local/dlgpu/sdk + else + echo "dlcc_wrapper: dlcc not found; set QY_ROOT" >&2 + exit 1 + fi +fi + +# CMakeDetermineCUDACompiler runs `${CMAKE_CUDA_COMPILER} -v __cmake_determine_cuda`. +if [[ "${1:-}" == "-v" ]]; then + echo "clang version 15.0.6" + echo "Cuda compilation tools, release 11.7, V11.7.0" + echo "#\$ TOP=${SDK}" + # Path need only match CMake's `nvvm/libdevice$` regex; Denglin has no nvvm tree. + echo "#\$ NVVMIR_LIBRARY_DIR=${SDK}/nvvm/libdevice" + "${DLCC}" --version || true + exit 0 +fi + +ARGS=() +skip_next=0 +has_cuda_path=0 +replaced_cudart=0 +for arg in "$@"; do + if [[ "${skip_next}" -eq 1 ]]; then + skip_next=0 + continue + fi + case "${arg}" in + -pthread) ;; + -B) skip_next=1 ;; + -B*) ;; + --cuda-path=*) + has_cuda_path=1 + ARGS+=("${arg}") + ;; + # CMake Clang detection probes sm_20/30/52; Denglin only accepts dlgput64. + --cuda-gpu-arch=sm_*) ;; + --cuda-gpu-arch=dlgput64) + ARGS+=("${arg}") + ;; + --cuda-gpu-arch=*) ;; + -Xcompiler=*) ;; + # Match pre-refactor xmake/qy.lua: drop NVIDIA static CUDA libs. + -lcudadevrt|-lcudart_static|-lcudart) + if [[ "${replaced_cudart}" -eq 0 ]]; then + ARGS+=("-lcurt") + replaced_cudart=1 + fi + ;; + *) + ARGS+=("${arg}") + ;; + esac +done + +EXTRA=() +if [[ "${has_cuda_path}" -eq 0 ]]; then + EXTRA+=("--cuda-path=${SDK}") +fi +# Always compile for Denglin GPU; ignore CMake sm_* probes. +EXTRA+=("--cuda-gpu-arch=dlgput64") + +exec "${DLCC}" "${EXTRA[@]}" "${ARGS[@]}" diff --git a/scripts/generate_public_headers.py b/scripts/generate_public_headers.py index 516d4aa..aeba346 100644 --- a/scripts/generate_public_headers.py +++ b/scripts/generate_public_headers.py @@ -57,6 +57,11 @@ ("ascend", "device_.h", "native/ascend/device_.h"), ("ascend", "runtime_.h", "native/ascend/runtime_.h"), ), + "qy": ( + ("qy", "data_type_.h", "native/cuda/qy/data_type_.h"), + ("qy", "device_.h", "native/cuda/qy/device_.h"), + ("qy", "runtime_.h", "native/cuda/qy/runtime_.h"), + ), } _DEVICE_TYPES = { @@ -70,6 +75,7 @@ "moore": "Device::Type::kMoore", "cambricon": "Device::Type::kCambricon", "ascend": "Device::Type::kAscend", + "qy": "Device::Type::kQy", } _DEFAULT_DEVICE_PRIORITY = ( @@ -82,6 +88,7 @@ "moore", "cambricon", "ascend", + "qy", "cpu", ) diff --git a/scripts/run_performance_tests.py b/scripts/run_performance_tests.py index d0b3776..c31f185 100644 --- a/scripts/run_performance_tests.py +++ b/scripts/run_performance_tests.py @@ -15,6 +15,7 @@ ("WITH_MOORE", "moore"), ("WITH_CAMBRICON", "cambricon"), ("WITH_ASCEND", "ascend"), + ("WITH_QY", "qy"), ("WITH_CPU", "cpu"), ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1dd146f..9079bc4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -105,6 +105,13 @@ if(WITH_CAMBRICON) "${CAMBRICON_RUNTIME_LIB}") endif() +if(WITH_QY) + target_compile_definitions(infinirt PUBLIC WITH_QY=1) + _infinirt_use_backend_runtime( + "${QY_SDK}/include" + "${QY_CURT_LIB}") +endif() + if(WITH_ASCEND) # ASCEND_HOME is set by the top-level CMakeLists.txt. target_compile_definitions(infinirt PUBLIC WITH_ASCEND=1) diff --git a/src/device.h b/src/device.h index 3c078ee..4f2cfc2 100644 --- a/src/device.h +++ b/src/device.h @@ -23,6 +23,7 @@ class Device { kHygon = 7, kThead = 8, kMars = 9, + kQy = 10, kCount }; @@ -68,6 +69,7 @@ class Device { {Type::kHygon, "hygon"}, {Type::kThead, "thead"}, {Type::kMars, "mars"}, + {Type::kQy, "qy"}, }}}; static constexpr ConstexprMap; + Device::Type::kMars, Device::Type::kQy>; // Deferred computation of active devices. The `Filter` and `FilterList` // evaluation are nested inside a class template so that `DeviceEnabled` diff --git a/src/native/cuda/qy/data_type_.h b/src/native/cuda/qy/data_type_.h new file mode 100644 index 0000000..d414770 --- /dev/null +++ b/src/native/cuda/qy/data_type_.h @@ -0,0 +1,30 @@ +#ifndef INFINI_RT_QY_DATA_TYPE__H_ +#define INFINI_RT_QY_DATA_TYPE__H_ + +// clang-format off +#include +#include +// clang-format on + +#include "data_type.h" +#include "native/cuda/qy/device_.h" + +namespace infini::rt { + +using cuda_bfloat16 = nv_bfloat16; + +using cuda_bfloat162 = nv_bfloat162; + +template <> +struct TypeMap { + using type = half; +}; + +template <> +struct TypeMap { + using type = __nv_bfloat16; +}; + +} // namespace infini::rt + +#endif diff --git a/src/native/cuda/qy/device_.h b/src/native/cuda/qy/device_.h new file mode 100644 index 0000000..147c2ab --- /dev/null +++ b/src/native/cuda/qy/device_.h @@ -0,0 +1,13 @@ +#ifndef INFINI_RT_QY_DEVICE__H_ +#define INFINI_RT_QY_DEVICE__H_ + +#include "device.h" + +namespace infini::rt { + +template <> +struct DeviceEnabled : std::true_type {}; + +} // namespace infini::rt + +#endif diff --git a/src/native/cuda/qy/runtime_.h b/src/native/cuda/qy/runtime_.h new file mode 100644 index 0000000..8fd5687 --- /dev/null +++ b/src/native/cuda/qy/runtime_.h @@ -0,0 +1,188 @@ +#ifndef INFINI_RT_QY_RUNTIME__H_ +#define INFINI_RT_QY_RUNTIME__H_ + +#include +#include + +// clang-format off +#include +// clang-format on + +#include "native/cuda/qy/device_.h" +#include "native/cuda/runtime_.h" + +namespace infini::rt::runtime { + +template <> +struct Runtime + : GraphRuntime, + CudaRuntime>> { + using Error = cudaError_t; + + using Stream = cudaStream_t; + + using Graph = cudaGraph_t; + + using GraphExec = cudaGraphExec_t; + + using Event = cudaEvent_t; + + using StreamCaptureMode = cudaStreamCaptureMode; + + static constexpr Device::Type kDeviceType = Device::Type::kQy; + + static constexpr Error kSuccess = cudaSuccess; + + // Denglin headers overload several cuda* entry points; wrap them in + // forwarding lambdas so Clang CUDA can resolve a single candidate. + static constexpr auto SetDevice = [](auto&&... args) { + return cudaSetDevice(std::forward(args)...); + }; + + static constexpr auto GetDevice = [](auto&&... args) { + return cudaGetDevice(std::forward(args)...); + }; + + static constexpr auto GetDeviceCount = [](auto&&... args) { + return cudaGetDeviceCount(std::forward(args)...); + }; + + static constexpr auto DeviceSynchronize = [](auto&&... args) { + return cudaDeviceSynchronize(std::forward(args)...); + }; + + static constexpr auto Malloc = [](auto&&... args) { + return cudaMalloc(std::forward(args)...); + }; + + static constexpr auto MallocHost = [](auto&&... args) { + return cudaMallocHost(std::forward(args)...); + }; + + static constexpr auto MallocAsync = [](auto&&... args) { + return cudaMallocAsync(std::forward(args)...); + }; + + static constexpr auto Free = [](auto&&... args) { + return cudaFree(std::forward(args)...); + }; + + static constexpr auto FreeHost = [](auto&&... args) { + return cudaFreeHost(std::forward(args)...); + }; + + static constexpr auto FreeAsync = [](auto&&... args) { + return cudaFreeAsync(std::forward(args)...); + }; + + static constexpr auto MemGetInfo = [](auto&&... args) { + return cudaMemGetInfo(std::forward(args)...); + }; + + static constexpr auto Memcpy = [](auto&&... args) { + return cudaMemcpy(std::forward(args)...); + }; + + static constexpr auto MemcpyAsync = [](auto&&... args) { + return cudaMemcpyAsync(std::forward(args)...); + }; + + static constexpr auto kMemcpyHostToHost = cudaMemcpyHostToHost; + + static constexpr auto kMemcpyHostToDevice = cudaMemcpyHostToDevice; + + static constexpr auto kMemcpyDeviceToHost = cudaMemcpyDeviceToHost; + + static constexpr auto kMemcpyDeviceToDevice = cudaMemcpyDeviceToDevice; + + static constexpr auto Memset = [](auto&&... args) { + return cudaMemset(std::forward(args)...); + }; + + static constexpr auto MemsetAsync = [](auto&&... args) { + return cudaMemsetAsync(std::forward(args)...); + }; + + static constexpr auto StreamCreate = [](auto&&... args) { + return cudaStreamCreate(std::forward(args)...); + }; + + static constexpr auto StreamDestroy = [](auto&&... args) { + return cudaStreamDestroy(std::forward(args)...); + }; + + static constexpr auto StreamSynchronize = [](auto&&... args) { + return cudaStreamSynchronize(std::forward(args)...); + }; + + static constexpr auto StreamWaitEvent = [](auto&&... args) { + return cudaStreamWaitEvent(std::forward(args)...); + }; + + static constexpr auto EventCreate = [](auto&&... args) { + return cudaEventCreate(std::forward(args)...); + }; + + static constexpr auto EventCreateWithFlags = [](auto&&... args) { + return cudaEventCreateWithFlags(std::forward(args)...); + }; + + static constexpr auto EventRecord = [](auto&&... args) { + return cudaEventRecord(std::forward(args)...); + }; + + static constexpr auto EventQuery = [](auto&&... args) { + return cudaEventQuery(std::forward(args)...); + }; + + static constexpr auto EventSynchronize = [](auto&&... args) { + return cudaEventSynchronize(std::forward(args)...); + }; + + static constexpr auto EventDestroy = [](auto&&... args) { + return cudaEventDestroy(std::forward(args)...); + }; + + static constexpr auto EventElapsedTime = [](auto&&... args) { + return cudaEventElapsedTime(std::forward(args)...); + }; + + static constexpr auto kStreamCaptureModeGlobal = cudaStreamCaptureModeGlobal; + + static constexpr auto kStreamCaptureModeThreadLocal = + cudaStreamCaptureModeThreadLocal; + + static constexpr auto kStreamCaptureModeRelaxed = + cudaStreamCaptureModeRelaxed; + + static constexpr auto StreamBeginCapture = [](auto&&... args) { + return cudaStreamBeginCapture(std::forward(args)...); + }; + + static constexpr auto StreamEndCapture = [](auto&&... args) { + return cudaStreamEndCapture(std::forward(args)...); + }; + + static constexpr auto GraphDestroy = [](auto&&... args) { + return cudaGraphDestroy(std::forward(args)...); + }; + + // Denglin SDK exposes the older 5-argument cudaGraphInstantiate ABI. + static Error GraphInstantiate(GraphExec* graph_exec, Graph graph) { + return cudaGraphInstantiate(graph_exec, graph, nullptr, nullptr, 0); + } + + static constexpr auto GraphExecDestroy = [](auto&&... args) { + return cudaGraphExecDestroy(std::forward(args)...); + }; + + static constexpr auto GraphLaunch = [](auto&&... args) { + return cudaGraphLaunch(std::forward(args)...); + }; +}; + +static_assert(Runtime::Validate()); + +} // namespace infini::rt::runtime + +#endif diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index bf759d2..b14a169 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -148,6 +148,16 @@ if(WITH_ASCEND) ASCEND infini::rt::Device::Type::kAscend 1) endif() +if(WITH_QY) + set(INFINI_RT_TEST_HAS_RUNTIME_BACKEND ON) + add_infini_rt_backend_runtime_test( + QY infini::rt::Device::Type::kQy + infini/rt/qy/runtime_.h + 1 1 1 1 1 1 1 1) + add_infini_rt_backend_graph_test( + QY infini::rt::Device::Type::kQy 1) +endif() + if(INFINI_RT_TEST_HAS_RUNTIME_BACKEND) add_infini_rt_test(test_runtime_dispatch test_runtime_dispatch.cc) @@ -191,6 +201,10 @@ if(INFINI_RT_TEST_HAS_RUNTIME_BACKEND) target_compile_definitions(test_runtime_dispatch PRIVATE INFINI_RT_TEST_WITH_ASCEND=1) endif() + if(WITH_QY) + target_compile_definitions(test_runtime_dispatch + PRIVATE INFINI_RT_TEST_WITH_QY=1) + endif() endif() set(INFINI_RT_TEST_INSTALL_PREFIX @@ -242,6 +256,10 @@ elseif(WITH_ASCEND) set(INFINI_RT_TEST_CONSUMER_BACKEND ASCEND) set(INFINI_RT_TEST_BACKEND_ROOT_VARIABLE InfiniRT_ASCEND_ROOT) set(INFINI_RT_TEST_BACKEND_ROOT "${ASCEND_HOME}") +elseif(WITH_QY) + set(INFINI_RT_TEST_CONSUMER_BACKEND QY) + set(INFINI_RT_TEST_BACKEND_ROOT_VARIABLE InfiniRT_QY_ROOT) + set(INFINI_RT_TEST_BACKEND_ROOT "${QY_ROOT}") elseif(WITH_CPU) set(INFINI_RT_TEST_CONSUMER_BACKEND CPU) endif() diff --git a/tests/install_consumer/CMakeLists.txt b/tests/install_consumer/CMakeLists.txt index 60b5636..51602c1 100644 --- a/tests/install_consumer/CMakeLists.txt +++ b/tests/install_consumer/CMakeLists.txt @@ -24,7 +24,7 @@ if(NOT "${InfiniRT_ENABLED_BACKENDS}" STREQUAL "InfiniRT reported enabled backends '${InfiniRT_ENABLED_BACKENDS}', expected '${_infinirt_expected_backends}'.") endif() -foreach(_infinirt_backend CPU NVIDIA ILUVATAR HYGON THEAD METAX MARS MOORE CAMBRICON ASCEND) +foreach(_infinirt_backend CPU NVIDIA ILUVATAR HYGON THEAD METAX MARS MOORE CAMBRICON ASCEND QY) string(TOLOWER "${_infinirt_backend}" _infinirt_backend_lower) list(FIND _infinirt_expected_backends "${_infinirt_backend_lower}" _infinirt_backend_index) diff --git a/tests/install_consumer_smoke.cc b/tests/install_consumer_smoke.cc index 968c144..90682f8 100644 --- a/tests/install_consumer_smoke.cc +++ b/tests/install_consumer_smoke.cc @@ -50,7 +50,8 @@ int main() { defined(INFINI_RT_CONSUMER_BACKEND_MARS) || \ defined(INFINI_RT_CONSUMER_BACKEND_MOORE) || \ defined(INFINI_RT_CONSUMER_BACKEND_CAMBRICON) || \ - defined(INFINI_RT_CONSUMER_BACKEND_ASCEND) + defined(INFINI_RT_CONSUMER_BACKEND_ASCEND) || \ + defined(INFINI_RT_CONSUMER_BACKEND_QY) namespace runtime = infini::rt::runtime; #if defined(INFINI_RT_CONSUMER_BACKEND_CPU) constexpr auto kExpectedDeviceType = infini::rt::Device::Type::kCpu; @@ -82,6 +83,9 @@ int main() { #elif defined(INFINI_RT_CONSUMER_BACKEND_ASCEND) constexpr auto kExpectedDeviceType = infini::rt::Device::Type::kAscend; constexpr bool kExpectAsyncMemcpySuccess = true; +#elif defined(INFINI_RT_CONSUMER_BACKEND_QY) + constexpr auto kExpectedDeviceType = infini::rt::Device::Type::kQy; + constexpr bool kExpectAsyncMemcpySuccess = true; #endif infini::rt::set_runtime_device_type(kExpectedDeviceType); if (infini::rt::runtime_device_type() != kExpectedDeviceType) { diff --git a/tests/performance/CMakeLists.txt b/tests/performance/CMakeLists.txt index 7db86de..da8ebda 100644 --- a/tests/performance/CMakeLists.txt +++ b/tests/performance/CMakeLists.txt @@ -15,6 +15,8 @@ elseif(WITH_CAMBRICON) set(INFINI_RT_PERF_BACKEND_NAME "cambricon") elseif(WITH_ASCEND) set(INFINI_RT_PERF_BACKEND_NAME "ascend") +elseif(WITH_QY) + set(INFINI_RT_PERF_BACKEND_NAME "qy") endif() function(add_infini_rt_performance_test target) diff --git a/tests/test_runtime_dispatch.cc b/tests/test_runtime_dispatch.cc index a234f51..e32a920 100644 --- a/tests/test_runtime_dispatch.cc +++ b/tests/test_runtime_dispatch.cc @@ -450,5 +450,10 @@ int main() { {true, false, false, false, true, false, false, false}); #endif +#if defined(INFINI_RT_TEST_WITH_QY) + TestDispatch(&context, infini::rt::Device::Type::kQy, "QY", + {true, true, true, true, true, true, true, true}); +#endif + return context.ExitCode(); }