| @@ -65,6 +65,7 @@ | |||||
| #include "toolchain/adx_datadump_server.h" | #include "toolchain/adx_datadump_server.h" | ||||
| #ifdef ENABLE_DUMP_IR | #ifdef ENABLE_DUMP_IR | ||||
| #include "debug/rdr/running_data_recorder.h" | #include "debug/rdr/running_data_recorder.h" | ||||
| #include "debug/rdr/recorder_manager.h" | |||||
| #include "runtime/device/ascend/ascend_bucket.h" | #include "runtime/device/ascend/ascend_bucket.h" | ||||
| #endif | #endif | ||||
| #if ENABLE_CPU && ENABLE_D | #if ENABLE_CPU && ENABLE_D | ||||
| @@ -1000,7 +1001,8 @@ void AscendSession::DumpAllGraphs(const std::vector<KernelGraphPtr> &all_graphs) | |||||
| bool save_graphs = context_ptr->get_param<bool>(MS_CTX_SAVE_GRAPHS_FLAG); | bool save_graphs = context_ptr->get_param<bool>(MS_CTX_SAVE_GRAPHS_FLAG); | ||||
| auto &json_parser = DumpJsonParser::GetInstance(); | auto &json_parser = DumpJsonParser::GetInstance(); | ||||
| json_parser.Parse(); | json_parser.Parse(); | ||||
| if (!save_graphs && !json_parser.e2e_dump_enabled() && !json_parser.async_dump_enabled()) { | |||||
| if (!save_graphs && !json_parser.e2e_dump_enabled() && !json_parser.async_dump_enabled() && | |||||
| !mindspore::RecorderManager::Instance().RdrEnable()) { | |||||
| return; | return; | ||||
| } | } | ||||
| auto kernel_runtime = device::KernelRuntimeManager::Instance().GetKernelRuntime(kAscendDevice, device_id_); | auto kernel_runtime = device::KernelRuntimeManager::Instance().GetKernelRuntime(kAscendDevice, device_id_); | ||||
| @@ -49,14 +49,7 @@ void MemAddressRecorder::SaveMemInfo(const std::string &op_name, const GPUMemInf | |||||
| mem_info_stream << MemInfo2String("kernel_outputs", *outputs); | mem_info_stream << MemInfo2String("kernel_outputs", *outputs); | ||||
| mem_info_stream << std::endl; | mem_info_stream << std::endl; | ||||
| std::string mem_info_str = mem_info_stream.str(); | std::string mem_info_str = mem_info_stream.str(); | ||||
| size_t length = mem_info_append_str_.size() + mem_info_str.size(); | |||||
| // set maximum length of one memory info recorder is 10 percent of string::max_size | |||||
| if (length < 0.1 * mem_info_str.max_size()) { | |||||
| mem_info_append_str_ += mem_info_str; | |||||
| } else { | |||||
| mem_infos_.push_back(mem_info_append_str_); | |||||
| mem_info_append_str_ = mem_info_str; | |||||
| } | |||||
| mem_info_container_[op_name] = mem_info_str; | |||||
| } | } | ||||
| void MemAddressRecorder::Export() { | void MemAddressRecorder::Export() { | ||||
| @@ -72,10 +65,9 @@ void MemAddressRecorder::Export() { | |||||
| MS_LOG(WARNING) << "Open file for saving gpu memory information failed. File path: '" << file_path << "'."; | MS_LOG(WARNING) << "Open file for saving gpu memory information failed. File path: '" << file_path << "'."; | ||||
| return; | return; | ||||
| } | } | ||||
| for (auto &info : mem_infos_) { | |||||
| fout << info; | |||||
| for (auto &info : mem_info_container_) { | |||||
| fout << info.second; | |||||
| } | } | ||||
| fout << mem_info_append_str_; | |||||
| fout.close(); | fout.close(); | ||||
| ChangeFileMode(file_path, S_IRUSR); | ChangeFileMode(file_path, S_IRUSR); | ||||
| } | } | ||||
| @@ -17,6 +17,7 @@ | |||||
| #define MINDSPORE_CCSRC_DEBUG_RDR_MEM_ADDRESS_RECORDER_H_ | #define MINDSPORE_CCSRC_DEBUG_RDR_MEM_ADDRESS_RECORDER_H_ | ||||
| #include <vector> | #include <vector> | ||||
| #include <string> | #include <string> | ||||
| #include <map> | |||||
| #include <memory> | #include <memory> | ||||
| #include <mutex> | #include <mutex> | ||||
| @@ -48,8 +49,7 @@ class MemAddressRecorder : public BaseRecorder { | |||||
| mutable std::mutex mtx_; | mutable std::mutex mtx_; | ||||
| std::string mem_info_append_str_; | |||||
| std::vector<std::string> mem_infos_; | |||||
| std::map<std::string, std::string> mem_info_container_; | |||||
| }; | }; | ||||
| using MemAddressRecorderPtr = std::shared_ptr<MemAddressRecorder>; | using MemAddressRecorderPtr = std::shared_ptr<MemAddressRecorder>; | ||||
| } // namespace mindspore | } // namespace mindspore | ||||