-/* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*-
+/*
+ * This file is part of the GROMACS molecular simulation package.
*
- *
- * This source code is part of
- *
- * G R O M A C S
- *
- * GROningen MAchine for Chemical Simulations
- *
- * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2012, The GROMACS development team,
* check out http://www.gromacs.org for more information.
+ * Copyright (c) 2012, by the GROMACS development team, led by
+ * David van der Spoel, Berk Hess, Erik Lindahl, and including many
+ * others, as listed in the AUTHORS file in the top-level source
+ * directory and at http://www.gromacs.org.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
+ * 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.
*
- * If you want to redistribute modifications, 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 www.gromacs.org.
+ * 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.
*
- * To help us fund GROMACS development, we humbly ask that you cite
- * the papers on the package - you can find them in the top README file.
+ * 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.
*
- * For more info, check our website at http://www.gromacs.org
+ * 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.
*
- * And Hey:
- * Gallium Rubidium Oxygen Manganese Argon Carbon Silicon
- */
-
-/* GMX_MM128_HERE or GMX_MM256_HERE should be set before including this file.
- * gmx_sse_or_avh.h should be included before including this file.
+ * To help us fund GROMACS development, we humbly ask that you cite
+ * the research papers on the package. Check out http://www.gromacs.org.
*/
-/* Copies PBC shifted i-cell packed atom coordinates to working array */
-#ifdef GMX_MM128_HERE
-static void icell_set_x_x86_simd128
+#if GMX_NBNXN_SIMD_BITWIDTH == 128
+#define GMX_MM128_HERE
#else
-#ifdef GMX_MM256_HERE
-static void icell_set_x_x86_simd256
+#if GMX_NBNXN_SIMD_BITWIDTH == 256
+#define GMX_MM256_HERE
#else
-"error: GMX_MM128_HERE or GMX_MM256_HERE not defined"
+#error "unsupported GMX_NBNXN_SIMD_BITWIDTH"
#endif
#endif
- (int ci,
- real shx,real shy,real shz,
- int na_c,
- int stride,const real *x,
- nbnxn_list_work_t *work)
-{
- int ia;
-#ifdef GMX_MM128_HERE
- nbnxn_x_ci_x86_simd128_t *x_ci;
-
- x_ci = work->x_ci_x86_simd128;
+#include "gmx_simd_macros.h"
- ia = X_IND_CI_S128(ci);
+#if GMX_SIMD_WIDTH_HERE >= NBNXN_CPU_CLUSTER_I_SIZE
+#define STRIDE_S (GMX_SIMD_WIDTH_HERE)
#else
- nbnxn_x_ci_x86_simd256_t *x_ci;
+#define STRIDE_S NBNXN_CPU_CLUSTER_I_SIZE
+#endif
- x_ci = work->x_ci_x86_simd256;
+/* Copies PBC shifted i-cell packed atom coordinates to working array */
+static gmx_inline void
+icell_set_x_simd_4xn(int ci,
+ real shx,real shy,real shz,
+ int na_c,
+ int stride,const real *x,
+ nbnxn_list_work_t *work)
+{
+ int ia;
+ nbnxn_x_ci_simd_4xn_t *x_ci;
- ia = X_IND_CI_S256(ci);
-#endif
+ x_ci = work->x_ci_simd_4xn;
+
+ ia = X_IND_CI_SIMD_4XN(ci);
x_ci->ix_SSE0 = gmx_set1_pr(x[ia + 0*STRIDE_S ] + shx);
x_ci->iy_SSE0 = gmx_set1_pr(x[ia + 1*STRIDE_S ] + shy);
x_ci->iz_SSE3 = gmx_set1_pr(x[ia + 2*STRIDE_S + 3] + shz);
}
-/* SSE or AVX code for making a pair list of cell ci vs cell cjf-cjl
+/* SIMD code for making a pair list of cell ci vs cell cjf-cjl
* for coordinates in packed format.
* Checks bouding box distances and possibly atom pair distances.
* This is an accelerated version of make_cluster_list_simple.
*/
-#ifdef GMX_MM128_HERE
-static void make_cluster_list_x86_simd128
-#else
-#ifdef GMX_MM256_HERE
-static void make_cluster_list_x86_simd256
-#else
-"error: GMX_MM128_HERE or GMX_MM256_HERE not defined"
-#endif
-#endif
- (const nbnxn_grid_t *gridj,
- nbnxn_pairlist_t *nbl,
- int ci,int cjf,int cjl,
- gmx_bool remove_sub_diag,
- const real *x_j,
- real rl2,float rbb2,
- int *ndistc)
+static gmx_inline void
+make_cluster_list_simd_4xn(const nbnxn_grid_t *gridj,
+ nbnxn_pairlist_t *nbl,
+ int ci,int cjf,int cjl,
+ gmx_bool remove_sub_diag,
+ const real *x_j,
+ real rl2,float rbb2,
+ int *ndistc)
{
-#ifdef GMX_MM128_HERE
- const nbnxn_x_ci_x86_simd128_t *work;
-#else
- const nbnxn_x_ci_x86_simd256_t *work;
-#endif
-
+ const nbnxn_x_ci_simd_4xn_t *work;
const float *bb_ci;
gmx_mm_pr jx_SSE,jy_SSE,jz_SSE;
float d2;
int xind_f,xind_l,cj;
-#ifdef GMX_MM128_HERE
- cjf = CI_TO_CJ_S128(cjf);
- cjl = CI_TO_CJ_S128(cjl+1) - 1;
-
- work = nbl->work->x_ci_x86_simd128;
-#else
- cjf = CI_TO_CJ_S256(cjf);
- cjl = CI_TO_CJ_S256(cjl+1) - 1;
+ cjf = CI_TO_CJ_SIMD_4XN(cjf);
+ cjl = CI_TO_CJ_SIMD_4XN(cjl+1) - 1;
- work = nbl->work->x_ci_x86_simd256;
-#endif
+ work = nbl->work->x_ci_simd_4xn;
bb_ci = nbl->work->bb_ci;
}
else if (d2 < rl2)
{
-#ifdef GMX_MM128_HERE
- xind_f = X_IND_CJ_S128(CI_TO_CJ_S128(gridj->cell0) + cjf);
-#else
- xind_f = X_IND_CJ_S256(CI_TO_CJ_S256(gridj->cell0) + cjf);
-#endif
+ xind_f = X_IND_CJ_SIMD_4XN(CI_TO_CJ_SIMD_4XN(gridj->cell0) + cjf);
+
jx_SSE = gmx_load_pr(x_j+xind_f+0*STRIDE_S);
jy_SSE = gmx_load_pr(x_j+xind_f+1*STRIDE_S);
jz_SSE = gmx_load_pr(x_j+xind_f+2*STRIDE_S);
InRange = gmx_movemask_pr(wco_any_SSE);
- *ndistc += 4*GMX_X86_SIMD_WIDTH_HERE;
+ *ndistc += 4*GMX_SIMD_WIDTH_HERE;
}
if (!InRange)
{
}
else if (d2 < rl2)
{
-#ifdef GMX_MM128_HERE
- xind_l = X_IND_CJ_S128(CI_TO_CJ_S128(gridj->cell0) + cjl);
-#else
- xind_l = X_IND_CJ_S256(CI_TO_CJ_S256(gridj->cell0) + cjl);
-#endif
+ xind_l = X_IND_CJ_SIMD_4XN(CI_TO_CJ_SIMD_4XN(gridj->cell0) + cjl);
+
jx_SSE = gmx_load_pr(x_j+xind_l+0*STRIDE_S);
jy_SSE = gmx_load_pr(x_j+xind_l+1*STRIDE_S);
jz_SSE = gmx_load_pr(x_j+xind_l+2*STRIDE_S);
InRange = gmx_movemask_pr(wco_any_SSE);
- *ndistc += 4*GMX_X86_SIMD_WIDTH_HERE;
+ *ndistc += 4*GMX_SIMD_WIDTH_HERE;
}
if (!InRange)
{
for(cj=cjf; cj<=cjl; cj++)
{
/* Store cj and the interaction mask */
-#ifdef GMX_MM128_HERE
- nbl->cj[nbl->ncj].cj = CI_TO_CJ_S128(gridj->cell0) + cj;
- nbl->cj[nbl->ncj].excl = get_imask_x86_simd128(remove_sub_diag,ci,cj);
-#else
- nbl->cj[nbl->ncj].cj = CI_TO_CJ_S256(gridj->cell0) + cj;
- nbl->cj[nbl->ncj].excl = get_imask_x86_simd256(remove_sub_diag,ci,cj);
-#endif
+ nbl->cj[nbl->ncj].cj = CI_TO_CJ_SIMD_4XN(gridj->cell0) + cj;
+ nbl->cj[nbl->ncj].excl = get_imask_x86_simd_4xn(remove_sub_diag,ci,cj);
nbl->ncj++;
}
/* Increase the closing index in i super-cell list */
nbl->ci[nbl->nci].cj_ind_end = nbl->ncj;
}
}
+
+#undef STRIDE_S
+#undef GMX_MM128_HERE
+#undef GMX_MM256_HERE