NFFT / NFFT3.jl

NFFT3 Julia Package
GNU General Public License v3.0
8 stars 2 forks source link

Set number of threads #12

Open tknopp opened 2 years ago

tknopp commented 2 years ago

Hi,

I am working at some benchmarks between NFFT.jl and NFFT3 and would like make a comparison with multi-threading turned off. Is this doable with NFFT3.jl ? It seem by default the number of threads is set to 4. Is there a simple way to change this? Ideally without compiling any stuff since I want to make NFFT3 a test dependency and run the tests with CI.

Thanks

Tobi

michaelquellmalz commented 2 years ago

It should be possible by calling ccall(("nfft_set_num_threads",lib_path_nfft),Nothing,(Int64,),convert(Int64,nthreads)) where nthreads is the new number of threads and lib_path_nfft is from NFFT3.jl. Please be aware that this needs to be called before creating the NFFT Plan (otherwise the FFT step might be executed with the old number of threads).

This was already implemented by @tvolkmer in the main repo https://github.com/NFFT/nfft/blob/develop/julia/nfft/NFFT.jl#L352. @mischmi96 I think we should add the function also in this repo.

tknopp commented 2 years ago

This would be great. In the mean time I am working on some accuracy graphs where I run over a combination of m and sigmas. On a first sight, that looks quite good, i.e. both libraries are calculating the same thing.

tknopp commented 2 years ago

I get

julia> ccall(("nfft_set_num_threads",NFFT3.lib_path_nfft),Nothing,(Int64,),convert(Int64,1))
ERROR: could not load symbol "nfft_set_num_threads":
dlsym(0x7ffe5466bdc0, nfft_set_num_threads): symbol not found

but I can call the getter, i.e. the binary seems to miss that symbol as the error message indicates.

michaelquellmalz commented 2 years ago

Oh, the nfft_set_num_threads is only available in the new version 3.5.3. We are preparing the release, which is currently still tested under Macos by @kevinmatthes.

Meanwhile, it should work with ccall(("omp_set_num_threads",NFFT3.lib_path_nfft),Nothing,(Int64,),convert(Int64,nthreads))

tknopp commented 2 years ago

seems to work, thanks!