Browse Source

step info

Signed-off-by: zhupuxu <zhupuxu@huawei.com>
tags/v1.5.1
zhupuxu 3 years ago
parent
commit
27a9d527f9
5 changed files with 69 additions and 3 deletions
  1. +37
    -2
      ge/common/profiling/ge_profiling.cc
  2. +5
    -0
      inc/framework/common/profiling/ge_profiling.h
  3. +8
    -0
      tests/depends/profiler/src/profiler_stub.cc
  4. +1
    -0
      tests/ut/ge/CMakeLists.txt
  5. +18
    -1
      tests/ut/ge/profiling/ge_profiling_manager_unittest.cc

+ 37
- 2
ge/common/profiling/ge_profiling.cc View File

@@ -22,6 +22,7 @@
#include "graph/load/graph_loader.h"
#include "init/gelib.h"
#include "framework/common/ge_inner_error_codes.h"
#include "model/ge_model.h"

namespace {
const uint32_t kDeviceListIndex = 3;
@@ -42,6 +43,10 @@ const std::map<ProfCommandHandleType, std::string> kProfCommandTypeMap = {
{kProfCommandhandleFinalize, kProfilingFinalize},
{kProfCommandhandleModelSubscribe, kProfModelSubscribe},
{kProfCommandhandleModelUnsubscribe, kProfModelUnsubscribe}};

const uint64_t kModelId = ge::INVALID_MODEL_ID;
const uint16_t kStepStart = 0;
const uint16_t kStepEnd = 1;
} // namespace

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;
}

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;
}

+ 5
- 0
inc/framework/common/profiling/ge_profiling.h View File

@@ -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 RegProfReporterCallback(MsprofReporterCallback func);
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);

#endif // INC_FRAMEWORK_COMMON_GE_PROFILING_H_

+ 8
- 0
tests/depends/profiler/src/profiler_stub.cc View File

@@ -16,6 +16,7 @@

#include "toolchain/prof_engine.h"
#include "toolchain/prof_mgr_core.h"
#include "runtime/base.h"

void * ProfMgrStartUp(const ProfMgrCfg *cfg)
{
@@ -32,3 +33,10 @@ int Msprof::Engine::RegisterEngine(const std::string& module, const Msprof::Engi
return 0;
}

rtError_t rtSetMsprofReporterCallback(MsprofReporterCallback callback) {
return 0;
}

rtError_t rtRegDeviceStateCallback(const char *regName, rtDeviceStateCallback callback) {
return 0;
}

+ 1
- 0
tests/ut/ge/CMakeLists.txt View File

@@ -158,6 +158,7 @@ set(COMMON_SRC_FILES
"${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/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/memory_api.cc"
"${GE_CODE_DIR}/ge/session/inner_session.cc"


+ 18
- 1
tests/ut/ge/profiling/ge_profiling_manager_unittest.cc View File

@@ -25,6 +25,7 @@
#define private public
#include "common/profiling/profiling_manager.h"
#include "graph/ge_local_context.h"
#include "inc/framework/common/profiling/ge_profiling.h"
#undef protected
#undef private

@@ -115,4 +116,20 @@ TEST_F(UtestGeProfilinganager, get_fp_bp_point_empty) {
ProfilingManager::Instance().GetFpBpPoint(fp_point, bp_point);
EXPECT_EQ(fp_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);
}

Loading…
Cancel
Save