forked from mindspore-Ecosystem/mindspore
adapt delete libms_profiler_fwk.a
This commit is contained in:
parent
c93bb9936e
commit
8fc11cb676
|
@ -198,12 +198,6 @@ if(NOT ENABLE_GE)
|
|||
set(ASCEND_DRIVER_PATH ${ASCEND_PATH}/driver/lib64/common)
|
||||
|
||||
if(ENABLE_D)
|
||||
install(
|
||||
TARGETS ms_profile
|
||||
DESTINATION ${INSTALL_LIB_DIR}
|
||||
COMPONENT mindspore
|
||||
)
|
||||
|
||||
install(
|
||||
TARGETS hccl_plugin
|
||||
DESTINATION ${INSTALL_LIB_DIR}
|
||||
|
|
|
@ -297,20 +297,14 @@ if(MODE_ASCEND_ALL)
|
|||
${ASCEND_DRIVER_BACK_PATH})
|
||||
find_library(DATATRANSFER datatransfer HINTS ${ASCEND_RUNTIME_PATH} ${ASCEND_TOOLKIT_RUNTIME_PATH}
|
||||
${ASCEND_DRIVER_BACK_PATH})
|
||||
find_library(PROFILING msprofiler_fwkacl ${ASCEND_RUNTIME_PATH} ${ASCEND_TOOLKIT_RUNTIME_PATH})
|
||||
find_library(PROFILING msprofiler ${ASCEND_RUNTIME_PATH} ${ASCEND_TOOLKIT_RUNTIME_PATH})
|
||||
find_library(ACL ascendcl ${ASCEND_RUNTIME_PATH} ${ASCEND_TOOLKIT_RUNTIME_PATH})
|
||||
find_library(PLATFORM platform ${ASCEND_RUNTIME_PATH} ${ASCEND_TOOLKIT_RUNTIME_PATH})
|
||||
find_library(OPTILING optiling ${ASCEND_OPP_PATH} ${ASCEND_TOOLKIT_OPP_PATH})
|
||||
find_library(OPT_FEATURE opt_feature ${ASCEND_RUNTIME_PATH} ${ASCEND_TOOLKIT_RUNTIME_PATH})
|
||||
|
||||
add_library(ms_profile SHARED
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/runtime/device/ascend/profiling/profiling_callback_register.cc)
|
||||
set_target_properties(ms_profile PROPERTIES LINKER_LANGUAGE CXX)
|
||||
target_link_options(ms_profile PRIVATE -Wl,-init,common_log_init)
|
||||
target_link_libraries(ms_profile -Wl,--start-group -Wl,--whole-archive ${PROFILING} -Wl,--no-whole-archive
|
||||
mindspore::protobuf -Wl,--end-group)
|
||||
target_link_libraries(mindspore ${RUNTIME_LIB} ${TSDCLIENT} ${DATATRANSFER} ${ERROR_MANAGER} -Wl,--no-as-needed
|
||||
${OPTILING} ${PLATFORM} ${ACL} ${OPT_FEATURE})
|
||||
${OPTILING} ${PLATFORM} ${ACL} ${OPT_FEATURE} ${PROFILING})
|
||||
target_link_libraries(mindspore -Wl,--start-group proto_input mindspore::protobuf -Wl,--end-group)
|
||||
elseif(CMAKE_SYSTEM_NAME MATCHES "Windows")
|
||||
target_link_libraries(mindspore -Wl,--start-group proto_input mindspore::protobuf mindspore::sentencepiece
|
||||
|
@ -325,7 +319,7 @@ endif()
|
|||
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
|
||||
set_property(SOURCE "pipeline/jit/init.cc" PROPERTY
|
||||
COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_PIPELINE)
|
||||
pybind11_add_module(_c_expression NO_EXTRAS "pipeline/jit/init.cc")
|
||||
pybind11_add_module(_c_expression NO_EXTRAS "pipeline/jit/init.cc" NO_EXTRAS)
|
||||
|
||||
MESSAGE(STATUS "operation system is ${CMAKE_SYSTEM}")
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
|
@ -375,9 +369,6 @@ else()
|
|||
proto_input -Wl,--no-whole-archive)
|
||||
target_link_libraries(_c_expression PRIVATE mindspore::pybind11_module)
|
||||
target_link_libraries(_c_expression PRIVATE mindspore_gvar)
|
||||
if(MODE_ASCEND_ALL)
|
||||
target_link_libraries(_c_expression PRIVATE -Wl,--no-as-needed ms_profile)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(USE_GLOG)
|
||||
|
|
|
@ -27,31 +27,43 @@ namespace mindspore {
|
|||
namespace kernel {
|
||||
namespace tbe {
|
||||
const std::unordered_map<std::string, TypeId> type_str_id_maps = {
|
||||
{"float", TypeId::kNumberTypeFloat32}, {"float16", TypeId::kNumberTypeFloat16},
|
||||
{"float32", TypeId::kNumberTypeFloat32}, {"float64", TypeId::kNumberTypeFloat64},
|
||||
{"int", TypeId::kNumberTypeInt}, {"int8", TypeId::kNumberTypeInt8},
|
||||
{"int16", TypeId::kNumberTypeInt16}, {"int32", TypeId::kNumberTypeInt32},
|
||||
{"int64", TypeId::kNumberTypeInt64}, {"uint", TypeId::kNumberTypeUInt},
|
||||
{"uint8", TypeId::kNumberTypeUInt8}, {"uint16", TypeId::kNumberTypeUInt16},
|
||||
{"uint32", TypeId::kNumberTypeUInt32}, {"uint64", TypeId::kNumberTypeUInt64},
|
||||
{"bool", TypeId::kNumberTypeBool}, {"", TypeId::kMetaTypeNone},
|
||||
{"float", TypeId::kNumberTypeFloat32},
|
||||
{"float16", TypeId::kNumberTypeFloat16},
|
||||
{"float32", TypeId::kNumberTypeFloat32},
|
||||
{"float64", TypeId::kNumberTypeFloat64},
|
||||
{"int", TypeId::kNumberTypeInt},
|
||||
{"int8", TypeId::kNumberTypeInt8},
|
||||
{"int16", TypeId::kNumberTypeInt16},
|
||||
{"int32", TypeId::kNumberTypeInt32},
|
||||
{"int64", TypeId::kNumberTypeInt64},
|
||||
{"uint", TypeId::kNumberTypeUInt},
|
||||
{"uint8", TypeId::kNumberTypeUInt8},
|
||||
{"uint16", TypeId::kNumberTypeUInt16},
|
||||
{"uint32", TypeId::kNumberTypeUInt32},
|
||||
{"uint64", TypeId::kNumberTypeUInt64},
|
||||
{"bool", TypeId::kNumberTypeBool},
|
||||
{"int4", TypeId::kNumberTypeInt4},
|
||||
{"", TypeId::kMetaTypeNone},
|
||||
};
|
||||
|
||||
const std::map<TypeId, std::string> type_id_str_maps = {
|
||||
{TypeId::kNumberTypeFloat32, "float32"}, {TypeId::kNumberTypeFloat16, "float16"},
|
||||
{TypeId::kNumberTypeFloat, "float"}, {TypeId::kNumberTypeFloat64, "float64"},
|
||||
{TypeId::kNumberTypeInt, "int"}, {TypeId::kNumberTypeInt8, "int8"},
|
||||
{TypeId::kNumberTypeInt16, "int16"}, {TypeId::kNumberTypeInt32, "int32"},
|
||||
{TypeId::kNumberTypeInt64, "int64"}, {TypeId::kNumberTypeUInt, "uint"},
|
||||
{TypeId::kNumberTypeUInt8, "uint8"}, {TypeId::kNumberTypeUInt16, "uint16"},
|
||||
{TypeId::kNumberTypeUInt32, "uint32"}, {TypeId::kNumberTypeUInt64, "uint64"},
|
||||
{TypeId::kNumberTypeBool, "int8"}, {TypeId::kMetaTypeNone, ""},
|
||||
};
|
||||
|
||||
const std::map<std::string, std::string> type_str_maps = {
|
||||
{"Float32", "float32"}, {"Float16", "float16"}, {"Int8", "int8"}, {"Int16", "int16"},
|
||||
{"UInt16", "uint16"}, {"UInt8", "uint8"}, {"Int32", "int32"}, {"UInt32", "uint32"},
|
||||
{"Int64", "int64"}, {"UInt64", "uint64"}, {"Bool", "int8"}, {"Float64", "float64"},
|
||||
{TypeId::kNumberTypeFloat32, "float32"},
|
||||
{TypeId::kNumberTypeFloat16, "float16"},
|
||||
{TypeId::kNumberTypeFloat, "float"},
|
||||
{TypeId::kNumberTypeFloat64, "float64"},
|
||||
{TypeId::kNumberTypeInt, "int"},
|
||||
{TypeId::kNumberTypeInt8, "int8"},
|
||||
{TypeId::kNumberTypeInt16, "int16"},
|
||||
{TypeId::kNumberTypeInt32, "int32"},
|
||||
{TypeId::kNumberTypeInt64, "int64"},
|
||||
{TypeId::kNumberTypeUInt, "uint"},
|
||||
{TypeId::kNumberTypeUInt8, "uint8"},
|
||||
{TypeId::kNumberTypeUInt16, "uint16"},
|
||||
{TypeId::kNumberTypeUInt32, "uint32"},
|
||||
{TypeId::kNumberTypeUInt64, "uint64"},
|
||||
{TypeId::kNumberTypeBool, "int8"},
|
||||
{TypeId::kNumberTypeInt4, "int4"},
|
||||
{TypeId::kMetaTypeNone, ""},
|
||||
};
|
||||
|
||||
const std::unordered_map<std::string, size_t> type_nbyte_maps = {
|
||||
|
@ -59,6 +71,7 @@ const std::unordered_map<std::string, size_t> type_nbyte_maps = {
|
|||
{"int8", sizeof(int) / 4}, {"int16", sizeof(int) / 2}, {"int32", sizeof(int)},
|
||||
{"int64", sizeof(int) * 2}, {"uint8", sizeof(int) / 4}, {"uint16", sizeof(int) / 2},
|
||||
{"uint32", sizeof(int)}, {"uint64", sizeof(int) * 2}, {"bool", sizeof(char)},
|
||||
{"int4", sizeof(int) / 4},
|
||||
};
|
||||
|
||||
TypeId DtypeToTypeId(const std::string &dtypes) {
|
||||
|
|
|
@ -146,6 +146,11 @@ Status ProfilingManager::GetProfConf(const NotNull<MsprofGeOptions *> prof) {
|
|||
bool ProfilingManager::StartupProfiling(uint32_t device_id) {
|
||||
auto is_profiling = IsProfiling();
|
||||
if (!is_profiling) {
|
||||
int32_t cb_ret = MsprofInit(0XFF, nullptr, 0);
|
||||
if (cb_ret != UintToInt(PROF_SUCCESS)) {
|
||||
MS_LOG(ERROR) << "Call msprofCtrlCallback failed, ret: " << cb_ret;
|
||||
return false;
|
||||
}
|
||||
MS_LOG(INFO) << "No need profiling. please export PROFILING_MODE and in train mode.";
|
||||
return true;
|
||||
}
|
||||
|
@ -181,14 +186,13 @@ uint32_t GetCurrentDeviceId() {
|
|||
bool ProfilingManager::ProfStartUp(const NotNull<MsprofGeOptions *> prof_conf) const {
|
||||
MS_LOG(INFO) << "Prof start up. ";
|
||||
|
||||
if (prof_cb_.msprofCtrlCallback == nullptr) {
|
||||
MS_LOG(ERROR) << "MsprofCtrlCallback callback is nullptr.";
|
||||
return false;
|
||||
bool ret = ProfRegisterCtrlCallback();
|
||||
if (ret == false) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
// call profiling start up api
|
||||
int32_t cb_ret =
|
||||
prof_cb_.msprofCtrlCallback(static_cast<uint32_t>(MsprofCtrlCallbackType::MSPROF_CTRL_INIT_GE_OPTIONS),
|
||||
int32_t cb_ret = MsprofInit(static_cast<uint32_t>(MsprofCtrlCallbackType::MSPROF_CTRL_INIT_GE_OPTIONS),
|
||||
static_cast<void *>(prof_conf.get()), sizeof(MsprofGeOptions));
|
||||
if (cb_ret != UintToInt(PROF_SUCCESS)) {
|
||||
MS_LOG(ERROR) << "Call msprofCtrlCallback failed, ret: " << cb_ret;
|
||||
|
@ -199,6 +203,30 @@ bool ProfilingManager::ProfStartUp(const NotNull<MsprofGeOptions *> prof_conf) c
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ProfilingManager::ProfRegisterCtrlCallback() const {
|
||||
rtError_t rt_ret = rtProfRegisterCtrlCallback(GE, CtrlCallbackHandle);
|
||||
if (rt_ret != RT_ERROR_NONE) {
|
||||
MS_LOG(ERROR) << "Call rtProfRegisterCtrlCallback failed.";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
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.";
|
||||
} else if (rt_type == RT_PROF_CTRL_SWITCH) {
|
||||
Status ret = ProfCtrlSwitchHandle(data);
|
||||
if (ret != PROF_SUCCESS) {
|
||||
MS_LOG(ERROR) << "Start runtime profiler failed.";
|
||||
}
|
||||
}
|
||||
|
||||
return RT_ERROR_NONE;
|
||||
}
|
||||
|
||||
bool ProfilingManager::StopProfiling() {
|
||||
MS_LOG(INFO) << "StopProfiling";
|
||||
if (!IsProfiling()) {
|
||||
|
@ -208,26 +236,11 @@ bool ProfilingManager::StopProfiling() {
|
|||
|
||||
// plugin unregister
|
||||
PluginUnInit();
|
||||
// stop runtime profiler
|
||||
auto module = GetProfilingModule();
|
||||
uint32_t device_ids[kProfilingDeviceNum] = {GetCurrentDeviceId()};
|
||||
|
||||
auto rt_ret = rtProfilerStop(module, kProfilingDeviceNum, device_ids);
|
||||
if (rt_ret != UintToInt(RT_ERROR_NONE)) {
|
||||
MS_LOG(ERROR) << "Call rtProfilerStop failed";
|
||||
return false;
|
||||
}
|
||||
|
||||
// stop profiling
|
||||
if (prof_cb_.msprofCtrlCallback == nullptr) {
|
||||
MS_LOG(ERROR) << "MsprofCtrlCallback callback is nullptr.";
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t cb_ret =
|
||||
prof_cb_.msprofCtrlCallback(static_cast<uint32_t>(MsprofCtrlCallbackType::MSPROF_CTRL_FINALIZE), nullptr, 0);
|
||||
int32_t cb_ret = MsprofFinalize();
|
||||
if (cb_ret != 0) {
|
||||
MS_LOG(WARNING) << "Call msprofCtrlCallback failed, ret: " << cb_ret;
|
||||
MS_LOG(WARNING) << "Call MsprofFinalize failed, ret: " << cb_ret;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -273,28 +286,18 @@ Status RegProfSetDeviceCallback(MsprofSetDeviceCallback func) {
|
|||
return PROF_SUCCESS;
|
||||
}
|
||||
|
||||
Status RegProfReporterCallback(MsprofReporterCallback func) {
|
||||
if (func == nullptr) {
|
||||
MS_LOG(ERROR) << "MsprofReporterCallback callback is nullptr.";
|
||||
Status ProfCtrlSwitchHandle(void *data) {
|
||||
if (data == nullptr) {
|
||||
MS_LOG(ERROR) << "Ctrl switch handl data is nullptr.";
|
||||
return PROF_FAILED;
|
||||
}
|
||||
if (ProfilingManager::GetInstance().GetMsprofCallback().msprofReporterCallback != nullptr) {
|
||||
MS_LOG(WARNING) << "Msprof reporter callback is exist, just ignore it.";
|
||||
} else {
|
||||
MS_LOG(INFO) << "GE register Msprof reporter callback.";
|
||||
ProfilingManager::GetInstance().SetMsprofReporterCallback(func);
|
||||
// Pass MsprofReporterCallback to runtime
|
||||
rtError_t rt_ret = rtSetMsprofReporterCallback(func);
|
||||
if (rt_ret != UintToInt(PROF_SUCCESS)) {
|
||||
MS_LOG(WARNING) << "Pass MsprofReporterCallback to runtime failed, ret: " << rt_ret;
|
||||
return IntToUint(rt_ret);
|
||||
}
|
||||
// Pass MsprofReporterCallback to hccl
|
||||
}
|
||||
return PROF_SUCCESS;
|
||||
|
||||
rtProfCommandHandle_t *prof_config_param = reinterpret_cast<rtProfCommandHandle_t *>(data);
|
||||
auto type = static_cast<ProfCommandHandleType>(prof_config_param->type);
|
||||
return ProfCommandHandle(type);
|
||||
}
|
||||
|
||||
Status ProfCommandHandle(ProfCommandHandleType type, void *, uint32_t) {
|
||||
Status ProfCommandHandle(ProfCommandHandleType type) {
|
||||
MS_LOG(INFO) << "ProfCommandHandle start, type:" << type;
|
||||
if (type == kProfCommandhandleInit) {
|
||||
auto cb_ret = ProfilingManager::GetInstance().PluginInit();
|
||||
|
@ -302,25 +305,10 @@ Status ProfCommandHandle(ProfCommandHandleType type, void *, uint32_t) {
|
|||
MS_LOG(ERROR) << "Profiling plugin int failed.";
|
||||
return PROF_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
// call runtime profiler API
|
||||
auto module = GetProfilingModule();
|
||||
auto device_id = GetCurrentDeviceId();
|
||||
auto ret = rtProfilerStart(module, kProfilingDeviceNum, &device_id);
|
||||
if (ret != RT_ERROR_NONE) {
|
||||
MS_LOG(ERROR) << "Call rtProfilerStart failed, ret:" << ret;
|
||||
return PROF_FAILED;
|
||||
}
|
||||
}
|
||||
return PROF_SUCCESS;
|
||||
}
|
||||
|
||||
bool DoRegiste() noexcept {
|
||||
MS_LOG(INFO) << "VM profiling register start";
|
||||
return VMCallbackRegister::GetInstance().Register(RegProfCtrlCallback, RegProfSetDeviceCallback,
|
||||
RegProfReporterCallback, ProfCommandHandle);
|
||||
}
|
||||
static bool doRegiste = DoRegiste();
|
||||
} // namespace ascend
|
||||
} // namespace device
|
||||
} // namespace mindspore
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
#include "utils/ms_context.h"
|
||||
#include "toolchain/prof_callback.h"
|
||||
#include "toolchain/prof_acl_api.h"
|
||||
#include "toolchain/slog.h"
|
||||
#include "runtime/base.h"
|
||||
#include "runtime/device/ascend/profiling/profiling_callback_register.h"
|
||||
|
||||
using std::map;
|
||||
|
@ -43,6 +45,7 @@ class ProfilingManager {
|
|||
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();
|
||||
|
||||
|
@ -75,7 +78,9 @@ class ProfilingManager {
|
|||
Status RegProfCtrlCallback(MsprofCtrlCallback func);
|
||||
Status RegProfSetDeviceCallback(MsprofSetDeviceCallback func);
|
||||
Status RegProfReporterCallback(MsprofReporterCallback func);
|
||||
Status ProfCommandHandle(ProfCommandHandleType type, void *data, uint32_t len);
|
||||
Status ProfCommandHandle(ProfCommandHandleType type);
|
||||
rtError_t CtrlCallbackHandle(uint32_t rt_type, void *data, uint32_t len);
|
||||
Status ProfCtrlSwitchHandle(void *data);
|
||||
} // namespace ascend
|
||||
} // namespace device
|
||||
} // namespace mindspore
|
||||
|
|
|
@ -80,6 +80,7 @@ enum TypeId : int {
|
|||
kNumberTypeFloat64,
|
||||
kNumberTypeComplex64,
|
||||
kNumberTypeComplex128,
|
||||
kNumberTypeInt4,
|
||||
kNumberTypeEnd,
|
||||
//
|
||||
// Monad Types
|
||||
|
|
|
@ -78,6 +78,9 @@ class FlopsParser:
|
|||
op_name = self._get_op_name(result)
|
||||
if op_name in op_name_set or op_name == "":
|
||||
continue
|
||||
if op_name not in op_avg_time_dict:
|
||||
logger.warning("Op name {op_name} is not exist in op average time dict.")
|
||||
continue
|
||||
# Convert the unit of task_fops to MFLOPs(1e6).
|
||||
task_fops = self._compute_task_flops(result) * 1e-6
|
||||
op_avg_time = op_avg_time_dict[op_name]
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
#include <string>
|
||||
#include "prof_mgr_core.h"
|
||||
#include "prof_callback.h"
|
||||
|
||||
namespace Msprof {
|
||||
namespace Engine {
|
||||
|
@ -54,3 +55,21 @@ int ProfMgrStop(void* handle) { return 0; }
|
|||
namespace Analysis::Dvvp::ProfilerSpecial {
|
||||
uint32_t MsprofilerInit() { return 0; }
|
||||
}
|
||||
|
||||
/*
|
||||
* @name MsprofInit
|
||||
* @brief Profiling module init
|
||||
* @param [in] dataType: profiling type: ACL Env/ACL Json/GE Option
|
||||
* @param [in] data: profiling switch data
|
||||
* @param [in] dataLen: Length of data
|
||||
* @return 0:SUCCESS, >0:FAILED
|
||||
*/
|
||||
int32_t MsprofInit(uint32_t dataType, void *data, uint32_t dataLen) { return 0; }
|
||||
|
||||
/*
|
||||
* @name AscendCL
|
||||
* @brief Finishing Profiling
|
||||
* @param NULL
|
||||
* @return 0:SUCCESS, >0:FAILED
|
||||
*/
|
||||
int32_t MsprofFinalize() { return 0; }
|
|
@ -201,3 +201,5 @@ RTS_API rtError_t rtKernelLaunchWithFlag(const void *stubFunc, uint32_t blockDim
|
|||
}
|
||||
|
||||
RTS_API rtError_t rtMemGetInfoEx(rtMemInfoType_t memInfoType, size_t *free, size_t *total) { return RT_ERROR_NONE; }
|
||||
|
||||
RTS_API rtError_t rtProfRegisterCtrlCallback(uint32_t moduleId, rtProfCtrlHandle callback) { return RT_ERROR_NONE; }
|
||||
|
|
|
@ -1 +1 @@
|
|||
1.4.0
|
||||
1.4.1
|
Loading…
Reference in New Issue