From 169df9e22a3a09793a08ca1fbb72b8781d4eb7b1 Mon Sep 17 00:00:00 2001 From: ZhouChen Date: Tue, 4 Nov 2025 22:48:06 +0800 Subject: [PATCH 1/2] set event mode --- CMakeLists.txt | 2 + cmake/modules/Findadump.cmake | 26 ++++++------ cmake/modules/Findmsprof.cmake | 6 +-- cmake/modules/Findopcompiler.cmake | 2 +- cmake/modules/Findslog.cmake | 12 +++--- cmake/modules/Findunified_dlog.cmake | 21 +++++----- common/acl.cpp | 30 +++++++++++++ common/common_inner.h | 2 + common/json_parser.cpp | 40 ++++++++++++++++++ common/json_parser.h | 1 + tests/depends/acl_stub.h | 4 +- tests/depends/dvpp/CMakeLists.txt | 3 ++ tests/depends/ge/CMakeLists.txt | 2 + tests/depends/ge/src/ge_stub.cpp | 2 +- tests/depends/jpeg/CMakeLists.txt | 3 ++ tests/depends/mmpa/CMakeLists.txt | 2 + tests/depends/profiling/CMakeLists.txt | 2 + tests/depends/runtime/CMakeLists.txt | 3 ++ tests/depends/runtime/src/runtime_stub.cpp | 11 +++++ tests/depends/slog/CMakeLists.txt | 2 + tests/depends/tdt/CMakeLists.txt | 3 ++ tests/depends/toolchain/CMakeLists.txt | 2 + .../json/testEventMode/testEventMode_01.json | 5 +++ .../json/testEventMode/testEventMode_02.json | 5 +++ .../json/testEventMode/testEventMode_03.json | 4 ++ .../json/testEventMode/testEventMode_04.json | 5 +++ .../json/testEventMode/testEventMode_05.json | 5 +++ .../json/testEventMode/testEventMode_06.json | 5 +++ tests/ut/acl/testcase/acl_common_unittest.cpp | 42 ++++++++++++++++++- third_party/cann-graph-engine | 2 +- 30 files changed, 217 insertions(+), 37 deletions(-) create mode 100755 tests/ut/acl/json/testEventMode/testEventMode_01.json create mode 100755 tests/ut/acl/json/testEventMode/testEventMode_02.json create mode 100755 tests/ut/acl/json/testEventMode/testEventMode_03.json create mode 100755 tests/ut/acl/json/testEventMode/testEventMode_04.json create mode 100755 tests/ut/acl/json/testEventMode/testEventMode_05.json create mode 100755 tests/ut/acl/json/testEventMode/testEventMode_06.json diff --git a/CMakeLists.txt b/CMakeLists.txt index 58883a0f..3fe88058 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,6 +60,7 @@ if(ENABLE_OPEN_SRC) ${ASCEND_3RD_LIB_PATH}/symengine/lib/cmake/symengine ${ASCEND_3RD_LIB_PATH}/boost/lib/cmake/Boost-1.87.0 ${ASCEND_INSTALL_PATH} + ${ASCEND_INSTALL_PATH}/pkg_inc ${CMAKE_CURRENT_LIST_DIR}/third_party/inc ${CANN_GE_DIR}/inc/framework/executor_c ${ASCEND_OPENSDK_DIR}/cmake @@ -336,6 +337,7 @@ target_include_directories(ascendcl PRIVATE $<$:${ASCEND_INSTALL_PATH}/include/experiment/ascend_hal> $<$:${ASCEND_INSTALL_PATH}/include/experiment/msprof> $<$:${ASCEND_INSTALL_PATH}/include/experiment/slog> + $<$:${ASCEND_INSTALL_PATH}/include/experiment/runtime/runtime/rts> $<$:${METADEF_DIR}/inc> $<$:${CANN_GE_DIR}/inc> $<$:${CANN_GE_DIR}/inc/graph_metadef> diff --git a/cmake/modules/Findadump.cmake b/cmake/modules/Findadump.cmake index 1dcb6fa9..bbccb63e 100644 --- a/cmake/modules/Findadump.cmake +++ b/cmake/modules/Findadump.cmake @@ -43,16 +43,16 @@ unset(_cmake_targets_defined) unset(_cmake_targets_not_defined) unset(_cmake_expected_targets) -find_path(_INCLUDE_DIR - NAMES experiment/adump/external/adump_api.h - NO_CMAKE_SYSTEM_PATH - NO_CMAKE_FIND_ROOT_PATH) +find_path(_PKG_INC_DIR + NAMES adump/adump_pub.h + NO_CMAKE_SYSTEM_PATH + NO_CMAKE_FIND_ROOT_PATH) find_library(adump_server_STATIC_LIBRARY - NAMES libadump_server.a - PATH_SUFFIXES lib64 - NO_CMAKE_SYSTEM_PATH - NO_CMAKE_FIND_ROOT_PATH) + NAMES libadump_server.a + PATH_SUFFIXES lib64 + NO_CMAKE_SYSTEM_PATH + NO_CMAKE_FIND_ROOT_PATH) find_library(adcore_STATIC_LIBRARY NAMES libadcore.a @@ -71,17 +71,17 @@ find_package_handle_standard_args(adump FOUND_VAR adump_FOUND REQUIRED_VARS - _INCLUDE_DIR + _PKG_INC_DIR adump_server_STATIC_LIBRARY adcore_STATIC_LIBRARY ascend_dump_SHARED_LIBRARY ) if(adump_FOUND) - set(adump_INCLUDE_DIR "${_INCLUDE_DIR}/experiment") + set(adump_PKG_INC_DIR "${_PKG_INC_DIR}") include(CMakePrintHelpers) message(STATUS "Variables in adump module:") - cmake_print_variables(adump_INCLUDE_DIR) + cmake_print_variables(adump_PKG_INC_DIR) cmake_print_variables(adump_server_STATIC_LIBRARY) cmake_print_variables(adcore_STATIC_LIBRARY) cmake_print_variables(ascend_dump_SHARED_LIBRARY) @@ -94,7 +94,7 @@ if(adump_FOUND) add_library(adump_headers INTERFACE IMPORTED) set_target_properties(adump_headers PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${adump_INCLUDE_DIR};${adump_INCLUDE_DIR}/adump;${adump_INCLUDE_DIR}/adump/external" + INTERFACE_INCLUDE_DIRECTORIES "${adump_PKG_INC_DIR}/adump" ) add_library(adcore STATIC IMPORTED) @@ -126,4 +126,4 @@ if(adump_FOUND) endif() # Cleanup temporary variables. -set(_INCLUDE_DIR) +set(_PKG_INC_DIR) diff --git a/cmake/modules/Findmsprof.cmake b/cmake/modules/Findmsprof.cmake index 84d0cc05..a044f158 100644 --- a/cmake/modules/Findmsprof.cmake +++ b/cmake/modules/Findmsprof.cmake @@ -44,7 +44,7 @@ unset(_cmake_targets_not_defined) unset(_cmake_expected_targets) find_path(_INCLUDE_DIR - NAMES experiment/msprof/toolchain/prof_api.h + NAMES prof/aprof_pub.h NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH) @@ -71,7 +71,7 @@ find_package_handle_standard_args(msprof ) if(msprof_FOUND) - set(msprof_INCLUDE_DIR "${_INCLUDE_DIR}/experiment") + set(msprof_INCLUDE_DIR "${_INCLUDE_DIR}") include(CMakePrintHelpers) message(STATUS "Variables in msprof module:") cmake_print_variables(msprof_INCLUDE_DIR) @@ -92,7 +92,7 @@ if(msprof_FOUND) add_library(msprof_headers INTERFACE IMPORTED) set_target_properties(msprof_headers PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${msprof_INCLUDE_DIR};${msprof_INCLUDE_DIR}/msprof;${msprof_INCLUDE_DIR}/msprof/toolchain" + INTERFACE_INCLUDE_DIRECTORIES "${msprof_INCLUDE_DIR}/prof;${msprof_INCLUDE_DIR}/experiment;${msprof_INCLUDE_DIR}/experiment/msprof;${msprof_INCLUDE_DIR}/experiment/msprof/toolchain" ) include(CMakePrintHelpers) diff --git a/cmake/modules/Findopcompiler.cmake b/cmake/modules/Findopcompiler.cmake index 4eefb439..8b8c7d81 100644 --- a/cmake/modules/Findopcompiler.cmake +++ b/cmake/modules/Findopcompiler.cmake @@ -73,7 +73,7 @@ if(opcompiler_FOUND) add_library(te_fusion SHARED IMPORTED) set_target_properties(te_fusion PROPERTIES INTERFACE_LINK_LIBRARIES "opcompiler_headers" - IMPORTED_LINK_DEPENDENT_LIBRARIES "graph;register;slog;c_sec;error_manager;cann_kb" + IMPORTED_LINK_DEPENDENT_LIBRARIES "graph;register;slog;c_sec;error_manager" IMPORTED_LOCATION "${te_fusion_SHARED_LIBRARY}" ) diff --git a/cmake/modules/Findslog.cmake b/cmake/modules/Findslog.cmake index cf1ca521..d23d684a 100644 --- a/cmake/modules/Findslog.cmake +++ b/cmake/modules/Findslog.cmake @@ -15,7 +15,7 @@ endif() set(_cmake_targets_defined "") set(_cmake_targets_not_defined "") set(_cmake_expected_targets "") -foreach(_cmake_expected_target IN ITEMS slog alog slog_headers) +foreach(_cmake_expected_target IN ITEMS slog alog old_slog_headers) list(APPEND _cmake_expected_targets "${_cmake_expected_target}") if(TARGET "${_cmake_expected_target}") list(APPEND _cmake_targets_defined "${_cmake_expected_target}") @@ -81,19 +81,19 @@ if(slog_FOUND) add_library(slog SHARED IMPORTED) set_target_properties(slog PROPERTIES INTERFACE_COMPILE_DEFINITIONS "LOG_CPP;PROCESS_LOG" - INTERFACE_LINK_LIBRARIES "slog_headers" + INTERFACE_LINK_LIBRARIES "old_slog_headers" IMPORTED_LOCATION "${slog_SHARED_LIBRARY}" ) add_library(alog SHARED IMPORTED) set_target_properties(alog PROPERTIES INTERFACE_COMPILE_DEFINITIONS "LOG_CPP;PROCESS_LOG" - INTERFACE_LINK_LIBRARIES "slog_headers" + INTERFACE_LINK_LIBRARIES "old_slog_headers" IMPORTED_LOCATION "${alog_SHARED_LIBRARY}" ) - add_library(slog_headers INTERFACE IMPORTED) - set_target_properties(slog_headers PROPERTIES + add_library(old_slog_headers INTERFACE IMPORTED) + set_target_properties(old_slog_headers PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${slog_INCLUDE_DIR};${slog_INCLUDE_DIR}/slog;${slog_INCLUDE_DIR}/slog/toolchain" ) @@ -104,7 +104,7 @@ if(slog_FOUND) cmake_print_properties(TARGETS alog PROPERTIES INTERFACE_COMPILE_DEFINITIONS INTERFACE_LINK_LIBRARIES IMPORTED_LOCATION ) - cmake_print_properties(TARGETS slog_headers + cmake_print_properties(TARGETS old_slog_headers PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ) endif() diff --git a/cmake/modules/Findunified_dlog.cmake b/cmake/modules/Findunified_dlog.cmake index 4d19cff1..260d511e 100644 --- a/cmake/modules/Findunified_dlog.cmake +++ b/cmake/modules/Findunified_dlog.cmake @@ -15,7 +15,7 @@ endif() set(_cmake_targets_defined "") set(_cmake_targets_not_defined "") set(_cmake_expected_targets "") -foreach(_cmake_expected_target IN ITEMS unified_dlog unified_dlog_headers) +foreach(_cmake_expected_target IN ITEMS unified_dlog slog_headers) list(APPEND _cmake_expected_targets "${_cmake_expected_target}") if(TARGET "${_cmake_expected_target}") list(APPEND _cmake_targets_defined "${_cmake_expected_target}") @@ -43,8 +43,9 @@ unset(_cmake_targets_defined) unset(_cmake_targets_not_defined) unset(_cmake_expected_targets) -find_path(_INCLUDE_DIR - NAMES base/dlog_pub.h +find_path(_INCLUDE_DIR_DLOG_PUB + NAMES dlog_pub.h + PATH_SUFFIXES pkg_inc/base NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH) @@ -59,12 +60,12 @@ find_package_handle_standard_args(unified_dlog FOUND_VAR unified_dlog_FOUND REQUIRED_VARS - _INCLUDE_DIR + _INCLUDE_DIR_DLOG_PUB unified_dlog_SHARED_LIBRARY ) if(unified_dlog_FOUND) - set(unified_dlog_INCLUDE_DIR "${_INCLUDE_DIR}") + set(unified_dlog_INCLUDE_DIR "${_INCLUDE_DIR_DLOG_PUB}") include(CMakePrintHelpers) message(STATUS "Variables in unified_dlog module:") cmake_print_variables(unified_dlog_INCLUDE_DIR) @@ -72,12 +73,12 @@ if(unified_dlog_FOUND) add_library(unified_dlog SHARED IMPORTED) set_target_properties(unified_dlog PROPERTIES - INTERFACE_LINK_LIBRARIES "unified_dlog_headers" + INTERFACE_LINK_LIBRARIES "slog_headers" IMPORTED_LOCATION "${unified_dlog_SHARED_LIBRARY}" ) - add_library(unified_dlog_headers INTERFACE IMPORTED) - set_target_properties(unified_dlog_headers PROPERTIES + add_library(slog_headers INTERFACE IMPORTED) + set_target_properties(slog_headers PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${unified_dlog_INCLUDE_DIR}" ) @@ -85,10 +86,10 @@ if(unified_dlog_FOUND) cmake_print_properties(TARGETS unified_dlog PROPERTIES INTERFACE_LINK_LIBRARIES IMPORTED_LOCATION ) - cmake_print_properties(TARGETS unified_dlog_headers + cmake_print_properties(TARGETS slog_headers PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ) endif() # Cleanup temporary variables. -set(_INCLUDE_DIR) \ No newline at end of file +set(_INCLUDE_DIR_DLOG_PUB) \ No newline at end of file diff --git a/common/acl.cpp b/common/acl.cpp index a1eff44f..ec5261ed 100755 --- a/common/acl.cpp +++ b/common/acl.cpp @@ -28,6 +28,9 @@ #include "utils/hash_utils.h" #include "runtime/acl_rt_impl_base.h" #include "runtime/init_callback_manager.h" +#include "runtime/rts/rts_device.h" +#include "runtime/rts/rts_stars.h" +#include "runtime/event.h" namespace { bool aclFinalizeFlag = false; @@ -174,6 +177,27 @@ aclError HandleErrorManagerConfig(const char_t *const configPath, error_message: return ACL_SUCCESS; } +aclError HandleEventModeConfig(const char_t *const configPath) { + ACL_LOG_INFO("Start to execute HandleEventModeConfig, configPath:[%s].", configPath); + std::string strConfig; + uint8_t event_mode = 0; + bool found = false; + + auto ret = acl::JsonParser::GetEventModeFromFile(configPath, event_mode, found); + if (ret != ACL_SUCCESS) { + ACL_LOG_ERROR("Can not parse event mode config from file[%s], errorCode = %d", configPath, ret); + return ret; + } + if (!found) { + ACL_LOG_INFO("Event mode config is not found in file[%s].", configPath); + return ACL_SUCCESS; + } + ACL_LOG_INFO("event mode is set [%d].", event_mode); + ACL_REQUIRES_CALL_RTS_OK(rtEventWorkModeSet(event_mode), rtEventWorkModeSet); + ACL_LOG_INFO("Successfully handled event mode config."); + return ACL_SUCCESS; +} + aclError HandleDefaultDeviceAndStackSize(const char_t *const configPath) { size_t stackSize = 0; bool stackSizeExist = false; @@ -315,6 +339,12 @@ aclError aclInit(const char *configPath) return ret; } ACL_LOG_INFO("set HandleDefaultDeviceAndStackSize success in aclInit"); + + ret = acl::HandleEventModeConfig(configPath); + if (ret != ACL_SUCCESS) { + ACL_LOG_INNER_ERROR("[Process][EventMode]process HandleEventModeConfig failed, ret=%d", ret); + return ret; + } } const auto profRet = MsprofRegisterCallback(ASCENDCL, &acl::AclProfCtrlHandle); if (profRet != 0) { diff --git a/common/common_inner.h b/common/common_inner.h index 91ec1629..ecb72338 100755 --- a/common/common_inner.h +++ b/common/common_inner.h @@ -42,6 +42,8 @@ namespace acl { int32_t UpdateOpSystemRunCfg(void *cfgAddr, uint32_t cfgLen); + aclError HandleEventModeConfig(const char_t *const configPath); + aclError HandleDefaultDeviceAndStackSize(const char_t *const configPath); aclError GetAlignedAndPaddingSize(const size_t size, const bool isPadding, size_t &alignedSize); diff --git a/common/json_parser.cpp b/common/json_parser.cpp index 61b0b756..29f0b93c 100755 --- a/common/json_parser.cpp +++ b/common/json_parser.cpp @@ -295,6 +295,46 @@ namespace acl { return ACL_SUCCESS; } + aclError JsonParser::GetEventModeFromFile(const char_t *const fileName, uint8_t &event_mode, bool &found) + { + nlohmann::json js; + std::string eventModeStr; + aclError ret = acl::JsonParser::ParseJsonFromFile(fileName, js); + if (ret != ACL_SUCCESS) { + ACL_LOG_INNER_ERROR("[Parse][JsonFromFile]parse json from file[%s] failed, errorCode = %d", fileName, ret); + return ret; + } + const std::string ACL_GRAPH_CONFIG_NAME = "acl_graph"; + const std::string ACL_EVENT_MODE_CONFIG_NAME = "event_mode"; + + if (!JsonParser::ContainKey(js, ACL_GRAPH_CONFIG_NAME)) { + ACL_LOG_INFO("No acl_graph in json file!"); + return ACL_SUCCESS; + } + const nlohmann::json &jsAclGraphConfig = JsonParser::GetCfgJsonByKey(js, ACL_GRAPH_CONFIG_NAME); + if (!JsonParser::ContainKey(jsAclGraphConfig, ACL_EVENT_MODE_CONFIG_NAME)) { + ACL_LOG_INFO("No event_mode under acl_graph in json file!"); + return ACL_SUCCESS; + } + eventModeStr = JsonParser::GetCfgStrByKey(jsAclGraphConfig, ACL_EVENT_MODE_CONFIG_NAME); + + // 校验 event_mode 是否为合法整数,只允许 0 或 1 + std::regex reg("0|1"); + if (!std::regex_match(eventModeStr, reg)) { + ACL_LOG_ERROR("event_mode value [%s] in json is not a valid integer.", eventModeStr.c_str()); + const char_t *argList[] = {"param", "value", "reason"}; + const char_t *argVal[] = {"event_mode", eventModeStr.c_str(), "only support [0,1]"}; + acl::AclErrorLogManager::ReportInputErrorWithChar(acl::INVALID_PARAM_MSG, + argList, argVal, 3U); + return ACL_ERROR_INVALID_PARAM; + } + + event_mode = static_cast(std::strtol(eventModeStr.c_str(), nullptr, DECIMAL)); + found = true; + ACL_LOG_INFO("Successfully parse event_mode: %d, event_mode_str: %s", event_mode, eventModeStr.c_str()); + return ACL_SUCCESS; + } + aclError JsonParser::GetStackSize(const char_t *const fileName, size_t &aicoreStackSize, bool &exist) { ACL_LOG_DEBUG("start to execute GetStackSize."); diff --git a/common/json_parser.h b/common/json_parser.h index fc93717e..0ecd069a 100755 --- a/common/json_parser.h +++ b/common/json_parser.h @@ -25,6 +25,7 @@ namespace acl { static aclError GetAttrConfigFromFile( const char_t *const fileName, std::map &cannInfoMap); static aclError GetDefaultDeviceIdFromFile(const char_t *const fileName, int32_t& devId); + static aclError GetEventModeFromFile(const char_t *const fileName, uint8_t &event_mode, bool &found); static aclError GetStackSize(const char_t *const fileName, size_t &aicoreStackSize, bool &exist); static aclError ParseJson(const char_t *const buffer, nlohmann::json &js); static aclError GetConfigStrFromFile(const char_t *const fileName, std::string &configBuffer); diff --git a/tests/depends/acl_stub.h b/tests/depends/acl_stub.h index cf3139db..a2677315 100755 --- a/tests/depends/acl_stub.h +++ b/tests/depends/acl_stub.h @@ -26,7 +26,7 @@ #include "graph/tensor.h" #include "common/helper/om_file_helper.h" #include "platform/platform_info.h" -#include "base/err_msg.h" +#include "base/err_mgr.h" #include "tdt/tdt_host_interface.h" #include "runtime/dev.h" @@ -421,6 +421,7 @@ public: virtual rtError_t rtMemQueueReset(int32_t devId, uint32_t qid); virtual rtError_t rtSetDefaultDeviceId(int32_t deviceId); virtual rtError_t rtDeviceSetLimit(int32_t devId, rtLimitType_t type, uint32_t val); + virtual rtError_t rtEventWorkModeSet(uint8_t event_mode); virtual rtError_t rtRegStreamStateCallback(const char *regName, rtStreamStateCallback callback); virtual rtError_t rtCtxGetCurrentDefaultStream(rtStream_t* stm); virtual rtError_t rtCmoAsync(void *srcAddrPtr, size_t srcLen, rtCmoOpCode_t cmpType, rtStream_t stm); @@ -746,6 +747,7 @@ public: MOCK_METHOD1(rtSetDevice, rtError_t(int32_t device)); MOCK_METHOD1(rtSetDefaultDeviceId, rtError_t(int32_t device)); MOCK_METHOD3(rtDeviceSetLimit, rtError_t(int32_t devId, rtLimitType_t type, uint32_t val)); + MOCK_METHOD1(rtEventWorkModeSet, rtError_t(uint8_t event_mode)); MOCK_METHOD1(rtDeviceReset, rtError_t(int32_t device)); MOCK_METHOD1(rtDeviceResetForce, rtError_t(int32_t device)); MOCK_METHOD1(rtSetDeviceWithoutTsd, rtError_t(int32_t device)); diff --git a/tests/depends/dvpp/CMakeLists.txt b/tests/depends/dvpp/CMakeLists.txt index ea79c573..13443f5a 100755 --- a/tests/depends/dvpp/CMakeLists.txt +++ b/tests/depends/dvpp/CMakeLists.txt @@ -40,6 +40,9 @@ include_directories(${CANN_GE_DIR}/inc) include_directories(${ASCEND_INSTALL_PATH}/include/experiment/adump/external) include_directories(${BASE_DIR}/third_party/inc/dvpp/inc/dvpp) include_directories(${ASCEND_INSTALL_PATH}/include/acl/dvpp) +include_directories(${ASCEND_INSTALL_PATH}/include/prof) +include_directories(${ASCEND_INSTALL_PATH}/pkg_inc) +include_directories(${ASCEND_INSTALL_PATH}/pkg_inc/base) add_library(himpi_stub SHARED ${SRC_FILES}) diff --git a/tests/depends/ge/CMakeLists.txt b/tests/depends/ge/CMakeLists.txt index 553c866d..d3f9ac42 100755 --- a/tests/depends/ge/CMakeLists.txt +++ b/tests/depends/ge/CMakeLists.txt @@ -27,6 +27,8 @@ include_directories(${ASCEND_OPENSDK_DIR}/include/runtime/runtime) include_directories(${ASCEND_INSTALL_PATH}/include/experiment/slog) include_directories(${ASCEND_INSTALL_PATH}/include/experiment/msprof) include_directories(${ASCEND_INSTALL_PATH}/include/prof) +include_directories(${ASCEND_INSTALL_PATH}/pkg_inc) +include_directories(${ASCEND_INSTALL_PATH}/pkg_inc/base) include_directories(${BASE_DIR}/third_party/inc) include_directories(${CANN_GE_DIR}/inc) include_directories(${CANN_GE_DIR}/inc/graph_metadef) diff --git a/tests/depends/ge/src/ge_stub.cpp b/tests/depends/ge/src/ge_stub.cpp index aee26e7b..1b010229 100755 --- a/tests/depends/ge/src/ge_stub.cpp +++ b/tests/depends/ge/src/ge_stub.cpp @@ -55,7 +55,7 @@ #include "acl_stub.h" #include "framework/runtime/subscriber/global_profiler.h" #include "platform/platform_info.h" -#include "base/err_msg.h" +#include "base/err_mgr.h" #include "nlohmann/json.hpp" using namespace ge; diff --git a/tests/depends/jpeg/CMakeLists.txt b/tests/depends/jpeg/CMakeLists.txt index 83467312..4383c09d 100644 --- a/tests/depends/jpeg/CMakeLists.txt +++ b/tests/depends/jpeg/CMakeLists.txt @@ -41,6 +41,9 @@ include_directories(${CMAKE_BINARY_DIR}/proto/acl/) include_directories(${ASCEND_INSTALL_PATH}/include/experiment/adump/external) include_directories(${BASE_DIR}/third_party/inc/dvpp/inc/dvpp) include_directories(${ASCEND_INSTALL_PATH}/include/acl/dvpp) +include_directories(${ASCEND_INSTALL_PATH}/include/prof) +include_directories(${ASCEND_INSTALL_PATH}/pkg_inc) +include_directories(${ASCEND_INSTALL_PATH}/pkg_inc/base) add_library(jpeg_stub SHARED ${SRC_FILES}) diff --git a/tests/depends/mmpa/CMakeLists.txt b/tests/depends/mmpa/CMakeLists.txt index 1b6c58d3..29581092 100755 --- a/tests/depends/mmpa/CMakeLists.txt +++ b/tests/depends/mmpa/CMakeLists.txt @@ -41,6 +41,8 @@ include_directories(${BASE_DIR}/tests/depends/) include_directories(${ASCEND_INSTALL_PATH}/include/experiment/adump/external) include_directories(${BASE_DIR}/third_party/inc/dvpp/inc/dvpp) include_directories(${ASCEND_INSTALL_PATH}/include/acl/dvpp) +include_directories(${ASCEND_INSTALL_PATH}/pkg_inc) +include_directories(${ASCEND_INSTALL_PATH}/pkg_inc/base) add_library(mmpa_stub SHARED ${SRC_FILES}) diff --git a/tests/depends/profiling/CMakeLists.txt b/tests/depends/profiling/CMakeLists.txt index 83087876..b24a355f 100755 --- a/tests/depends/profiling/CMakeLists.txt +++ b/tests/depends/profiling/CMakeLists.txt @@ -26,6 +26,8 @@ include_directories(${ASCEND_OPENSDK_DIR}/include/runtime/runtime) include_directories(${ASCEND_INSTALL_PATH}/include/experiment/slog) include_directories(${ASCEND_INSTALL_PATH}/include/experiment/msprof) include_directories(${ASCEND_INSTALL_PATH}/include/prof) +include_directories(${ASCEND_INSTALL_PATH}/pkg_inc) +include_directories(${ASCEND_INSTALL_PATH}/pkg_inc/base) include_directories(${BASE_DIR}/inc/external) include_directories(${BASE_DIR}/third_party/inc) include_directories(${BASE_DIR}/third_party/inc/runtime/external) diff --git a/tests/depends/runtime/CMakeLists.txt b/tests/depends/runtime/CMakeLists.txt index e611572f..4fc2e852 100755 --- a/tests/depends/runtime/CMakeLists.txt +++ b/tests/depends/runtime/CMakeLists.txt @@ -41,6 +41,9 @@ include_directories(${ASCEND_INSTALL_PATH}/include/experiment/adump/external) include_directories(${BASE_DIR}/tests/depends/) include_directories(${BASE_DIR}/third_party/inc/dvpp/inc/dvpp) include_directories(${ASCEND_INSTALL_PATH}/include/acl/dvpp) +include_directories(${ASCEND_INSTALL_PATH}/include/prof) +include_directories(${ASCEND_INSTALL_PATH}/pkg_inc) +include_directories(${ASCEND_INSTALL_PATH}/pkg_inc/base) add_library(runtime_stub SHARED ${SRC_FILES}) diff --git a/tests/depends/runtime/src/runtime_stub.cpp b/tests/depends/runtime/src/runtime_stub.cpp index ce28625b..59f8fa8b 100755 --- a/tests/depends/runtime/src/runtime_stub.cpp +++ b/tests/depends/runtime/src/runtime_stub.cpp @@ -984,6 +984,12 @@ rtError_t aclStub::rtDeviceSetLimit(int32_t devId, rtLimitType_t type, uint32_t return RT_ERROR_NONE; } +rtError_t aclStub::rtEventWorkModeSet(uint8_t event_mode) +{ + (void)event_mode; + return RT_ERROR_NONE; +} + rtError_t aclStub::rtRegStreamStateCallback(const char *regName, rtStreamStateCallback callback) { (void)regName; @@ -2688,6 +2694,11 @@ rtError_t rtDeviceSetLimit(int32_t devId, rtLimitType_t type, uint32_t val) return MockFunctionTest::aclStubInstance().rtDeviceSetLimit(devId, type, val); } +rtError_t rtEventWorkModeSet(uint8_t event_mode) +{ + return MockFunctionTest::aclStubInstance().rtEventWorkModeSet(event_mode); +} + rtError_t rtRegStreamStateCallback(const char *regName, rtStreamStateCallback callback) { return MockFunctionTest::aclStubInstance().rtRegStreamStateCallback(regName, callback); diff --git a/tests/depends/slog/CMakeLists.txt b/tests/depends/slog/CMakeLists.txt index a9a5d77a..b144eaa6 100755 --- a/tests/depends/slog/CMakeLists.txt +++ b/tests/depends/slog/CMakeLists.txt @@ -40,6 +40,8 @@ include_directories(${CANN_GE_DIR}/inc/graph_metadef/graph/utils) include_directories(${ASCEND_INSTALL_PATH}/include/experiment/adump/external) include_directories(${BASE_DIR}/third_party/inc/dvpp/inc/dvpp) include_directories(${ASCEND_INSTALL_PATH}/include/acl/dvpp) +include_directories(${ASCEND_INSTALL_PATH}/include/prof) +include_directories(${ASCEND_INSTALL_PATH}/pkg_inc) include_directories(${ASCEND_INSTALL_PATH}/pkg_inc/base) add_library(slog_stub SHARED ${SRC_FILES}) diff --git a/tests/depends/tdt/CMakeLists.txt b/tests/depends/tdt/CMakeLists.txt index 4dbe83c6..fb37e407 100755 --- a/tests/depends/tdt/CMakeLists.txt +++ b/tests/depends/tdt/CMakeLists.txt @@ -40,6 +40,9 @@ include_directories(${ASCEND_INSTALL_PATH}/include/experiment/adump/external) include_directories(${BASE_DIR}/tests/depends/) include_directories(${BASE_DIR}/third_party/inc/dvpp/inc/dvpp) include_directories(${ASCEND_INSTALL_PATH}/include/acl/dvpp) +include_directories(${ASCEND_INSTALL_PATH}/include/prof) +include_directories(${ASCEND_INSTALL_PATH}/pkg_inc) +include_directories(${ASCEND_INSTALL_PATH}/pkg_inc/base) add_library(tdt_stub SHARED ${SRC_FILES}) diff --git a/tests/depends/toolchain/CMakeLists.txt b/tests/depends/toolchain/CMakeLists.txt index fe106894..0964a111 100755 --- a/tests/depends/toolchain/CMakeLists.txt +++ b/tests/depends/toolchain/CMakeLists.txt @@ -42,6 +42,8 @@ include_directories(${ASCEND_INSTALL_PATH}/include/experiment/adump/external) include_directories(${BASE_DIR}/third_party/inc/dvpp/inc/dvpp) include_directories(${ASCEND_INSTALL_PATH}/include/acl/dvpp) include_directories(${ASCEND_INSTALL_PATH}/include/experiment/awatchdog) +include_directories(${ASCEND_INSTALL_PATH}/include/prof) +include_directories(${ASCEND_INSTALL_PATH}/pkg_inc) include_directories(${ASCEND_INSTALL_PATH}/pkg_inc/base) add_library(toolchain_stub SHARED ${SRC_FILES}) diff --git a/tests/ut/acl/json/testEventMode/testEventMode_01.json b/tests/ut/acl/json/testEventMode/testEventMode_01.json new file mode 100755 index 00000000..beba4cbe --- /dev/null +++ b/tests/ut/acl/json/testEventMode/testEventMode_01.json @@ -0,0 +1,5 @@ +{ + "acl_graph":{ + "event_mode":"0" + } +} \ No newline at end of file diff --git a/tests/ut/acl/json/testEventMode/testEventMode_02.json b/tests/ut/acl/json/testEventMode/testEventMode_02.json new file mode 100755 index 00000000..872f3bd4 --- /dev/null +++ b/tests/ut/acl/json/testEventMode/testEventMode_02.json @@ -0,0 +1,5 @@ +{ + "acl_graph":{ + "event_mode":"1" + } +} \ No newline at end of file diff --git a/tests/ut/acl/json/testEventMode/testEventMode_03.json b/tests/ut/acl/json/testEventMode/testEventMode_03.json new file mode 100755 index 00000000..78cc852d --- /dev/null +++ b/tests/ut/acl/json/testEventMode/testEventMode_03.json @@ -0,0 +1,4 @@ +{ + "acl_graph":{ + "event_mode":"0" + } diff --git a/tests/ut/acl/json/testEventMode/testEventMode_04.json b/tests/ut/acl/json/testEventMode/testEventMode_04.json new file mode 100755 index 00000000..a9e8e80b --- /dev/null +++ b/tests/ut/acl/json/testEventMode/testEventMode_04.json @@ -0,0 +1,5 @@ +{ + "acl_graph1":{ + "event_mode":"0" + } +} \ No newline at end of file diff --git a/tests/ut/acl/json/testEventMode/testEventMode_05.json b/tests/ut/acl/json/testEventMode/testEventMode_05.json new file mode 100755 index 00000000..88cd882a --- /dev/null +++ b/tests/ut/acl/json/testEventMode/testEventMode_05.json @@ -0,0 +1,5 @@ +{ + "acl_graph":{ + "event_mode1":"0" + } +} \ No newline at end of file diff --git a/tests/ut/acl/json/testEventMode/testEventMode_06.json b/tests/ut/acl/json/testEventMode/testEventMode_06.json new file mode 100755 index 00000000..413644a1 --- /dev/null +++ b/tests/ut/acl/json/testEventMode/testEventMode_06.json @@ -0,0 +1,5 @@ +{ + "acl_graph":{ + "event_mode":"2" + } +} \ No newline at end of file diff --git a/tests/ut/acl/testcase/acl_common_unittest.cpp b/tests/ut/acl/testcase/acl_common_unittest.cpp index e8af1d33..b262cc24 100755 --- a/tests/ut/acl/testcase/acl_common_unittest.cpp +++ b/tests/ut/acl/testcase/acl_common_unittest.cpp @@ -25,7 +25,7 @@ #include "utils/hash_utils.h" #include "framework/executor/ge_executor.h" -#include "base/err_msg.h" +#include "base/err_mgr.h" #define protected public #define private public @@ -189,6 +189,46 @@ TEST_F(UTEST_ACL_Common, SetDefaultDeviceTest) EXPECT_EQ(ret, ACL_ERROR_RT_STREAM_NO_CB_REG); } +TEST_F(UTEST_ACL_Common, SetEventModeTest) +{ + EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtSetDefaultDeviceId(_)) + .WillRepeatedly(Return(ACL_SUCCESS)); + + aclError ret = aclInit(ACL_BASE_DIR "/tests/ut/acl/json/testEventMode/testEventMode_01.json"); + EXPECT_EQ(ret, ACL_SUCCESS); + ret = aclFinalize(); + EXPECT_EQ(ret, ACL_SUCCESS); + resetAclJsonHash(); + + ret = aclInit(ACL_BASE_DIR "/tests/ut/acl/json/testEventMode/testEventMode_02.json"); + EXPECT_EQ(ret, ACL_SUCCESS); + ret = aclFinalize(); + EXPECT_EQ(ret, ACL_SUCCESS); + resetAclJsonHash(); + + ret = aclInit(ACL_BASE_DIR "/tests/ut/acl/json/testEventMode/testEventMode_03.json"); // 格式错误 + EXPECT_EQ(ret, ACL_ERROR_PARSE_FILE); + + ret = aclInit(ACL_BASE_DIR "/tests/ut/acl/json/testEventMode/testEventMode_04.json"); // 不包含acl_graph + EXPECT_EQ(ret, ACL_SUCCESS); + ret = aclFinalize(); + EXPECT_EQ(ret, ACL_SUCCESS); + resetAclJsonHash(); + + ret = aclInit(ACL_BASE_DIR "/tests/ut/acl/json/testEventMode/testEventMode_05.json"); // 不包含event_mode + EXPECT_EQ(ret, ACL_SUCCESS); + ret = aclFinalize(); + EXPECT_EQ(ret, ACL_SUCCESS); + resetAclJsonHash(); + + ret = aclInit(ACL_BASE_DIR "/tests/ut/acl/json/testEventMode/testEventMode_06.json"); // event_mode参数非法 + EXPECT_EQ(ret, ACL_ERROR_INVALID_PARAM); + resetAclJsonHash(); + + ret = HandleEventModeConfig("testEventMode_not_exist.json"); + EXPECT_EQ(ret, ACL_ERROR_INVALID_FILE); +} + TEST_F(UTEST_ACL_Common, SetStackSize) { // stack size 32k diff --git a/third_party/cann-graph-engine b/third_party/cann-graph-engine index f15250ed..c6091b70 160000 --- a/third_party/cann-graph-engine +++ b/third_party/cann-graph-engine @@ -1 +1 @@ -Subproject commit f15250ed4eae9ce6bb910556b293e57c65077757 +Subproject commit c6091b70e00fe01fb797a248c88f7dfe37662b87 -- Gitee From ca92404514b30886d38304983c317b2580f603ff Mon Sep 17 00:00:00 2001 From: ZhouChen Date: Fri, 14 Nov 2025 14:23:30 +0800 Subject: [PATCH 2/2] set event mode --- tests/ut/acl/testcase/acl_common_unittest.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/ut/acl/testcase/acl_common_unittest.cpp b/tests/ut/acl/testcase/acl_common_unittest.cpp index b262cc24..32a3158d 100755 --- a/tests/ut/acl/testcase/acl_common_unittest.cpp +++ b/tests/ut/acl/testcase/acl_common_unittest.cpp @@ -193,7 +193,6 @@ TEST_F(UTEST_ACL_Common, SetEventModeTest) { EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtSetDefaultDeviceId(_)) .WillRepeatedly(Return(ACL_SUCCESS)); - aclError ret = aclInit(ACL_BASE_DIR "/tests/ut/acl/json/testEventMode/testEventMode_01.json"); EXPECT_EQ(ret, ACL_SUCCESS); ret = aclFinalize(); -- Gitee