From b4b4577b85dda76ac141859cb36c4bae6abdb031 Mon Sep 17 00:00:00 2001 From: ms_yan <6576637+ms_yan@user.noreply.gitee.com> Date: Tue, 2 Mar 2021 13:02:10 +0800 Subject: [PATCH] adapter profiling with new ascend lib --- mindspore/ccsrc/CMakeLists.txt | 5 ++- .../profiling/profiling_callback_register.cc | 42 +++++++++++++++++-- tests/ut/cpp/stub/profiling/profiling_stub.cc | 2 +- 3 files changed, 43 insertions(+), 6 deletions(-) diff --git a/mindspore/ccsrc/CMakeLists.txt b/mindspore/ccsrc/CMakeLists.txt index eb8283efd4..96c595a8a3 100644 --- a/mindspore/ccsrc/CMakeLists.txt +++ b/mindspore/ccsrc/CMakeLists.txt @@ -285,7 +285,8 @@ if(ENABLE_D) ${ASCEND_DRIVER_BACK_PATH}) find_library(DATATRANSFER datatransfer HINTS ${ASCEND_RUNTIME_PATH} ${ASCEND_TOOLKIT_RUNTIME_PATH} ${ASCEND_DRIVER_BACK_PATH}) - find_library(PROFILING msprofiler_fwk ${ASCEND_RUNTIME_PATH} ${ASCEND_TOOLKIT_RUNTIME_PATH}) + find_library(PROFILING msprofiler_fwkacl ${ASCEND_RUNTIME_PATH} ${ASCEND_TOOLKIT_RUNTIME_PATH}) + find_library(ACL ascendcl ${ASCEND_RUNTIME_PATH} ${ASCEND_TOOLKIT_RUNTIME_PATH}) find_library(REGISTER register ${ASCEND_RUNTIME_PATH} ${ASCEND_TOOLKIT_RUNTIME_PATH}) find_library(PLATFORM platform ${ASCEND_RUNTIME_PATH} ${ASCEND_TOOLKIT_RUNTIME_PATH}) find_library(OPTILING optiling ${ASCEND_OPP_PATH} ${ASCEND_TOOLKIT_OPP_PATH}) @@ -303,7 +304,7 @@ if(ENABLE_D) mindspore::protobuf -Wl,--end-group) target_link_libraries(mindspore ge_runtime ${CCE_LIB} ${RUNTIME_LIB} ${TSDCLIENT} ${HCCL} ${DATATRANSFER} ${HCCL_ADPTER} ${REGISTER} -Wl,--no-as-needed ${OPTILING} ${HCCL_BUILDER} - ${HCCL_RA} ${PLATFORM}) + ${HCCL_RA} ${PLATFORM} ${ACL}) target_link_libraries(mindspore -Wl,--start-group proto_input mindspore::protobuf -Wl,--end-group) elseif(CMAKE_SYSTEM_NAME MATCHES "Windows") target_link_libraries(mindspore -Wl,--start-group proto_input mindspore::protobuf mindspore::sentencepiece diff --git a/mindspore/ccsrc/runtime/device/ascend/profiling/profiling_callback_register.cc b/mindspore/ccsrc/runtime/device/ascend/profiling/profiling_callback_register.cc index c4056ab84b..1a821e3b7a 100644 --- a/mindspore/ccsrc/runtime/device/ascend/profiling/profiling_callback_register.cc +++ b/mindspore/ccsrc/runtime/device/ascend/profiling/profiling_callback_register.cc @@ -19,9 +19,9 @@ namespace Analysis { namespace Dvvp { -namespace ProfilerCommon { +namespace ProfilerSpecial { extern int32_t MsprofilerInit(); -} // namespace ProfilerCommon +} // namespace ProfilerSpecial } // namespace Dvvp } // namespace Analysis @@ -30,6 +30,42 @@ constexpr Status PROF_SUCCESS = 0; constexpr Status PROF_FAILED = 0xFFFFFFFF; } // namespace +int32_t _aclprofGetDeviceByModelId(uint32_t modelId, uint32_t &deviceId) { return 0; } + +bool _aclprofGetInitFlag() { return true; } + +int32_t _aclprofRegisterCtrlCallback(MsprofCtrlCallback callback) { + if (VMCallbackRegister::GetInstance().registered()) { + return VMCallbackRegister::GetInstance().DoRegProfCtrlCallback(callback); + } else { + return PROF_SUCCESS; + } +} + +int32_t _aclprofRegisterSetDeviceCallback(MsprofSetDeviceCallback callback) { + if (VMCallbackRegister::GetInstance().registered()) { + return VMCallbackRegister::GetInstance().DoRegProfSetDeviceCallback(callback); + } else { + return PROF_SUCCESS; + } +} + +int32_t _aclprofRegisterReporterCallback(MsprofReporterCallback callback) { + if (VMCallbackRegister::GetInstance().registered()) { + return VMCallbackRegister::GetInstance().DoRegProfReporterCallback(callback); + } else { + return PROF_SUCCESS; + } +} + +int32_t _aclprofCommandHandle(uint32_t type, void *data, uint32_t len) { + if (VMCallbackRegister::GetInstance().registered()) { + return VMCallbackRegister::GetInstance().DoProfCommandHandle((ProfCommandHandleType)type, data, len); + } else { + return PROF_SUCCESS; + } +} + Status RegProfCtrlCallback(MsprofCtrlCallback func) { if (VMCallbackRegister::GetInstance().registered()) { return VMCallbackRegister::GetInstance().DoRegProfCtrlCallback(func); @@ -87,7 +123,7 @@ bool VMCallbackRegister::Register(Status (*pRegProfCtrlCallback)(MsprofCtrlCallb void VMCallbackRegister::ForceMsprofilerInit() { if (!ms_profile_inited_) { - Analysis::Dvvp::ProfilerCommon::MsprofilerInit(); + Analysis::Dvvp::ProfilerSpecial::MsprofilerInit(); ms_profile_inited_ = true; } } diff --git a/tests/ut/cpp/stub/profiling/profiling_stub.cc b/tests/ut/cpp/stub/profiling/profiling_stub.cc index 86df5facde..6678225390 100644 --- a/tests/ut/cpp/stub/profiling/profiling_stub.cc +++ b/tests/ut/cpp/stub/profiling/profiling_stub.cc @@ -51,6 +51,6 @@ void* ProfMgrStartUp(const ProfMgrCfg* cfg) { return const_cast(reinterpr */ int ProfMgrStop(void* handle) { return 0; } -namespace Analysis::Dvvp::ProfilerCommon { +namespace Analysis::Dvvp::ProfilerSpecial { uint32_t MsprofilerInit() { return 0; } }