| 83 | } |
| 84 | |
| 85 | void GPUMemoryPlanner::StartCollect() { |
| 86 | if (is_stats_.load()) { |
| 87 | BestFit(); |
| 88 | ResetStats(); |
| 89 | } |
| 90 | |
| 91 | auto current = counter_.fetch_add(1); |
| 92 | if (current == start_step_) { |
| 93 | is_stats_ = true; |
| 94 | } else if (current == stop_step_) { |
| 95 | is_stats_ = false; |
| 96 | CollectDone(); |
| 97 | } |
| 98 | if (allocator_ != nullptr) { |
| 99 | allocator_->BeginStep(); |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | void GPUMemoryPlanner::BestFit() { |
| 104 | for (auto policy : lifetime_stats_polices_) { |