FFTW's planner (every fftwf_plan_* and fftwf_destroy_plan) shares global state and is not thread-safe; executing a plan is. FFTIndexerCPU and BeamCenterFFTCPU each guarded their planning with a lock of their own, TranslationalNCS and the viewer's spectrum with none, and ModelFFT with a third - which does not stop two of them planning at once. common/FFTWPlannerLock.h holds the one mutex they all now take. No numerical change. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013nW6FNRP1bBJJ8pfHiByAT
15 lines
550 B
C++
15 lines
550 B
C++
// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#pragma once
|
|
|
|
#include <mutex>
|
|
|
|
// FFTW's planner - every fftwf_plan_* and fftwf_destroy_plan call - shares global state and is not
|
|
// thread-safe; executing a plan is. So every piece of code that makes or destroys a plan takes this
|
|
// one lock, not a lock of its own: two private locks do not stop two planners running at once.
|
|
inline std::mutex &FFTWPlannerMutex() {
|
|
static std::mutex m;
|
|
return m;
|
|
}
|