Browse Source

common log optimize

pull/1572/head
liyihan2@huawei.com 4 years ago
parent
commit
f4cbb12d60
6 changed files with 187 additions and 82 deletions
  1. +4
    -1
      ge/common/kernel_store.cc
  2. +15
    -5
      ge/common/model_parser/model_parser.cc
  3. +9
    -6
      ge/common/model_saver.cc
  4. +15
    -6
      ge/common/op/ge_op_utils.cc
  5. +22
    -13
      ge/common/profiling/ge_profiling.cc
  6. +122
    -51
      ge/common/profiling/profiling_manager.cc

+ 4
- 1
ge/common/kernel_store.cc View File

@@ -37,7 +37,10 @@ bool KernelStore::Build() {
try { try {
buffer_.resize(total_len); buffer_.resize(total_len);
} catch (std::bad_alloc &e) { } catch (std::bad_alloc &e) {
GELOGE(ge::MEMALLOC_FAILED, "All build memory failed, memory size %zu", total_len);
GELOGE(ge::MEMALLOC_FAILED, "[Malloc][Memmory]All build memory failed, memory size %zu, exception %s",
total_len, e.what());
REPORT_CALL_ERROR("E19999", "All build memory failed, memory size %zu, exception %s",
total_len, e.what());
return false; return false;
} }




+ 15
- 5
ge/common/model_parser/model_parser.cc View File

@@ -31,18 +31,24 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelParserBase::LoadFro
ge::ModelData &model_data) { ge::ModelData &model_data) {
std::string real_path = RealPath(model_path); std::string real_path = RealPath(model_path);
if (real_path.empty()) { if (real_path.empty()) {
GELOGE(ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID, "Model file path '%s' is invalid", model_path);
GELOGE(ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID, "[Check][Param]Model file path %s is invalid",
model_path);
REPORT_INNER_ERROR("E19999", "Model file path %s is invalid", model_path);
return ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID; return ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID;
} }


if (GetFileLength(model_path) == -1) { if (GetFileLength(model_path) == -1) {
GELOGE(ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID, "File size not valid, file: %s.", model_path);
GELOGE(ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID, "[Check][Param]File size not valid, file %s",
model_path);
REPORT_INNER_ERROR("E19999", "File size not valid, file %s", model_path);
return ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID; return ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID;
} }


std::ifstream fs(real_path.c_str(), std::ifstream::binary); std::ifstream fs(real_path.c_str(), std::ifstream::binary);
if (!fs.is_open()) { if (!fs.is_open()) {
GELOGE(ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID, "Open file: %s failed, error: %s", model_path, strerror(errno));
GELOGE(ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID, "[Open][File]Failed, file %s, error %s",
model_path, strerror(errno));
REPORT_CALL_ERROR("E19999", "Open file %s failed, error %s", model_path, strerror(errno));
return ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID; return ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID;
} }


@@ -56,7 +62,10 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelParserBase::LoadFro


char *data = new (std::nothrow) char[len]; char *data = new (std::nothrow) char[len];
if (data == nullptr) { if (data == nullptr) {
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "Load model From file failed, bad memory allocation occur. (need:%u)", len);
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "[Load][ModelFromFile]Failed, "
"bad memory allocation occur(need %u), file %s", len, model_path);
REPORT_CALL_ERROR("E19999", "Load model from file %s failed, "
"bad memory allocation occur(need %u)", model_path, len);
return ACL_ERROR_GE_MEMORY_ALLOCATION; return ACL_ERROR_GE_MEMORY_ALLOCATION;
} }


@@ -105,7 +114,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelParserBase::ParseMo
model_len = file_header->length; model_len = file_header->length;
GELOGD("Model_len is %u, model_file_head_len is %zu.", model_len, sizeof(ModelFileHeader)); GELOGD("Model_len is %u, model_file_head_len is %zu.", model_len, sizeof(ModelFileHeader));
} else { } else {
GELOGE(ACL_ERROR_GE_PARAM_INVALID, "Invalid model. ModelEncryptType not supported.");
GELOGE(ACL_ERROR_GE_PARAM_INVALID, "[Check][Param]Invalid, model encrypt type not supported");
REPORT_CALL_ERROR("E19999","Invalid model ,encrypt type not supported");
res = ACL_ERROR_GE_PARAM_INVALID; res = ACL_ERROR_GE_PARAM_INVALID;
} }




+ 9
- 6
ge/common/model_saver.cc View File

@@ -33,7 +33,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelSaver::SaveJsonToFi
const Json &model) { const Json &model) {
Status ret = SUCCESS; Status ret = SUCCESS;
if (file_path == nullptr || SUCCESS != CheckPath(file_path)) { if (file_path == nullptr || SUCCESS != CheckPath(file_path)) {
GELOGE(FAILED, "Check output file failed.");
GELOGE(FAILED, "[Check][OutputFile]Failed, file %s", file_path);
REPORT_CALL_ERROR("E19999", "Output file %s check invalid", file_path);
return FAILED; return FAILED;
} }
std::string model_str; std::string model_str;
@@ -41,11 +42,12 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelSaver::SaveJsonToFi
model_str = model.dump(kInteval, ' ', false, Json::error_handler_t::ignore); model_str = model.dump(kInteval, ' ', false, Json::error_handler_t::ignore);
} catch (std::exception &e) { } catch (std::exception &e) {
ErrorManager::GetInstance().ATCReportErrMessage("E19007", {"exception"}, {e.what()}); ErrorManager::GetInstance().ATCReportErrMessage("E19007", {"exception"}, {e.what()});
GELOGE(FAILED, "Failed to convert JSON to string, reason: %s.", e.what());
GELOGE(FAILED, "[Convert][File]Failed to convert JSON to string, file %s, reason %s",
file_path, e.what());
return FAILED; return FAILED;
} catch (...) { } catch (...) {
ErrorManager::GetInstance().ATCReportErrMessage("E19008"); ErrorManager::GetInstance().ATCReportErrMessage("E19008");
GELOGE(FAILED, "Failed to convert JSON to string.");
GELOGE(FAILED, "[Convert][File]Failed to convert JSON to string, file %s", file_path);
return FAILED; return FAILED;
} }


@@ -59,7 +61,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelSaver::SaveJsonToFi
int32_t fd = mmOpen2(real_path, M_RDWR | M_CREAT | O_TRUNC, mode); int32_t fd = mmOpen2(real_path, M_RDWR | M_CREAT | O_TRUNC, mode);
if (fd == EN_ERROR || fd == EN_INVALID_PARAM) { if (fd == EN_ERROR || fd == EN_INVALID_PARAM) {
ErrorManager::GetInstance().ATCReportErrMessage("E19001", {"file", "errmsg"}, {file_path, strerror(errno)}); ErrorManager::GetInstance().ATCReportErrMessage("E19001", {"file", "errmsg"}, {file_path, strerror(errno)});
GELOGE(FAILED, "Open file[%s] failed. %s", file_path, strerror(errno));
GELOGE(FAILED, "[Open][File]Failed, file %s, error %s", file_path, strerror(errno));
return FAILED; return FAILED;
} }
const char *model_char = model_str.c_str(); const char *model_char = model_str.c_str();
@@ -70,12 +72,13 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelSaver::SaveJsonToFi
ErrorManager::GetInstance().ATCReportErrMessage( ErrorManager::GetInstance().ATCReportErrMessage(
"E19004", {"file", "errmsg"}, {file_path, strerror(errno)}); "E19004", {"file", "errmsg"}, {file_path, strerror(errno)});
// Need to both print the error info of mmWrite and mmClose, so return ret after mmClose // Need to both print the error info of mmWrite and mmClose, so return ret after mmClose
GELOGE(FAILED, "Write to file failed. errno = %ld, %s", mmpa_ret, strerror(errno));
GELOGE(FAILED, "[Write][Data]Write to file failed. errno = %ld, %s", mmpa_ret, strerror(errno));
ret = FAILED; ret = FAILED;
} }
// Close file // Close file
if (mmClose(fd) != EN_OK) { if (mmClose(fd) != EN_OK) {
GELOGE(FAILED, "Close file failed.");
GELOGE(FAILED, "[Close][File]Failed, file %s", file_path);
REPORT_CALL_ERROR("E19999", "Close file %s failed", file_path)
ret = FAILED; ret = FAILED;
} }
return ret; return ret;


+ 15
- 6
ge/common/op/ge_op_utils.cc View File

@@ -239,7 +239,8 @@ Status OpUtils::SetDataByDataType(size_t out_size, const std::vector<char *> &ch
const std::vector<char *> &chunk_output, GeTensor *output) { const std::vector<char *> &chunk_output, GeTensor *output) {
unique_ptr<T[]> output_data(new (std::nothrow) T[out_size]()); unique_ptr<T[]> output_data(new (std::nothrow) T[out_size]());
if (output_data == nullptr) { if (output_data == nullptr) {
GELOGE(MEMALLOC_FAILED, "New buf failed");
GELOGE(MEMALLOC_FAILED, "[Malloc][Data]New buf failed");
REPORT_CALL_ERROR("E19999", "New buf failed");
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }


@@ -275,7 +276,8 @@ Status OpUtils::SetOutputSliceDataByDataType(void *data, int64_t data_size, cons
int64_t dim_i = input_dims[i]; int64_t dim_i = input_dims[i];
int64_t stride_i = stride[i]; int64_t stride_i = stride[i];
if (dim_i == 0) { if (dim_i == 0) {
GELOGE(PARAM_INVALID, "Dim_i of size tensor can't be 0.");
GELOGE(PARAM_INVALID, "[Check][Param]Invalid, Dim_i of size tensor is 0");
REPORT_INNER_ERROR("E19999", "Dim_i of size tensor is 0, invalid");
return PARAM_INVALID; return PARAM_INVALID;
} }
chunk_size = chunk_size / dim_i; chunk_size = chunk_size / dim_i;
@@ -299,7 +301,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status OpUtils::SetOutputSliceD
void *data, int64_t data_size, int32_t data_type, std::vector<int64_t> &input_dims, std::vector<int64_t> &begin, void *data, int64_t data_size, int32_t data_type, std::vector<int64_t> &input_dims, std::vector<int64_t> &begin,
std::vector<int64_t> &output_dims, GeTensor *output, std::vector<int64_t> &stride) { std::vector<int64_t> &output_dims, GeTensor *output, std::vector<int64_t> &stride) {
if (data == nullptr || output == nullptr) { if (data == nullptr || output == nullptr) {
GELOGE(PARAM_INVALID, "Input param is nullptr.");
GELOGE(PARAM_INVALID, "[Check][Param]Input param is nullptr");
REPORT_INNER_ERROR("E19999", "Input param is nullptr");
return PARAM_INVALID; return PARAM_INVALID;
} }


@@ -436,14 +439,18 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status OpUtils::SetWeights(ge::
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status
OpUtils::GetShapeDataFromConstTensor(const ConstGeTensorPtr &tensor, DataType type, std::vector<int64_t> &dims) { OpUtils::GetShapeDataFromConstTensor(const ConstGeTensorPtr &tensor, DataType type, std::vector<int64_t> &dims) {
if (tensor == nullptr) { if (tensor == nullptr) {
GELOGE(PARAM_INVALID, "Input tensor is nullptr");
GELOGE(PARAM_INVALID, "[Check][Param]Input tensor is nullptr");
REPORT_INNER_ERROR("E19999","Input tensor is nullptr");
return PARAM_INVALID; return PARAM_INVALID;
} }


// If the tensor data is a vector, the shape dimension must be 1 // If the tensor data is a vector, the shape dimension must be 1
if (tensor->GetTensorDesc().GetShape().GetDims().size() > 1) { if (tensor->GetTensorDesc().GetShape().GetDims().size() > 1) {
GELOGE(PARAM_INVALID, "The dimension of the input tensor shape cannot be more than 1, it is %zu",
GELOGE(PARAM_INVALID, "[Check][Param]The dimension of the input tensor shape "
"cannot be more than 1, it is %zu",
tensor->GetTensorDesc().GetShape().GetDims().size()); tensor->GetTensorDesc().GetShape().GetDims().size());
REPORT_CALL_ERRPR("E19999", "The dimension of the input tensor shape %zu invalid, "
"more than 1", tensor->GetTensorDesc().GetShape().GetDims().size());
return PARAM_INVALID; return PARAM_INVALID;
} }


@@ -462,8 +469,10 @@ OpUtils::GetShapeDataFromConstTensor(const ConstGeTensorPtr &tensor, DataType ty
dims.push_back(shape_data[i]); dims.push_back(shape_data[i]);
} }
} else { } else {
GELOGE(PARAM_INVALID, "Data type only can be DT_INT32 or DT_INT64. type is %s",
GELOGE(PARAM_INVALID, "[Check][DataType]Invalid, type only can be DT_INT32 or DT_INT64, type is %s",
TypeUtils::DataTypeToSerialString(type).c_str()); TypeUtils::DataTypeToSerialString(type).c_str());
REPORT_INNER_ERROR("E19999", "Data type %s check invalid, only can be DT_INT32 or DT_INT64",
TypeUtils::DataTypeToSerialString(type).c_str());
return PARAM_INVALID; return PARAM_INVALID;
} }




+ 22
- 13
ge/common/profiling/ge_profiling.cc View File

@@ -67,11 +67,12 @@ bool TransProfConfigToParam(const ProfCommandHandleData &profCommand, vector<str


bool isProfConfigValid(const uint32_t *deviceid_list, uint32_t device_nums) { bool isProfConfigValid(const uint32_t *deviceid_list, uint32_t device_nums) {
if (deviceid_list == nullptr) { if (deviceid_list == nullptr) {
GELOGE(ge::PARAM_INVALID, "deviceIdList is nullptr");
GELOGE(ge::PARAM_INVALID, "[Check][DeviceIDList]Invalid, it is nullptr");
return false; return false;
} }
if (device_nums == 0 || device_nums > MAX_DEV_NUM) { if (device_nums == 0 || device_nums > MAX_DEV_NUM) {
GELOGE(ge::PARAM_INVALID, "The device nums: %u is invalid.", device_nums);
GELOGE(ge::PARAM_INVALID, "[Check][DeviceNums]Invalid, device nums: %u", device_nums);
REPORT_INNER_ERROR("E19999", "DeviceNums %u check invalid", device_nums);
return false; return false;
} }


@@ -79,12 +80,14 @@ bool isProfConfigValid(const uint32_t *deviceid_list, uint32_t device_nums) {
int32_t dev_count = 0; int32_t dev_count = 0;
rtError_t rt_err = rtGetDeviceCount(&dev_count); rtError_t rt_err = rtGetDeviceCount(&dev_count);
if (rt_err != RT_ERROR_NONE) { if (rt_err != RT_ERROR_NONE) {
GELOGE(ge::INTERNAL_ERROR, "Get the Device count fail.");
GELOGE(ge::INTERNAL_ERROR, "[Get][DeviceCount]Failed, error_code %d", rt_err);
REPORT_CALL_ERROR("E19999", "Get device count failed, error_code %d", rt_err);
return false; return false;
} }


if (device_nums > static_cast<uint32_t>(dev_count)) { 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);
GELOGE(ge::PARAM_INVALID, "[Check][Param]Device num %u is not in range [1,%d]", device_nums, dev_count);
REPORT_INNER_ERROR("E19999", "Device num %u check invalid, it is not in range [1,%d]", device_nums, dev_count);
return false; return false;
} }


@@ -92,11 +95,13 @@ bool isProfConfigValid(const uint32_t *deviceid_list, uint32_t device_nums) {
for (size_t i = 0; i < device_nums; ++i) { for (size_t i = 0; i < device_nums; ++i) {
uint32_t dev_id = deviceid_list[i]; uint32_t dev_id = deviceid_list[i];
if (dev_id >= static_cast<uint32_t>(dev_count)) { 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);
GELOGE(ge::PARAM_INVALID, "[Check][DeviceId]Device id %u is not in range [0,%d)", dev_id, dev_count);
REPORT_CALL_ERROR("E19999", "Device id %u is not in range [0,%d)", dev_id, dev_count);
return false; return false;
} }
if (record.count(dev_id) > 0) { if (record.count(dev_id) > 0) {
GELOGE(ge::PARAM_INVALID, "Device id %u is duplicatedly set", dev_id);
GELOGE(ge::PARAM_INVALID, "[Check][DeviceId]Device id %u is duplicatedly set", dev_id);
REPORT_CALL_ERROR("E19999", "Device id %u is not unique, duplicatedly set", dev_id);
return false; return false;
} }
record.insert(dev_id); record.insert(dev_id);
@@ -106,7 +111,7 @@ bool isProfConfigValid(const uint32_t *deviceid_list, uint32_t device_nums) {


ge::Status RegProfCtrlCallback(MsprofCtrlCallback func) { ge::Status RegProfCtrlCallback(MsprofCtrlCallback func) {
if (func == nullptr) { if (func == nullptr) {
GELOGE(ge::PARAM_INVALID, "Msprof ctrl callback is nullptr.");
GELOGE(ge::PARAM_INVALID, "[Check][Param]Msprof ctrl callback is nullptr");
return ge::PARAM_INVALID; return ge::PARAM_INVALID;
} }
if (ge::ProfilingManager::Instance().GetMsprofCallback().msprofCtrlCallback != nullptr) { if (ge::ProfilingManager::Instance().GetMsprofCallback().msprofCtrlCallback != nullptr) {
@@ -119,13 +124,13 @@ ge::Status RegProfCtrlCallback(MsprofCtrlCallback func) {


ge::Status RegProfSetDeviceCallback(MsprofSetDeviceCallback func) { ge::Status RegProfSetDeviceCallback(MsprofSetDeviceCallback func) {
if (func == nullptr) { if (func == nullptr) {
GELOGE(ge::PARAM_INVALID, "MsprofSetDeviceCallback callback is nullptr.");
GELOGE(ge::PARAM_INVALID, "[Check][Param]MsprofSetDeviceCallback callback is nullptr.");
return ge::PARAM_INVALID; return ge::PARAM_INVALID;
} }
// Pass MsprofSetDeviceCallback to runtime // Pass MsprofSetDeviceCallback to runtime
ge::Status rt_ret = rtRegDeviceStateCallback(kRtSetDeviceRegName.c_str(), static_cast<rtDeviceStateCallback>(func)); ge::Status rt_ret = rtRegDeviceStateCallback(kRtSetDeviceRegName.c_str(), static_cast<rtDeviceStateCallback>(func));
if (rt_ret != ge::SUCCESS) { if (rt_ret != ge::SUCCESS) {
GELOGE(rt_ret, "Pass MsprofSetDeviceCallback to runtime failed!");
GELOGE(rt_ret, "[Pass][MsprofSetDeviceCallback]Pass it to runtime failed!");
return rt_ret; return rt_ret;
} }
return ge::SUCCESS; return ge::SUCCESS;
@@ -133,7 +138,7 @@ ge::Status RegProfSetDeviceCallback(MsprofSetDeviceCallback func) {


ge::Status RegProfReporterCallback(MsprofReporterCallback func) { ge::Status RegProfReporterCallback(MsprofReporterCallback func) {
if (func == nullptr) { if (func == nullptr) {
GELOGE(ge::PARAM_INVALID, "MsprofReporterCallback callback is nullptr.");
GELOGE(ge::PARAM_INVALID, "[Check][Param]MsprofReporterCallback callback is nullptr.");
return ge::PARAM_INVALID; return ge::PARAM_INVALID;
} }
if (ge::ProfilingManager::Instance().GetMsprofCallback().msprofReporterCallback != nullptr) { if (ge::ProfilingManager::Instance().GetMsprofCallback().msprofReporterCallback != nullptr) {
@@ -144,7 +149,8 @@ ge::Status RegProfReporterCallback(MsprofReporterCallback 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) {
GELOGE(rt_ret, "Pass MsprofReporterCallback to runtime failed!!");
GELOGE(rt_ret, "[Pass][Param]Pass MsprofReporterCallback to runtime failed, error_code %u", rt_ret);
REPORT_CALL_ERROR("E19999", "Pass MsprofReporterCallback to runtime failed, error_code %u", rt_ret);
return rt_ret; return rt_ret;
} }
// Pass MsprofReporterCallback to hccl // Pass MsprofReporterCallback to hccl
@@ -169,7 +175,7 @@ ge::Status ProfCommandHandle(ProfCommandHandleType type, void *data, uint32_t le
} }
if (!TransProfConfigToParam(*prof_config_param, prof_params)) { if (!TransProfConfigToParam(*prof_config_param, prof_params)) {
GELOGE(ge::PARAM_INVALID, "Transfer profilerConfig to string vector failed");
GELOGE(ge::PARAM_INVALID, "[Check][Param]Transfer profilerConfig to string vector failed");
return ge::PARAM_INVALID; return ge::PARAM_INVALID;
} }
} }
@@ -188,7 +194,10 @@ ge::Status ProfCommandHandle(ProfCommandHandleType type, void *data, uint32_t le
} }
ge::Status ret = graph_loader.CommandHandle(command); ge::Status ret = graph_loader.CommandHandle(command);
if (ret != ge::SUCCESS) { if (ret != ge::SUCCESS) {
GELOGE(ret, "Handle profiling command failed");
GELOGE(ret, "[Handle][Command]Handle profiling command failed, command type %s, error_code %u",
iter->second.c_str(), ret);
REPORT_CALL_ERROR("E19999", "Handle profiling command failed, command type %s, error_code %u",
iter->second.c_str(), ret);
return ge::FAILED; return ge::FAILED;
} }




+ 122
- 51
ge/common/profiling/profiling_manager.cc View File

@@ -87,21 +87,25 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ge::Status ProfilingManager::In
struct MsprofGeOptions prof_conf = {{ 0 }}; struct MsprofGeOptions prof_conf = {{ 0 }};
Status ret = InitFromOptions(options, prof_conf); Status ret = InitFromOptions(options, prof_conf);
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGE(ret, "Failed to init profiling.");
GELOGE(ret, "[Init][Profiling]Failed, error_code %u", ret);
REPORT_CALL_ERROR("E19999", "Init profiling failed, error_code %u", ret);
return ret; return ret;
} }


if (is_execute_profiling_) { if (is_execute_profiling_) {
if (prof_cb_.msprofCtrlCallback == nullptr) { if (prof_cb_.msprofCtrlCallback == nullptr) {
GELOGE(ge::PARAM_INVALID, "MsprofCtrlCallback callback is nullptr.");
GELOGE(ge::PARAM_INVALID, "[Check][Param]MsprofCtrlCallback callback is nullptr");
REPORT_CALL_ERROR("E19999", "MsprofCtrlCallback callback is nullptr");
return ge::PARAM_INVALID; return ge::PARAM_INVALID;
} }
int32_t cb_ret = prof_cb_.msprofCtrlCallback( int32_t cb_ret = prof_cb_.msprofCtrlCallback(
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) {
GELOGE(FAILED, "Call msprofCtrlCallback failed, type:%u, return:%d",
GELOGE(FAILED, "[Call][msprofCtrlCallback]Failed, type %u, return %d",
static_cast<uint32_t>(MsprofCtrlCallbackType::MSPROF_CTRL_INIT_GE_OPTIONS), cb_ret); static_cast<uint32_t>(MsprofCtrlCallbackType::MSPROF_CTRL_INIT_GE_OPTIONS), cb_ret);
REPORT_CALL_ERROR("E19999", "Call msprofCtrlCallback failed, type %u, return %d",
static_cast<uint32_t>(MsprofCtrlCallbackType::MSPROF_CTRL_INIT_GE_OPTIONS), cb_ret);
return FAILED; return FAILED;
} }
GELOGI("Profiling init success"); GELOGI("Profiling init success");
@@ -122,7 +126,8 @@ ge::Status ProfilingManager::InitFromOptions(const Options &options, MsprofGeOpt
// enable profiling by ge option // enable profiling by ge option
if (strncpy_s(prof_conf.options, MSPROF_OPTIONS_DEF_LEN_MAX, options.profiling_options.c_str(), if (strncpy_s(prof_conf.options, MSPROF_OPTIONS_DEF_LEN_MAX, options.profiling_options.c_str(),
MSPROF_OPTIONS_DEF_LEN_MAX - 1) != EOK) { MSPROF_OPTIONS_DEF_LEN_MAX - 1) != EOK) {
GELOGE(INTERNAL_ERROR, "copy profiling_options failed.");
GELOGE(INTERNAL_ERROR, "[copy][ProfilingOptions]Failed, options %s", options.profiling_options.c_str());
REPORT_CALL_ERROR("E19999", "Copy profiling_options %s failed", options.profiling_options.c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
is_execute_profiling_ = true; is_execute_profiling_ = true;
@@ -147,13 +152,17 @@ ge::Status ProfilingManager::InitFromOptions(const Options &options, MsprofGeOpt
// Parse json str for bp fp // Parse json str for bp fp
Status ret = ParseOptions(prof_conf.options); Status ret = ParseOptions(prof_conf.options);
if (ret != ge::SUCCESS) { if (ret != ge::SUCCESS) {
GELOGE(ge::PARAM_INVALID, "Parse training trace param failed.");
GELOGE(ge::PARAM_INVALID, "[Parse][Options]Parse training trace param %s failed, error_code %u",
prof_conf.options, ret);
REPORT_CALL_ERROR("E19999", "Parse training trace param %s failed, error_code %u",
prof_conf.options, ret);
return ge::PARAM_INVALID; return ge::PARAM_INVALID;
} }


if (strncpy_s(prof_conf.jobId, MSPROF_OPTIONS_DEF_LEN_MAX, options.job_id.c_str(), MSPROF_OPTIONS_DEF_LEN_MAX - 1) != if (strncpy_s(prof_conf.jobId, MSPROF_OPTIONS_DEF_LEN_MAX, options.job_id.c_str(), MSPROF_OPTIONS_DEF_LEN_MAX - 1) !=
EOK) { EOK) {
GELOGE(INTERNAL_ERROR, "copy job_id failed.");
GELOGE(INTERNAL_ERROR, "[Copy][JobId]Failed, original job_id %s", options.job_id.c_str());
REPORT_CALL_ERROR("E19999", "Copy job_id %s failed", options.job_id.c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
GELOGI("Job id: %s, original job id: %s.", prof_conf.jobId, options.job_id.c_str()); GELOGI("Job id: %s, original job id: %s.", prof_conf.jobId, options.job_id.c_str());
@@ -163,7 +172,8 @@ ge::Status ProfilingManager::InitFromOptions(const Options &options, MsprofGeOpt


ge::Status ProfilingManager::ParseOptions(const std::string &options) { ge::Status ProfilingManager::ParseOptions(const std::string &options) {
if (options.empty()) { if (options.empty()) {
GELOGE(ge::PARAM_INVALID, "Profiling options is empty.");
GELOGE(ge::PARAM_INVALID, "[Check][Param]Profiling options is empty");
REPORT_INNER_ERROR("E19999", "Profiling options is empty");
return ge::PARAM_INVALID; return ge::PARAM_INVALID;
} }
try { try {
@@ -178,7 +188,8 @@ ge::Status ProfilingManager::ParseOptions(const std::string &options) {
} }
GELOGI("GE profiling training trace:%s", training_trace.c_str()); GELOGI("GE profiling training trace:%s", training_trace.c_str());
if (training_trace != "on") { if (training_trace != "on") {
GELOGE(ge::PARAM_INVALID, "Training trace param:%s is invalid.", training_trace.c_str());
GELOGE(ge::PARAM_INVALID, "[Check][Param]Training trace param:%s is invalid.", training_trace.c_str());
REPORT_CALL_ERROR("E19999", "Training trace param:%s is invalid.", training_trace.c_str());
return ge::PARAM_INVALID; return ge::PARAM_INVALID;
} }
fp_point_ = prof_options[kFpPoint]; fp_point_ = prof_options[kFpPoint];
@@ -188,7 +199,8 @@ ge::Status ProfilingManager::ParseOptions(const std::string &options) {
} }
is_training_trace_ = true; is_training_trace_ = true;
} catch (...) { } catch (...) {
GELOGE(FAILED, "Json prof_conf options is invalid.");
GELOGE(FAILED, "[Check][Param]Json prof_conf options is invalid");
REPORT_INNER_ERRO("E19999", "Json prof_conf options is invalid");
return ge::PARAM_INVALID; return ge::PARAM_INVALID;
} }
return ge::SUCCESS; return ge::SUCCESS;
@@ -202,7 +214,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::StopProf
if (device_num != 0) { if (device_num != 0) {
auto device_id_ptr = std::unique_ptr<uint32_t[]>(new (std::nothrow) uint32_t[device_num]); auto device_id_ptr = std::unique_ptr<uint32_t[]>(new (std::nothrow) uint32_t[device_num]);
if (device_id_ptr == nullptr) { if (device_id_ptr == nullptr) {
GELOGE(FAILED, "Stop profiling: device id ptr is null.");
GELOGE(FAILED, "[Stop][Profiling]Device id ptr is null.");
REPORT_INNER_ERROR("E19999", "Stop profiling, device id ptr is null");
return; return;
} }
for (int32_t i = 0; i < device_num; i++) { for (int32_t i = 0; i < device_num; i++) {
@@ -216,7 +229,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::StopProf


// stop profiling // stop profiling
if (prof_cb_.msprofCtrlCallback == nullptr) { if (prof_cb_.msprofCtrlCallback == nullptr) {
GELOGE(ge::PARAM_INVALID, "MsprofCtrlCallback callback is nullptr.");
GELOGE(ge::PARAM_INVALID, "[Check][Param]MsprofCtrlCallback callback is nullptr");
REPORT_INNER_ERROR("E19999", "MsprofCtrlCallback callback is nullptr");
return; return;
} }
int32_t cb_ret = prof_cb_.msprofCtrlCallback(static_cast<uint32_t>(MsprofCtrlCallbackType::MSPROF_CTRL_FINALIZE), int32_t cb_ret = prof_cb_.msprofCtrlCallback(static_cast<uint32_t>(MsprofCtrlCallbackType::MSPROF_CTRL_FINALIZE),
@@ -278,10 +292,12 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::Profilin
try { try {
reported_data = task_info.dump(kInteval, ' ', false, Json::error_handler_t::ignore); reported_data = task_info.dump(kInteval, ' ', false, Json::error_handler_t::ignore);
} catch (std::exception &e) { } catch (std::exception &e) {
GELOGE(FAILED, "Failed to convert JSON to string, reason: %s.", e.what());
GELOGE(FAILED, "[Convert][ReportData]Failed to convert json to string, reason %s.", e.what());
REPORT_CALL_ERROR("E19999", "Failed to convert reported_data from json to string, reason %s", e.what());
return ; return ;
} catch (...) { } catch (...) {
GELOGE(FAILED, "Failed to convert JSON to string.");
GELOGE(FAILED, "[Convert][ReportedData]Failed to convert JSON to string");
REPORT_CALL_ERROR("E19999", "Failed to convert reported data from json to string");
return; return;
} }
reported_data.append(",") reported_data.append(",")
@@ -300,7 +316,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::Profil
index_id, model_id, tag_id); index_id, model_id, tag_id);
rt_ret = rtProfilerTraceEx(index_id, model_id, tag_id, stream); rt_ret = rtProfilerTraceEx(index_id, model_id, tag_id, stream);
if (rt_ret != RT_ERROR_NONE) { if (rt_ret != RT_ERROR_NONE) {
GELOGE(RT_FAILED, "[Call][rtProfilerTraceEx] failed, ret: 0x%X", rt_ret);
GELOGE(RT_FAILED, "[Call][rtProfilerTraceEx]Failed, ret 0x%X", rt_ret);
REPORT_CALL_ERROR("E19999", "Call rtProfilerTraceEx failed, ret 0x%X", rt_ret);
return RT_ERROR_TO_GE_STATUS(rt_ret); return RT_ERROR_TO_GE_STATUS(rt_ret);
} }
GELOGD("Profiling Step Info TraceTask execute async success, index_id = %lu, model_id = %lu, tag_id = %u", GELOGD("Profiling Step Info TraceTask execute async success, index_id = %lu, model_id = %lu, tag_id = %u",
@@ -314,7 +331,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::Profil
uint32_t stream_id = 0; uint32_t stream_id = 0;
rt_ret = rtGetTaskIdAndStreamID(&task_id, &stream_id); rt_ret = rtGetTaskIdAndStreamID(&task_id, &stream_id);
if (rt_ret != RT_ERROR_NONE) { if (rt_ret != RT_ERROR_NONE) {
GELOGE(RT_FAILED, "[Get][RtsInfo] task_id and stream_id failed, ret: 0x%X.", rt_ret);
GELOGE(RT_FAILED, "[Get][RtsInfo]Task_id and stream_id failed, ret 0x%X", rt_ret);
REPORT_CALL_ERROR("E19999", "Get task_id and stream_id failed, ret 0x%X", rt_ret);
return RT_ERROR_TO_GE_STATUS(rt_ret); return RT_ERROR_TO_GE_STATUS(rt_ret);
} }
GELOGD("Get profiling args, task_id[%u], stream_id[%u]", task_id, stream_id); GELOGD("Get profiling args, task_id[%u], stream_id[%u]", task_id, stream_id);
@@ -332,9 +350,11 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::Profil
try { try {
reported_data = step_info.dump(kInteval, ' ', false, Json::error_handler_t::ignore); reported_data = step_info.dump(kInteval, ' ', false, Json::error_handler_t::ignore);
} catch (std::exception &e) { } catch (std::exception &e) {
GELOGE(FAILED, "Failed to convert JSON to string, reason: %s.", e.what());
GELOGE(FAILED, "[Convert][ReportedData]Failed to convert from json to string, reason: %s", e.what());
REPORT_CALL_ERROR("E19999", "Failed to convert reported data from json to string, reason: %s", e.what());
} catch (...) { } catch (...) {
GELOGE(FAILED, "Failed to convert JSON to string.");
GELOGE(FAILED, "[Convert][ReportedData]Failed to convert from json to string");
REPORT_CALL_ERROR("E19999", "Failed to convert reported data from json to string");
} }
reported_data.append(",") reported_data.append(",")
.append("\n"); .append("\n");
@@ -389,7 +409,9 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::ReportPr
int32_t logic_device_id = 0; int32_t logic_device_id = 0;
rtError_t rt_ret = rtGetDevice(&logic_device_id); rtError_t rt_ret = rtGetDevice(&logic_device_id);
if (rt_ret != RT_ERROR_NONE) { if (rt_ret != RT_ERROR_NONE) {
GELOGE(rt_ret, "runtime get logic_device_id failed, current logic_device_id:%d", logic_device_id);
GELOGE(rt_ret, "[Get][LogicDeviceId]Failed, current logic_device_id %d, ret 0x%X",
logic_device_id, rt_ret);
REPORT_CALL_ERROR("E19999", "Get logic device id %d failed, ret 0x%X", logic_device_id, rt_ret);
return; return;
} }
GELOGD("current logic_device_id:%d", logic_device_id); GELOGD("current logic_device_id:%d", logic_device_id);
@@ -451,7 +473,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfMo
// register Framework to profiling // register Framework to profiling
int32_t cb_ret = PluginInit(); int32_t cb_ret = PluginInit();
if (cb_ret != 0) { if (cb_ret != 0) {
GELOGE(cb_ret, "profiling plugin init failed, ret:%d", cb_ret);
GELOGE(cb_ret, "[Init][ProfilingPlugin]Failed, ret %d", cb_ret);
REPORT_CALL_ERROR("E19999", "Init profiling plugin failed, ret %d", cb_ret);
return cb_ret; return cb_ret;
} }
GELOGI("Prof subscribe: model load profiling on."); GELOGI("Prof subscribe: model load profiling on.");
@@ -464,7 +487,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfMo
device[0] = davinci_model->GetDeviceId(); device[0] = davinci_model->GetDeviceId();
rtError_t rt_ret = rtProfilerStart(module, device_num, device); rtError_t rt_ret = rtProfilerStart(module, device_num, device);
if (rt_ret != RT_ERROR_NONE) { if (rt_ret != RT_ERROR_NONE) {
GELOGE(FAILED, "Runtime profiler start failed.");
GELOGE(FAILED, "[Start][Profiler]Failed, ret 0x%X", rt_ret);
REPORT_CALL_ERROR("E19999", "Start runtime profiler failed, ret 0x%X", rt_ret);
return FAILED; return FAILED;
} }
UpdateSubscribeDeviceModuleMap(kProfModelSubscribe, device[0], module); UpdateSubscribeDeviceModuleMap(kProfModelSubscribe, device[0], module);
@@ -472,7 +496,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfMo
// Report profiling data // Report profiling data
Status p_ret = davinci_model->ReportProfilingData(); Status p_ret = davinci_model->ReportProfilingData();
if (p_ret != SUCCESS) { if (p_ret != SUCCESS) {
GELOGE(p_ret, "Report profiling data failed.");
GELOGE(p_ret, "[Report][ProfilingData]Failed, ret %u", p_ret);
REPORT_CALL_ERROR("E19999", "Report profiling data failed, ret %u", p_ret);
return p_ret; return p_ret;
} }
#endif #endif
@@ -498,13 +523,17 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfMo
// The same device_id, only stop at last time // The same device_id, only stop at last time
rtError_t rt_ret = rtProfilerStop(subs_dev_module_[device[0]].module, dev_num, device); rtError_t rt_ret = rtProfilerStop(subs_dev_module_[device[0]].module, dev_num, device);
if (rt_ret != RT_ERROR_NONE) { if (rt_ret != RT_ERROR_NONE) {
GELOGE(FAILED, "Runtime profiler stop failed.");
GELOGE(FAILED, "[Stop][Profiler]Failed, ret %d", rt_ret);
REPORT_CALL_ERROR("E19999", "Stop profiler failed, ret %d", rt_ret);
return FAILED; return FAILED;
} }
} }
UpdateSubscribeDeviceModuleMap(kProfModelUnsubscribe, device[0], subs_dev_module_[device[0]].module); UpdateSubscribeDeviceModuleMap(kProfModelUnsubscribe, device[0], subs_dev_module_[device[0]].module);
} else { } else {
GELOGE(FAILED, "The device_id:%u has not been subscribed, do not need to cancel.", device[0]);
GELOGE(FAILED, "[Cancel][DeviceId]The device_id %u has not been subscribed, do not need to cancel",
device[0]);
REPORT_CALL_ERROR("E19999", "The device_id %u has not been subscribed, do not need to cancel",
device[0]);
return FAILED; return FAILED;
} }


@@ -526,14 +555,16 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfIn
// register Framework to profiling // register Framework to profiling
int32_t cb_ret = PluginInit(); int32_t cb_ret = PluginInit();
if (cb_ret != 0) { if (cb_ret != 0) {
GELOGE(cb_ret, "profiling plugin init failed, ret:%d", cb_ret);
GELOGE(cb_ret, "[Init][ProfilingPlugin]Failed, ret %d", cb_ret);
REPORT_CALL_ERROR("E19999", "Init profiling plugin failed, ret %d", cb_ret);
return cb_ret; return cb_ret;
} }


int32_t device_num = -1; int32_t device_num = -1;
rtError_t rt_ret = rtProfilerStart(model_load_mask, device_num, nullptr); rtError_t rt_ret = rtProfilerStart(model_load_mask, device_num, nullptr);
if (rt_ret != RT_ERROR_NONE) { if (rt_ret != RT_ERROR_NONE) {
GELOGE(FAILED, "Runtime profiler start failed.");
GELOGE(FAILED, "[Start][Profiler]Failed, ret 0x%X", rt_ret);
REPORT_CALL_ERROR("E19999", "Start rumtime profiler failed, ret 0x%X", rt_ret);
return FAILED; return FAILED;
} }
is_load_profiling_ = true; is_load_profiling_ = true;
@@ -562,7 +593,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfFi
int32_t dev_num = -1; int32_t dev_num = -1;
rtError_t rt_ret = rtProfilerStop(PROF_MODEL_LOAD_MASK, dev_num, nullptr); rtError_t rt_ret = rtProfilerStop(PROF_MODEL_LOAD_MASK, dev_num, nullptr);
if (rt_ret != RT_ERROR_NONE) { if (rt_ret != RT_ERROR_NONE) {
GELOGE(FAILED, "Runtime profiler stop failed.");
GELOGE(FAILED, "[Stop][Profiler]Failed, ret 0x%X", rt_ret);
REPORT_CALL_ERROR("E19999", "Stop rumtime profiler faield, ret 0x%X", rt_ret);
return FAILED; return FAILED;
} }
for (auto device_id_module : device_id_module_map_) { for (auto device_id_module : device_id_module_map_) {
@@ -571,7 +603,9 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfFi
GELOGI("Prof finalize: device_id: %u, module: 0x%lx.", device_id, device_id_module.second); GELOGI("Prof finalize: device_id: %u, module: 0x%lx.", device_id, device_id_module.second);
rt_ret = rtProfilerStop(device_id_module.second, 1, &device_id); rt_ret = rtProfilerStop(device_id_module.second, 1, &device_id);
if (rt_ret != RT_ERROR_NONE) { if (rt_ret != RT_ERROR_NONE) {
GELOGE(FAILED, "Runtime profiler stop failed.");
GELOGE(FAILED, "[Stop][Profiler]Failed, device_id %d, ret 0x%X", device_id, rt_ret);
REPORT_CALL_ERROR("E19999", "Stop runtime profiler failed, device_id %d, ret 0x%X",
device_id,rt_ret);
return FAILED; return FAILED;
} }
} }
@@ -610,18 +644,26 @@ Status ProfilingManager::ProfParseDeviceId(const std::map<std::string, std::stri
int32_t dev_id = std::stoi(decvice_id[i]); int32_t dev_id = std::stoi(decvice_id[i]);
device_list.push_back(dev_id); device_list.push_back(dev_id);
} catch (std::invalid_argument &) { } catch (std::invalid_argument &) {
GELOGE(FAILED, "Device id: %s is invalid.", decvice_id[i].c_str());
GELOGE(FAILED, "[Parse][DeviceId]Failed, it is invalid, %s", decvice_id[i].c_str());
REPORT_CALL_ERROR("E19999", "Parse device id %s failed, it is invalid",
decvice_id[i].c_str());
return FAILED; return FAILED;
} catch (std::out_of_range &) { } catch (std::out_of_range &) {
GELOGE(FAILED, "Device id: %s is out of range.", decvice_id[i].c_str());
GELOGE(FAILED, "[Parse][DeviceId]Failed, it is out of range, %s", decvice_id[i].c_str());
REPORT_CALL_ERROR("E19999", "Parse device id %s failed, it is out of range",
decvice_id[i].c_str());
return FAILED; return FAILED;
} catch (...) { } catch (...) {
GELOGE(FAILED, "Device id: %s cannot change to int.", decvice_id[i].c_str());
GELOGE(FAILED, "[Parse][DeviceId]Faield, it cannot change to int, %s", decvice_id[i].c_str());
REPORT_CALL_ERROR("E19999", "Parse device id %s failed, it cannot change to int",
decvice_id[i].c_str());
return FAILED; return FAILED;
} }
} }
} else { } else {
GELOGE(FAILED, "Config para not contain device id list.");
GELOGE(FAILED, "[Parse][DeviceId]Config para not contain device id %s list", decvice_id[i].c_str());
REPORT_CALL_ERROR("E19999", "Parse device id failed, config para not contain device id %s list",
decvice_id[i].c_str());
return FAILED; return FAILED;
} }
#endif #endif
@@ -637,27 +679,37 @@ Status ProfilingManager::ProfParseParam(const std::map<std::string, std::string>
try { try {
device_num = std::stoi(iter->second); device_num = std::stoi(iter->second);
} catch (std::invalid_argument &) { } catch (std::invalid_argument &) {
GELOGE(FAILED, "Device nun: %s is invalid.", iter->second.c_str());
GELOGE(FAILED, "[Parse][Param]Failed, device num %s is invalid", iter->second.c_str());
REPORT_CALL_ERROR("E19999", "Parse param failed, device num %s is invalid", iter->second.c_str());
return FAILED; return FAILED;
} catch (std::out_of_range &) { } catch (std::out_of_range &) {
GELOGE(FAILED, "Device num: %s is out of range.", iter->second.c_str());
GELOGE(FAILED, "[Parse][Param]Failed, device num %s is out of range", iter->second.c_str());
REPORT_CALL_ERROR("E19999", "Parse param failed, device num %s is out of range", iter->second.c_str());
return FAILED; return FAILED;
} catch (...) { } catch (...) {
GELOGE(FAILED, "Device num: %s cannot change to int.", iter->second.c_str());
GELOGE(FAILED, "[Parse][Param]Failed, device num %s cannot change to int", iter->second.c_str());
REPORT_CALL_ERROR("E19999", "Parse param failed, device num %s cannot change to int",
iter->second.c_str());
return FAILED; return FAILED;
} }
} else { } else {
GELOGE(FAILED, "Config para not contain device num.");
GELOGE(FAILED, "[Parse][Param]Config para not contain device num %s", iter->second.c_str());
REPORT_CALL_ERROR("E19999", "Parse param failed, config para not contain device num %s",
iter->second.c_str());
return FAILED; return FAILED;
} }
// device id // device id
if (ProfParseDeviceId(config_para, device_list) != SUCCESS) { if (ProfParseDeviceId(config_para, device_list) != SUCCESS) {
GELOGE(FAILED, "Parse config para device id failed.");
GELOGE(FAILED, "[Parse][DeviceId]Failed");
REPORT_CALL_ERROR("E19999", "Parse device id failed");
return FAILED; return FAILED;
} }


if (device_num == 0 || device_num > kMaxDeviceNum || device_num != static_cast<int32_t>(device_list.size())) { if (device_num == 0 || device_num > kMaxDeviceNum || device_num != static_cast<int32_t>(device_list.size())) {
GELOGE(FAILED, "Config para device num: %d not equal to device list size: %zu.", device_num, device_list.size());
GELOGE(FAILED, "[Parse][Param]Failed, config para device num %d not equal to device list size %zu",
device_num, device_list.size());
REPORT_CALL_ERROR("E19999", "[Parse][Param]Failed, config para device num %d "
"not equal to device list size %zu", device_num, device_list.size());
return FAILED; return FAILED;
} }
#endif #endif
@@ -675,13 +727,17 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfSt
int32_t device_num = 0; int32_t device_num = 0;
vector<int32_t> device_list; vector<int32_t> device_list;
if (ProfParseParam(config_para, device_num, device_list) != SUCCESS) { if (ProfParseParam(config_para, device_num, device_list) != SUCCESS) {
GELOGE(FAILED, "Prof start parse param failed.");
GELOGE(FAILED, "[Start][Profiling]Prof start parse param failed, device num %d, device list size %zu",
device_num, device_list.size());
REPORT_CALL_ERROR("E19999", "Prof start parse param failed, device num %d, device list size %zu",
device_num, device_list.size());
return FAILED; return FAILED;
} }


auto device_id_ptr = std::unique_ptr<uint32_t[]>(new (std::nothrow) uint32_t[device_num]); auto device_id_ptr = std::unique_ptr<uint32_t[]>(new (std::nothrow) uint32_t[device_num]);
if (device_id_ptr == nullptr) { if (device_id_ptr == nullptr) {
GELOGE(FAILED, "Prof start: device id ptr is null.");
GELOGE(FAILED, "[Start][Profiling]Failed, device id ptr is null, device num %d", device_num);
REPORT_CALL_ERROR("E19999", "Start profiling failed, device id ptr is null, device num %d", device_num);
return FAILED; return FAILED;
} }
for (int32_t i = 0; i < device_num; i++) { for (int32_t i = 0; i < device_num; i++) {
@@ -691,7 +747,10 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfSt


rtError_t rt_ret = rtProfilerStart(module, device_num, device_id_ptr.get()); rtError_t rt_ret = rtProfilerStart(module, device_num, device_id_ptr.get());
if (rt_ret != RT_ERROR_NONE) { if (rt_ret != RT_ERROR_NONE) {
GELOGE(FAILED, "Runtime profiler config proc failed.");
GELOGE(FAILED, "[Start][Profiler]Runtime profiler config proc failed, config param 0x%lx, "
"device num %d, ret 0x%X", module, device_num, rt_ret);
REPORT_CALL_ERROR("E19999", "Runtime profiler config proc failed, config param 0x%lx, "
"device num %d, ret 0x%X", module, device_num, rt_ret);
return FAILED; return FAILED;
} }
if ((module & PROF_MODEL_EXECUTE_MASK) == PROF_MODEL_EXECUTE_MASK) { if ((module & PROF_MODEL_EXECUTE_MASK) == PROF_MODEL_EXECUTE_MASK) {
@@ -718,12 +777,16 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfSt
int32_t device_num = 0; int32_t device_num = 0;
vector<int32_t> device_list; vector<int32_t> device_list;
if (ProfParseParam(config_para, device_num, device_list) != SUCCESS) { if (ProfParseParam(config_para, device_num, device_list) != SUCCESS) {
GELOGE(FAILED, "Prof stop parse param failed.");
GELOGE(FAILED, "[Stop][Profiling]Prof stop parse param failed, device num %d, device list size %zu".
device_num, device_list.size());
REPORT_CALL_ERROR("E19999", "Prof stop parse param failed, device num %d, device list size %zu",
device_num, device_list.size());
return FAILED; return FAILED;
} }
auto device_id_ptr = std::unique_ptr<uint32_t[]>(new (std::nothrow) uint32_t[device_num]); auto device_id_ptr = std::unique_ptr<uint32_t[]>(new (std::nothrow) uint32_t[device_num]);
if (device_id_ptr == nullptr) { if (device_id_ptr == nullptr) {
GELOGE(FAILED, "Prof stop: device id ptr is null.");
GELOGE(FAILED, "[Stop][Profiling]Failed, device id ptr is null, device num %d", device_num);
REPORT_CALL_ERROR("E19999", "Stop profiling failed, device id ptr is null, device num %d", device_num);
return FAILED; return FAILED;
} }
for (int32_t i = 0; i < device_num; i++) { for (int32_t i = 0; i < device_num; i++) {
@@ -732,7 +795,10 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfSt
GELOGI("Prof stop: runtime config param: 0x%lx, device num: %d", module, device_num); GELOGI("Prof stop: runtime config param: 0x%lx, device num: %d", module, device_num);
rtError_t rt_ret = rtProfilerStop(module, device_num, device_id_ptr.get()); rtError_t rt_ret = rtProfilerStop(module, device_num, device_id_ptr.get());
if (rt_ret != RT_ERROR_NONE) { if (rt_ret != RT_ERROR_NONE) {
GELOGE(FAILED, "Prof stop: runtime profiler config proc failed.");
GELOGE(FAILED, "[Stop][Profiler]Runtime profiler config proc failed, config param 0x%lx, "
"device num: %d, ret 0x%X", module, device_num, rt_ret);
REPORT_CALL_ERROR("E19999", "Runtime profiler config proc failed, config param 0x%lx, "
"device num %d, ret 0x%X", module, device_num, rt_ret);
return FAILED; return FAILED;
} }
uint64_t execute_model_mask = module & PROF_MODEL_EXECUTE_MASK; uint64_t execute_model_mask = module & PROF_MODEL_EXECUTE_MASK;
@@ -789,7 +855,9 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ProfilingManager::Profilin
int32_t logic_device_id = 0; int32_t logic_device_id = 0;
rtError_t rt_ret = rtGetDevice(&logic_device_id); rtError_t rt_ret = rtGetDevice(&logic_device_id);
if (rt_ret != RT_ERROR_NONE) { if (rt_ret != RT_ERROR_NONE) {
GELOGE(rt_ret, "Runtime get logic_device_id failed, current logic_device_id:%d", logic_device_id);
GELOGE(rt_ret, "[Get][LogicDeviceId]Failed, current logic_device_id %d, ret 0x%X",
logic_device_id, rt_ret);
REPORT_CALL_ERROR("E19999", "Get logic device id %d failed, ret 0x%X", logic_device_id, rt_ret);
} }
GELOGI("Current logic_device_id:%d", logic_device_id); GELOGI("Current logic_device_id:%d", logic_device_id);


@@ -804,7 +872,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ProfilingManager::Profilin


FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::PluginInit() { FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::PluginInit() {
if (prof_cb_.msprofReporterCallback == nullptr) { if (prof_cb_.msprofReporterCallback == nullptr) {
GELOGE(ge::PARAM_INVALID, "MsprofReporterCallback callback is nullptr.");
GELOGE(ge::PARAM_INVALID, "[Check][Param]MsprofReporterCallback callback is nullptr");
REPORT_CALL_ERROR("E19999", "MsprofReporterCallback callback is nullptr");
return ge::PARAM_INVALID; return ge::PARAM_INVALID;
} }
int32_t cb_ret = prof_cb_.msprofReporterCallback( int32_t cb_ret = prof_cb_.msprofReporterCallback(
@@ -812,8 +881,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::Plugin
static_cast<uint32_t>(MsprofReporterCallbackType::MSPROF_REPORTER_INIT), static_cast<uint32_t>(MsprofReporterCallbackType::MSPROF_REPORTER_INIT),
nullptr, 0); nullptr, 0);
if (cb_ret != MSPROF_ERROR_NONE) { if (cb_ret != MSPROF_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Profiling reporter init failed, ret = %d.", cb_ret);
GELOGE(INTERNAL_ERROR, "[Init][ProfilingReporter] profiling init failed, ret = %d.", cb_ret);
REPORT_CALL_ERROR("E19999", "Profiling reporter init failed, ret 0x%X", cb_ret);
GELOGE(INTERNAL_ERROR, "[Init][ProfilingReporter]Failed, ret 0x%X", cb_ret);
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }


@@ -822,8 +891,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::Plugin
static_cast<uint32_t>(MsprofReporterCallbackType::MSPROF_REPORTER_DATA_MAX_LEN), static_cast<uint32_t>(MsprofReporterCallbackType::MSPROF_REPORTER_DATA_MAX_LEN),
&reporter_max_len_, sizeof(uint32_t)); &reporter_max_len_, sizeof(uint32_t));
if (cb_ret != MSPROF_ERROR_NONE) { if (cb_ret != MSPROF_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Get profiling reporter data max len failed, ret = %d.", cb_ret);
GELOGE(INTERNAL_ERROR, "[Init][ProfilingReporter] Get profiling reporter data max len failed, ret = %d.", cb_ret);
REPORT_CALL_ERROR("E19999", "Get profiling reporter data max len failed, ret 0x%X", cb_ret);
GELOGE(INTERNAL_ERROR, "[Get][ProfilingData]Failed, ret 0x%X", cb_ret);
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }


@@ -833,7 +902,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::Plugin
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::PluginUnInit() const { FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::PluginUnInit() const {
#ifdef DAVINCI_SUPPORT_PROFILING #ifdef DAVINCI_SUPPORT_PROFILING
if (prof_cb_.msprofReporterCallback == nullptr) { if (prof_cb_.msprofReporterCallback == nullptr) {
GELOGE(ge::PARAM_INVALID, "MsprofReporterCallback callback is nullptr.");
GELOGE(ge::PARAM_INVALID, "[Check][Param]MsprofReporterCallback callback is nullptr");
REPORT_CALL_ERROR("E19999", "MsprofReporterCallback callback is nullptr");
return; return;
} }
int32_t cb_ret = prof_cb_.msprofReporterCallback( int32_t cb_ret = prof_cb_.msprofReporterCallback(
@@ -849,7 +919,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::PluginUn
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::CallMsprofReport( FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::CallMsprofReport(
ReporterData &reporter_data) const { ReporterData &reporter_data) const {
if (prof_cb_.msprofReporterCallback == nullptr) { if (prof_cb_.msprofReporterCallback == nullptr) {
GELOGE(ge::PARAM_INVALID, "MsprofReporterCallback callback is nullptr.");
GELOGE(ge::PARAM_INVALID, "[Check][Param]MsprofReporterCallback callback is nullptr");
REPORT_CALL_ERROR("E19999", "MsprofReporterCallback callback is nullptr");
return ge::PARAM_INVALID; return ge::PARAM_INVALID;
} }
return prof_cb_.msprofReporterCallback( return prof_cb_.msprofReporterCallback(


Loading…
Cancel
Save