forked from huawei/mindspore2022
code clean
Signed-off-by: zhoufeng <zhoufeng54@huawei.com>
This commit is contained in:
parent
aeaf2d14b3
commit
a2114f29eb
|
|
@ -60,7 +60,7 @@ std::shared_ptr<HcclKernel> HcclKernelFactory::Get(const std::string &name) {
|
|||
}
|
||||
|
||||
HcclKernelFactory &HcclKernelFactory::Get() {
|
||||
static HcclKernelFactory _this;
|
||||
static HcclKernelFactory _this{};
|
||||
return _this;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ void DynamicShapeKernel::Execute() {
|
|||
auto data_ptr = static_cast<int64_t *>(output_tensor_for_sync->data_c());
|
||||
for (size_t i = 0; i < prev_output_shape.size(); ++i) {
|
||||
MS_LOG(INFO) << "DEBUG prev_output_shape[" << i << "]:" << prev_output_shape[i];
|
||||
*(data_ptr + i) = prev_output_shape[i];
|
||||
*(data_ptr + i) = SizeToLong(prev_output_shape[i]);
|
||||
}
|
||||
|
||||
auto output_addr = AnfAlgo::GetOutputAddr(cnode, 0);
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ std::shared_ptr<HostKernelMod> HostKernelFactory::Get(const std::string &name) {
|
|||
}
|
||||
|
||||
HostKernelFactory &HostKernelFactory::Get() {
|
||||
static HostKernelFactory instance;
|
||||
static HostKernelFactory instance{};
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
|
@ -76,8 +76,8 @@ bool HostKernelMod::Init(const AnfNodePtr &anf_node) {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
bool HostKernelMod::Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &workspace,
|
||||
const std::vector<AddressPtr> &outputs, void *stream_ptr) {
|
||||
bool HostKernelMod::Launch(const std::vector<AddressPtr> &, const std::vector<AddressPtr> &,
|
||||
const std::vector<AddressPtr> &, void *) {
|
||||
return true;
|
||||
}
|
||||
std::vector<TaskInfoPtr> HostKernelMod::GenTask(const std::vector<AddressPtr> &, const std::vector<AddressPtr> &,
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include "utils/convert_utils_base.h"
|
||||
|
||||
namespace mindspore {
|
||||
DuplexPipe::~DuplexPipe() {
|
||||
|
|
@ -29,7 +30,7 @@ DuplexPipe::~DuplexPipe() {
|
|||
}
|
||||
}
|
||||
|
||||
int DuplexPipe::Open(std::initializer_list<std::string> arg_list, bool append_fds) {
|
||||
int DuplexPipe::Open(const std::initializer_list<std::string> &arg_list, bool append_fds) {
|
||||
if (pipe(fd1_) == -1) {
|
||||
DP_EXCEPTION << "pipe 1 failed, errno: " << errno;
|
||||
}
|
||||
|
|
@ -80,7 +81,7 @@ int DuplexPipe::Open(std::initializer_list<std::string> arg_list, bool append_fd
|
|||
return 0;
|
||||
}
|
||||
|
||||
void DuplexPipe::Write(const std::string &buf, bool flush) {
|
||||
void DuplexPipe::Write(const std::string &buf, bool flush) const {
|
||||
// Write the string into pipe
|
||||
if (write(fd1_[1], buf.data(), buf.size()) == -1) {
|
||||
DP_ERROR << "write failed, errno: " << errno;
|
||||
|
|
@ -108,7 +109,7 @@ std::string DuplexPipe::Read() {
|
|||
}
|
||||
CancelTimeOut();
|
||||
bool line_end = c_buf_[size - 1] == '\n';
|
||||
buf.append(c_buf_, line_end ? size - 1 : size); // Copy without the last '\n'
|
||||
buf.append(c_buf_, LongToSize(line_end ? size - 1 : size)); // Copy without the last '\n'
|
||||
if (line_end) {
|
||||
break;
|
||||
}
|
||||
|
|
@ -166,12 +167,12 @@ DuplexPipe::SignalHandler::SignalHandler(const std::weak_ptr<DuplexPipe> &dp, pi
|
|||
|
||||
DuplexPipe::SignalHandler::~SignalHandler() {}
|
||||
|
||||
void DuplexPipe::SignalHandler::SetAlarm(unsigned int interval_secs) {
|
||||
void DuplexPipe::SignalHandler::SetAlarm(unsigned int interval_secs) const {
|
||||
signal(SIGALRM, SigAlarmHandler);
|
||||
alarm(interval_secs);
|
||||
}
|
||||
|
||||
void DuplexPipe::SignalHandler::CancelAlarm() { alarm(0); }
|
||||
void DuplexPipe::SignalHandler::CancelAlarm() const { alarm(0); }
|
||||
|
||||
void DuplexPipe::SignalHandler::SigAlarmHandler(int sig) {
|
||||
DP_INFO << "Signal: " << sig << ", child_pid_: " << child_pid_;
|
||||
|
|
@ -196,6 +197,7 @@ void DuplexPipe::SignalHandler::SigPipeHandler(int sig) {
|
|||
}
|
||||
|
||||
void DuplexPipe::SignalHandler::SigChildHandler(int sig) {
|
||||
DP_INFO << "Signal: " << sig << ", child_pid_: " << child_pid_;
|
||||
int status;
|
||||
if (child_pid_ != nullptr) {
|
||||
(void)waitpid(*child_pid_, &status, WNOHANG | WUNTRACED);
|
||||
|
|
|
|||
|
|
@ -42,14 +42,14 @@ class DuplexPipe : public std::enable_shared_from_this<mindspore::DuplexPipe> {
|
|||
~DuplexPipe();
|
||||
|
||||
// Create a subprocess and open a duplex pipe between local and remote
|
||||
int Open(std::initializer_list<std::string> arg_list, bool append_fds = false);
|
||||
int Open(const std::initializer_list<std::string> &arg_list, bool append_fds = false);
|
||||
void Close();
|
||||
void SetTimeOutSeconds(unsigned int secs) { time_out_secs_ = secs; }
|
||||
void SetTimeOutCallback(const std::shared_ptr<std::function<void()>> cb) { time_out_callback_ = cb; }
|
||||
void SetFinalizeCallback(const std::shared_ptr<std::function<void()>> cb) { finalize_callback_ = cb; }
|
||||
|
||||
// Write the 'buf' to remote stdin
|
||||
void Write(const std::string &buf, bool flush = true);
|
||||
void Write(const std::string &buf, bool flush = true) const;
|
||||
// Read from remote stdout/stderr into 'c_buf_'
|
||||
std::string Read();
|
||||
|
||||
|
|
@ -108,8 +108,8 @@ class DuplexPipe : public std::enable_shared_from_this<mindspore::DuplexPipe> {
|
|||
SignalHandler(const std::weak_ptr<DuplexPipe> &dp, pid_t *pid);
|
||||
~SignalHandler();
|
||||
|
||||
void SetAlarm(unsigned int interval_secs);
|
||||
void CancelAlarm();
|
||||
void SetAlarm(unsigned int interval_secs) const;
|
||||
void CancelAlarm() const;
|
||||
|
||||
private:
|
||||
static void SigAlarmHandler(int sig);
|
||||
|
|
|
|||
|
|
@ -20,11 +20,11 @@
|
|||
#include <vector>
|
||||
|
||||
namespace mindspore {
|
||||
int DuplexPipe::Open(std::initializer_list<std::string> arg_list, bool append_fds) {
|
||||
int DuplexPipe::Open(const std::initializer_list<std::string> &arg_list, bool append_fds) {
|
||||
DP_EXCEPTION << "Not support for Windows by now.";
|
||||
}
|
||||
|
||||
void DuplexPipe::Write(const std::string &buf, bool flush) { DP_EXCEPTION << "Not support for Windows by now."; }
|
||||
void DuplexPipe::Write(const std::string &buf, bool flush) const { DP_EXCEPTION << "Not support for Windows by now."; }
|
||||
|
||||
std::string DuplexPipe::Read() { DP_EXCEPTION << "Not support for Windows by now."; }
|
||||
|
||||
|
|
@ -40,9 +40,9 @@ DuplexPipe &DuplexPipe::operator>>(std::string &buf) { DP_EXCEPTION << "Not supp
|
|||
|
||||
void DuplexPipe::Close() { DP_EXCEPTION << "Not support for Windows by now."; }
|
||||
|
||||
void DuplexPipe::SignalHandler::SetAlarm(unsigned int interval_secs) {
|
||||
void DuplexPipe::SignalHandler::SetAlarm(unsigned int interval_secs) const {
|
||||
DP_EXCEPTION << "Not support for Windows by now.";
|
||||
}
|
||||
|
||||
void DuplexPipe::SignalHandler::CancelAlarm() { DP_EXCEPTION << "Not support for Windows by now."; }
|
||||
void DuplexPipe::SignalHandler::CancelAlarm() const { DP_EXCEPTION << "Not support for Windows by now."; }
|
||||
} // namespace mindspore
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
|
||||
#include "runtime/device/ascend/profiling/profiling_callback_register.h"
|
||||
#include "runtime/base.h"
|
||||
#include "utils/convert_utils_base.h"
|
||||
|
||||
namespace Analysis {
|
||||
namespace Dvvp {
|
||||
|
|
@ -30,39 +30,40 @@ constexpr Status PROF_SUCCESS = 0;
|
|||
constexpr Status PROF_FAILED = 0xFFFFFFFF;
|
||||
} // namespace
|
||||
|
||||
int32_t _aclprofGetDeviceByModelId(uint32_t modelId, uint32_t &deviceId) { return 0; }
|
||||
int32_t _aclprofGetDeviceByModelId(uint32_t, uint32_t &) { return 0; }
|
||||
|
||||
bool _aclprofGetInitFlag() { return true; }
|
||||
|
||||
int32_t _aclprofRegisterCtrlCallback(MsprofCtrlCallback callback) {
|
||||
if (VMCallbackRegister::GetInstance().registered()) {
|
||||
return VMCallbackRegister::GetInstance().DoRegProfCtrlCallback(callback);
|
||||
return mindspore::UintToInt(VMCallbackRegister::GetInstance().DoRegProfCtrlCallback(callback));
|
||||
} else {
|
||||
return PROF_SUCCESS;
|
||||
return mindspore::UintToInt(PROF_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t _aclprofRegisterSetDeviceCallback(MsprofSetDeviceCallback callback) {
|
||||
if (VMCallbackRegister::GetInstance().registered()) {
|
||||
return VMCallbackRegister::GetInstance().DoRegProfSetDeviceCallback(callback);
|
||||
return mindspore::UintToInt(VMCallbackRegister::GetInstance().DoRegProfSetDeviceCallback(callback));
|
||||
} else {
|
||||
return PROF_SUCCESS;
|
||||
return mindspore::UintToInt(PROF_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t _aclprofRegisterReporterCallback(MsprofReporterCallback callback) {
|
||||
if (VMCallbackRegister::GetInstance().registered()) {
|
||||
return VMCallbackRegister::GetInstance().DoRegProfReporterCallback(callback);
|
||||
return mindspore::UintToInt(VMCallbackRegister::GetInstance().DoRegProfReporterCallback(callback));
|
||||
} else {
|
||||
return PROF_SUCCESS;
|
||||
return mindspore::UintToInt(PROF_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t _aclprofCommandHandle(uint32_t type, void *data, uint32_t len) {
|
||||
if (VMCallbackRegister::GetInstance().registered()) {
|
||||
return VMCallbackRegister::GetInstance().DoProfCommandHandle((ProfCommandHandleType)type, data, len);
|
||||
return mindspore::UintToInt(
|
||||
VMCallbackRegister::GetInstance().DoProfCommandHandle((ProfCommandHandleType)type, data, len));
|
||||
} else {
|
||||
return PROF_SUCCESS;
|
||||
return mindspore::UintToInt(PROF_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -101,7 +102,7 @@ Status ProfCommandHandle(ProfCommandHandleType type, void *data, uint32_t len) {
|
|||
bool IsInitialize() { return true; }
|
||||
|
||||
VMCallbackRegister &VMCallbackRegister::GetInstance() {
|
||||
static VMCallbackRegister instance;
|
||||
static VMCallbackRegister instance{};
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
#include "runtime/device/ascend/profiling/profiling_callback_register.h"
|
||||
|
||||
namespace {
|
||||
constexpr uint32_t kProfilingDeviceNum = 1;
|
||||
constexpr int32_t kProfilingDeviceNum = 1;
|
||||
constexpr auto kRtSetDeviceRegName = "profiling";
|
||||
constexpr Status PROF_SUCCESS = 0;
|
||||
constexpr Status PROF_FAILED = 0xFFFFFFFF;
|
||||
|
|
@ -38,7 +38,7 @@ namespace mindspore {
|
|||
namespace device {
|
||||
namespace ascend {
|
||||
ProfilingManager &ProfilingManager::GetInstance() {
|
||||
static ProfilingManager inst;
|
||||
static ProfilingManager inst{};
|
||||
return inst;
|
||||
}
|
||||
|
||||
|
|
@ -93,9 +93,8 @@ Status ProfilingManager::PluginInit() const {
|
|||
MS_LOG(ERROR) << "MsprofReporterCallback callback is nullptr.";
|
||||
return PROF_FAILED;
|
||||
}
|
||||
return prof_cb_.msprofReporterCallback(static_cast<uint32_t>(MsprofReporterModuleId::MSPROF_MODULE_FRAMEWORK),
|
||||
static_cast<uint32_t>(MsprofReporterCallbackType::MSPROF_REPORTER_INIT),
|
||||
nullptr, 0);
|
||||
return prof_cb_.msprofReporterCallback(IntToUint(MsprofReporterModuleId::MSPROF_MODULE_FRAMEWORK),
|
||||
IntToUint(MsprofReporterCallbackType::MSPROF_REPORTER_INIT), nullptr, 0);
|
||||
}
|
||||
|
||||
void ProfilingManager::PluginUnInit() const {
|
||||
|
|
@ -180,7 +179,7 @@ bool ProfilingManager::ProfStartUp(const NotNull<MsprofGeOptions *> prof_conf) c
|
|||
int32_t cb_ret =
|
||||
prof_cb_.msprofCtrlCallback(static_cast<uint32_t>(MsprofCtrlCallbackType::MSPROF_CTRL_INIT_GE_OPTIONS),
|
||||
static_cast<void *>(prof_conf.get()), sizeof(MsprofGeOptions));
|
||||
if (cb_ret != PROF_SUCCESS) {
|
||||
if (cb_ret != UintToInt(PROF_SUCCESS)) {
|
||||
MS_LOG(ERROR) << "Call msprofCtrlCallback failed, ret: " << cb_ret;
|
||||
return false;
|
||||
}
|
||||
|
|
@ -203,7 +202,7 @@ bool ProfilingManager::StopProfiling() {
|
|||
uint32_t device_ids[kProfilingDeviceNum] = {GetCurrentDeviceId()};
|
||||
|
||||
auto rt_ret = rtProfilerStop(module, kProfilingDeviceNum, device_ids);
|
||||
if (rt_ret != RT_ERROR_NONE) {
|
||||
if (rt_ret != UintToInt(RT_ERROR_NONE)) {
|
||||
MS_LOG(ERROR) << "Call rtProfilerStop failed";
|
||||
return false;
|
||||
}
|
||||
|
|
@ -228,8 +227,8 @@ Status ProfilingManager::CallMsprofReport(const NotNull<ReporterData *> reporter
|
|||
MS_LOG(ERROR) << "MsprofReporterCallback callback is nullptr.";
|
||||
return PROF_FAILED;
|
||||
}
|
||||
return prof_cb_.msprofReporterCallback(static_cast<uint32_t>(MsprofReporterModuleId::MSPROF_MODULE_FRAMEWORK),
|
||||
static_cast<uint32_t>(MsprofReporterCallbackType::MSPROF_REPORTER_REPORT),
|
||||
return prof_cb_.msprofReporterCallback(IntToUint(MsprofReporterModuleId::MSPROF_MODULE_FRAMEWORK),
|
||||
IntToUint(MsprofReporterCallbackType::MSPROF_REPORTER_REPORT),
|
||||
static_cast<void *>(reporter_data.get()), sizeof(ReporterData));
|
||||
}
|
||||
|
||||
|
|
@ -255,10 +254,10 @@ Status RegProfSetDeviceCallback(MsprofSetDeviceCallback func) {
|
|||
ProfilingManager::GetInstance().SetMsprofSetDeviceCallback(func);
|
||||
// Pass MsprofSetDeviceCallback to runtime
|
||||
MS_LOG(INFO) << "GE pass setdevice callback to runtime.";
|
||||
Status rt_ret = rtRegDeviceStateCallback(kRtSetDeviceRegName, static_cast<rtDeviceStateCallback>(func));
|
||||
if (rt_ret != PROF_SUCCESS) {
|
||||
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 rt_ret;
|
||||
return IntToUint(rt_ret);
|
||||
}
|
||||
return PROF_SUCCESS;
|
||||
}
|
||||
|
|
@ -274,10 +273,10 @@ Status RegProfReporterCallback(MsprofReporterCallback func) {
|
|||
MS_LOG(INFO) << "GE register Msprof reporter callback.";
|
||||
ProfilingManager::GetInstance().SetMsprofReporterCallback(func);
|
||||
// Pass MsprofReporterCallback to runtime
|
||||
Status rt_ret = rtSetMsprofReporterCallback(func);
|
||||
if (rt_ret != PROF_SUCCESS) {
|
||||
rtError_t rt_ret = rtSetMsprofReporterCallback(func);
|
||||
if (rt_ret != UintToInt(PROF_SUCCESS)) {
|
||||
MS_LOG(WARNING) << "Pass MsprofReporterCallback to runtime failed, ret: " << rt_ret;
|
||||
return rt_ret;
|
||||
return IntToUint(rt_ret);
|
||||
}
|
||||
// Pass MsprofReporterCallback to hccl
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ void ProfilingUtils::GetTraceCustomNode(ProfilingTraceInfo *trace_info) {
|
|||
break;
|
||||
}
|
||||
MS_LOG(INFO) << "Get custom profiling node:" << node_full_name;
|
||||
trace_info->trace_custom_node.insert(node_full_name);
|
||||
trace_info->trace_custom_node.emplace(node_full_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -285,8 +285,7 @@ void ProfilingUtils::SaveProfilingPoint(uint32_t graph_id, const std::string &no
|
|||
std::shared_ptr<ProfDesc> prof_desc_ptr = std::make_shared<PointDesc>(node_name, point_id);
|
||||
auto iter = graph_point_.find(graph_id);
|
||||
if (iter == graph_point_.end()) {
|
||||
std::vector<std::shared_ptr<ProfDesc>> tmp_vect = {prof_desc_ptr};
|
||||
graph_point_.insert({graph_id, tmp_vect});
|
||||
graph_point_.emplace(graph_id, std::vector<std::shared_ptr<ProfDesc>>{prof_desc_ptr});
|
||||
} else {
|
||||
iter->second.emplace_back(prof_desc_ptr);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ void TaskDescReporter::ReportData() {
|
|||
ReportAllLine();
|
||||
}
|
||||
|
||||
void TaskDescReporter::CheckStreamTaskValid(uint32_t task_id, uint32_t stream_id) {
|
||||
void TaskDescReporter::CheckStreamTaskValid(size_t task_id, size_t stream_id) const {
|
||||
if (task_id >= task_ids_.size() || stream_id >= stream_ids_.size()) {
|
||||
MS_LOG(EXCEPTION) << "Index invalid. task_id:" << task_id << ", task_ids.size:" << task_ids_.size()
|
||||
<< ", stream_id:" << stream_id << ", stream_ids.size:" << stream_ids_.size();
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class TaskDescReporter : public DescReporter {
|
|||
private:
|
||||
std::vector<uint32_t> task_ids_;
|
||||
std::vector<uint32_t> stream_ids_;
|
||||
void CheckStreamTaskValid(uint32_t task_id, uint32_t stream_id);
|
||||
void CheckStreamTaskValid(size_t task_id, size_t stream_id) const;
|
||||
std::vector<CNodePtr> cnode_list_;
|
||||
};
|
||||
} // namespace ascend
|
||||
|
|
|
|||
Loading…
Reference in New Issue