Merge branch 'fft-admit' into rc175: FFT indexer construction waits for GPU work beside it before failing
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EizBKhTqrAYago9KJG3dA3
This commit is contained in:
commit
8dbaa9f8d7
11 files changed
+181
-30
No files matched your search
+35
-12
@@ -28,27 +28,50 @@ std::string get_gpu_description() {
|
||||
}
|
||||
|
||||
namespace {
|
||||
std::mutex gpu_work_beside_mutex;
|
||||
std::condition_variable gpu_work_beside_done;
|
||||
int gpu_work_beside = 0;
|
||||
// How many of one kind of GPU work are running, for a thread to wait until none is.
|
||||
struct GPUWorkCount {
|
||||
std::mutex m;
|
||||
std::condition_variable none;
|
||||
int n = 0;
|
||||
void Add() {
|
||||
std::lock_guard lock(m);
|
||||
++n;
|
||||
}
|
||||
void Remove() {
|
||||
{
|
||||
std::lock_guard lock(m);
|
||||
--n;
|
||||
}
|
||||
none.notify_all();
|
||||
}
|
||||
};
|
||||
GPUWorkCount gpu_work_beside, gpu_image_passes;
|
||||
}
|
||||
|
||||
GPUWorkBeside::GPUWorkBeside() {
|
||||
std::lock_guard lock(gpu_work_beside_mutex);
|
||||
++gpu_work_beside;
|
||||
gpu_work_beside.Add();
|
||||
}
|
||||
|
||||
GPUWorkBeside::~GPUWorkBeside() {
|
||||
{
|
||||
std::lock_guard lock(gpu_work_beside_mutex);
|
||||
--gpu_work_beside;
|
||||
}
|
||||
gpu_work_beside_done.notify_all();
|
||||
gpu_work_beside.Remove();
|
||||
}
|
||||
|
||||
bool wait_for_gpu_work_beside(std::chrono::seconds timeout) {
|
||||
std::unique_lock lock(gpu_work_beside_mutex);
|
||||
return gpu_work_beside_done.wait_for(lock, timeout, [] { return gpu_work_beside == 0; });
|
||||
std::unique_lock lock(gpu_work_beside.m);
|
||||
return gpu_work_beside.none.wait_for(lock, timeout, [] { return gpu_work_beside.n == 0; });
|
||||
}
|
||||
|
||||
GPUImagePass::GPUImagePass() {
|
||||
gpu_image_passes.Add();
|
||||
}
|
||||
|
||||
GPUImagePass::~GPUImagePass() {
|
||||
gpu_image_passes.Remove();
|
||||
}
|
||||
|
||||
void wait_for_gpu_image_passes() {
|
||||
std::unique_lock lock(gpu_image_passes.m);
|
||||
gpu_image_passes.none.wait(lock, [] { return gpu_image_passes.n == 0; });
|
||||
}
|
||||
|
||||
#ifndef JFJOCH_USE_CUDA
|
||||
|
||||
Reference in new issue
Block a user