Browse Source

fix review issue

tags/v1.3.0
yanghaitao1 4 years ago
parent
commit
71990c836a
6 changed files with 28 additions and 3 deletions
  1. +1
    -0
      mindspore/ccsrc/backend/kernel_compiler/gpu/data/dataset_iterator_kernel.cc
  2. +1
    -0
      mindspore/ccsrc/profiler/device/common/memory_profiling.cc
  3. +4
    -0
      mindspore/ccsrc/profiler/device/data_saver.cc
  4. +5
    -0
      mindspore/ccsrc/profiler/device/gpu/gpu_data_saver.cc
  5. +9
    -1
      mindspore/ccsrc/profiler/device/gpu/gpu_profiling.cc
  6. +8
    -2
      mindspore/ccsrc/profiler/device/profiling.cc

+ 1
- 0
mindspore/ccsrc/backend/kernel_compiler/gpu/data/dataset_iterator_kernel.cc View File

@@ -72,6 +72,7 @@ bool DatasetIteratorKernel::Init(const CNodePtr &kernel_node) {
if (profiling_enable_) {
std::string path = profiler_inst->ProfileDataPath();
profiling_op_ = std::make_shared<GetNextProfiling>(path);
MS_EXCEPTION_IF_NULL(profiling_op_);
profiler_inst->RegisterProfilingOp(profiling_op_);
}
return true;


+ 1
- 0
mindspore/ccsrc/profiler/device/common/memory_profiling.cc View File

@@ -44,6 +44,7 @@ bool MemoryProfiling::IsMemoryProfilingEnable() const {

std::shared_ptr<GraphMemory> MemoryProfiling::AddGraphMemoryNode(uint32_t graph_id) {
std::shared_ptr<GraphMemory> node = std::make_shared<GraphMemory>(graph_id);
MS_EXCEPTION_IF_NULL(node);
graph_memory_[graph_id] = node;
return node;
}


+ 4
- 0
mindspore/ccsrc/profiler/device/data_saver.cc View File

@@ -41,6 +41,10 @@ void DataSaver::ParseOpInfo(const OpInfoMap &op_info_maps) {
op_timestamps_map_[item.first] = item.second.start_duration;
float proportion = item.second.op_host_cost_time / total_time_sum;
auto op_info = std::make_shared<OpInfo>(item.second);
if (op_info == nullptr) {
MS_LOG(ERROR) << "Create Operation information node failed when parse operation information.";
return;
}
OpDetailInfo op_detail_info = OpDetailInfo(op_info, proportion);
op_detail_infos_.emplace_back(op_detail_info);
AddOpDetailInfoForType(op_detail_info);


+ 5
- 0
mindspore/ccsrc/profiler/device/gpu/gpu_data_saver.cc View File

@@ -89,6 +89,10 @@ void GpuDataSaver::AddKernelEvent(const Event &event) {
void GpuDataSaver::AddKernelEventToDevice(const Event &event, DeviceActivityInfos *device_activity_infos) {
// Combine kernel activity with same kernel name
auto event_ptr = std::make_shared<Event>(event);
if (event_ptr == nullptr) {
MS_LOG(WARNING) << "Create event failed when add event to device.";
return;
}
ActivityData activity_data = ActivityData(event_ptr);
std::string kernel_name = event.kernel_name;
auto iter = device_activity_infos->find(kernel_name);
@@ -135,6 +139,7 @@ void GpuDataSaver::WriteActivity(const std::string &saver_base_dir) {
std::string timestamp_file_path = timestamp_file_path_base + std::to_string(device_info.first) + ".txt";
std::ofstream activity_timestamp_ofs(timestamp_file_path);
if (!activity_timestamp_ofs.is_open()) {
ofs.close();
MS_LOG(WARNING) << "Open file '" << timestamp_file_path << "' failed!";
return;
}


+ 9
- 1
mindspore/ccsrc/profiler/device/gpu/gpu_profiling.cc View File

@@ -520,7 +520,12 @@ void CUPTIAPI ActivityAllocBuffer(uint8_t **buffer, size_t *size, size_t *maxNum

void CUPTIAPI ActivityProcessBuffer(CUcontext ctx, uint32_t streamId, uint8_t *buffer, size_t size, size_t validSize) {
PROFILER_ERROR_IF_NULLPTR(buffer);
GPUProfiler::GetInstance()->ProcessBuffer(ctx, streamId, buffer, size, validSize);
auto gpu_profiler_inst = GPUProfiler::GetInstance();
if (gpu_profiler_inst == nullptr) {
MS_LOG(ERROR) << "GPU profiler instance is nullptr";
return;
}
gpu_profiler_inst->ProcessBuffer(ctx, streamId, buffer, size, validSize);
}

void ProcessActivityMemcpyRecord(Event *profilingData, CUpti_Activity *record, CUpti_ActivityMemcpy *memcpy) {
@@ -673,6 +678,7 @@ void GPUProfiler::HandleActivityRecord(CUpti_Activity *record) {
void GPUProfiler::SetStepTraceOpName(ProfilingTraceInfo trace_op_name) { step_trace_op_name = trace_op_name; }

void GPUProfiler::RegisterProfilingOp(std::shared_ptr<ProfilingOp> node) {
PROFILER_ERROR_IF_NULLPTR(node);
if (profiling_op_.find(node->Name()) != profiling_op_.end()) {
return;
}
@@ -681,6 +687,8 @@ void GPUProfiler::RegisterProfilingOp(std::shared_ptr<ProfilingOp> node) {
}

void CUPTIAPI GPUProfiler::AllocBuffer(uint8_t **buffer, size_t *size, size_t *maxNumRecords) {
PROFILER_ERROR_IF_NULLPTR(size);
PROFILER_ERROR_IF_NULLPTR(maxNumRecords);
int stat = posix_memalign(reinterpret_cast<void **>(buffer), ALIGN_SIZE, BUF_SIZE);
if (stat) {
MS_LOG(ERROR) << "Out of memory, activity buffer alloc failed.";


+ 8
- 2
mindspore/ccsrc/profiler/device/profiling.cc View File

@@ -29,9 +29,15 @@ namespace profiler {
uint64_t Profiler::GetHostMonoTimeStamp() const {
struct timespec ts;
#if defined(_WIN32) || defined(_WIN64)
clock_gettime(CLOCK_MONOTONIC, &ts);
if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) {
MS_LOG(ERROR) << "Get host timestamp failed";
return 0;
}
#else
clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
if (clock_gettime(CLOCK_MONOTONIC_RAW, &ts) != 0) {
MS_LOG(ERROR) << "Get host timestamp failed";
return 0;
}
#endif
constexpr uint64_t kNSecondInSecond = 1000000000;
uint64_t cur_time_stamp = ts.tv_sec * kNSecondInSecond + ts.tv_nsec;


Loading…
Cancel
Save