Browse Source

!24182 clean codex

Merge pull request !24182 from caifubi/master-clean-codex
tags/v1.6.0
i-robot Gitee 4 years ago
parent
commit
b690ae1b7a
20 changed files with 37 additions and 367 deletions
  1. +3
    -4
      mindspore/ccsrc/backend/kernel_compiler/aicpu/aicpu_kernel_build.cc
  2. +0
    -4
      mindspore/ccsrc/backend/kernel_compiler/host/host_kernel_mod.cc
  3. +4
    -4
      mindspore/ccsrc/backend/session/ascend_session.cc
  4. +1
    -1
      mindspore/ccsrc/backend/session/ascend_session.h
  5. +0
    -33
      mindspore/ccsrc/cxx_api/graph/ascend/ascend_stub.cc
  6. +0
    -2
      mindspore/ccsrc/runtime/device/ascend/ascend_bucket.cc
  7. +9
    -3
      mindspore/ccsrc/runtime/device/ascend/ascend_device_address.cc
  8. +3
    -6
      mindspore/ccsrc/runtime/device/ascend/ascend_kernel_runtime.cc
  9. +1
    -2
      mindspore/ccsrc/runtime/device/ascend/executor/ai_core_dynamic_kernel.cc
  10. +1
    -4
      mindspore/ccsrc/runtime/device/ascend/executor/ai_cpu_dynamic_kernel.cc
  11. +0
    -2
      mindspore/ccsrc/runtime/device/ascend/executor/hccl_dynamic_kernel.cc
  12. +0
    -130
      mindspore/ccsrc/runtime/device/ascend/profiling/profiling_callback_register.cc
  13. +0
    -82
      mindspore/ccsrc/runtime/device/ascend/profiling/profiling_callback_register.h
  14. +1
    -72
      mindspore/ccsrc/runtime/device/ascend/profiling/profiling_manager.cc
  15. +10
    -6
      mindspore/ccsrc/runtime/device/ascend/profiling/profiling_manager.h
  16. +2
    -1
      mindspore/ccsrc/runtime/device/ascend/profiling/reporter/desc_reporter.cc
  17. +0
    -2
      mindspore/ccsrc/runtime/device/ascend/profiling/reporter/graph_desc_reporter.cc
  18. +0
    -5
      mindspore/ccsrc/runtime/device/ascend/profiling/reporter/op_name_task_stream_reporter.cc
  19. +2
    -3
      mindspore/ccsrc/runtime/device/ascend/profiling/reporter/profiling_desc.cc
  20. +0
    -1
      mindspore/ccsrc/runtime/device/ascend/profiling/reporter/task_desc_reporter.cc

+ 3
- 4
mindspore/ccsrc/backend/kernel_compiler/aicpu/aicpu_kernel_build.cc View File

@@ -359,15 +359,15 @@ uint64_t SetExtInfoOutputShapeType(char *ext_info_buf, uint64_t ext_info_offset,
return ext_info_offset;
}

bool CreateExtInfo(const std::shared_ptr<AnfNode> &anf_node, const std::shared_ptr<AicpuOpKernelMod> &kernel_mod_ptr) {
void CreateExtInfo(const std::shared_ptr<AnfNode> &anf_node, const std::shared_ptr<AicpuOpKernelMod> &kernel_mod_ptr) {
MS_EXCEPTION_IF_NULL(anf_node);
MS_EXCEPTION_IF_NULL(kernel_mod_ptr);
if (!anf_node->isa<CNode>()) {
return true;
return;
}

if (!AnfAlgo::IsDynamicShape(anf_node)) {
return true;
return;
}

uint64_t ext_info_head_len = kExtInfoHeadSize;
@@ -401,7 +401,6 @@ bool CreateExtInfo(const std::shared_ptr<AnfNode> &anf_node, const std::shared_p
MS_LOG(INFO) << "Check ext_info_len:" << ext_info_len << " ext_info_offset:" << ext_info_offset;
// set ext info
kernel_mod_ptr->SetExtInfo(ext_info);
return true;
}

KernelModPtr AicpuOpBuild(const std::shared_ptr<AnfNode> &anf_node) {


+ 0
- 4
mindspore/ccsrc/backend/kernel_compiler/host/host_kernel_mod.cc View File

@@ -16,10 +16,6 @@
#include "backend/kernel_compiler/host/host_kernel_mod.h"
#include <memory>
#include <vector>
#include <string>
#include <utility>
#include "runtime/mem.h"
#include "utils/ms_context.h"
#include "backend/kernel_compiler/common_utils.h"


+ 4
- 4
mindspore/ccsrc/backend/session/ascend_session.cc View File

@@ -833,6 +833,7 @@ void AscendSession::BindAddressToTensor(
void AscendSession::LaunchFunc(const KernelGraphPtr &graph,
const std::map<tensor::TensorPtr, session::KernelWithIndex> &tensor_to_node,
bool is_dynamic_shape, const std::vector<tensor::TensorPtr> &input_tensors) {
MS_EXCEPTION_IF_NULL(graph);
// Wait for AllReduce
for (auto &tensor : input_tensors) {
if (tensor->NeedWaitDevice()) {
@@ -841,7 +842,7 @@ void AscendSession::LaunchFunc(const KernelGraphPtr &graph,
}

RunOpRemoveNopNode(graph);
RunOpMemoryAllocNew(input_tensors, tensor_to_node, graph.get());
RunOpMemoryAllocNew(input_tensors, tensor_to_node, *graph);
AnfAlgo::CacheAddrForGraph(graph);
// Bind Device Ptr to DeviceAddress of Tensor
BindAddressToTensor(tensor_to_node);
@@ -1485,11 +1486,10 @@ void AscendSession::RunOpMemoryAlloc(const std::vector<tensor::TensorPtr> &input

void AscendSession::RunOpMemoryAllocNew(const std::vector<tensor::TensorPtr> &input_tensors,
const std::map<tensor::TensorPtr, session::KernelWithIndex> &tensor_to_node,
KernelGraph *kernel_graph) const {
MS_EXCEPTION_IF_NULL(kernel_graph);
const KernelGraph &kernel_graph) const {
auto runtime_instance = device::KernelRuntimeManager::Instance().GetKernelRuntime(kAscendDevice, device_id_);
MS_EXCEPTION_IF_NULL(runtime_instance);
runtime_instance->RunOpAssignMemory(input_tensors, *kernel_graph, tensor_to_node);
runtime_instance->RunOpAssignMemory(input_tensors, kernel_graph, tensor_to_node);
}

void AscendSession::RunOpGenKernelEvent(const KernelGraph *graph) const {


+ 1
- 1
mindspore/ccsrc/backend/session/ascend_session.h View File

@@ -107,7 +107,7 @@ class AscendSession : public SessionBasic {
void RunOpMemoryAlloc(const std::vector<tensor::TensorPtr> &input_tensors, KernelGraph *kernel_graph) const;
void RunOpMemoryAllocNew(const std::vector<tensor::TensorPtr> &input_tensors,
const std::map<tensor::TensorPtr, session::KernelWithIndex> &tensor_to_node,
KernelGraph *kernel_graph) const;
const KernelGraph &kernel_graph) const;
void RunOpMemoryClear(const KernelGraph *kernel_graph) const;
void RunOpGenKernelEvent(const KernelGraph *graph) const;
void Load(const std::shared_ptr<KernelGraph> &kernel_graph) const;


+ 0
- 33
mindspore/ccsrc/cxx_api/graph/ascend/ascend_stub.cc View File

@@ -1,33 +0,0 @@
/**
* Copyright 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.
*/

#ifndef ENABLE_SECURITY
#include "runtime/device/ascend/profiling/profiling_callback_register.h"

VMCallbackRegister &VMCallbackRegister::GetInstance() {
static VMCallbackRegister instance;
return instance;
}

bool VMCallbackRegister::Register(Status (*pRegProfCtrlCallback)(MsprofCtrlCallback),
Status (*pRegProfSetDeviceCallback)(MsprofSetDeviceCallback),
Status (*pRegProfReporterCallback)(MsprofReporterCallback),
Status (*pProfCommandHandle)(ProfCommandHandleType, void *, uint32_t)) {
return false;
}

void VMCallbackRegister::ForceMsprofilerInit() {}
#endif

+ 0
- 2
mindspore/ccsrc/runtime/device/ascend/ascend_bucket.cc View File

@@ -16,8 +16,6 @@

#include "runtime/device/ascend/ascend_bucket.h"

#include <vector>
#include <memory>
#include "runtime/mem.h"
#include "external/hccl/hccl.h"
#include "runtime/device/ascend/ascend_memory_pool.h"


+ 9
- 3
mindspore/ccsrc/runtime/device/ascend/ascend_device_address.cc View File

@@ -95,7 +95,7 @@ void SyncMemory(void *dst, const void *src, uint64_t size, rtMemcpyKind_t kind)
}
}

bool DataSync(void *dst, uint64_t dst_size, const void *src, uint64_t src_size) {
bool DataSync(void *dst, const void *src, uint64_t src_size) {
if (dst == src) {
MS_LOG(INFO) << "dst addr is same with src addr, no need memcpy data.";
return true;
@@ -415,7 +415,7 @@ bool AscendDeviceAddress::SyncDeviceToDevice(const ShapeVector &, size_t size, T
}
bool sync_ok = false;
if (format_ == format && type_id_ == type) {
if (!DataSync(ptr_, size_, src_ptr, size)) {
if (!DataSync(ptr_, src_ptr, size)) {
MS_LOG(ERROR) << "DataSync failed!";
return false;
}
@@ -491,7 +491,13 @@ void AscendDeviceAddress::ClearDeviceMemory() {
}
}

AscendDeviceAddress::~AscendDeviceAddress() { ClearDeviceMemory(); }
AscendDeviceAddress::~AscendDeviceAddress() {
try {
ClearDeviceMemory();
} catch (const std::exception &e) {
MS_LOG(ERROR) << "AscendDeviceAddress destructor failed: " << e.what();
}
}

#ifndef ENABLE_SECURITY
bool AscendDeviceAddress::DumpMemToFile(const std::string &filepath, const std::string &host_fmt,


+ 3
- 6
mindspore/ccsrc/runtime/device/ascend/ascend_kernel_runtime.cc View File

@@ -59,7 +59,6 @@
#include "utils/config_manager.h"
#include "runtime/device/ascend/profiling/reporter/op_name_task_stream_reporter.h"
#include "runtime/hccl_adapter/hccl_adapter.h"
#include "runtime/device/ascend/profiling/profiling_callback_register.h"
#ifdef ENABLE_TDTQUE
#include "minddata/dataset/engine/tdt/tdt_handle.h"
using mindspore::dataset::TdtHandle;
@@ -370,7 +369,7 @@ bool AscendKernelRuntime::Init() {
return true;
}

bool AscendKernelRuntime::LoadData(const session::KernelGraph &graph) {
bool AscendKernelRuntime::LoadData(const session::KernelGraph & /*graph*/) {
#ifdef ENABLE_DEBUGGER
MS_LOG(INFO) << "Start load step";
MS_EXCEPTION_IF_NULL(debugger_);
@@ -1079,11 +1078,9 @@ bool AscendKernelRuntime::HcclInit() {
auto mode = context_ptr->get_param<int>(MS_CTX_EXECUTION_MODE);
if (!is_task_sink && mode == kGraphMode) {
(void)hccl::HcclAdapter::GetInstance().InitHccl();
std::vector<unsigned int> ranks;
auto rank_size = HcclCollectiveGroup::instance().GetRankSize();
for (size_t i = 0; i < IntToSize(rank_size); ++i) {
ranks.push_back(i);
}
std::vector<unsigned int> ranks(rank_size);
std::iota(std::begin(ranks), std::end(ranks), 0);
HcclCollectiveGroup::instance().CreateCommGroup(kHcclWorldGroup, ranks);
return true;
}


+ 1
- 2
mindspore/ccsrc/runtime/device/ascend/executor/ai_core_dynamic_kernel.cc View File

@@ -15,8 +15,7 @@
*/

#include "runtime/device/ascend/executor/ai_core_dynamic_kernel.h"
#include <algorithm>
#include <memory>

#include "framework/common/debug/log.h"
#include "utils/log_adapter.h"
#include "register/op_tiling.h"


+ 1
- 4
mindspore/ccsrc/runtime/device/ascend/executor/ai_cpu_dynamic_kernel.cc View File

@@ -15,10 +15,7 @@
*/

#include "runtime/device/ascend/executor/ai_cpu_dynamic_kernel.h"
#include <vector>
#include <memory>
#include <set>
#include <algorithm>

#include "runtime/mem.h"
#include "runtime/kernel.h"
#include "utils/utils.h"


+ 0
- 2
mindspore/ccsrc/runtime/device/ascend/executor/hccl_dynamic_kernel.cc View File

@@ -16,8 +16,6 @@

#include "runtime/device/ascend/executor/hccl_dynamic_kernel.h"

#include <dlfcn.h>
#include <vector>
#include "hccl/hcom.h"
#include "common/opskernel/ge_task_info.h"
#include "utils/log_adapter.h"


+ 0
- 130
mindspore/ccsrc/runtime/device/ascend/profiling/profiling_callback_register.cc View File

@@ -1,130 +0,0 @@
/**
* Copyright 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 "runtime/device/ascend/profiling/profiling_callback_register.h"
#include "utils/convert_utils_base.h"

namespace Analysis {
namespace Dvvp {
namespace ProfilerSpecial {
extern int32_t MsprofilerInit();
} // namespace ProfilerSpecial
} // namespace Dvvp
} // namespace Analysis

namespace {
constexpr Status PROF_SUCCESS = 0;
constexpr Status PROF_FAILED = 0xFFFFFFFF;
} // namespace

int32_t _aclprofGetDeviceByModelId(uint32_t, uint32_t &) { return 0; }

bool _aclprofGetInitFlag() { return true; }

int32_t _aclprofRegisterCtrlCallback(MsprofCtrlCallback callback) {
if (VMCallbackRegister::GetInstance().registered()) {
return mindspore::UintToInt(VMCallbackRegister::GetInstance().DoRegProfCtrlCallback(callback));
} else {
return mindspore::UintToInt(PROF_SUCCESS);
}
}

int32_t _aclprofRegisterSetDeviceCallback(MsprofSetDeviceCallback callback) {
if (VMCallbackRegister::GetInstance().registered()) {
return mindspore::UintToInt(VMCallbackRegister::GetInstance().DoRegProfSetDeviceCallback(callback));
} else {
return mindspore::UintToInt(PROF_SUCCESS);
}
}

int32_t _aclprofRegisterReporterCallback(MsprofReporterCallback callback) {
if (VMCallbackRegister::GetInstance().registered()) {
return mindspore::UintToInt(VMCallbackRegister::GetInstance().DoRegProfReporterCallback(callback));
} else {
return mindspore::UintToInt(PROF_SUCCESS);
}
}

int32_t _aclprofCommandHandle(uint32_t type, void *data, uint32_t len) {
if (VMCallbackRegister::GetInstance().registered()) {
return mindspore::UintToInt(
VMCallbackRegister::GetInstance().DoProfCommandHandle((ProfCommandHandleType)type, data, len));
} else {
return mindspore::UintToInt(PROF_SUCCESS);
}
}

Status RegProfCtrlCallback(MsprofCtrlCallback func) {
if (VMCallbackRegister::GetInstance().registered()) {
return VMCallbackRegister::GetInstance().DoRegProfCtrlCallback(func);
} else {
return PROF_SUCCESS;
}
}

Status RegProfSetDeviceCallback(MsprofSetDeviceCallback func) {
if (VMCallbackRegister::GetInstance().registered()) {
return VMCallbackRegister::GetInstance().DoRegProfSetDeviceCallback(func);
} else {
return PROF_SUCCESS;
}
}

Status RegProfReporterCallback(MsprofReporterCallback func) {
if (VMCallbackRegister::GetInstance().registered()) {
return VMCallbackRegister::GetInstance().DoRegProfReporterCallback(func);
} else {
return PROF_SUCCESS;
}
}

Status ProfCommandHandle(ProfCommandHandleType type, void *data, uint32_t len) {
if (VMCallbackRegister::GetInstance().registered()) {
return VMCallbackRegister::GetInstance().DoProfCommandHandle(type, data, len);
} else {
return PROF_SUCCESS;
}
}

bool IsInitialize() { return true; }

VMCallbackRegister &VMCallbackRegister::GetInstance() {
static VMCallbackRegister instance{};
return instance;
}

bool VMCallbackRegister::Register(Status (*pRegProfCtrlCallback)(MsprofCtrlCallback),
Status (*pRegProfSetDeviceCallback)(MsprofSetDeviceCallback),
Status (*pRegProfReporterCallback)(MsprofReporterCallback),
Status (*pProfCommandHandle)(ProfCommandHandleType, void *, uint32_t)) {
if (!registered_) {
pRegProfCtrlCallback_ = pRegProfCtrlCallback;
pRegProfSetDeviceCallback_ = pRegProfSetDeviceCallback;
pRegProfReporterCallback_ = pRegProfReporterCallback;
pProfCommandHandle_ = pProfCommandHandle;
registered_ = true;
ForceMsprofilerInit();
return true;
}
return false;
}

void VMCallbackRegister::ForceMsprofilerInit() {
if (!ms_profile_inited_) {
Analysis::Dvvp::ProfilerSpecial::MsprofilerInit();
ms_profile_inited_ = true;
}
}

+ 0
- 82
mindspore/ccsrc/runtime/device/ascend/profiling/profiling_callback_register.h View File

@@ -1,82 +0,0 @@
/**
* Copyright 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.
*/

#ifndef MINDSPORE_CCSRC_RUNTIME_DEVICE_ASCEND_PROFILING_PROFILING_CALLBACK_REGISTER_H_
#define MINDSPORE_CCSRC_RUNTIME_DEVICE_ASCEND_PROFILING_PROFILING_CALLBACK_REGISTER_H_

#include "toolchain/prof_callback.h"
#include "toolchain/prof_acl_api.h"

#define MAX_DEV_NUM (64)

enum ProfCommandHandleType {
kProfCommandhandleInit = 0,
kProfCommandhandleStart,
kProfCommandhandleStop,
kProfCommandhandleFinalize,
kProfCommandhandleModelSubscribe,
kProfCommandhandleModelUnsubscribe
};

struct ProfCommandHandleData {
uint64_t profSwitch;
uint32_t devNums; // length of device id list
uint32_t devIdList[MAX_DEV_NUM];
uint32_t modelId;
};

Status RegProfCtrlCallback(MsprofCtrlCallback func);
Status RegProfSetDeviceCallback(MsprofSetDeviceCallback func);
Status RegProfReporterCallback(MsprofReporterCallback func);
Status ProfCommandHandle(ProfCommandHandleType type, void *data, uint32_t len);
bool IsInitialize();

class __attribute__((visibility("default"))) VMCallbackRegister {
public:
static VMCallbackRegister &GetInstance();
VMCallbackRegister(const VMCallbackRegister &) = delete;
VMCallbackRegister &operator=(const VMCallbackRegister &) = delete;
bool Register(Status (*pRegProfCtrlCallback)(MsprofCtrlCallback),
Status (*pRegProfSetDeviceCallback)(MsprofSetDeviceCallback),
Status (*pRegProfReporterCallback)(MsprofReporterCallback),
Status (*pProfCommandHandle)(ProfCommandHandleType, void *, uint32_t));
void ForceMsprofilerInit();
bool registered() { return registered_; }
Status DoRegProfCtrlCallback(MsprofCtrlCallback func) { return pRegProfCtrlCallback_(func); }
Status DoRegProfSetDeviceCallback(MsprofSetDeviceCallback func) { return pRegProfSetDeviceCallback_(func); }
Status DoRegProfReporterCallback(MsprofReporterCallback func) { return pRegProfReporterCallback_(func); }
Status DoProfCommandHandle(ProfCommandHandleType type, void *data, uint32_t len) {
return pProfCommandHandle_(type, data, len);
}

private:
VMCallbackRegister()
: registered_(false),
ms_profile_inited_(false),
pRegProfCtrlCallback_(nullptr),
pRegProfSetDeviceCallback_(nullptr),
pRegProfReporterCallback_(nullptr),
pProfCommandHandle_(nullptr) {}
~VMCallbackRegister() = default;

bool registered_;
bool ms_profile_inited_;
Status (*pRegProfCtrlCallback_)(MsprofCtrlCallback);
Status (*pRegProfSetDeviceCallback_)(MsprofSetDeviceCallback);
Status (*pRegProfReporterCallback_)(MsprofReporterCallback);
Status (*pProfCommandHandle_)(ProfCommandHandleType, void *, uint32_t);
};
#endif // MINDSPORE_CCSRC_RUNTIME_DEVICE_ASCEND_PROFILING_PROFILING_CALLBACK_REGISTER_H_

+ 1
- 72
mindspore/ccsrc/runtime/device/ascend/profiling/profiling_manager.cc View File

@@ -24,12 +24,9 @@
#include "utils/ms_utils.h"
#include "utils/convert_utils.h"
#include "runtime/base.h"
#include "runtime/device/ascend/profiling/profiling_callback_register.h"
#include <nlohmann/json.hpp>

namespace {
constexpr int32_t kProfilingDeviceNum = 1;
constexpr auto kRtSetDeviceRegName = "profiling";
constexpr Status PROF_SUCCESS = 0;
constexpr Status PROF_FAILED = 0xFFFFFFFF;
} // namespace
@@ -46,38 +43,6 @@ ProfilingManager::ProfilingManager() : device_id_(0), prof_cb_({0}), hccl_enable

uint64_t ProfilingManager::GetJobId() const { return 0; }

bool ProfilingManager::ReportProfilingData(const map<uint32_t, string> &op_taskId_map) const {
if (!IsProfiling()) {
MS_LOG(INFO) << "No need profiling. please export PROFILING_MODE and in train mode.";
return false;
}
if (op_taskId_map.empty()) {
MS_LOG(WARNING) << "op_taskId_map is empty.";
return false;
}

MS_LOG(INFO) << "DistributeTask: op tasId map size = " << op_taskId_map.size();

ReporterData reporter_data = {};
for (const auto &iter : op_taskId_map) {
auto data = iter.second + ' ' + std::to_string(iter.first) + ';';
reporter_data.deviceId = UintToInt(device_id_);
reporter_data.data = (unsigned char *)(const_cast<char *>(data.c_str()));
reporter_data.dataLen = data.size();
auto ret = memcpy_s(reporter_data.tag, MSPROF_ENGINE_MAX_TAG_LEN + 1, "framework", sizeof("framework"));
if (ret != 0) {
MS_LOG(ERROR) << "memcpy_s error, errorno(" << ret << ")";
return false;
}
int32_t cb_ret = CallMsprofReport(NOT_NULL(&reporter_data));
if (cb_ret != 0) {
MS_LOG(ERROR) << "reporter data fail, errorno(" << cb_ret << ")";
return false;
}
}
return true;
}

uint64_t GetProfilingModule() {
return PROF_MODEL_EXECUTE_MASK | PROF_RUNTIME_API_MASK | PROF_RUNTIME_TRACE_MASK | PROF_SCHEDULE_TIMELINE_MASK |
PROF_SCHEDULE_TRACE_MASK | PROF_TASK_TIME_MASK | PROF_SUBTASK_TIME_MASK | PROF_AICPU_TRACE_MASK |
@@ -173,12 +138,6 @@ bool ProfilingManager::StartupProfiling(uint32_t device_id) {
return true;
}

uint32_t GetCurrentDeviceId() {
auto context = MsContext::GetInstance();
MS_EXCEPTION_IF_NULL(context);
return context->get_param<uint32_t>(MS_CTX_DEVICE_ID);
}

bool ProfilingManager::ProfStartUp(const NotNull<MsprofGeOptions *> prof_conf) const {
MS_LOG(INFO) << "Prof start up. ";

@@ -209,7 +168,7 @@ bool ProfilingManager::ProfRegisterCtrlCallback() const {
return true;
}

rtError_t CtrlCallbackHandle(uint32_t rt_type, void *data, uint32_t len) {
rtError_t CtrlCallbackHandle(uint32_t rt_type, void *data, uint32_t /*len*/) {
if (rt_type == RT_PROF_CTRL_REPORTER) {
ProfilingManager::GetInstance().SetMsprofReporterCallback(reinterpret_cast<MsprofReporterCallback>(data));
MS_LOG(INFO) << "Set MsprofReporterCallback success.";
@@ -252,36 +211,6 @@ Status ProfilingManager::CallMsprofReport(const NotNull<ReporterData *> reporter
static_cast<void *>(reporter_data.get()), sizeof(ReporterData));
}

Status RegProfCtrlCallback(MsprofCtrlCallback func) {
if (func == nullptr) {
MS_LOG(ERROR) << "Msprof ctrl callback is nullptr.";
return PROF_FAILED;
}
if (ProfilingManager::GetInstance().GetMsprofCallback().msprofCtrlCallback != nullptr) {
MS_LOG(WARNING) << "Msprof ctrl callback is exist, just ignore it.";
} else {
MS_LOG(INFO) << "GE register Msprof ctrl callback.";
ProfilingManager::GetInstance().SetMsprofCtrlCallback(func);
}
return PROF_SUCCESS;
}

Status RegProfSetDeviceCallback(MsprofSetDeviceCallback func) {
if (func == nullptr) {
MS_LOG(ERROR) << "MsprofSetDeviceCallback callback is nullptr.";
return PROF_FAILED;
}
ProfilingManager::GetInstance().SetMsprofSetDeviceCallback(func);
// Pass MsprofSetDeviceCallback to runtime
MS_LOG(INFO) << "GE pass setdevice callback to runtime.";
rtError_t rt_ret = rtRegDeviceStateCallback(kRtSetDeviceRegName, static_cast<rtDeviceStateCallback>(func));
if (rt_ret != UintToInt(PROF_SUCCESS)) {
MS_LOG(WARNING) << "Pass MsprofSetDeviceCallback to runtime failed.";
return IntToUint(rt_ret);
}
return PROF_SUCCESS;
}

Status ProfCtrlSwitchHandle(void *data) {
if (data == nullptr) {
MS_LOG(ERROR) << "Ctrl switch handl data is nullptr.";


+ 10
- 6
mindspore/ccsrc/runtime/device/ascend/profiling/profiling_manager.h View File

@@ -27,7 +27,6 @@
#include "toolchain/prof_acl_api.h"
#include "toolchain/slog.h"
#include "runtime/base.h"
#include "runtime/device/ascend/profiling/profiling_callback_register.h"
#include "profiler/device/profiling.h"

using std::map;
@@ -42,11 +41,19 @@ struct MsprofCallback {
MsprofReporterCallback msprofReporterCallback;
};

enum ProfCommandHandleType {
kProfCommandhandleInit = 0,
kProfCommandhandleStart,
kProfCommandhandleStop,
kProfCommandhandleFinalize,
kProfCommandhandleModelSubscribe,
kProfCommandhandleModelUnsubscribe
};

class ProfilingManager {
public:
static ProfilingManager &GetInstance();
uint64_t GetJobId() const;
bool ReportProfilingData(const map<uint32_t, string> &op_taskId_map) const;
bool ProfRegisterCtrlCallback() const;
bool StartupProfiling(uint32_t device_id);
bool StopProfiling() const;
@@ -77,11 +84,8 @@ class ProfilingManager {
bool hccl_enabled_bef_profiling_enabled_;
};

Status RegProfCtrlCallback(MsprofCtrlCallback func);
Status RegProfSetDeviceCallback(MsprofSetDeviceCallback func);
Status RegProfReporterCallback(MsprofReporterCallback func);
Status ProfCommandHandle(ProfCommandHandleType type);
rtError_t CtrlCallbackHandle(uint32_t rt_type, void *data, uint32_t len);
rtError_t CtrlCallbackHandle(uint32_t rt_type, void *data, uint32_t /*len*/);
Status ProfCtrlSwitchHandle(void *data);
} // namespace ascend
} // namespace device


+ 2
- 1
mindspore/ccsrc/runtime/device/ascend/profiling/reporter/desc_reporter.cc View File

@@ -19,8 +19,9 @@
#include "runtime/device/ascend/profiling/profiling_manager.h"
#include "utils/log_adapter.h"

namespace {
constexpr size_t kReportMaxLen = 1024;
}
namespace mindspore {
namespace device {
namespace ascend {


+ 0
- 2
mindspore/ccsrc/runtime/device/ascend/profiling/reporter/graph_desc_reporter.cc View File

@@ -14,8 +14,6 @@
* limitations under the License.
*/

#include <vector>
#include <memory>
#include "runtime/device/ascend/profiling/reporter/graph_desc_reporter.h"
#include "backend/session/anf_runtime_algorithm.h"



+ 0
- 5
mindspore/ccsrc/runtime/device/ascend/profiling/reporter/op_name_task_stream_reporter.cc View File

@@ -15,11 +15,6 @@
*/

#include "runtime/device/ascend/profiling/reporter/op_name_task_stream_reporter.h"
#include <map>
#include <string>
#include <vector>
#include <memory>
#include "runtime/device/ascend/profiling/reporter/task_desc_reporter.h"

namespace mindspore {
namespace device {


+ 2
- 3
mindspore/ccsrc/runtime/device/ascend/profiling/reporter/profiling_desc.cc View File

@@ -13,11 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <iostream>

#include "runtime/device/ascend/profiling/reporter/profiling_desc.h"
#include <iterator>
#include <sstream>
#include <algorithm>
#include "runtime/device/ascend/profiling/reporter/profiling_desc.h"

namespace mindspore {
namespace device {


+ 0
- 1
mindspore/ccsrc/runtime/device/ascend/profiling/reporter/task_desc_reporter.cc View File

@@ -14,7 +14,6 @@
* limitations under the License.
*/

#include <memory>
#include "runtime/device/ascend/profiling/reporter/task_desc_reporter.h"
#include "backend/session/anf_runtime_algorithm.h"
#include "backend/kernel_compiler/ascend_kernel_mod.h"


Loading…
Cancel
Save