@@ -49,7 +49,10 @@ def _set_fftw_variables(self):
4949 if not hasattr (self , 'BLAS_LIB_DIR' ):
5050 raise EasyBuildError ("_set_fftw_variables: IntelFFT based on IntelMKL (no BLAS_LIB_DIR found)" )
5151
52+ imklroot = get_software_root (self .FFT_MODULE_NAME [0 ])
5253 imklver = get_software_version (self .FFT_MODULE_NAME [0 ])
54+ self .FFT_LIB_DIR = self .BLAS_LIB_DIR
55+ self .FFT_INCLUDE_DIR = [os .path .join (d , 'fftw' ) for d in self .BLAS_INCLUDE_DIR ]
5356
5457 picsuff = ''
5558 if self .options .get ('pic' , None ):
@@ -69,54 +72,47 @@ def _set_fftw_variables(self):
6972 raise EasyBuildError (error_msg )
7073
7174 interface_lib = "fftw3xc%s%s" % (compsuff , picsuff )
72- fftw_libs = [interface_lib ]
73- cluster_interface_lib = None
75+ fft_lib_dirs = [os .path .join (imklroot , d ) for d in self .FFT_LIB_DIR ]
76+
77+ def fftw_lib_exists (libname ):
78+ """Helper function to check whether FFTW library with specified name exists."""
79+ return any (os .path .exists (os .path .join (d , "lib%s.a" % libname )) for d in fft_lib_dirs )
80+
81+ # interface libs can be optional:
82+ # MKL >= 10.2 include fftw3xc and fftw3xf interfaces in LIBBLAS=libmkl_gf/libmkl_intel
83+ # See https://software.intel.com/en-us/articles/intel-mkl-main-libraries-contain-fftw3-interfaces
84+ # The cluster interface libs (libfftw3x_cdft*) can be omitted if the toolchain does not provide MPI-FFTW
85+ # interfaces.
86+ fftw_libs = []
87+ if fftw_lib_exists (interface_lib ) or LooseVersion (imklver ) < LooseVersion ("10.2" ):
88+ fftw_libs = [interface_lib ]
89+
7490 if self .options .get ('usempi' , False ):
7591 # add cluster interface for recent imkl versions
76- if LooseVersion (imklver ) >= LooseVersion ('10.3' ):
92+ # only get cluster_interface_lib from seperate module imkl-FFTW, rest via libmkl_gf/libmkl_intel
93+ imklfftwroot = get_software_root ('imkl-FFTW' )
94+ if LooseVersion (imklver ) >= LooseVersion ('10.3' ) and (fftw_libs or imklfftwroot ):
7795 suff = picsuff
7896 if LooseVersion (imklver ) >= LooseVersion ('11.0.2' ):
7997 suff = bitsuff + suff
8098 cluster_interface_lib = 'fftw3x_cdft%s' % suff
8199 fftw_libs .append (cluster_interface_lib )
82100 fftw_libs .append ("mkl_cdft_core" ) # add cluster dft
83101 fftw_libs .extend (self .variables ['LIBBLACS' ].flatten ()) # add BLACS; use flatten because ListOfList
102+ if imklfftwroot :
103+ fft_lib_dirs += [os .path .join (imklfftwroot , 'lib' )]
104+ self .FFT_LIB_DIR = [os .path .join (imklfftwroot , 'lib' )]
84105
85106 fftw_mt_libs = fftw_libs + [x % self .BLAS_LIB_MAP for x in self .BLAS_LIB_MT ]
86107
87108 self .log .debug ('fftw_libs %s' % fftw_libs .__repr__ ())
88109 fftw_libs .extend (self .variables ['LIBBLAS' ].flatten ()) # add BLAS libs (contains dft)
89110 self .log .debug ('fftw_libs %s' % fftw_libs .__repr__ ())
90111
91- self .FFT_LIB_DIR = self .BLAS_LIB_DIR
92- self .FFT_INCLUDE_DIR = [os .path .join (d , 'fftw' ) for d in self .BLAS_INCLUDE_DIR ]
93-
94112 # building the FFTW interfaces is optional,
95113 # so make sure libraries are there before FFT_LIB is set
96- imklroot = get_software_root (self .FFT_MODULE_NAME [0 ])
97- fft_lib_dirs = [os .path .join (imklroot , d ) for d in self .FFT_LIB_DIR ]
98- imklfftwroot = get_software_root ('imkl-FFTW' )
99- if imklfftwroot :
100- # only get cluster_interface_lib from seperate module imkl-FFTW, rest via libmkl_gf/libmkl_intel
101- fft_lib_dirs += [os .path .join (imklfftwroot , 'lib' )]
102- fftw_libs .remove (interface_lib )
103- fftw_mt_libs .remove (interface_lib )
104-
105- def fftw_lib_exists (libname ):
106- """Helper function to check whether FFTW library with specified name exists."""
107- return any (os .path .exists (os .path .join (d , "lib%s.a" % libname )) for d in fft_lib_dirs )
108-
109- if not fftw_lib_exists (interface_lib ) and LooseVersion (imklver ) >= LooseVersion ("10.2" ):
110- # interface libs can be optional:
111- # MKL >= 10.2 include fftw3xc and fftw3xf interfaces in LIBBLAS=libmkl_gf/libmkl_intel
112- # See https://software.intel.com/en-us/articles/intel-mkl-main-libraries-contain-fftw3-interfaces
113- # The cluster interface libs (libfftw3x_cdft*) can be omitted if the toolchain does not provide MPI-FFTW
114- # interfaces.
115- fftw_libs = [lib for lib in fftw_libs if lib not in [interface_lib , cluster_interface_lib ]]
116- fftw_mt_libs = [lib for lib in fftw_mt_libs if lib not in [interface_lib , cluster_interface_lib ]]
117-
118114 # filter out libraries from list of FFTW libraries to check for if they are not provided by Intel MKL
119- check_fftw_libs = [lib for lib in fftw_libs if lib not in ['dl' , 'gfortran' ]]
115+ check_fftw_libs = [lib for lib in fftw_libs + fftw_mt_libs if lib not in ['dl' , 'gfortran' ]]
120116
121117 missing_fftw_libs = [lib for lib in check_fftw_libs if not fftw_lib_exists (lib )]
122118 if missing_fftw_libs :
@@ -128,5 +124,4 @@ def fftw_lib_exists(libname):
128124 raise EasyBuildError (msg )
129125 else :
130126 self .FFT_LIB = fftw_libs
131-
132- self .FFT_LIB_MT = fftw_mt_libs
127+ self .FFT_LIB_MT = fftw_mt_libs
0 commit comments