Merge pull request !73 from taoxiangdong/mastertags/v1.1.0
@@ -20,7 +20,7 @@ add_compile_definitions(_GLIBCXX_USE_CXX11_ABI=0) | |||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) | ||||
set(GE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}) | set(GE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}) | ||||
set(GE_PROTO_DIR ${GE_SOURCE_DIR}/src) | |||||
set(GE_PROTO_DIR ${GE_SOURCE_DIR}/) | |||||
if (NOT BUILD_PATH) | if (NOT BUILD_PATH) | ||||
set(BUILD_PATH "${CMAKE_SOURCE_DIR}/build") | set(BUILD_PATH "${CMAKE_SOURCE_DIR}/build") | ||||
@@ -112,19 +112,19 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__FILE__='\"$(subst $(realpath ${CMAKE | |||||
# compile libraries from following directories | # compile libraries from following directories | ||||
# libgraph is compiled in any situation | # libgraph is compiled in any situation | ||||
add_subdirectory(${GE_SOURCE_DIR}/src/common/graph) | |||||
add_subdirectory(${GE_SOURCE_DIR}/metadef/graph) | |||||
if(ENABLE_D) | if(ENABLE_D) | ||||
# if MindSpore compiles in D mode, compile the following libraries | # if MindSpore compiles in D mode, compile the following libraries | ||||
add_subdirectory(${GE_SOURCE_DIR}/src/ge/common) | |||||
add_subdirectory(${GE_SOURCE_DIR}/src/ge/ge_runtime) | |||||
add_subdirectory(${GE_SOURCE_DIR}/ge/common) | |||||
add_subdirectory(${GE_SOURCE_DIR}/ge/ge_runtime) | |||||
elseif(GE_ONLY) | elseif(GE_ONLY) | ||||
# standalone GraphEngine compiles all following libraries | # standalone GraphEngine compiles all following libraries | ||||
add_subdirectory(${GE_SOURCE_DIR}/src/ge/common) | |||||
add_subdirectory(${GE_SOURCE_DIR}/src/ge/ge_runtime) | |||||
add_subdirectory(${GE_SOURCE_DIR}/src/ge/ge_local_engine) | |||||
add_subdirectory(${GE_SOURCE_DIR}/src/ge/graph/build/memory) | |||||
add_subdirectory(${GE_SOURCE_DIR}/src/ge/) | |||||
add_subdirectory(${GE_SOURCE_DIR}/src/ge/plugin/engine) | |||||
add_subdirectory(${GE_SOURCE_DIR}/ge/common) | |||||
add_subdirectory(${GE_SOURCE_DIR}/ge/ge_runtime) | |||||
add_subdirectory(${GE_SOURCE_DIR}/ge/ge_local_engine) | |||||
add_subdirectory(${GE_SOURCE_DIR}/ge/graph/build/memory) | |||||
add_subdirectory(${GE_SOURCE_DIR}/ge/) | |||||
add_subdirectory(${GE_SOURCE_DIR}/ge/plugin/engine) | |||||
endif() | endif() | ||||
# if (ENABLE_GE_COV OR ENABLE_GE_UT OR ENABLE_GE_ST) | # if (ENABLE_GE_COV OR ENABLE_GE_UT OR ENABLE_GE_ST) | ||||
@@ -191,8 +191,8 @@ generate_package() | |||||
mk_dir "${OUTPUT_PATH}/${ATC_PATH}/${OPSKERNEL_PATH}" | mk_dir "${OUTPUT_PATH}/${ATC_PATH}/${OPSKERNEL_PATH}" | ||||
find output/ -name graphengine_lib.tar -exec rm {} \; | find output/ -name graphengine_lib.tar -exec rm {} \; | ||||
cp src/ge/engine_manager/engine_conf.json ${OUTPUT_PATH}/${FWK_PATH}/${NNENGINE_PATH} | |||||
cp src/ge/engine_manager/engine_conf.json ${OUTPUT_PATH}/${ATC_PATH}/${NNENGINE_PATH} | |||||
cp ge/engine_manager/engine_conf.json ${OUTPUT_PATH}/${FWK_PATH}/${NNENGINE_PATH} | |||||
cp ge/engine_manager/engine_conf.json ${OUTPUT_PATH}/${ATC_PATH}/${NNENGINE_PATH} | |||||
find output/ -maxdepth 1 -name libengine.so -exec cp -f {} ${OUTPUT_PATH}/${FWK_PATH}/${NNENGINE_PATH}/../ \; | find output/ -maxdepth 1 -name libengine.so -exec cp -f {} ${OUTPUT_PATH}/${FWK_PATH}/${NNENGINE_PATH}/../ \; | ||||
find output/ -maxdepth 1 -name libengine.so -exec cp -f {} ${OUTPUT_PATH}/${ATC_PATH}/${NNENGINE_PATH}/../ \; | find output/ -maxdepth 1 -name libengine.so -exec cp -f {} ${OUTPUT_PATH}/${ATC_PATH}/${NNENGINE_PATH}/../ \; | ||||
@@ -18,20 +18,20 @@ | |||||
# compiling proto files generates some warnings, use no-unused-variable to suppress them | # compiling proto files generates some warnings, use no-unused-variable to suppress them | ||||
set(CMAKE_CXX_FLAGS "-Wno-unused-variable ${CMAKE_CXX_FLAGS}") | set(CMAKE_CXX_FLAGS "-Wno-unused-variable ${CMAKE_CXX_FLAGS}") | ||||
file(GLOB PROTO_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} | file(GLOB PROTO_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} | ||||
"../proto/fusion_model.proto" | |||||
"../proto/optimizer_priority.proto" | |||||
"${GE_SOURCE_DIR}/metadef/proto/fusion_model.proto" | |||||
"${GE_SOURCE_DIR}/metadef/proto/optimizer_priority.proto" | |||||
) | ) | ||||
file(GLOB PROTO_CLIENT_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} | file(GLOB PROTO_CLIENT_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} | ||||
"../proto/ge_api.proto" | |||||
"${GE_SOURCE_DIR}/metadef/proto/ge_api.proto" | |||||
) | ) | ||||
file(GLOB PROTO_HEADER_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} | file(GLOB PROTO_HEADER_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} | ||||
"../proto/om.proto" | |||||
"../proto/task.proto" | |||||
"../proto/insert_op.proto" | |||||
"../proto/ge_ir.proto" | |||||
"../proto/fwk_adapter.proto" | |||||
"../proto/op_mapping_info.proto" | |||||
"../proto/dump_task.proto" | |||||
"${GE_SOURCE_DIR}/metadef/proto/om.proto" | |||||
"${GE_SOURCE_DIR}/metadef/proto/task.proto" | |||||
"${GE_SOURCE_DIR}/metadef/proto/insert_op.proto" | |||||
"${GE_SOURCE_DIR}/metadef/proto/ge_ir.proto" | |||||
"${GE_SOURCE_DIR}/metadef/proto/fwk_adapter.proto" | |||||
"${GE_SOURCE_DIR}/metadef/proto/op_mapping_info.proto" | |||||
"${GE_SOURCE_DIR}/metadef/proto/dump_task.proto" | |||||
) | ) | ||||
ge_protobuf_generate(ge PROTO_SRCS PROTO_HDRS ${PROTO_LIST}) | ge_protobuf_generate(ge PROTO_SRCS PROTO_HDRS ${PROTO_LIST}) | ||||
ge_protobuf_generate(ge PROTO_CLIENT_SRCS PROTO_CLIENT_HDRS ${PROTO_CLIENT_LIST}) | ge_protobuf_generate(ge PROTO_CLIENT_SRCS PROTO_CLIENT_HDRS ${PROTO_CLIENT_LIST}) | ||||
@@ -39,15 +39,20 @@ ge_protobuf_generate(ge PROTO_HEADER_SRCS PROTO_HEADER_HDRS ${PROTO_HEADER_LIST} | |||||
# include directories | # include directories | ||||
include_directories(${CMAKE_CURRENT_LIST_DIR}) | include_directories(${CMAKE_CURRENT_LIST_DIR}) | ||||
include_directories(${GE_SOURCE_DIR}) | include_directories(${GE_SOURCE_DIR}) | ||||
include_directories(${GE_SOURCE_DIR}/src) | |||||
include_directories(${GE_SOURCE_DIR}/src/ge/analyzer) | |||||
include_directories(${GE_SOURCE_DIR}/ge) | |||||
include_directories(${GE_SOURCE_DIR}/ge/analyzer) | |||||
include_directories(${GE_SOURCE_DIR}/inc) | include_directories(${GE_SOURCE_DIR}/inc) | ||||
include_directories(${GE_SOURCE_DIR}/inc/common/util) | include_directories(${GE_SOURCE_DIR}/inc/common/util) | ||||
include_directories(${GE_SOURCE_DIR}/inc) | |||||
include_directories(${GE_SOURCE_DIR}/inc/external) | include_directories(${GE_SOURCE_DIR}/inc/external) | ||||
include_directories(${GE_SOURCE_DIR}/inc/external/graph) | |||||
include_directories(${GE_SOURCE_DIR}/inc/external/ge) | |||||
include_directories(${GE_SOURCE_DIR}/inc/framework) | include_directories(${GE_SOURCE_DIR}/inc/framework) | ||||
include_directories(${GE_SOURCE_DIR}/inc/framework/common) | include_directories(${GE_SOURCE_DIR}/inc/framework/common) | ||||
include_directories(${GE_SOURCE_DIR}/inc/graph) | |||||
include_directories(${GE_SOURCE_DIR}/metadef) | |||||
include_directories(${GE_SOURCE_DIR}/metadef/inc) | |||||
include_directories(${GE_SOURCE_DIR}/metadef/inc/external) | |||||
include_directories(${GE_SOURCE_DIR}/metadef/inc/external/graph) | |||||
include_directories(${GE_SOURCE_DIR}/metadef/inc/graph) | |||||
include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib) | include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib) | ||||
include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc) | include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc) | ||||
include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc/cce) | include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc/cce) | ||||
@@ -58,6 +63,7 @@ include_directories(${CMAKE_BINARY_DIR}/proto/ge) | |||||
# need to remove dependencies on pb files later | # need to remove dependencies on pb files later | ||||
file(GLOB TRAIN_SRC_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} | file(GLOB TRAIN_SRC_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} | ||||
"analyzer/analyzer.cc" | "analyzer/analyzer.cc" | ||||
"client/ge_prof.cc" | |||||
"client/ge_api.cc" | "client/ge_api.cc" | ||||
"common/dump/dump_manager.cc" | "common/dump/dump_manager.cc" | ||||
"common/dump/dump_properties.cc" | "common/dump/dump_properties.cc" | ||||
@@ -225,6 +231,7 @@ target_link_libraries(ge_runner | |||||
${msprof} | ${msprof} | ||||
${runtime} | ${runtime} | ||||
${resouce} | ${resouce} | ||||
${ascend_hal} | |||||
rt | rt | ||||
dl) | dl) | ||||
@@ -335,6 +342,7 @@ file(GLOB INFER_SRC_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} | |||||
"host_kernels/unpack_kernel.cc" | "host_kernels/unpack_kernel.cc" | ||||
"host_kernels/unsqueeze_kernel.cc" | "host_kernels/unsqueeze_kernel.cc" | ||||
"hybrid/hybrid_davinci_model_stub.cc" | "hybrid/hybrid_davinci_model_stub.cc" | ||||
"hybrid/node_executor/aicpu/aicpu_ext_info.cc" | |||||
"init/gelib.cc" | "init/gelib.cc" | ||||
"ir_build/atc_ir_common.cc" | "ir_build/atc_ir_common.cc" | ||||
"ir_build/ge_ir_build.cc" | "ir_build/ge_ir_build.cc" |
@@ -101,7 +101,7 @@ Status Analyzer::BuildJsonObject(uint64_t session_id, uint64_t graph_id) { | |||||
ge::Status Analyzer::Initialize() { | ge::Status Analyzer::Initialize() { | ||||
ClearHistoryFile(); | ClearHistoryFile(); | ||||
return CreateAnalyzerFile(); | |||||
return SUCCESS; | |||||
} | } | ||||
void Analyzer::Finalize() { | void Analyzer::Finalize() { | ||||
@@ -136,7 +136,7 @@ void Analyzer::DestroyGraphJsonObject(uint64_t session_id, uint64_t graph_id) { | |||||
} else { | } else { | ||||
auto iter1 = (iter->second).find(graph_id); | auto iter1 = (iter->second).find(graph_id); | ||||
if (iter1 == (iter->second).end()) { | if (iter1 == (iter->second).end()) { | ||||
GELOGW("can not find the graph json object by session_id[%lu] and graph_id[%lu].Do nothing", session_id, | |||||
GELOGW("Can not find the graph json object by session_id[%lu] and graph_id[%lu]. Do nothing.", session_id, | |||||
graph_id); | graph_id); | ||||
} | } | ||||
(iter->second).erase(iter1); | (iter->second).erase(iter1); | ||||
@@ -169,6 +169,10 @@ void Analyzer::ClearHistoryFile() { | |||||
} | } | ||||
ge::Status Analyzer::CreateAnalyzerFile() { | ge::Status Analyzer::CreateAnalyzerFile() { | ||||
if (is_json_file_create_) { | |||||
GELOGD("analyzer file has been created!No necessary to create again!"); | |||||
return SUCCESS; | |||||
} | |||||
GELOGD("start to create analyzer file!"); | GELOGD("start to create analyzer file!"); | ||||
// Check whether the manifest exists, if not, create it. | // Check whether the manifest exists, if not, create it. | ||||
string real_path = RealPath(kFilePath.c_str()); | string real_path = RealPath(kFilePath.c_str()); | ||||
@@ -176,18 +180,19 @@ ge::Status Analyzer::CreateAnalyzerFile() { | |||||
GELOGE(FAILED, "File path is invalid."); | GELOGE(FAILED, "File path is invalid."); | ||||
return FAILED; | return FAILED; | ||||
} | } | ||||
string file = real_path + "/" + kAnalyzeFile; | |||||
GELOGD("Created analyzer file:[%s]", file.c_str()); | |||||
int fd = open(file.c_str(), O_WRONLY | O_CREAT | O_TRUNC, kFileAuthority); | |||||
std::lock_guard<std::mutex> lg(file_mutex_); | |||||
json_file_name_ = real_path + "/" + kAnalyzeFile; | |||||
GELOGD("Created analyzer file:[%s]", json_file_name_.c_str()); | |||||
int fd = open(json_file_name_.c_str(), O_WRONLY | O_CREAT | O_TRUNC, kFileAuthority); | |||||
if (fd < 0) { | if (fd < 0) { | ||||
GELOGE(INTERNAL_ERROR, "Fail to open the file: %s.", file.c_str()); | |||||
GELOGE(INTERNAL_ERROR, "Fail to open the file: %s.", json_file_name_.c_str()); | |||||
return INTERNAL_ERROR; | return INTERNAL_ERROR; | ||||
} | } | ||||
if (close(fd) != 0) { | if (close(fd) != 0) { | ||||
GELOGE(INTERNAL_ERROR, "Fail to close the file: %s.", file.c_str()); | |||||
GELOGE(INTERNAL_ERROR, "Fail to close the file: %s.", json_file_name_.c_str()); | |||||
return INTERNAL_ERROR; | return INTERNAL_ERROR; | ||||
} | } | ||||
json_file_name_ = file; | |||||
is_json_file_create_ = true; | |||||
GELOGD("success to create analyzer file[%s]!", json_file_name_.c_str()); | GELOGD("success to create analyzer file[%s]!", json_file_name_.c_str()); | ||||
return SUCCESS; | return SUCCESS; | ||||
@@ -231,6 +236,12 @@ ge::Status Analyzer::DoAnalyze(DataInfo &data_info) { | |||||
GELOGE(status, "save op info failed!"); | GELOGE(status, "save op info failed!"); | ||||
return FAILED; | return FAILED; | ||||
} | } | ||||
// create json file | |||||
status = CreateAnalyzerFile(); | |||||
if (status != SUCCESS) { | |||||
GELOGE(status, "create analyzer file failed!"); | |||||
return status; | |||||
} | |||||
// save data to file | // save data to file | ||||
return SaveAnalyzerDataToFile(); | return SaveAnalyzerDataToFile(); | ||||
} | } |
@@ -24,6 +24,7 @@ | |||||
#include <mutex> | #include <mutex> | ||||
#include <memory> | #include <memory> | ||||
#include <fstream> | #include <fstream> | ||||
#include <atomic> | |||||
#include "external/ge/ge_api_types.h" | #include "external/ge/ge_api_types.h" | ||||
#include "graph/compute_graph.h" | #include "graph/compute_graph.h" | ||||
@@ -181,6 +182,7 @@ class Analyzer { | |||||
std::mutex file_mutex_; // protect json_file_ | std::mutex file_mutex_; // protect json_file_ | ||||
std::ofstream json_file_; | std::ofstream json_file_; | ||||
std::string json_file_name_; | std::string json_file_name_; | ||||
std::atomic_bool is_json_file_create_{false}; | |||||
}; | }; | ||||
} // namespace ge | } // namespace ge | ||||
#endif // DOMI_ANALYZER_ANANLYZER_H_ | #endif // DOMI_ANALYZER_ANANLYZER_H_ |
@@ -17,18 +17,19 @@ | |||||
# add all proto files, generate corresponding .h and .cc files | # add all proto files, generate corresponding .h and .cc files | ||||
set(CMAKE_CXX_FLAGS "-Wno-unused-variable ${CMAKE_CXX_FLAGS}") | set(CMAKE_CXX_FLAGS "-Wno-unused-variable ${CMAKE_CXX_FLAGS}") | ||||
file(GLOB PROTO_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} | file(GLOB PROTO_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} | ||||
"../../proto/ge_api.proto" | |||||
"../proto/ge_api.proto" | |||||
) | ) | ||||
file(GLOB PROTO_HEADER_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} | file(GLOB PROTO_HEADER_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} | ||||
"../../proto/ge_ir.proto" | |||||
"../../proto/task.proto" | |||||
"../../proto/om.proto" | |||||
"../../proto/insert_op.proto" | |||||
"../proto/ge_ir.proto" | |||||
"../proto/task.proto" | |||||
"../proto/om.proto" | |||||
"../proto/insert_op.proto" | |||||
) | ) | ||||
file(GLOB SRC_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} | file(GLOB SRC_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} | ||||
"ge_api.cc" | "ge_api.cc" | ||||
"ge_prof.cc" | |||||
) | ) | ||||
ge_protobuf_generate(ge PROTO_SRCS PROTO_HDRS ${PROTO_LIST}) | ge_protobuf_generate(ge PROTO_SRCS PROTO_HDRS ${PROTO_LIST}) | ||||
@@ -36,14 +37,14 @@ ge_protobuf_generate(ge PROTO_HEADER_SRCS PROTO_HEADER_HDRS ${PROTO_HEADER_LIST} | |||||
# include directories | # include directories | ||||
include_directories(${CMAKE_CURRENT_LIST_DIR}) | include_directories(${CMAKE_CURRENT_LIST_DIR}) | ||||
include_directories(${GE_SOURCE_DIR}/src/ge) | |||||
include_directories(${GE_SOURCE_DIR}/src) | |||||
include_directories(${GE_SOURCE_DIR}/ge) | |||||
include_directories(${GE_SOURCE_DIR}/inc) | include_directories(${GE_SOURCE_DIR}/inc) | ||||
include_directories(${GE_SOURCE_DIR}/inc/external) | include_directories(${GE_SOURCE_DIR}/inc/external) | ||||
include_directories(${GE_SOURCE_DIR}/inc/external/graph) | |||||
include_directories(${GE_SOURCE_DIR}/inc/common) | include_directories(${GE_SOURCE_DIR}/inc/common) | ||||
include_directories(${GE_SOURCE_DIR}/inc/framework) | include_directories(${GE_SOURCE_DIR}/inc/framework) | ||||
include_directories(${GE_SOURCE_DIR}/inc/graph) | |||||
include_directories(${GE_SOURCE_DIR}/metadef/inc) | |||||
include_directories(${GE_SOURCE_DIR}/metadef/inc/external/graph) | |||||
include_directories(${GE_SOURCE_DIR}/metadef/inc/graph) | |||||
include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc) | include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc) | ||||
include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc/cce) | include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc/cce) | ||||
include_directories(${CMAKE_BINARY_DIR}) | include_directories(${CMAKE_BINARY_DIR}) | ||||
@@ -66,5 +67,6 @@ target_link_libraries(ge_client | |||||
${slog} | ${slog} | ||||
${mmpa} | ${mmpa} | ||||
${runtime} | ${runtime} | ||||
${msprof} | |||||
rt | rt | ||||
dl) | dl) |
@@ -39,7 +39,7 @@ using std::vector; | |||||
namespace { | namespace { | ||||
const int32_t kMaxStrLen = 128; | const int32_t kMaxStrLen = 128; | ||||
} | |||||
} // namespace | |||||
static bool g_ge_initialized = false; | static bool g_ge_initialized = false; | ||||
static std::mutex g_ge_release_mutex; // GEFinalize and ~Session use | static std::mutex g_ge_release_mutex; // GEFinalize and ~Session use |
@@ -0,0 +1,375 @@ | |||||
/** | |||||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
* | |||||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||||
* you may not use this file except in compliance with the License. | |||||
* You may obtain a copy of the License at | |||||
* | |||||
* http://www.apache.org/licenses/LICENSE-2.0 | |||||
* | |||||
* Unless required by applicable law or agreed to in writing, software | |||||
* distributed under the License is distributed on an "AS IS" BASIS, | |||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
* See the License for the specific language governing permissions and | |||||
* limitations under the License. | |||||
*/ | |||||
#include "ge/ge_prof.h" | |||||
#include "ge/ge_api.h" | |||||
#include "init/gelib.h" | |||||
#include "common/debug/log.h" | |||||
#include "framework/common/debug/ge_log.h" | |||||
#include "common/profiling/profiling_manager.h" | |||||
#include "graph/load/graph_loader.h" | |||||
#include "toolchain/prof_acl_api.h" | |||||
using std::map; | |||||
using std::string; | |||||
using std::vector; | |||||
namespace { | |||||
const uint32_t kMaxDeviceNum = 64; | |||||
const std::string PROFILING_INIT = "prof_init"; | |||||
const std::string PROFILING_FINALIZE = "prof_finalize"; | |||||
const std::string PROFILING_START = "prof_start"; | |||||
const std::string PROFILING_STOP = "prof_stop"; | |||||
const std::string DEVICES_NUMS = "devNums"; | |||||
const std::string DEVICE_ID_LIST = "devIdList"; | |||||
const std::string AICORE_METRICS = "aicoreMetrics"; | |||||
const std::map<ge::ProfilingAicoreMetrics, std::string> kProfAicoreMetricsToString = { | |||||
{ge::kAicoreArithmaticThroughput, "AICORE_ARITHMATIC_THROUGHPUT"}, | |||||
{ge::kAicorePipeline, "AICORE_PIPELINE"}, | |||||
{ge::kAicoreSynchronization, "AICORE_SYNCHRONIZATION"}, | |||||
{ge::kAicoreMemory, "AICORE_MEMORY"}, | |||||
{ge::kAicoreInternalMemory, "AICORE_INTERNAL_MEMORY"}, | |||||
{ge::kAicoreStall, "AICORE_STALL"}, | |||||
{ge::kAicoreMetricsAll, "AICORE_METRICS_ALL"}}; | |||||
const std::map<uint64_t, uint64_t> kDataTypeConfigMapping = {{ge::kProfAcl, PROF_ACL_API}, | |||||
{ge::kProfTaskTime, PROF_TASK_TIME}, | |||||
{ge::kProfAiCoreMetrics, PROF_AICORE_METRICS}, | |||||
{ge::kProfAicpuTrace, PROF_AICPU_TRACE}, | |||||
{ge::kProfModelExecute, PROF_MODEL_EXECUTE}, | |||||
{ge::kProfRuntimeApi, PROF_RUNTIME_API}, | |||||
{ge::kProfRuntimeTrace, PROF_RUNTIME_TRACE}, | |||||
{ge::kProfScheduleTimeline, PROF_SCHEDULE_TIMELINE}, | |||||
{ge::kProfScheduleTrace, PROF_SCHEDULE_TRACE}, | |||||
{ge::kProfAiVectorCoreMetrics, PROF_AIVECTORCORE_METRICS}, | |||||
{ge::kProfSubtaskTime, PROF_SUBTASK_TIME}, | |||||
{ge::kProfTrainingTrace, PROF_TRAINING_TRACE}, | |||||
{ge::kProfHcclTrace, PROF_HCCL_TRACE}, | |||||
{ge::kProfDataProcess, PROF_DATA_PROCESS}, | |||||
{ge::kProfTaskTrace, PROF_TASK_TRACE}, | |||||
{ge::kProfModelLoad, PROF_MODEL_LOAD}}; | |||||
} // namespace | |||||
static bool g_graph_prof_init_ = false; | |||||
static std::mutex g_prof_mutex_; | |||||
namespace ge { | |||||
struct aclgrphProfConfig { | |||||
ProfConfig config; | |||||
}; | |||||
Status aclgrphProfInit(const char *profiler_path, uint32_t length) { | |||||
GELOGT(TRACE_INIT, "Graph prof init start"); | |||||
std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); | |||||
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { | |||||
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "Ge client is not initialized."); | |||||
return FAILED; | |||||
} | |||||
std::lock_guard<std::mutex> lock(g_prof_mutex_); | |||||
if (g_graph_prof_init_) { | |||||
GELOGW("Multi graph profiling initializations."); | |||||
return GE_PROF_MULTI_INIT; | |||||
} | |||||
Status ret = CheckPath(profiler_path, length); | |||||
if (ret != SUCCESS) { | |||||
GELOGE(ret, "Profiling config path is invalid."); | |||||
return ret; | |||||
} | |||||
// if command mode is set, just return | |||||
if (ProfilingManager::Instance().ProfilingOn()) { | |||||
GELOGW("Graph prof init failed, cause profiling command pattern is running."); | |||||
return GE_PROF_MODE_CONFLICT; | |||||
} | |||||
ret = ProfInit(profiler_path); | |||||
if (ret != SUCCESS) { | |||||
GELOGE(ret, "ProfInit init fail"); | |||||
return ret; | |||||
} | |||||
GraphLoader graph_loader; | |||||
Command command; | |||||
command.cmd_params.clear(); | |||||
command.cmd_type = PROFILING_INIT; | |||||
command.module_index = kProfModelLoad | kProfTrainingTrace; | |||||
ret = graph_loader.CommandHandle(command); | |||||
if (ret != SUCCESS) { | |||||
GELOGE(ret, "Handle profiling command %s failed, config = %s", PROFILING_INIT.c_str(), profiler_path); | |||||
return ret; | |||||
} | |||||
if (!g_graph_prof_init_) { | |||||
g_graph_prof_init_ = true; | |||||
GELOGI("Profiling init successfully."); | |||||
} | |||||
GELOGI("Successfully execute GraphProfInit."); | |||||
return SUCCESS; | |||||
} | |||||
Status aclgrphProfFinalize() { | |||||
std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); | |||||
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { | |||||
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "Ge client is not initialized."); | |||||
return FAILED; | |||||
} | |||||
std::lock_guard<std::mutex> lock(g_prof_mutex_); | |||||
// if command mode is set, just return | |||||
if (ProfilingManager::Instance().ProfilingOn()) { | |||||
GELOGW("Graph prof finalize failed, cause profiling command pattern is running."); | |||||
return GE_PROF_MODE_CONFLICT; | |||||
} | |||||
if (!g_graph_prof_init_) { | |||||
GELOGE(GE_PROF_NOT_INIT, "Graph not profiling initialize."); | |||||
return GE_PROF_NOT_INIT; | |||||
} | |||||
GraphLoader graph_loader; | |||||
Command command; | |||||
command.cmd_params.clear(); | |||||
command.cmd_type = PROFILING_FINALIZE; | |||||
Status ret = graph_loader.CommandHandle(command); | |||||
if (ret != SUCCESS) { | |||||
GELOGE(ret, "Handle profiling command %s failed.", PROFILING_FINALIZE.c_str()); | |||||
return ret; | |||||
} | |||||
ret = ProfFinalize(); | |||||
if (ret != SUCCESS) { | |||||
GELOGE(ret, "Finalize profiling failed, result = %d", ret); | |||||
} | |||||
if (ret == SUCCESS) { | |||||
g_graph_prof_init_ = false; | |||||
GELOGI("Successfully execute GraphProfFinalize."); | |||||
} | |||||
return ret; | |||||
} | |||||
bool TransProfConfigToParam(const aclgrphProfConfig *profiler_config, vector<string> &prof_config_params) { | |||||
prof_config_params.clear(); | |||||
prof_config_params.emplace_back(DEVICES_NUMS); | |||||
prof_config_params.emplace_back(std::to_string(profiler_config->config.devNums)); | |||||
prof_config_params.emplace_back(DEVICE_ID_LIST); | |||||
std::string devID = ""; | |||||
if (profiler_config->config.devNums == 0) { | |||||
GELOGW("The device num is invalid."); | |||||
return false; | |||||
} | |||||
for (uint32_t i = 0; i < profiler_config->config.devNums; i++) { | |||||
devID.append(std::to_string(profiler_config->config.devIdList[i])); | |||||
if (i != profiler_config->config.devNums - 1) { | |||||
devID.append(","); | |||||
} | |||||
} | |||||
prof_config_params.push_back(devID); | |||||
prof_config_params.push_back(AICORE_METRICS); | |||||
auto iter = | |||||
kProfAicoreMetricsToString.find(static_cast<ProfilingAicoreMetrics>(profiler_config->config.aicoreMetrics)); | |||||
if (iter == kProfAicoreMetricsToString.end()) { | |||||
GELOGW("The prof aicore metrics is invalid."); | |||||
return false; | |||||
} | |||||
prof_config_params.push_back(iter->second); | |||||
return true; | |||||
} | |||||
bool isProfConfigValid(const uint32_t *deviceid_list, uint32_t device_nums) { | |||||
if (deviceid_list == nullptr) { | |||||
GELOGE(PARAM_INVALID, "deviceIdList is nullptr"); | |||||
return false; | |||||
} | |||||
if (device_nums == 0 || device_nums > kMaxDeviceNum) { | |||||
GELOGE(PARAM_INVALID, "The device nums is invalid."); | |||||
return false; | |||||
} | |||||
// real device num | |||||
int32_t dev_count = 0; | |||||
rtError_t rt_err = rtGetDeviceCount(&dev_count); | |||||
if (rt_err != RT_ERROR_NONE) { | |||||
GELOGE(INTERNAL_ERROR, "Get the Device count fail."); | |||||
return false; | |||||
} | |||||
if (device_nums > static_cast<uint32_t>(dev_count)) { | |||||
GELOGE(PARAM_INVALID, "Device num(%u) is not in range 1 ~ %d.", device_nums, dev_count); | |||||
return false; | |||||
} | |||||
std::unordered_set<uint32_t> record; | |||||
for (size_t i = 0; i < device_nums; ++i) { | |||||
uint32_t dev_id = deviceid_list[i]; | |||||
if (dev_id >= static_cast<uint32_t>(dev_count)) { | |||||
GELOGE(PARAM_INVALID, "Device id %u is not in range 0 ~ %d(exclude %d)", dev_id, dev_count, dev_count); | |||||
return false; | |||||
} | |||||
if (record.count(dev_id) > 0) { | |||||
GELOGE(PARAM_INVALID, "Device id %u is duplicatedly set", dev_id); | |||||
return false; | |||||
} | |||||
record.insert(dev_id); | |||||
} | |||||
return true; | |||||
} | |||||
aclgrphProfConfig *aclgrphProfCreateConfig(uint32_t *deviceid_list, uint32_t device_nums, | |||||
ProfilingAicoreMetrics aicore_metrics, ProfAicoreEvents *aicore_events, | |||||
uint64_t data_type_config) { | |||||
if (!isProfConfigValid(deviceid_list, device_nums)) { | |||||
return nullptr; | |||||
} | |||||
aclgrphProfConfig *config = new (std::nothrow) aclgrphProfConfig(); | |||||
if (config == nullptr) { | |||||
GELOGE(INTERNAL_ERROR, "new aclgrphProfConfig fail"); | |||||
return nullptr; | |||||
} | |||||
config->config.devNums = device_nums; | |||||
if (memcpy_s(config->config.devIdList, sizeof(config->config.devIdList), deviceid_list, | |||||
device_nums * sizeof(uint32_t)) != EOK) { | |||||
GELOGE(INTERNAL_ERROR, "copy devID failed. size = %u", device_nums); | |||||
delete config; | |||||
return nullptr; | |||||
} | |||||
config->config.aicoreMetrics = static_cast<ProfAicoreMetrics>(aicore_metrics); | |||||
uint64_t data_type = 0; | |||||
for (auto &iter : kDataTypeConfigMapping) { | |||||
if ((iter.first & data_type_config) == iter.first) { | |||||
data_type |= iter.second; | |||||
} | |||||
} | |||||
config->config.dataTypeConfig = data_type; | |||||
GELOGI("Successfully create prof config."); | |||||
return config; | |||||
} | |||||
Status aclgrphProfDestroyConfig(aclgrphProfConfig *profiler_config) { | |||||
if (profiler_config == nullptr) { | |||||
GELOGE(PARAM_INVALID, "destroy profilerConfig failed, profilerConfig must not be nullptr"); | |||||
return PARAM_INVALID; | |||||
} | |||||
delete profiler_config; | |||||
GELOGI("Successfully destroy prof config."); | |||||
return SUCCESS; | |||||
} | |||||
Status aclgrphProfStart(aclgrphProfConfig *profiler_config) { | |||||
if (profiler_config == nullptr) { | |||||
GELOGE(PARAM_INVALID, "aclgrphProfConfig is invalid."); | |||||
return FAILED; | |||||
} | |||||
std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); | |||||
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { | |||||
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "Ge client is not initialized."); | |||||
return FAILED; | |||||
} | |||||
std::lock_guard<std::mutex> lock(g_prof_mutex_); | |||||
// if command mode is set, just return | |||||
if (ProfilingManager::Instance().ProfilingOn()) { | |||||
GELOGW("Graph prof finalize failed, cause profiling command pattern is running."); | |||||
return GE_PROF_MODE_CONFLICT; | |||||
} | |||||
if (!g_graph_prof_init_) { | |||||
GELOGE(GE_PROF_NOT_INIT, "Graph not profiling initialize."); | |||||
return GE_PROF_NOT_INIT; | |||||
} | |||||
Status ret = ProfStartProfiling(&profiler_config->config); | |||||
if (ret != SUCCESS) { | |||||
GELOGE(ret, "Start profiling failed, prof result = %d", ret); | |||||
return FAILED; | |||||
} | |||||
std::vector<string> prof_params; | |||||
if (!TransProfConfigToParam(profiler_config, prof_params)) { | |||||
GELOGE(PARAM_INVALID, "Transfer profilerConfig to string vector failed"); | |||||
return PARAM_INVALID; | |||||
} | |||||
GraphLoader graph_loader; | |||||
Command command; | |||||
command.cmd_params.clear(); | |||||
command.cmd_type = PROFILING_START; | |||||
command.cmd_params = prof_params; | |||||
command.module_index = profiler_config->config.dataTypeConfig; | |||||
ret = graph_loader.CommandHandle(command); | |||||
if (ret != SUCCESS) { | |||||
GELOGE(ret, "Handle profiling command failed"); | |||||
return FAILED; | |||||
} | |||||
GELOGI("Successfully execute GraphProfStartProfiling."); | |||||
return SUCCESS; | |||||
} | |||||
Status aclgrphProfStop(aclgrphProfConfig *profiler_config) { | |||||
if (profiler_config == nullptr) { | |||||
GELOGE(PARAM_INVALID, "aclgrphProfConfig is invalid."); | |||||
return FAILED; | |||||
} | |||||
std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); | |||||
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { | |||||
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "Ge client is not initialized."); | |||||
return FAILED; | |||||
} | |||||
std::lock_guard<std::mutex> lock(g_prof_mutex_); | |||||
// if command mode is set, just return | |||||
if (ProfilingManager::Instance().ProfilingOn()) { | |||||
GELOGW("Graph prof finalize failed, cause profiling command pattern is running."); | |||||
return GE_PROF_MODE_CONFLICT; | |||||
} | |||||
if (!g_graph_prof_init_) { | |||||
GELOGE(GE_PROF_NOT_INIT, "Graph not profiling initialize."); | |||||
return GE_PROF_NOT_INIT; | |||||
} | |||||
Status ret = ProfStopProfiling(&profiler_config->config); | |||||
if (ret != SUCCESS) { | |||||
GELOGE(ret, "Stop profiling failed, prof result = %d", ret); | |||||
return ret; | |||||
} | |||||
std::vector<string> prof_params; | |||||
if (!TransProfConfigToParam(profiler_config, prof_params)) { | |||||
GELOGE(PARAM_INVALID, "Transfer profilerConfig to string vector failed"); | |||||
return PARAM_INVALID; | |||||
} | |||||
GraphLoader graph_loader; | |||||
Command command; | |||||
command.cmd_params.clear(); | |||||
command.cmd_type = PROFILING_STOP; | |||||
command.cmd_params = prof_params; | |||||
command.module_index = profiler_config->config.dataTypeConfig; | |||||
ret = graph_loader.CommandHandle(command); | |||||
if (ret != SUCCESS) { | |||||
GELOGE(ret, "Handle profiling command failed"); | |||||
return FAILED; | |||||
} | |||||
GELOGI("Successfully execute GraphProfStopProfiling."); | |||||
return SUCCESS; | |||||
} | |||||
} // namespace ge |
@@ -4,6 +4,7 @@ LOCAL_PATH := $(call my-dir) | |||||
COMMON_LOCAL_SRC_FILES := \ | COMMON_LOCAL_SRC_FILES := \ | ||||
proto/ge_api.proto \ | proto/ge_api.proto \ | ||||
ge_api.cc \ | ge_api.cc \ | ||||
ge_prof.cc \ | |||||
COMMON_LOCAL_C_INCLUDES := \ | COMMON_LOCAL_C_INCLUDES := \ | ||||
@@ -69,6 +70,8 @@ LOCAL_SHARED_LIBRARIES := \ | |||||
libregister \ | libregister \ | ||||
libge_compiler \ | libge_compiler \ | ||||
libge_common \ | libge_common \ | ||||
libmsprof | |||||
LOCAL_LDFLAGS := -lrt -ldl | LOCAL_LDFLAGS := -lrt -ldl | ||||
@@ -102,6 +105,7 @@ LOCAL_SHARED_LIBRARIES := \ | |||||
libruntime \ | libruntime \ | ||||
libge_compiler \ | libge_compiler \ | ||||
libge_common \ | libge_common \ | ||||
libmsprof | |||||
LOCAL_LDFLAGS := -lrt -ldl | LOCAL_LDFLAGS := -lrt -ldl |
@@ -15,10 +15,10 @@ | |||||
# libge_common.so | # libge_common.so | ||||
file(GLOB PROTO_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} | file(GLOB PROTO_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} | ||||
"../../proto/om.proto" | |||||
"../../proto/ge_ir.proto" | |||||
"../../proto/task.proto" | |||||
"../../proto/insert_op.proto" | |||||
"${GE_SOURCE_DIR}/metadef/proto/om.proto" | |||||
"${GE_SOURCE_DIR}/metadef/proto/ge_ir.proto" | |||||
"${GE_SOURCE_DIR}/metadef/proto/task.proto" | |||||
"${GE_SOURCE_DIR}/metadef/proto/insert_op.proto" | |||||
) | ) | ||||
file(GLOB SRC_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} | file(GLOB SRC_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} | ||||
@@ -27,6 +27,7 @@ file(GLOB SRC_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} | |||||
"context/ctx.cc" | "context/ctx.cc" | ||||
"cust_aicpu_kernel_store.cc" | "cust_aicpu_kernel_store.cc" | ||||
"debug/memory_dumper.cc" | "debug/memory_dumper.cc" | ||||
"dump/dump_properties.cc" | |||||
"fmk_error_codes.cc" | "fmk_error_codes.cc" | ||||
"formats/format_transfers/datatype_transfer.cc" | "formats/format_transfers/datatype_transfer.cc" | ||||
"formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc" | "formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc" | ||||
@@ -71,13 +72,15 @@ ge_protobuf_generate(ge PROTO_SRCS PROTO_HDRS ${PROTO_LIST}) | |||||
# include directories | # include directories | ||||
include_directories(${CMAKE_CURRENT_LIST_DIR}) | include_directories(${CMAKE_CURRENT_LIST_DIR}) | ||||
include_directories(${CMAKE_CURRENT_LIST_DIR}/op) | include_directories(${CMAKE_CURRENT_LIST_DIR}/op) | ||||
include_directories(${GE_SOURCE_DIR}/src/ge) | |||||
include_directories(${GE_SOURCE_DIR}/ge) | |||||
include_directories(${GE_SOURCE_DIR}/inc) | include_directories(${GE_SOURCE_DIR}/inc) | ||||
include_directories(${GE_SOURCE_DIR}/inc/common/util) | include_directories(${GE_SOURCE_DIR}/inc/common/util) | ||||
include_directories(${GE_SOURCE_DIR}/inc/external) | include_directories(${GE_SOURCE_DIR}/inc/external) | ||||
include_directories(${GE_SOURCE_DIR}/inc/external/graph) | |||||
include_directories(${GE_SOURCE_DIR}/inc/framework) | include_directories(${GE_SOURCE_DIR}/inc/framework) | ||||
include_directories(${GE_SOURCE_DIR}/inc/graph) | |||||
include_directories(${GE_SOURCE_DIR}/metadef/inc) | |||||
include_directories(${GE_SOURCE_DIR}/metadef/inc/external) | |||||
include_directories(${GE_SOURCE_DIR}/metadef/inc/external/graph) | |||||
include_directories(${GE_SOURCE_DIR}/metadef/inc/graph) | |||||
include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc) | include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc) | ||||
include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc/cce) | include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc/cce) | ||||
include_directories(${CMAKE_BINARY_DIR}) | include_directories(${CMAKE_BINARY_DIR}) |
@@ -49,7 +49,10 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status DumpManager::SetDumpConf | |||||
dump_properties_.ClearDumpPropertyValue(); | dump_properties_.ClearDumpPropertyValue(); | ||||
return SUCCESS; | return SUCCESS; | ||||
} | } | ||||
dump_properties_.SetDumpStatus(dump_status); | |||||
dump_op_switch = dump_config.dump_op_switch; | dump_op_switch = dump_config.dump_op_switch; | ||||
dump_properties_.SetDumpOpSwitch(dump_op_switch); | |||||
if (dump_op_switch == kDumpoff && dump_config.dump_list.empty()) { | if (dump_op_switch == kDumpoff && dump_config.dump_list.empty()) { | ||||
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; | return PARAM_INVALID; | ||||
@@ -95,14 +98,6 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status DumpManager::SetDumpConf | |||||
return SUCCESS; | return SUCCESS; | ||||
} | } | ||||
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool DumpManager::IsDumpOpen() { | |||||
std::lock_guard<std::mutex> lock(mutex_); | |||||
if (!dump_properties_.GetDumpPath().empty()) { | |||||
return true; | |||||
} | |||||
return false; | |||||
} | |||||
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY const DumpProperties &DumpManager::GetDumpProperties() { | FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY const DumpProperties &DumpManager::GetDumpProperties() { | ||||
std::lock_guard<std::mutex> lock(mutex_); | std::lock_guard<std::mutex> lock(mutex_); | ||||
return dump_properties_; | return dump_properties_; |
@@ -28,7 +28,6 @@ class DumpManager { | |||||
static DumpManager &GetInstance(); | static DumpManager &GetInstance(); | ||||
Status SetDumpConf(const DumpConfig &dump_config); | Status SetDumpConf(const DumpConfig &dump_config); | ||||
bool IsDumpOpen(); | |||||
const DumpProperties &GetDumpProperties(); | const DumpProperties &GetDumpProperties(); | ||||
void SetModelName(const std::string &model_name); | void SetModelName(const std::string &model_name); | ||||
const std::string &GetModelName(); | const std::string &GetModelName(); |
@@ -31,7 +31,7 @@ | |||||
namespace { | namespace { | ||||
const std::string kEnableFlag = "1"; | const std::string kEnableFlag = "1"; | ||||
const std::string kDumpStatusOpen = "on"; | |||||
const uint32_t kAicoreOverflow = (0x1 << 0); | const uint32_t kAicoreOverflow = (0x1 << 0); | ||||
const uint32_t kAtomicOverflow = (0x1 << 1); | const uint32_t kAtomicOverflow = (0x1 << 1); | ||||
const uint32_t kAllOverflow = (kAicoreOverflow | kAtomicOverflow); | const uint32_t kAllOverflow = (kAicoreOverflow | kAtomicOverflow); | ||||
@@ -81,12 +81,12 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void DumpProperties::InitByOpti | |||||
if (enable_dump_ == kEnableFlag) { | if (enable_dump_ == kEnableFlag) { | ||||
std::string dump_step; | std::string dump_step; | ||||
if (GetContext().GetOption(OPTION_EXEC_DUMP_STEP, dump_step) == GRAPH_SUCCESS) { | if (GetContext().GetOption(OPTION_EXEC_DUMP_STEP, dump_step) == GRAPH_SUCCESS) { | ||||
GELOGD("Get dump step %s successfully", dump_step.c_str()); | |||||
GELOGI("Get dump step %s successfully", dump_step.c_str()); | |||||
SetDumpStep(dump_step); | SetDumpStep(dump_step); | ||||
} | } | ||||
string dump_mode; | string dump_mode; | ||||
if (GetContext().GetOption(OPTION_EXEC_DUMP_MODE, dump_mode) == GRAPH_SUCCESS) { | if (GetContext().GetOption(OPTION_EXEC_DUMP_MODE, dump_mode) == GRAPH_SUCCESS) { | ||||
GELOGD("Get dump mode %s successfully", dump_mode.c_str()); | |||||
GELOGI("Get dump mode %s successfully", dump_mode.c_str()); | |||||
SetDumpMode(dump_mode); | SetDumpMode(dump_mode); | ||||
} | } | ||||
AddPropertyValue(DUMP_ALL_MODEL, {}); | AddPropertyValue(DUMP_ALL_MODEL, {}); | ||||
@@ -192,6 +192,37 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY const std::string &DumpProperti | |||||
return dump_mode_; | return dump_mode_; | ||||
} | } | ||||
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void DumpProperties::SetDumpStatus(const std::string &status) { | |||||
dump_status_ = status; | |||||
} | |||||
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY const std::string &DumpProperties::GetDumpStatus() const { | |||||
return dump_status_; | |||||
} | |||||
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void DumpProperties::SetDumpOpSwitch( | |||||
const std::string &dump_op_switch) { | |||||
dump_op_switch_ = dump_op_switch; | |||||
} | |||||
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY const std::string &DumpProperties::GetDumpOpSwitch() const { | |||||
return dump_op_switch_; | |||||
} | |||||
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool DumpProperties::IsSingleOpNeedDump() const { | |||||
if (dump_op_switch_ == kDumpStatusOpen) { | |||||
return true; | |||||
} | |||||
return false; | |||||
} | |||||
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool DumpProperties::IsDumpOpen() const { | |||||
if (enable_dump_ == kEnableFlag || dump_status_ == kDumpStatusOpen) { | |||||
return true; | |||||
} | |||||
return false; | |||||
} | |||||
void DumpProperties::CopyFrom(const DumpProperties &other) { | void DumpProperties::CopyFrom(const DumpProperties &other) { | ||||
if (&other != this) { | if (&other != this) { | ||||
enable_dump_ = other.enable_dump_; | enable_dump_ = other.enable_dump_; |
@@ -61,10 +61,26 @@ class DumpProperties { | |||||
const std::string &GetDumpMode() const; | const std::string &GetDumpMode() const; | ||||
void SetDumpStatus(const std::string &status); | |||||
const std::string &GetDumpStatus() const; | |||||
void SetDumpOpSwitch(const std::string &dump_op_switch); | |||||
const std::string &GetDumpOpSwitch() const; | |||||
bool IsOpDebugOpen() const { return is_op_debug_; } | bool IsOpDebugOpen() const { return is_op_debug_; } | ||||
bool IsDumpOpen() const; | |||||
bool IsSingleOpNeedDump() const; | |||||
uint32_t GetOpDebugMode() const { return op_debug_mode_; } | uint32_t GetOpDebugMode() const { return op_debug_mode_; } | ||||
const std::string &GetEnableDump() const { return enable_dump_; } | |||||
const std::string &GetEnableDumpDebug() const { return enable_dump_debug_; } | |||||
private: | private: | ||||
void CopyFrom(const DumpProperties &other); | void CopyFrom(const DumpProperties &other); | ||||
@@ -76,6 +92,8 @@ class DumpProperties { | |||||
std::string dump_path_; | std::string dump_path_; | ||||
std::string dump_step_; | std::string dump_step_; | ||||
std::string dump_mode_; | std::string dump_mode_; | ||||
std::string dump_status_; | |||||
std::string dump_op_switch_; | |||||
std::map<std::string, std::set<std::string>> model_dump_properties_map_; | std::map<std::string, std::set<std::string>> model_dump_properties_map_; | ||||
bool is_op_debug_ = false; | bool is_op_debug_ = false; |
@@ -15,14 +15,15 @@ | |||||
*/ | */ | ||||
#include "common/ge/op_tiling_manager.h" | #include "common/ge/op_tiling_manager.h" | ||||
#include "common/util/error_manager/error_manager.h" | |||||
#include "framework/common/debug/log.h" | #include "framework/common/debug/log.h" | ||||
#include <string> | #include <string> | ||||
namespace { | namespace { | ||||
const char *const kEnvName = "ASCEND_OPP_PATH"; | const char *const kEnvName = "ASCEND_OPP_PATH"; | ||||
const std::string kDefaultPath = "/usr/local/Ascend/opp"; | const std::string kDefaultPath = "/usr/local/Ascend/opp"; | ||||
const std::string kDefaultBuiltInTilingPath = "/op_impl/built-in/liboptiling.so"; | |||||
const std::string kDefaultCustomTilingPath = "/op_impl/custom/liboptiling.so"; | |||||
const std::string kDefaultBuiltInTilingPath = "/op_impl/built-in/ai_core/tbe/op_tiling/liboptiling.so"; | |||||
const std::string kDefaultCustomTilingPath = "/op_impl/custom/ai_core/tbe/op_tiling/liboptiling.so"; | |||||
const uint8_t kPrefixIndex = 9; | const uint8_t kPrefixIndex = 9; | ||||
} // namespace | } // namespace | ||||
@@ -44,7 +45,9 @@ std::string OpTilingManager::GetPath() { | |||||
if (opp_path_env != nullptr) { | if (opp_path_env != nullptr) { | ||||
char resolved_path[PATH_MAX]; | char resolved_path[PATH_MAX]; | ||||
if (realpath(opp_path_env, resolved_path) == NULL) { | if (realpath(opp_path_env, resolved_path) == NULL) { | ||||
GELOGE(PARAM_INVALID, "Failed load tiling lib as env 'ASCEND_OPP_PATH'(%s) is invalid path.", opp_path_env); | |||||
ErrorManager::GetInstance().ATCReportErrMessage("E19024", {"env", "value", "situation"}, | |||||
{"ASCEND_OPP_PATH", opp_path_env, "loading the tiling lib"}); | |||||
GELOGE(PARAM_INVALID, "Failed load tiling lib as env 'ASCEND_OPP_PATH'[%s] is invalid path.", opp_path_env); | |||||
return std::string(); | return std::string(); | ||||
} | } | ||||
opp_path = resolved_path; | opp_path = resolved_path; |
@@ -12,6 +12,7 @@ GE_COMMON_LOCAL_SRC_FILES := \ | |||||
math/fp16_math.cc \ | math/fp16_math.cc \ | ||||
debug/memory_dumper.cc \ | debug/memory_dumper.cc \ | ||||
formats/utils/formats_trans_utils.cc \ | formats/utils/formats_trans_utils.cc \ | ||||
dump/dump_properties.cc \ | |||||
formats/format_transfers/datatype_transfer.cc \ | formats/format_transfers/datatype_transfer.cc \ | ||||
formats/format_transfers/format_transfer_transpose.cc \ | formats/format_transfers/format_transfer_transpose.cc \ | ||||
formats/format_transfers/format_transfer_nchw_nc1hwc0.cc \ | formats/format_transfers/format_transfer_nchw_nc1hwc0.cc \ |
@@ -497,7 +497,25 @@ Status ModelCacheHelper::LoadJsonFromFile(const string &file_name, Json &json) c | |||||
GELOGW("Fail to open the file: %s.", path.c_str()); | GELOGW("Fail to open the file: %s.", path.c_str()); | ||||
return INTERNAL_ERROR; | return INTERNAL_ERROR; | ||||
} | } | ||||
ifs >> json; | |||||
try { | |||||
ifs >> json; | |||||
} catch (nlohmann::detail::parse_error e) { | |||||
GELOGW("Fail to load json from file, json throw an error:%s.", e.what()); | |||||
return INTERNAL_ERROR; | |||||
} catch (nlohmann::detail::invalid_iterator e) { | |||||
GELOGW("Fail to load json from file, json throw an error:%s.", e.what()); | |||||
return INTERNAL_ERROR; | |||||
} catch (nlohmann::detail::type_error e) { | |||||
GELOGW("Fail to load json from file, json throw an error:%s.", e.what()); | |||||
return INTERNAL_ERROR; | |||||
} catch (nlohmann::detail::out_of_range e) { | |||||
GELOGW("Fail to load json from file, json throw an error:%s.", e.what()); | |||||
return INTERNAL_ERROR; | |||||
} catch (nlohmann::detail::other_error e) { | |||||
GELOGW("Fail to load json from file, json throw an error:%s.", e.what()); | |||||
return INTERNAL_ERROR; | |||||
} | |||||
if (!json.is_object()) { | if (!json.is_object()) { | ||||
GELOGW("Fail to load the json file: %s.", path.c_str()); | GELOGW("Fail to load the json file: %s.", path.c_str()); | ||||
return INTERNAL_ERROR; | return INTERNAL_ERROR; |
@@ -41,7 +41,22 @@ Status ModelHelper::SaveModelPartition(std::shared_ptr<OmFileSaveHelper> &om_fil | |||||
const uint8_t *data, size_t size) { | const uint8_t *data, size_t size) { | ||||
if (size < 1 || size > UINT32_MAX) { | if (size < 1 || size > UINT32_MAX) { | ||||
GELOGE(PARAM_INVALID, "Add model partition failed, partition size %zu invalid", size); | GELOGE(PARAM_INVALID, "Add model partition failed, partition size %zu invalid", size); | ||||
ErrorManager::GetInstance().ATCReportErrMessage("E19022"); | |||||
if (size > UINT32_MAX) { | |||||
string item = "item"; | |||||
if (type == MODEL_DEF) { | |||||
item = "model info"; | |||||
} else if (type == WEIGHTS_DATA) { | |||||
item = "weight data"; | |||||
} else if (type == TASK_INFO) { | |||||
item = "task info"; | |||||
} else if (type == TBE_KERNELS) { | |||||
item = "tbe kernels"; | |||||
} else if (type == CUST_AICPU_KERNELS) { | |||||
item = "aicpu kernels"; | |||||
} | |||||
ErrorManager::GetInstance().ATCReportErrMessage("E19023", {"size", "item", "maxsize"}, | |||||
{std::to_string(size), item, std::to_string(UINT32_MAX)}); | |||||
} | |||||
return PARAM_INVALID; | return PARAM_INVALID; | ||||
} | } | ||||
if (data == nullptr) { | if (data == nullptr) { | ||||
@@ -263,7 +278,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::LoadModel(c | |||||
} | } | ||||
Status status = ge::DavinciModelParser::ParseModelContent(model_data, model_addr_tmp_, model_len_tmp_); | Status status = ge::DavinciModelParser::ParseModelContent(model_data, model_addr_tmp_, model_len_tmp_); | ||||
if (ge::DavinciModelParser::ParseModelContent(model_data, model_addr_tmp_, model_len_tmp_) != SUCCESS) { | |||||
if (status != SUCCESS) { | |||||
GELOGE(status, "Parse model content failed!"); | GELOGE(status, "Parse model content failed!"); | ||||
return status; | return status; | ||||
} | } |
@@ -51,10 +51,23 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ProfilingManager &ProfilingMana | |||||
return profiling_manager; | return profiling_manager; | ||||
} | } | ||||
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ge::Status ProfilingManager::Init(const Options &options) { | |||||
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ge::Status ProfilingManager::Init(const Options &options, | |||||
bool convert_2_phy_device_id) { | |||||
#ifdef DAVINCI_SUPPORT_PROFILING | #ifdef DAVINCI_SUPPORT_PROFILING | ||||
vector<int32_t>().swap(device_id_); | vector<int32_t>().swap(device_id_); | ||||
device_id_.push_back(options.device_id); | |||||
// profiling need phy device id | |||||
if (!convert_2_phy_device_id) { | |||||
device_id_.push_back(options.device_id); | |||||
} else { | |||||
uint32_t phy_device_id = 0; | |||||
rtError_t rt_ret = rtGetDevicePhyIdByIndex(static_cast<uint32_t>(options.device_id), &phy_device_id); | |||||
if (rt_ret != RT_ERROR_NONE) { | |||||
GELOGE(rt_ret, "runtime get phy_device_id failed, current phy_device_id:%u", phy_device_id); | |||||
return FAILED; | |||||
} | |||||
device_id_.push_back(phy_device_id); | |||||
} | |||||
job_id_ = options.job_id; | job_id_ = options.job_id; | ||||
Status ret; | Status ret; |
@@ -69,7 +69,7 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ProfilingManager { | |||||
ProfilingManager(); | ProfilingManager(); | ||||
virtual ~ProfilingManager(); | virtual ~ProfilingManager(); | ||||
static ProfilingManager &Instance(); | static ProfilingManager &Instance(); | ||||
ge::Status Init(const Options &options); | |||||
ge::Status Init(const Options &options, bool convert_2_phy_device_id = false); | |||||
ge::Status InitFromOptions(const Options &options); | ge::Status InitFromOptions(const Options &options); | ||||
ge::Status InitFromAclCfg(const std::string &config); | ge::Status InitFromAclCfg(const std::string &config); | ||||
ge::Status StartProfiling(int32_t iter, int32_t device_id); | ge::Status StartProfiling(int32_t iter, int32_t device_id); |
@@ -172,6 +172,12 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY DumpProperties &PropertiesManag | |||||
return dump_properties_map_[session_id]; | return dump_properties_map_[session_id]; | ||||
} | } | ||||
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void PropertiesManager::AddDumpProperties( | |||||
uint64_t session_id, const DumpProperties &dump_properties) { | |||||
std::lock_guard<std::mutex> lock(mutex_); | |||||
dump_properties_map_.emplace(session_id, dump_properties); | |||||
} | |||||
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void PropertiesManager::RemoveDumpProperties(uint64_t session_id) { | FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void PropertiesManager::RemoveDumpProperties(uint64_t session_id) { | ||||
std::lock_guard<std::mutex> lock(mutex_); | std::lock_guard<std::mutex> lock(mutex_); | ||||
auto iter = dump_properties_map_.find(session_id); | auto iter = dump_properties_map_.find(session_id); |
@@ -23,8 +23,8 @@ | |||||
#include <string> | #include <string> | ||||
#include <vector> | #include <vector> | ||||
#include "graph/op_desc.h" | |||||
#include "common/dump/dump_properties.h" | #include "common/dump/dump_properties.h" | ||||
#include "graph/op_desc.h" | |||||
namespace ge { | namespace ge { | ||||
// Configuration property management | // Configuration property management | ||||
@@ -83,6 +83,10 @@ class PropertiesManager { | |||||
void SetPropertyDelimiter(const std::string &de); | void SetPropertyDelimiter(const std::string &de); | ||||
DumpProperties &GetDumpProperties(uint64_t session_id); | DumpProperties &GetDumpProperties(uint64_t session_id); | ||||
const map<uint64_t, DumpProperties> &GetDumpPropertiesMap() { return dump_properties_map_; } | |||||
void AddDumpProperties(uint64_t session_id, const DumpProperties &dump_properties); | |||||
void RemoveDumpProperties(uint64_t session_id); | void RemoveDumpProperties(uint64_t session_id); | ||||
private: | private: |