Skip to content

Commit

Permalink
enable use of fftw threads
Browse files Browse the repository at this point in the history
Adds fftw_init_threads & fftw_plan_with_nthreads functions.
  • Loading branch information
nolta committed May 6, 2012
1 parent 9d52e44 commit 535a73c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
17 changes: 14 additions & 3 deletions base/signal_fftw.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
## FFT: Implement fft by calling fftw.

_jl_libfftw = dlopen("libfftw3")
_jl_libfftwf = dlopen("libfftw3f")

## Direction of FFT

const _jl_FFTW_FORWARD = int32(-1)
Expand Down Expand Up @@ -35,6 +32,20 @@ const _jl_FFTW_RODFT11 = int32(10)

## Julia wrappers around FFTW functions

# Threads

function fftw_init_threads()
stat = ccall(dlsym(_jl_libfftw,:fftw_init_threads), Int32, ())
@assert stat != 0
stat = ccall(dlsym(_jl_libfftwf,:fftwf_init_threads), Int32, ())
@assert stat != 0
end

function fftw_plan_with_nthreads(nthreads::Int)
ccall(dlsym(_jl_libfftw,:fftw_plan_with_nthreads), Void, (Int32,), nthreads)
ccall(dlsym(_jl_libfftwf,:fftwf_plan_with_nthreads), Void, (Int32,), nthreads)
end

# Execute

_jl_fftw_execute(precision::Union(Type{Float64}, Type{Complex128}), plan) =
Expand Down
4 changes: 2 additions & 2 deletions base/start_image.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ _jl_librandom = dlopen("librandom"); _jl_librandom_init();
# Optional libraries
const _jl_libblas = dlopen(_jl_libblas_name)
const _jl_liblapack = _jl_libblas
_jl_libfftw = dlopen("libfftw3")
_jl_libfftwf = dlopen("libfftw3f")
const _jl_libfftw = dlopen("libfftw3_threads")
const _jl_libfftwf = dlopen("libfftw3f_threads")

##_jl_libglpk = dlopen("libglpk")
##_jl_libglpk = dlopen("libglpk_wrapper")
Expand Down
2 changes: 1 addition & 1 deletion deps/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ fftw-$(FFTW_VER)-single/configure: fftw-$(FFTW_VER).tar.gz
touch $@
fftw-$(FFTW_VER)-single/config.status: fftw-$(FFTW_VER)-single/configure
cd fftw-$(FFTW_VER)-single && \
./configure --prefix=$(abspath $(USR)) $(FFTW_CONFIG) --enable-shared --disable-fortran --enable-sse --enable-single --enable-threads && \
./configure --prefix=$(abspath $(USR)) $(FFTW_CONFIG) --enable-sse --enable-single && \
$(MAKE) clean
touch $@
$(FFTW_SINGLE_OBJ_TARGET): fftw-$(FFTW_VER)-single/config.status
Expand Down

0 comments on commit 535a73c

Please sign in to comment.