Merge pull request !576 from taoxiangdong/dev
pull/576/MERGE
lujiale 4 years ago committed by Gitee
commit 1f05cd0b5c

@ -71,7 +71,7 @@ if (ENABLE_OPEN_SRC)
set(STATIC_ACL_LIB ${GE_LIB_PATH}) set(STATIC_ACL_LIB ${GE_LIB_PATH})
find_module(slog libslog.so ${GE_LIB_PATH}) find_module(slog libslog.so ${GE_LIB_PATH})
find_module(static_mmpa libmmpa.a ${GE_LIB_PATH}) find_module(static_mmpa libmmpa.a ${GE_LIB_PATH})
find_module(msprof libmsprof.so ${GE_LIB_PATH}) find_module(msprofiler 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})
@ -80,20 +80,19 @@ if (ENABLE_OPEN_SRC)
find_module(error_manager liberror_manager.so ${GE_LIB_PATH}) find_module(error_manager liberror_manager.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(error_manager_static liberror_manager.a ${GE_LIB_PATH}) find_module(error_manager_static liberror_manager.a ${GE_LIB_PATH})
find_module(msprofiler libmsprofiler.a ${GE_LIB_PATH}) find_module(msprofiler_fwk 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 libslog.so ${ASCEND_ATC_DIR}) find_module(slog libslog.so ${ASCEND_ATC_DIR})
find_module(static_mmpa libmmpa.a ${ASCEND_ATC_DIR}) find_module(static_mmpa libmmpa.a ${ASCEND_ATC_DIR})
find_module(error_manager liberror_manager.so ${ASCEND_ATC_DIR}) find_module(error_manager liberror_manager.so ${ASCEND_ATC_DIR})
if(PLATFORM STREQUAL "train") if(PLATFORM STREQUAL "train")
find_module(msprof libmsprof.so ${ASCEND_DRIVER_COMMON_DIR})
find_module(hccl libhccl.so ${ASCEND_RUNTIME_DIR}) find_module(hccl libhccl.so ${ASCEND_RUNTIME_DIR})
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(resource libresource.so ${ASCEND_RUNTIME_DIR}) find_module(resource libresource.so ${ASCEND_RUNTIME_DIR})
find_module(error_manager liberror_manager.so ${ASCEND_RUNTIME_DIR}) find_module(error_manager liberror_manager.so ${ASCEND_RUNTIME_DIR})
find_module(msprofiler libmsprofiler.a ${ASCEND_RUNTIME_DIR}) find_module(msprofiler_fwk 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,18 +107,15 @@ if (ENABLE_OPEN_SRC)
find_module(msprofiler libmsprofiler.a ${ASCEND_ACL_DIR}) find_module(msprofiler libmsprofiler.a ${ASCEND_ACL_DIR})
#find_module(ascendcl_static libascendcl.a ${ASCEND_ACL_DIR}) #find_module(ascendcl_static libascendcl.a ${ASCEND_ACL_DIR})
if(PRODUCT STREQUAL "flr3") if(PRODUCT STREQUAL "flr3")
find_module(msprof libmsprof.so ${ASCEND_DRIVER_SHARE_DIR})
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)
find_module(msprof libmsprof.so ${ASCEND_DRIVER_COMMON_DIR})
elseif(PRODUCT STREQUAL "flr2") elseif(PRODUCT STREQUAL "flr2")
# flr2 ascend_hal_stub limsprof ? # flr2 ascend_hal_stub limsprof ?
else() else()
find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}) find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR})
find_module(msprof libmsprof.so ${ASCEND_DRIVER_DIR})
endif() endif()
elseif(PLATFORM STREQUAL "all") elseif(PLATFORM STREQUAL "all")
find_module(msprof libmsprof.so ${ASCEND_DRIVER_COMMON_DIR}) find_module(msprofiler libmsprofiler.a ${ASCEND_DRIVER_COMMON_DIR})
find_module(hccl libhccl.so ${ASCEND_RUNTIME_DIR}) find_module(hccl libhccl.so ${ASCEND_RUNTIME_DIR})
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})
@ -127,7 +123,7 @@ if (ENABLE_OPEN_SRC)
find_module(resource libresource.so ${ASCEND_ATC_DIR}) find_module(resource libresource.so ${ASCEND_ATC_DIR})
find_module(error_manager liberror_manager.so ${ASCEND_ATC_DIR}) find_module(error_manager liberror_manager.so ${ASCEND_ATC_DIR})
find_module(error_manager_static liberror_manager.a ${ASCEND_ACL_DIR}) find_module(error_manager_static liberror_manager.a ${ASCEND_ACL_DIR})
find_module(msprofiler libmsprofiler.a ${ASCEND_ACL_DIR}) find_module(msprofiler_fwk libmsprofiler_fwk.a ${ASCEND_ACL_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)
#find_module(ascendcl_static libascendcl.a ${ASCEND_ACL_DIR}) #find_module(ascendcl_static libascendcl.a ${ASCEND_ACL_DIR})
else() else()

@ -60,6 +60,8 @@ set(TRAIN_SRC_LIST
"common/dump/dump_manager.cc" "common/dump/dump_manager.cc"
"common/dump/dump_properties.cc" "common/dump/dump_properties.cc"
"common/dump/dump_op.cc" "common/dump/dump_op.cc"
"common/profiling/ge_profiling.cc"
"common/profiling/ge_runner_profiling.cc"
"engine_manager/dnnengine_manager.cc" "engine_manager/dnnengine_manager.cc"
"ge_local_engine/engine/host_cpu_engine.cc" "ge_local_engine/engine/host_cpu_engine.cc"
"generator/ge_generator.cc" "generator/ge_generator.cc"
@ -332,7 +334,6 @@ set(TRAIN_SRC_LIST
"hybrid/hybrid_davinci_model.cc" "hybrid/hybrid_davinci_model.cc"
"executor/ge_executor.cc" "executor/ge_executor.cc"
"client/ge_api.cc" "client/ge_api.cc"
"client/ge_prof.cc"
"analyzer/analyzer.cc" "analyzer/analyzer.cc"
"ir_build/ge_ir_build.cc" "ir_build/ge_ir_build.cc"
"ir_build/atc_ir_common.cc" "ir_build/atc_ir_common.cc"
@ -604,7 +605,7 @@ set(INFER_SRC_LIST
if (NOT ENABLE_D AND NOT ENABLE_ACL AND NOT ENABLE_MS_TESTCASES) if (NOT ENABLE_D AND NOT ENABLE_ACL AND NOT ENABLE_MS_TESTCASES)
############ libge_runner.so ############ ############ libge_runner.so ############
add_library(ge_runner SHARED ${TRAIN_SRC_LIST} ${PROTO_SRCS} ${PROTO_CLIENT_SRCS}) add_library(ge_runner SHARED ${TRAIN_SRC_LIST} ${PROTO_SRCS} ${PROTO_CLIENT_SRCS} $<TARGET_OBJECTS:msprofiler_fwk>)
target_compile_definitions(ge_runner PRIVATE target_compile_definitions(ge_runner PRIVATE
PROTOBUF_INLINE_NOT_IN_HEADERS=0 PROTOBUF_INLINE_NOT_IN_HEADERS=0
@ -649,7 +650,6 @@ target_link_libraries(ge_runner
$<BUILD_INTERFACE:intf_pub> $<BUILD_INTERFACE:intf_pub>
ge_memory ge_memory
adump_server adump_server
msprofiler
static_mmpa static_mmpa
-Wl,--no-as-needed -Wl,--no-as-needed
graph graph
@ -658,7 +658,6 @@ target_link_libraries(ge_runner
register register
c_sec c_sec
slog slog
msprof
runtime runtime
resource resource
error_manager error_manager
@ -783,7 +782,6 @@ target_link_libraries(opensrc_ascendcl PRIVATE
c_sec c_sec
runtime runtime
slog slog
msprof
ascend_hal_stub ascend_hal_stub
-Wl,--as-needed -Wl,--as-needed
-lrt -lrt
@ -799,12 +797,10 @@ set_target_properties(opensrc_ascendcl PROPERTIES
add_custom_command( add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/stub_ge_ir_build.cc OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/stub_ge_ir_build.cc
${CMAKE_CURRENT_BINARY_DIR}/stub_ge_api.cc ${CMAKE_CURRENT_BINARY_DIR}/stub_ge_api.cc
${CMAKE_CURRENT_BINARY_DIR}/stub_ge_prof.cc
COMMAND echo "Generating stub files." COMMAND echo "Generating stub files."
&& ${HI_PYTHON} ${CMAKE_CURRENT_LIST_DIR}/stub/gen_stubapi.py ${GE_CODE_DIR}/inc/external ${CMAKE_CURRENT_BINARY_DIR} && ${HI_PYTHON} ${CMAKE_CURRENT_LIST_DIR}/stub/gen_stubapi.py ${GE_CODE_DIR}/inc/external ${CMAKE_CURRENT_BINARY_DIR}
&& mv ge_ir_build.cc stub_ge_ir_build.cc && mv ge_ir_build.cc stub_ge_ir_build.cc
&& mv ge_api.cc stub_ge_api.cc && mv ge_api.cc stub_ge_api.cc
&& mv ge_prof.cc stub_ge_prof.cc
&& echo "Generating stub files end." && echo "Generating stub files end."
#WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} #WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
#DEPENDS stub/gen_stubapi.py ${TOP_DIR}/inc/external ${CMAKE_CURRENT_BINARY_DIR} #DEPENDS stub/gen_stubapi.py ${TOP_DIR}/inc/external ${CMAKE_CURRENT_BINARY_DIR}
@ -813,7 +809,6 @@ add_custom_command(
add_custom_target(ge_stub add_custom_target(ge_stub
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/stub_ge_ir_build.cc DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/stub_ge_ir_build.cc
${CMAKE_CURRENT_BINARY_DIR}/stub_ge_api.cc ${CMAKE_CURRENT_BINARY_DIR}/stub_ge_api.cc
${CMAKE_CURRENT_BINARY_DIR}/stub_ge_prof.cc
) )
################################################################## ##################################################################
@ -855,7 +850,6 @@ target_include_directories(atc_stub_ge_compiler PRIVATE
############ stub/libge_runner.so ############ ############ stub/libge_runner.so ############
add_library(fwk_stub_ge_runner SHARED add_library(fwk_stub_ge_runner SHARED
stub_ge_api.cc stub_ge_api.cc
stub_ge_prof.cc
stub_ge_ir_build.cc stub_ge_ir_build.cc
) )

File diff suppressed because it is too large Load Diff

@ -4,7 +4,6 @@ LOCAL_PATH := $(call my-dir)
COMMON_LOCAL_SRC_FILES := \ COMMON_LOCAL_SRC_FILES := \
proto/ge_api.proto \ proto/ge_api.proto \
ge_api.cc \ ge_api.cc \
ge_prof.cc \
COMMON_LOCAL_C_INCLUDES := \ COMMON_LOCAL_C_INCLUDES := \
@ -69,9 +68,9 @@ LOCAL_SHARED_LIBRARIES := \
libgraph \ libgraph \
libregister \ libregister \
libge_compiler \ libge_compiler \
libge_common \ libge_common
libmsprof
LOCAL_STATIC_LIBRARIES += libmsprofiler_fwk \
LOCAL_LDFLAGS := -lrt -ldl LOCAL_LDFLAGS := -lrt -ldl
@ -104,8 +103,10 @@ LOCAL_SHARED_LIBRARIES := \
libregister \ libregister \
libruntime \ libruntime \
libge_compiler \ libge_compiler \
libge_common \ libge_common
libmsprof
LOCAL_STATIC_LIBRARIES += libmsprofiler_fwk \
LOCAL_LDFLAGS := -lrt -ldl LOCAL_LDFLAGS := -lrt -ldl

@ -0,0 +1,199 @@
/**
* Copyright 2020 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "common/profiling/ge_profiling.h"
#include "runtime/base.h"
#include "common/profiling/profiling_manager.h"
#include "framework/common/debug/ge_log.h"
#include "framework/common/debug/log.h"
#include "graph/load/graph_loader.h"
#include "init/gelib.h"
#include "framework/common/ge_inner_error_codes.h"
namespace {
const uint32_t kDeviceListIndex = 3;
const std::string kDeviceNums = "devNums";
const std::string kDeviceIdList = "devIdList";
const std::string kProfilingInit = "prof_init";
const std::string kProfilingFinalize = "prof_finalize";
const std::string kProfilingStart = "prof_start";
const std::string kProfilingStop = "prof_stop";
const std::string kProfModelSubscribe = "prof_model_subscribe";
const std::string kProfModelUnsubscribe = "prof_model_cancel_subscribe";
const std::string kRtSetDeviceRegName = "profiling";
const std::map<ProfCommandHandleType, std::string> kProfCommandTypeMap = {
{kProfCommandhandleInit, kProfilingInit},
{kProfCommandhandleStart, kProfilingStart},
{kProfCommandhandleStop, kProfilingStop},
{kProfCommandhandleFinalize, kProfilingFinalize},
{kProfCommandhandleModelSubscribe, kProfModelSubscribe},
{kProfCommandhandleModelUnsubscribe, kProfModelUnsubscribe}};
} // namespace
bool TransProfConfigToParam(const ProfCommandHandleData &profCommand, vector<string> &prof_config_params) {
prof_config_params.clear();
prof_config_params.emplace_back(kDeviceNums);
prof_config_params.emplace_back(std::to_string(profCommand.devNums));
prof_config_params.emplace_back(kDeviceIdList);
std::string devID = "";
if (profCommand.devNums == 0) {
GELOGW("The device num is invalid.");
return false;
}
for (uint32_t i = 0; i < profCommand.devNums; i++) {
devID.append(std::to_string(profCommand.devIdList[i]));
if (i != profCommand.devNums - 1) {
devID.append(",");
}
}
prof_config_params.push_back(devID);
return true;
}
bool isProfConfigValid(const uint32_t *deviceid_list, uint32_t device_nums) {
if (deviceid_list == nullptr) {
GELOGE(ge::PARAM_INVALID, "deviceIdList is nullptr");
return false;
}
if (device_nums == 0 || device_nums > MAX_DEV_NUM) {
GELOGE(ge::PARAM_INVALID, "The device nums: %u is invalid.", device_nums);
return false;
}
// real device num
int32_t dev_count = 0;
rtError_t rt_err = rtGetDeviceCount(&dev_count);
if (rt_err != RT_ERROR_NONE) {
GELOGE(ge::INTERNAL_ERROR, "Get the Device count fail.");
return false;
}
if (device_nums > static_cast<uint32_t>(dev_count)) {
GELOGE(ge::PARAM_INVALID, "Device num(%u) is not in range 1 ~ %d.", device_nums, dev_count);
return false;
}
std::unordered_set<uint32_t> record;
for (size_t i = 0; i < device_nums; ++i) {
uint32_t dev_id = deviceid_list[i];
if (dev_id >= static_cast<uint32_t>(dev_count)) {
GELOGE(ge::PARAM_INVALID, "Device id %u is not in range 0 ~ %d(exclude %d)", dev_id, dev_count, dev_count);
return false;
}
if (record.count(dev_id) > 0) {
GELOGE(ge::PARAM_INVALID, "Device id %u is duplicatedly set", dev_id);
return false;
}
record.insert(dev_id);
}
return true;
}
ge::Status RegProfCtrlCallback(MsprofCtrlCallback func) {
if (func == nullptr) {
GELOGE(ge::PARAM_INVALID, "Msprof ctrl callback is nullptr.");
return ge::PARAM_INVALID;
}
if (ge::ProfilingManager::Instance().GetMsprofCallback().msprofCtrlCallback != nullptr) {
GELOGW("Msprof ctrl callback is exist, just ignore it.");
} else {
GELOGI("GE register Msprof ctrl callback.");
ge::ProfilingManager::Instance().SetMsprofCtrlCallback(func);
}
return ge::SUCCESS;
}
ge::Status RegProfSetDeviceCallback(MsprofSetDeviceCallback func) {
if (func == nullptr) {
GELOGE(ge::PARAM_INVALID, "MsprofSetDeviceCallback callback is nullptr.");
return ge::PARAM_INVALID;
}
// Pass MsprofSetDeviceCallback to runtime
GELOGI("GE pass setdevice callback to runtime.");
ge::Status rt_ret = rtRegDeviceStateCallback(kRtSetDeviceRegName.c_str(), static_cast<rtDeviceStateCallback>(func));
if (rt_ret != ge::SUCCESS) {
GELOGE(rt_ret, "Pass MsprofSetDeviceCallback to runtime failed!");
return rt_ret;
}
return ge::SUCCESS;
}
ge::Status RegProfReporterCallback(MsprofReporterCallback func) {
if (func == nullptr) {
GELOGE(ge::PARAM_INVALID, "MsprofReporterCallback callback is nullptr.");
return ge::PARAM_INVALID;
}
if (ge::ProfilingManager::Instance().GetMsprofCallback().msprofReporterCallback != nullptr) {
GELOGW("Msprof reporter callback is exist, just ignore it.");
} else {
GELOGI("GE register Msprof reporter callback.");
ge::ProfilingManager::Instance().SetMsprofReporterCallback(func);
// Pass MsprofReporterCallback to runtime
ge::Status rt_ret = rtSetMsprofReporterCallback(func);
if (rt_ret != ge::SUCCESS) {
GELOGE(rt_ret, "Pass MsprofReporterCallback to runtime failed!!");
return rt_ret;
}
// Pass MsprofReporterCallback to hccl
}
return ge::SUCCESS;
}
ge::Status ProfCommandHandle(ProfCommandHandleType type, void *data, uint32_t len) {
if (type != kProfCommandhandleFinalize) {
GE_CHECK_NOTNULL(data);
}
ProfCommandHandleData *prof_config_param = (ProfCommandHandleData *)data;
auto iter = kProfCommandTypeMap.find(type);
if (iter == kProfCommandTypeMap.end()) {
GELOGW("The prof comand type is invalid.");
return ge::PARAM_INVALID;
}
std::vector<string> prof_params;
if (type == kProfCommandhandleStart || type == kProfCommandhandleStop) {
if (!isProfConfigValid(prof_config_param->devIdList, prof_config_param->devNums)) {
return ge::FAILED;
}
if (!TransProfConfigToParam(*prof_config_param, prof_params)) {
GELOGE(ge::PARAM_INVALID, "Transfer profilerConfig to string vector failed");
return ge::PARAM_INVALID;
}
}
ge::GraphLoader graph_loader;
ge::Command command;
command.cmd_params.clear();
command.cmd_type = iter->second;
command.cmd_params = prof_params;
if (type != kProfCommandhandleFinalize) {
command.module_index = prof_config_param->profSwitch;
}
GELOGI("GE commandhandle execute, Command Type: %d, data type config: 0x%llx", type, command.module_index);
if (type == kProfCommandhandleStart || type == kProfCommandhandleStop) {
GELOGI("Profiling device nums:%s , deviceID:[%s]", prof_params[0].c_str(), prof_params[kDeviceListIndex].c_str());
}
ge::Status ret = graph_loader.CommandHandle(command);
if (ret != ge::SUCCESS) {
GELOGE(ret, "Handle profiling command failed");
return ge::FAILED;
}
GELOGI("Successfully execute profiling command type: %d, command 0x%llx.", type, command.module_index);
return ge::SUCCESS;
}

@ -0,0 +1,26 @@
/**
* Copyright 2020 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "common/profiling/ge_runner_profiling.h"
#include "init/gelib.h"
bool IsInitialize() {
std::shared_ptr<ge::GELib> instance_ptr = ge::GELib::GetInstance();
if (instance_ptr == nullptr || instance_ptr->InitFlag() == false) {
return false;
}
return true;
}

File diff suppressed because it is too large Load Diff

@ -26,9 +26,7 @@
#include "framework/common/ge_inner_error_codes.h" #include "framework/common/ge_inner_error_codes.h"
#include "framework/common/ge_types.h" #include "framework/common/ge_types.h"
#include "external/register/register_types.h" #include "external/register/register_types.h"
#include "toolchain/prof_engine.h" #include "toolchain/prof_callback.h"
#include "toolchain/prof_mgr_core.h"
#include "toolchain/prof_acl_api.h"
using std::map; using std::map;
using std::string; using std::string;
@ -37,35 +35,33 @@ using Json = nlohmann::json;
namespace { namespace {
const std::string GE_PROFILING_MODULE = "Framework"; const std::string GE_PROFILING_MODULE = "Framework";
// DataTypeConfig MASK
#define PROF_ACL_API_MASK 0x0001
#define PROF_TASK_TIME_MASK 0x0002
#define PROF_AICORE_METRICS_MASK 0x0004
#define PROF_AICPU_TRACE_MASK 0x0008
#define PROF_MODEL_EXECUTE_MASK 0x0010
#define PROF_RUNTIME_API_MASK 0x0020
#define PROF_RUNTIME_TRACE_MASK 0x0040
#define PROF_SCHEDULE_TIMELINE_MASK 0x0080
#define PROF_SCHEDULE_TRACE_MASK 0x0100
#define PROF_AIVECTORCORE_METRICS_MASK 0x0200
#define PROF_SUBTASK_TIME_MASK 0x0400
#define PROF_TRAINING_TRACE_MASK 0x0800
#define PROF_HCCL_TRACE_MASK 0x1000
#define PROF_DATA_PROCESS_MASK 0x2000
#define PROF_MODEL_LOAD_MASK 0x8000000000000000
} // namespace } // namespace
namespace ge { namespace ge {
struct DeviceSubsInfo { struct DeviceSubsInfo {
uint64_t module; uint64_t module;
uint32_t subscribe_count; uint32_t subscribe_count;
}; };
// register Plugin
class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY PluginImpl : public Msprof::Engine::PluginIntf {
public:
explicit PluginImpl(const std::string &module);
~PluginImpl() {}
int Init(const Msprof::Engine::Reporter *reporter);
int UnInit();
static Msprof::Engine::Reporter *GetPluginReporter() { return reporter_; }
private: struct MsprofCallback {
static Msprof::Engine::Reporter *reporter_; MsprofCtrlCallback msprofCtrlCallback;
std::string module_; MsprofReporterCallback msprofReporterCallback;
};
// register Engine
class ProfilingEngineImpl : public Msprof::Engine::EngineIntf {
public:
ProfilingEngineImpl() {}
~ProfilingEngineImpl() {}
Msprof::Engine::PluginIntf *CreatePlugin();
int ReleasePlugin(Msprof::Engine::PluginIntf *plugin);
}; };
class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ProfilingManager { class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ProfilingManager {
@ -73,68 +69,54 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ProfilingManager {
ProfilingManager(); ProfilingManager();
virtual ~ProfilingManager(); virtual ~ProfilingManager();
static ProfilingManager &Instance(); static ProfilingManager &Instance();
ge::Status Init(const Options &options); Status Init(const Options &options);
ge::Status InitFromOptions(const Options &options); Status ProfInit(uint64_t module);
ge::Status InitFromAclCfg(const std::string &config); Status ProfFinalize();
ge::Status StartProfiling(int32_t iter, int32_t device_id); Status ProfStartProfiling(uint64_t module, const std::map<std::string, std::string> &config_para);
void UpdateSubscribeDeviceModuleMap(std::string prof_type, uint32_t device_id, uint64_t module); Status ProfStopProfiling(uint64_t module, const std::map<std::string, std::string> &config_para);
ge::Status ProfModelSubscribe(uint64_t module, void *model); Status ProfModelSubscribe(uint64_t module, void *model);
ge::Status ProfModelUnsubscribe(void *model); Status ProfModelUnsubscribe(void *model);
ge::Status ProfInit(uint64_t module);
ge::Status ProfFinalize();
ge::Status ProfStartProfiling(uint64_t module, const std::map<std::string, std::string> &config_para);
ge::Status ProfStopProfiling(uint64_t module, const std::map<std::string, std::string> &config_para);
void StopProfiling(); void StopProfiling();
bool ProfilingOpTraceOn() const { return is_op_trace_; }
bool ProfilingLoadFlag() const { return is_load_; }
bool ProfilingTrainingTraceOn() const { return is_training_trace_; } bool ProfilingTrainingTraceOn() const { return is_training_trace_; }
bool ProfilingModelLoadOn() const { return is_load_profiling_; } bool ProfilingModelLoadOn() const { return is_load_profiling_; }
bool ProfilingModelExecuteOn() const; bool ProfilingModelExecuteOn() const;
bool ProfilingOn() const { return is_load_profiling_ && is_execute_profiling_; } // only used by command pattern bool ProfilingOn() const { return is_load_profiling_ && is_execute_profiling_; } // is_execute_profiling_ only used by ge option and env
bool IsAclApiMode() const { return is_acl_api_mode_; }
int32_t GetOpTraceIterNum() const { return op_trace_iter_num_; }
void ReportProfilingData(uint32_t model_id, const std::vector<TaskDescInfo> &task_desc_info, void ReportProfilingData(uint32_t model_id, const std::vector<TaskDescInfo> &task_desc_info,
const std::vector<ComputeGraphDescInfo> &compute_graph_desc_info, const std::vector<ComputeGraphDescInfo> &compute_graph_desc_info);
bool check_device);
void Report(const int32_t &device_id, const string &data, Msprof::Engine::Reporter &reporter,
Msprof::Engine::ReporterData &reporter_data);
void ProfilingTaskDescInfo(uint32_t model_id, const std::vector<TaskDescInfo> &task_desc_info, void ProfilingTaskDescInfo(uint32_t model_id, const std::vector<TaskDescInfo> &task_desc_info,
const int32_t &device_id); const int32_t &device_id);
void ProfilingGraphDescInfo(uint32_t model_id, const std::vector<ComputeGraphDescInfo> &compute_graph_desc_info, void ProfilingGraphDescInfo(uint32_t model_id, const std::vector<ComputeGraphDescInfo> &compute_graph_desc_info,
const int32_t &device_id); const int32_t &device_id);
void SetProfilingConfig(const string &profiling_cfg); Status PluginInit() const;
vector<int32_t> GetProfilingDeviceId() const { return device_id_; } void PluginUnInit() const;
void PluginUnInit(const std::string &module) const; Status CallMsprofReport(ReporterData &reporter_data) const;
struct MsprofCallback &GetMsprofCallback() { return prof_cb_; }
void SetMsprofCtrlCallback(MsprofCtrlCallback func) { prof_cb_.msprofCtrlCallback = func; }
void SetMsprofReporterCallback(MsprofReporterCallback func) { prof_cb_.msprofReporterCallback = func; }
void GetFpBpPoint(std::string &fp_point, std::string &bp_point);
private: private:
ge::Status ParseFeaturesFromAclCfg(const Json &feature); Status InitFromOptions(const Options &options, MsprofGeOptions &prof_conf);
ge::Status ProfParseParam(const std::map<std::string, std::string> &config_para, int32_t &device_num, Status ParseOptions(const std::string &options);
vector<int32_t> &device_list); Status ProfParseParam(const std::map<std::string, std::string> &config_para, int32_t &device_num,
ge::Status ProfParseDeviceId(const std::map<std::string, std::string> &config_para, vector<int32_t> &device_list);
Status ProfParseDeviceId(const std::map<std::string, std::string> &config_para,
vector<int32_t> &device_list); vector<int32_t> &device_list);
uint64_t GetProfilingModule(); uint64_t GetProfilingModule();
void GraphDescReport(const int32_t &device_id, const string &data);
void UpdateDeviceIdModuleMap(string prof_type, uint64_t module, const vector<int32_t> &device_list); void UpdateDeviceIdModuleMap(string prof_type, uint64_t module, const vector<int32_t> &device_list);
bool is_load_profiling_ = false; void UpdateSubscribeDeviceModuleMap(std::string prof_type, uint32_t device_id, uint64_t module);
bool is_execute_profiling_ = false;
bool is_op_trace_ = false; bool is_load_profiling_;
bool is_load_ = false; bool is_execute_profiling_;
bool is_training_trace_ = false; bool is_training_trace_;
bool is_acl_api_mode_ = false;
int32_t op_trace_iter_num_ = 0;
string job_id_;
string prof_dir_;
vector<int32_t> device_id_; vector<int32_t> device_id_;
vector<string> op_trace_conf_;
vector<string> profiling_opts_;
vector<void *> prof_handle_vec_;
string recv_profiling_config_;
string send_profiling_config_;
string system_trace_conf_;
string task_trace_conf_;
const ProfilingEngineImpl engine_;
map<int32_t, uint64_t> device_id_module_map_; // key: device_id, value: profiling on module map<int32_t, uint64_t> device_id_module_map_; // key: device_id, value: profiling on module
map<uint32_t, DeviceSubsInfo> subs_dev_module_; // key: device_id, value: profiling on module map<uint32_t, DeviceSubsInfo> subs_dev_module_; // key: device_id, value: profiling on module
uint32_t subscribe_count_; uint32_t subscribe_count_;
std::mutex mutex_; std::mutex mutex_;
MsprofCallback prof_cb_;
std::string fp_point_;
std::string bp_point_;
}; };
} // namespace ge } // namespace ge
#endif // GE_COMMON_PROFILING_PROFILING_MANAGER_H_ #endif // GE_COMMON_PROFILING_PROFILING_MANAGER_H_

@ -17,6 +17,7 @@ set(SRC_LIST
"../common/dump/dump_properties.cc" "../common/dump/dump_properties.cc"
"../common/dump/dump_manager.cc" "../common/dump/dump_manager.cc"
"../common/dump/dump_op.cc" "../common/dump/dump_op.cc"
"../common/profiling/ge_profiling.cc"
"../graph/load/graph_loader.cc" "../graph/load/graph_loader.cc"
"../graph/execute/graph_execute.cc" "../graph/execute/graph_execute.cc"
"../omm/csa_interact.cc" "../omm/csa_interact.cc"
@ -244,7 +245,6 @@ target_link_libraries(ge_executor_shared PRIVATE
mmpa mmpa
graph graph
register register
msprof
error_manager error_manager
ascend_hal_stub ascend_hal_stub
ascend_protobuf ascend_protobuf

@ -304,7 +304,7 @@ Status GeExecutor::Finalize() {
// Stop profiling // Stop profiling
if (ProfilingManager::Instance().ProfilingOn()) { if (ProfilingManager::Instance().ProfilingOn()) {
ProfilingManager::Instance().StopProfiling(); ProfilingManager::Instance().StopProfiling();
ProfilingManager::Instance().PluginUnInit(GE_PROFILING_MODULE); ProfilingManager::Instance().PluginUnInit();
} }
GELOGI("Uninit GeExecutor over."); GELOGI("Uninit GeExecutor over.");

@ -8,6 +8,7 @@ local_ge_executor_src_files := \
../common/dump/dump_op.cc \ ../common/dump/dump_op.cc \
../common/ge/plugin_manager.cc \ ../common/ge/plugin_manager.cc \
../common/ge/op_tiling_manager.cc \ ../common/ge/op_tiling_manager.cc \
../common/profiling/ge_profiling.cc \
../graph/load/graph_loader.cc \ ../graph/load/graph_loader.cc \
../graph/execute/graph_execute.cc \ ../graph/execute/graph_execute.cc \
../omm/csa_interact.cc \ ../omm/csa_interact.cc \
@ -177,7 +178,6 @@ local_ge_executor_shared_library := \
libmmpa \ libmmpa \
libgraph \ libgraph \
libregister \ libregister \
libmsprof \
liberror_manager \ liberror_manager \
local_ge_executor_ldflags := -lrt -ldl \ local_ge_executor_ldflags := -lrt -ldl \
@ -234,7 +234,6 @@ LOCAL_SHARED_LIBRARIES := \
libmmpa \ libmmpa \
libgraph \ libgraph \
libregister \ libregister \
libmsprof \
liberror_manager \ liberror_manager \
stub/libascend_hal \ stub/libascend_hal \
@ -272,7 +271,6 @@ LOCAL_SHARED_LIBRARIES := \
libruntime \ libruntime \
libslog \ libslog \
libmmpa \ libmmpa \
libmsprof \
LOCAL_LDFLAGS += $(local_ge_executor_ldflags) LOCAL_LDFLAGS += $(local_ge_executor_ldflags)
@ -304,7 +302,6 @@ LOCAL_SHARED_LIBRARIES := \
libruntime \ libruntime \
libslog \ libslog \
libmmpa \ libmmpa \
libmsprof \
ifeq ($(device_os),android) ifeq ($(device_os),android)
LOCAL_LDFLAGS += -ldl LOCAL_LDFLAGS += -ldl

@ -29,6 +29,8 @@ LIBGE_LOCAL_SRC_FILES := \
common/dump/dump_manager.cc \ common/dump/dump_manager.cc \
common/dump/dump_properties.cc \ common/dump/dump_properties.cc \
common/dump/dump_op.cc \ common/dump/dump_op.cc \
common/profiling/ge_profiling.cc \
common/profiling/ge_runner_profiling.cc \
engine_manager/dnnengine_manager.cc \ engine_manager/dnnengine_manager.cc \
ge_local_engine/engine/host_cpu_engine.cc \ ge_local_engine/engine/host_cpu_engine.cc \
generator/ge_generator.cc \ generator/ge_generator.cc \
@ -307,7 +309,6 @@ LIBGE_LOCAL_SRC_FILES := \
LIBCLIENT_LOCAL_SRC_FILES := \ LIBCLIENT_LOCAL_SRC_FILES := \
proto/ge_api.proto \ proto/ge_api.proto \
client/ge_api.cc \ client/ge_api.cc \
client/ge_prof.cc \
RUNNER_LOCAL_C_INCLUDES := \ RUNNER_LOCAL_C_INCLUDES := \
$(LOCAL_PATH) ./ \ $(LOCAL_PATH) ./ \
@ -372,7 +373,7 @@ LOCAL_SRC_FILES += $(LIBCLIENT_LOCAL_SRC_FILES)
LOCAL_STATIC_LIBRARIES := libge_memory \ LOCAL_STATIC_LIBRARIES := libge_memory \
libadump_server \ libadump_server \
libmsprofiler \ libmsprofiler_fwk \
libmmpa \ libmmpa \
LOCAL_SHARED_LIBRARIES := \ LOCAL_SHARED_LIBRARIES := \
@ -382,7 +383,6 @@ LOCAL_SHARED_LIBRARIES := \
libgraph \ libgraph \
libregister \ libregister \
libge_common \ libge_common \
libmsprof \
liberror_manager \ liberror_manager \
LOCAL_LDFLAGS := -lrt -ldl LOCAL_LDFLAGS := -lrt -ldl
@ -409,7 +409,6 @@ endif
LOCAL_C_INCLUDES := $(RUNNER_LOCAL_C_INCLUDES) LOCAL_C_INCLUDES := $(RUNNER_LOCAL_C_INCLUDES)
LOCAL_SRC_FILES := ../../out/ge/lib64/stub/ge_api.cc \ LOCAL_SRC_FILES := ../../out/ge/lib64/stub/ge_api.cc \
../../out/ge/lib64/stub/ge_prof.cc \
../../out/ge/lib64/stub/ge_ir_build.cc \ ../../out/ge/lib64/stub/ge_ir_build.cc \
LOCAL_SHARED_LIBRARIES := LOCAL_SHARED_LIBRARIES :=
@ -465,7 +464,6 @@ LOCAL_SHARED_LIBRARIES := \
libc_sec \ libc_sec \
libslog \ libslog \
libmmpa \ libmmpa \
libmsprof \
LOCAL_LDFLAGS := -lrt -ldl LOCAL_LDFLAGS := -lrt -ldl
@ -498,7 +496,6 @@ LOCAL_SHARED_LIBRARIES := \
libc_sec \ libc_sec \
libslog \ libslog \
libmmpa \ libmmpa \
libmsprof \
LOCAL_LDFLAGS := -lrt -ldl LOCAL_LDFLAGS := -lrt -ldl

@ -49,8 +49,6 @@ const char *const kIsLastNode = "is_last_node";
const char *const kIsInputVar = "INPUT_IS_VAR"; const char *const kIsInputVar = "INPUT_IS_VAR";
const char *const kIsOutputVar = "OUTPUT_IS_VAR"; const char *const kIsOutputVar = "OUTPUT_IS_VAR";
const char *const kProfilingMode = "PROFILING_MODE"; const char *const kProfilingMode = "PROFILING_MODE";
const char *const kProfilingFpPoint = "FP_POINT";
const char *const kProfilingBpPoint = "BP_POINT";
const uint32_t kProfilingArStep = 2; const uint32_t kProfilingArStep = 2;
const uint64_t kProfilingFpStartLogid = 1; const uint64_t kProfilingFpStartLogid = 1;
const uint64_t kProfilingBpEndLogid = 2; const uint64_t kProfilingBpEndLogid = 2;
@ -810,35 +808,23 @@ Status TaskGenerator::GetFpBpIndex(const ComputeGraphPtr &graph, ProfilingPoint
vector<uint32_t> &all_reduce_nodes, std::string &fp_point_str, vector<uint32_t> &all_reduce_nodes, std::string &fp_point_str,
std::string &bp_point_str) const { std::string &bp_point_str) const {
if (ge::GetContext().GetOption(OPTION_EXEC_PROFILING_FPPONIT_OPTIONS, fp_point_str) == SUCCESS && ProfilingManager::Instance().GetFpBpPoint(fp_point_str, bp_point_str);
ge::GetContext().GetOption(OPTION_EXEC_PROFILING_BPPONIT_OPTIONS, bp_point_str) == SUCCESS &&
!fp_point_str.empty() && !bp_point_str.empty()) {
return SUCCESS;
}
Status ret = SUCCESS; Status ret = SUCCESS;
const char *fp_point = std::getenv(kProfilingFpPoint); if (fp_point_str.empty()) {
if (fp_point == nullptr) {
ret = AutoFindFpOpIndex(graph, profiling_point); ret = AutoFindFpOpIndex(graph, profiling_point);
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGW("First forward profiling op_index not set and FindFpOpIndex failed."); GELOGW("First forward profiling op_index not set and FindFpOpIndex failed.");
return FAILED; return FAILED;
} }
} else {
fp_point_str = string(fp_point);
GELOGI("Get fp_point_str from env %s", fp_point_str.c_str());
} }
const char *bp_point = std::getenv(kProfilingBpPoint); if (bp_point_str.empty()) {
if (bp_point == nullptr) {
ret = AutoFindBpOpIndex(graph, profiling_point, all_reduce_nodes); ret = AutoFindBpOpIndex(graph, profiling_point, all_reduce_nodes);
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGW("Last backward profiling op_index not set and FindBpOpIndex failed."); GELOGW("Last backward profiling op_index not set and FindBpOpIndex failed.");
return FAILED; return FAILED;
} }
} else {
bp_point_str = string(bp_point);
GELOGI("Get bp_point_str from env %s", bp_point_str.c_str());
} }
return SUCCESS; return SUCCESS;

File diff suppressed because it is too large Load Diff

@ -440,7 +440,7 @@ class DavinciModel {
Status SinkTimeProfile(const InputData &current_data); Status SinkTimeProfile(const InputData &current_data);
Status ReportProfilingData(bool check_device = true); Status ReportProfilingData();
void SaveDumpOpInfo(const RuntimeParam &model_param, const OpDescPtr &op, uint32_t task_id, uint32_t stream_id) { void SaveDumpOpInfo(const RuntimeParam &model_param, const OpDescPtr &op, uint32_t task_id, uint32_t stream_id) {
data_dumper_.SaveDumpOpInfo(model_param, op, task_id, stream_id); data_dumper_.SaveDumpOpInfo(model_param, op, task_id, stream_id);

@ -40,9 +40,7 @@ const int kCmdParSize = 2;
const int kDumpCmdPairSize = 2; const int kDumpCmdPairSize = 2;
const std::size_t kProfCmdParaMaxSize = 1000; const std::size_t kProfCmdParaMaxSize = 1000;
const std::size_t kProfStartCmdParaSize = 2; const std::size_t kProfStartCmdParaSize = 2;
const std::string kCmdTypeProfile = "profile";
const std::string kCmdTypeDump = "dump"; const std::string kCmdTypeDump = "dump";
const std::string kCmdTypeProfiling = "profiling";
const std::string kCmdTypeProfInit = "prof_init"; const std::string kCmdTypeProfInit = "prof_init";
const std::string kCmdTypeProfFinalize = "prof_finalize"; const std::string kCmdTypeProfFinalize = "prof_finalize";
const std::string kCmdTypeProfStart = "prof_start"; const std::string kCmdTypeProfStart = "prof_start";
@ -632,8 +630,7 @@ Status ModelManager::Stop(uint32_t model_id) {
/// ///
Status ModelManager::HandleCommand(const Command &command) { Status ModelManager::HandleCommand(const Command &command) {
static const std::map<std::string, std::function<uint32_t(const Command &)>> cmds = { static const std::map<std::string, std::function<uint32_t(const Command &)>> cmds = {
{kCmdTypeProfile, HandleProfileCommand}, {kCmdTypeDump, HandleDumpCommand}, {kCmdTypeDump, HandleDumpCommand}, {kCmdTypeProfInit, HandleProfInitCommand},
{kCmdTypeProfiling, HandleAclProfilingCommand}, {kCmdTypeProfInit, HandleProfInitCommand},
{kCmdTypeProfFinalize, HandleProfFinalizeCommand}, {kCmdTypeProfStart, HandleProfStartCommand}, {kCmdTypeProfFinalize, HandleProfFinalizeCommand}, {kCmdTypeProfStart, HandleProfStartCommand},
{kCmdTypeProfStop, HandleProfStopCommand}, {kCmdTypeProfStop, HandleProfStopCommand},
{kCmdTypeProfModelSubscribe, HandleProfModelSubscribeCommand}, {kCmdTypeProfModelSubscribe, HandleProfModelSubscribeCommand},
@ -648,21 +645,6 @@ Status ModelManager::HandleCommand(const Command &command) {
} }
} }
Status ModelManager::HandleAclProfilingCommand(const Command &command) {
if (command.cmd_params.size() < kCmdParSize) {
GELOGE(PARAM_INVALID, "When the cmd_type is 'profiling', the size of cmd_params must larger than 2.");
return PARAM_INVALID;
}
std::string map_key = command.cmd_params[0];
std::string value = command.cmd_params[1];
if (map_key == PROFILE_CONFIG) {
ProfilingManager::Instance().SetProfilingConfig(value);
}
return SUCCESS;
}
Status ModelManager::GetModelByCmd(const Command &command, Status ModelManager::GetModelByCmd(const Command &command,
std::shared_ptr<DavinciModel> &davinci_model) { std::shared_ptr<DavinciModel> &davinci_model) {
if (command.cmd_params.size() < kCmdParSize) { if (command.cmd_params.size() < kCmdParSize) {
@ -809,29 +791,6 @@ Status ModelManager::HandleProfStopCommand(const Command &command) {
return SUCCESS; return SUCCESS;
} }
Status ModelManager::HandleProfileCommand(const Command &command) {
if (command.cmd_params.size() < kCmdParSize) {
GELOGE(PARAM_INVALID, "When the cmd_type is 'profile', the size of cmd_params must larger than 2.");
return PARAM_INVALID;
}
std::string map_key = command.cmd_params[0];
std::string value = command.cmd_params[1];
GELOGI("Profiling mode, Command key:%s , value:%s ", map_key.c_str(), value.c_str());
auto iter = PROFILE_COMPONENT_MAP.find(map_key);
if (iter != PROFILE_COMPONENT_MAP.end()) {
std::string property_value = (value == "on") ? "1" : "0";
PropertiesManager::Instance().SetPropertyValue(iter->second, property_value);
}
if ((map_key == PROFILER_JOBCTX || map_key == PROFILER_TARGET_PATH || map_key == RTS_PROFILE_PATH)) {
PropertiesManager::Instance().SetPropertyValue(map_key, value);
}
return SUCCESS;
}
static Status ParserPara(const Command &command, const string &dump_key, string &dump_value) { static Status ParserPara(const Command &command, const string &dump_key, string &dump_value) {
auto iter = std::find(command.cmd_params.begin(), command.cmd_params.end(), dump_key); auto iter = std::find(command.cmd_params.begin(), command.cmd_params.end(), dump_key);
if (iter != command.cmd_params.end()) { if (iter != command.cmd_params.end()) {

@ -169,8 +169,6 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ModelManager {
/// @brief comment handle function /// @brief comment handle function
/// ///
ge::Status HandleCommand(const Command &command); ge::Status HandleCommand(const Command &command);
static ge::Status HandleAclProfilingCommand(const Command &command);
static ge::Status HandleProfileCommand(const Command &command);
static ge::Status HandleDumpCommand(const Command &command); static ge::Status HandleDumpCommand(const Command &command);
static ge::Status HandleProfModelSubscribeCommand(const Command &command); static ge::Status HandleProfModelSubscribeCommand(const Command &command);
static ge::Status HandleProfModelUnsubscribeCommand(const Command &command); static ge::Status HandleProfModelUnsubscribeCommand(const Command &command);

@ -260,8 +260,7 @@ Status NodeDoneCallback::ProfilingReport() {
} }
auto &profiling_manager = ProfilingManager::Instance(); auto &profiling_manager = ProfilingManager::Instance();
profiling_manager.ReportProfilingData(model->GetModelId(), task_desc_info, compute_graph_info, profiling_manager.ReportProfilingData(model->GetModelId(), task_desc_info, compute_graph_info);
!profiling_manager.IsAclApiMode());
return SUCCESS; return SUCCESS;
} }

@ -485,11 +485,9 @@ Status GELib::Finalize() {
void GELib::ShutDownProfiling() { void GELib::ShutDownProfiling() {
std::lock_guard<std::mutex> lock(status_mutex_); std::lock_guard<std::mutex> lock(status_mutex_);
if (!ProfilingManager::Instance().ProfilingOpTraceOn() && ProfilingManager::Instance().ProfilingOn()) {
ProfilingManager::Instance().StopProfiling();
}
if (ProfilingManager::Instance().ProfilingOn()) { if (ProfilingManager::Instance().ProfilingOn()) {
ProfilingManager::Instance().PluginUnInit(GE_PROFILING_MODULE); ProfilingManager::Instance().StopProfiling();
ProfilingManager::Instance().PluginUnInit();
} }
} }

@ -167,4 +167,5 @@ Status OpsKernelBuilderManager::GenerateTask(const Node &node,
GELOGD("Done invoking GenerateTask successfully"); GELOGD("Done invoking GenerateTask successfully");
return SUCCESS; return SUCCESS;
} }
} // namespace ge
} // namespace ge

@ -72,8 +72,7 @@ Status ProfilingTaskInfo(OpTask *op_task) {
std::vector<ComputeGraphDescInfo> compute_graph_info; std::vector<ComputeGraphDescInfo> compute_graph_info;
auto &profiling_manager = ProfilingManager::Instance(); auto &profiling_manager = ProfilingManager::Instance();
profiling_manager.ReportProfilingData(model_id, task_desc_info, compute_graph_info, profiling_manager.ReportProfilingData(model_id, task_desc_info, compute_graph_info);
!profiling_manager.IsAclApiMode());
return SUCCESS; return SUCCESS;
} }
} // namespace } // namespace

@ -71,7 +71,7 @@ max_code_len_per_line = 100
when DEBUG on when DEBUG on
""" """
white_list_for_debug = ["attr_value.h", "operator.h", "tensor.h", "graph.h", "operator_factory.h", white_list_for_debug = ["attr_value.h", "operator.h", "tensor.h", "graph.h", "operator_factory.h",
"ge_ir_build.h", "ge_api.h", "ge_prof.h", "tensorflow_parser.h", "caffe_parser.h"] "ge_ir_build.h", "ge_api.h", "tensorflow_parser.h", "caffe_parser.h"]
include_dir_key_words = ["ge", "graph", "parser"] include_dir_key_words = ["ge", "graph", "parser"]
DEBUG = True DEBUG = True

@ -1,102 +0,0 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef INC_EXTERNAL_GE_GE_PROF_H_
#define INC_EXTERNAL_GE_GE_PROF_H_
#include <map>
#include <string>
#include <vector>
#include "ge/ge_api_error_codes.h"
namespace ge {
enum ProfDataTypeConfig {
kProfTaskTime = 0x0002,
kProfAiCoreMetrics = 0x0004,
kProfAicpuTrace = 0x0008,
kProfTrainingTrace = 0x0800,
kProfHcclTrace = 0x1000
};
enum ProfilingAicoreMetrics {
kAicoreArithmaticThroughput = 0,
kAicorePipeline = 1,
kAicoreSynchronization = 2,
kAicoreMemory = 3,
kAicoreInternalMemory = 4,
kAicoreStall = 5
};
typedef struct ProfAicoreEvents ProfAicoreEvents;
typedef struct aclgrphProfConfig aclgrphProfConfig;
///
/// @ingroup AscendCL
/// @brief Initialize the profiling and set profiling configuration path
/// @param [in] profiler_path: configuration path of profiling
/// @param [in] length: length of configuration path
/// @return Status result of function
///
Status aclgrphProfInit(const char *profiler_path, uint32_t length);
///
/// @ingroup AscendCL
/// @brief Finalize profiling
/// @return Status result of function
///
Status aclgrphProfFinalize();
///
/// @ingroup AscendCL
/// @brief Create data of type aclgrphProfConfig
/// @param [in] deviceid_list: device id list
/// @param [in] device_nums: device numbers
/// @param [in] aicore_metrics: type of aicore metrics
/// @param [in] aicore_events: pointer to aicore events be reserved, only support NULL now
/// @param [in] data_type_config: modules need profiling
/// @return Status result of function
///
aclgrphProfConfig *aclgrphProfCreateConfig(uint32_t *deviceid_list, uint32_t device_nums,
ProfilingAicoreMetrics aicore_metrics, ProfAicoreEvents *aicore_events,
uint64_t data_type_config);
///
/// @ingroup AscendCL
/// @brief Destroy data of type aclgrphProfConfig
/// @param [in] profiler_config: config of profiling
/// @return Status result of function
///
Status aclgrphProfDestroyConfig(aclgrphProfConfig *profiler_config);
///
/// @ingroup AscendCL
/// @brief Start profiling of modules which is configured by profiler config
/// @param [in] profiler_config: config of profiling
/// @return Status result of function
///
Status aclgrphProfStart(aclgrphProfConfig *profiler_config);
///
/// @ingroup AscendCL
/// @brief Stop profiling of modules which is configured by profiler config
/// @param [in] profiler_config: config of profiling
/// @return Status result of function
///
Status aclgrphProfStop(aclgrphProfConfig *profiler_config);
} // namespace ge
#endif // INC_EXTERNAL_GE_GE_PROF_H_

@ -0,0 +1,45 @@
/**
* Copyright 2020 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef INC_FRAMEWORK_COMMON_GE_PROFILING_H_
#define INC_FRAMEWORK_COMMON_GE_PROFILING_H_
#include "ge/ge_api_error_codes.h"
#include "toolchain/prof_callback.h"
#define MAX_DEV_NUM (64)
enum ProfCommandHandleType {
kProfCommandhandleInit = 0,
kProfCommandhandleStart,
kProfCommandhandleStop,
kProfCommandhandleFinalize,
kProfCommandhandleModelSubscribe,
kProfCommandhandleModelUnsubscribe
};
struct ProfCommandHandleData {
uint64_t profSwitch;
uint32_t devNums; // length of device id list
uint32_t devIdList[MAX_DEV_NUM];
uint32_t modelId;
};
ge::Status RegProfCtrlCallback(MsprofCtrlCallback func);
ge::Status RegProfSetDeviceCallback(MsprofSetDeviceCallback func);
ge::Status RegProfReporterCallback(MsprofReporterCallback func);
ge::Status ProfCommandHandle(ProfCommandHandleType type, void *data, uint32_t len);
#endif // INC_FRAMEWORK_COMMON_GE_PROFILING_H_

@ -0,0 +1,24 @@
/**
* Copyright 2020 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef INC_FRAMEWORK_COMMON_GE_RUNNER_PROFILING_H_
#define INC_FRAMEWORK_COMMON_GE_RUNNER_PROFILING_H_
#include "profiling/ge_profiling.h"
bool IsInitialize();
#endif // INC_FRAMEWORK_COMMON_GE_RUNNER_PROFILING_H_

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save