| @@ -84,14 +84,12 @@ else () | |||||
| set(STATIC_ACL_LIB ${GE_LIB_PATH}) | set(STATIC_ACL_LIB ${GE_LIB_PATH}) | ||||
| find_module(slog libalog.so ${GE_LIB_PATH}) | find_module(slog libalog.so ${GE_LIB_PATH}) | ||||
| find_module(static_mmpa libmmpa.a ${GE_LIB_PATH}) | find_module(static_mmpa libmmpa.a ${GE_LIB_PATH}) | ||||
| find_module(msprofiler_ext libmsprofiler.a ${GE_LIB_PATH}) | |||||
| find_module(hccl libhccl.so ${GE_LIB_PATH}) | find_module(hccl libhccl.so ${GE_LIB_PATH}) | ||||
| find_module(adump_server libadump_server.a ${GE_LIB_PATH}) | find_module(adump_server libadump_server.a ${GE_LIB_PATH}) | ||||
| find_module(runtime libruntime.so ${GE_LIB_PATH}) | find_module(runtime libruntime.so ${GE_LIB_PATH}) | ||||
| find_module(runtime_compile libruntime_compile.so ${GE_LIB_PATH}) | find_module(runtime_compile libruntime_compile.so ${GE_LIB_PATH}) | ||||
| find_module(resource libresource.so ${GE_LIB_PATH}) | find_module(resource libresource.so ${GE_LIB_PATH}) | ||||
| find_module(ascend_hal_stub libascend_hal.so ${GE_LIB_PATH}) | find_module(ascend_hal_stub libascend_hal.so ${GE_LIB_PATH}) | ||||
| find_module(msprofiler_fwk_ext libmsprofiler_fwk.a ${GE_LIB_PATH}) | |||||
| #find_module(ascendcl_static libascendcl.a ${GE_LIB_PATH}) | #find_module(ascendcl_static libascendcl.a ${GE_LIB_PATH}) | ||||
| else() | else() | ||||
| find_module(slog libalog.so ${ASCEND_ATC_DIR}) | find_module(slog libalog.so ${ASCEND_ATC_DIR}) | ||||
| @@ -100,7 +98,6 @@ else () | |||||
| if(PLATFORM STREQUAL "train") | if(PLATFORM STREQUAL "train") | ||||
| find_module(adump_server libadump_server.a ${ASCEND_RUNTIME_DIR}) | find_module(adump_server libadump_server.a ${ASCEND_RUNTIME_DIR}) | ||||
| find_module(runtime libruntime.so ${ASCEND_RUNTIME_DIR}) | find_module(runtime libruntime.so ${ASCEND_RUNTIME_DIR}) | ||||
| find_module(msprofiler_fwk_ext libmsprofiler_fwk.a ${ASCEND_RUNTIME_DIR}) | |||||
| find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}/driver) | find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}/driver) | ||||
| if(PRODUCT STREQUAL "flr3") | if(PRODUCT STREQUAL "flr3") | ||||
| message(FATAL_ERROR "This platform is not supported in train mode, build terminated") | message(FATAL_ERROR "This platform is not supported in train mode, build terminated") | ||||
| @@ -108,8 +105,7 @@ else () | |||||
| elseif(PLATFORM STREQUAL "inference") | elseif(PLATFORM STREQUAL "inference") | ||||
| find_module(adump_server libadump_server.a ${ASCEND_ACL_DIR}) | find_module(adump_server libadump_server.a ${ASCEND_ACL_DIR}) | ||||
| find_module(runtime libruntime.so ${ASCEND_ACL_DIR}) | find_module(runtime libruntime.so ${ASCEND_ACL_DIR}) | ||||
| find_module(runtime_compile libruntime_compile.so ${ASCEND_ATC_DIR}) | |||||
| find_module(msprofiler_ext libmsprofiler.a ${ASCEND_ACL_DIR}) | |||||
| find_module(runtime_compile libruntime_compile.so ${ASCEND_ATC_DIR}) | |||||
| if(PRODUCT STREQUAL "flr3") | if(PRODUCT STREQUAL "flr3") | ||||
| elseif(PRODUCT STREQUAL "flr1") | elseif(PRODUCT STREQUAL "flr1") | ||||
| find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}/driver) | find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}/driver) | ||||
| @@ -119,12 +115,10 @@ else () | |||||
| find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}) | find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}) | ||||
| endif() | endif() | ||||
| elseif(PLATFORM STREQUAL "all") | elseif(PLATFORM STREQUAL "all") | ||||
| find_module(adump_server libadump_server.a ${ASCEND_RUNTIME_DIR}) | |||||
| find_module(runtime libruntime.so ${ASCEND_RUNTIME_DIR}) | |||||
| find_module(msprofiler_fwk_ext libmsprofiler_fwk.a ${ASCEND_RUNTIME_DIR}) | |||||
| find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}) | |||||
| find_module(runtime_compile libruntime_compile.so ${ASCEND_ATC_DIR}) | |||||
| find_module(msprofiler_ext libmsprofiler.a ${ASCEND_ACL_DIR}) | |||||
| find_module(adump_server libadump_server.a ${ASCEND_RUNTIME_DIR}) | |||||
| find_module(runtime libruntime.so ${ASCEND_RUNTIME_DIR}) | |||||
| find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}) | |||||
| find_module(runtime_compile libruntime_compile.so ${ASCEND_ATC_DIR}) | |||||
| else() | else() | ||||
| message(STATUS "PLATFORM param is invalid, should be train or inference, you choose nothing!") | message(STATUS "PLATFORM param is invalid, should be train or inference, you choose nothing!") | ||||
| endif() | endif() | ||||
| @@ -813,6 +813,7 @@ target_link_libraries(ge_runner PRIVATE | |||||
| ge_proto_common | ge_proto_common | ||||
| ge_proto_client | ge_proto_client | ||||
| -Wl,--no-as-needed | -Wl,--no-as-needed | ||||
| msprofiler_fwk_share | |||||
| graph | graph | ||||
| ge_common | ge_common | ||||
| ascend_protobuf | ascend_protobuf | ||||
| @@ -178,6 +178,11 @@ ge::Status RegProfReporterCallback(MsprofReporterCallback func) { | |||||
| } else { | } else { | ||||
| GELOGI("GE register Msprof reporter callback."); | GELOGI("GE register Msprof reporter callback."); | ||||
| ge::ProfilingManager::Instance().SetMsprofReporterCallback(func); | ge::ProfilingManager::Instance().SetMsprofReporterCallback(func); | ||||
| auto ctrl_handle = ge::ProfilingManager::Instance().GetMsprofCtrlHandle(); | |||||
| if (ctrl_handle != nullptr) { | |||||
| void *report_func = reinterpret_cast<void *>(func); | |||||
| ctrl_handle(0, report_func, sizeof(report_func)); | |||||
| } | |||||
| // Pass MsprofReporterCallback to runtime | // Pass MsprofReporterCallback to runtime | ||||
| ge::Status rt_ret = rtSetMsprofReporterCallback(func); | ge::Status rt_ret = rtSetMsprofReporterCallback(func); | ||||
| if (rt_ret != ge::SUCCESS) { | if (rt_ret != ge::SUCCESS) { | ||||
| @@ -202,6 +207,15 @@ ge::Status ProfCommandHandle(ProfCommandHandleType type, void *data, uint32_t le | |||||
| GELOGW("The prof comand type is invalid."); | GELOGW("The prof comand type is invalid."); | ||||
| return ge::PARAM_INVALID; | return ge::PARAM_INVALID; | ||||
| } | } | ||||
| auto ctrl_handle = ge::ProfilingManager::Instance().GetMsprofCtrlHandle(); | |||||
| if (ctrl_handle != nullptr) { | |||||
| if (type == kProfCommandhandleStart) { | |||||
| ctrl_handle(1, data, len); | |||||
| } | |||||
| if (type == kProfCommandhandleStop) { | |||||
| ctrl_handle(2, data, len); | |||||
| } | |||||
| } | |||||
| std::vector<string> prof_params; | std::vector<string> prof_params; | ||||
| if (type == kProfCommandhandleStart || type == kProfCommandhandleStop) { | if (type == kProfCommandhandleStart || type == kProfCommandhandleStop) { | ||||
| if (!isProfConfigValid(prof_config_param->devIdList, prof_config_param->devNums)) { | if (!isProfConfigValid(prof_config_param->devIdList, prof_config_param->devNums)) { | ||||
| @@ -289,3 +303,17 @@ ge::Status ProfSetStepInfo(uint64_t index_id, uint16_t tag_id, rtStream_t stream | |||||
| ge::Status ProfGetDeviceFormGraphId(uint32_t graph_id, uint32_t &device_id) { | ge::Status ProfGetDeviceFormGraphId(uint32_t graph_id, uint32_t &device_id) { | ||||
| return ge::ProfilingManager::Instance().GetDeviceIdFromGraph(graph_id, device_id); | return ge::ProfilingManager::Instance().GetDeviceIdFromGraph(graph_id, device_id); | ||||
| } | } | ||||
| ge::Status ProfRegisterCtrlCallback(MsprofCtrlHandle func) { | |||||
| if (func == nullptr) { | |||||
| GELOGE(ge::PARAM_INVALID, "[Check][Param]Msprof ctrl callback is nullptr"); | |||||
| REPORT_INNER_ERROR("E19999", "Msprof ctrl callback is nullptr"); | |||||
| return ge::PARAM_INVALID; | |||||
| } | |||||
| if (ge::ProfilingManager::Instance().GetMsprofCtrlHandle() != nullptr) { | |||||
| GELOGW("Msprof ctrl callback is exist, just ignore it."); | |||||
| } else { | |||||
| ge::ProfilingManager::Instance().SetMsprofCtrlHandle(func); | |||||
| } | |||||
| return ge::SUCCESS; | |||||
| } | |||||
| @@ -97,12 +97,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ge::Status ProfilingManager::In | |||||
| } | } | ||||
| if (is_execute_profiling_) { | if (is_execute_profiling_) { | ||||
| if (prof_cb_.msprofCtrlCallback == nullptr) { | |||||
| GELOGE(ge::PARAM_INVALID, "[Check][Param]MsprofCtrlCallback callback is nullptr"); | |||||
| REPORT_INNER_ERROR("E19999", "MsprofCtrlCallback callback is nullptr"); | |||||
| return ge::PARAM_INVALID; | |||||
| } | |||||
| int32_t cb_ret = prof_cb_.msprofCtrlCallback( | |||||
| int32_t cb_ret = MsprofInit( | |||||
| static_cast<uint32_t>(MsprofCtrlCallbackType::MSPROF_CTRL_INIT_GE_OPTIONS), | static_cast<uint32_t>(MsprofCtrlCallbackType::MSPROF_CTRL_INIT_GE_OPTIONS), | ||||
| static_cast<void *>(&prof_conf), sizeof(MsprofGeOptions)); | static_cast<void *>(&prof_conf), sizeof(MsprofGeOptions)); | ||||
| if (cb_ret != 0) { | if (cb_ret != 0) { | ||||
| @@ -243,13 +238,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::StopProf | |||||
| } | } | ||||
| // stop profiling | // stop profiling | ||||
| if (prof_cb_.msprofCtrlCallback == nullptr) { | |||||
| GELOGE(ge::PARAM_INVALID, "[Check][Param]MsprofCtrlCallback callback is nullptr"); | |||||
| REPORT_INNER_ERROR("E19999", "MsprofCtrlCallback callback is nullptr"); | |||||
| return; | |||||
| } | |||||
| int32_t cb_ret = prof_cb_.msprofCtrlCallback(static_cast<uint32_t>(MsprofCtrlCallbackType::MSPROF_CTRL_FINALIZE), | |||||
| nullptr, 0); | |||||
| int32_t cb_ret = MsprofFinalize(); | |||||
| if (cb_ret != 0) { | if (cb_ret != 0) { | ||||
| GELOGW("call msprofCtrlCallback failed, type:%u, return:%d", | GELOGW("call msprofCtrlCallback failed, type:%u, return:%d", | ||||
| static_cast<uint32_t>(MsprofCtrlCallbackType::MSPROF_CTRL_FINALIZE), cb_ret); | static_cast<uint32_t>(MsprofCtrlCallbackType::MSPROF_CTRL_FINALIZE), cb_ret); | ||||
| @@ -28,6 +28,7 @@ | |||||
| #include "external/register/register_types.h" | #include "external/register/register_types.h" | ||||
| #include "toolchain/prof_callback.h" | #include "toolchain/prof_callback.h" | ||||
| #include "runtime/stream.h" | #include "runtime/stream.h" | ||||
| #include "common/profiling/ge_profiling.h" | |||||
| using std::map; | using std::map; | ||||
| using std::string; | using std::string; | ||||
| @@ -116,6 +117,8 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ProfilingManager { | |||||
| void CleanSubscribeInfo(); | void CleanSubscribeInfo(); | ||||
| void SetGraphIdToModelMap(uint32_t graph_id, uint32_t model_id) { model_id_map_[graph_id] = model_id; } | void SetGraphIdToModelMap(uint32_t graph_id, uint32_t model_id) { model_id_map_[graph_id] = model_id; } | ||||
| Status GetModelIdFromGraph(uint32_t graph_id, uint32_t &model_id); | Status GetModelIdFromGraph(uint32_t graph_id, uint32_t &model_id); | ||||
| void SetMsprofCtrlHandle(MsprofCtrlHandle func) { ctrl_handle_ = func; } | |||||
| MsprofCtrlHandle GetMsprofCtrlHandle() { return ctrl_handle_; } | |||||
| private: | private: | ||||
| Status InitFromOptions(const Options &options, MsprofGeOptions &prof_conf); | Status InitFromOptions(const Options &options, MsprofGeOptions &prof_conf); | ||||
| @@ -147,6 +150,7 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ProfilingManager { | |||||
| std::map<uint32_t, uint32_t> device_id_map_; // key: graph_id, value: device_id | std::map<uint32_t, uint32_t> device_id_map_; // key: graph_id, value: device_id | ||||
| std::map<uint32_t, uint32_t> model_id_map_; // key: graph_id, value: model_id | std::map<uint32_t, uint32_t> model_id_map_; // key: graph_id, value: model_id | ||||
| ProfSubscribeInfo subscribe_info_; | ProfSubscribeInfo subscribe_info_; | ||||
| MsprofCtrlHandle ctrl_handle_; | |||||
| }; | }; | ||||
| } // namespace ge | } // namespace ge | ||||
| #endif // GE_COMMON_PROFILING_PROFILING_MANAGER_H_ | #endif // GE_COMMON_PROFILING_PROFILING_MANAGER_H_ | ||||
| @@ -39,6 +39,8 @@ struct ProfCommandHandleData { | |||||
| uint32_t modelId; | uint32_t modelId; | ||||
| }; | }; | ||||
| typedef int32_t (*MsprofCtrlHandle)(uint32_t dataType, void *data, uint32_t dataLen); | |||||
| GE_FUNC_VISIBILITY ge::Status RegProfCtrlCallback(MsprofCtrlCallback func); | GE_FUNC_VISIBILITY ge::Status RegProfCtrlCallback(MsprofCtrlCallback func); | ||||
| GE_FUNC_VISIBILITY ge::Status RegProfSetDeviceCallback(MsprofSetDeviceCallback func); | GE_FUNC_VISIBILITY ge::Status RegProfSetDeviceCallback(MsprofSetDeviceCallback func); | ||||
| GE_FUNC_VISIBILITY ge::Status RegProfReporterCallback(MsprofReporterCallback func); | GE_FUNC_VISIBILITY ge::Status RegProfReporterCallback(MsprofReporterCallback func); | ||||
| @@ -52,4 +54,5 @@ GE_FUNC_VISIBILITY ge::Status ProfSetStepInfo(uint64_t index_id, uint16_t tag_id | |||||
| GE_FUNC_VISIBILITY ge::Status ProfGetDeviceFormGraphId(uint32_t graph_id, uint32_t &device_id); | GE_FUNC_VISIBILITY ge::Status ProfGetDeviceFormGraphId(uint32_t graph_id, uint32_t &device_id); | ||||
| GE_FUNC_VISIBILITY ge::Status ProfRegisterCtrlCallback(MsprofCtrlHandle func); | |||||
| #endif // INC_FRAMEWORK_COMMON_GE_PROFILING_H_ | #endif // INC_FRAMEWORK_COMMON_GE_PROFILING_H_ | ||||