Skip to content

Commit 8f014a8

Browse files
authored
Merge pull request #4012 from ComputeCanada/fftw.mpi
Support FFTW.MPI module in framework (FFT*DIR variables)
2 parents af140b3 + b34bfc1 commit 8f014a8

File tree

6 files changed

+196
-1
lines changed

6 files changed

+196
-1
lines changed

easybuild/toolchains/fft/fftw.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
from easybuild.tools.build_log import EasyBuildError
3535
from easybuild.tools.toolchain.fft import Fft
36+
from easybuild.tools.modules import get_software_root
3637

3738

3839
class Fftw(Fft):
@@ -56,6 +57,11 @@ def _set_fftw_variables(self):
5657
fftw_libs = ["fftw%s" % suffix]
5758
if self.options.get('usempi', False):
5859
fftw_libs.insert(0, "fftw%s_mpi" % suffix)
60+
fftwmpiroot = get_software_root('FFTW.MPI')
61+
if fftwmpiroot:
62+
# get libfft%_mpi via the FFTW.MPI module
63+
self.FFT_MODULE_NAME = ['FFTW.MPI']
64+
5965
fftw_libs_mt = ["fftw%s" % suffix]
6066
if self.options.get('openmp', False):
6167
fftw_libs_mt.insert(0, "fftw%s_omp" % suffix)

test/framework/modules.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454

5555

5656
# number of modules included for testing purposes
57-
TEST_MODULES_COUNT = 87
57+
TEST_MODULES_COUNT = 90
5858

5959

6060
class ModulesTest(EnhancedTestCase):
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#%Module
2+
3+
proc ModulesHelp { } {
4+
puts stderr { FFTW is a C subroutine library for computing the discrete Fourier transform (DFT)
5+
in one or more dimensions, of arbitrary input size, and of both real and complex data. - Homepage: http://www.fftw.org
6+
}
7+
}
8+
9+
module-whatis {FFTW is a C subroutine library for computing the discrete Fourier transform (DFT)
10+
in one or more dimensions, of arbitrary input size, and of both real and complex data. - Homepage: http://www.fftw.org}
11+
12+
set root /home-2/khoste/.local/easybuild/software/FFTW.MPI/3.3.7
13+
14+
conflict FFTW.MPI
15+
16+
if { ![is-loaded gompi/2018a] } {
17+
module load gompi/2018a
18+
}
19+
20+
prepend-path CPATH $root/include
21+
prepend-path LD_LIBRARY_PATH $root/lib
22+
prepend-path MANPATH $root/share/man
23+
prepend-path PATH $root/bin
24+
prepend-path PKG_CONFIG_PATH $root/lib/pkgconfig
25+
26+
setenv EBROOTFFTWMPI "$root"
27+
setenv EBVERSIONFFTWMPI "3.3.7"
28+
setenv EBDEVELFFTWMPI "$root/easybuild/FFTW.MPI-3.3.7-easybuild-devel"
29+
30+
31+
# built with EasyBuild version 1.4.0dev

test/framework/modules/FFTW/3.3.7

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#%Module
2+
3+
proc ModulesHelp { } {
4+
puts stderr { FFTW is a C subroutine library for computing the discrete Fourier transform (DFT)
5+
in one or more dimensions, of arbitrary input size, and of both real and complex data. - Homepage: http://www.fftw.org
6+
}
7+
}
8+
9+
module-whatis {FFTW is a C subroutine library for computing the discrete Fourier transform (DFT)
10+
in one or more dimensions, of arbitrary input size, and of both real and complex data. - Homepage: http://www.fftw.org}
11+
12+
set root /home-2/khoste/.local/easybuild/software/FFTW/3.3.7
13+
14+
conflict FFTW
15+
16+
if { ![is-loaded gompi/2018a] } {
17+
module load gompi/2018a
18+
}
19+
20+
prepend-path CPATH $root/include
21+
prepend-path LD_LIBRARY_PATH $root/lib
22+
prepend-path MANPATH $root/share/man
23+
prepend-path PATH $root/bin
24+
prepend-path PKG_CONFIG_PATH $root/lib/pkgconfig
25+
26+
setenv EBROOTFFTW "$root"
27+
setenv EBVERSIONFFTW "3.3.7"
28+
setenv EBDEVELFFTW "$root/easybuild/FFTW-3.3.7-easybuild-devel"
29+
30+
31+
# built with EasyBuild version 1.4.0dev
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#%Module
2+
3+
proc ModulesHelp { } {
4+
puts stderr { GCC based compiler toolchain including
5+
OpenMPI for MPI support, OpenBLAS (BLAS and LAPACK support), FFTW and ScaLAPACK. - Homepage: (none)
6+
}
7+
}
8+
9+
module-whatis {GCC based compiler toolchain including
10+
OpenMPI for MPI support, OpenBLAS (BLAS and LAPACK support), FFTW and ScaLAPACK. - Homepage: (none)}
11+
12+
set root /prefix/software/foss/2018a
13+
14+
conflict foss
15+
16+
if { ![is-loaded GCC/6.4.0-2.28] } {
17+
module load GCC/6.4.0-2.28
18+
}
19+
20+
if { ![is-loaded OpenMPI/2.1.2-GCC-6.4.0-2.28] } {
21+
module load OpenMPI/2.1.2-GCC-6.4.0-2.28
22+
}
23+
24+
if { ![is-loaded OpenBLAS/0.2.20-GCC-6.4.0-2.28] } {
25+
module load OpenBLAS/0.2.20-GCC-6.4.0-2.28
26+
}
27+
28+
if { ![is-loaded FFTW/3.3.7] } {
29+
module load FFTW/3.3.7
30+
}
31+
32+
if { ![is-loaded FFTW.MPI/3.3.7 ] } {
33+
module load FFTW.MPI/3.3.7
34+
}
35+
36+
if { ![is-loaded ScaLAPACK/2.0.2-gompi-2018a-OpenBLAS-0.2.20] } {
37+
module load ScaLAPACK/2.0.2-gompi-2018a-OpenBLAS-0.2.20
38+
}
39+
40+
41+
setenv EBROOTFOSS "$root"
42+
setenv EBVERSIONFOSS "2018a"
43+
setenv EBDEVELFOSS "$root/easybuild/foss-2018a-easybuild-devel"
44+
45+
46+
# built with EasyBuild version 1.4.0dev

test/framework/toolchain.py

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,60 @@ def test_fft_env_vars_foss(self):
10171017
self.assertEqual(tc.get_variable('LIBFFT'), '-lfftw3_mpi -lfftw3')
10181018
self.assertEqual(tc.get_variable('LIBFFT_MT'), '-lfftw3 -lpthread')
10191019

1020+
self.modtool.purge()
1021+
self.setup_sandbox_for_foss_fftw(self.test_prefix)
1022+
self.modtool.prepend_module_path(self.test_prefix)
1023+
1024+
tc = self.get_toolchain('foss', version='2018a-FFTW.MPI')
1025+
tc.prepare()
1026+
1027+
fft_static_libs = 'libfftw3.a'
1028+
self.assertEqual(tc.get_variable('FFT_STATIC_LIBS'), fft_static_libs)
1029+
self.assertEqual(tc.get_variable('FFTW_STATIC_LIBS'), fft_static_libs)
1030+
1031+
fft_static_libs_mt = 'libfftw3.a,libpthread.a'
1032+
self.assertEqual(tc.get_variable('FFT_STATIC_LIBS_MT'), fft_static_libs_mt)
1033+
self.assertEqual(tc.get_variable('FFTW_STATIC_LIBS_MT'), fft_static_libs_mt)
1034+
1035+
self.assertEqual(tc.get_variable('LIBFFT'), '-lfftw3')
1036+
self.assertEqual(tc.get_variable('LIBFFT_MT'), '-lfftw3 -lpthread')
1037+
1038+
fft_lib_dir = os.path.join(modules.get_software_root('FFTW'), 'lib')
1039+
self.assertEqual(tc.get_variable('FFT_LIB_DIR'), fft_lib_dir)
1040+
1041+
tc = self.get_toolchain('foss', version='2018a-FFTW.MPI')
1042+
tc.set_options({'openmp': True})
1043+
tc.prepare()
1044+
1045+
self.assertEqual(tc.get_variable('FFT_STATIC_LIBS'), fft_static_libs)
1046+
self.assertEqual(tc.get_variable('FFTW_STATIC_LIBS'), fft_static_libs)
1047+
1048+
self.assertEqual(tc.get_variable('FFT_STATIC_LIBS_MT'), 'libfftw3_omp.a,' + fft_static_libs_mt)
1049+
self.assertEqual(tc.get_variable('FFTW_STATIC_LIBS_MT'), 'libfftw3_omp.a,' + fft_static_libs_mt)
1050+
1051+
self.assertEqual(tc.get_variable('LIBFFT'), '-lfftw3')
1052+
self.assertEqual(tc.get_variable('LIBFFT_MT'), '-lfftw3_omp -lfftw3 -lpthread')
1053+
1054+
fft_lib_dir = os.path.join(modules.get_software_root('FFTW'), 'lib')
1055+
self.assertEqual(tc.get_variable('FFT_LIB_DIR'), fft_lib_dir)
1056+
1057+
tc = self.get_toolchain('foss', version='2018a-FFTW.MPI')
1058+
tc.set_options({'usempi': True})
1059+
tc.prepare()
1060+
1061+
fft_static_libs = 'libfftw3_mpi.a,libfftw3.a'
1062+
self.assertEqual(tc.get_variable('FFT_STATIC_LIBS'), fft_static_libs)
1063+
self.assertEqual(tc.get_variable('FFTW_STATIC_LIBS'), fft_static_libs)
1064+
1065+
self.assertEqual(tc.get_variable('FFT_STATIC_LIBS_MT'), fft_static_libs_mt)
1066+
self.assertEqual(tc.get_variable('FFTW_STATIC_LIBS_MT'), fft_static_libs_mt)
1067+
1068+
self.assertEqual(tc.get_variable('LIBFFT'), '-lfftw3_mpi -lfftw3')
1069+
self.assertEqual(tc.get_variable('LIBFFT_MT'), '-lfftw3 -lpthread')
1070+
1071+
fft_lib_dir = os.path.join(modules.get_software_root('FFTW.MPI'), 'lib')
1072+
self.assertEqual(tc.get_variable('FFT_LIB_DIR'), fft_lib_dir)
1073+
10201074
def test_fft_env_vars_intel(self):
10211075
"""Test setting of $FFT* environment variables using intel toolchain."""
10221076

@@ -1174,6 +1228,33 @@ def test_fosscuda(self):
11741228
# check CUDA runtime lib
11751229
self.assertTrue("-lrt -lcudart" in tc.get_variable('LIBS'))
11761230

1231+
def setup_sandbox_for_foss_fftw(self, moddir, fftwver='3.3.7'):
1232+
"""Set up sandbox for foss FFTW and FFTW.MPI"""
1233+
# hack to make foss FFTW lib check pass
1234+
# create dummy FFTW and FFTW.MPI modules
1235+
1236+
fftw_module_path = os.path.join(moddir, 'FFTW', fftwver)
1237+
fftw_dir = os.path.join(self.test_prefix, 'software', 'FFTW', fftwver)
1238+
1239+
fftw_mod_txt = '\n'.join([
1240+
"#%Module",
1241+
"setenv EBROOTFFTW %s" % fftw_dir,
1242+
"setenv EBVERSIONFFTW %s" % fftwver,
1243+
])
1244+
write_file(fftw_module_path, fftw_mod_txt)
1245+
1246+
fftw_mpi_module_path = os.path.join(moddir, 'FFTW.MPI', fftwver)
1247+
fftw_mpi_dir = os.path.join(self.test_prefix, 'software', 'FFTW.MPI', fftwver)
1248+
fftw_mpi_mod_txt = '\n'.join([
1249+
"#%Module",
1250+
"setenv EBROOTFFTWMPI %s" % fftw_mpi_dir,
1251+
"setenv EBVERSIONFFTWMPI %s" % fftwver,
1252+
])
1253+
write_file(fftw_mpi_module_path, fftw_mpi_mod_txt)
1254+
1255+
os.makedirs(os.path.join(fftw_dir, 'lib'))
1256+
os.makedirs(os.path.join(fftw_mpi_dir, 'lib'))
1257+
11771258
def setup_sandbox_for_intel_fftw(self, moddir, imklver='2018.1.163'):
11781259
"""Set up sandbox for Intel FFTW"""
11791260
# hack to make Intel FFTW lib check pass

0 commit comments

Comments
 (0)