2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013, 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.
36 * Note: this file was generated by the Verlet kernel generator for
46 #ifdef GMX_NBNXN_SIMD_4XN
48 #ifdef GMX_NBNXN_HALF_WIDTH_SIMD
49 #define GMX_USE_HALF_WIDTH_SIMD_HERE
51 #include "gromacs/simd/macros.h"
52 #include "gromacs/simd/vector_operations.h"
54 #if !(GMX_SIMD_WIDTH_HERE == 2 || GMX_SIMD_WIDTH_HERE == 4 || GMX_SIMD_WIDTH_HERE == 8)
55 #error "unsupported SIMD width"
58 #define GMX_SIMD_J_UNROLL_SIZE 1
59 #include "nbnxn_kernel_simd_4xn.h"
60 #include "../nbnxn_kernel_common.h"
61 #include "gmx_omp_nthreads.h"
62 #include "types/force_flags.h"
64 /*! \brief Kinds of electrostatic treatments in SIMD Verlet kernels
67 coultRF, coultTAB, coultTAB_TWIN, coultEWALD, coultEWALD_TWIN, coultNR
70 /* Declare and define the kernel function pointer lookup tables. */
71 static p_nbk_func_ener p_nbk_ener[coultNR][ljcrNR] =
74 nbnxn_kernel_simd_4xn_rf_comb_geom_ener,
75 nbnxn_kernel_simd_4xn_rf_comb_lb_ener,
76 nbnxn_kernel_simd_4xn_rf_comb_none_ener,
79 nbnxn_kernel_simd_4xn_tab_comb_geom_ener,
80 nbnxn_kernel_simd_4xn_tab_comb_lb_ener,
81 nbnxn_kernel_simd_4xn_tab_comb_none_ener,
84 nbnxn_kernel_simd_4xn_tab_twin_comb_geom_ener,
85 nbnxn_kernel_simd_4xn_tab_twin_comb_lb_ener,
86 nbnxn_kernel_simd_4xn_tab_twin_comb_none_ener,
89 nbnxn_kernel_simd_4xn_ewald_comb_geom_ener,
90 nbnxn_kernel_simd_4xn_ewald_comb_lb_ener,
91 nbnxn_kernel_simd_4xn_ewald_comb_none_ener,
94 nbnxn_kernel_simd_4xn_ewald_twin_comb_geom_ener,
95 nbnxn_kernel_simd_4xn_ewald_twin_comb_lb_ener,
96 nbnxn_kernel_simd_4xn_ewald_twin_comb_none_ener,
100 static p_nbk_func_ener p_nbk_energrp[coultNR][ljcrNR] =
103 nbnxn_kernel_simd_4xn_rf_comb_geom_energrp,
104 nbnxn_kernel_simd_4xn_rf_comb_lb_energrp,
105 nbnxn_kernel_simd_4xn_rf_comb_none_energrp,
108 nbnxn_kernel_simd_4xn_tab_comb_geom_energrp,
109 nbnxn_kernel_simd_4xn_tab_comb_lb_energrp,
110 nbnxn_kernel_simd_4xn_tab_comb_none_energrp,
113 nbnxn_kernel_simd_4xn_tab_twin_comb_geom_energrp,
114 nbnxn_kernel_simd_4xn_tab_twin_comb_lb_energrp,
115 nbnxn_kernel_simd_4xn_tab_twin_comb_none_energrp,
118 nbnxn_kernel_simd_4xn_ewald_comb_geom_energrp,
119 nbnxn_kernel_simd_4xn_ewald_comb_lb_energrp,
120 nbnxn_kernel_simd_4xn_ewald_comb_none_energrp,
123 nbnxn_kernel_simd_4xn_ewald_twin_comb_geom_energrp,
124 nbnxn_kernel_simd_4xn_ewald_twin_comb_lb_energrp,
125 nbnxn_kernel_simd_4xn_ewald_twin_comb_none_energrp,
129 static p_nbk_func_noener p_nbk_noener[coultNR][ljcrNR] =
132 nbnxn_kernel_simd_4xn_rf_comb_geom_noener,
133 nbnxn_kernel_simd_4xn_rf_comb_lb_noener,
134 nbnxn_kernel_simd_4xn_rf_comb_none_noener,
137 nbnxn_kernel_simd_4xn_tab_comb_geom_noener,
138 nbnxn_kernel_simd_4xn_tab_comb_lb_noener,
139 nbnxn_kernel_simd_4xn_tab_comb_none_noener,
142 nbnxn_kernel_simd_4xn_tab_twin_comb_geom_noener,
143 nbnxn_kernel_simd_4xn_tab_twin_comb_lb_noener,
144 nbnxn_kernel_simd_4xn_tab_twin_comb_none_noener,
147 nbnxn_kernel_simd_4xn_ewald_comb_geom_noener,
148 nbnxn_kernel_simd_4xn_ewald_comb_lb_noener,
149 nbnxn_kernel_simd_4xn_ewald_comb_none_noener,
152 nbnxn_kernel_simd_4xn_ewald_twin_comb_geom_noener,
153 nbnxn_kernel_simd_4xn_ewald_twin_comb_lb_noener,
154 nbnxn_kernel_simd_4xn_ewald_twin_comb_none_noener,
160 reduce_group_energies(int ng, int ng_2log,
161 const real *VSvdw, const real *VSc,
162 real *Vvdw, real *Vc)
164 const int unrollj = GMX_SIMD_WIDTH_HERE/GMX_SIMD_J_UNROLL_SIZE;
165 const int unrollj_half = unrollj/2;
166 int ng_p2, i, j, j0, j1, c, s;
168 ng_p2 = (1<<ng_2log);
170 /* The size of the x86 SIMD energy group buffer array is:
171 * ng*ng*ng_p2*unrollj_half*simd_width
173 for (i = 0; i < ng; i++)
175 for (j = 0; j < ng; j++)
181 for (j1 = 0; j1 < ng; j1++)
183 for (j0 = 0; j0 < ng; j0++)
185 c = ((i*ng + j1)*ng_p2 + j0)*unrollj_half*unrollj;
186 for (s = 0; s < unrollj_half; s++)
188 Vvdw[i*ng+j0] += VSvdw[c+0];
189 Vvdw[i*ng+j1] += VSvdw[c+1];
190 Vc [i*ng+j0] += VSc [c+0];
191 Vc [i*ng+j1] += VSc [c+1];
199 #else /* GMX_NBNXN_SIMD_4XN */
201 #include "gmx_fatal.h"
203 #endif /* GMX_NBNXN_SIMD_4XN */
206 nbnxn_kernel_simd_4xn(nbnxn_pairlist_set_t gmx_unused *nbl_list,
207 const nbnxn_atomdata_t gmx_unused *nbat,
208 const interaction_const_t gmx_unused *ic,
209 int gmx_unused ewald_excl,
210 rvec gmx_unused *shift_vec,
211 int gmx_unused force_flags,
212 int gmx_unused clearF,
213 real gmx_unused *fshift,
215 real gmx_unused *Vvdw)
216 #ifdef GMX_NBNXN_SIMD_4XN
219 nbnxn_pairlist_t **nbl;
223 nnbl = nbl_list->nnbl;
226 if (EEL_RF(ic->eeltype) || ic->eeltype == eelCUT)
232 if (ewald_excl == ewaldexclTable)
234 if (ic->rcoulomb == ic->rvdw)
240 coult = coultTAB_TWIN;
245 if (ic->rcoulomb == ic->rvdw)
251 coult = coultEWALD_TWIN;
256 #pragma omp parallel for schedule(static) num_threads(gmx_omp_nthreads_get(emntNonbonded))
257 for (nb = 0; nb < nnbl; nb++)
259 nbnxn_atomdata_output_t *out;
262 out = &nbat->out[nb];
264 if (clearF == enbvClearFYes)
266 clear_f(nbat, nb, out->f);
269 if ((force_flags & GMX_FORCE_VIRIAL) && nnbl == 1)
275 fshift_p = out->fshift;
277 if (clearF == enbvClearFYes)
279 clear_fshift(fshift_p);
283 if (!(force_flags & GMX_FORCE_ENERGY))
285 /* Don't calculate energies */
286 p_nbk_noener[coult][nbat->comb_rule](nbl[nb], nbat,
292 else if (out->nV == 1)
294 /* No energy groups */
298 p_nbk_ener[coult][nbat->comb_rule](nbl[nb], nbat,
308 /* Calculate energy group contributions */
311 for (i = 0; i < out->nVS; i++)
315 for (i = 0; i < out->nVS; i++)
320 p_nbk_energrp[coult][nbat->comb_rule](nbl[nb], nbat,
328 reduce_group_energies(nbat->nenergrp, nbat->neg_2log,
329 out->VSvdw, out->VSc,
334 if (force_flags & GMX_FORCE_ENERGY)
336 reduce_energies_over_lists(nbat, nnbl, Vvdw, Vc);
341 gmx_incons("nbnxn_kernel_simd_4xn called when such kernels "
342 " are not enabled.");
345 #undef GMX_SIMD_J_UNROLL_SIZE