Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Follow-up to the big reorg PR #584

Merged
merged 13 commits into from
Nov 5, 2024
9 changes: 4 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,7 @@ if(FINUFFT_USE_CPU)
set(FFTW_VERSION 3.3.10)
set(XTL_VERSION 0.7.7)
set(XSIMD_VERSION 13.0.0)
# using latest ducc0 version for now as it fixes MacOS GCC build
set(DUCC0_VERSION b0beb85e03982344a31ebb119758d7aa3ef5d362)
ahbarnett marked this conversation as resolved.
Show resolved Hide resolved
set(DUCC0_VERSION ducc0_0_35_0)
set(FINUFFT_FFTW_LIBRARIES)
include(cmake/setupXSIMD.cmake)
if(FINUFFT_USE_DUCC0)
Expand Down Expand Up @@ -199,7 +198,7 @@ function(finufft_link_test target)
if(FINUFFT_USE_DUCC0)
target_compile_definitions(${target} PRIVATE FINUFFT_USE_DUCC0)
endif()
target_link_libraries(${target} PRIVATE finufft ${FINUFFT_FFTLIBS})
target_link_libraries(${target} PRIVATE finufft xsimd ${FINUFFT_FFTLIBS})
if(FINUFFT_USE_OPENMP)
target_link_libraries(${target} PRIVATE OpenMP::OpenMP_CXX)
target_link_options(${target} PRIVATE ${OpenMP_CXX_FLAGS})
Expand Down Expand Up @@ -258,7 +257,7 @@ if(FINUFFT_USE_CPU)
contrib/legendre_rule_fast.cpp
src/fft.cpp
src/finufft_core.cpp
src/simpleinterfaces.cpp
src/c_interface.cpp
fortran/finufftfort.cpp)
else()
add_library(
Expand All @@ -268,7 +267,7 @@ if(FINUFFT_USE_CPU)
contrib/legendre_rule_fast.cpp
src/fft.cpp
src/finufft_core.cpp
src/simpleinterfaces.cpp
src/c_interface.cpp
fortran/finufftfort.cpp)
endif()
set_finufft_options(finufft)
Expand Down
221 changes: 94 additions & 127 deletions fortran/finufftfort.cpp

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions include/finufft.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

// This contains both single and double precision user-facing commands.
// "macro-safe" rewrite, including the plan object, Barnett 5/21/22-6/7/22.
// They will clobber any prior macros starting FINUFFT*, so in the lib/test
// sources finufft.h must be included before defs.h
// They will clobber any prior macros starting FINUFFT*.

/* Devnotes.
A) Two precisions done by including the "either precision" headers twice.
Expand Down
137 changes: 0 additions & 137 deletions include/finufft/defs.h

This file was deleted.

42 changes: 28 additions & 14 deletions include/finufft/dirft.h
Original file line number Diff line number Diff line change
@@ -1,22 +1,36 @@
#ifndef DIRFT_H
#define DIRFT_H

#include <finufft/defs.h>
#include <finufft/finufft_core.h>

void dirft1d1(BIGINT nj, FLT *x, CPX *c, int isign, BIGINT ms, CPX *f);
void dirft1d2(BIGINT nj, FLT *x, CPX *c, int iflag, BIGINT ms, CPX *f);
void dirft1d3(BIGINT nj, FLT *x, CPX *c, int iflag, BIGINT nk, FLT *s, CPX *f);
template<typename T>
void dirft1d1(BIGINT nj, T *x, std::complex<T> *c, int isign, BIGINT ms,
std::complex<T> *f);
template<typename T>
void dirft1d2(BIGINT nj, T *x, std::complex<T> *c, int iflag, BIGINT ms,
std::complex<T> *f);
template<typename T>
void dirft1d3(BIGINT nj, T *x, std::complex<T> *c, int iflag, BIGINT nk, T *s,
std::complex<T> *f);

void dirft2d1(BIGINT nj, FLT *x, FLT *y, CPX *c, int iflag, BIGINT ms, BIGINT mt, CPX *f);
void dirft2d2(BIGINT nj, FLT *x, FLT *y, CPX *c, int iflag, BIGINT ms, BIGINT mt, CPX *f);
void dirft2d3(BIGINT nj, FLT *x, FLT *y, CPX *c, int iflag, BIGINT nk, FLT *s, FLT *t,
CPX *f);
template<typename T>
void dirft2d1(BIGINT nj, T *x, T *y, std::complex<T> *c, int iflag, BIGINT ms, BIGINT mt,
std::complex<T> *f);
template<typename T>
void dirft2d2(BIGINT nj, T *x, T *y, std::complex<T> *c, int iflag, BIGINT ms, BIGINT mt,
std::complex<T> *f);
template<typename T>
void dirft2d3(BIGINT nj, T *x, T *y, std::complex<T> *c, int iflag, BIGINT nk, T *s, T *t,
std::complex<T> *f);

void dirft3d1(BIGINT nj, FLT *x, FLT *y, FLT *z, CPX *c, int iflag, BIGINT ms, BIGINT mt,
BIGINT mu, CPX *f);
void dirft3d2(BIGINT nj, FLT *x, FLT *y, FLT *z, CPX *c, int iflag, BIGINT ms, BIGINT mt,
BIGINT mu, CPX *f);
void dirft3d3(BIGINT nj, FLT *x, FLT *y, FLT *z, CPX *c, int iflag, BIGINT nk, FLT *s,
FLT *t, FLT *u, CPX *f);
template<typename T>
void dirft3d1(BIGINT nj, T *x, T *y, T *z, std::complex<T> *c, int iflag, BIGINT ms,
BIGINT mt, BIGINT mu, std::complex<T> *f);
template<typename T>
void dirft3d2(BIGINT nj, T *x, T *y, T *z, std::complex<T> *c, int iflag, BIGINT ms,
BIGINT mt, BIGINT mu, std::complex<T> *f);
template<typename T>
void dirft3d3(BIGINT nj, T *x, T *y, T *z, std::complex<T> *c, int iflag, BIGINT nk, T *s,
T *t, T *u, std::complex<T> *f);

#endif
25 changes: 9 additions & 16 deletions include/finufft/fft.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ template<typename T> class Finufft_FFT_plan {
public:
[[maybe_unused]] Finufft_FFT_plan(void (*)(void *) = nullptr,
void (*)(void *) = nullptr, void * = nullptr) {}
// deleting these operations to be consistent with the FFTW plans (seel below)
Finufft_FFT_plan(const Finufft_FFT_plan &) = delete;
Finufft_FFT_plan &operator=(const Finufft_FFT_plan &) = delete;
[[maybe_unused]] void plan(const std::vector<int> & /*dims*/, size_t /*batchSize*/,
std::complex<T> * /*ptr*/, int /*sign*/, int /*options*/,
int /*nthreads*/) {}
[[maybe_unused]] static std::complex<T> *alloc_complex(size_t N) {
return new std::complex<T>[N];
}
[[maybe_unused]] static void free(std::complex<T> *ptr) { delete[] ptr; }

[[maybe_unused]] static void forget_wisdom() {}
[[maybe_unused]] static void cleanup() {}
Expand Down Expand Up @@ -63,11 +62,15 @@ template<> struct Finufft_FFT_plan<float> {
#endif
unlock();
}
// we have raw pointers in the object (the FFTW plan).
// If we allow copying those, we end up destroying the plans multiple times.
Finufft_FFT_plan(const Finufft_FFT_plan &) = delete;
[[maybe_unused]] ~Finufft_FFT_plan() {
lock();
fftwf_destroy_plan(plan_);
unlock();
}
Finufft_FFT_plan &operator=(const Finufft_FFT_plan &) = delete;

void plan
[[maybe_unused]] (const std::vector<int> &dims, size_t batchSize,
Expand All @@ -84,12 +87,6 @@ template<> struct Finufft_FFT_plan<float> {
1, int(nf), sign, unsigned(options));
unlock();
}
static std::complex<float> *alloc_complex [[maybe_unused]] (size_t N) {
return reinterpret_cast<std::complex<float> *>(fftwf_alloc_complex(N));
}
static void free [[maybe_unused]] (std::complex<float> *ptr) {
if (ptr) fftwf_free(reinterpret_cast<fftwf_complex *>(ptr));
}
void execute [[maybe_unused]] () { fftwf_execute(plan_); }

static void forget_wisdom [[maybe_unused]] () { fftwf_forget_wisdom(); }
Expand Down Expand Up @@ -131,11 +128,13 @@ template<> struct Finufft_FFT_plan<double> {
#endif
unlock();
}
Finufft_FFT_plan(const Finufft_FFT_plan &) = delete;
[[maybe_unused]] ~Finufft_FFT_plan() {
lock();
fftw_destroy_plan(plan_);
unlock();
}
Finufft_FFT_plan &operator=(const Finufft_FFT_plan &) = delete;

void plan
[[maybe_unused]] (const std::vector<int> &dims, size_t batchSize,
Expand All @@ -152,12 +151,6 @@ template<> struct Finufft_FFT_plan<double> {
sign, unsigned(options));
unlock();
}
static std::complex<double> *alloc_complex [[maybe_unused]] (size_t N) {
return reinterpret_cast<std::complex<double> *>(fftw_alloc_complex(N));
}
static void free [[maybe_unused]] (std::complex<double> *ptr) {
fftw_free(reinterpret_cast<fftw_complex *>(ptr));
}
void execute [[maybe_unused]] () { fftw_execute(plan_); }

static void forget_wisdom [[maybe_unused]] () { fftw_forget_wisdom(); }
Expand Down
Loading
Loading