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

Method loop

engine/sycl/src/program/generate.cpp:1482–1500  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1480#endif
1481 }
1482 void loop() {
1483 // the job's memcpys stay off the host's core and the pool's: by default the spare SMT sibling of the last
1484 // two-thread core (Windows); STRATA_ADAPT_JOB_CPU=<logical cpu>, or -1 for no pinning
1485 const char* c = std::getenv("STRATA_ADAPT_JOB_CPU");
1486 const int cpu = c != nullptr ? std::atoi(c) : smt_spare_cpu();
1487 if (cpu >= 0) (void) strata::kernels::cpu::pin_current_thread(cpu);
1488 for (;;) {
1489 std::function<void()> f;
1490 {
1491 std::unique_lock<std::mutex> lk(mu_);
1492 cv_.wait(lk, [&] { return has_ || quit_; });
1493 if (!has_) return;
1494 f = std::move(job_);
1495 has_ = false;
1496 }
1497 f();
1498 done_.store(true, std::memory_order_release);
1499 }
1500 }
1501 std::mutex mu_;
1502 std::condition_variable cv_;
1503 std::function<void()> job_;

Callers

nothing calls this directly

Calls 5

moveFunction · 0.85
pin_current_threadFunction · 0.50
fFunction · 0.50
waitMethod · 0.45
storeMethod · 0.45

Tested by

no test coverage detected