/* Enable code that requires AVX-512 instruction support, without GMX_SIMD=AVX_512 */
#cmakedefine01 SIMD_AVX_512_CXX_SUPPORTED
+/* Whether NBNXM and other SIMD kernels should be compiled */
+#cmakedefine01 GMX_USE_SIMD_KERNELS
+
/* Whether a double-precision configuration may target accuracy equivalent to single precision */
#cmakedefine01 GMX_RELAXED_DOUBLE_PRECISION
$<INSTALL_INTERFACE:include>
)
+# Permit the configuration to disable compiling the many nbnxm kernels
+# and others involved in force calculations. Currently only
+# short-ranged and bonded kernels are disabled this way, but in future
+# others may be appropriate. Thus the cmake option is not specific to
+# nbnxm module.
+option(GMX_USE_SIMD_KERNELS "Whether to compile NBNXM and other SIMD kernels" ON)
+mark_as_advanced(GMX_USE_SIMD_KERNELS)
+
if(SIMD_AVX_512_CXX_SUPPORTED AND NOT ("${GMX_SIMD_ACTIVE}" STREQUAL "AVX_512_KNL"))
# Since we might be overriding -march=core-avx2, add a flag so we don't warn for this specific file.
# On KNL this can cause illegal instruction because the compiler might use non KNL AVX instructions
{
if (useSimd)
{
-#if GMX_SIMD_HAVE_REAL && GMX_SIMD_HAVE_INT32_ARITHMETICS
+#if GMX_SIMD_HAVE_REAL && GMX_SIMD_HAVE_INT32_ARITHMETICS && GMX_USE_SIMD_KERNELS
/* FIXME: Here SimdDataTypes should be used to enable SIMD. So far, the code in nb_free_energy_kernel is not adapted to SIMD */
return (nb_free_energy_kernel<ScalarDataTypes, useSoftCore, scLambdasOrAlphasDiffer, vdwInteractionTypeIsEwald,
elecInteractionTypeIsEwald, vdwModifierIsPotSwitch>);
#include "forcerec.h"
+#include "config.h"
+
#include <cassert>
#include <cmath>
#include <cstdlib>
gmx::ArrayRef<const std::string> tabbfnm,
real print_force)
{
- /* By default we turn SIMD kernels on, but it might be turned off further down... */
- fr->use_simd_kernels = TRUE;
+ /* The CMake default turns SIMD kernels on, but it might be turned off further down... */
+ fr->use_simd_kernels = GMX_USE_SIMD_KERNELS;
if (check_box(ir->pbcType, box))
{
#
# This file is part of the GROMACS molecular simulation package.
#
-# Copyright (c) 2019, by the GROMACS development team, led by
+# Copyright (c) 2019,2020, by the GROMACS development team, led by
# Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
# and including many others, as listed in the AUTHORS file in the
# top-level source directory and at http://www.gromacs.org.
# To help us fund GROMACS development, we humbly ask that you cite
# the research papers on the package. Check out http://www.gromacs.org.
-file(GLOB NBNXM_SOURCES kernels_reference/*.cpp kernels_simd_4xm/*.cpp kernels_simd_2xmm/*.cpp *.cpp benchmark/*.cpp)
+add_subdirectory(kernels_simd_4xm)
+add_subdirectory(kernels_simd_2xmm)
+
+file (GLOB NBNXM_SOURCES
+ # Source files
+ atomdata.cpp
+ grid.cpp
+ gridset.cpp
+ kernel_common.cpp
+ kerneldispatch.cpp
+ nbnxm.cpp
+ nbnxm_geometry.cpp
+ nbnxm_setup.cpp
+ pairlist.cpp
+ pairlistparams.cpp
+ pairlistset.cpp
+ pairlist_tuning.cpp
+ pairsearch.cpp
+ prunekerneldispatch.cpp
+ # Reference kernel source files
+ kernels_reference/kernel_gpu_ref.cpp
+ kernels_reference/kernel_ref.cpp
+ kernels_reference/kernel_ref_prune.cpp
+ # Benchmark source files
+ # TODO these should not be in libgromacs
+ benchmark/bench_setup.cpp
+ benchmark/bench_system.cpp
+ )
if(GMX_USE_CUDA)
add_subdirectory(cuda)
--- /dev/null
+#
+# This file is part of the GROMACS molecular simulation package.
+#
+# Copyright (c) 2020, by the GROMACS development team, led by
+# Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
+# and including many others, as listed in the AUTHORS file in the
+# top-level source directory and at http://www.gromacs.org.
+#
+# GROMACS is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public License
+# as published by the Free Software Foundation; either version 2.1
+# of the License, or (at your option) any later version.
+#
+# GROMACS is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with GROMACS; if not, see
+# http://www.gnu.org/licenses, or write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# If you want to redistribute modifications to GROMACS, please
+# consider that scientific software is very special. Version
+# control is crucial - bugs must be traceable. We will be happy to
+# consider code for inclusion in the official distribution, but
+# derived work must not be called official GROMACS. Details are found
+# in the README & COPYING files - if they are missing, get the
+# official version at http://www.gromacs.org.
+#
+# To help us fund GROMACS development, we humbly ask that you cite
+# the research papers on the package. Check out http://www.gromacs.org.
+
+if (GMX_USE_SIMD_KERNELS)
+ file(GLOB KERNEL_SOURCES
+ kernel_ElecEwTwinCut_VdwLJCombGeom_F.cpp
+ kernel_ElecEwTwinCut_VdwLJCombGeom_VF.cpp
+ kernel_ElecEwTwinCut_VdwLJCombGeom_VgrpF.cpp
+ kernel_ElecEwTwinCut_VdwLJCombLB_F.cpp
+ kernel_ElecEwTwinCut_VdwLJCombLB_VF.cpp
+ kernel_ElecEwTwinCut_VdwLJCombLB_VgrpF.cpp
+ kernel_ElecEwTwinCut_VdwLJEwCombGeom_F.cpp
+ kernel_ElecEwTwinCut_VdwLJEwCombGeom_VF.cpp
+ kernel_ElecEwTwinCut_VdwLJEwCombGeom_VgrpF.cpp
+ kernel_ElecEwTwinCut_VdwLJ_F.cpp
+ kernel_ElecEwTwinCut_VdwLJFSw_F.cpp
+ kernel_ElecEwTwinCut_VdwLJFSw_VF.cpp
+ kernel_ElecEwTwinCut_VdwLJFSw_VgrpF.cpp
+ kernel_ElecEwTwinCut_VdwLJPSw_F.cpp
+ kernel_ElecEwTwinCut_VdwLJPSw_VF.cpp
+ kernel_ElecEwTwinCut_VdwLJPSw_VgrpF.cpp
+ kernel_ElecEwTwinCut_VdwLJ_VF.cpp
+ kernel_ElecEwTwinCut_VdwLJ_VgrpF.cpp
+ kernel_ElecEw_VdwLJCombGeom_F.cpp
+ kernel_ElecEw_VdwLJCombGeom_VF.cpp
+ kernel_ElecEw_VdwLJCombGeom_VgrpF.cpp
+ kernel_ElecEw_VdwLJCombLB_F.cpp
+ kernel_ElecEw_VdwLJCombLB_VF.cpp
+ kernel_ElecEw_VdwLJCombLB_VgrpF.cpp
+ kernel_ElecEw_VdwLJEwCombGeom_F.cpp
+ kernel_ElecEw_VdwLJEwCombGeom_VF.cpp
+ kernel_ElecEw_VdwLJEwCombGeom_VgrpF.cpp
+ kernel_ElecEw_VdwLJ_F.cpp
+ kernel_ElecEw_VdwLJFSw_F.cpp
+ kernel_ElecEw_VdwLJFSw_VF.cpp
+ kernel_ElecEw_VdwLJFSw_VgrpF.cpp
+ kernel_ElecEw_VdwLJPSw_F.cpp
+ kernel_ElecEw_VdwLJPSw_VF.cpp
+ kernel_ElecEw_VdwLJPSw_VgrpF.cpp
+ kernel_ElecEw_VdwLJ_VF.cpp
+ kernel_ElecEw_VdwLJ_VgrpF.cpp
+ kernel_ElecQSTabTwinCut_VdwLJCombGeom_F.cpp
+ kernel_ElecQSTabTwinCut_VdwLJCombGeom_VF.cpp
+ kernel_ElecQSTabTwinCut_VdwLJCombGeom_VgrpF.cpp
+ kernel_ElecQSTabTwinCut_VdwLJCombLB_F.cpp
+ kernel_ElecQSTabTwinCut_VdwLJCombLB_VF.cpp
+ kernel_ElecQSTabTwinCut_VdwLJCombLB_VgrpF.cpp
+ kernel_ElecQSTabTwinCut_VdwLJEwCombGeom_F.cpp
+ kernel_ElecQSTabTwinCut_VdwLJEwCombGeom_VF.cpp
+ kernel_ElecQSTabTwinCut_VdwLJEwCombGeom_VgrpF.cpp
+ kernel_ElecQSTabTwinCut_VdwLJ_F.cpp
+ kernel_ElecQSTabTwinCut_VdwLJFSw_F.cpp
+ kernel_ElecQSTabTwinCut_VdwLJFSw_VF.cpp
+ kernel_ElecQSTabTwinCut_VdwLJFSw_VgrpF.cpp
+ kernel_ElecQSTabTwinCut_VdwLJPSw_F.cpp
+ kernel_ElecQSTabTwinCut_VdwLJPSw_VF.cpp
+ kernel_ElecQSTabTwinCut_VdwLJPSw_VgrpF.cpp
+ kernel_ElecQSTabTwinCut_VdwLJ_VF.cpp
+ kernel_ElecQSTabTwinCut_VdwLJ_VgrpF.cpp
+ kernel_ElecQSTab_VdwLJCombGeom_F.cpp
+ kernel_ElecQSTab_VdwLJCombGeom_VF.cpp
+ kernel_ElecQSTab_VdwLJCombGeom_VgrpF.cpp
+ kernel_ElecQSTab_VdwLJCombLB_F.cpp
+ kernel_ElecQSTab_VdwLJCombLB_VF.cpp
+ kernel_ElecQSTab_VdwLJCombLB_VgrpF.cpp
+ kernel_ElecQSTab_VdwLJEwCombGeom_F.cpp
+ kernel_ElecQSTab_VdwLJEwCombGeom_VF.cpp
+ kernel_ElecQSTab_VdwLJEwCombGeom_VgrpF.cpp
+ kernel_ElecQSTab_VdwLJ_F.cpp
+ kernel_ElecQSTab_VdwLJFSw_F.cpp
+ kernel_ElecQSTab_VdwLJFSw_VF.cpp
+ kernel_ElecQSTab_VdwLJFSw_VgrpF.cpp
+ kernel_ElecQSTab_VdwLJPSw_F.cpp
+ kernel_ElecQSTab_VdwLJPSw_VF.cpp
+ kernel_ElecQSTab_VdwLJPSw_VgrpF.cpp
+ kernel_ElecQSTab_VdwLJ_VF.cpp
+ kernel_ElecQSTab_VdwLJ_VgrpF.cpp
+ kernel_ElecRF_VdwLJCombGeom_F.cpp
+ kernel_ElecRF_VdwLJCombGeom_VF.cpp
+ kernel_ElecRF_VdwLJCombGeom_VgrpF.cpp
+ kernel_ElecRF_VdwLJCombLB_F.cpp
+ kernel_ElecRF_VdwLJCombLB_VF.cpp
+ kernel_ElecRF_VdwLJCombLB_VgrpF.cpp
+ kernel_ElecRF_VdwLJEwCombGeom_F.cpp
+ kernel_ElecRF_VdwLJEwCombGeom_VF.cpp
+ kernel_ElecRF_VdwLJEwCombGeom_VgrpF.cpp
+ kernel_ElecRF_VdwLJ_F.cpp
+ kernel_ElecRF_VdwLJFSw_F.cpp
+ kernel_ElecRF_VdwLJFSw_VF.cpp
+ kernel_ElecRF_VdwLJFSw_VgrpF.cpp
+ kernel_ElecRF_VdwLJPSw_F.cpp
+ kernel_ElecRF_VdwLJPSw_VF.cpp
+ kernel_ElecRF_VdwLJPSw_VgrpF.cpp
+ kernel_ElecRF_VdwLJ_VF.cpp
+ kernel_ElecRF_VdwLJ_VgrpF.cpp
+ kernel_prune.cpp
+ )
+endif()
+
+set(LIBGROMACS_SOURCES ${LIBGROMACS_SOURCES} ${KERNEL_SOURCES} PARENT_SCOPE)
--- /dev/null
+#
+# This file is part of the GROMACS molecular simulation package.
+#
+# Copyright (c) 2020, by the GROMACS development team, led by
+# Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
+# and including many others, as listed in the AUTHORS file in the
+# top-level source directory and at http://www.gromacs.org.
+#
+# GROMACS is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public License
+# as published by the Free Software Foundation; either version 2.1
+# of the License, or (at your option) any later version.
+#
+# GROMACS is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with GROMACS; if not, see
+# http://www.gnu.org/licenses, or write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# If you want to redistribute modifications to GROMACS, please
+# consider that scientific software is very special. Version
+# control is crucial - bugs must be traceable. We will be happy to
+# consider code for inclusion in the official distribution, but
+# derived work must not be called official GROMACS. Details are found
+# in the README & COPYING files - if they are missing, get the
+# official version at http://www.gromacs.org.
+#
+# To help us fund GROMACS development, we humbly ask that you cite
+# the research papers on the package. Check out http://www.gromacs.org.
+
+if (GMX_USE_SIMD_KERNELS)
+ file(GLOB KERNEL_SOURCES
+ kernel_ElecEwTwinCut_VdwLJCombGeom_F.cpp
+ kernel_ElecEwTwinCut_VdwLJCombGeom_VF.cpp
+ kernel_ElecEwTwinCut_VdwLJCombGeom_VgrpF.cpp
+ kernel_ElecEwTwinCut_VdwLJCombLB_F.cpp
+ kernel_ElecEwTwinCut_VdwLJCombLB_VF.cpp
+ kernel_ElecEwTwinCut_VdwLJCombLB_VgrpF.cpp
+ kernel_ElecEwTwinCut_VdwLJEwCombGeom_F.cpp
+ kernel_ElecEwTwinCut_VdwLJEwCombGeom_VF.cpp
+ kernel_ElecEwTwinCut_VdwLJEwCombGeom_VgrpF.cpp
+ kernel_ElecEwTwinCut_VdwLJ_F.cpp
+ kernel_ElecEwTwinCut_VdwLJFSw_F.cpp
+ kernel_ElecEwTwinCut_VdwLJFSw_VF.cpp
+ kernel_ElecEwTwinCut_VdwLJFSw_VgrpF.cpp
+ kernel_ElecEwTwinCut_VdwLJPSw_F.cpp
+ kernel_ElecEwTwinCut_VdwLJPSw_VF.cpp
+ kernel_ElecEwTwinCut_VdwLJPSw_VgrpF.cpp
+ kernel_ElecEwTwinCut_VdwLJ_VF.cpp
+ kernel_ElecEwTwinCut_VdwLJ_VgrpF.cpp
+ kernel_ElecEw_VdwLJCombGeom_F.cpp
+ kernel_ElecEw_VdwLJCombGeom_VF.cpp
+ kernel_ElecEw_VdwLJCombGeom_VgrpF.cpp
+ kernel_ElecEw_VdwLJCombLB_F.cpp
+ kernel_ElecEw_VdwLJCombLB_VF.cpp
+ kernel_ElecEw_VdwLJCombLB_VgrpF.cpp
+ kernel_ElecEw_VdwLJEwCombGeom_F.cpp
+ kernel_ElecEw_VdwLJEwCombGeom_VF.cpp
+ kernel_ElecEw_VdwLJEwCombGeom_VgrpF.cpp
+ kernel_ElecEw_VdwLJ_F.cpp
+ kernel_ElecEw_VdwLJFSw_F.cpp
+ kernel_ElecEw_VdwLJFSw_VF.cpp
+ kernel_ElecEw_VdwLJFSw_VgrpF.cpp
+ kernel_ElecEw_VdwLJPSw_F.cpp
+ kernel_ElecEw_VdwLJPSw_VF.cpp
+ kernel_ElecEw_VdwLJPSw_VgrpF.cpp
+ kernel_ElecEw_VdwLJ_VF.cpp
+ kernel_ElecEw_VdwLJ_VgrpF.cpp
+ kernel_ElecQSTabTwinCut_VdwLJCombGeom_F.cpp
+ kernel_ElecQSTabTwinCut_VdwLJCombGeom_VF.cpp
+ kernel_ElecQSTabTwinCut_VdwLJCombGeom_VgrpF.cpp
+ kernel_ElecQSTabTwinCut_VdwLJCombLB_F.cpp
+ kernel_ElecQSTabTwinCut_VdwLJCombLB_VF.cpp
+ kernel_ElecQSTabTwinCut_VdwLJCombLB_VgrpF.cpp
+ kernel_ElecQSTabTwinCut_VdwLJEwCombGeom_F.cpp
+ kernel_ElecQSTabTwinCut_VdwLJEwCombGeom_VF.cpp
+ kernel_ElecQSTabTwinCut_VdwLJEwCombGeom_VgrpF.cpp
+ kernel_ElecQSTabTwinCut_VdwLJ_F.cpp
+ kernel_ElecQSTabTwinCut_VdwLJFSw_F.cpp
+ kernel_ElecQSTabTwinCut_VdwLJFSw_VF.cpp
+ kernel_ElecQSTabTwinCut_VdwLJFSw_VgrpF.cpp
+ kernel_ElecQSTabTwinCut_VdwLJPSw_F.cpp
+ kernel_ElecQSTabTwinCut_VdwLJPSw_VF.cpp
+ kernel_ElecQSTabTwinCut_VdwLJPSw_VgrpF.cpp
+ kernel_ElecQSTabTwinCut_VdwLJ_VF.cpp
+ kernel_ElecQSTabTwinCut_VdwLJ_VgrpF.cpp
+ kernel_ElecQSTab_VdwLJCombGeom_F.cpp
+ kernel_ElecQSTab_VdwLJCombGeom_VF.cpp
+ kernel_ElecQSTab_VdwLJCombGeom_VgrpF.cpp
+ kernel_ElecQSTab_VdwLJCombLB_F.cpp
+ kernel_ElecQSTab_VdwLJCombLB_VF.cpp
+ kernel_ElecQSTab_VdwLJCombLB_VgrpF.cpp
+ kernel_ElecQSTab_VdwLJEwCombGeom_F.cpp
+ kernel_ElecQSTab_VdwLJEwCombGeom_VF.cpp
+ kernel_ElecQSTab_VdwLJEwCombGeom_VgrpF.cpp
+ kernel_ElecQSTab_VdwLJ_F.cpp
+ kernel_ElecQSTab_VdwLJFSw_F.cpp
+ kernel_ElecQSTab_VdwLJFSw_VF.cpp
+ kernel_ElecQSTab_VdwLJFSw_VgrpF.cpp
+ kernel_ElecQSTab_VdwLJPSw_F.cpp
+ kernel_ElecQSTab_VdwLJPSw_VF.cpp
+ kernel_ElecQSTab_VdwLJPSw_VgrpF.cpp
+ kernel_ElecQSTab_VdwLJ_VF.cpp
+ kernel_ElecQSTab_VdwLJ_VgrpF.cpp
+ kernel_ElecRF_VdwLJCombGeom_F.cpp
+ kernel_ElecRF_VdwLJCombGeom_VF.cpp
+ kernel_ElecRF_VdwLJCombGeom_VgrpF.cpp
+ kernel_ElecRF_VdwLJCombLB_F.cpp
+ kernel_ElecRF_VdwLJCombLB_VF.cpp
+ kernel_ElecRF_VdwLJCombLB_VgrpF.cpp
+ kernel_ElecRF_VdwLJEwCombGeom_F.cpp
+ kernel_ElecRF_VdwLJEwCombGeom_VF.cpp
+ kernel_ElecRF_VdwLJEwCombGeom_VgrpF.cpp
+ kernel_ElecRF_VdwLJ_F.cpp
+ kernel_ElecRF_VdwLJFSw_F.cpp
+ kernel_ElecRF_VdwLJFSw_VF.cpp
+ kernel_ElecRF_VdwLJFSw_VgrpF.cpp
+ kernel_ElecRF_VdwLJPSw_F.cpp
+ kernel_ElecRF_VdwLJPSw_VF.cpp
+ kernel_ElecRF_VdwLJPSw_VgrpF.cpp
+ kernel_ElecRF_VdwLJ_VF.cpp
+ kernel_ElecRF_VdwLJ_VgrpF.cpp
+ kernel_prune.cpp
+ )
+endif()
+
+set(LIBGROMACS_SOURCES ${LIBGROMACS_SOURCES} ${KERNEL_SOURCES} PARENT_SCOPE)
#include "gromacs/simd/simd.h"
#include "gromacs/utility/real.h"
-#if GMX_SIMD
+#if GMX_SIMD && GMX_USE_SIMD_KERNELS
/*! \brief The nbnxn SIMD 4xN and 2x(N+N) kernels can be added independently.
* Currently the 2xNN SIMD kernels only make sense with:
* 8-way SIMD: 4x4 setup, works with AVX-256 in single precision
# error "No SIMD kernel type defined"
# endif
-#endif // GMX_SIMD
+#endif // GMX_SIMD && GMX_USE_SIMD_KERNELS
#endif
#include "clusterdistancekerneltype.h"
#include "nbnxm_gpu.h"
+#include "nbnxm_simd.h"
#include "pairlistset.h"
#include "pairlistsets.h"
#include "kernels_reference/kernel_ref_prune.h"
switch (getClusterDistanceKernelType(params_.pairlistType, *nbat))
{
+#ifdef GMX_NBNXN_SIMD_4XN
case ClusterDistanceKernelType::CpuSimd_4xM:
nbnxn_kernel_prune_4xn(nbl, nbat, shift_vec, rlistInner);
break;
+#endif
+#ifdef GMX_NBNXN_SIMD_2XNN
case ClusterDistanceKernelType::CpuSimd_2xMM:
nbnxn_kernel_prune_2xnn(nbl, nbat, shift_vec, rlistInner);
break;
+#endif
case ClusterDistanceKernelType::CpuPlainC:
nbnxn_kernel_prune_ref(nbl, nbat, shift_vec, rlistInner);
break;