First part of commit for redesigned SIMD module - namechanges.
[alexxy/gromacs.git] / src / gromacs / mdlib / nbnxn_kernels / nbnxn_kernel_simd_utils_ibm_qpx.h
index bfbf9e24eecc43f61ef86e6a50f0738b269c6253..fd857475b4291108a59fb7891fde890995bb3598 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2013, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
 #ifndef _nbnxn_kernel_simd_utils_ibm_qpx_h_
 #define _nbnxn_kernel_simd_utils_ibm_qpx_h_
 
-typedef gmx_mm_pr gmx_exclfilter;
+typedef gmx_simd_real_t gmx_exclfilter;
 static const int filter_stride = 1;
 
 /* The 4xn kernel operates on 4-wide i-force registers */
-typedef gmx_mm_pr gmx_mm_pr4;
+typedef gmx_simd_real_t gmx_mm_pr4;
 
 /* This files contains all functions/macros for the SIMD kernels
  * which have explicit dependencies on the j-cluster size and/or SIMD-width.
@@ -51,9 +51,10 @@ typedef gmx_mm_pr gmx_mm_pr4;
 
 /* Collect all [0123] elements of the 4 inputs to out[0123], respectively */
 static gmx_inline void
-gmx_transpose_4_ps(gmx_mm_pr a, gmx_mm_pr b, gmx_mm_pr c, gmx_mm_pr d,
-                   gmx_mm_pr *out0, gmx_mm_pr *out1,
-                   gmx_mm_pr *out2, gmx_mm_pr *out3)
+gmx_transpose_4_ps(gmx_simd_real_t a, gmx_simd_real_t b,
+                   gmx_simd_real_t c, gmx_simd_real_t d,
+                   gmx_simd_real_t *out0, gmx_simd_real_t *out1,
+                   gmx_simd_real_t *out2, gmx_simd_real_t *out3)
 {
     /* Prepare control vectors for swizzling. In its third input,
        vec_perm accepts indices into the effective 8-wide SIMD vector
@@ -63,14 +64,14 @@ gmx_transpose_4_ps(gmx_mm_pr a, gmx_mm_pr b, gmx_mm_pr c, gmx_mm_pr d,
        vec_gpci() converts an octal literal of the indices into the
        correct form for vec_perm() to use. That form is an octal digit
        in bits 0-2 of the mantissa of each double. */
-    gmx_mm_pr p6420 = vec_gpci(06420);
-    gmx_mm_pr p7531 = vec_gpci(07531);
+    gmx_simd_real_t p6420 = vec_gpci(06420);
+    gmx_simd_real_t p7531 = vec_gpci(07531);
 
     /* Four-way swizzle (i.e. transpose) of vectors a = a0a1a2a3, etc. */
-    gmx_mm_pr b2b0a2a0 = vec_perm(a, b, p6420);
-    gmx_mm_pr b3b1a3a1 = vec_perm(a, b, p7531);
-    gmx_mm_pr d2d0c2c0 = vec_perm(c, d, p6420);
-    gmx_mm_pr d3d1c3c1 = vec_perm(c, d, p7531);
+    gmx_simd_real_t b2b0a2a0 = vec_perm(a, b, p6420);
+    gmx_simd_real_t b3b1a3a1 = vec_perm(a, b, p7531);
+    gmx_simd_real_t d2d0c2c0 = vec_perm(c, d, p6420);
+    gmx_simd_real_t d3d1c3c1 = vec_perm(c, d, p7531);
     *out0 = vec_perm(d2d0c2c0, b2b0a2a0, p7531);
     *out1 = vec_perm(d3d1c3c1, b3b1a3a1, p7531);
     *out2 = vec_perm(d2d0c2c0, b2b0a2a0, p6420);
@@ -79,30 +80,32 @@ gmx_transpose_4_ps(gmx_mm_pr a, gmx_mm_pr b, gmx_mm_pr c, gmx_mm_pr d,
 
 /* Collect element 0 and 1 of the 4 inputs to out0 and out1, respectively */
 static gmx_inline void
-gmx_shuffle_4_ps_fil01_to_2_ps(gmx_mm_pr a, gmx_mm_pr b, gmx_mm_pr c, gmx_mm_pr d,
-                               gmx_mm_pr *out0, gmx_mm_pr *out1)
+gmx_shuffle_4_ps_fil01_to_2_ps(gmx_simd_real_t a, gmx_simd_real_t b,
+                               gmx_simd_real_t c, gmx_simd_real_t d,
+                               gmx_simd_real_t *out0, gmx_simd_real_t *out1)
 {
-    gmx_mm_pr p6420 = vec_gpci(06420);
-    gmx_mm_pr p7531 = vec_gpci(07531);
+    gmx_simd_real_t p6420 = vec_gpci(06420);
+    gmx_simd_real_t p7531 = vec_gpci(07531);
 
     /* Partial four-way swizzle of vectors a = a0a1a2a3, etc. */
-    gmx_mm_pr b2b0a2a0 = vec_perm(a, b, p6420);
-    gmx_mm_pr b3b1a3a1 = vec_perm(a, b, p7531);
-    gmx_mm_pr d2d0c2c0 = vec_perm(c, d, p6420);
-    gmx_mm_pr d3d1c3c1 = vec_perm(c, d, p7531);
+    gmx_simd_real_t b2b0a2a0 = vec_perm(a, b, p6420);
+    gmx_simd_real_t b3b1a3a1 = vec_perm(a, b, p7531);
+    gmx_simd_real_t d2d0c2c0 = vec_perm(c, d, p6420);
+    gmx_simd_real_t d3d1c3c1 = vec_perm(c, d, p7531);
     *out0 = vec_perm(d2d0c2c0, b2b0a2a0, p7531);
     *out1 = vec_perm(d3d1c3c1, b3b1a3a1, p7531);
 }
 
 /* Collect element 2 of the 4 inputs to out */
-static gmx_inline gmx_mm_pr
-gmx_shuffle_4_ps_fil2_to_1_ps(gmx_mm_pr a, gmx_mm_pr b, gmx_mm_pr c, gmx_mm_pr d)
+static gmx_inline gmx_simd_real_t
+gmx_shuffle_4_ps_fil2_to_1_ps(gmx_simd_real_t a, gmx_simd_real_t b,
+                              gmx_simd_real_t c, gmx_simd_real_t d)
 {
-    gmx_mm_pr p6420 = vec_gpci(06420);
+    gmx_simd_real_t p6420 = vec_gpci(06420);
 
     /* Partial four-way swizzle of vectors a = a0a1a2a3, etc. */
-    gmx_mm_pr b2b0a2a0 = vec_perm(a, b, p6420);
-    gmx_mm_pr d2d0c2c0 = vec_perm(c, d, p6420);
+    gmx_simd_real_t b2b0a2a0 = vec_perm(a, b, p6420);
+    gmx_simd_real_t d2d0c2c0 = vec_perm(c, d, p6420);
     return vec_perm(d2d0c2c0, b2b0a2a0, p6420);
 }
 
@@ -112,12 +115,12 @@ gmx_shuffle_4_ps_fil2_to_1_ps(gmx_mm_pr a, gmx_mm_pr b, gmx_mm_pr c, gmx_mm_pr d
 static gmx_inline int *
 prepare_table_load_buffer(const int *array)
 {
-    return gmx_simd_align_int(array);
+    return gmx_simd_align_i(array);
 }
 
 static gmx_inline void
-load_table_f(const real *tab_coul_FDV0, gmx_epi32 ti_S, int *ti,
-             gmx_mm_pr *ctab0_S, gmx_mm_pr *ctab1_S)
+load_table_f(const real *tab_coul_FDV0, gmx_simd_int32_t ti_S, int *ti,
+             gmx_simd_real_t *ctab0_S, gmx_simd_real_t *ctab1_S)
 {
 #ifdef NDEBUG
     /* Just like 256-bit AVX, we need to use memory to get indices
@@ -128,19 +131,19 @@ load_table_f(const real *tab_coul_FDV0, gmx_epi32 ti_S, int *ti,
 #endif
 
     /* Here we load 4 aligned reals, but we need just 2 elements of each */
-    gmx_mm_pr a = gmx_load_pr(tab_coul_FDV0 + ti[0] * nbfp_stride);
-    gmx_mm_pr b = gmx_load_pr(tab_coul_FDV0 + ti[1] * nbfp_stride);
-    gmx_mm_pr c = gmx_load_pr(tab_coul_FDV0 + ti[2] * nbfp_stride);
-    gmx_mm_pr d = gmx_load_pr(tab_coul_FDV0 + ti[3] * nbfp_stride);
+    gmx_simd_real_t a = gmx_simd_load_r(tab_coul_FDV0 + ti[0] * nbfp_stride);
+    gmx_simd_real_t b = gmx_simd_load_r(tab_coul_FDV0 + ti[1] * nbfp_stride);
+    gmx_simd_real_t c = gmx_simd_load_r(tab_coul_FDV0 + ti[2] * nbfp_stride);
+    gmx_simd_real_t d = gmx_simd_load_r(tab_coul_FDV0 + ti[3] * nbfp_stride);
 
     gmx_shuffle_4_ps_fil01_to_2_ps(a, b, c, d, ctab0_S, ctab1_S);
 }
 
 static gmx_inline void
 load_table_f_v(const real *tab_coul_FDV0,
-               gmx_epi32 ti_S, int *ti,
-               gmx_mm_pr *ctab0_S, gmx_mm_pr *ctab1_S,
-               gmx_mm_pr *ctabv_S)
+               gmx_simd_int32_t ti_S, int *ti,
+               gmx_simd_real_t *ctab0_S, gmx_simd_real_t *ctab1_S,
+               gmx_simd_real_t *ctabv_S)
 {
 #ifdef NDEBUG
     /* Just like 256-bit AVX, we need to use memory to get indices
@@ -151,10 +154,10 @@ load_table_f_v(const real *tab_coul_FDV0,
 #endif
 
     /* Here we load 4 aligned reals, but we need just 3 elements of each. */
-    gmx_mm_pr a = gmx_load_pr(tab_coul_FDV0 + ti[0] * nbfp_stride);
-    gmx_mm_pr b = gmx_load_pr(tab_coul_FDV0 + ti[1] * nbfp_stride);
-    gmx_mm_pr c = gmx_load_pr(tab_coul_FDV0 + ti[2] * nbfp_stride);
-    gmx_mm_pr d = gmx_load_pr(tab_coul_FDV0 + ti[3] * nbfp_stride);
+    gmx_simd_real_t a = gmx_simd_load_r(tab_coul_FDV0 + ti[0] * nbfp_stride);
+    gmx_simd_real_t b = gmx_simd_load_r(tab_coul_FDV0 + ti[1] * nbfp_stride);
+    gmx_simd_real_t c = gmx_simd_load_r(tab_coul_FDV0 + ti[2] * nbfp_stride);
+    gmx_simd_real_t d = gmx_simd_load_r(tab_coul_FDV0 + ti[3] * nbfp_stride);
 
     gmx_shuffle_4_ps_fil01_to_2_ps(a, b, c, d, ctab0_S, ctab1_S);
     *ctabv_S = gmx_shuffle_4_ps_fil2_to_1_ps(a, b, c, d);
@@ -167,20 +170,20 @@ load_table_f_v(const real *tab_coul_FDV0,
 
 /* Sum the elements within each input register and store the sums in out.
  */
-static gmx_inline gmx_mm_pr
-gmx_mm_transpose_sum4_pr(gmx_mm_pr a, gmx_mm_pr b,
-                         gmx_mm_pr c, gmx_mm_pr d)
+static gmx_inline gmx_simd_real_t
+gmx_mm_transpose_sum4_pr(gmx_simd_real_t a, gmx_simd_real_t b,
+                         gmx_simd_real_t c, gmx_simd_real_t d)
 {
-    gmx_mm_pr a0b0c0d0, a1b1c1d1, a2b2c2d2, a3b3c3d3;
+    gmx_simd_real_t a0b0c0d0, a1b1c1d1, a2b2c2d2, a3b3c3d3;
     gmx_transpose_4_ps(a, b, c, d,
                        &a0b0c0d0,
                        &a1b1c1d1,
                        &a2b2c2d2,
                        &a3b3c3d3);
     /* Now reduce the transposed vectors */
-    gmx_mm_pr sum01 = gmx_add_pr(a0b0c0d0, a1b1c1d1);
-    gmx_mm_pr sim23 = gmx_add_pr(a2b2c2d2, a3b3c3d3);
-    return gmx_add_pr(sum01, sim23);
+    gmx_simd_real_t sum01 = gmx_simd_add_r(a0b0c0d0, a1b1c1d1);
+    gmx_simd_real_t sim23 = gmx_simd_add_r(a2b2c2d2, a3b3c3d3);
+    return gmx_simd_add_r(sum01, sim23);
 }
 
 #ifdef GMX_DOUBLE
@@ -191,23 +194,23 @@ gmx_mm_transpose_sum4_pr(gmx_mm_pr a, gmx_mm_pr b,
  * reciprocal square roots.
  */
 static gmx_inline void
-gmx_mm_invsqrt2_pd(gmx_mm_pr in0, gmx_mm_pr in1,
-                   gmx_mm_pr *out0, gmx_mm_pr *out1)
+gmx_mm_invsqrt2_pd(gmx_simd_real_t in0, gmx_simd_real_t in1,
+                   gmx_simd_real_t *out0, gmx_simd_real_t *out1)
 {
-    *out0 = gmx_invsqrt_pr(in0);
-    *out1 = gmx_invsqrt_pr(in1);
+    *out0 = gmx_simd_invsqrt_r(in0);
+    *out1 = gmx_simd_invsqrt_r(in1);
 }
 #endif
 
 static gmx_inline void
 load_lj_pair_params(const real *nbfp, const int *type, int aj,
-                    gmx_mm_pr *c6_S, gmx_mm_pr *c12_S)
+                    gmx_simd_real_t *c6_S, gmx_simd_real_t *c12_S)
 {
     /* Here we load 4 aligned reals, but we need just 2 elemnts of each. */
-    gmx_mm_pr a = gmx_load_pr(nbfp + type[aj+0] * nbfp_stride);
-    gmx_mm_pr b = gmx_load_pr(nbfp + type[aj+1] * nbfp_stride);
-    gmx_mm_pr c = gmx_load_pr(nbfp + type[aj+2] * nbfp_stride);
-    gmx_mm_pr d = gmx_load_pr(nbfp + type[aj+3] * nbfp_stride);
+    gmx_simd_real_t a = gmx_simd_load_r(nbfp + type[aj+0] * nbfp_stride);
+    gmx_simd_real_t b = gmx_simd_load_r(nbfp + type[aj+1] * nbfp_stride);
+    gmx_simd_real_t c = gmx_simd_load_r(nbfp + type[aj+2] * nbfp_stride);
+    gmx_simd_real_t d = gmx_simd_load_r(nbfp + type[aj+3] * nbfp_stride);
 
     gmx_shuffle_4_ps_fil01_to_2_ps(a, b, c, d, c6_S, c12_S);
 }
@@ -234,7 +237,7 @@ static gmx_inline gmx_exclfilter gmx_load_exclusion_filter(const unsigned *a)
 /* Code for handling loading and applying exclusion masks. Note that
    parameter a is not treated like an array index; it is naively added
    to b, so should be in bytes. */
-static gmx_inline gmx_mm_pb gmx_load_interaction_mask_pb(long a, const real *b)
+static gmx_inline gmx_simd_bool_t gmx_load_interaction_mask_pb(long a, const real *b)
 {
 #ifdef NDEBUG
     return vec_ld(a, (real *) b);