From 638432875b64c2e0e30ccbab12a0fc844bc1ae40 Mon Sep 17 00:00:00 2001 From: zhuyue Date: Fri, 7 Aug 2026 17:07:32 +0800 Subject: [PATCH] fix: align backend capabilities, tests, and docs --- CMakeLists.txt | 4 ++-- docs/backends.md | 19 ++++++++++++++----- src/native/ascend/runtime_.h | 3 ++- tests/CMakeLists.txt | 4 +++- tests/test_native_graph.cc | 4 ++++ tests/test_runtime_dispatch.cc | 2 +- 6 files changed, 26 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d760cd..270f4bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -140,14 +140,14 @@ 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_ASCEND) +foreach(_gpu_backend WITH_NVIDIA WITH_ILUVATAR WITH_HYGON WITH_THEAD WITH_METAX WITH_MARS WITH_MOORE WITH_CAMBRICON WITH_ASCEND) if(${_gpu_backend}) math(EXPR _gpu_backend_count "${_gpu_backend_count} + 1") endif() endforeach() if(_gpu_backend_count GREATER 1) - message(FATAL_ERROR "`WITH_NVIDIA`, `WITH_ILUVATAR`, `WITH_HYGON`, `WITH_THEAD`, `WITH_METAX`, `WITH_MARS`, `WITH_MOORE`, and `WITH_ASCEND` are mutually exclusive. Build one GPU backend at a time.") + message(FATAL_ERROR "GPU backend options are mutually exclusive. Build one GPU backend at a time.") endif() if(WITH_NVIDIA) diff --git a/docs/backends.md b/docs/backends.md index b08334c..1c5a575 100644 --- a/docs/backends.md +++ b/docs/backends.md @@ -15,6 +15,7 @@ backend. | Mars | `WITH_MARS` | Requires `HPCC_PATH`. | | Moore | `WITH_MOORE` | Requires `MUSA_ROOT`, `MUSA_HOME`, or `MUSA_PATH`. | | Hygon | `WITH_HYGON` | Requires DTK and a DTK CUDA toolkit. | +| T-Head | `WITH_THEAD` | Requires a T-Head CUDA-compatible toolkit. | | Cambricon | `WITH_CAMBRICON` | Requires `NEUWARE_HOME`. | | Ascend | `WITH_ASCEND` | Requires Ascend toolkit. | @@ -27,7 +28,7 @@ All enabled runtime backends provide the core device and memory entry points needed by the dispatching runtime API. Optional operations may return an error status on backends that do not support them. -Current test expectations are: +Current runtime test expectations are: | Backend | Async memcpy | Host memory | Async memory | Memory info | Async memset | Events | Graph capture | | --- | --- | --- | --- | --- | --- | --- | --- | @@ -36,14 +37,22 @@ Current test expectations are: | Iluvatar | Yes | Yes | Yes | Yes | Yes | Yes | Yes | | MetaX | Yes | Yes | Yes | Yes | Yes | Yes | Yes | | Mars | Yes | Yes | Yes | Yes | Yes | Yes | Yes | -| Moore | Yes | Yes | No | Yes | Yes | Yes | No | -| Hygon | Yes | Yes | Yes | Yes | Yes | Yes | No | -| Cambricon | Yes | No | No | No | No | No | No | -| Ascend | Yes | No | No | No | No | No | Yes | +| Moore | Yes | Yes | No | Yes | Yes | Yes | Yes | +| Hygon | Yes | Yes | Yes | Yes | Yes | Yes | Yes | +| T-Head | Yes | Yes | Yes | Yes | Yes | Yes | Yes | +| Cambricon | Yes | No | No | No | Yes | No | Yes | +| Ascend | Yes | No | No | No | Yes | No | Yes* | Treat a non-`kSuccess` status as the portable way to detect unsupported operations. +\* Ascend Graph capture and replay require the runtime `aclmdlRI*` symbols +(`aclmdlRICaptureBegin`, `aclmdlRICaptureGetInfo`, `aclmdlRICaptureEnd`, +`aclmdlRIExecuteAsync`, and `aclmdlRIDestroy`). The Graph replay test is +registered for Ascend builds and passes on CANN 9.0 with 910B hardware. On a +CANN installation without these symbols, the runtime reports Graph capture as +unsupported. + ## Header Dependencies Backend public wrappers may include vendor headers. For example, an NVIDIA diff --git a/src/native/ascend/runtime_.h b/src/native/ascend/runtime_.h index 35f3005..6503279 100644 --- a/src/native/ascend/runtime_.h +++ b/src/native/ascend/runtime_.h @@ -197,7 +197,8 @@ struct Runtime bool Available() const { return CaptureBegin != nullptr && CaptureGetInfo != nullptr && - CaptureEnd != nullptr && ExecuteAsync != nullptr; + CaptureEnd != nullptr && ExecuteAsync != nullptr && + Destroy != nullptr; } }; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index bb05ed2..bf759d2 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -143,7 +143,9 @@ if(WITH_ASCEND) add_infini_rt_backend_runtime_test( ASCEND infini::rt::Device::Type::kAscend infini/rt/ascend/runtime_.h - 1 0 0 0 0 0 0 0) + 1 0 0 0 1 0 0 0) + add_infini_rt_backend_graph_test( + ASCEND infini::rt::Device::Type::kAscend 1) endif() if(INFINI_RT_TEST_HAS_RUNTIME_BACKEND) diff --git a/tests/test_native_graph.cc b/tests/test_native_graph.cc index 17a51c8..1c429d9 100644 --- a/tests/test_native_graph.cc +++ b/tests/test_native_graph.cc @@ -110,9 +110,13 @@ void RunGraphReplayTest(infini::rt::test::TestContext* context) { "Failed to record device-to-device copy."); ExpectSuccess(context, runtime::StreamEndCapture(stream, &graph), "Failed to end stream capture."); + context->Expect(graph != nullptr, + "Stream capture should produce a graph handle."); ExpectSuccess(context, runtime::GraphInstantiate(&graph_exec, graph), "Failed to instantiate graph."); + context->Expect(graph_exec != nullptr, + "Graph instantiation should produce an executable handle."); } std::array replay_input_1{}; diff --git a/tests/test_runtime_dispatch.cc b/tests/test_runtime_dispatch.cc index 637efe2..a234f51 100644 --- a/tests/test_runtime_dispatch.cc +++ b/tests/test_runtime_dispatch.cc @@ -447,7 +447,7 @@ int main() { #if defined(INFINI_RT_TEST_WITH_ASCEND) TestDispatch(&context, infini::rt::Device::Type::kAscend, "ASCEND", - {true, false, false, false, false, false, false, false}); + {true, false, false, false, true, false, false, false}); #endif return context.ExitCode();