MCPcopy Create free account
hub / github.com/Niko1221/Strata / fill_loop

Method fill_loop

engine/src/core/expert_source.cpp:7218–7243  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7216}
7217
7218void ForesightSwap::fill_loop() {
7219 strata::platform::name_this_thread("strata-fill");
7220 int cur_dev = -1;
7221 for (;;) {
7222 int64_t idx;
7223 {
7224 std::unique_lock<std::mutex> lk(mu_);
7225 cv_.wait(lk, [&] { return stop_ || !queue_.empty(); });
7226 if (stop_) return;
7227 idx = queue_.front();
7228 queue_.pop_front();
7229 }
7230 Slot& sl = slot[(size_t) idx];
7231 const int64_t l = idx / slots;
7232 const int dev = layer_dev[(size_t) l];
7233 if (dev != cur_dev) { cudaSetDevice(dev); cur_dev = dev; }
7234 cudaStream_t s = (cudaStream_t) card_stream[(size_t) layer_card[(size_t) l]];
7235 if (cudaMemcpyAsync((void*) sl.dptr, sl.src, sl.bytes, cudaMemcpyHostToDevice, s) != cudaSuccess ||
7236 cudaEventRecord((cudaEvent_t) sl.ev, s) != cudaSuccess) {
7237 cudaGetLastError();
7238 if (!failed.exchange(true)) std::fprintf(stderr, "strata serve: foresight swap: a copy failed - swap space off\n");
7239 continue; // never marked issued: the slot is never used
7240 }
7241 sl.issued.store(true, std::memory_order_release);
7242 }
7243}
7244
7245bool ForesightSwap::take(int64_t layer, int32_t expert, unsigned long long& ptr) {
7246 std::lock_guard<std::mutex> smu_lk(smu_);

Callers

nothing calls this directly

Calls 10

frontMethod · 0.80
name_this_threadFunction · 0.50
cudaSetDeviceFunction · 0.50
cudaMemcpyAsyncFunction · 0.50
cudaEventRecordFunction · 0.50
cudaGetLastErrorFunction · 0.50
waitMethod · 0.45
emptyMethod · 0.45
exchangeMethod · 0.45
storeMethod · 0.45

Tested by

no test coverage detected