From e943ac3eabe8663a20bb5e5cf18b6c2e720e4ca1 Mon Sep 17 00:00:00 2001 From: "liyihan2@huawei.com" Date: Tue, 23 Mar 2021 17:31:33 +0800 Subject: [PATCH 01/15] Common log optimize --- ge/common/auth/file_saver.cc | 30 ++++++++++++++++++------------ ge/common/debug/memory_dumper.cc | 17 ++++++++++------- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/ge/common/auth/file_saver.cc b/ge/common/auth/file_saver.cc index 12999e54..1ed36035 100755 --- a/ge/common/auth/file_saver.cc +++ b/ge/common/auth/file_saver.cc @@ -33,7 +33,8 @@ const int kFileOpSuccess = 0; namespace ge { Status FileSaver::OpenFile(int32_t &fd, const std::string &file_path) { if (CheckPath(file_path) != SUCCESS) { - GELOGE(FAILED, "Check output file failed."); + GELOGE(FAILED, "[Open][File]Check output file failed, file_path:%s.", file_path); + REPORT_INPUT_ERROR("E10052", std::vector({"path"}), std::vector({file_path})); return FAILED; } @@ -45,7 +46,7 @@ Status FileSaver::OpenFile(int32_t &fd, const std::string &file_path) { fd = mmOpen2(real_path, M_RDWR | M_CREAT | O_TRUNC, mode); if (fd == EN_INVALID_PARAM || fd == EN_ERROR) { // -1: Failed to open file; - 2: Illegal parameter - GELOGE(FAILED, "Open file failed. mmpa_errno = %d, %s", fd, strerror(errno)); + GELOGE(FAILED, "[Open][File]Open file failed. mmpa_errno = fd:%d, error:%s", fd, strerror(errno)); return FAILED; } return SUCCESS; @@ -62,7 +63,7 @@ Status FileSaver::WriteData(const void *data, uint32_t size, int32_t fd) { while (size > size_1g) { write_count = mmWrite(fd, reinterpret_cast(seek), size_1g); if (write_count == EN_INVALID_PARAM || write_count == EN_ERROR) { - GELOGE(FAILED, "Write data failed. mmpa_errorno = %ld, %s", write_count, strerror(errno)); + GELOGE(FAILED, "[Write][Data]Write data failed. mmpa_errorno = write_count:%ld, error:%s", write_count, strerror(errno)); return FAILED; } size -= size_1g; @@ -75,7 +76,7 @@ Status FileSaver::WriteData(const void *data, uint32_t size, int32_t fd) { // -1: Failed to write to file; - 2: Illegal parameter if (write_count == EN_INVALID_PARAM || write_count == EN_ERROR) { - GELOGE(FAILED, "Write data failed. mmpa_errorno = %ld, %s", write_count, strerror(errno)); + GELOGE(FAILED, "[Write][Data]Write data failed. mmpa_errorno = write_count:%ld, error:%s", write_count, strerror(errno)); return FAILED; } @@ -85,7 +86,8 @@ Status FileSaver::WriteData(const void *data, uint32_t size, int32_t fd) { Status FileSaver::SaveWithFileHeader(const std::string &file_path, const ModelFileHeader &file_header, const void *data, int len) { if (data == nullptr || len <= 0) { - GELOGE(FAILED, "Model_data is null or the length[%d] less than 1.", len); + GELOGE(FAILED, "[Save][File]Failed, model_data is null or the length[%d] is less than 1.", len); + REPORT_INNER_ERROR("E19999", "Init save file failed, model_data is null or the length:%d is less than 1.", len); return FAILED; } @@ -104,7 +106,7 @@ Status FileSaver::SaveWithFileHeader(const std::string &file_path, const ModelFi } while (0); // Close file if (mmClose(fd) != 0) { // mmClose 0: success - GELOGE(FAILED, "Close file failed."); + GELOGE(FAILED, "[Save][File]Close file failed, error_code:%u.", ret); ret = FAILED; } return ret; @@ -193,7 +195,8 @@ Status FileSaver::SaveToBuffWithFileHeader(const ModelFileHeader &file_header, FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status FileSaver::CheckPath(const std::string &file_path) { // Determine file path length if (file_path.size() >= MMPA_MAX_PATH) { - GELOGE(FAILED, "Path is too long:%zu", file_path.size()); + GELOGE(FAILED, "[Check][FilePath]Failed, file path's length:%zu > mmpa_max_path:%zu", file_path.size(), MMPA_MAX_PATH); + REPORT_INPUT_ERROR("E10053", std::vector({"length"}), std:;vector({std::to_string(file_path.size())})); return FAILED; } @@ -212,7 +215,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status FileSaver::CheckPath(con // If there is a path before the file name, create the path if (path_split_pos != -1) { if (CreateDirectory(std::string(file_path).substr(0, static_cast(path_split_pos))) != kFileOpSuccess) { - GELOGE(FAILED, "CreateDirectory failed, file path:%s.", file_path.c_str()); + GELOGE(FAILED, "[Create][Directory]Failed, file path:%s.", file_path.c_str()); return FAILED; } } @@ -223,7 +226,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status FileSaver::CheckPath(con FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status FileSaver::SaveToFile(const string &file_path, const ge::ModelData &model, const ModelFileHeader *model_file_header) { if (file_path.empty() || model.model_data == nullptr || model.model_len == 0) { - GELOGE(FAILED, "Incorrected input param. file_path.empty() || model.model_data == nullptr || model.model_len == 0"); + GELOGE(FAILED, "[Save][File]Incorrect input param, file_path is empty or model_data is nullptr or model_len is 0"); + REPORT_INNER_ERROR("E19999", "Save file failed, at least one of the input parameters(file_path, model_data, model_len) is incorrect") return FAILED; } @@ -240,7 +244,8 @@ FileSaver::SaveToFile(const string &file_path, const ge::ModelData &model, const const Status ret = SaveWithFileHeader(file_path, file_header, model.model_data, file_header.length); if (ret != SUCCESS) { - GELOGE(FAILED, "Save file failed, file_path:%s, file header len:%u.", file_path.c_str(), file_header.length); + GELOGE(FAILED, "[Save][File]Failed, file_path:%s, file_header_len:%u, error_code:%u.", + file_path.c_str(), file_header.length, ret); return FAILED; } @@ -320,7 +325,8 @@ Status FileSaver::SaveWithFileHeader(const std::string &file_path, const ModelFi FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status FileSaver::SaveToFile(const string &file_path, const void *data, int len) { if (data == nullptr || len <= 0) { - GELOGE(FAILED, "Model_data is null or the length[%d] less than 1.", len); + GELOGE(FAILED, "[Save][File]Failed, model_data is null or the length[%d] is less than 1.", len); + REPORT_INNER_ERROR("E19999", "Save file failed, the model_data is null or its length:%d is less than 1.", len); return FAILED; } @@ -335,7 +341,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status FileSaver::SaveToFile(co // Close file if (mmClose(fd) != 0) { // mmClose 0: success - GELOGE(FAILED, "Close file failed."); + GELOGE(FAILED, "[Save][File]Close file failed, error_code:%u.", ret); ret = FAILED; } return ret; diff --git a/ge/common/debug/memory_dumper.cc b/ge/common/debug/memory_dumper.cc index 527f0bb2..08364c33 100644 --- a/ge/common/debug/memory_dumper.cc +++ b/ge/common/debug/memory_dumper.cc @@ -41,14 +41,16 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status MemoryDumper::DumpToFile GE_CHECK_NOTNULL(filename); GE_CHECK_NOTNULL(data); if (len == 0) { - GELOGE(FAILED, "len is 0."); + GELOGE(FAILED, "[Dump][Data]Init failed, data length is 0."); + REPORT_INPUT_ERROR("E10054", std::vector({"length"}), std::vector({std::to_string(len)})); return PARAM_INVALID; } // Open the file int fd = OpenFile(filename); if (fd == kInvalidFd) { - GELOGE(FAILED, "Open file failed."); + GELOGE(FAILED, "[Dump][Data]Open file failed, filename:%s.", filename.c_str()); + REPORT_INPUT_ERROR("E10055", std::vector({"filename"}), std::vector({filename.c_str()})); return FAILED; } @@ -57,13 +59,13 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status MemoryDumper::DumpToFile int32_t mmpa_ret = mmWrite(fd, data, len); // mmWrite return -1:Failed to write data to file;return -2:Invalid parameter if (mmpa_ret == EN_ERROR || mmpa_ret == EN_INVALID_PARAM) { - GELOGE(FAILED, "Write to file failed. errno = %d, %s", mmpa_ret, strerror(errno)); + GELOGE(FAILED, "[Dump][Data]Write data to file failed. errno = mmpa_ret:%d, error:%s", mmpa_ret, strerror(errno)); ret = FAILED; } // Close the file if (mmClose(fd) != EN_OK) { // mmClose return 0: success - GELOGE(FAILED, "Close file failed."); + GELOGE(FAILED, "[Dump][Data]Close file failed, error_code:%u.", ret); ret = FAILED; } @@ -89,7 +91,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status MemoryDumper::Open(const fd_ = OpenFile(filename); if (fd_ == kInvalidFd) { - GELOGE(FAILED, "Open %s failed.", filename); + GELOGE(FAILED, "[Open][File]Open file:%s failed.", filename); + REPORT_INNER_ERROR("E19999", "Open file:%s failed.", filename) return FAILED; } @@ -104,7 +107,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status MemoryDumper::Dump(void int32_t mmpa_ret = mmWrite(fd_, data, len); // mmWrite return -1:failed to write data to file;return -2:invalid parameter if (mmpa_ret == EN_ERROR || mmpa_ret == EN_INVALID_PARAM) { - GELOGE(FAILED, "Write to file failed. errno = %d, %s", mmpa_ret, strerror(errno)); + GELOGE(FAILED, "[Dump][Data]Write data to file failed, errno = mmpa_ret:%d, error:%s", mmpa_ret, strerror(errno)); return FAILED; } @@ -157,7 +160,7 @@ int MemoryDumper::OpenFile(const char *filename) { int32_t fd = mmOpen2(real_path.c_str(), M_RDWR | M_CREAT | O_TRUNC, mode); if (fd == EN_ERROR || fd == EN_INVALID_PARAM) { - GELOGE(kInvalidFd, "open file failed. errno = %d, %s", fd, strerror(errno)); + GELOGE(kInvalidFd, "[Open][File]Failed. errno = %d, %s", fd, strerror(errno)); return kInvalidFd; } return fd; From 51a9cd52e1864d30ae3b9e5f97499c7b3b0cfc76 Mon Sep 17 00:00:00 2001 From: "liyihan2@huawei.com" Date: Tue, 23 Mar 2021 17:33:32 +0800 Subject: [PATCH 02/15] Common log optimize --- ge/client/ge_api.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ge/client/ge_api.cc b/ge/client/ge_api.cc index ae7f51ab..7ecfcc9c 100644 --- a/ge/client/ge_api.cc +++ b/ge/client/ge_api.cc @@ -70,8 +70,8 @@ Status CheckOptionsValid(const std::map &options) { if (job_id_iter != options.end()) { if (job_id_iter->second.length() > kMaxStrLen) { GELOGE(PARAM_INVALID,"[Check][JobId]Failed," - "the job_id [%s] string length > max string length: %d", - job_id_iter->second.c_str(), kMaxStrLen); + "the job_id [%s] string length: %zu > max string length: %d", + job_id_iter->second.c_str(), job_id_iter->second.length(), kMaxStrLen); REPORT_INPUT_ERROR("E10051", std::vector({"id","length"}), std::vector({job_id_iter->second, std::to_string(kMaxStrLen)})); return FAILED; } From 876f9e301af4ef821a78200318bac842c196f991 Mon Sep 17 00:00:00 2001 From: "liyihan2@huawei.com" Date: Tue, 23 Mar 2021 20:46:09 +0800 Subject: [PATCH 03/15] Common log optimize --- ge/common/auth/file_saver.cc | 25 ++++++++++++++++--------- ge/common/debug/memory_dumper.cc | 22 +++++++++++++--------- 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/ge/common/auth/file_saver.cc b/ge/common/auth/file_saver.cc index 1ed36035..23aab7ac 100755 --- a/ge/common/auth/file_saver.cc +++ b/ge/common/auth/file_saver.cc @@ -34,7 +34,7 @@ namespace ge { Status FileSaver::OpenFile(int32_t &fd, const std::string &file_path) { if (CheckPath(file_path) != SUCCESS) { GELOGE(FAILED, "[Open][File]Check output file failed, file_path:%s.", file_path); - REPORT_INPUT_ERROR("E10052", std::vector({"path"}), std::vector({file_path})); + REPORT_INNER_ERROR("E19999", "Check output file failed, file_path:%s.", file_path); return FAILED; } @@ -46,7 +46,8 @@ Status FileSaver::OpenFile(int32_t &fd, const std::string &file_path) { fd = mmOpen2(real_path, M_RDWR | M_CREAT | O_TRUNC, mode); if (fd == EN_INVALID_PARAM || fd == EN_ERROR) { // -1: Failed to open file; - 2: Illegal parameter - GELOGE(FAILED, "[Open][File]Open file failed. mmpa_errno = fd:%d, error:%s", fd, strerror(errno)); + GELOGE(FAILED, "[Open][File]Failed. mmpa_errno = %d, %s", fd, strerror(errno)); + REPORT_INNER_ERROR("E19999", "Open file failed, mmpa_errno = %d, error:%s.", fd, strerror(errno)); return FAILED; } return SUCCESS; @@ -63,7 +64,9 @@ Status FileSaver::WriteData(const void *data, uint32_t size, int32_t fd) { while (size > size_1g) { write_count = mmWrite(fd, reinterpret_cast(seek), size_1g); if (write_count == EN_INVALID_PARAM || write_count == EN_ERROR) { - GELOGE(FAILED, "[Write][Data]Write data failed. mmpa_errorno = write_count:%ld, error:%s", write_count, strerror(errno)); + GELOGE(FAILED, "[Write][Data]Failed, mmpa_errorno = %ld, error:%s", write_count, strerror(errno)); + REPORT_INNER_ERROR("E19999", "Write data failed, mmpa_errorno = %ld, error:%s.", + write_count, strerror(errno)); return FAILED; } size -= size_1g; @@ -76,7 +79,9 @@ Status FileSaver::WriteData(const void *data, uint32_t size, int32_t fd) { // -1: Failed to write to file; - 2: Illegal parameter if (write_count == EN_INVALID_PARAM || write_count == EN_ERROR) { - GELOGE(FAILED, "[Write][Data]Write data failed. mmpa_errorno = write_count:%ld, error:%s", write_count, strerror(errno)); + GELOGE(FAILED, "[Write][Data]Failed. mmpa_errorno = %ld, error:%s", write_count, strerror(errno)); + REPORT_INNER_ERROR("E19999", "Write data failed, mmpa_errorno = %ld, error:%s.", + write_count, strerror(errno)); return FAILED; } @@ -87,7 +92,7 @@ Status FileSaver::SaveWithFileHeader(const std::string &file_path, const ModelFi int len) { if (data == nullptr || len <= 0) { GELOGE(FAILED, "[Save][File]Failed, model_data is null or the length[%d] is less than 1.", len); - REPORT_INNER_ERROR("E19999", "Init save file failed, model_data is null or the length:%d is less than 1.", len); + REPORT_INNER_ERROR("E19999", "Save file failed, model_data is null or the length:%d is less than 1.", len); return FAILED; } @@ -106,7 +111,7 @@ Status FileSaver::SaveWithFileHeader(const std::string &file_path, const ModelFi } while (0); // Close file if (mmClose(fd) != 0) { // mmClose 0: success - GELOGE(FAILED, "[Save][File]Close file failed, error_code:%u.", ret); + GELOGE(FAILED, "[Save][File]Failed, error_code:%u.", ret); ret = FAILED; } return ret; @@ -195,8 +200,10 @@ Status FileSaver::SaveToBuffWithFileHeader(const ModelFileHeader &file_header, FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status FileSaver::CheckPath(const std::string &file_path) { // Determine file path length if (file_path.size() >= MMPA_MAX_PATH) { - GELOGE(FAILED, "[Check][FilePath]Failed, file path's length:%zu > mmpa_max_path:%zu", file_path.size(), MMPA_MAX_PATH); - REPORT_INPUT_ERROR("E10053", std::vector({"length"}), std:;vector({std::to_string(file_path.size())})); + GELOGE(FAILED, "[Check][FilePath]Failed, file path's length:%zu > mmpa_max_path:%zu", + file_path.size(), MMPA_MAX_PATH); + REPORT_INNER_ERROR("E19999", "Check file path failed, file path's length:%zu > mmpa_max_path:%zu", + file_path.size(), MMPA_MAX_PATH); return FAILED; } @@ -341,7 +348,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status FileSaver::SaveToFile(co // Close file if (mmClose(fd) != 0) { // mmClose 0: success - GELOGE(FAILED, "[Save][File]Close file failed, error_code:%u.", ret); + GELOGE(FAILED, "[Save][File]Failed, error_code:%u.", ret); ret = FAILED; } return ret; diff --git a/ge/common/debug/memory_dumper.cc b/ge/common/debug/memory_dumper.cc index 08364c33..2fcb13a9 100644 --- a/ge/common/debug/memory_dumper.cc +++ b/ge/common/debug/memory_dumper.cc @@ -41,16 +41,16 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status MemoryDumper::DumpToFile GE_CHECK_NOTNULL(filename); GE_CHECK_NOTNULL(data); if (len == 0) { - GELOGE(FAILED, "[Dump][Data]Init failed, data length is 0."); - REPORT_INPUT_ERROR("E10054", std::vector({"length"}), std::vector({std::to_string(len)})); + GELOGE(FAILED, "[Check][Param]Failed, data length is 0."); + REPORT_INNER_ERROR("E19999", "Check param failed, data length is 0."); return PARAM_INVALID; } // Open the file int fd = OpenFile(filename); if (fd == kInvalidFd) { - GELOGE(FAILED, "[Dump][Data]Open file failed, filename:%s.", filename.c_str()); - REPORT_INPUT_ERROR("E10055", std::vector({"filename"}), std::vector({filename.c_str()})); + GELOGE(FAILED, "[Open][File]Failed, filename:%s.", filename.c_str()); + REPORT_INNER_ERROR("E19999", "Opne file failed, filename:%s.", filename.c_str()); return FAILED; } @@ -59,13 +59,15 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status MemoryDumper::DumpToFile int32_t mmpa_ret = mmWrite(fd, data, len); // mmWrite return -1:Failed to write data to file;return -2:Invalid parameter if (mmpa_ret == EN_ERROR || mmpa_ret == EN_INVALID_PARAM) { - GELOGE(FAILED, "[Dump][Data]Write data to file failed. errno = mmpa_ret:%d, error:%s", mmpa_ret, strerror(errno)); + GELOGE(FAILED, "[Write][Data]Failed, errno = %d, error:%s", mmpa_ret, strerror(errno)); + REPORT_INNER_ERROR("E19999", "Write data failed, errno = %d, error:%s.", mmpa_ret, strerror(errno)); ret = FAILED; } // Close the file if (mmClose(fd) != EN_OK) { // mmClose return 0: success - GELOGE(FAILED, "[Dump][Data]Close file failed, error_code:%u.", ret); + GELOGE(FAILED, "[Close][File]Failed, error_code:%u, filename:%s.", ret, file_name.c_str()); + REPORT_INNER_ERROR("E19999", "Close file failed, error_code:%u, filename:%s.", ret, filename.c_str()); ret = FAILED; } @@ -91,7 +93,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status MemoryDumper::Open(const fd_ = OpenFile(filename); if (fd_ == kInvalidFd) { - GELOGE(FAILED, "[Open][File]Open file:%s failed.", filename); + GELOGE(FAILED, "[Open][File]Failed, filename:%s.", filename); REPORT_INNER_ERROR("E19999", "Open file:%s failed.", filename) return FAILED; } @@ -107,7 +109,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status MemoryDumper::Dump(void int32_t mmpa_ret = mmWrite(fd_, data, len); // mmWrite return -1:failed to write data to file;return -2:invalid parameter if (mmpa_ret == EN_ERROR || mmpa_ret == EN_INVALID_PARAM) { - GELOGE(FAILED, "[Dump][Data]Write data to file failed, errno = mmpa_ret:%d, error:%s", mmpa_ret, strerror(errno)); + GELOGE(FAILED, "[Write][Data]Failed, errno = %d, error:%s", mmpa_ret, strerror(errno)); + REPORT_INNER_ERROR("E19999", "Write data to file failed, errno = %d, error:%s.", mmpa_ret, strerror(errno)); return FAILED; } @@ -160,7 +163,8 @@ int MemoryDumper::OpenFile(const char *filename) { int32_t fd = mmOpen2(real_path.c_str(), M_RDWR | M_CREAT | O_TRUNC, mode); if (fd == EN_ERROR || fd == EN_INVALID_PARAM) { - GELOGE(kInvalidFd, "[Open][File]Failed. errno = %d, %s", fd, strerror(errno)); + GELOGE(kInvalidFd, "[Open][File]Failed. errno = %d, error:%s, filename:%s.", + fd, strerror(errno), filename.c_str()); return kInvalidFd; } return fd; From 7070f39692e49823bc6e4bfc3a9525f4f6113cde Mon Sep 17 00:00:00 2001 From: "liyihan2@huawei.com" Date: Tue, 23 Mar 2021 21:58:25 +0800 Subject: [PATCH 04/15] Common log optimize --- ge/common/debug/memory_dumper.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ge/common/debug/memory_dumper.cc b/ge/common/debug/memory_dumper.cc index 2fcb13a9..1e5e9295 100644 --- a/ge/common/debug/memory_dumper.cc +++ b/ge/common/debug/memory_dumper.cc @@ -49,8 +49,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status MemoryDumper::DumpToFile // Open the file int fd = OpenFile(filename); if (fd == kInvalidFd) { - GELOGE(FAILED, "[Open][File]Failed, filename:%s.", filename.c_str()); - REPORT_INNER_ERROR("E19999", "Opne file failed, filename:%s.", filename.c_str()); + GELOGE(FAILED, "[Open][File]Failed, filename:%s.", filename); + REPORT_INNER_ERROR("E19999", "Opne file failed, filename:%s.", filename); return FAILED; } @@ -66,8 +66,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status MemoryDumper::DumpToFile // Close the file if (mmClose(fd) != EN_OK) { // mmClose return 0: success - GELOGE(FAILED, "[Close][File]Failed, error_code:%u, filename:%s.", ret, file_name.c_str()); - REPORT_INNER_ERROR("E19999", "Close file failed, error_code:%u, filename:%s.", ret, filename.c_str()); + GELOGE(FAILED, "[Close][File]Failed, error_code:%u, filename:%s.", ret, file_name); + REPORT_INNER_ERROR("E19999", "Close file failed, error_code:%u, filename:%s.", ret, filename); ret = FAILED; } @@ -164,7 +164,7 @@ int MemoryDumper::OpenFile(const char *filename) { int32_t fd = mmOpen2(real_path.c_str(), M_RDWR | M_CREAT | O_TRUNC, mode); if (fd == EN_ERROR || fd == EN_INVALID_PARAM) { GELOGE(kInvalidFd, "[Open][File]Failed. errno = %d, error:%s, filename:%s.", - fd, strerror(errno), filename.c_str()); + fd, strerror(errno), filename); return kInvalidFd; } return fd; From 11a72900c2748f5219c151b8795007332bb52718 Mon Sep 17 00:00:00 2001 From: "liyihan2@huawei.com" Date: Wed, 24 Mar 2021 09:23:16 +0800 Subject: [PATCH 05/15] Common log optimize --- ge/common/debug/memory_dumper.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ge/common/debug/memory_dumper.cc b/ge/common/debug/memory_dumper.cc index 1e5e9295..5cbf13cb 100644 --- a/ge/common/debug/memory_dumper.cc +++ b/ge/common/debug/memory_dumper.cc @@ -66,7 +66,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status MemoryDumper::DumpToFile // Close the file if (mmClose(fd) != EN_OK) { // mmClose return 0: success - GELOGE(FAILED, "[Close][File]Failed, error_code:%u, filename:%s.", ret, file_name); + GELOGE(FAILED, "[Close][File]Failed, error_code:%u, filename:%s.", ret, filename); REPORT_INNER_ERROR("E19999", "Close file failed, error_code:%u, filename:%s.", ret, filename); ret = FAILED; } From fc58b5f4043aab131ff29bd63df199e9822c13b7 Mon Sep 17 00:00:00 2001 From: "liyihan2@huawei.com" Date: Wed, 24 Mar 2021 09:58:38 +0800 Subject: [PATCH 06/15] Common log optimize --- ge/common/auth/file_saver.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ge/common/auth/file_saver.cc b/ge/common/auth/file_saver.cc index 23aab7ac..a30cc93a 100755 --- a/ge/common/auth/file_saver.cc +++ b/ge/common/auth/file_saver.cc @@ -33,8 +33,8 @@ const int kFileOpSuccess = 0; namespace ge { Status FileSaver::OpenFile(int32_t &fd, const std::string &file_path) { if (CheckPath(file_path) != SUCCESS) { - GELOGE(FAILED, "[Open][File]Check output file failed, file_path:%s.", file_path); - REPORT_INNER_ERROR("E19999", "Check output file failed, file_path:%s.", file_path); + GELOGE(FAILED, "[Open][File]Check output file failed, file_path:%s.", file_path.c_str()); + REPORT_INNER_ERROR("E19999", "Check output file failed, file_path:%s.", file_path.c_str()); return FAILED; } @@ -200,9 +200,9 @@ Status FileSaver::SaveToBuffWithFileHeader(const ModelFileHeader &file_header, FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status FileSaver::CheckPath(const std::string &file_path) { // Determine file path length if (file_path.size() >= MMPA_MAX_PATH) { - GELOGE(FAILED, "[Check][FilePath]Failed, file path's length:%zu > mmpa_max_path:%zu", + GELOGE(FAILED, "[Check][FilePath]Failed, file path's length:%zu > mmpa_max_path:%d", file_path.size(), MMPA_MAX_PATH); - REPORT_INNER_ERROR("E19999", "Check file path failed, file path's length:%zu > mmpa_max_path:%zu", + REPORT_INNER_ERROR("E19999", "Check file path failed, file path's length:%zu > mmpa_max_path:%d", file_path.size(), MMPA_MAX_PATH); return FAILED; } From be5eecabb729bf2a128d7cb1227c6b317fae3749 Mon Sep 17 00:00:00 2001 From: "liyihan2@huawei.com" Date: Wed, 24 Mar 2021 10:31:07 +0800 Subject: [PATCH 07/15] Common log optimize --- ge/common/cust_aicpu_kernel_store.cc | 4 ++-- ge/common/fmk_error_codes.cc | 36 ++++++++++++++-------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/ge/common/cust_aicpu_kernel_store.cc b/ge/common/cust_aicpu_kernel_store.cc index 1055989b..fda7c040 100755 --- a/ge/common/cust_aicpu_kernel_store.cc +++ b/ge/common/cust_aicpu_kernel_store.cc @@ -25,7 +25,7 @@ void CustAICPUKernelStore::AddCustAICPUKernel(const CustAICPUKernelPtr &kernel) } void CustAICPUKernelStore::LoadCustAICPUKernelBinToOpDesc(const std::shared_ptr &op_desc) const { - GELOGD("LoadCustAICPUKernelBinToOpDesc in."); + GELOGD("LoadCustAICPUKernelBinToOpDesc in!"); if (op_desc != nullptr) { auto kernel_bin = FindKernel(op_desc->GetName()); if (kernel_bin != nullptr) { @@ -34,6 +34,6 @@ void CustAICPUKernelStore::LoadCustAICPUKernelBinToOpDesc(const std::shared_ptr< GELOGI("Load cust aicpu kernel:%s, %zu", kernel_bin->GetName().c_str(), kernel_bin->GetBinDataSize()); } } - GELOGD("LoadCustAICPUKernelBinToOpDesc success."); + GELOGD("LoadCustAICPUKernelBinToOpDesc success!"); } } // namespace ge diff --git a/ge/common/fmk_error_codes.cc b/ge/common/fmk_error_codes.cc index ddb8089d..a1798b80 100755 --- a/ge/common/fmk_error_codes.cc +++ b/ge/common/fmk_error_codes.cc @@ -37,28 +37,28 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY std::string StatusFactory::GetE return iter_find->second; } // General error code -DEF_ERRORNO(SUCCESS, "Success"); -DEF_ERRORNO(FAILED, "Failed"); +DEF_ERRORNO(SUCCESS, "Success."); +DEF_ERRORNO(FAILED, "Failed."); // Common errocode -DEF_ERRORNO(MEMALLOC_FAILED, "Failed to allocate memory!"); // 50331648 -DEF_ERRORNO(PARAM_INVALID, "Parameter's invalid!"); // 50331649 -DEF_ERRORNO(CCE_FAILED, "Failed to call CCE API!"); // 50331650 -DEF_ERRORNO(RT_FAILED, "Failed to call runtime API!"); // 50331651 -DEF_ERRORNO(INTERNAL_ERROR, "Internal errors"); // 50331652 -DEF_ERRORNO(CSEC_ERROR, "Failed to call libc_sec API!"); // 50331653 -DEF_ERRORNO(TEE_ERROR, "Failed to call tee API!"); // 50331653 -DEF_ERRORNO(UNSUPPORTED, "Parameter's unsupported!"); -DEF_ERRORNO(OUT_OF_MEMORY, "Out of memory!"); +DEF_ERRORNO(MEMALLOC_FAILED, "Failed to allocate memory."); // 50331648 +DEF_ERRORNO(PARAM_INVALID, "Parameter's invalid."); // 50331649 +DEF_ERRORNO(CCE_FAILED, "Failed to call CCE API."); // 50331650 +DEF_ERRORNO(RT_FAILED, "Failed to call runtime API."); // 50331651 +DEF_ERRORNO(INTERNAL_ERROR, "Internal errors."); // 50331652 +DEF_ERRORNO(CSEC_ERROR, "Failed to call libc_sec API."); // 50331653 +DEF_ERRORNO(TEE_ERROR, "Failed to call tee API."); // 50331653 +DEF_ERRORNO(UNSUPPORTED, "Parameter's unsupported."); +DEF_ERRORNO(OUT_OF_MEMORY, "Out of memory."); // errorcode -DEF_ERRORNO(PARSE_MODEL_FAILED, "Failed to parse the model!"); -DEF_ERRORNO(PARSE_WEIGHTS_FAILED, "Failed to parse the weights!"); -DEF_ERRORNO(NOT_INITIALIZED, "It hasn't been initialized!"); -DEF_ERRORNO(TIMEOUT, "Running time out!"); +DEF_ERRORNO(PARSE_MODEL_FAILED, "Failed to parse the model."); +DEF_ERRORNO(PARSE_WEIGHTS_FAILED, "Failed to parse the weights."); +DEF_ERRORNO(NOT_INITIALIZED, "It hasn't been initialized."); +DEF_ERRORNO(TIMEOUT, "Running time out."); // errorcode -DEF_ERRORNO(MODEL_NOT_READY, "The model is not ready yet!"); -DEF_ERRORNO(PUSH_DATA_FAILED, "Failed to push data!"); -DEF_ERRORNO(DATA_QUEUE_ISFULL, "Data queue is full!"); +DEF_ERRORNO(MODEL_NOT_READY, "The model is not ready yet."); +DEF_ERRORNO(PUSH_DATA_FAILED, "Failed to push data."); +DEF_ERRORNO(DATA_QUEUE_ISFULL, "Data queue is full."); } // namespace domi From 29af5ca0159636d764737f75ae4ac38bb9cbc9fc Mon Sep 17 00:00:00 2001 From: "liyihan2@huawei.com" Date: Wed, 24 Mar 2021 11:05:27 +0800 Subject: [PATCH 08/15] Common log optimize --- ge/analyzer/analyzer.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ge/analyzer/analyzer.cc b/ge/analyzer/analyzer.cc index 528a0265..47b5c3ab 100755 --- a/ge/analyzer/analyzer.cc +++ b/ge/analyzer/analyzer.cc @@ -155,7 +155,7 @@ std::shared_ptr Analyzer::GetJsonObject(uint64_t session_id, uint64_t std::lock_guard lg(mutex_); auto iter = graph_infos_.find(session_id); if (iter == graph_infos_.end()) { - GELOGE(PARAM_INVALID, "[Check][SessionId]session_id:%lu does not exist! graph_id:%lu", session_id, graph_id); + GELOGE(PARAM_INVALID, "[Check][SessionId]session_id:%lu does not exist! graph_id:%lu.", session_id, graph_id); return nullptr; } else { auto iter1 = (iter->second).find(graph_id); @@ -200,7 +200,7 @@ ge::Status Analyzer::CreateAnalyzerFile() { } ge::Status Analyzer::SaveAnalyzerDataToFile(uint64_t session_id, uint64_t graph_id) { - GELOGD("start to save analyze file"); + GELOGD("start to save analyze file!"); auto graph_info = GetJsonObject(session_id, graph_id); GE_CHECK_NOTNULL(graph_info); @@ -232,7 +232,7 @@ ge::Status Analyzer::SaveAnalyzerDataToFile(uint64_t session_id, uint64_t graph_ } ge::Status Analyzer::DoAnalyze(DataInfo &data_info) { - GELOGD("start to do analyzer process"); + GELOGD("start to do analyzer process!"); auto pnode = data_info.node_ptr; GE_CHECK_NOTNULL(pnode); From 229e7c13f779eb4f1f2d0678bb8e9279a179776a Mon Sep 17 00:00:00 2001 From: "liyihan2@huawei.com" Date: Wed, 24 Mar 2021 11:18:07 +0800 Subject: [PATCH 09/15] Common log optimize --- ge/common/debug/memory_dumper.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ge/common/debug/memory_dumper.cc b/ge/common/debug/memory_dumper.cc index 5cbf13cb..e19d9a95 100644 --- a/ge/common/debug/memory_dumper.cc +++ b/ge/common/debug/memory_dumper.cc @@ -94,7 +94,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status MemoryDumper::Open(const fd_ = OpenFile(filename); if (fd_ == kInvalidFd) { GELOGE(FAILED, "[Open][File]Failed, filename:%s.", filename); - REPORT_INNER_ERROR("E19999", "Open file:%s failed.", filename) + REPORT_INNER_ERROR("E19999", "Open file:%s failed.", filename); return FAILED; } From 7b259765938831113d0a23a9d60491a696652bb0 Mon Sep 17 00:00:00 2001 From: "liyihan2@huawei.com" Date: Wed, 24 Mar 2021 11:29:37 +0800 Subject: [PATCH 10/15] Common log optimize --- ge/common/auth/file_saver.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ge/common/auth/file_saver.cc b/ge/common/auth/file_saver.cc index a30cc93a..69b3d402 100755 --- a/ge/common/auth/file_saver.cc +++ b/ge/common/auth/file_saver.cc @@ -234,7 +234,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status FileSaver::SaveToFile(const string &file_path, const ge::ModelData &model, const ModelFileHeader *model_file_header) { if (file_path.empty() || model.model_data == nullptr || model.model_len == 0) { GELOGE(FAILED, "[Save][File]Incorrect input param, file_path is empty or model_data is nullptr or model_len is 0"); - REPORT_INNER_ERROR("E19999", "Save file failed, at least one of the input parameters(file_path, model_data, model_len) is incorrect") + REPORT_INNER_ERROR("E19999", "Save file failed, at least one of the input parameters(file_path, model_data, model_len) is incorrect"); return FAILED; } From 14744209b960279362adf456f45c13c6e1394250 Mon Sep 17 00:00:00 2001 From: "liyihan2@huawei.com" Date: Wed, 24 Mar 2021 16:08:48 +0800 Subject: [PATCH 11/15] Common log optimize --- ge/common/auth/file_saver.cc | 14 ++++++++------ ge/common/util.cc | 8 ++++---- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/ge/common/auth/file_saver.cc b/ge/common/auth/file_saver.cc index 69b3d402..c98d2b09 100755 --- a/ge/common/auth/file_saver.cc +++ b/ge/common/auth/file_saver.cc @@ -33,8 +33,8 @@ const int kFileOpSuccess = 0; namespace ge { Status FileSaver::OpenFile(int32_t &fd, const std::string &file_path) { if (CheckPath(file_path) != SUCCESS) { - GELOGE(FAILED, "[Open][File]Check output file failed, file_path:%s.", file_path.c_str()); - REPORT_INNER_ERROR("E19999", "Check output file failed, file_path:%s.", file_path.c_str()); + GELOGE(FAILED, "[Check][FilePath]Check output file failed, file_path:%s.", file_path.c_str()); + REPORT_CALL_ERROR("E19999", "Check output file failed, file_path:%s.", file_path.c_str()); return FAILED; } @@ -91,7 +91,7 @@ Status FileSaver::WriteData(const void *data, uint32_t size, int32_t fd) { Status FileSaver::SaveWithFileHeader(const std::string &file_path, const ModelFileHeader &file_header, const void *data, int len) { if (data == nullptr || len <= 0) { - GELOGE(FAILED, "[Save][File]Failed, model_data is null or the length[%d] is less than 1.", len); + GELOGE(FAILED, "[Check][Param]Failed, model_data is null or the length[%d] is less than 1.", len); REPORT_INNER_ERROR("E19999", "Save file failed, model_data is null or the length:%d is less than 1.", len); return FAILED; } @@ -111,7 +111,8 @@ Status FileSaver::SaveWithFileHeader(const std::string &file_path, const ModelFi } while (0); // Close file if (mmClose(fd) != 0) { // mmClose 0: success - GELOGE(FAILED, "[Save][File]Failed, error_code:%u.", ret); + GELOGE(FAILED, "[Close][File]Failed, error_code:%u.", ret); + REPORT_INNER_ERROR("E19999", "Close file failed, error_code:%u.", ret); ret = FAILED; } return ret; @@ -332,7 +333,7 @@ Status FileSaver::SaveWithFileHeader(const std::string &file_path, const ModelFi FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status FileSaver::SaveToFile(const string &file_path, const void *data, int len) { if (data == nullptr || len <= 0) { - GELOGE(FAILED, "[Save][File]Failed, model_data is null or the length[%d] is less than 1.", len); + GELOGE(FAILED, "[Check][Param]Failed, model_data is null or the length[%d] is less than 1.", len); REPORT_INNER_ERROR("E19999", "Save file failed, the model_data is null or its length:%d is less than 1.", len); return FAILED; } @@ -348,7 +349,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status FileSaver::SaveToFile(co // Close file if (mmClose(fd) != 0) { // mmClose 0: success - GELOGE(FAILED, "[Save][File]Failed, error_code:%u.", ret); + GELOGE(FAILED, "[Close][File]Failed, error_code:%u.", ret); + REPORT_INNER_ERROR("E19999", "Close file failed, error_code:%u.", ret); ret = FAILED; } return ret; diff --git a/ge/common/util.cc b/ge/common/util.cc index 0a343a83..836f4664 100644 --- a/ge/common/util.cc +++ b/ge/common/util.cc @@ -113,11 +113,11 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadProtoFromArray(const v // Get file length long GetFileLength(const std::string &input_file) { - GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(input_file.empty(), return -1, "input_file path is null."); + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(input_file.empty(), return -1, "input_file path is null"); std::string real_path = RealPath(input_file.c_str()); - GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(real_path.empty(), return -1, "input_file path '%s' not valid", input_file.c_str()); + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(real_path.empty(), return -1, "input_file path '%s' not valid.", input_file.c_str()); unsigned long long file_length = 0; GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( mmGetFileSize(input_file.c_str(), &file_length) != EN_OK, @@ -318,7 +318,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY uint64_t GetCurrentTimestamp() FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY uint32_t GetCurrentSecondTimestap() { mmTimeval tv{}; int ret = mmGetTimeOfDay(&tv, nullptr); - GE_LOGE_IF(ret != EN_OK, "Func gettimeofday may failed: ret=%d", ret); + GE_LOGE_IF(ret != EN_OK, "Func gettimeofday may failed: ret=%d.", ret); auto total_use_time = tv.tv_sec; // seconds return static_cast(total_use_time); } @@ -349,7 +349,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckInt64MulOverflow(int6 } FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY std::string RealPath(const char *path) { - GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(path == nullptr, return "", "path pointer is NULL."); + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(path == nullptr, return "", "path pointer is NULL"); GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(strlen(path) >= MMPA_MAX_PATH, ErrorManager::GetInstance().ATCReportErrMessage("E19002", {"filepath", "size"}, {path, std::to_string(MMPA_MAX_PATH)}); From 4ef1970f6d8c34ade37a72573cdd064ffe900a8d Mon Sep 17 00:00:00 2001 From: "liyihan2@huawei.com" Date: Fri, 26 Mar 2021 15:03:52 +0800 Subject: [PATCH 12/15] Common log optimize --- ge/common/dump/dump_manager.cc | 6 ++++-- ge/common/dump/dump_op.cc | 33 ++++++++++++++++-------------- ge/common/dump/opdebug_register.cc | 27 ++++++++++++++++-------- 3 files changed, 41 insertions(+), 25 deletions(-) diff --git a/ge/common/dump/dump_manager.cc b/ge/common/dump/dump_manager.cc index a659d9c6..462e5032 100644 --- a/ge/common/dump/dump_manager.cc +++ b/ge/common/dump/dump_manager.cc @@ -56,7 +56,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status DumpManager::SetDumpConf dump_properties.SetDumpOpSwitch(dump_op_switch); if (dump_op_switch == kDumpoff && dump_config.dump_list.empty()) { dump_properties_map_.emplace(kInferSessionId, dump_properties); - GELOGE(PARAM_INVALID, "Dump list is invalid,dump_op_switch is %s", dump_op_switch.c_str()); + GELOGE(PARAM_INVALID, "[Check][DumpList]Failed, dump_op_switch is %s.", dump_op_switch.c_str()); + REPORT_INNER_ERROR("E19999", "Check dump list failed, dump_op_switch is %s.", dump_op_switch.c_str()); return PARAM_INVALID; } @@ -82,7 +83,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status DumpManager::SetDumpConf dump_path = dump_config.dump_path; if (dump_path.empty()) { - GELOGE(PARAM_INVALID, "Dump path is empty"); + GELOGE(PARAM_INVALID, "[Check][DumpPath]Failed, it is empty."); + REPORT_INNER_ERROR("E19999", "Check dump path failed, it is empty."); return PARAM_INVALID; } diff --git a/ge/common/dump/dump_op.cc b/ge/common/dump/dump_op.cc index 0becbdc8..1bdbe513 100755 --- a/ge/common/dump/dump_op.cc +++ b/ge/common/dump/dump_op.cc @@ -99,7 +99,8 @@ Status DumpOp::DumpOutput(aicpu::dump::Task &task) { } int64_t output_size = 0; if (TensorUtils::GetTensorSizeInBytes(output_descs.at(i), output_size) != SUCCESS) { - GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "Get output size filed"); + GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "[Get][Param]Get output size failed, output_size:%d.", output_size); + REPORT_INNER_ERROR("E19999", "Get output size failed, output_size:%d.", output_size); return ACL_ERROR_GE_INTERNAL_ERROR; } GELOGD("Get output size in lanch dump op is %ld", output_size); @@ -126,7 +127,8 @@ Status DumpOp::DumpInput(aicpu::dump::Task &task) { } int64_t input_size = 0; if (TensorUtils::GetTensorSizeInBytes(input_descs.at(i), input_size) != SUCCESS) { - GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "Get output size filed"); + GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "[Get][Param]Get input size failed, input_size:%d.", input_size); + REPORT_INNER_ERROR("E19999", "Get input size failed, input_size:%d.", input_size); return ACL_ERROR_GE_INTERNAL_ERROR; } GELOGD("Get input size in lanch dump op is %ld", input_size); @@ -151,30 +153,31 @@ Status DumpOp::ExecutorDumpOp(aicpu::dump::OpMappingInfo &op_mapping_info) { size_t proto_size = op_mapping_info.ByteSizeLong(); bool ret = op_mapping_info.SerializeToString(&proto_msg); if (!ret || proto_size == 0) { - GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "Protobuf serialize failed, proto_size is %zu", proto_size); + GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "[Serialize][Protobuf]Failed, proto_size:%zu.", proto_size); + REPORT_INNER_ERROR("E19999", "Serialize protobuf failed, proto_size:%zu.", proto_size); return ACL_ERROR_GE_INTERNAL_ERROR; } rtError_t rt_ret = rtMalloc(&proto_dev_mem_, proto_size, RT_MEMORY_HBM); if (rt_ret != RT_ERROR_NONE) { - GELOGE(rt_ret, "Call rtMalloc failed, ret: 0x%X", rt_ret); + GELOGE(rt_ret, "[Malloc][ProtoDevMem]Failed, ret:0x%X", rt_ret); return RT_ERROR_TO_GE_STATUS(rt_ret); } rt_ret = rtMemcpy(proto_dev_mem_, proto_size, proto_msg.c_str(), proto_size, RT_MEMCPY_HOST_TO_DEVICE); if (rt_ret != RT_ERROR_NONE) { - GELOGE(rt_ret, "Call rtMemcpy failed, ret: 0x%X", rt_ret); + GELOGE(rt_ret, "[Copy][ProtoDevMem]Failed, ret:0x%X", rt_ret); return RT_ERROR_TO_GE_STATUS(rt_ret); } rt_ret = rtMalloc(&proto_size_dev_mem_, sizeof(size_t), RT_MEMORY_HBM); if (rt_ret != RT_ERROR_NONE) { - GELOGE(rt_ret, "Call rtMalloc failed, ret: 0x%X", rt_ret); + GELOGE(rt_ret, "[Malloc][ProtoSizeDevMem]Failed, ret:0x%X", rt_ret); return RT_ERROR_TO_GE_STATUS(rt_ret); } rt_ret = rtMemcpy(proto_size_dev_mem_, sizeof(size_t), &proto_size, sizeof(size_t), RT_MEMCPY_HOST_TO_DEVICE); if (rt_ret != RT_ERROR_NONE) { - GELOGE(rt_ret, "Call rtMemcpy failed, ret: 0x%X", rt_ret); + GELOGE(rt_ret, "[Copy][ProtoSizeDevMem]Failed, ret:0x%X", rt_ret); return RT_ERROR_TO_GE_STATUS(rt_ret); } @@ -193,7 +196,7 @@ Status DumpOp::ExecutorDumpOp(aicpu::dump::OpMappingInfo &op_mapping_info) { nullptr, // no need smDesc stream_); if (rt_ret != RT_ERROR_NONE) { - GELOGE(rt_ret, "Call rtCpuKernelLaunch failed,rt_ret:0x%X", rt_ret); + GELOGE(rt_ret, "[Call][rtCpuKernelLaunch]Failed, rt_ret:0x%X", rt_ret); return RT_ERROR_TO_GE_STATUS(rt_ret); } GELOGI("Kernel launch dump op success"); @@ -205,12 +208,12 @@ Status DumpOp::LaunchDumpOp() { int32_t device_id = 0; rtError_t rt_ret = rtGetDevice(&device_id); if (rt_ret != RT_ERROR_NONE) { - GELOGE(rt_ret, "Call rtGetDevice failed, ret = 0x%X, device_id = %d.", rt_ret, device_id); + GELOGE(rt_ret, "[Call][rtGetDevice]Failed, ret:0x%X, device_id:%d.", rt_ret, device_id); return RT_ERROR_TO_GE_STATUS(rt_ret); } if (device_id < 0) { GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, - "Check device_id failed, device_id = %d, which should be not less than 0.", + "[Check][DeviceId]Failed, device_id:%d, which should be not less than 0.", device_id); return ACL_ERROR_GE_INTERNAL_ERROR; } @@ -240,7 +243,7 @@ Status DumpOp::LaunchDumpOp() { if (dump_properties_.GetDumpMode() == kDumpOutput) { auto ret = DumpOutput(task); if (ret != SUCCESS) { - GELOGE(ret, "Dump output failed"); + GELOGE(ret, "[Dump][Output]Failed, error_code:%u.", ret); return ret; } op_mapping_info.mutable_task()->Add(std::move(task)); @@ -248,7 +251,7 @@ Status DumpOp::LaunchDumpOp() { if (dump_properties_.GetDumpMode() == kDumpInput) { auto ret = DumpInput(task); if (ret != SUCCESS) { - GELOGE(ret, "Dump input failed"); + GELOGE(ret, "[Dump][Input]Failed, error_code:%u.", ret); return ret; } op_mapping_info.mutable_task()->Add(std::move(task)); @@ -256,19 +259,19 @@ Status DumpOp::LaunchDumpOp() { if (dump_properties_.GetDumpMode() == kDumpAll || dump_properties_.IsOpDebugOpen()) { auto ret = DumpOutput(task); if (ret != SUCCESS) { - GELOGE(ret, "Dump output failed when in dumping all"); + GELOGE(ret, "[Dump][Output]Failed when in dumping all, error_code:%u.", ret); return ret; } ret = DumpInput(task); if (ret != SUCCESS) { - GELOGE(ret, "Dump input failed when in dumping all"); + GELOGE(ret, "[Dump][Input]Failed when in dumping all, error_code:%u.", ret); return ret; } op_mapping_info.mutable_task()->Add(std::move(task)); } auto ret = ExecutorDumpOp(op_mapping_info); if (ret != SUCCESS) { - GELOGE(ret, "Executor dump op failed"); + GELOGE(ret, "[Dump][Op]Failed, error_code:%u.", ret); return ret; } return SUCCESS; diff --git a/ge/common/dump/opdebug_register.cc b/ge/common/dump/opdebug_register.cc index 340b89e5..d4011a10 100644 --- a/ge/common/dump/opdebug_register.cc +++ b/ge/common/dump/opdebug_register.cc @@ -27,14 +27,20 @@ Status OpdebugRegister::RegisterDebugForModel(rtModel_t model_handle, uint32_t o GELOGD("Start to register debug for model in overflow"); auto ret = MallocMemForOpdebug(); if (ret != SUCCESS) { - GELOGE(ret, "Malloc memory for opdebug in model overflow failed ,ret:0x%X", ret); + GELOGE(ret, "[Malloc][MemoryForOpdebug]Failed in model overflow, ret:0x%X, op_debug_mode:%u.", + ret, op_debug_mode); + REPORT_INNER_ERROR("E19999", "Malloc memory for opdebug failed in model overflow, ret:0x%X, op_debug_mode:%u.", + ret, op_debug_mode); return ret; } uint32_t debug_stream_id = 0; uint32_t debug_task_id = 0; auto rt_ret = rtDebugRegister(model_handle, op_debug_mode, op_debug_addr_, &debug_stream_id, &debug_task_id); if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "rtDebugRegister error, ret: 0x%X", rt_ret); + GELOGE(RT_FAILED, "[Register][rtDebug]Failed in model overflow, ret: 0x%X, op_debug_mode:%u.", + rt_ret, op_debug_mode); + REPORT_INNER_ERROR("E19999", "Register rtDebug failed in model overflow, ret:0x%X, op_debug_mode:%u.", + rt_ret, op_debug_mode); return RT_ERROR_TO_GE_STATUS(rt_ret); } GELOGD("debug_task_id:%u, debug_stream_id:%u in model overflow", debug_task_id, debug_stream_id); @@ -74,7 +80,9 @@ Status OpdebugRegister::RegisterDebugForStream(rtStream_t stream, uint32_t op_de GELOGD("Start to register debug for stream in stream overflow"); auto ret = MallocMemForOpdebug(); if (ret != SUCCESS) { - GELOGE(ret, "Malloc memory for opdebug in stream overflow ,ret:0x%X", ret); + GELOGE(ret, "[Malloc][MemoryForOpdebug]Failed in stream overflow, ret:0x%X, op_debug_mode:%u.", + ret, op_debug_mode); + REPORT_INNER_ERROR("E19999", "Malloc memory for opdebug failed in stream overflow, ret:0x%X, op_debug_mode:%u.", ret, op_debug_mode); return ret; } @@ -83,7 +91,10 @@ Status OpdebugRegister::RegisterDebugForStream(rtStream_t stream, uint32_t op_de #ifdef ONLY_COMPILE_OPEN_SRC auto rt_ret = rtDebugRegisterForStream(stream, op_debug_mode, op_debug_addr_, &debug_stream_id, &debug_task_id); if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "rtDebugRegisterForStream error, ret: 0x%X", rt_ret); + GELOGE(RT_FAILED, "[Register][rtDebug]Failed in stream overflow, ret:0x%X, op_debug_mode:%u.", + rt_ret, op_debug_mode); + REPORT_INNER_ERROR("E19999", "Register rtDebug failed in stream overflow, ret:0x%X, op_debug_mode:%u.", + rt_ret, op_debug_mode); return RT_ERROR_TO_GE_STATUS(rt_ret); } #endif @@ -125,7 +136,7 @@ void OpdebugRegister::UnregisterDebugForStream(rtStream_t stream) { Status OpdebugRegister::MallocMemForOpdebug() { rtError_t rt_ret = rtMalloc(&op_debug_addr_, kOpDebugMemorySize, RT_MEMORY_DDR); if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "rtMalloc error, ret: 0x%X", rt_ret); + GELOGE(RT_FAILED, "[Malloc][OpDebugMem]Failed, ret: 0x%X", rt_ret); return RT_ERROR_TO_GE_STATUS(rt_ret); } @@ -133,16 +144,16 @@ Status OpdebugRegister::MallocMemForOpdebug() { // For data dump, aicpu needs the pointer to pointer that save the real debug address. rt_ret = rtMalloc(&p2p_debug_addr_, kDebugP2pSize, RT_MEMORY_HBM); if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "rtMalloc error, ret: 0x%X", rt_ret); + GELOGE(RT_FAILED, "[Malloc][P2PDebugMem]Failed, ret: 0x%X", rt_ret); return RT_ERROR_TO_GE_STATUS(rt_ret); } rt_ret = rtMemcpy(p2p_debug_addr_, sizeof(uint64_t), &debug_addrs_tmp, sizeof(uint64_t), RT_MEMCPY_HOST_TO_DEVICE); if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "rtMemcpy to p2p_addr error: 0x%X", rt_ret); + GELOGE(RT_FAILED, "[Copy][P2PDebugMem]Failed, ret: 0x%X", rt_ret); return RT_ERROR_TO_GE_STATUS(rt_ret); } return SUCCESS; } -} // namespace ge \ No newline at end of file +} // namespace ge From 5445cd0f865e60fef776c237022026d1eb7a58f7 Mon Sep 17 00:00:00 2001 From: "liyihan2@huawei.com" Date: Sat, 27 Mar 2021 15:17:26 +0800 Subject: [PATCH 13/15] Common log optimize --- ge/analyzer/analyzer.cc | 6 ++--- ge/common/cust_aicpu_kernel_store.cc | 4 ++-- ge/common/dump/dump_manager.cc | 6 ++--- ge/common/dump/dump_op.cc | 33 ++++++++++++------------- ge/common/dump/opdebug_register.cc | 25 ++++++------------- ge/common/fmk_error_codes.cc | 36 ++++++++++++++-------------- ge/common/util.cc | 8 +++---- 7 files changed, 51 insertions(+), 67 deletions(-) diff --git a/ge/analyzer/analyzer.cc b/ge/analyzer/analyzer.cc index 47b5c3ab..528a0265 100755 --- a/ge/analyzer/analyzer.cc +++ b/ge/analyzer/analyzer.cc @@ -155,7 +155,7 @@ std::shared_ptr Analyzer::GetJsonObject(uint64_t session_id, uint64_t std::lock_guard lg(mutex_); auto iter = graph_infos_.find(session_id); if (iter == graph_infos_.end()) { - GELOGE(PARAM_INVALID, "[Check][SessionId]session_id:%lu does not exist! graph_id:%lu.", session_id, graph_id); + GELOGE(PARAM_INVALID, "[Check][SessionId]session_id:%lu does not exist! graph_id:%lu", session_id, graph_id); return nullptr; } else { auto iter1 = (iter->second).find(graph_id); @@ -200,7 +200,7 @@ ge::Status Analyzer::CreateAnalyzerFile() { } ge::Status Analyzer::SaveAnalyzerDataToFile(uint64_t session_id, uint64_t graph_id) { - GELOGD("start to save analyze file!"); + GELOGD("start to save analyze file"); auto graph_info = GetJsonObject(session_id, graph_id); GE_CHECK_NOTNULL(graph_info); @@ -232,7 +232,7 @@ ge::Status Analyzer::SaveAnalyzerDataToFile(uint64_t session_id, uint64_t graph_ } ge::Status Analyzer::DoAnalyze(DataInfo &data_info) { - GELOGD("start to do analyzer process!"); + GELOGD("start to do analyzer process"); auto pnode = data_info.node_ptr; GE_CHECK_NOTNULL(pnode); diff --git a/ge/common/cust_aicpu_kernel_store.cc b/ge/common/cust_aicpu_kernel_store.cc index fda7c040..1055989b 100755 --- a/ge/common/cust_aicpu_kernel_store.cc +++ b/ge/common/cust_aicpu_kernel_store.cc @@ -25,7 +25,7 @@ void CustAICPUKernelStore::AddCustAICPUKernel(const CustAICPUKernelPtr &kernel) } void CustAICPUKernelStore::LoadCustAICPUKernelBinToOpDesc(const std::shared_ptr &op_desc) const { - GELOGD("LoadCustAICPUKernelBinToOpDesc in!"); + GELOGD("LoadCustAICPUKernelBinToOpDesc in."); if (op_desc != nullptr) { auto kernel_bin = FindKernel(op_desc->GetName()); if (kernel_bin != nullptr) { @@ -34,6 +34,6 @@ void CustAICPUKernelStore::LoadCustAICPUKernelBinToOpDesc(const std::shared_ptr< GELOGI("Load cust aicpu kernel:%s, %zu", kernel_bin->GetName().c_str(), kernel_bin->GetBinDataSize()); } } - GELOGD("LoadCustAICPUKernelBinToOpDesc success!"); + GELOGD("LoadCustAICPUKernelBinToOpDesc success."); } } // namespace ge diff --git a/ge/common/dump/dump_manager.cc b/ge/common/dump/dump_manager.cc index 462e5032..3d9df167 100644 --- a/ge/common/dump/dump_manager.cc +++ b/ge/common/dump/dump_manager.cc @@ -56,8 +56,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status DumpManager::SetDumpConf dump_properties.SetDumpOpSwitch(dump_op_switch); if (dump_op_switch == kDumpoff && dump_config.dump_list.empty()) { dump_properties_map_.emplace(kInferSessionId, dump_properties); - GELOGE(PARAM_INVALID, "[Check][DumpList]Failed, dump_op_switch is %s.", dump_op_switch.c_str()); - REPORT_INNER_ERROR("E19999", "Check dump list failed, dump_op_switch is %s.", dump_op_switch.c_str()); + GELOGE(PARAM_INVALID, "Dump list is invalid, dump_op_switch is %s", dump_op_switch.c_str()) return PARAM_INVALID; } @@ -83,8 +82,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status DumpManager::SetDumpConf dump_path = dump_config.dump_path; if (dump_path.empty()) { - GELOGE(PARAM_INVALID, "[Check][DumpPath]Failed, it is empty."); - REPORT_INNER_ERROR("E19999", "Check dump path failed, it is empty."); + GELOGE(PARAM_INVALID, "Dump path is empty"); return PARAM_INVALID; } diff --git a/ge/common/dump/dump_op.cc b/ge/common/dump/dump_op.cc index 1bdbe513..d4119d52 100755 --- a/ge/common/dump/dump_op.cc +++ b/ge/common/dump/dump_op.cc @@ -99,8 +99,7 @@ Status DumpOp::DumpOutput(aicpu::dump::Task &task) { } int64_t output_size = 0; if (TensorUtils::GetTensorSizeInBytes(output_descs.at(i), output_size) != SUCCESS) { - GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "[Get][Param]Get output size failed, output_size:%d.", output_size); - REPORT_INNER_ERROR("E19999", "Get output size failed, output_size:%d.", output_size); + GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "Get output size filed"); return ACL_ERROR_GE_INTERNAL_ERROR; } GELOGD("Get output size in lanch dump op is %ld", output_size); @@ -127,8 +126,7 @@ Status DumpOp::DumpInput(aicpu::dump::Task &task) { } int64_t input_size = 0; if (TensorUtils::GetTensorSizeInBytes(input_descs.at(i), input_size) != SUCCESS) { - GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "[Get][Param]Get input size failed, input_size:%d.", input_size); - REPORT_INNER_ERROR("E19999", "Get input size failed, input_size:%d.", input_size); + GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "Get output size filed"); return ACL_ERROR_GE_INTERNAL_ERROR; } GELOGD("Get input size in lanch dump op is %ld", input_size); @@ -153,31 +151,30 @@ Status DumpOp::ExecutorDumpOp(aicpu::dump::OpMappingInfo &op_mapping_info) { size_t proto_size = op_mapping_info.ByteSizeLong(); bool ret = op_mapping_info.SerializeToString(&proto_msg); if (!ret || proto_size == 0) { - GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "[Serialize][Protobuf]Failed, proto_size:%zu.", proto_size); - REPORT_INNER_ERROR("E19999", "Serialize protobuf failed, proto_size:%zu.", proto_size); + GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "Protobuf serialize failed, proto_size is %zu", proto_size); return ACL_ERROR_GE_INTERNAL_ERROR; } rtError_t rt_ret = rtMalloc(&proto_dev_mem_, proto_size, RT_MEMORY_HBM); if (rt_ret != RT_ERROR_NONE) { - GELOGE(rt_ret, "[Malloc][ProtoDevMem]Failed, ret:0x%X", rt_ret); + GELOGE(rt_ret, "Call rtMalloc failed, ret:0x%X", rt_ret); return RT_ERROR_TO_GE_STATUS(rt_ret); } rt_ret = rtMemcpy(proto_dev_mem_, proto_size, proto_msg.c_str(), proto_size, RT_MEMCPY_HOST_TO_DEVICE); if (rt_ret != RT_ERROR_NONE) { - GELOGE(rt_ret, "[Copy][ProtoDevMem]Failed, ret:0x%X", rt_ret); + GELOGE(rt_ret, "Call rtMemcpy failed, ret:0x%X", rt_ret); return RT_ERROR_TO_GE_STATUS(rt_ret); } rt_ret = rtMalloc(&proto_size_dev_mem_, sizeof(size_t), RT_MEMORY_HBM); if (rt_ret != RT_ERROR_NONE) { - GELOGE(rt_ret, "[Malloc][ProtoSizeDevMem]Failed, ret:0x%X", rt_ret); + GELOGE(rt_ret, "Call rtMalloc failed, ret:0x%X", rt_ret); return RT_ERROR_TO_GE_STATUS(rt_ret); } rt_ret = rtMemcpy(proto_size_dev_mem_, sizeof(size_t), &proto_size, sizeof(size_t), RT_MEMCPY_HOST_TO_DEVICE); if (rt_ret != RT_ERROR_NONE) { - GELOGE(rt_ret, "[Copy][ProtoSizeDevMem]Failed, ret:0x%X", rt_ret); + GELOGE(rt_ret, "Call rtMemcpy failed, ret:0x%X", rt_ret); return RT_ERROR_TO_GE_STATUS(rt_ret); } @@ -196,7 +193,7 @@ Status DumpOp::ExecutorDumpOp(aicpu::dump::OpMappingInfo &op_mapping_info) { nullptr, // no need smDesc stream_); if (rt_ret != RT_ERROR_NONE) { - GELOGE(rt_ret, "[Call][rtCpuKernelLaunch]Failed, rt_ret:0x%X", rt_ret); + GELOGE(rt_ret, "Call rtCpuKernelLaunch failed,rt_ret:0x%X", rt_ret); return RT_ERROR_TO_GE_STATUS(rt_ret); } GELOGI("Kernel launch dump op success"); @@ -208,12 +205,12 @@ Status DumpOp::LaunchDumpOp() { int32_t device_id = 0; rtError_t rt_ret = rtGetDevice(&device_id); if (rt_ret != RT_ERROR_NONE) { - GELOGE(rt_ret, "[Call][rtGetDevice]Failed, ret:0x%X, device_id:%d.", rt_ret, device_id); + GELOGE(rt_ret, "Call rtGetDevice failed, ret = 0x%X, device_id = %d.", rt_ret, device_id); return RT_ERROR_TO_GE_STATUS(rt_ret); } if (device_id < 0) { GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, - "[Check][DeviceId]Failed, device_id:%d, which should be not less than 0.", + "Check device_id failed, device_id = %d, which should be not less than 0.", device_id); return ACL_ERROR_GE_INTERNAL_ERROR; } @@ -243,7 +240,7 @@ Status DumpOp::LaunchDumpOp() { if (dump_properties_.GetDumpMode() == kDumpOutput) { auto ret = DumpOutput(task); if (ret != SUCCESS) { - GELOGE(ret, "[Dump][Output]Failed, error_code:%u.", ret); + GELOGE(ret, "Dump output failed"); return ret; } op_mapping_info.mutable_task()->Add(std::move(task)); @@ -251,7 +248,7 @@ Status DumpOp::LaunchDumpOp() { if (dump_properties_.GetDumpMode() == kDumpInput) { auto ret = DumpInput(task); if (ret != SUCCESS) { - GELOGE(ret, "[Dump][Input]Failed, error_code:%u.", ret); + GELOGE(ret, "Dump input failed"); return ret; } op_mapping_info.mutable_task()->Add(std::move(task)); @@ -259,19 +256,19 @@ Status DumpOp::LaunchDumpOp() { if (dump_properties_.GetDumpMode() == kDumpAll || dump_properties_.IsOpDebugOpen()) { auto ret = DumpOutput(task); if (ret != SUCCESS) { - GELOGE(ret, "[Dump][Output]Failed when in dumping all, error_code:%u.", ret); + GELOGE(ret, "Dump output failed when in dumping all"); return ret; } ret = DumpInput(task); if (ret != SUCCESS) { - GELOGE(ret, "[Dump][Input]Failed when in dumping all, error_code:%u.", ret); + GELOGE(ret, "Dump input failed when in dumping all"); return ret; } op_mapping_info.mutable_task()->Add(std::move(task)); } auto ret = ExecutorDumpOp(op_mapping_info); if (ret != SUCCESS) { - GELOGE(ret, "[Dump][Op]Failed, error_code:%u.", ret); + GELOGE(ret, "Executor dump op failed"); return ret; } return SUCCESS; diff --git a/ge/common/dump/opdebug_register.cc b/ge/common/dump/opdebug_register.cc index a29f59de..a439ef54 100644 --- a/ge/common/dump/opdebug_register.cc +++ b/ge/common/dump/opdebug_register.cc @@ -27,20 +27,14 @@ Status OpdebugRegister::RegisterDebugForModel(rtModel_t model_handle, uint32_t o GELOGD("Start to register debug for model in overflow"); auto ret = MallocMemForOpdebug(); if (ret != SUCCESS) { - GELOGE(ret, "[Malloc][MemoryForOpdebug]Failed in model overflow, ret:0x%X, op_debug_mode:%u.", - ret, op_debug_mode); - REPORT_INNER_ERROR("E19999", "Malloc memory for opdebug failed in model overflow, ret:0x%X, op_debug_mode:%u.", - ret, op_debug_mode); + GELOGE(ret, "Malloc memory for opdebug in model overflow failed, ret:0x%X", ret); return ret; } uint32_t debug_stream_id = 0; uint32_t debug_task_id = 0; auto rt_ret = rtDebugRegister(model_handle, op_debug_mode, op_debug_addr_, &debug_stream_id, &debug_task_id); if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "[Register][rtDebug]Failed in model overflow, ret: 0x%X, op_debug_mode:%u.", - rt_ret, op_debug_mode); - REPORT_INNER_ERROR("E19999", "Register rtDebug failed in model overflow, ret:0x%X, op_debug_mode:%u.", - rt_ret, op_debug_mode); + GELOGE(RT_FAILED, "rtDebugRegister error, ret: 0x%X", rt_ret); return RT_ERROR_TO_GE_STATUS(rt_ret); } GELOGD("debug_task_id:%u, debug_stream_id:%u in model overflow", debug_task_id, debug_stream_id); @@ -80,9 +74,7 @@ Status OpdebugRegister::RegisterDebugForStream(rtStream_t stream, uint32_t op_de GELOGD("Start to register debug for stream in stream overflow"); auto ret = MallocMemForOpdebug(); if (ret != SUCCESS) { - GELOGE(ret, "[Malloc][MemoryForOpdebug]Failed in stream overflow, ret:0x%X, op_debug_mode:%u.", - ret, op_debug_mode); - REPORT_INNER_ERROR("E19999", "Malloc memory for opdebug failed in stream overflow, ret:0x%X, op_debug_mode:%u.", ret, op_debug_mode); + GELOGE(ret, "Malloc memory for opdebug in stream overflow, ret:0x%X", ret); return ret; } @@ -90,10 +82,7 @@ Status OpdebugRegister::RegisterDebugForStream(rtStream_t stream, uint32_t op_de uint32_t debug_task_id = 0; auto rt_ret = rtDebugRegisterForStream(stream, op_debug_mode, op_debug_addr_, &debug_stream_id, &debug_task_id); if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "[Register][rtDebug]Failed in stream overflow, ret:0x%X, op_debug_mode:%u.", - rt_ret, op_debug_mode); - REPORT_INNER_ERROR("E19999", "Register rtDebug failed in stream overflow, ret:0x%X, op_debug_mode:%u.", - rt_ret, op_debug_mode); + GELOGE(RT_FAILED, "rtDebugRegisterForStream error, ret:0x%X", rt_ret); return RT_ERROR_TO_GE_STATUS(rt_ret); } GELOGD("debug_task_id:%u, debug_stream_id:%u in stream overflow.", debug_task_id, debug_stream_id); @@ -132,7 +121,7 @@ void OpdebugRegister::UnregisterDebugForStream(rtStream_t stream) { Status OpdebugRegister::MallocMemForOpdebug() { rtError_t rt_ret = rtMalloc(&op_debug_addr_, kOpDebugMemorySize, RT_MEMORY_DDR); if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "[Malloc][OpDebugMem]Failed, ret: 0x%X", rt_ret); + GELOGE(RT_FAILED, "rtMalloc error, ret: 0x%X", rt_ret); return RT_ERROR_TO_GE_STATUS(rt_ret); } @@ -140,12 +129,12 @@ Status OpdebugRegister::MallocMemForOpdebug() { // For data dump, aicpu needs the pointer to pointer that save the real debug address. rt_ret = rtMalloc(&p2p_debug_addr_, kDebugP2pSize, RT_MEMORY_HBM); if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "[Malloc][P2PDebugMem]Failed, ret: 0x%X", rt_ret); + GELOGE(RT_FAILED, "rtMalloc error, ret: 0x%X", rt_ret); return RT_ERROR_TO_GE_STATUS(rt_ret); } rt_ret = rtMemcpy(p2p_debug_addr_, sizeof(uint64_t), &debug_addrs_tmp, sizeof(uint64_t), RT_MEMCPY_HOST_TO_DEVICE); if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "[Copy][P2PDebugMem]Failed, ret: 0x%X", rt_ret); + GELOGE(RT_FAILED, "rtMemcpy to p2p_addr, ret: 0x%X", rt_ret); return RT_ERROR_TO_GE_STATUS(rt_ret); } diff --git a/ge/common/fmk_error_codes.cc b/ge/common/fmk_error_codes.cc index a1798b80..ddb8089d 100755 --- a/ge/common/fmk_error_codes.cc +++ b/ge/common/fmk_error_codes.cc @@ -37,28 +37,28 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY std::string StatusFactory::GetE return iter_find->second; } // General error code -DEF_ERRORNO(SUCCESS, "Success."); -DEF_ERRORNO(FAILED, "Failed."); +DEF_ERRORNO(SUCCESS, "Success"); +DEF_ERRORNO(FAILED, "Failed"); // Common errocode -DEF_ERRORNO(MEMALLOC_FAILED, "Failed to allocate memory."); // 50331648 -DEF_ERRORNO(PARAM_INVALID, "Parameter's invalid."); // 50331649 -DEF_ERRORNO(CCE_FAILED, "Failed to call CCE API."); // 50331650 -DEF_ERRORNO(RT_FAILED, "Failed to call runtime API."); // 50331651 -DEF_ERRORNO(INTERNAL_ERROR, "Internal errors."); // 50331652 -DEF_ERRORNO(CSEC_ERROR, "Failed to call libc_sec API."); // 50331653 -DEF_ERRORNO(TEE_ERROR, "Failed to call tee API."); // 50331653 -DEF_ERRORNO(UNSUPPORTED, "Parameter's unsupported."); -DEF_ERRORNO(OUT_OF_MEMORY, "Out of memory."); +DEF_ERRORNO(MEMALLOC_FAILED, "Failed to allocate memory!"); // 50331648 +DEF_ERRORNO(PARAM_INVALID, "Parameter's invalid!"); // 50331649 +DEF_ERRORNO(CCE_FAILED, "Failed to call CCE API!"); // 50331650 +DEF_ERRORNO(RT_FAILED, "Failed to call runtime API!"); // 50331651 +DEF_ERRORNO(INTERNAL_ERROR, "Internal errors"); // 50331652 +DEF_ERRORNO(CSEC_ERROR, "Failed to call libc_sec API!"); // 50331653 +DEF_ERRORNO(TEE_ERROR, "Failed to call tee API!"); // 50331653 +DEF_ERRORNO(UNSUPPORTED, "Parameter's unsupported!"); +DEF_ERRORNO(OUT_OF_MEMORY, "Out of memory!"); // errorcode -DEF_ERRORNO(PARSE_MODEL_FAILED, "Failed to parse the model."); -DEF_ERRORNO(PARSE_WEIGHTS_FAILED, "Failed to parse the weights."); -DEF_ERRORNO(NOT_INITIALIZED, "It hasn't been initialized."); -DEF_ERRORNO(TIMEOUT, "Running time out."); +DEF_ERRORNO(PARSE_MODEL_FAILED, "Failed to parse the model!"); +DEF_ERRORNO(PARSE_WEIGHTS_FAILED, "Failed to parse the weights!"); +DEF_ERRORNO(NOT_INITIALIZED, "It hasn't been initialized!"); +DEF_ERRORNO(TIMEOUT, "Running time out!"); // errorcode -DEF_ERRORNO(MODEL_NOT_READY, "The model is not ready yet."); -DEF_ERRORNO(PUSH_DATA_FAILED, "Failed to push data."); -DEF_ERRORNO(DATA_QUEUE_ISFULL, "Data queue is full."); +DEF_ERRORNO(MODEL_NOT_READY, "The model is not ready yet!"); +DEF_ERRORNO(PUSH_DATA_FAILED, "Failed to push data!"); +DEF_ERRORNO(DATA_QUEUE_ISFULL, "Data queue is full!"); } // namespace domi diff --git a/ge/common/util.cc b/ge/common/util.cc index 836f4664..0a343a83 100644 --- a/ge/common/util.cc +++ b/ge/common/util.cc @@ -113,11 +113,11 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadProtoFromArray(const v // Get file length long GetFileLength(const std::string &input_file) { - GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(input_file.empty(), return -1, "input_file path is null"); + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(input_file.empty(), return -1, "input_file path is null."); std::string real_path = RealPath(input_file.c_str()); - GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(real_path.empty(), return -1, "input_file path '%s' not valid.", input_file.c_str()); + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(real_path.empty(), return -1, "input_file path '%s' not valid", input_file.c_str()); unsigned long long file_length = 0; GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( mmGetFileSize(input_file.c_str(), &file_length) != EN_OK, @@ -318,7 +318,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY uint64_t GetCurrentTimestamp() FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY uint32_t GetCurrentSecondTimestap() { mmTimeval tv{}; int ret = mmGetTimeOfDay(&tv, nullptr); - GE_LOGE_IF(ret != EN_OK, "Func gettimeofday may failed: ret=%d.", ret); + GE_LOGE_IF(ret != EN_OK, "Func gettimeofday may failed: ret=%d", ret); auto total_use_time = tv.tv_sec; // seconds return static_cast(total_use_time); } @@ -349,7 +349,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckInt64MulOverflow(int6 } FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY std::string RealPath(const char *path) { - GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(path == nullptr, return "", "path pointer is NULL"); + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(path == nullptr, return "", "path pointer is NULL."); GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(strlen(path) >= MMPA_MAX_PATH, ErrorManager::GetInstance().ATCReportErrMessage("E19002", {"filepath", "size"}, {path, std::to_string(MMPA_MAX_PATH)}); From bc3879718e948320e1eaced8bfc13275fdf0135d Mon Sep 17 00:00:00 2001 From: "liyihan2@huawei.com" Date: Sat, 27 Mar 2021 15:21:05 +0800 Subject: [PATCH 14/15] Common log optimize --- ge/common/dump/dump_manager.cc | 2 +- ge/common/dump/dump_op.cc | 8 ++++---- ge/common/dump/opdebug_register.cc | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ge/common/dump/dump_manager.cc b/ge/common/dump/dump_manager.cc index 3d9df167..879e898f 100644 --- a/ge/common/dump/dump_manager.cc +++ b/ge/common/dump/dump_manager.cc @@ -56,7 +56,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status DumpManager::SetDumpConf dump_properties.SetDumpOpSwitch(dump_op_switch); if (dump_op_switch == kDumpoff && dump_config.dump_list.empty()) { dump_properties_map_.emplace(kInferSessionId, dump_properties); - GELOGE(PARAM_INVALID, "Dump list is invalid, dump_op_switch is %s", dump_op_switch.c_str()) + GELOGE(PARAM_INVALID, "Dump list is invalid,dump_op_switch is %s", dump_op_switch.c_str()) return PARAM_INVALID; } diff --git a/ge/common/dump/dump_op.cc b/ge/common/dump/dump_op.cc index d4119d52..0becbdc8 100755 --- a/ge/common/dump/dump_op.cc +++ b/ge/common/dump/dump_op.cc @@ -157,24 +157,24 @@ Status DumpOp::ExecutorDumpOp(aicpu::dump::OpMappingInfo &op_mapping_info) { rtError_t rt_ret = rtMalloc(&proto_dev_mem_, proto_size, RT_MEMORY_HBM); if (rt_ret != RT_ERROR_NONE) { - GELOGE(rt_ret, "Call rtMalloc failed, ret:0x%X", rt_ret); + GELOGE(rt_ret, "Call rtMalloc failed, ret: 0x%X", rt_ret); return RT_ERROR_TO_GE_STATUS(rt_ret); } rt_ret = rtMemcpy(proto_dev_mem_, proto_size, proto_msg.c_str(), proto_size, RT_MEMCPY_HOST_TO_DEVICE); if (rt_ret != RT_ERROR_NONE) { - GELOGE(rt_ret, "Call rtMemcpy failed, ret:0x%X", rt_ret); + GELOGE(rt_ret, "Call rtMemcpy failed, ret: 0x%X", rt_ret); return RT_ERROR_TO_GE_STATUS(rt_ret); } rt_ret = rtMalloc(&proto_size_dev_mem_, sizeof(size_t), RT_MEMORY_HBM); if (rt_ret != RT_ERROR_NONE) { - GELOGE(rt_ret, "Call rtMalloc failed, ret:0x%X", rt_ret); + GELOGE(rt_ret, "Call rtMalloc failed, ret: 0x%X", rt_ret); return RT_ERROR_TO_GE_STATUS(rt_ret); } rt_ret = rtMemcpy(proto_size_dev_mem_, sizeof(size_t), &proto_size, sizeof(size_t), RT_MEMCPY_HOST_TO_DEVICE); if (rt_ret != RT_ERROR_NONE) { - GELOGE(rt_ret, "Call rtMemcpy failed, ret:0x%X", rt_ret); + GELOGE(rt_ret, "Call rtMemcpy failed, ret: 0x%X", rt_ret); return RT_ERROR_TO_GE_STATUS(rt_ret); } diff --git a/ge/common/dump/opdebug_register.cc b/ge/common/dump/opdebug_register.cc index a439ef54..aae80cb0 100644 --- a/ge/common/dump/opdebug_register.cc +++ b/ge/common/dump/opdebug_register.cc @@ -27,7 +27,7 @@ Status OpdebugRegister::RegisterDebugForModel(rtModel_t model_handle, uint32_t o GELOGD("Start to register debug for model in overflow"); auto ret = MallocMemForOpdebug(); if (ret != SUCCESS) { - GELOGE(ret, "Malloc memory for opdebug in model overflow failed, ret:0x%X", ret); + GELOGE(ret, "Malloc memory for opdebug in model overflow failed ,ret:0x%X", ret); return ret; } uint32_t debug_stream_id = 0; @@ -74,7 +74,7 @@ Status OpdebugRegister::RegisterDebugForStream(rtStream_t stream, uint32_t op_de GELOGD("Start to register debug for stream in stream overflow"); auto ret = MallocMemForOpdebug(); if (ret != SUCCESS) { - GELOGE(ret, "Malloc memory for opdebug in stream overflow, ret:0x%X", ret); + GELOGE(ret, "Malloc memory for opdebug in stream overflow ,ret:0x%X", ret); return ret; } @@ -82,7 +82,7 @@ Status OpdebugRegister::RegisterDebugForStream(rtStream_t stream, uint32_t op_de uint32_t debug_task_id = 0; auto rt_ret = rtDebugRegisterForStream(stream, op_debug_mode, op_debug_addr_, &debug_stream_id, &debug_task_id); if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "rtDebugRegisterForStream error, ret:0x%X", rt_ret); + GELOGE(RT_FAILED, "rtDebugRegisterForStream error, ret: 0x%X", rt_ret); return RT_ERROR_TO_GE_STATUS(rt_ret); } GELOGD("debug_task_id:%u, debug_stream_id:%u in stream overflow.", debug_task_id, debug_stream_id); @@ -134,7 +134,7 @@ Status OpdebugRegister::MallocMemForOpdebug() { } rt_ret = rtMemcpy(p2p_debug_addr_, sizeof(uint64_t), &debug_addrs_tmp, sizeof(uint64_t), RT_MEMCPY_HOST_TO_DEVICE); if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "rtMemcpy to p2p_addr, ret: 0x%X", rt_ret); + GELOGE(RT_FAILED, "rtMemcpy to p2p_addr error: 0x%X", rt_ret); return RT_ERROR_TO_GE_STATUS(rt_ret); } From a74de10c0247922b00d6792e097b2d5b2b5b5daf Mon Sep 17 00:00:00 2001 From: "liyihan2@huawei.com" Date: Sat, 27 Mar 2021 16:02:43 +0800 Subject: [PATCH 15/15] Common log optimize --- ge/common/dump/dump_manager.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ge/common/dump/dump_manager.cc b/ge/common/dump/dump_manager.cc index 879e898f..a659d9c6 100644 --- a/ge/common/dump/dump_manager.cc +++ b/ge/common/dump/dump_manager.cc @@ -56,7 +56,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status DumpManager::SetDumpConf dump_properties.SetDumpOpSwitch(dump_op_switch); if (dump_op_switch == kDumpoff && dump_config.dump_list.empty()) { dump_properties_map_.emplace(kInferSessionId, dump_properties); - GELOGE(PARAM_INVALID, "Dump list is invalid,dump_op_switch is %s", dump_op_switch.c_str()) + GELOGE(PARAM_INVALID, "Dump list is invalid,dump_op_switch is %s", dump_op_switch.c_str()); return PARAM_INVALID; }