target_link_libraries(nbnxm INTERFACE
utility
)
+
+if (BUILD_TESTING)
+ add_subdirectory(tests)
+endif()
* This file is part of the GROMACS molecular simulation package.
*
* Copyright (c) 2012,2013,2014,2015,2017 by the GROMACS development team.
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020,2021, 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.
#include "pairlist.h"
struct interaction_const_t;
+enum class CoulombInteractionType : int;
+
+namespace Nbnxm
+{
+enum class EwaldExclusionType : int;
+}
// TODO: Consider using one nbk_func type now ener and noener are identical
/*! \brief Kinds of electrostatic treatments in SIMD Verlet kernels
*/
-enum
+enum class CoulombKernelType : int
{
- coulktRF,
- coulktTAB,
- coulktTAB_TWIN,
- coulktEWALD,
- coulktEWALD_TWIN,
- coulktNR
+ ReactionField,
+ Table,
+ TableTwin,
+ Ewald,
+ EwaldTwin,
+ Count
};
+//! \brief Lookup function for Coulomb kernel type
+CoulombKernelType getCoulombKernelType(Nbnxm::EwaldExclusionType ewaldExclusionType,
+ CoulombInteractionType coulombInteractionType,
+ bool haveEqualCoulombVwdRadii);
+
/*! \brief Kinds of Van der Waals treatments in SIMD Verlet kernels
*
* The \p LJCUT_COMB refers to the LJ combination rule for the short range.
* This file is part of the GROMACS molecular simulation package.
*
* Copyright (c) 2012,2013,2014,2015,2017 by the GROMACS development team.
- * Copyright (c) 2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020,2021, 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.
* The minor index of the array goes over both the LJ combination rules,
* which is only supported by plain cut-off, and the LJ switch/PME functions.
*/
-static p_nbk_func_noener nbnxm_kernel_noener_simd_{1}[coulktNR][vdwktNR] =
+static p_nbk_func_noener nbnxm_kernel_noener_simd_{1}[static_cast<int>(CoulombKernelType::Count)][vdwktNR] =
{2}
-static p_nbk_func_ener nbnxm_kernel_ener_simd_{1}[coulktNR][vdwktNR] =
+static p_nbk_func_ener nbnxm_kernel_ener_simd_{1}[static_cast<int>(CoulombKernelType::Count)][vdwktNR] =
{3}
-static p_nbk_func_ener nbnxm_kernel_energrp_simd_{1}[coulktNR][vdwktNR] =
+static p_nbk_func_ener nbnxm_kernel_energrp_simd_{1}[static_cast<int>(CoulombKernelType::Count)][vdwktNR] =
{4}
#endif /* INCLUDE_KERNELFUNCTION_TABLES */
}
}
-static int getCoulombKernelType(const Nbnxm::KernelSetup& kernelSetup, const interaction_const_t& ic)
+CoulombKernelType getCoulombKernelType(const Nbnxm::EwaldExclusionType ewaldExclusionType,
+ const CoulombInteractionType coulombInteractionType,
+ const bool haveEqualCoulombVwdRadii)
{
- if (EEL_RF(ic.eeltype) || ic.eeltype == CoulombInteractionType::Cut)
+ if (EEL_RF(coulombInteractionType) || coulombInteractionType == CoulombInteractionType::Cut)
{
- return coulktRF;
+ return CoulombKernelType::ReactionField;
}
else
{
- if (kernelSetup.ewaldExclusionType == Nbnxm::EwaldExclusionType::Table)
+ if (ewaldExclusionType == Nbnxm::EwaldExclusionType::Table)
{
- if (ic.rcoulomb == ic.rvdw)
+ if (haveEqualCoulombVwdRadii)
{
- return coulktTAB;
+ return CoulombKernelType::Table;
}
else
{
- return coulktTAB_TWIN;
+ return CoulombKernelType::TableTwin;
}
}
else
{
- if (ic.rcoulomb == ic.rvdw)
+ if (haveEqualCoulombVwdRadii)
{
- return coulktEWALD;
+ return CoulombKernelType::Ewald;
}
else
{
- return coulktEWALD_TWIN;
+ return CoulombKernelType::EwaldTwin;
}
}
}
const nbnxn_atomdata_t::Params& nbatParams = nbat->params();
- const int coulkt = getCoulombKernelType(kernelSetup, ic);
+ const int coulkt = static_cast<int>(getCoulombKernelType(
+ kernelSetup.ewaldExclusionType, ic.eeltype, (ic.rcoulomb == ic.rvdw)));
const int vdwkt = getVdwKernelType(kernelSetup, nbatParams, ic);
gmx::ArrayRef<const NbnxnPairlistCpu> pairlists = pairlistSet.cpuLists();
* advantage in using combination rules, so we (re-)use the same kernel.
*/
//! \{
-static const p_nbk_func_noener nbnxn_kernel_noener_ref[coulktNR][vdwktNR_ref] = {
+static const p_nbk_func_noener nbnxn_kernel_noener_ref[static_cast<int>(CoulombKernelType::Count)][vdwktNR_ref] = {
{ nbnxn_kernel_ElecRF_VdwLJ_F_ref,
nbnxn_kernel_ElecRF_VdwLJ_F_ref,
nbnxn_kernel_ElecRF_VdwLJ_F_ref,
nbnxn_kernel_ElecQSTabTwinCut_VdwLJEwCombLB_F_ref }
};
-static const p_nbk_func_ener nbnxn_kernel_ener_ref[coulktNR][vdwktNR_ref] = {
+static const p_nbk_func_ener nbnxn_kernel_ener_ref[static_cast<int>(CoulombKernelType::Count)][vdwktNR_ref] = {
{ nbnxn_kernel_ElecRF_VdwLJ_VF_ref,
nbnxn_kernel_ElecRF_VdwLJ_VF_ref,
nbnxn_kernel_ElecRF_VdwLJ_VF_ref,
nbnxn_kernel_ElecQSTabTwinCut_VdwLJEwCombLB_VF_ref }
};
-static const p_nbk_func_ener nbnxn_kernel_energrp_ref[coulktNR][vdwktNR_ref] = {
+static const p_nbk_func_ener nbnxn_kernel_energrp_ref[static_cast<int>(CoulombKernelType::Count)][vdwktNR_ref] = {
{ nbnxn_kernel_ElecRF_VdwLJ_VgrpF_ref,
nbnxn_kernel_ElecRF_VdwLJ_VgrpF_ref,
nbnxn_kernel_ElecRF_VdwLJ_VgrpF_ref,
* The minor index of the array goes over both the LJ combination rules,
* which is only supported by plain cut-off, and the LJ switch/PME functions.
*/
-static const p_nbk_func_noener nbnxm_kernel_noener_simd_2xmm[coulktNR][vdwktNR] = {
+static const p_nbk_func_noener nbnxm_kernel_noener_simd_2xmm[static_cast<int>(CoulombKernelType::Count)][vdwktNR] = {
{
nbnxm_kernel_ElecRF_VdwLJCombGeom_F_2xmm,
nbnxm_kernel_ElecRF_VdwLJCombLB_F_2xmm,
},
};
-static const p_nbk_func_ener nbnxm_kernel_ener_simd_2xmm[coulktNR][vdwktNR] = {
+static const p_nbk_func_ener nbnxm_kernel_ener_simd_2xmm[static_cast<int>(CoulombKernelType::Count)][vdwktNR] = {
{
nbnxm_kernel_ElecRF_VdwLJCombGeom_VF_2xmm,
nbnxm_kernel_ElecRF_VdwLJCombLB_VF_2xmm,
},
};
-static const p_nbk_func_ener nbnxm_kernel_energrp_simd_2xmm[coulktNR][vdwktNR] = {
+static const p_nbk_func_ener nbnxm_kernel_energrp_simd_2xmm[static_cast<int>(CoulombKernelType::Count)][vdwktNR] = {
{
nbnxm_kernel_ElecRF_VdwLJCombGeom_VgrpF_2xmm,
nbnxm_kernel_ElecRF_VdwLJCombLB_VgrpF_2xmm,
* The minor index of the array goes over both the LJ combination rules,
* which is only supported by plain cut-off, and the LJ switch/PME functions.
*/
-static const p_nbk_func_noener nbnxm_kernel_noener_simd_4xm[coulktNR][vdwktNR] = {
+static const p_nbk_func_noener nbnxm_kernel_noener_simd_4xm[static_cast<int>(CoulombKernelType::Count)][vdwktNR] = {
{
nbnxm_kernel_ElecRF_VdwLJCombGeom_F_4xm,
nbnxm_kernel_ElecRF_VdwLJCombLB_F_4xm,
},
};
-static const p_nbk_func_ener nbnxm_kernel_ener_simd_4xm[coulktNR][vdwktNR] = {
+static const p_nbk_func_ener nbnxm_kernel_ener_simd_4xm[static_cast<int>(CoulombKernelType::Count)][vdwktNR] = {
{
nbnxm_kernel_ElecRF_VdwLJCombGeom_VF_4xm,
nbnxm_kernel_ElecRF_VdwLJCombLB_VF_4xm,
},
};
-static const p_nbk_func_ener nbnxm_kernel_energrp_simd_4xm[coulktNR][vdwktNR] = {
+static const p_nbk_func_ener nbnxm_kernel_energrp_simd_4xm[static_cast<int>(CoulombKernelType::Count)][vdwktNR] = {
{
nbnxm_kernel_ElecRF_VdwLJCombGeom_VgrpF_4xm,
nbnxm_kernel_ElecRF_VdwLJCombLB_VgrpF_4xm,
--- /dev/null
+#
+# This file is part of the GROMACS molecular simulation package.
+#
+# Copyright (c) 2021, 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.
+
+gmx_add_unit_test(NbnxmTests nbnxm-test
+ CPP_SOURCE_FILES
+ kernelsetup.cpp
+ )
--- /dev/null
+/*
+ * This file is part of the GROMACS molecular simulation package.
+ *
+ * Copyright (c) 2021, 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.
+ */
+/*! \internal \file
+ * \brief
+ * Tests for Setup of kernels.
+ *
+ * \author Joe Jordan <ejjordan@kth.se>
+ * \ingroup module_nbnxm
+ */
+#include "gmxpre.h"
+
+#include "gromacs/mdtypes/md_enums.h"
+#include "gromacs/nbnxm/kernel_common.h"
+#include "gromacs/nbnxm/nbnxm.h"
+
+#include "testutils/testasserts.h"
+
+namespace gmx
+{
+
+TEST(KernelSetupTest, getCoulombKernelTypeRF)
+{
+ EXPECT_EQ(getCoulombKernelType(Nbnxm::EwaldExclusionType::NotSet, CoulombInteractionType::RF, false),
+ CoulombKernelType::ReactionField);
+}
+
+TEST(KernelSetupTest, getCoulombKernelTypeCut)
+{
+ EXPECT_EQ(getCoulombKernelType(Nbnxm::EwaldExclusionType::NotSet, CoulombInteractionType::Cut, false),
+ CoulombKernelType::ReactionField);
+}
+
+TEST(KernelSetupTest, getCoulombKernelTypeTable)
+{
+ EXPECT_EQ(getCoulombKernelType(Nbnxm::EwaldExclusionType::Table, CoulombInteractionType::Count, true),
+ CoulombKernelType::Table);
+}
+
+TEST(KernelSetupTest, getCoulombKernelTypeTableTwin)
+{
+ EXPECT_EQ(getCoulombKernelType(Nbnxm::EwaldExclusionType::Table, CoulombInteractionType::Count, false),
+ CoulombKernelType::TableTwin);
+}
+
+TEST(KernelSetupTest, getCoulombKernelTypeEwald)
+{
+ EXPECT_EQ(getCoulombKernelType(Nbnxm::EwaldExclusionType::NotSet, CoulombInteractionType::Count, true),
+ CoulombKernelType::Ewald);
+}
+
+TEST(KernelSetupTest, getCoulombKernelTypeEwaldTwin)
+{
+ EXPECT_EQ(getCoulombKernelType(Nbnxm::EwaldExclusionType::NotSet, CoulombInteractionType::Count, false),
+ CoulombKernelType::EwaldTwin);
+}
+
+} // namespace gmx