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 'double': Option
.simple
,
51 'thread-mpi': Option
.bool,
52 'clang_cuda': Option
.bool,
53 'openmp': Option
.bool,
54 'nranks': Option
.string
,
55 'npme': Option
.string
,
56 'gpu_id': Option
.string
,
61 extra_projects
= [Project
.REGRESSIONTESTS
]
63 def do_build(context
):
65 cmake_opts
['GMX_COMPILER_WARNINGS'] = 'ON'
66 cmake_opts
['GMX_DEFAULT_SUFFIX'] = 'OFF'
67 cmake_opts
['CMAKE_BUILD_TYPE'] = 'Debug'
68 cmake_opts
['GMX_USE_RDTSCP'] = 'DETECT'
70 if context
.opts
.reference
:
71 cmake_opts
['CMAKE_BUILD_TYPE'] = 'Reference'
72 elif context
.opts
['release']:
73 cmake_opts
['CMAKE_BUILD_TYPE'] = 'Release'
74 elif context
.opts
['release-with-assert']:
75 cmake_opts
['CMAKE_BUILD_TYPE'] = 'RelWithAssert'
76 elif context
.opts
['release-with-debug-info']:
77 cmake_opts
['CMAKE_BUILD_TYPE'] = 'RelWithDebInfo'
78 elif context
.opts
.asan
:
79 cmake_opts
['CMAKE_BUILD_TYPE'] = 'ASAN'
80 elif context
.opts
.tsan
:
81 cmake_opts
['CMAKE_BUILD_TYPE'] = 'TSAN'
83 if context
.opts
.static
:
84 cmake_opts
['BUILD_SHARED_LIBS'] = 'OFF'
87 cmake_opts
['CMAKE_TOOLCHAIN_FILE'] = 'Platform/XeonPhi'
89 if context
.opts
.double
:
90 cmake_opts
['GMX_DOUBLE'] = 'ON'
92 if context
.opts
.simd
is None:
93 cmake_opts
['GMX_SIMD'] = 'None'
95 cmake_opts
['GMX_SIMD'] = context
.opts
.simd
96 if context
.opts
.cuda
or context
.opts
.opencl
:
97 cmake_opts
['GMX_GPU'] = 'ON'
98 if context
.opts
.opencl
:
99 context
.env
.set_env_var('CUDA_PATH', context
.env
.cuda_root
)
100 cmake_opts
['GMX_USE_OPENCL'] = 'ON'
102 cmake_opts
['CUDA_TOOLKIT_ROOT_DIR'] = context
.env
.cuda_root
103 if context
.opts
.clang_cuda
:
104 cmake_opts
['GMX_CLANG_CUDA'] = 'ON'
106 cmake_opts
['CUDA_HOST_COMPILER'] = context
.env
.cuda_host_compiler
108 cmake_opts
['GMX_GPU'] = 'OFF'
109 if context
.opts
.thread_mpi
is False:
110 cmake_opts
['GMX_THREAD_MPI'] = 'OFF'
112 cmake_opts
['GMX_MPI'] = 'ON'
113 if context
.opts
.openmp
is False:
114 cmake_opts
['GMX_OPENMP'] = 'OFF'
115 if context
.opts
.tng
is False:
116 cmake_opts
['GMX_USE_TNG'] = 'OFF'
119 cmake_opts
['GMX_FFT_LIBRARY'] = 'mkl'
120 elif context
.opts
.fftpack
:
121 cmake_opts
['GMX_FFT_LIBRARY'] = 'fftpack'
122 if context
.opts
.mkl
or context
.opts
.atlas
or context
.opts
.armpl
:
123 cmake_opts
['GMX_EXTERNAL_BLAS'] = 'ON'
124 cmake_opts
['GMX_EXTERNAL_LAPACK'] = 'ON'
125 if context
.opts
.clFFT
:
126 cmake_opts
['GMX_EXTERNAL_CLFFT'] = 'ON'
127 cmake_opts
['clFFT_ROOT'] = context
.env
.clFFT_root
129 if context
.opts
.armpl
:
130 cmake_opts
['FFTWF_LIBRARY'] = os
.path
.join(context
.env
.armpl_dir
, 'lib/libarmpl_lp64.so')
131 cmake_opts
['FFTWF_INCLUDE_DIR'] = os
.path
.join(context
.env
.armpl_dir
, '/include')
132 cmake_opts
['GMX_BLAS_USER'] = os
.path
.join(context
.env
.armpl_dir
, '/lib/libarmpl_lp64.so')
133 cmake_opts
['GMX_LAPACK_USER'] = os
.path
.join(context
.env
.armpl_dir
, '/lib/libarmpl_lp64.so')
135 if context
.opts
.hwloc
is False:
136 cmake_opts
['GMX_HWLOC'] = 'OFF'
138 if context
.opts
.tng
is False:
139 cmake_opts
['GMX_USE_TNG'] = 'OFF'
142 cmake_opts
['GMX_X11'] = 'ON'
144 if context
.opts
.tidy
:
145 cmake_opts
['GMX_CLANG_TIDY'] = 'ON'
146 cmake_opts
['CLANG_TIDY'] = context
.env
.cxx_compiler
.replace("clang++", "clang-tidy")
148 # At least hwloc on Jenkins produces a massive amount of reports about
149 # memory leaks, which cannot be reasonably suppressed because ASAN cannot
150 # produce a reasonable stack trace for them.
151 if context
.opts
.asan
:
152 cmake_opts
['GMX_HWLOC'] = 'OFF'
154 regressiontests_path
= context
.workspace
.get_project_dir(Project
.REGRESSIONTESTS
)
156 if context
.job_type
== JobType
.RELEASE
:
157 cmake_opts
['REGRESSIONTEST_PATH'] = regressiontests_path
159 if context
.opts
.mdrun_only
:
160 cmake_opts
['GMX_BUILD_MDRUN_ONLY'] = 'ON'
162 context
.env
.set_env_var('GMX_NO_TERM', '1')
164 context
.run_cmake(cmake_opts
)
165 context
.build_target(target
=None, keep_going
=True)
167 # TODO: Consider if it would be better to split this into a separate build
168 # script, since it is somewhat different, even though it benefits from some
169 # of the same build options.
170 if context
.job_type
== JobType
.RELEASE
:
171 context
.build_target(target
='check', keep_going
=True)
172 context
.build_target(target
='install')
173 if context
.opts
.mdrun_only
:
174 context
.workspace
.clean_build_dir()
175 cmake_opts
['REGRESSIONTEST_PATH'] = None
176 cmake_opts
['GMX_BUILD_MDRUN_ONLY'] = 'ON'
177 context
.run_cmake(cmake_opts
)
178 context
.build_target(target
=None, keep_going
=True)
179 context
.build_target(target
='check', keep_going
=True)
180 context
.build_target(target
='install')
181 gmxrc_cmd
= '. ' + os
.path
.join(context
.workspace
.install_dir
, 'bin', 'GMXRC')
182 context
.env
.run_env_script(gmxrc_cmd
)
183 cmd
= [os
.path
.join(regressiontests_path
, 'gmxtest.pl'), '-nosuffix', 'all']
186 if context
.opts
.double
:
188 if context
.opts
.mdrun_only
:
189 cmd
+= ['-mdrun', 'mdrun']
190 context
.run_cmd(cmd
, failure_message
='Regression tests failed to execute')
191 # TODO: Add testing for building the template.
192 # TODO: Generalize the machinery here such that it can easily be used
193 # also for non-release builds.
195 context
.build_target(target
='tests', keep_going
=True)
197 context
.run_ctest(args
=['--output-on-failure', '--label-exclude', 'SlowTest'], memcheck
=context
.opts
.asan
)
199 context
.build_target(target
='install')
200 # TODO: Consider what could be tested about the installed binaries.
202 if not context
.opts
.mdrun_only
:
203 context
.env
.prepend_path_env(os
.path
.join(context
.workspace
.build_dir
, 'bin'))
204 context
.chdir(regressiontests_path
)
206 use_tmpi
= not context
.opts
.mpi
and context
.opts
.thread_mpi
is not False
208 cmd
= 'perl gmxtest.pl -mpirun mpirun -xml -nosuffix all'
210 # setting this stuff below is just a temporary solution,
211 # it should all be passed as a proper the runconf from outside
212 # The whole mechanism should be rethought in #1587.
215 elif context
.opts
.openmp
:
216 # OpenMP should always work when compiled in! Currently not set if
220 if context
.opts
.gpuhw
== Gpuhw
.NONE
:
221 context
.env
.set_env_var('GMX_DISABLE_GPU_DETECTION', '1')
223 if context
.opts
.gpu_id
:
224 cmd
+= ' -gpu_id ' + context
.opts
.gpu_id
226 if context
.opts
.nranks
:
227 nranks
= context
.opts
.nranks
231 if context
.opts
.npme
:
232 cmd
+= ' -npme ' + context
.opts
.npme
235 cmd
+= ' -np ' + nranks
237 cmd
+= ' -nt ' + nranks
238 if context
.opts
.double
:
240 if context
.opts
.asan
:
241 context
.env
.set_env_var('ASAN_OPTIONS', 'detect_leaks=0')
242 context
.run_cmd(cmd
, shell
=True, failure_message
='Regression tests failed to execute')