FFTW is no longer fetched, built or linked - not even by jfjoch_test. The JFJOCH_USE_FFTW define and its #ifdefs are gone: the CPU FFT indexer, the viewer's FFT chart and the rest are always built. The test that checked pocketfft against FFTW now checks it against a direct double-precision DFT (forward) and a round trip (backward), on the same shapes. The user-facing name stays: -X FFTW, the OpenAPI enum value, the CBOR and HDF5 strings - the CPU FFT indexer is still called FFTW, only the implementation changed; the CLI page says so. Under MSVC pocketfft is told explicitly to run scalar (it already decides so itself: its vector code needs the GCC/Clang vector extension). Licences: licenses/fftw.txt, its COLLECT.sh line, the THIRD_PARTY_NOTICES row and note, and the viewer's embedded copy removed; docs/THIRD_PARTY_NOTICES.md regenerated with update_version.sh's own sed block. CLAUDE.md and the docs that named FFTW as the library now name pocketfft. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UqXYdJDrM65gxsCn2PrbfK
76 lines
2.9 KiB
C++
76 lines
2.9 KiB
C++
// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#include "CpuFFT.h"
|
|
|
|
// Under a name of its own: gemmi includes the same header with POCKETFFT_NO_MULTITHREADING, and its
|
|
// templates and ours must not be merged by the linker into one (single-threaded or not) copy.
|
|
#define pocketfft jfjoch_pocketfft
|
|
// MSVC: the scalar code (pocketfft vectorises only with the GCC/Clang vector extension, and decides so
|
|
// itself; said here so that it stays so).
|
|
#ifdef _MSC_VER
|
|
#define POCKETFFT_NO_VECTORS
|
|
#endif
|
|
#include "../gemmi_gph/gemmi/third_party/pocketfft_hdronly.h"
|
|
|
|
namespace cpu_fft {
|
|
|
|
namespace {
|
|
|
|
// pocketfft counts strides in bytes.
|
|
pocketfft::stride_t Bytes(const Strides &s, size_t element) {
|
|
pocketfft::stride_t out(s.size());
|
|
for (size_t i = 0; i < s.size(); i++)
|
|
out[i] = s[i] * static_cast<std::ptrdiff_t>(element);
|
|
return out;
|
|
}
|
|
|
|
Strides Contiguous(const Shape &shape) {
|
|
Strides s(shape.size());
|
|
std::ptrdiff_t step = 1;
|
|
for (size_t i = shape.size(); i-- > 0;) {
|
|
s[i] = step;
|
|
step *= static_cast<std::ptrdiff_t>(shape[i]);
|
|
}
|
|
return s;
|
|
}
|
|
|
|
Shape Halved(Shape shape, size_t axis) {
|
|
shape[axis] = shape[axis] / 2 + 1;
|
|
return shape;
|
|
}
|
|
|
|
} // namespace
|
|
|
|
void R2C(const Shape &shape, const Strides &stride_in, const Strides &stride_out, const Shape &axes,
|
|
const float *in, std::complex<float> *out, size_t nthreads) {
|
|
pocketfft::r2c<float>(shape, Bytes(stride_in, sizeof(float)), Bytes(stride_out, sizeof(std::complex<float>)),
|
|
axes, pocketfft::FORWARD, in, out, 1.0f, nthreads);
|
|
}
|
|
|
|
void R2C(const Shape &shape, const Shape &axes, const float *in, std::complex<float> *out, size_t nthreads) {
|
|
R2C(shape, Contiguous(shape), Contiguous(Halved(shape, axes.back())), axes, in, out, nthreads);
|
|
}
|
|
|
|
void C2R(const Shape &shape, const Shape &axes, std::complex<float> *in, float *out, size_t nthreads) {
|
|
const Shape half = Halved(shape, axes.back());
|
|
const pocketfft::stride_t stride_in = Bytes(Contiguous(half), sizeof(std::complex<float>));
|
|
if (axes.size() > 1)
|
|
pocketfft::c2c<float>(half, stride_in, stride_in, Shape(axes.begin(), axes.end() - 1), pocketfft::BACKWARD,
|
|
in, in, 1.0f, nthreads);
|
|
pocketfft::c2r<float>(shape, stride_in, Bytes(Contiguous(shape), sizeof(float)), axes.back(),
|
|
pocketfft::BACKWARD, in, out, 1.0f, nthreads);
|
|
}
|
|
|
|
void C2C(const Shape &shape, const Strides &stride, const Shape &axes, bool forward, std::complex<float> *data,
|
|
size_t nthreads) {
|
|
const pocketfft::stride_t s = Bytes(stride, sizeof(std::complex<float>));
|
|
pocketfft::c2c<float>(shape, s, s, axes, forward, data, data, 1.0f, nthreads);
|
|
}
|
|
|
|
void C2C(const Shape &shape, const Shape &axes, bool forward, std::complex<float> *data, size_t nthreads) {
|
|
C2C(shape, Contiguous(shape), axes, forward, data, nthreads);
|
|
}
|
|
|
|
} // namespace cpu_fft
|