GPU memory over the run: FFT indexers given back after the last indexing; speculative probe takes turns with the merge on a small card
- IndexerThreadPool::ReleaseIndexers(): each worker drops the indexers it has built (once its current frame is done) and the allocation pool is trimmed, so their memory goes back to the card, not only to the pool. A later frame builds them again, as on first use. A rotation pass calls it once its first pass is done and again when the leftover-lattice census - the last of its indexing - ends. Measured on the RTX 5080: the 1.24 GB (pre-pass) / 0.62 GB (later passes) the pass's pool held through the image pass and the scaling is gone; 4nwv's pre-pass image pass peaks 5.97 instead of 7.18 GB of device memory. - GPUMerge: the main line holds one through ScaleMergeAndSymmetry. The speculative geometry probe (GPUWorkBeside(after_merges=true)) waits for it on a card below the take-turns size (12 GB), where the probe's FFT indexers and image workers beside the merge's arrays would overfill the card - on a Windows (WDDM) card that does not fail an allocation but pages it and crawls. The merge waits for nothing, so nothing the merge waits on (the rotation-scale walk's probes) can wait in a circle with it. No change on a 16 GB card. Output unchanged: p.hkl byte-identical on cytc_x10sa, myob_x10sa, 4nwv and 8qaw on this card; also identical with the card's total read as 8.55 GB (10 / 9 image workers instead of 16) and with 4 image workers, so the worker count does not change the result. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
640b2e464a
commit
1c3a2e202c
7 files changed
+174
-10
No files matched your search
@@ -147,14 +147,28 @@ void IndexerThread::Worker(int threadid) {
|
||||
|
||||
while (true) {
|
||||
std::unique_ptr<TaskInput> input;
|
||||
bool drop = false;
|
||||
// Look for task + handle stop
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(m);
|
||||
c_start.wait(lock, [this] { return stop || state == TaskState::READY; });
|
||||
c_start.wait(lock, [this] { return stop || drop_indexers || state == TaskState::READY; });
|
||||
if (stop && (state != TaskState::READY))
|
||||
return;
|
||||
state = TaskState::RUNNING;
|
||||
input = std::move(task_input);
|
||||
if (state == TaskState::READY) {
|
||||
state = TaskState::RUNNING;
|
||||
input = std::move(task_input);
|
||||
} else
|
||||
drop = true;
|
||||
}
|
||||
if (drop) {
|
||||
fft_indexer.reset();
|
||||
ffbidx_indexer.reset();
|
||||
fftw_indexer.reset();
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(m);
|
||||
drop_indexers = false;
|
||||
}
|
||||
c_done.notify_all();
|
||||
}
|
||||
if (input) {
|
||||
std::unique_ptr<IndexerResult> tmp_result;
|
||||
@@ -210,6 +224,15 @@ void IndexerThread::Worker(int threadid) {
|
||||
}
|
||||
}
|
||||
|
||||
void IndexerThread::Release() {
|
||||
std::unique_lock<std::mutex> lock(m);
|
||||
if (stop)
|
||||
return;
|
||||
drop_indexers = true;
|
||||
c_start.notify_all();
|
||||
c_done.wait(lock, [this] { return !drop_indexers; });
|
||||
}
|
||||
|
||||
void IndexerThread::Finalize() {
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(m);
|
||||
@@ -257,6 +280,19 @@ IndexerThreadPool::IndexerThreadPool(const IndexingSettings &settings, IndexerCo
|
||||
tasks.emplace_back(std::make_unique<IndexerThread>(std::cref(settings), i, construction, beside));
|
||||
}
|
||||
|
||||
void IndexerThreadPool::ReleaseIndexers() {
|
||||
for (auto &t : tasks)
|
||||
t->Release();
|
||||
#ifdef JFJOCH_USE_CUDA
|
||||
// Their buffers went back to the allocation pool, which would keep them reserved for the next
|
||||
// buffer of whoever asks; hand them to the card.
|
||||
for (int32_t d = 0; d < get_gpu_count(); d++) {
|
||||
ScopedGpuPin pin(d);
|
||||
cuda_trim_allocation_pool();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int IndexerThreadPool::GetFreeWorker() {
|
||||
std::unique_lock<std::mutex> lock(m);
|
||||
|
||||
|
||||
Reference in new issue
Block a user