2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5 * Copyright (c) 2001-2012, The GROMACS Development Team
6 * Copyright (c) 2012,2013, by the GROMACS development team, led by
7 * David van der Spoel, Berk Hess, Erik Lindahl, and including many
8 * others, as listed in the AUTHORS file in the top-level source
9 * directory and at http://www.gromacs.org.
11 * GROMACS is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public License
13 * as published by the Free Software Foundation; either version 2.1
14 * of the License, or (at your option) any later version.
16 * GROMACS is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with GROMACS; if not, see
23 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
24 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 * If you want to redistribute modifications to GROMACS, please
27 * consider that scientific software is very special. Version
28 * control is crucial - bugs must be traceable. We will be happy to
29 * consider code for inclusion in the official distribution, but
30 * derived work must not be called official GROMACS. Details are found
31 * in the README & COPYING files - if they are missing, get the
32 * official version at http://www.gromacs.org.
34 * To help us fund GROMACS development, we humbly ask that you cite
35 * the research papers on the package. Check out http://www.gromacs.org.
37 #ifndef _nbnxn_kernel_sse_utils_h_
38 #define _nbnxn_kernel_sse_utils_h_
40 /* This files contains all functions/macros for the SIMD kernels
41 * which have explicit dependencies on the j-cluster size and/or SIMD-width.
42 * The functionality which depends on the j-cluster size is:
45 * energy group pair energy storage
49 /* Include SIMD architecture specific versions of the 4/5 functions above */
50 #ifdef GMX_SIMD_REFERENCE_PLAIN_C
51 #include "nbnxn_kernel_simd_utils_ref.h"
54 /* Include x86 SSE2 compatible SIMD functions */
55 #if defined GMX_X86_AVX_256 && !defined GMX_USE_HALF_WIDTH_SIMD_HERE
57 #include "nbnxn_kernel_simd_utils_x86_256d.h"
59 #include "nbnxn_kernel_simd_utils_x86_256s.h"
63 #include "nbnxn_kernel_simd_utils_x86_128d.h"
65 #include "nbnxn_kernel_simd_utils_x86_128s.h"
73 /* Add energy register to possibly multiple terms in the energy array */
74 static inline void add_ener_grp(gmx_mm_pr e_S, real *v, const int *offset_jj)
78 /* We need to balance the number of store operations with
79 * the rapidly increases number of combinations of energy groups.
80 * We add to a temporary buffer for 1 i-group vs 2 j-groups.
82 for (jj = 0; jj < (UNROLLJ/2); jj++)
86 v_S = gmx_load_pr(v+offset_jj[jj]+jj*GMX_SIMD_WIDTH_HERE);
87 gmx_store_pr(v+offset_jj[jj]+jj*GMX_SIMD_WIDTH_HERE, gmx_add_pr(v_S, e_S));
92 #if defined GMX_NBNXN_SIMD_2XNN && defined UNROLLJ
93 /* As add_ener_grp, but for two groups of UNROLLJ/2 stored in
94 * a single SIMD register.
97 add_ener_grp_halves(gmx_mm_pr e_S, real *v0, real *v1, const int *offset_jj)
99 gmx_mm_hpr e_S0, e_S1;
102 gmx_pr_to_2hpr(e_S, &e_S0, &e_S1);
104 for (jj = 0; jj < (UNROLLJ/2); jj++)
108 gmx_load_hpr(&v_S, v0+offset_jj[jj]+jj*GMX_SIMD_WIDTH_HERE/2);
109 gmx_store_hpr(v0+offset_jj[jj]+jj*GMX_SIMD_WIDTH_HERE/2, gmx_add_hpr(v_S, e_S0));
111 for (jj = 0; jj < (UNROLLJ/2); jj++)
115 gmx_load_hpr(&v_S, v1+offset_jj[jj]+jj*GMX_SIMD_WIDTH_HERE/2);
116 gmx_store_hpr(v1+offset_jj[jj]+jj*GMX_SIMD_WIDTH_HERE/2, gmx_add_hpr(v_S, e_S1));
121 #endif /* _nbnxn_kernel_sse_utils_h_ */