@@ -22,6 +22,7 @@ | |||||
#include "graph/load/graph_loader.h" | #include "graph/load/graph_loader.h" | ||||
#include "init/gelib.h" | #include "init/gelib.h" | ||||
#include "framework/common/ge_inner_error_codes.h" | #include "framework/common/ge_inner_error_codes.h" | ||||
#include "model/ge_model.h" | |||||
namespace { | namespace { | ||||
const uint32_t kDeviceListIndex = 3; | const uint32_t kDeviceListIndex = 3; | ||||
@@ -42,6 +43,10 @@ const std::map<ProfCommandHandleType, std::string> kProfCommandTypeMap = { | |||||
{kProfCommandhandleFinalize, kProfilingFinalize}, | {kProfCommandhandleFinalize, kProfilingFinalize}, | ||||
{kProfCommandhandleModelSubscribe, kProfModelSubscribe}, | {kProfCommandhandleModelSubscribe, kProfModelSubscribe}, | ||||
{kProfCommandhandleModelUnsubscribe, kProfModelUnsubscribe}}; | {kProfCommandhandleModelUnsubscribe, kProfModelUnsubscribe}}; | ||||
const uint64_t kModelId = ge::INVALID_MODEL_ID; | |||||
const uint16_t kStepStart = 0; | |||||
const uint16_t kStepEnd = 1; | |||||
} // namespace | } // namespace | ||||
bool TransProfConfigToParam(const ProfCommandHandleData &profCommand, vector<string> &prof_config_params) { | bool TransProfConfigToParam(const ProfCommandHandleData &profCommand, vector<string> &prof_config_params) { | ||||
@@ -216,6 +221,36 @@ ge::Status ProfCommandHandle(ProfCommandHandleType type, void *data, uint32_t le | |||||
return ge::SUCCESS; | return ge::SUCCESS; | ||||
} | } | ||||
GE_FUNC_VISIBILITY ge::Status ProfSetStepInfo(uint64_t index_id, uint16_t tag_id, rtStream_t stream) { | |||||
return ge::SUCCESS; | |||||
ge::Status ProfSetStepInfo(uint64_t index_id, uint16_t tag_id, rtStream_t stream) { | |||||
static bool is_first_run = true; | |||||
int32_t device_id = 0; | |||||
rtError_t rt_ret = rtGetDevice(&device_id); | |||||
if (rt_ret != RT_ERROR_NONE) { | |||||
GELOGE(rt_ret, "[Get][LogicDeviceId]Failed, ret 0x%X", rt_ret); | |||||
REPORT_CALL_ERROR("E19999", "Get logic device id failed, ret 0x%X", rt_ret); | |||||
return ge::FAILED; | |||||
} | |||||
if (is_first_run && tag_id == kStepStart) { | |||||
GE_CHK_STATUS_RET_NOLOG(ge::ProfilingManager::Instance().ProfileStepInfo(index_id, | |||||
kModelId, | |||||
tag_id, | |||||
stream, | |||||
device_id)); | |||||
is_first_run = false; | |||||
return ge::SUCCESS; | |||||
} | |||||
if (!is_first_run && tag_id == kStepEnd) { | |||||
GE_CHK_STATUS_RET_NOLOG(ge::ProfilingManager::Instance().ProfileStepInfo(index_id, | |||||
kModelId, | |||||
tag_id, | |||||
stream, | |||||
device_id)); | |||||
is_first_run = true; | |||||
return ge::SUCCESS; | |||||
} | |||||
GELOGE(ge::FAILED, "Param tag_id:%u invalid when is_first_run is %d", tag_id, is_first_run); | |||||
REPORT_INPUT_ERROR("E10001", std::vector<std::string>({"value", "parameter", "reason"}), | |||||
std::vector<std::string>({std::to_string(tag_id), "tag_id", | |||||
"tag id must be 0 when first run, must be 1 when second run"})); | |||||
return ge::FAILED; | |||||
} | } |
@@ -43,6 +43,11 @@ GE_FUNC_VISIBILITY ge::Status RegProfCtrlCallback(MsprofCtrlCallback func); | |||||
GE_FUNC_VISIBILITY ge::Status RegProfSetDeviceCallback(MsprofSetDeviceCallback func); | GE_FUNC_VISIBILITY ge::Status RegProfSetDeviceCallback(MsprofSetDeviceCallback func); | ||||
GE_FUNC_VISIBILITY ge::Status RegProfReporterCallback(MsprofReporterCallback func); | GE_FUNC_VISIBILITY ge::Status RegProfReporterCallback(MsprofReporterCallback func); | ||||
GE_FUNC_VISIBILITY ge::Status ProfCommandHandle(ProfCommandHandleType type, void *data, uint32_t len); | GE_FUNC_VISIBILITY ge::Status ProfCommandHandle(ProfCommandHandleType type, void *data, uint32_t len); | ||||
/// | |||||
/// @brief Output the profiling data of single operator in Pytorch, and does not support multithreading | |||||
/// @return Status result | |||||
/// | |||||
GE_FUNC_VISIBILITY ge::Status ProfSetStepInfo(uint64_t index_id, uint16_t tag_id, rtStream_t stream); | GE_FUNC_VISIBILITY ge::Status ProfSetStepInfo(uint64_t index_id, uint16_t tag_id, rtStream_t stream); | ||||
#endif // INC_FRAMEWORK_COMMON_GE_PROFILING_H_ | #endif // INC_FRAMEWORK_COMMON_GE_PROFILING_H_ |
@@ -16,6 +16,7 @@ | |||||
#include "toolchain/prof_engine.h" | #include "toolchain/prof_engine.h" | ||||
#include "toolchain/prof_mgr_core.h" | #include "toolchain/prof_mgr_core.h" | ||||
#include "runtime/base.h" | |||||
void * ProfMgrStartUp(const ProfMgrCfg *cfg) | void * ProfMgrStartUp(const ProfMgrCfg *cfg) | ||||
{ | { | ||||
@@ -32,3 +33,10 @@ int Msprof::Engine::RegisterEngine(const std::string& module, const Msprof::Engi | |||||
return 0; | return 0; | ||||
} | } | ||||
rtError_t rtSetMsprofReporterCallback(MsprofReporterCallback callback) { | |||||
return 0; | |||||
} | |||||
rtError_t rtRegDeviceStateCallback(const char *regName, rtDeviceStateCallback callback) { | |||||
return 0; | |||||
} |
@@ -158,6 +158,7 @@ set(COMMON_SRC_FILES | |||||
"${GE_CODE_DIR}/ge/opskernel_manager/ops_kernel_builder_manager.cc" | "${GE_CODE_DIR}/ge/opskernel_manager/ops_kernel_builder_manager.cc" | ||||
"${GE_CODE_DIR}/ge/graph/load/model_manager/model_manager.cc" | "${GE_CODE_DIR}/ge/graph/load/model_manager/model_manager.cc" | ||||
"${GE_CODE_DIR}/ge/common/profiling/profiling_manager.cc" | "${GE_CODE_DIR}/ge/common/profiling/profiling_manager.cc" | ||||
"${GE_CODE_DIR}/ge/common/profiling/ge_profiling.cc" | |||||
"${GE_CODE_DIR}/ge/graph/manager/host_mem_manager.cc" | "${GE_CODE_DIR}/ge/graph/manager/host_mem_manager.cc" | ||||
"${GE_CODE_DIR}/ge/graph/manager/memory_api.cc" | "${GE_CODE_DIR}/ge/graph/manager/memory_api.cc" | ||||
"${GE_CODE_DIR}/ge/session/inner_session.cc" | "${GE_CODE_DIR}/ge/session/inner_session.cc" | ||||
@@ -25,6 +25,7 @@ | |||||
#define private public | #define private public | ||||
#include "common/profiling/profiling_manager.h" | #include "common/profiling/profiling_manager.h" | ||||
#include "graph/ge_local_context.h" | #include "graph/ge_local_context.h" | ||||
#include "inc/framework/common/profiling/ge_profiling.h" | |||||
#undef protected | #undef protected | ||||
#undef private | #undef private | ||||
@@ -115,4 +116,20 @@ TEST_F(UtestGeProfilinganager, get_fp_bp_point_empty) { | |||||
ProfilingManager::Instance().GetFpBpPoint(fp_point, bp_point); | ProfilingManager::Instance().GetFpBpPoint(fp_point, bp_point); | ||||
EXPECT_EQ(fp_point, ""); | EXPECT_EQ(fp_point, ""); | ||||
EXPECT_EQ(bp_point, ""); | EXPECT_EQ(bp_point, ""); | ||||
} | |||||
} | |||||
TEST_F(UtestGeProfilinganager, set_step_info_success) { | |||||
uint64_t index_id = 0; | |||||
auto stream = (rtStream_t)0x1; | |||||
Status ret = ProfSetStepInfo(index_id, 0, stream); | |||||
EXPECT_EQ(ret, ge::SUCCESS); | |||||
ret = ProfSetStepInfo(index_id, 1, stream); | |||||
EXPECT_EQ(ret, ge::SUCCESS); | |||||
} | |||||
TEST_F(UtestGeProfilinganager, set_step_info_failed) { | |||||
uint64_t index_id = 0; | |||||
auto stream = (rtStream_t)0x1; | |||||
Status ret = ProfSetStepInfo(index_id, 1, stream); | |||||
EXPECT_EQ(ret, ge::FAILED); | |||||
} |