| 711 | } |
| 712 | |
| 713 | bool Dflash2Drafter::catch_up(int64_t upto, std::string& err) { |
| 714 | if (!has_deferred()) return true; |
| 715 | const Clock::time_point t0 = Clock::now(); |
| 716 | const OnDevice on_device(device_); |
| 717 | const size_t row = taps_.size() * (size_t) N_; |
| 718 | int64_t from = std::max<int64_t>(dpend_lo_, upto - 2047); |
| 719 | upto = std::min<int64_t>(upto, dpend_hi_); |
| 720 | int64_t replayed = 0; |
| 721 | while (from < upto) { |
| 722 | const int m = (int) std::min<int64_t>(kRows, upto - from); |
| 723 | if (!context_wait(err)) return false; |
| 724 | for (int i = 0; i < m; ++i) // (the held run wraps at 2048 positions: row by row) |
| 725 | if (cudaMemcpyAsync(landing_ + (size_t) i * row, dpend_ + (size_t) ((from + i) % kRing2048) * row, row * 4, cudaMemcpyHostToDevice, cs_) != cudaSuccess) { |
| 726 | err = "dflash2: the deferred rows' upload"; |
| 727 | return false; |
| 728 | } |
| 729 | if (!context(landing_, m, from, err)) return false; // (waits for the stream, so the next chunk may reuse the landing) |
| 730 | from += m; |
| 731 | replayed += m; |
| 732 | } |
| 733 | dpend_lo_ = std::max<int64_t>(upto, dpend_lo_); |
| 734 | if (dpend_lo_ >= dpend_hi_) dpend_lo_ = dpend_hi_ = 0; |
| 735 | ++n_catchups; |
| 736 | n_catchup_rows += replayed; |
| 737 | ms_catchup += ms_since(t0); |
| 738 | return true; |
| 739 | } |
| 740 | |
| 741 | void Dflash2Drafter::set_max_drafts(int n) { |
| 742 | n = std::max(1, std::min(n, (int) kDrafts)); |
nothing calls this directly
no test coverage detected