2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2019, 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.
39 * Declares the ClusterDistanceKernelType enum
41 * \author Berk Hess <hess@kth.se>
42 * \ingroup module_nbnxm
45 #ifndef GMX_NBNXM_CLUSTERDISTANCEKERNELTYPE_H
46 #define GMX_NBNXM_CLUSTERDISTANCEKERNELTYPE_H
48 #include "gromacs/nbnxm/atomdata.h"
49 #include "gromacs/simd/simd.h"
50 #include "gromacs/utility/gmxassert.h"
52 #include "pairlistparams.h"
54 //! The types of kernel for calculating the distance between pairs of atom clusters
55 enum class ClusterDistanceKernelType
: int
57 CpuPlainC
, //!< Plain-C for CPU list
58 CpuSimd_4xM
, //!< SIMD for CPU list for j-cluster size matching the SIMD width
59 CpuSimd_2xMM
, //!< SIMD for CPU list for j-cluster size matching half the SIMD width
60 Gpu
//!< For GPU list, can be either plain-C or SIMD
63 //! Return the cluster distance kernel type given the pairlist type and atomdata
64 static inline ClusterDistanceKernelType
65 getClusterDistanceKernelType(const PairlistType pairlistType
,
66 const nbnxn_atomdata_t
&atomdata
)
68 if (pairlistType
== PairlistType::HierarchicalNxN
)
70 return ClusterDistanceKernelType::Gpu
;
72 else if (atomdata
.XFormat
== nbatXYZ
)
74 return ClusterDistanceKernelType::CpuPlainC
;
76 else if (pairlistType
== PairlistType::Simple4x2
)
78 #if GMX_SIMD && GMX_SIMD_REAL_WIDTH == 2
79 return ClusterDistanceKernelType::CpuSimd_4xM
;
81 GMX_RELEASE_ASSERT(false, "Expect 2-wide SIMD with 4x2 list and nbat SIMD layout");
84 else if (pairlistType
== PairlistType::Simple4x4
)
86 #if GMX_SIMD && GMX_SIMD_REAL_WIDTH == 4
87 return ClusterDistanceKernelType::CpuSimd_4xM
;
88 #elif GMX_SIMD && GMX_SIMD_REAL_WIDTH == 8
89 return ClusterDistanceKernelType::CpuSimd_2xMM
;
91 GMX_RELEASE_ASSERT(false, "Expect 4-wide or 8-wide SIMD with 4x4 list and nbat SIMD layout");
96 GMX_ASSERT(pairlistType
== PairlistType::Simple4x8
, "Unhandled pairlist type");
97 #if GMX_SIMD && GMX_SIMD_REAL_WIDTH == 8
98 return ClusterDistanceKernelType::CpuSimd_4xM
;
99 #elif GMX_SIMD && GMX_SIMD_REAL_WIDTH == 16
100 return ClusterDistanceKernelType::CpuSimd_2xMM
;
102 GMX_RELEASE_ASSERT(false, "Expect 8-wide or 16-wide SIMD with 4x4 list and nbat SIMD layout");
106 GMX_RELEASE_ASSERT(false, "We should have returned before getting here");
107 return ClusterDistanceKernelType::CpuPlainC
;