2 # This file is part of the GROMACS molecular simulation package.
4 # Copyright (c) 2015,2016,2017,2018, by the GROMACS development team, led by
5 # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 # and including many others, as listed in the AUTHORS file in the
7 # top-level source directory and at http://www.gromacs.org.
9 # GROMACS is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU Lesser General Public License
11 # as published by the Free Software Foundation; either version 2.1
12 # of the License, or (at your option) any later version.
14 # GROMACS is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 # Lesser General Public License for more details.
19 # You should have received a copy of the GNU Lesser General Public
20 # License along with GROMACS; if not, see
21 # http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 # If you want to redistribute modifications to GROMACS, please
25 # consider that scientific software is very special. Version
26 # control is crucial - bugs must be traceable. We will be happy to
27 # consider code for inclusion in the official distribution, but
28 # derived work must not be called official GROMACS. Details are found
29 # in the README & COPYING files - if they are missing, get the
30 # official version at http://www.gromacs.org.
32 # To help us fund GROMACS development, we humbly ask that you cite
33 # the research papers on the package. Check out http://www.gromacs.org.
37 # These are accessible later in the script, just like other
38 # declared options, via e.g. context.opts.release.
40 'mdrun-only': Option
.simple
,
41 'static': Option
.simple
,
42 'reference': Option
.simple
,
43 'release': Option
.simple
,
44 'release-with-assert': Option
.simple
,
45 'release-with-debug-info': Option
.simple
,
46 'asan': Option
.simple
,
49 'fftpack': Option
.simple
,
50 'buildfftw': Option
.simple
,
51 'double': Option
.simple
,
52 'thread-mpi': Option
.bool,
53 'clang_cuda': Option
.bool,
54 'openmp': Option
.bool,
55 'nranks': Option
.string
,
56 'npme': Option
.string
,
57 'gpu_id': Option
.string
,
62 extra_projects
= [Project
.REGRESSIONTESTS
]
64 def do_build(context
):
66 cmake_opts
['GMX_COMPILER_WARNINGS'] = 'ON'
67 cmake_opts
['GMX_DEFAULT_SUFFIX'] = 'OFF'
68 cmake_opts
['CMAKE_BUILD_TYPE'] = 'Debug'
69 cmake_opts
['GMX_USE_RDTSCP'] = 'DETECT'
71 if not context
.opts
.msvc
and not context
.opts
.mdrun_only
and not context
.opts
.static
:
72 cmake_opts
['GMXAPI'] = 'ON'
74 if context
.opts
.reference
:
75 cmake_opts
['CMAKE_BUILD_TYPE'] = 'Reference'
76 elif context
.opts
['release']:
77 cmake_opts
['CMAKE_BUILD_TYPE'] = 'Release'
78 elif context
.opts
['release-with-assert']:
79 cmake_opts
['CMAKE_BUILD_TYPE'] = 'RelWithAssert'
80 elif context
.opts
['release-with-debug-info']:
81 cmake_opts
['CMAKE_BUILD_TYPE'] = 'RelWithDebInfo'
82 elif context
.opts
.asan
:
83 cmake_opts
['CMAKE_BUILD_TYPE'] = 'ASAN'
84 elif context
.opts
.tsan
:
85 cmake_opts
['CMAKE_BUILD_TYPE'] = 'TSAN'
87 if context
.opts
.static
:
88 cmake_opts
['BUILD_SHARED_LIBS'] = 'OFF'
91 cmake_opts
['CMAKE_TOOLCHAIN_FILE'] = 'Platform/XeonPhi'
93 if context
.opts
.double
:
94 cmake_opts
['GMX_DOUBLE'] = 'ON'
96 if context
.opts
.simd
is None:
97 cmake_opts
['GMX_SIMD'] = 'None'
99 cmake_opts
['GMX_SIMD'] = context
.opts
.simd
100 if context
.opts
.cuda
or context
.opts
.opencl
:
101 cmake_opts
['GMX_GPU'] = 'ON'
102 if context
.opts
.opencl
:
103 context
.env
.set_env_var('CUDA_PATH', context
.env
.cuda_root
)
104 cmake_opts
['GMX_USE_OPENCL'] = 'ON'
106 cmake_opts
['CUDA_TOOLKIT_ROOT_DIR'] = context
.env
.cuda_root
107 if context
.opts
.clang_cuda
:
108 cmake_opts
['GMX_CLANG_CUDA'] = 'ON'
110 cmake_opts
['CUDA_HOST_COMPILER'] = context
.env
.cuda_host_compiler
112 cmake_opts
['GMX_GPU'] = 'OFF'
113 if context
.opts
.thread_mpi
is False:
114 cmake_opts
['GMX_THREAD_MPI'] = 'OFF'
116 cmake_opts
['GMX_MPI'] = 'ON'
117 if context
.opts
.openmp
is False:
118 cmake_opts
['GMX_OPENMP'] = 'OFF'
119 if context
.opts
.tng
is False:
120 cmake_opts
['GMX_USE_TNG'] = 'OFF'
123 cmake_opts
['GMX_FFT_LIBRARY'] = 'mkl'
124 elif context
.opts
.fftpack
:
125 cmake_opts
['GMX_FFT_LIBRARY'] = 'fftpack'
126 elif context
.opts
.buildfftw
:
127 cmake_opts
['GMX_BUILD_OWN_FFTW'] = 'ON'
128 cmake_opts
['GMX_BUILD_OWN_FFTW_URL'] = 'ftp://ftp.gromacs.org/misc/fftw-3.3.8.tar.gz'
129 cmake_opts
['GMX_BUILD_OWN_FFTW_MD5'] = '8aac833c943d8e90d51b697b27d4384d'
130 if context
.opts
.mkl
or context
.opts
.atlas
or context
.opts
.armpl
:
131 cmake_opts
['GMX_EXTERNAL_BLAS'] = 'ON'
132 cmake_opts
['GMX_EXTERNAL_LAPACK'] = 'ON'
133 if context
.opts
.clFFT
:
134 cmake_opts
['GMX_EXTERNAL_CLFFT'] = 'ON'
135 cmake_opts
['clFFT_ROOT'] = context
.env
.clFFT_root
137 if context
.opts
.armpl
:
138 cmake_opts
['FFTWF_LIBRARY'] = os
.path
.join(context
.env
.armpl_dir
, 'lib/libarmpl_lp64.so')
139 cmake_opts
['FFTWF_INCLUDE_DIR'] = os
.path
.join(context
.env
.armpl_dir
, 'include')
140 cmake_opts
['GMX_BLAS_USER'] = os
.path
.join(context
.env
.armpl_dir
, 'lib/libarmpl_lp64.so')
141 cmake_opts
['GMX_LAPACK_USER'] = os
.path
.join(context
.env
.armpl_dir
, 'lib/libarmpl_lp64.so')
143 if context
.opts
.hwloc
is False:
144 cmake_opts
['GMX_HWLOC'] = 'OFF'
146 if context
.opts
.tng
is False:
147 cmake_opts
['GMX_USE_TNG'] = 'OFF'
150 cmake_opts
['GMX_X11'] = 'ON'
152 if context
.opts
.tidy
:
153 cmake_opts
['GMX_CLANG_TIDY'] = 'ON'
154 cmake_opts
['CLANG_TIDY'] = context
.env
.cxx_compiler
.replace("clang++", "clang-tidy")
156 # At least hwloc on Jenkins produces a massive amount of reports about
157 # memory leaks, which cannot be reasonably suppressed because ASAN cannot
158 # produce a reasonable stack trace for them.
159 if context
.opts
.asan
:
160 cmake_opts
['GMX_HWLOC'] = 'OFF'
162 regressiontests_path
= context
.workspace
.get_project_dir(Project
.REGRESSIONTESTS
)
164 if context
.job_type
== JobType
.RELEASE
:
165 cmake_opts
['REGRESSIONTEST_PATH'] = regressiontests_path
167 if context
.opts
.mdrun_only
:
168 cmake_opts
['GMX_BUILD_MDRUN_ONLY'] = 'ON'
170 context
.env
.set_env_var('GMX_NO_TERM', '1')
172 context
.run_cmake(cmake_opts
)
173 context
.build_target(target
=None, keep_going
=True)
175 # TODO: Consider if it would be better to split this into a separate build
176 # script, since it is somewhat different, even though it benefits from some
177 # of the same build options.
178 if context
.job_type
== JobType
.RELEASE
:
179 context
.build_target(target
='check', keep_going
=True)
180 context
.build_target(target
='install')
181 if context
.opts
.mdrun_only
:
182 context
.workspace
.clean_build_dir()
183 cmake_opts
['REGRESSIONTEST_PATH'] = None
184 cmake_opts
['GMX_BUILD_MDRUN_ONLY'] = 'ON'
185 context
.run_cmake(cmake_opts
)
186 context
.build_target(target
=None, keep_going
=True)
187 context
.build_target(target
='check', keep_going
=True)
188 context
.build_target(target
='install')
189 gmxrc_cmd
= '. ' + os
.path
.join(context
.workspace
.install_dir
, 'bin', 'GMXRC')
190 context
.env
.run_env_script(gmxrc_cmd
)
191 cmd
= [os
.path
.join(regressiontests_path
, 'gmxtest.pl'), '-nosuffix', 'all']
194 if context
.opts
.double
:
196 if context
.opts
.mdrun_only
:
197 cmd
+= ['-mdrun', 'mdrun']
198 context
.run_cmd(cmd
, failure_message
='Regression tests failed to execute')
199 # TODO: Add testing for building the template.
200 # TODO: Generalize the machinery here such that it can easily be used
201 # also for non-release builds.
203 context
.build_target(target
='tests', keep_going
=True)
205 context
.run_ctest(args
=['--output-on-failure', '--label-exclude', 'SlowTest'], memcheck
=context
.opts
.asan
)
207 context
.build_target(target
='install')
208 # TODO: Consider what could be tested about the installed binaries.
210 if not context
.opts
.mdrun_only
:
211 context
.env
.prepend_path_env(os
.path
.join(context
.workspace
.build_dir
, 'bin'))
212 context
.chdir(regressiontests_path
)
214 use_tmpi
= not context
.opts
.mpi
and context
.opts
.thread_mpi
is not False
216 cmd
= 'perl gmxtest.pl -mpirun mpirun -xml -nosuffix all'
218 # setting this stuff below is just a temporary solution,
219 # it should all be passed as a proper the runconf from outside
220 # The whole mechanism should be rethought in #1587.
223 elif context
.opts
.openmp
:
224 # OpenMP should always work when compiled in! Currently not set if
228 if context
.opts
.gpuhw
== Gpuhw
.NONE
:
229 context
.env
.set_env_var('GMX_DISABLE_GPU_DETECTION', '1')
231 if context
.opts
.gpu_id
:
232 cmd
+= ' -gpu_id ' + context
.opts
.gpu_id
234 if context
.opts
.nranks
:
235 nranks
= context
.opts
.nranks
239 if context
.opts
.npme
:
240 cmd
+= ' -npme ' + context
.opts
.npme
243 cmd
+= ' -np ' + nranks
245 cmd
+= ' -nt ' + nranks
246 if context
.opts
.double
:
248 if context
.opts
.asan
:
249 context
.env
.set_env_var('ASAN_OPTIONS', 'detect_leaks=0')
250 context
.run_cmd(cmd
, shell
=True, failure_message
='Regression tests failed to execute')