@@ -38,6 +38,10 @@ bool KernelStore::Build() { | |||||
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, "All build memory failed, memory size %zu", total_len); | ||||
GELOGE(ge::MEMALLOC_FAILED, "[Malloc][Memmory]Resize buffer failed, memory size %zu, " | |||||
"exception %s", total_len, e.what()); | |||||
REPORT_CALL_ERROR("E19999", "Resize buffer failed, memory size %zu, exception %s", | |||||
total_len, e.what()); | |||||
return false; | return false; | ||||
} | } | ||||
@@ -32,17 +32,24 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelParserBase::LoadFro | |||||
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, "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; | ||||
} | } | ||||
@@ -57,6 +64,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 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 +116,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; | ||||
} | } | ||||
@@ -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. errmsg:%s", file_path, strerror(errno)); | |||||
GELOGE(FAILED, "[Open][File]Failed, file %s, errmsg %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, errmsg:%s", mmpa_ret, strerror(errno)); | |||||
GELOGE(FAILED, "[Write][Data]To file %s failed. errno %ld, errmsg %s", file_path, 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. errmsg:%s", strerror(errno)); | |||||
GELOGE(FAILED, "[Close][File]Failed, file %s, errmsg %s", file_path, strerror(errno)); | |||||
REPORT_CALL_ERROR("E19999", "Close file %s failed, errmsg %s", file_path, strerror(errno)); | |||||
ret = FAILED; | ret = FAILED; | ||||
} | } | ||||
return ret; | return ret; | ||||
@@ -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,10 @@ 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 %s of size tensor is 0", | |||||
ShapeToString(input_dims[i]).c_str()); | |||||
REPORT_INNER_ERROR("E19999", "Dim_i %s of size tensor is 0, invalid", | |||||
ShapeToString(input_dims[i]).c_str()); | |||||
return PARAM_INVALID; | return PARAM_INVALID; | ||||
} | } | ||||
chunk_size = chunk_size / dim_i; | chunk_size = chunk_size / dim_i; | ||||
@@ -299,7 +303,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 +441,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_ERROR("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 +471,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", | |||||
TypeUtils::DataTypeToSerialString(type).c_str()); | |||||
GELOGE(PARAM_INVALID, "[Check][DataType]Invalid, type only can be DT_INT32 or DT_INT64, " | |||||
"type is %s", 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; | ||||
} | } | ||||
@@ -67,11 +67,13 @@ 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"); | |||||
REPORT_INNER_ERROR("E19999", "Device id list 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 +81,16 @@ 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 +98,14 @@ 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 +115,8 @@ 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"); | |||||
REPORT_INNER_ERROR("E19999", "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 +129,15 @@ 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"); | |||||
REPORT_INNER_ERROR("E19999", "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]To runtime failed!"); | |||||
REPORT_CALL_ERROR("E19999", "Pass MsprofSetDeviceCallback to runtime failed, ret 0x%X", rt_ret); | |||||
return rt_ret; | return rt_ret; | ||||
} | } | ||||
return ge::SUCCESS; | return ge::SUCCESS; | ||||
@@ -133,7 +145,8 @@ 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"); | |||||
REPORT_INNER_ERROR("E19999", "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 +157,10 @@ 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 +185,8 @@ 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"); | |||||
REPORT_CALL_ERROR("E19999", "Transfer profilerConfig to string vector failed"); | |||||
return ge::PARAM_INVALID; | return ge::PARAM_INVALID; | ||||
} | } | ||||
} | } | ||||
@@ -188,7 +205,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; | ||||
} | } | ||||
@@ -87,21 +87,26 @@ 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_INNER_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 +127,10 @@ 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 +155,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 +175,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 +191,9 @@ 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_INNER_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 +203,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_ERROR("E19999", "Json prof_conf options is invalid"); | |||||
return ge::PARAM_INVALID; | return ge::PARAM_INVALID; | ||||
} | } | ||||
return ge::SUCCESS; | return ge::SUCCESS; | ||||
@@ -202,7 +218,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 +233,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 +296,14 @@ 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 +322,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 +337,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); | ||||
@@ -333,8 +357,13 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::Profil | |||||
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, "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"); | ||||
@@ -390,7 +419,8 @@ 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, ret 0x%X", rt_ret); | |||||
REPORT_CALL_ERROR("E19999", "Get logic device id failed, ret 0x%X", rt_ret); | |||||
return; | return; | ||||
} | } | ||||
GELOGD("current logic_device_id:%d", logic_device_id); | GELOGD("current logic_device_id:%d", logic_device_id); | ||||
@@ -452,7 +482,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."); | ||||
@@ -465,7 +496,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]Malloc buffer failed, ret 0x%X", rt_ret); | |||||
REPORT_CALL_ERROR("E19999", "Malloc buffer failed when start profiling, ret 0x%X", rt_ret); | |||||
return FAILED; | return FAILED; | ||||
} | } | ||||
UpdateSubscribeDeviceModuleMap(kProfModelSubscribe, device[0], module); | UpdateSubscribeDeviceModuleMap(kProfModelSubscribe, device[0], module); | ||||
@@ -473,7 +505,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 | ||||
@@ -499,13 +532,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]Malloc buffer Failed, ret %d", rt_ret); | |||||
REPORT_CALL_ERROR("E19999", "Malloc buffer failed when stop profiling, 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; | ||||
} | } | ||||
@@ -527,14 +564,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]Malloc buffer failed, ret 0x%X", rt_ret); | |||||
REPORT_CALL_ERROR("E19999", "Malloc buffer failed when start profiling, ret 0x%X", rt_ret); | |||||
return FAILED; | return FAILED; | ||||
} | } | ||||
is_load_profiling_ = true; | is_load_profiling_ = true; | ||||
@@ -563,7 +602,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]Malloc buffer failed, ret 0x%X", rt_ret); | |||||
REPORT_CALL_ERROR("E19999", "Malloc buffer failed when stop profiling, 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_) { | ||||
@@ -572,7 +612,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; | ||||
} | } | ||||
} | } | ||||
@@ -611,18 +653,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 list"); | |||||
REPORT_CALL_ERROR("E19999", "Parse device id failed, config para not contain device id list"); | |||||
return FAILED; | return FAILED; | ||||
} | } | ||||
#endif | #endif | ||||
@@ -638,27 +688,41 @@ 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 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; | ||||
} 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_INNER_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 | ||||
@@ -676,13 +740,18 @@ 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, "[Parse][Param]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]Malloc buffer failed when start profiling, device num %d", device_num); | |||||
REPORT_CALL_ERROR("E19999", "Malloc buffer failed when start profiling, 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++) { | ||||
@@ -692,7 +761,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) { | ||||
@@ -719,12 +791,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 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]Malloc buffer failed when stop profiling, device num %d", device_num); | |||||
REPORT_CALL_ERROR("E19999", "Malloc buffer failed when stop profiling, 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++) { | ||||
@@ -733,7 +810,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; | ||||
@@ -790,7 +870,8 @@ 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, ret 0x%X", rt_ret); | |||||
REPORT_CALL_ERROR("E19999", "Get logic device id failed, ret 0x%X", rt_ret); | |||||
} | } | ||||
GELOGI("Current logic_device_id:%d", logic_device_id); | GELOGI("Current logic_device_id:%d", logic_device_id); | ||||
@@ -805,7 +886,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_INNER_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( | ||||
@@ -813,8 +895,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; | ||||
} | } | ||||
@@ -823,8 +905,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][ProfilingDataMaxLen]Failed, ret 0x%X", cb_ret); | |||||
return INTERNAL_ERROR; | return INTERNAL_ERROR; | ||||
} | } | ||||
@@ -834,7 +916,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_INNER_ERROR("E19999", "MsprofReporterCallback callback is nullptr"); | |||||
return; | return; | ||||
} | } | ||||
int32_t cb_ret = prof_cb_.msprofReporterCallback( | int32_t cb_ret = prof_cb_.msprofReporterCallback( | ||||
@@ -850,7 +933,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_INNER_ERROR("E19999", "MsprofReporterCallback callback is nullptr"); | |||||
return ge::PARAM_INVALID; | return ge::PARAM_INVALID; | ||||
} | } | ||||
return prof_cb_.msprofReporterCallback( | return prof_cb_.msprofReporterCallback( | ||||
@@ -946,5 +1030,4 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::GetFpBpP | |||||
return; | return; | ||||
} | } | ||||
} // namespace ge | } // namespace ge |
@@ -69,7 +69,8 @@ bool PropertiesManager::LoadFileContent(const std::string &file_path) { | |||||
std::ifstream fs(resolved_file_path, std::ifstream::in); | std::ifstream fs(resolved_file_path, std::ifstream::in); | ||||
if (!fs.is_open()) { | if (!fs.is_open()) { | ||||
GELOGE(PARAM_INVALID, "Open %s failed.", file_path.c_str()); | |||||
GELOGE(PARAM_INVALID, "[Open][File]Failed, file path %s invalid", file_path.c_str()); | |||||
REPORT_CALL_ERROR("E19999", "Open file failed, path %s invalid", file_path.c_str()); | |||||
return false; | return false; | ||||
} | } | ||||
@@ -77,7 +78,8 @@ bool PropertiesManager::LoadFileContent(const std::string &file_path) { | |||||
while (getline(fs, line)) { // line not with \n | while (getline(fs, line)) { // line not with \n | ||||
if (!ParseLine(line)) { | if (!ParseLine(line)) { | ||||
GELOGE(PARAM_INVALID, "Parse line failed. content is [%s].", line.c_str()); | |||||
GELOGE(PARAM_INVALID, "[Parse][Line]Failed, content is %s", line.c_str()); | |||||
REPORT_CALL_ERROR("E19999", "Parse line failed, content is %s", line.c_str()); | |||||
fs.close(); | fs.close(); | ||||
return false; | return false; | ||||
} | } | ||||
@@ -100,15 +102,18 @@ bool PropertiesManager::ParseLine(const std::string &line) { | |||||
if (!temp.empty()) { | if (!temp.empty()) { | ||||
std::string::size_type pos = temp.find_first_of(delimiter); | std::string::size_type pos = temp.find_first_of(delimiter); | ||||
if (pos == std::string::npos) { | if (pos == std::string::npos) { | ||||
GELOGE(PARAM_INVALID, "Incorrect line [%s], it must include [%s].Perhaps you use illegal chinese symbol", | |||||
GELOGE(PARAM_INVALID, "[Check][Param]Incorrect line %s, it must include %s", | |||||
line.c_str(), delimiter.c_str()); | line.c_str(), delimiter.c_str()); | ||||
REPORT_CALL_ERROR("E19999", "Incorrect line %s, it must include %s", | |||||
line.c_str(), delimiter.c_str()); | |||||
return false; | return false; | ||||
} | } | ||||
std::string map_key = Trim(temp.substr(0, pos)); | std::string map_key = Trim(temp.substr(0, pos)); | ||||
std::string value = Trim(temp.substr(pos + 1)); | std::string value = Trim(temp.substr(pos + 1)); | ||||
if (map_key.empty() || value.empty()) { | if (map_key.empty() || value.empty()) { | ||||
GELOGE(PARAM_INVALID, "Map_key or value empty. %s", line.c_str()); | |||||
GELOGE(PARAM_INVALID, "[Check][Param]Map_key or value empty, line %s", line.c_str()); | |||||
REPORT_CALL_ERROR("E19999", "Map_key or value empty, line %s", line.c_str()); | |||||
return false; | return false; | ||||
} | } | ||||
@@ -83,7 +83,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadProtoFromBinaryFile(co | |||||
std::ifstream fs(real_path, std::ifstream::in | std::ifstream::binary); | std::ifstream fs(real_path, std::ifstream::in | std::ifstream::binary); | ||||
if (!fs.is_open()) { | if (!fs.is_open()) { | ||||
ErrorManager::GetInstance().ATCReportErrMessage("E19001", {"file", "errmsg"}, {file, "ifstream is_open failed"}); | ErrorManager::GetInstance().ATCReportErrMessage("E19001", {"file", "errmsg"}, {file, "ifstream is_open failed"}); | ||||
GELOGE(ge::FAILED, "Open real path[%s] failed.", file); | |||||
GELOGE(ge::FAILED, "[Open][File]Failed, file path %s", file); | |||||
return false; | return false; | ||||
} | } | ||||
@@ -96,7 +96,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadProtoFromBinaryFile(co | |||||
if (!ret) { | if (!ret) { | ||||
ErrorManager::GetInstance().ATCReportErrMessage("E19005", {"file"}, {file}); | ErrorManager::GetInstance().ATCReportErrMessage("E19005", {"file"}, {file}); | ||||
GELOGE(ge::FAILED, "Parse file[%s] failed.", file); | |||||
GELOGE(ge::FAILED, "[Parse][File]Failed, file %s", file); | |||||
return ret; | return ret; | ||||
} | } | ||||
@@ -155,7 +155,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadBytesFromBinaryFile(co | |||||
std::ifstream file(real_path.c_str(), std::ios::binary | std::ios::ate); | std::ifstream file(real_path.c_str(), std::ios::binary | std::ios::ate); | ||||
if (!file.is_open()) { | if (!file.is_open()) { | ||||
GELOGE(ge::FAILED, "Read file %s failed.", file_name); | |||||
GELOGE(ge::FAILED, "[Read][File]Failed, file %s", file_name); | |||||
REPORT_CALL_ERROR("E19999", "Read file %s failed", file_name); | |||||
return false; | return false; | ||||
} | } | ||||
@@ -182,7 +183,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadBytesFromBinaryFile(co | |||||
std::ifstream file(real_path.c_str(), std::ios::binary | std::ios::ate); | std::ifstream file(real_path.c_str(), std::ios::binary | std::ios::ate); | ||||
if (!file.is_open()) { | if (!file.is_open()) { | ||||
GELOGE(ge::FAILED, "Read file %s failed.", file_name); | |||||
GELOGE(ge::FAILED, "[Read][File]Failed, file %s", file_name); | |||||
REPORT_CALL_ERROR("E19999", "Read file %s failed", file_name); | |||||
return false; | return false; | ||||
} | } | ||||
@@ -250,7 +252,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY std::string CurrentTimeInStr() | |||||
std::time_t now = std::time(nullptr); | std::time_t now = std::time(nullptr); | ||||
std::tm *ptm = std::localtime(&now); | std::tm *ptm = std::localtime(&now); | ||||
if (ptm == nullptr) { | if (ptm == nullptr) { | ||||
GELOGE(ge::FAILED, "Localtime failed."); | |||||
GELOGE(ge::FAILED, "[Check][Param]Localtime incorrect"); | |||||
REPORT_CALL_ERROR("E19999", "Localtime incorrect"); | |||||
return ""; | return ""; | ||||
} | } | ||||
@@ -277,17 +280,15 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadProtoFromText(const ch | |||||
if (!fs.is_open()) { | if (!fs.is_open()) { | ||||
ErrorManager::GetInstance().ATCReportErrMessage("E19017", {"realpth", "protofile"}, {real_path, file}); | ErrorManager::GetInstance().ATCReportErrMessage("E19017", {"realpth", "protofile"}, {real_path, file}); | ||||
GELOGE(ge::FAILED, "Fail to open proto file real path is '%s' when orginal file path is '%s'.", real_path.c_str(), | |||||
file); | |||||
GELOGE(ge::FAILED, "[Open][ProtoFile]Failed, real path %s, orginal file path %s", | |||||
real_path.c_str(), file); | |||||
return false; | return false; | ||||
} | } | ||||
google::protobuf::io::IstreamInputStream input(&fs); | google::protobuf::io::IstreamInputStream input(&fs); | ||||
bool ret = google::protobuf::TextFormat::Parse(&input, message); | bool ret = google::protobuf::TextFormat::Parse(&input, message); | ||||
GE_IF_BOOL_EXEC(!ret, ErrorManager::GetInstance().ATCReportErrMessage("E19018", {"protofile"}, {file}); | GE_IF_BOOL_EXEC(!ret, ErrorManager::GetInstance().ATCReportErrMessage("E19018", {"protofile"}, {file}); | ||||
GELOGE(ret, | |||||
"Parse file[%s] through [google::protobuf::TextFormat::Parse] failed, " | |||||
"please check whether the file is a valid protobuf format file.", | |||||
GELOGE(ret, "[Parse][File]Through [google::protobuf::TextFormat::Parse] failed, file %s", | |||||
file)); | file)); | ||||
fs.close(); | fs.close(); | ||||
@@ -490,7 +491,8 @@ FMK_FUNC_HOST_VISIBILITY bool ValidateStr(const std::string &str, const std::str | |||||
ret = regexec(®, str.c_str(), 0, NULL, 0); | ret = regexec(®, str.c_str(), 0, NULL, 0); | ||||
if (ret) { | if (ret) { | ||||
regerror(ret, ®, ebuff, kMaxBuffSize); | regerror(ret, ®, ebuff, kMaxBuffSize); | ||||
GELOGE(ge::PARAM_INVALID, "regexec failed, reason: %s", ebuff); | |||||
GELOGE(ge::PARAM_INVALID, "[Rgexec][Param]Failed, reason %s", ebuff); | |||||
REPORT_CALL_ERROR("E19999", "Rgexec failed, reason %s", ebuff); | |||||
regfree(®); | regfree(®); | ||||
return false; | return false; | ||||
} | } | ||||
@@ -518,35 +520,44 @@ FMK_FUNC_HOST_VISIBILITY bool ValidateStr(const std::string &str, const std::str | |||||
FMK_FUNC_HOST_VISIBILITY bool IsValidFile(const char *file_path) { | FMK_FUNC_HOST_VISIBILITY bool IsValidFile(const char *file_path) { | ||||
if (file_path == nullptr) { | if (file_path == nullptr) { | ||||
GELOGE(PARAM_INVALID, "Config path is null."); | |||||
GELOGE(PARAM_INVALID, "[Check][Param]Config path is null"); | |||||
REPORT_INNER_ERROR("E19999", "Config path is null"); | |||||
return false; | return false; | ||||
} | } | ||||
if (!CheckInputPathValid(file_path)) { | if (!CheckInputPathValid(file_path)) { | ||||
GELOGE(PARAM_INVALID, "Config path is invalid: %s", file_path); | |||||
GELOGE(PARAM_INVALID, "[Check][Param]Config path %s is invalid", file_path); | |||||
REPORT_CALL_ERROR("E19999", "Config path %s is invalid", file_path); | |||||
return false; | return false; | ||||
} | } | ||||
// Normalize the path | // Normalize the path | ||||
std::string resolved_file_path = RealPath(file_path); | std::string resolved_file_path = RealPath(file_path); | ||||
if (resolved_file_path.empty()) { | if (resolved_file_path.empty()) { | ||||
GELOGE(PARAM_INVALID, "Invalid input file path [%s], make sure that the file path is correct.", file_path); | |||||
GELOGE(PARAM_INVALID, "[Check][Param]Invalid input file path %s", file_path); | |||||
REPORT_CALL_ERROR("E19999", "Invalid input file path %s", file_path); | |||||
return false; | return false; | ||||
} | } | ||||
mmStat_t stat = {0}; | mmStat_t stat = {0}; | ||||
int32_t ret = mmStatGet(resolved_file_path.c_str(), &stat); | int32_t ret = mmStatGet(resolved_file_path.c_str(), &stat); | ||||
if (ret != EN_OK) { | if (ret != EN_OK) { | ||||
GELOGE(PARAM_INVALID, "cannot get config file status, which path is %s, maybe not exist, return %d, errcode %d", | |||||
resolved_file_path.c_str(), ret, mmGetErrorCode()); | |||||
GELOGE(PARAM_INVALID, "[Get][FileStatus]Failed, which path %s maybe not exist, " | |||||
"return %d, errcode %d", resolved_file_path.c_str(), ret, mmGetErrorCode()); | |||||
REPORT_CALL_ERROR("E19999", "Get config file status failed, which path %s maybe not exist, " | |||||
"return %d, errcode %d", resolved_file_path.c_str(), ret, mmGetErrorCode()); | |||||
return false; | return false; | ||||
} | } | ||||
if ((stat.st_mode & S_IFMT) != S_IFREG) { | if ((stat.st_mode & S_IFMT) != S_IFREG) { | ||||
GELOGE(PARAM_INVALID, "config file is not a common file, which path is %s, mode is %u", resolved_file_path.c_str(), | |||||
stat.st_mode); | |||||
GELOGE(PARAM_INVALID, "[Check][Param]Config file is not a common file, which path is %s, " | |||||
"mode is %u", resolved_file_path.c_str(), stat.st_mode); | |||||
REPORT_CALL_ERROR("E19999", "Config file is not a common file, which path is %s, " | |||||
"mode is %u", resolved_file_path.c_str(), stat.st_mode); | |||||
return false; | return false; | ||||
} | } | ||||
if (stat.st_size > kMaxConfigFileByte) { | if (stat.st_size > kMaxConfigFileByte) { | ||||
GELOGE(PARAM_INVALID, "config file %s size[%ld] is larger than max config file Bytes[%u]", | |||||
GELOGE(PARAM_INVALID, "[Check][Param]Config file %s size %ld is larger than max config file Bytes %u", | |||||
resolved_file_path.c_str(), stat.st_size, kMaxConfigFileByte); | resolved_file_path.c_str(), stat.st_size, kMaxConfigFileByte); | ||||
REPORT_CALL_ERROR("E19999", "Config file %s size %ld is larger than max config file Bytes %u", | |||||
resolved_file_path.c_str(), stat.st_size, kMaxConfigFileByte); | |||||
return false; | return false; | ||||
} | } | ||||
return true; | return true; | ||||
@@ -554,29 +565,35 @@ FMK_FUNC_HOST_VISIBILITY bool IsValidFile(const char *file_path) { | |||||
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status CheckPath(const char *path, size_t length) { | FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status CheckPath(const char *path, size_t length) { | ||||
if (path == nullptr) { | if (path == nullptr) { | ||||
GELOGE(PARAM_INVALID, "Config path is invalid."); | |||||
GELOGE(PARAM_INVALID, "[Check][Param]Config path is invalid"); | |||||
REPORT_CALL_ERROR("E19999", "Config path is invalid"); | |||||
return PARAM_INVALID; | return PARAM_INVALID; | ||||
} | } | ||||
if (strlen(path) != length) { | if (strlen(path) != length) { | ||||
GELOGE(PARAM_INVALID, "Path is invalid or length of config path is not equal to given length."); | |||||
GELOGE(PARAM_INVALID, "[Check][Param]Path %s is invalid or length %zu " | |||||
"not equal to given length %zu", path, strlen(path), length); | |||||
REPORT_CALL_ERROR("E19999", "Path %s is invalid or length %zu " | |||||
"not equal to given length %zu", path, strlen(path), length); | |||||
return PARAM_INVALID; | return PARAM_INVALID; | ||||
} | } | ||||
if (length == 0 || length > MMPA_MAX_PATH) { | if (length == 0 || length > MMPA_MAX_PATH) { | ||||
GELOGE(PARAM_INVALID, "Length of config path is invalid."); | |||||
GELOGE(PARAM_INVALID, "[Check][Param]Length of config path %zu is invalid", length); | |||||
REPORT_INNER_ERROR("E19999", "Length of config path %zu is invalid", length); | |||||
return PARAM_INVALID; | return PARAM_INVALID; | ||||
} | } | ||||
INT32 is_dir = mmIsDir(path); | INT32 is_dir = mmIsDir(path); | ||||
if (is_dir != EN_OK) { | if (is_dir != EN_OK) { | ||||
GELOGE(PATH_INVALID, "Open directory %s failed, maybe it is not exit or not a dir. errmsg:%s", | |||||
path, strerror(errno)); | |||||
GELOGE(PATH_INVALID, "[Open][Directory]Failed, directory path %s, errmsg %s", path, strerror(errno)); | |||||
REPORT_CALL_ERROR("E19999", "Open directory %s failed, errmsg %s", path, strerror(errno)); | |||||
return PATH_INVALID; | return PATH_INVALID; | ||||
} | } | ||||
if (mmAccess2(path, M_R_OK) != EN_OK) { | if (mmAccess2(path, M_R_OK) != EN_OK) { | ||||
GELOGE(PATH_INVALID, "Read path[%s] failed, errmsg[%s]", path, strerror(errno)); | |||||
GELOGE(PATH_INVALID, "[Read][Path]Failed, path %s, errmsg %s", path, strerror(errno)); | |||||
REPORT_CALL_ERROR("E19999", "Read path %s failed, errmsg %s", path, strerror(errno)); | |||||
return PATH_INVALID; | return PATH_INVALID; | ||||
} | } | ||||
return SUCCESS; | return SUCCESS; | ||||