-
Notifications
You must be signed in to change notification settings - Fork 79
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
Provide a user level locking mechanism for FFTW #548
Merged
Merged
Commits on Sep 10, 2024
-
Provide a user level locking mechanism for FFTW
This commit provides a basic interface for the user to provide a lock around `fftw` calls. This is because any plan manipulation functions in `fftw` (make, destroy) are not thread-safe. See example code here: ```c++ #include <vector> #include <mutex> #include <fftw3.h> #include <finufft.h> #include <omp.h> using namespace std; #define N 65384 void locker(void *lck) { reinterpret_cast<recursive_mutex *>(lck)->lock(); } void unlocker(void *lck) { reinterpret_cast<recursive_mutex *>(lck)->unlock(); } int main() { int64_t Ns[3]; // guru describes mode array by vector [N1,N2..] Ns[0] = N; recursive_mutex lck; finufft_opts opts; finufft_default_opts(&opts); opts.nthreads = 1; opts.debug = 0; opts.fftw_lock_fun = locker; opts.fftw_unlock_fun = unlocker; opts.fftw_lock_data = reinterpret_cast<void *>(&lck); // random nonuniform points (x) and complex strengths (c)... vector<complex<double>> c(N); // init FFTW threads fftw_init_threads(); // FFTW and FINUFFT execution using OpenMP parallelization #pragma omp parallel for for (int j = 0; j < 100; ++j) { // allocate output array for FFTW... vector<complex<double>> F1(N); // FFTW plan lck.lock(); fftw_plan_with_nthreads(1); fftw_plan plan = fftw_plan_dft_1d(N, reinterpret_cast<fftw_complex*>(c.data()), reinterpret_cast<fftw_complex*>(F1.data()), FFTW_FORWARD, FFTW_ESTIMATE); fftw_destroy_plan(plan); lck.unlock(); // FINUFFT plan finufft_plan nufftplan; finufft_makeplan(1, 1, Ns, 1, 1, 1e-6, &nufftplan, &opts); finufft_destroy(nufftplan); } return 0; } ```
Configuration menu - View commit details
-
Copy full SHA for 1d9fb8e - Browse repository at this point
Copy the full SHA 1d9fb8eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 904baf3 - Browse repository at this point
Copy the full SHA 904baf3View commit details -
Configuration menu - View commit details
-
Copy full SHA for f129880 - Browse repository at this point
Copy the full SHA f129880View commit details -
Configuration menu - View commit details
-
Copy full SHA for 49675c0 - Browse repository at this point
Copy the full SHA 49675c0View commit details -
Configuration menu - View commit details
-
Copy full SHA for 024bfa8 - Browse repository at this point
Copy the full SHA 024bfa8View commit details -
Configuration menu - View commit details
-
Copy full SHA for 1e2c047 - Browse repository at this point
Copy the full SHA 1e2c047View commit details -
Configuration menu - View commit details
-
Copy full SHA for 8594b65 - Browse repository at this point
Copy the full SHA 8594b65View commit details
Commits on Sep 17, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 3de4ed5 - Browse repository at this point
Copy the full SHA 3de4ed5View commit details -
Revert "fftw_lock: share lock and init between float/double"
This reverts commit 8594b65.
Configuration menu - View commit details
-
Copy full SHA for 4dd9ad7 - Browse repository at this point
Copy the full SHA 4dd9ad7View commit details -
Configuration menu - View commit details
-
Copy full SHA for 0dd134c - Browse repository at this point
Copy the full SHA 0dd134cView commit details
Commits on Sep 18, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 5101cef - Browse repository at this point
Copy the full SHA 5101cefView commit details
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.