Browse Source

!27438 fix debugger lock

Merge pull request !27438 from jiangshuqiang/fix_debugger_lock
tags/v1.6.0
i-robot Gitee 4 years ago
parent
commit
5d4d35cc2a
2 changed files with 26 additions and 9 deletions
  1. +18
    -7
      mindspore/ccsrc/debug/debug_services.cc
  2. +8
    -2
      mindspore/ccsrc/debug/tensor_load.h

+ 18
- 7
mindspore/ccsrc/debug/debug_services.cc View File

@@ -928,14 +928,20 @@ void DebugServices::GetTensorDataInfoAsync(const std::vector<std::tuple<std::str
bool output_flag = (output_str == "output");

for (const std::string &file_name : async_file_pool) {
std::size_t found = file_name.find(dump_name);
std::size_t found_out = file_name.find(output_str);
std::size_t found_dot_start = file_name.find(".", found_out);
std::size_t found_dot_end = file_name.find(".", found_dot_start);
std::string file_name_to_check = file_name;
auto delim = file_name.rfind("/");
if (delim != std::string::npos) {
file_name_to_check = file_name.substr(delim + 1);
}
std::size_t found = file_name_to_check.find(dump_name);
std::size_t found_out = file_name_to_check.find(output_str);
std::size_t found_dot_start = file_name_to_check.find(".", found_out);
std::size_t found_dot_end = file_name_to_check.find(".", found_dot_start);

if (file_name.find(specific_dump_dir) != std::string::npos && found != std::string::npos &&
found_out != std::string::npos) {
slot_list.push_back(std::stoul(file_name.substr(found_dot_start + 1, found_dot_end - found_dot_start - 1)));
slot_list.push_back(
std::stoul(file_name_to_check.substr(found_dot_start + 1, found_dot_end - found_dot_start - 1)));
}
}
for (auto slot : slot_list) {
@@ -1302,9 +1308,14 @@ void DebugServices::ReadDumpedTensorAsync(const std::string &specific_dump_dir,
std::vector<std::string> matched_paths;
// if async mode
for (const std::string &file_path : async_file_pool) {
std::string file_name_to_check = file_path;
auto delim = file_path.rfind("/");
if (delim != std::string::npos) {
file_name_to_check = file_path.substr(delim + 1);
}
if (file_path.find(specific_dump_dir) != std::string::npos &&
file_path.find(prefix_dump_to_check) != std::string::npos &&
file_path.find(slot_string_to_check) != std::string::npos) {
file_name_to_check.find(prefix_dump_to_check) != std::string::npos &&
file_name_to_check.find(slot_string_to_check) != std::string::npos) {
matched_paths.push_back(file_path);
found = true;
}


+ 8
- 2
mindspore/ccsrc/debug/tensor_load.h View File

@@ -176,12 +176,18 @@ class TensorLoader {
// wait until there is any not-in-use candidate to be evicted from cache
evict_cond.wait(lk, [&] { return !cache_evict_queue_.empty(); });
candidate_name = cache_evict_queue_.front();
candidates_size = tensor_list_map_[candidate_name]->GetByteSize();
cache_evict_queue_.pop_front();
// evict candidate tensor
lock_.lock();
auto tensor = GetTensor(candidate_name);
if (tensor == nullptr) {
MS_LOG(INFO) << "Tensor: " << candidate_name << " has already been evicted.";
lock_.unlock();
continue;
}
candidates_size = tensor->GetByteSize();
tensor_list_map_.erase(candidate_name);
lock_.unlock();
cache_evict_queue_.pop_front();
mem_usage_ = std::max(uint64_t(0), mem_usage_ - candidates_size);
MS_LOG(INFO) << "Evict tensor: " << candidate_name;
}


Loading…
Cancel
Save