profiling AR version 1

pull/576/head
taoxiangdong 4 years ago
parent 8422f4be5c
commit 07f5327b18

@ -60,6 +60,8 @@ set(TRAIN_SRC_LIST
"common/dump/dump_manager.cc"
"common/dump/dump_properties.cc"
"common/dump/dump_op.cc"
"common/profiling/ge_profiling.cc"
"common/profiling/ge_profiling_cb.cc"
"engine_manager/dnnengine_manager.cc"
"ge_local_engine/engine/host_cpu_engine.cc"
"generator/ge_generator.cc"
@ -332,7 +334,6 @@ set(TRAIN_SRC_LIST
"hybrid/hybrid_davinci_model.cc"
"executor/ge_executor.cc"
"client/ge_api.cc"
"client/ge_prof.cc"
"analyzer/analyzer.cc"
"ir_build/ge_ir_build.cc"
"ir_build/atc_ir_common.cc"
@ -649,7 +650,7 @@ target_link_libraries(ge_runner
$<BUILD_INTERFACE:intf_pub>
ge_memory
adump_server
msprofiler
msprofiler_fwk
static_mmpa
-Wl,--no-as-needed
graph
@ -658,7 +659,6 @@ target_link_libraries(ge_runner
register
c_sec
slog
msprof
runtime
resource
error_manager
@ -777,13 +777,12 @@ target_link_libraries(opensrc_ascendcl PRIVATE
register_static
error_manager_static
adump_server
msprofiler
msprofiler_fwk
-Wl,--no-whole-archive
-Wl,--no-as-needed
c_sec
runtime
slog
msprof
ascend_hal_stub
-Wl,--as-needed
-lrt
@ -799,12 +798,10 @@ set_target_properties(opensrc_ascendcl PROPERTIES
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/stub_ge_ir_build.cc
${CMAKE_CURRENT_BINARY_DIR}/stub_ge_api.cc
${CMAKE_CURRENT_BINARY_DIR}/stub_ge_prof.cc
COMMAND echo "Generating stub files."
&& ${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_api.cc stub_ge_api.cc
&& mv ge_prof.cc stub_ge_prof.cc
&& echo "Generating stub files end."
#WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
#DEPENDS stub/gen_stubapi.py ${TOP_DIR}/inc/external ${CMAKE_CURRENT_BINARY_DIR}
@ -813,7 +810,6 @@ add_custom_command(
add_custom_target(ge_stub
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/stub_ge_ir_build.cc
${CMAKE_CURRENT_BINARY_DIR}/stub_ge_api.cc
${CMAKE_CURRENT_BINARY_DIR}/stub_ge_prof.cc
)
##################################################################
@ -855,7 +851,6 @@ target_include_directories(atc_stub_ge_compiler PRIVATE
############ stub/libge_runner.so ############
add_library(fwk_stub_ge_runner SHARED
stub_ge_api.cc
stub_ge_prof.cc
stub_ge_ir_build.cc
)

@ -4,7 +4,6 @@ LOCAL_PATH := $(call my-dir)
COMMON_LOCAL_SRC_FILES := \
proto/ge_api.proto \
ge_api.cc \
ge_prof.cc \
COMMON_LOCAL_C_INCLUDES := \

@ -0,0 +1,176 @@
/**
* 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 MsprofCommandHandle &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 is invalid.");
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 (ge::ProfilingManager::Instance().GetMsprofCallback().msprofCtrlCallback != nullptr) {
GELOGW("Msprof ctrl callback is exist, just ignore it.");
} else {
ge::ProfilingManager::Instance().SetMsprofCtrlCallback(func);
}
return ge::SUCCESS;
}
ge::Status RegProfSetDeviceCallback(MsprofSetDeviceCallback func) {
// Pass MsprofSetDeviceCallback 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 (ge::ProfilingManager::Instance().GetMsprofCallback().msprofCtrlCallback != nullptr) {
GELOGW("Msprof ctrl callback is exist, just ignore it.");
} else {
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 in opskernel so initialize
return ge::SUCCESS;
}
ge::Status ProfCommandHandle(ProfCommandHandleType type, void *data, uint32_t len) {
GE_CHECK_NOTNULL(data);
MsprofCommandHandle *prof_config_param = (MsprofCommandHandle *)data;
if (!isProfConfigValid(prof_config_param->devIdList, prof_config_param->devNums)) {
return ge::FAILED;
}
std::vector<string> prof_params;
if (!TransProfConfigToParam(*prof_config_param, prof_params)) {
GELOGE(ge::PARAM_INVALID, "Transfer profilerConfig to string vector failed");
return ge::PARAM_INVALID;
}
auto iter = kProfCommandTypeMap.find(type);
if (iter == kProfCommandTypeMap.end()) {
GELOGW("The prof comand type is invalid.");
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;
command.module_index = prof_config_param->profSwitch;
GELOGI("GE commandhandle execute, device nums:%s , deviceID:[%s], data type config: 0x%llx", prof_params[0].c_str(),
prof_params[kDeviceListIndex].c_str(), command.module_index);
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 0x%llx.", 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_profiling_cb.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_types.h"
#include "external/register/register_types.h"
#include "toolchain/prof_engine.h"
#include "toolchain/prof_mgr_core.h"
#include "toolchain/prof_acl_api.h"
#include "toolchain/prof_callback.h"
using std::map;
using std::string;
@ -43,29 +41,10 @@ struct DeviceSubsInfo {
uint64_t module;
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:
static Msprof::Engine::Reporter *reporter_;
std::string module_;
};
// register Engine
class ProfilingEngineImpl : public Msprof::Engine::EngineIntf {
public:
ProfilingEngineImpl() {}
~ProfilingEngineImpl() {}
Msprof::Engine::PluginIntf *CreatePlugin();
int ReleasePlugin(Msprof::Engine::PluginIntf *plugin);
struct MsprofCallback {
MsprofCtrlCallback msprofCtrlCallback;
MsprofReporterCallback msprofReporterCallback;
};
class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ProfilingManager {
@ -73,68 +52,50 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ProfilingManager {
ProfilingManager();
virtual ~ProfilingManager();
static ProfilingManager &Instance();
ge::Status Init(const Options &options);
ge::Status InitFromOptions(const Options &options);
ge::Status InitFromAclCfg(const std::string &config);
ge::Status StartProfiling(int32_t iter, int32_t device_id);
void UpdateSubscribeDeviceModuleMap(std::string prof_type, uint32_t device_id, uint64_t module);
ge::Status ProfModelSubscribe(uint64_t module, void *model);
ge::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);
Status Init(const Options &options);
Status ProfInit(uint64_t module);
Status ProfFinalize();
Status ProfStartProfiling(uint64_t module, const std::map<std::string, std::string> &config_para);
Status ProfStopProfiling(uint64_t module, const std::map<std::string, std::string> &config_para);
Status ProfModelSubscribe(uint64_t module, void *model);
Status ProfModelUnsubscribe(void *model);
void StopProfiling();
bool ProfilingOpTraceOn() const { return is_op_trace_; }
bool ProfilingLoadFlag() const { return is_load_; }
bool ProfilingTrainingTraceOn() const { return is_training_trace_; }
bool ProfilingModelLoadOn() const { return is_load_profiling_; }
bool ProfilingModelExecuteOn() const;
bool ProfilingOn() const { return is_load_profiling_ && is_execute_profiling_; } // only used by command pattern
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,
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);
const std::vector<ComputeGraphDescInfo> &compute_graph_desc_info);
void ProfilingTaskDescInfo(uint32_t model_id, const std::vector<TaskDescInfo> &task_desc_info,
const int32_t &device_id);
void ProfilingGraphDescInfo(uint32_t model_id, const std::vector<ComputeGraphDescInfo> &compute_graph_desc_info,
const int32_t &device_id);
void SetProfilingConfig(const string &profiling_cfg);
vector<int32_t> GetProfilingDeviceId() const { return device_id_; }
void PluginUnInit(const std::string &module) const;
Status PluginInit() const;
void PluginUnInit() 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; }
private:
ge::Status ParseFeaturesFromAclCfg(const Json &feature);
ge::Status ProfParseParam(const std::map<std::string, std::string> &config_para, int32_t &device_num,
Status InitFromOptions(const Options &options, MsprofGeOptions &prof_conf);
Status ProfParseParam(const std::map<std::string, std::string> &config_para, int32_t &device_num,
vector<int32_t> &device_list);
ge::Status ProfParseDeviceId(const std::map<std::string, std::string> &config_para,
Status ProfParseDeviceId(const std::map<std::string, std::string> &config_para,
vector<int32_t> &device_list);
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);
bool is_load_profiling_ = false;
bool is_execute_profiling_ = false;
bool is_op_trace_ = false;
bool is_load_ = false;
bool is_training_trace_ = false;
bool is_acl_api_mode_ = false;
int32_t op_trace_iter_num_ = 0;
string job_id_;
string prof_dir_;
void UpdateSubscribeDeviceModuleMap(std::string prof_type, uint32_t device_id, uint64_t module);
bool is_load_profiling_;
bool is_execute_profiling_;
bool is_training_trace_;
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<uint32_t, DeviceSubsInfo> subs_dev_module_; // key: device_id, value: profiling on module
uint32_t subscribe_count_;
std::mutex mutex_;
MsprofCallback prof_cb_;
};
} // namespace ge
#endif // GE_COMMON_PROFILING_PROFILING_MANAGER_H_

@ -17,6 +17,7 @@ set(SRC_LIST
"../common/dump/dump_properties.cc"
"../common/dump/dump_manager.cc"
"../common/dump/dump_op.cc"
"../common/profiling/ge_profiling.cc"
"../graph/load/graph_loader.cc"
"../graph/execute/graph_execute.cc"
"../omm/csa_interact.cc"

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

@ -8,6 +8,7 @@ local_ge_executor_src_files := \
../common/dump/dump_op.cc \
../common/ge/plugin_manager.cc \
../common/ge/op_tiling_manager.cc \
../common/profiling/ge_profiling.cc \
../graph/load/graph_loader.cc \
../graph/execute/graph_execute.cc \
../omm/csa_interact.cc \

@ -29,6 +29,7 @@ LIBGE_LOCAL_SRC_FILES := \
common/dump/dump_manager.cc \
common/dump/dump_properties.cc \
common/dump/dump_op.cc \
common/profiling/ge_profiling.cc \
engine_manager/dnnengine_manager.cc \
ge_local_engine/engine/host_cpu_engine.cc \
generator/ge_generator.cc \
@ -307,7 +308,6 @@ LIBGE_LOCAL_SRC_FILES := \
LIBCLIENT_LOCAL_SRC_FILES := \
proto/ge_api.proto \
client/ge_api.cc \
client/ge_prof.cc \
RUNNER_LOCAL_C_INCLUDES := \
$(LOCAL_PATH) ./ \
@ -409,7 +409,6 @@ endif
LOCAL_C_INCLUDES := $(RUNNER_LOCAL_C_INCLUDES)
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 \
LOCAL_SHARED_LIBRARIES :=

File diff suppressed because it is too large Load Diff

@ -440,7 +440,7 @@ class DavinciModel {
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) {
data_dumper_.SaveDumpOpInfo(model_param, op, task_id, stream_id);

@ -40,9 +40,7 @@ const int kCmdParSize = 2;
const int kDumpCmdPairSize = 2;
const std::size_t kProfCmdParaMaxSize = 1000;
const std::size_t kProfStartCmdParaSize = 2;
const std::string kCmdTypeProfile = "profile";
const std::string kCmdTypeDump = "dump";
const std::string kCmdTypeProfiling = "profiling";
const std::string kCmdTypeProfInit = "prof_init";
const std::string kCmdTypeProfFinalize = "prof_finalize";
const std::string kCmdTypeProfStart = "prof_start";
@ -632,8 +630,7 @@ Status ModelManager::Stop(uint32_t model_id) {
///
Status ModelManager::HandleCommand(const Command &command) {
static const std::map<std::string, std::function<uint32_t(const Command &)>> cmds = {
{kCmdTypeProfile, HandleProfileCommand}, {kCmdTypeDump, HandleDumpCommand},
{kCmdTypeProfiling, HandleAclProfilingCommand}, {kCmdTypeProfInit, HandleProfInitCommand},
{kCmdTypeDump, HandleDumpCommand}, {kCmdTypeProfInit, HandleProfInitCommand},
{kCmdTypeProfFinalize, HandleProfFinalizeCommand}, {kCmdTypeProfStart, HandleProfStartCommand},
{kCmdTypeProfStop, HandleProfStopCommand},
{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,
std::shared_ptr<DavinciModel> &davinci_model) {
if (command.cmd_params.size() < kCmdParSize) {
@ -809,29 +791,6 @@ Status ModelManager::HandleProfStopCommand(const Command &command) {
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) {
auto iter = std::find(command.cmd_params.begin(), command.cmd_params.end(), dump_key);
if (iter != command.cmd_params.end()) {

@ -169,8 +169,6 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ModelManager {
/// @brief comment handle function
///
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 HandleProfModelSubscribeCommand(const Command &command);
static ge::Status HandleProfModelUnsubscribeCommand(const Command &command);

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

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

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

@ -71,7 +71,7 @@ max_code_len_per_line = 100
when DEBUG on
"""
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"]
DEBUG = True

@ -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 {
unit64_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_PROFILING_CB_H_
#define INC_FRAMEWORK_COMMON_GE_PROFILING_CB_H_
#include "profiling/ge_profiling.h"
bool IsInitialize();
#endif // INC_FRAMEWORK_COMMON_GE_PROFILING_CB_H_
Loading…
Cancel
Save