Merge branch release-4-6
[alexxy/gromacs.git] / src / gromacs / mdlib / nbnxn_kernels / simd_2xnn / nbnxn_kernel_simd_2xnn_common.h
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 2012,2013, by the GROMACS development team, led by
5  * David van der Spoel, Berk Hess, Erik Lindahl, and including many
6  * others, as listed in the AUTHORS file in the top-level source
7  * directory and at http://www.gromacs.org.
8  *
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.
13  *
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.
18  *
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.
23  *
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.
31  *
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.
34  */
35 #include "gmx_simd_macros.h"
36 #include "gmx_simd_vec.h"
37 #include "../../nbnxn_consts.h"
38 #ifdef CALC_COUL_EWALD
39 #include "maths.h"
40 #endif
41
42
43 #define SUM_SIMD4(x) (x[0]+x[1]+x[2]+x[3])
44
45 #define UNROLLI    NBNXN_CPU_CLUSTER_I_SIZE
46 #define UNROLLJ    (GMX_SIMD_WIDTH_HERE/GMX_SIMD_J_UNROLL_SIZE)
47
48 /* The stride of all the atom data arrays is equal to half the SIMD width */
49 #define STRIDE     (GMX_SIMD_WIDTH_HERE/GMX_SIMD_J_UNROLL_SIZE)
50
51 #if GMX_SIMD_WIDTH_HERE == 8
52 #define SUM_SIMD(x) (x[0]+x[1]+x[2]+x[3]+x[4]+x[5]+x[6]+x[7])
53 #else
54 #if GMX_SIMD_WIDTH_HERE == 16
55 /* This is getting ridiculous, SIMD horizontal adds would help,
56  * but this is not performance critical (only used to reduce energies)
57  */
58 #define SUM_SIMD(x) (x[0]+x[1]+x[2]+x[3]+x[4]+x[5]+x[6]+x[7]+x[8]+x[9]+x[10]+x[11]+x[12]+x[13]+x[14]+x[15])
59 #else
60 #error "unsupported kernel configuration"
61 #endif
62 #endif
63
64 #include "../nbnxn_kernel_simd_utils.h"
65
66 static inline void
67 gmx_load_simd_2xnn_interactions(int            excl,
68                                 gmx_exclfilter filter_S0,
69                                 gmx_exclfilter filter_S2,
70                                 gmx_mm_pb     *interact_S0,
71                                 gmx_mm_pb     *interact_S2)
72 {
73     /* Load integer interaction mask */
74     gmx_exclfilter mask_pr_S = gmx_load1_exclfilter(excl);
75     *interact_S0  = gmx_checkbitmask_pb(mask_pr_S, filter_S0);
76     *interact_S2  = gmx_checkbitmask_pb(mask_pr_S, filter_S2);
77 }
78
79 /* All functionality defines are set here, except for:
80  * CALC_ENERGIES, ENERGY_GROUPS which are defined before.
81  * CHECK_EXCLS, which is set just before including the inner loop contents.
82  * The combination rule defines, LJ_COMB_GEOM or LJ_COMB_LB are currently
83  * set before calling the kernel function. We might want to move that
84  * to inside the n-loop and have a different combination rule for different
85  * ci's, as no combination rule gives a 50% performance hit for LJ.
86  */
87
88 /* We always calculate shift forces, because it's cheap anyhow */
89 #define CALC_SHIFTFORCES
90
91 /* Assumes all LJ parameters are identical */
92 /* #define FIX_LJ_C */