From 82c8dedfeafc9a94cc809895a453ad6d41a5daee Mon Sep 17 00:00:00 2001 From: zhengyuanhua Date: Thu, 22 Apr 2021 15:31:12 +0800 Subject: [PATCH] profiling report data add lock --- ge/common/profiling/profiling_manager.cc | 3 ++- ge/common/profiling/profiling_manager.h | 1 + ge/ir_build/option_utils.cc | 8 +++----- inc/external/ge/ge_api_types.h | 1 + tests/ut/ge/graph_ir/ge_ir_build_unittest.cc | 16 +++++++++++++++- .../profiling/ge_profiling_manager_unittest.cc | 6 ++++++ 6 files changed, 28 insertions(+), 7 deletions(-) diff --git a/ge/common/profiling/profiling_manager.cc b/ge/common/profiling/profiling_manager.cc index fbbf1f04..443f5213 100644 --- a/ge/common/profiling/profiling_manager.cc +++ b/ge/common/profiling/profiling_manager.cc @@ -355,6 +355,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::ReportDa reporter_data.deviceId = device_id; ret = memcpy_s(reporter_data.tag, MSPROF_ENGINE_MAX_TAG_LEN + 1, tag_name.c_str(), tag_name.size()); GE_IF_BOOL_EXEC(ret != EOK, GELOGE(ret, "Report data tag [%s] memcpy error!", tag_name.c_str()); return;); + std::lock_guard lock(mutex_report_); for (size_t i = 0; i < index; ++i) { reporter_data.data = (unsigned char *)data.c_str() + report_max_len * i; reporter_data.dataLen = report_max_len; @@ -375,7 +376,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::ReportDa reporter_data.dataLen = data.size(); ret = memcpy_s(reporter_data.tag, MSPROF_ENGINE_MAX_TAG_LEN + 1, tag_name.c_str(), tag_name.size()); GE_IF_BOOL_EXEC(ret != EOK, GELOGE(ret, "Report data tag [%s] memcpy error!", tag_name.c_str()); return;); - + std::lock_guard lock(mutex_report_); cb_ret = CallMsprofReport(reporter_data); GE_IF_BOOL_EXEC(cb_ret != 0, GELOGE(cb_ret, "Reporter data [%s] failed, ret:%d", tag_name.c_str(), cb_ret); return;); diff --git a/ge/common/profiling/profiling_manager.h b/ge/common/profiling/profiling_manager.h index ab344204..af9fce06 100755 --- a/ge/common/profiling/profiling_manager.h +++ b/ge/common/profiling/profiling_manager.h @@ -118,6 +118,7 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ProfilingManager { map subs_dev_module_; // key: device_id, value: profiling on module uint32_t subscribe_count_; std::mutex mutex_; + std::mutex mutex_report_; MsprofCallback prof_cb_; std::string fp_point_; std::string bp_point_; diff --git a/ge/ir_build/option_utils.cc b/ge/ir_build/option_utils.cc index c7b9b11f..94706233 100755 --- a/ge/ir_build/option_utils.cc +++ b/ge/ir_build/option_utils.cc @@ -523,11 +523,9 @@ Status CheckDynamicInputParamValid(string &dynamic_batch_size, string &dynamic_i } if (!dynamic_batch_size.empty()) { - if (input_shape_range.find(":") != string::npos) { - if (!CheckDynamicBatchSizeInputShapeValid(shape_map, dynamic_batch_size)) { - GELOGE(ge::PARAM_INVALID, "[Check][DynamicBatchSizeInputShape] input_shape: %s invalid.", input_shape.c_str()); - return ge::PARAM_INVALID; - } + if (!CheckDynamicBatchSizeInputShapeValid(shape_map, dynamic_batch_size)) { + GELOGE(ge::PARAM_INVALID, "[Check][DynamicBatchSizeInputShape] input_shape: %s invalid.", input_shape.c_str()); + return ge::PARAM_INVALID; } } diff --git a/inc/external/ge/ge_api_types.h b/inc/external/ge/ge_api_types.h index 5ae5f036..ed843bb0 100644 --- a/inc/external/ge/ge_api_types.h +++ b/inc/external/ge/ge_api_types.h @@ -359,6 +359,7 @@ using RunAsyncCallback = std::function