1368008961fbbfae4544b2d591bba319e359bc5e
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_sparc64_hpc_ace_double / nb_kernel_ElecEwSh_VdwLJEwSh_GeomW4W4_sparc64_hpc_ace_double.c
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 2012,2013,2014, 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.
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 /*
36  * Note: this file was generated by the GROMACS sparc64_hpc_ace_double kernel generator.
37  */
38 #include "config.h"
39
40 #include <math.h>
41
42 #include "../nb_kernel.h"
43 #include "gromacs/legacyheaders/types/simple.h"
44 #include "gromacs/math/vec.h"
45 #include "gromacs/legacyheaders/nrnb.h"
46
47 #include "kernelutil_sparc64_hpc_ace_double.h"
48
49 /*
50  * Gromacs nonbonded kernel:   nb_kernel_ElecEwSh_VdwLJEwSh_GeomW4W4_VF_sparc64_hpc_ace_double
51  * Electrostatics interaction: Ewald
52  * VdW interaction:            LJEwald
53  * Geometry:                   Water4-Water4
54  * Calculate force/pot:        PotentialAndForce
55  */
56 void
57 nb_kernel_ElecEwSh_VdwLJEwSh_GeomW4W4_VF_sparc64_hpc_ace_double
58                     (t_nblist                    * gmx_restrict       nlist,
59                      rvec                        * gmx_restrict          xx,
60                      rvec                        * gmx_restrict          ff,
61                      t_forcerec                  * gmx_restrict          fr,
62                      t_mdatoms                   * gmx_restrict     mdatoms,
63                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
64                      t_nrnb                      * gmx_restrict        nrnb)
65 {
66     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
67      * just 0 for non-waters.
68      * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
69      * jnr indices corresponding to data put in the four positions in the SIMD register.
70      */
71     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
72     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
73     int              jnrA,jnrB;
74     int              j_coord_offsetA,j_coord_offsetB;
75     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
76     real             rcutoff_scalar;
77     real             *shiftvec,*fshift,*x,*f;
78     _fjsp_v2r8       tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
79     int              vdwioffset0;
80     _fjsp_v2r8       ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
81     int              vdwioffset1;
82     _fjsp_v2r8       ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
83     int              vdwioffset2;
84     _fjsp_v2r8       ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
85     int              vdwioffset3;
86     _fjsp_v2r8       ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
87     int              vdwjidx0A,vdwjidx0B;
88     _fjsp_v2r8       jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
89     int              vdwjidx1A,vdwjidx1B;
90     _fjsp_v2r8       jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
91     int              vdwjidx2A,vdwjidx2B;
92     _fjsp_v2r8       jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
93     int              vdwjidx3A,vdwjidx3B;
94     _fjsp_v2r8       jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
95     _fjsp_v2r8       dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
96     _fjsp_v2r8       dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
97     _fjsp_v2r8       dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
98     _fjsp_v2r8       dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13;
99     _fjsp_v2r8       dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
100     _fjsp_v2r8       dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
101     _fjsp_v2r8       dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23;
102     _fjsp_v2r8       dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31;
103     _fjsp_v2r8       dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32;
104     _fjsp_v2r8       dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33;
105     _fjsp_v2r8       velec,felec,velecsum,facel,crf,krf,krf2;
106     real             *charge;
107     int              nvdwtype;
108     _fjsp_v2r8       rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
109     int              *vdwtype;
110     real             *vdwparam;
111     _fjsp_v2r8       one_sixth   = gmx_fjsp_set1_v2r8(1.0/6.0);
112     _fjsp_v2r8       one_twelfth = gmx_fjsp_set1_v2r8(1.0/12.0);
113     _fjsp_v2r8           c6grid_00;
114     _fjsp_v2r8           c6grid_11;
115     _fjsp_v2r8           c6grid_12;
116     _fjsp_v2r8           c6grid_13;
117     _fjsp_v2r8           c6grid_21;
118     _fjsp_v2r8           c6grid_22;
119     _fjsp_v2r8           c6grid_23;
120     _fjsp_v2r8           c6grid_31;
121     _fjsp_v2r8           c6grid_32;
122     _fjsp_v2r8           c6grid_33;
123     real                 *vdwgridparam;
124     _fjsp_v2r8           ewclj,ewclj2,ewclj6,ewcljrsq,poly,exponent,f6A,f6B,sh_lj_ewald;
125     _fjsp_v2r8           one_half = gmx_fjsp_set1_v2r8(0.5);
126     _fjsp_v2r8           minus_one = gmx_fjsp_set1_v2r8(-1.0);
127     _fjsp_v2r8       ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
128     real             *ewtab;
129     _fjsp_v2r8       itab_tmp;
130     _fjsp_v2r8       dummy_mask,cutoff_mask;
131     _fjsp_v2r8       one     = gmx_fjsp_set1_v2r8(1.0);
132     _fjsp_v2r8       two     = gmx_fjsp_set1_v2r8(2.0);
133     union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
134
135     x                = xx[0];
136     f                = ff[0];
137
138     nri              = nlist->nri;
139     iinr             = nlist->iinr;
140     jindex           = nlist->jindex;
141     jjnr             = nlist->jjnr;
142     shiftidx         = nlist->shift;
143     gid              = nlist->gid;
144     shiftvec         = fr->shift_vec[0];
145     fshift           = fr->fshift[0];
146     facel            = gmx_fjsp_set1_v2r8(fr->epsfac);
147     charge           = mdatoms->chargeA;
148     nvdwtype         = fr->ntype;
149     vdwparam         = fr->nbfp;
150     vdwtype          = mdatoms->typeA;
151     vdwgridparam     = fr->ljpme_c6grid;
152     sh_lj_ewald      = gmx_fjsp_set1_v2r8(fr->ic->sh_lj_ewald);
153     ewclj            = gmx_fjsp_set1_v2r8(fr->ewaldcoeff_lj);
154     ewclj2           = _fjsp_mul_v2r8(minus_one,_fjsp_mul_v2r8(ewclj,ewclj));
155
156     sh_ewald         = gmx_fjsp_set1_v2r8(fr->ic->sh_ewald);
157     ewtab            = fr->ic->tabq_coul_FDV0;
158     ewtabscale       = gmx_fjsp_set1_v2r8(fr->ic->tabq_scale);
159     ewtabhalfspace   = gmx_fjsp_set1_v2r8(0.5/fr->ic->tabq_scale);
160
161     /* Setup water-specific parameters */
162     inr              = nlist->iinr[0];
163     iq1              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+1]));
164     iq2              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+2]));
165     iq3              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+3]));
166     vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
167
168     jq1              = gmx_fjsp_set1_v2r8(charge[inr+1]);
169     jq2              = gmx_fjsp_set1_v2r8(charge[inr+2]);
170     jq3              = gmx_fjsp_set1_v2r8(charge[inr+3]);
171     vdwjidx0A        = 2*vdwtype[inr+0];
172     c6_00            = gmx_fjsp_set1_v2r8(vdwparam[vdwioffset0+vdwjidx0A]);
173     c12_00           = gmx_fjsp_set1_v2r8(vdwparam[vdwioffset0+vdwjidx0A+1]);
174     c6grid_00        = gmx_fjsp_set1_v2r8(vdwgridparam[vdwioffset0+vdwjidx0A]);
175     qq11             = _fjsp_mul_v2r8(iq1,jq1);
176     qq12             = _fjsp_mul_v2r8(iq1,jq2);
177     qq13             = _fjsp_mul_v2r8(iq1,jq3);
178     qq21             = _fjsp_mul_v2r8(iq2,jq1);
179     qq22             = _fjsp_mul_v2r8(iq2,jq2);
180     qq23             = _fjsp_mul_v2r8(iq2,jq3);
181     qq31             = _fjsp_mul_v2r8(iq3,jq1);
182     qq32             = _fjsp_mul_v2r8(iq3,jq2);
183     qq33             = _fjsp_mul_v2r8(iq3,jq3);
184
185     /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
186     rcutoff_scalar   = fr->rcoulomb;
187     rcutoff          = gmx_fjsp_set1_v2r8(rcutoff_scalar);
188     rcutoff2         = _fjsp_mul_v2r8(rcutoff,rcutoff);
189
190     sh_vdw_invrcut6  = gmx_fjsp_set1_v2r8(fr->ic->sh_invrc6);
191     rvdw             = gmx_fjsp_set1_v2r8(fr->rvdw);
192
193     /* Avoid stupid compiler warnings */
194     jnrA = jnrB = 0;
195     j_coord_offsetA = 0;
196     j_coord_offsetB = 0;
197
198     outeriter        = 0;
199     inneriter        = 0;
200
201     /* Start outer loop over neighborlists */
202     for(iidx=0; iidx<nri; iidx++)
203     {
204         /* Load shift vector for this list */
205         i_shift_offset   = DIM*shiftidx[iidx];
206
207         /* Load limits for loop over neighbors */
208         j_index_start    = jindex[iidx];
209         j_index_end      = jindex[iidx+1];
210
211         /* Get outer coordinate index */
212         inr              = iinr[iidx];
213         i_coord_offset   = DIM*inr;
214
215         /* Load i particle coords and add shift vector */
216         gmx_fjsp_load_shift_and_4rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,
217                                                  &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
218
219         fix0             = _fjsp_setzero_v2r8();
220         fiy0             = _fjsp_setzero_v2r8();
221         fiz0             = _fjsp_setzero_v2r8();
222         fix1             = _fjsp_setzero_v2r8();
223         fiy1             = _fjsp_setzero_v2r8();
224         fiz1             = _fjsp_setzero_v2r8();
225         fix2             = _fjsp_setzero_v2r8();
226         fiy2             = _fjsp_setzero_v2r8();
227         fiz2             = _fjsp_setzero_v2r8();
228         fix3             = _fjsp_setzero_v2r8();
229         fiy3             = _fjsp_setzero_v2r8();
230         fiz3             = _fjsp_setzero_v2r8();
231
232         /* Reset potential sums */
233         velecsum         = _fjsp_setzero_v2r8();
234         vvdwsum          = _fjsp_setzero_v2r8();
235
236         /* Start inner kernel loop */
237         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
238         {
239
240             /* Get j neighbor index, and coordinate index */
241             jnrA             = jjnr[jidx];
242             jnrB             = jjnr[jidx+1];
243             j_coord_offsetA  = DIM*jnrA;
244             j_coord_offsetB  = DIM*jnrB;
245
246             /* load j atom coordinates */
247             gmx_fjsp_load_4rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
248                                               &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,
249                                               &jy2,&jz2,&jx3,&jy3,&jz3);
250
251             /* Calculate displacement vector */
252             dx00             = _fjsp_sub_v2r8(ix0,jx0);
253             dy00             = _fjsp_sub_v2r8(iy0,jy0);
254             dz00             = _fjsp_sub_v2r8(iz0,jz0);
255             dx11             = _fjsp_sub_v2r8(ix1,jx1);
256             dy11             = _fjsp_sub_v2r8(iy1,jy1);
257             dz11             = _fjsp_sub_v2r8(iz1,jz1);
258             dx12             = _fjsp_sub_v2r8(ix1,jx2);
259             dy12             = _fjsp_sub_v2r8(iy1,jy2);
260             dz12             = _fjsp_sub_v2r8(iz1,jz2);
261             dx13             = _fjsp_sub_v2r8(ix1,jx3);
262             dy13             = _fjsp_sub_v2r8(iy1,jy3);
263             dz13             = _fjsp_sub_v2r8(iz1,jz3);
264             dx21             = _fjsp_sub_v2r8(ix2,jx1);
265             dy21             = _fjsp_sub_v2r8(iy2,jy1);
266             dz21             = _fjsp_sub_v2r8(iz2,jz1);
267             dx22             = _fjsp_sub_v2r8(ix2,jx2);
268             dy22             = _fjsp_sub_v2r8(iy2,jy2);
269             dz22             = _fjsp_sub_v2r8(iz2,jz2);
270             dx23             = _fjsp_sub_v2r8(ix2,jx3);
271             dy23             = _fjsp_sub_v2r8(iy2,jy3);
272             dz23             = _fjsp_sub_v2r8(iz2,jz3);
273             dx31             = _fjsp_sub_v2r8(ix3,jx1);
274             dy31             = _fjsp_sub_v2r8(iy3,jy1);
275             dz31             = _fjsp_sub_v2r8(iz3,jz1);
276             dx32             = _fjsp_sub_v2r8(ix3,jx2);
277             dy32             = _fjsp_sub_v2r8(iy3,jy2);
278             dz32             = _fjsp_sub_v2r8(iz3,jz2);
279             dx33             = _fjsp_sub_v2r8(ix3,jx3);
280             dy33             = _fjsp_sub_v2r8(iy3,jy3);
281             dz33             = _fjsp_sub_v2r8(iz3,jz3);
282
283             /* Calculate squared distance and things based on it */
284             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
285             rsq11            = gmx_fjsp_calc_rsq_v2r8(dx11,dy11,dz11);
286             rsq12            = gmx_fjsp_calc_rsq_v2r8(dx12,dy12,dz12);
287             rsq13            = gmx_fjsp_calc_rsq_v2r8(dx13,dy13,dz13);
288             rsq21            = gmx_fjsp_calc_rsq_v2r8(dx21,dy21,dz21);
289             rsq22            = gmx_fjsp_calc_rsq_v2r8(dx22,dy22,dz22);
290             rsq23            = gmx_fjsp_calc_rsq_v2r8(dx23,dy23,dz23);
291             rsq31            = gmx_fjsp_calc_rsq_v2r8(dx31,dy31,dz31);
292             rsq32            = gmx_fjsp_calc_rsq_v2r8(dx32,dy32,dz32);
293             rsq33            = gmx_fjsp_calc_rsq_v2r8(dx33,dy33,dz33);
294
295             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
296             rinv11           = gmx_fjsp_invsqrt_v2r8(rsq11);
297             rinv12           = gmx_fjsp_invsqrt_v2r8(rsq12);
298             rinv13           = gmx_fjsp_invsqrt_v2r8(rsq13);
299             rinv21           = gmx_fjsp_invsqrt_v2r8(rsq21);
300             rinv22           = gmx_fjsp_invsqrt_v2r8(rsq22);
301             rinv23           = gmx_fjsp_invsqrt_v2r8(rsq23);
302             rinv31           = gmx_fjsp_invsqrt_v2r8(rsq31);
303             rinv32           = gmx_fjsp_invsqrt_v2r8(rsq32);
304             rinv33           = gmx_fjsp_invsqrt_v2r8(rsq33);
305
306             rinvsq00         = _fjsp_mul_v2r8(rinv00,rinv00);
307             rinvsq11         = _fjsp_mul_v2r8(rinv11,rinv11);
308             rinvsq12         = _fjsp_mul_v2r8(rinv12,rinv12);
309             rinvsq13         = _fjsp_mul_v2r8(rinv13,rinv13);
310             rinvsq21         = _fjsp_mul_v2r8(rinv21,rinv21);
311             rinvsq22         = _fjsp_mul_v2r8(rinv22,rinv22);
312             rinvsq23         = _fjsp_mul_v2r8(rinv23,rinv23);
313             rinvsq31         = _fjsp_mul_v2r8(rinv31,rinv31);
314             rinvsq32         = _fjsp_mul_v2r8(rinv32,rinv32);
315             rinvsq33         = _fjsp_mul_v2r8(rinv33,rinv33);
316
317             fjx0             = _fjsp_setzero_v2r8();
318             fjy0             = _fjsp_setzero_v2r8();
319             fjz0             = _fjsp_setzero_v2r8();
320             fjx1             = _fjsp_setzero_v2r8();
321             fjy1             = _fjsp_setzero_v2r8();
322             fjz1             = _fjsp_setzero_v2r8();
323             fjx2             = _fjsp_setzero_v2r8();
324             fjy2             = _fjsp_setzero_v2r8();
325             fjz2             = _fjsp_setzero_v2r8();
326             fjx3             = _fjsp_setzero_v2r8();
327             fjy3             = _fjsp_setzero_v2r8();
328             fjz3             = _fjsp_setzero_v2r8();
329
330             /**************************
331              * CALCULATE INTERACTIONS *
332              **************************/
333
334             if (gmx_fjsp_any_lt_v2r8(rsq00,rcutoff2))
335             {
336
337             r00              = _fjsp_mul_v2r8(rsq00,rinv00);
338
339             /* Analytical LJ-PME */
340             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
341             ewcljrsq         = _fjsp_mul_v2r8(ewclj2,rsq00);
342             ewclj6           = _fjsp_mul_v2r8(ewclj2,_fjsp_mul_v2r8(ewclj2,ewclj2));
343             exponent         = gmx_simd_exp_d(-ewcljrsq);
344             /* poly = exp(-(beta*r)^2) * (1 + (beta*r)^2 + (beta*r)^4 /2) */
345             poly             = _fjsp_mul_v2r8(exponent,_fjsp_madd_v2r8(_fjsp_mul_v2r8(ewcljrsq,ewcljrsq),one_half,_fjsp_sub_v2r8(one,ewcljrsq)));
346             /* vvdw6 = [C6 - C6grid * (1-poly)]/r6 */
347             vvdw6            = _fjsp_mul_v2r8(_fjsp_madd_v2r8(-c6grid_00,_fjsp_sub_v2r8(one,poly),c6_00),rinvsix);
348             vvdw12           = _fjsp_mul_v2r8(c12_00,_fjsp_mul_v2r8(rinvsix,rinvsix));
349             vvdw             = _fjsp_msub_v2r8(_fjsp_nmsub_v2r8(c12_00,_fjsp_mul_v2r8(sh_vdw_invrcut6,sh_vdw_invrcut6),vvdw12),one_twelfth,
350                                _fjsp_mul_v2r8(_fjsp_sub_v2r8(vvdw6,_fjsp_madd_v2r8(c6grid_00,sh_lj_ewald,_fjsp_mul_v2r8(c6_00,sh_vdw_invrcut6))),one_sixth));
351             /* fvdw = vvdw12/r - (vvdw6/r + (C6grid * exponent * beta^6)/r) */
352             fvdw             = _fjsp_mul_v2r8(_fjsp_add_v2r8(vvdw12,_fjsp_msub_v2r8(_fjsp_mul_v2r8(c6grid_00,one_sixth),_fjsp_mul_v2r8(exponent,ewclj6),vvdw6)),rinvsq00);
353
354             cutoff_mask      = _fjsp_cmplt_v2r8(rsq00,rcutoff2);
355
356             /* Update potential sum for this i atom from the interaction with this j atom. */
357             vvdw             = _fjsp_and_v2r8(vvdw,cutoff_mask);
358             vvdwsum          = _fjsp_add_v2r8(vvdwsum,vvdw);
359
360             fscal            = fvdw;
361
362             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
363
364             /* Update vectorial force */
365             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
366             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
367             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
368             
369             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
370             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
371             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
372
373             }
374
375             /**************************
376              * CALCULATE INTERACTIONS *
377              **************************/
378
379             if (gmx_fjsp_any_lt_v2r8(rsq11,rcutoff2))
380             {
381
382             r11              = _fjsp_mul_v2r8(rsq11,rinv11);
383
384             /* EWALD ELECTROSTATICS */
385
386             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
387             ewrt             = _fjsp_mul_v2r8(r11,ewtabscale);
388             itab_tmp         = _fjsp_dtox_v2r8(ewrt);
389             eweps            = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
390             _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
391
392             ewtabF           = _fjsp_load_v2r8( ewtab + 4*ewconv.i[0] );
393             ewtabD           = _fjsp_load_v2r8( ewtab + 4*ewconv.i[1] );
394             GMX_FJSP_TRANSPOSE2_V2R8(ewtabF,ewtabD);
395             ewtabV           = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[0] +2);
396             ewtabFn          = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[1] +2);
397             GMX_FJSP_TRANSPOSE2_V2R8(ewtabV,ewtabFn);
398             felec            = _fjsp_madd_v2r8(eweps,ewtabD,ewtabF);
399             velec            = _fjsp_nmsub_v2r8(_fjsp_mul_v2r8(ewtabhalfspace,eweps) ,_fjsp_add_v2r8(ewtabF,felec), ewtabV);
400             velec            = _fjsp_mul_v2r8(qq11,_fjsp_sub_v2r8(_fjsp_sub_v2r8(rinv11,sh_ewald),velec));
401             felec            = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq11,rinv11),_fjsp_sub_v2r8(rinvsq11,felec));
402
403             cutoff_mask      = _fjsp_cmplt_v2r8(rsq11,rcutoff2);
404
405             /* Update potential sum for this i atom from the interaction with this j atom. */
406             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
407             velecsum         = _fjsp_add_v2r8(velecsum,velec);
408
409             fscal            = felec;
410
411             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
412
413             /* Update vectorial force */
414             fix1             = _fjsp_madd_v2r8(dx11,fscal,fix1);
415             fiy1             = _fjsp_madd_v2r8(dy11,fscal,fiy1);
416             fiz1             = _fjsp_madd_v2r8(dz11,fscal,fiz1);
417             
418             fjx1             = _fjsp_madd_v2r8(dx11,fscal,fjx1);
419             fjy1             = _fjsp_madd_v2r8(dy11,fscal,fjy1);
420             fjz1             = _fjsp_madd_v2r8(dz11,fscal,fjz1);
421
422             }
423
424             /**************************
425              * CALCULATE INTERACTIONS *
426              **************************/
427
428             if (gmx_fjsp_any_lt_v2r8(rsq12,rcutoff2))
429             {
430
431             r12              = _fjsp_mul_v2r8(rsq12,rinv12);
432
433             /* EWALD ELECTROSTATICS */
434
435             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
436             ewrt             = _fjsp_mul_v2r8(r12,ewtabscale);
437             itab_tmp         = _fjsp_dtox_v2r8(ewrt);
438             eweps            = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
439             _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
440
441             ewtabF           = _fjsp_load_v2r8( ewtab + 4*ewconv.i[0] );
442             ewtabD           = _fjsp_load_v2r8( ewtab + 4*ewconv.i[1] );
443             GMX_FJSP_TRANSPOSE2_V2R8(ewtabF,ewtabD);
444             ewtabV           = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[0] +2);
445             ewtabFn          = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[1] +2);
446             GMX_FJSP_TRANSPOSE2_V2R8(ewtabV,ewtabFn);
447             felec            = _fjsp_madd_v2r8(eweps,ewtabD,ewtabF);
448             velec            = _fjsp_nmsub_v2r8(_fjsp_mul_v2r8(ewtabhalfspace,eweps) ,_fjsp_add_v2r8(ewtabF,felec), ewtabV);
449             velec            = _fjsp_mul_v2r8(qq12,_fjsp_sub_v2r8(_fjsp_sub_v2r8(rinv12,sh_ewald),velec));
450             felec            = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq12,rinv12),_fjsp_sub_v2r8(rinvsq12,felec));
451
452             cutoff_mask      = _fjsp_cmplt_v2r8(rsq12,rcutoff2);
453
454             /* Update potential sum for this i atom from the interaction with this j atom. */
455             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
456             velecsum         = _fjsp_add_v2r8(velecsum,velec);
457
458             fscal            = felec;
459
460             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
461
462             /* Update vectorial force */
463             fix1             = _fjsp_madd_v2r8(dx12,fscal,fix1);
464             fiy1             = _fjsp_madd_v2r8(dy12,fscal,fiy1);
465             fiz1             = _fjsp_madd_v2r8(dz12,fscal,fiz1);
466             
467             fjx2             = _fjsp_madd_v2r8(dx12,fscal,fjx2);
468             fjy2             = _fjsp_madd_v2r8(dy12,fscal,fjy2);
469             fjz2             = _fjsp_madd_v2r8(dz12,fscal,fjz2);
470
471             }
472
473             /**************************
474              * CALCULATE INTERACTIONS *
475              **************************/
476
477             if (gmx_fjsp_any_lt_v2r8(rsq13,rcutoff2))
478             {
479
480             r13              = _fjsp_mul_v2r8(rsq13,rinv13);
481
482             /* EWALD ELECTROSTATICS */
483
484             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
485             ewrt             = _fjsp_mul_v2r8(r13,ewtabscale);
486             itab_tmp         = _fjsp_dtox_v2r8(ewrt);
487             eweps            = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
488             _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
489
490             ewtabF           = _fjsp_load_v2r8( ewtab + 4*ewconv.i[0] );
491             ewtabD           = _fjsp_load_v2r8( ewtab + 4*ewconv.i[1] );
492             GMX_FJSP_TRANSPOSE2_V2R8(ewtabF,ewtabD);
493             ewtabV           = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[0] +2);
494             ewtabFn          = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[1] +2);
495             GMX_FJSP_TRANSPOSE2_V2R8(ewtabV,ewtabFn);
496             felec            = _fjsp_madd_v2r8(eweps,ewtabD,ewtabF);
497             velec            = _fjsp_nmsub_v2r8(_fjsp_mul_v2r8(ewtabhalfspace,eweps) ,_fjsp_add_v2r8(ewtabF,felec), ewtabV);
498             velec            = _fjsp_mul_v2r8(qq13,_fjsp_sub_v2r8(_fjsp_sub_v2r8(rinv13,sh_ewald),velec));
499             felec            = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq13,rinv13),_fjsp_sub_v2r8(rinvsq13,felec));
500
501             cutoff_mask      = _fjsp_cmplt_v2r8(rsq13,rcutoff2);
502
503             /* Update potential sum for this i atom from the interaction with this j atom. */
504             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
505             velecsum         = _fjsp_add_v2r8(velecsum,velec);
506
507             fscal            = felec;
508
509             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
510
511             /* Update vectorial force */
512             fix1             = _fjsp_madd_v2r8(dx13,fscal,fix1);
513             fiy1             = _fjsp_madd_v2r8(dy13,fscal,fiy1);
514             fiz1             = _fjsp_madd_v2r8(dz13,fscal,fiz1);
515             
516             fjx3             = _fjsp_madd_v2r8(dx13,fscal,fjx3);
517             fjy3             = _fjsp_madd_v2r8(dy13,fscal,fjy3);
518             fjz3             = _fjsp_madd_v2r8(dz13,fscal,fjz3);
519
520             }
521
522             /**************************
523              * CALCULATE INTERACTIONS *
524              **************************/
525
526             if (gmx_fjsp_any_lt_v2r8(rsq21,rcutoff2))
527             {
528
529             r21              = _fjsp_mul_v2r8(rsq21,rinv21);
530
531             /* EWALD ELECTROSTATICS */
532
533             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
534             ewrt             = _fjsp_mul_v2r8(r21,ewtabscale);
535             itab_tmp         = _fjsp_dtox_v2r8(ewrt);
536             eweps            = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
537             _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
538
539             ewtabF           = _fjsp_load_v2r8( ewtab + 4*ewconv.i[0] );
540             ewtabD           = _fjsp_load_v2r8( ewtab + 4*ewconv.i[1] );
541             GMX_FJSP_TRANSPOSE2_V2R8(ewtabF,ewtabD);
542             ewtabV           = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[0] +2);
543             ewtabFn          = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[1] +2);
544             GMX_FJSP_TRANSPOSE2_V2R8(ewtabV,ewtabFn);
545             felec            = _fjsp_madd_v2r8(eweps,ewtabD,ewtabF);
546             velec            = _fjsp_nmsub_v2r8(_fjsp_mul_v2r8(ewtabhalfspace,eweps) ,_fjsp_add_v2r8(ewtabF,felec), ewtabV);
547             velec            = _fjsp_mul_v2r8(qq21,_fjsp_sub_v2r8(_fjsp_sub_v2r8(rinv21,sh_ewald),velec));
548             felec            = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq21,rinv21),_fjsp_sub_v2r8(rinvsq21,felec));
549
550             cutoff_mask      = _fjsp_cmplt_v2r8(rsq21,rcutoff2);
551
552             /* Update potential sum for this i atom from the interaction with this j atom. */
553             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
554             velecsum         = _fjsp_add_v2r8(velecsum,velec);
555
556             fscal            = felec;
557
558             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
559
560             /* Update vectorial force */
561             fix2             = _fjsp_madd_v2r8(dx21,fscal,fix2);
562             fiy2             = _fjsp_madd_v2r8(dy21,fscal,fiy2);
563             fiz2             = _fjsp_madd_v2r8(dz21,fscal,fiz2);
564             
565             fjx1             = _fjsp_madd_v2r8(dx21,fscal,fjx1);
566             fjy1             = _fjsp_madd_v2r8(dy21,fscal,fjy1);
567             fjz1             = _fjsp_madd_v2r8(dz21,fscal,fjz1);
568
569             }
570
571             /**************************
572              * CALCULATE INTERACTIONS *
573              **************************/
574
575             if (gmx_fjsp_any_lt_v2r8(rsq22,rcutoff2))
576             {
577
578             r22              = _fjsp_mul_v2r8(rsq22,rinv22);
579
580             /* EWALD ELECTROSTATICS */
581
582             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
583             ewrt             = _fjsp_mul_v2r8(r22,ewtabscale);
584             itab_tmp         = _fjsp_dtox_v2r8(ewrt);
585             eweps            = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
586             _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
587
588             ewtabF           = _fjsp_load_v2r8( ewtab + 4*ewconv.i[0] );
589             ewtabD           = _fjsp_load_v2r8( ewtab + 4*ewconv.i[1] );
590             GMX_FJSP_TRANSPOSE2_V2R8(ewtabF,ewtabD);
591             ewtabV           = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[0] +2);
592             ewtabFn          = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[1] +2);
593             GMX_FJSP_TRANSPOSE2_V2R8(ewtabV,ewtabFn);
594             felec            = _fjsp_madd_v2r8(eweps,ewtabD,ewtabF);
595             velec            = _fjsp_nmsub_v2r8(_fjsp_mul_v2r8(ewtabhalfspace,eweps) ,_fjsp_add_v2r8(ewtabF,felec), ewtabV);
596             velec            = _fjsp_mul_v2r8(qq22,_fjsp_sub_v2r8(_fjsp_sub_v2r8(rinv22,sh_ewald),velec));
597             felec            = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq22,rinv22),_fjsp_sub_v2r8(rinvsq22,felec));
598
599             cutoff_mask      = _fjsp_cmplt_v2r8(rsq22,rcutoff2);
600
601             /* Update potential sum for this i atom from the interaction with this j atom. */
602             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
603             velecsum         = _fjsp_add_v2r8(velecsum,velec);
604
605             fscal            = felec;
606
607             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
608
609             /* Update vectorial force */
610             fix2             = _fjsp_madd_v2r8(dx22,fscal,fix2);
611             fiy2             = _fjsp_madd_v2r8(dy22,fscal,fiy2);
612             fiz2             = _fjsp_madd_v2r8(dz22,fscal,fiz2);
613             
614             fjx2             = _fjsp_madd_v2r8(dx22,fscal,fjx2);
615             fjy2             = _fjsp_madd_v2r8(dy22,fscal,fjy2);
616             fjz2             = _fjsp_madd_v2r8(dz22,fscal,fjz2);
617
618             }
619
620             /**************************
621              * CALCULATE INTERACTIONS *
622              **************************/
623
624             if (gmx_fjsp_any_lt_v2r8(rsq23,rcutoff2))
625             {
626
627             r23              = _fjsp_mul_v2r8(rsq23,rinv23);
628
629             /* EWALD ELECTROSTATICS */
630
631             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
632             ewrt             = _fjsp_mul_v2r8(r23,ewtabscale);
633             itab_tmp         = _fjsp_dtox_v2r8(ewrt);
634             eweps            = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
635             _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
636
637             ewtabF           = _fjsp_load_v2r8( ewtab + 4*ewconv.i[0] );
638             ewtabD           = _fjsp_load_v2r8( ewtab + 4*ewconv.i[1] );
639             GMX_FJSP_TRANSPOSE2_V2R8(ewtabF,ewtabD);
640             ewtabV           = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[0] +2);
641             ewtabFn          = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[1] +2);
642             GMX_FJSP_TRANSPOSE2_V2R8(ewtabV,ewtabFn);
643             felec            = _fjsp_madd_v2r8(eweps,ewtabD,ewtabF);
644             velec            = _fjsp_nmsub_v2r8(_fjsp_mul_v2r8(ewtabhalfspace,eweps) ,_fjsp_add_v2r8(ewtabF,felec), ewtabV);
645             velec            = _fjsp_mul_v2r8(qq23,_fjsp_sub_v2r8(_fjsp_sub_v2r8(rinv23,sh_ewald),velec));
646             felec            = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq23,rinv23),_fjsp_sub_v2r8(rinvsq23,felec));
647
648             cutoff_mask      = _fjsp_cmplt_v2r8(rsq23,rcutoff2);
649
650             /* Update potential sum for this i atom from the interaction with this j atom. */
651             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
652             velecsum         = _fjsp_add_v2r8(velecsum,velec);
653
654             fscal            = felec;
655
656             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
657
658             /* Update vectorial force */
659             fix2             = _fjsp_madd_v2r8(dx23,fscal,fix2);
660             fiy2             = _fjsp_madd_v2r8(dy23,fscal,fiy2);
661             fiz2             = _fjsp_madd_v2r8(dz23,fscal,fiz2);
662             
663             fjx3             = _fjsp_madd_v2r8(dx23,fscal,fjx3);
664             fjy3             = _fjsp_madd_v2r8(dy23,fscal,fjy3);
665             fjz3             = _fjsp_madd_v2r8(dz23,fscal,fjz3);
666
667             }
668
669             /**************************
670              * CALCULATE INTERACTIONS *
671              **************************/
672
673             if (gmx_fjsp_any_lt_v2r8(rsq31,rcutoff2))
674             {
675
676             r31              = _fjsp_mul_v2r8(rsq31,rinv31);
677
678             /* EWALD ELECTROSTATICS */
679
680             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
681             ewrt             = _fjsp_mul_v2r8(r31,ewtabscale);
682             itab_tmp         = _fjsp_dtox_v2r8(ewrt);
683             eweps            = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
684             _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
685
686             ewtabF           = _fjsp_load_v2r8( ewtab + 4*ewconv.i[0] );
687             ewtabD           = _fjsp_load_v2r8( ewtab + 4*ewconv.i[1] );
688             GMX_FJSP_TRANSPOSE2_V2R8(ewtabF,ewtabD);
689             ewtabV           = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[0] +2);
690             ewtabFn          = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[1] +2);
691             GMX_FJSP_TRANSPOSE2_V2R8(ewtabV,ewtabFn);
692             felec            = _fjsp_madd_v2r8(eweps,ewtabD,ewtabF);
693             velec            = _fjsp_nmsub_v2r8(_fjsp_mul_v2r8(ewtabhalfspace,eweps) ,_fjsp_add_v2r8(ewtabF,felec), ewtabV);
694             velec            = _fjsp_mul_v2r8(qq31,_fjsp_sub_v2r8(_fjsp_sub_v2r8(rinv31,sh_ewald),velec));
695             felec            = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq31,rinv31),_fjsp_sub_v2r8(rinvsq31,felec));
696
697             cutoff_mask      = _fjsp_cmplt_v2r8(rsq31,rcutoff2);
698
699             /* Update potential sum for this i atom from the interaction with this j atom. */
700             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
701             velecsum         = _fjsp_add_v2r8(velecsum,velec);
702
703             fscal            = felec;
704
705             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
706
707             /* Update vectorial force */
708             fix3             = _fjsp_madd_v2r8(dx31,fscal,fix3);
709             fiy3             = _fjsp_madd_v2r8(dy31,fscal,fiy3);
710             fiz3             = _fjsp_madd_v2r8(dz31,fscal,fiz3);
711             
712             fjx1             = _fjsp_madd_v2r8(dx31,fscal,fjx1);
713             fjy1             = _fjsp_madd_v2r8(dy31,fscal,fjy1);
714             fjz1             = _fjsp_madd_v2r8(dz31,fscal,fjz1);
715
716             }
717
718             /**************************
719              * CALCULATE INTERACTIONS *
720              **************************/
721
722             if (gmx_fjsp_any_lt_v2r8(rsq32,rcutoff2))
723             {
724
725             r32              = _fjsp_mul_v2r8(rsq32,rinv32);
726
727             /* EWALD ELECTROSTATICS */
728
729             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
730             ewrt             = _fjsp_mul_v2r8(r32,ewtabscale);
731             itab_tmp         = _fjsp_dtox_v2r8(ewrt);
732             eweps            = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
733             _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
734
735             ewtabF           = _fjsp_load_v2r8( ewtab + 4*ewconv.i[0] );
736             ewtabD           = _fjsp_load_v2r8( ewtab + 4*ewconv.i[1] );
737             GMX_FJSP_TRANSPOSE2_V2R8(ewtabF,ewtabD);
738             ewtabV           = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[0] +2);
739             ewtabFn          = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[1] +2);
740             GMX_FJSP_TRANSPOSE2_V2R8(ewtabV,ewtabFn);
741             felec            = _fjsp_madd_v2r8(eweps,ewtabD,ewtabF);
742             velec            = _fjsp_nmsub_v2r8(_fjsp_mul_v2r8(ewtabhalfspace,eweps) ,_fjsp_add_v2r8(ewtabF,felec), ewtabV);
743             velec            = _fjsp_mul_v2r8(qq32,_fjsp_sub_v2r8(_fjsp_sub_v2r8(rinv32,sh_ewald),velec));
744             felec            = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq32,rinv32),_fjsp_sub_v2r8(rinvsq32,felec));
745
746             cutoff_mask      = _fjsp_cmplt_v2r8(rsq32,rcutoff2);
747
748             /* Update potential sum for this i atom from the interaction with this j atom. */
749             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
750             velecsum         = _fjsp_add_v2r8(velecsum,velec);
751
752             fscal            = felec;
753
754             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
755
756             /* Update vectorial force */
757             fix3             = _fjsp_madd_v2r8(dx32,fscal,fix3);
758             fiy3             = _fjsp_madd_v2r8(dy32,fscal,fiy3);
759             fiz3             = _fjsp_madd_v2r8(dz32,fscal,fiz3);
760             
761             fjx2             = _fjsp_madd_v2r8(dx32,fscal,fjx2);
762             fjy2             = _fjsp_madd_v2r8(dy32,fscal,fjy2);
763             fjz2             = _fjsp_madd_v2r8(dz32,fscal,fjz2);
764
765             }
766
767             /**************************
768              * CALCULATE INTERACTIONS *
769              **************************/
770
771             if (gmx_fjsp_any_lt_v2r8(rsq33,rcutoff2))
772             {
773
774             r33              = _fjsp_mul_v2r8(rsq33,rinv33);
775
776             /* EWALD ELECTROSTATICS */
777
778             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
779             ewrt             = _fjsp_mul_v2r8(r33,ewtabscale);
780             itab_tmp         = _fjsp_dtox_v2r8(ewrt);
781             eweps            = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
782             _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
783
784             ewtabF           = _fjsp_load_v2r8( ewtab + 4*ewconv.i[0] );
785             ewtabD           = _fjsp_load_v2r8( ewtab + 4*ewconv.i[1] );
786             GMX_FJSP_TRANSPOSE2_V2R8(ewtabF,ewtabD);
787             ewtabV           = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[0] +2);
788             ewtabFn          = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[1] +2);
789             GMX_FJSP_TRANSPOSE2_V2R8(ewtabV,ewtabFn);
790             felec            = _fjsp_madd_v2r8(eweps,ewtabD,ewtabF);
791             velec            = _fjsp_nmsub_v2r8(_fjsp_mul_v2r8(ewtabhalfspace,eweps) ,_fjsp_add_v2r8(ewtabF,felec), ewtabV);
792             velec            = _fjsp_mul_v2r8(qq33,_fjsp_sub_v2r8(_fjsp_sub_v2r8(rinv33,sh_ewald),velec));
793             felec            = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq33,rinv33),_fjsp_sub_v2r8(rinvsq33,felec));
794
795             cutoff_mask      = _fjsp_cmplt_v2r8(rsq33,rcutoff2);
796
797             /* Update potential sum for this i atom from the interaction with this j atom. */
798             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
799             velecsum         = _fjsp_add_v2r8(velecsum,velec);
800
801             fscal            = felec;
802
803             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
804
805             /* Update vectorial force */
806             fix3             = _fjsp_madd_v2r8(dx33,fscal,fix3);
807             fiy3             = _fjsp_madd_v2r8(dy33,fscal,fiy3);
808             fiz3             = _fjsp_madd_v2r8(dz33,fscal,fiz3);
809             
810             fjx3             = _fjsp_madd_v2r8(dx33,fscal,fjx3);
811             fjy3             = _fjsp_madd_v2r8(dy33,fscal,fjy3);
812             fjz3             = _fjsp_madd_v2r8(dz33,fscal,fjz3);
813
814             }
815
816             gmx_fjsp_decrement_4rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
817
818             /* Inner loop uses 503 flops */
819         }
820
821         if(jidx<j_index_end)
822         {
823
824             jnrA             = jjnr[jidx];
825             j_coord_offsetA  = DIM*jnrA;
826
827             /* load j atom coordinates */
828             gmx_fjsp_load_4rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
829                                               &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,
830                                               &jy2,&jz2,&jx3,&jy3,&jz3);
831
832             /* Calculate displacement vector */
833             dx00             = _fjsp_sub_v2r8(ix0,jx0);
834             dy00             = _fjsp_sub_v2r8(iy0,jy0);
835             dz00             = _fjsp_sub_v2r8(iz0,jz0);
836             dx11             = _fjsp_sub_v2r8(ix1,jx1);
837             dy11             = _fjsp_sub_v2r8(iy1,jy1);
838             dz11             = _fjsp_sub_v2r8(iz1,jz1);
839             dx12             = _fjsp_sub_v2r8(ix1,jx2);
840             dy12             = _fjsp_sub_v2r8(iy1,jy2);
841             dz12             = _fjsp_sub_v2r8(iz1,jz2);
842             dx13             = _fjsp_sub_v2r8(ix1,jx3);
843             dy13             = _fjsp_sub_v2r8(iy1,jy3);
844             dz13             = _fjsp_sub_v2r8(iz1,jz3);
845             dx21             = _fjsp_sub_v2r8(ix2,jx1);
846             dy21             = _fjsp_sub_v2r8(iy2,jy1);
847             dz21             = _fjsp_sub_v2r8(iz2,jz1);
848             dx22             = _fjsp_sub_v2r8(ix2,jx2);
849             dy22             = _fjsp_sub_v2r8(iy2,jy2);
850             dz22             = _fjsp_sub_v2r8(iz2,jz2);
851             dx23             = _fjsp_sub_v2r8(ix2,jx3);
852             dy23             = _fjsp_sub_v2r8(iy2,jy3);
853             dz23             = _fjsp_sub_v2r8(iz2,jz3);
854             dx31             = _fjsp_sub_v2r8(ix3,jx1);
855             dy31             = _fjsp_sub_v2r8(iy3,jy1);
856             dz31             = _fjsp_sub_v2r8(iz3,jz1);
857             dx32             = _fjsp_sub_v2r8(ix3,jx2);
858             dy32             = _fjsp_sub_v2r8(iy3,jy2);
859             dz32             = _fjsp_sub_v2r8(iz3,jz2);
860             dx33             = _fjsp_sub_v2r8(ix3,jx3);
861             dy33             = _fjsp_sub_v2r8(iy3,jy3);
862             dz33             = _fjsp_sub_v2r8(iz3,jz3);
863
864             /* Calculate squared distance and things based on it */
865             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
866             rsq11            = gmx_fjsp_calc_rsq_v2r8(dx11,dy11,dz11);
867             rsq12            = gmx_fjsp_calc_rsq_v2r8(dx12,dy12,dz12);
868             rsq13            = gmx_fjsp_calc_rsq_v2r8(dx13,dy13,dz13);
869             rsq21            = gmx_fjsp_calc_rsq_v2r8(dx21,dy21,dz21);
870             rsq22            = gmx_fjsp_calc_rsq_v2r8(dx22,dy22,dz22);
871             rsq23            = gmx_fjsp_calc_rsq_v2r8(dx23,dy23,dz23);
872             rsq31            = gmx_fjsp_calc_rsq_v2r8(dx31,dy31,dz31);
873             rsq32            = gmx_fjsp_calc_rsq_v2r8(dx32,dy32,dz32);
874             rsq33            = gmx_fjsp_calc_rsq_v2r8(dx33,dy33,dz33);
875
876             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
877             rinv11           = gmx_fjsp_invsqrt_v2r8(rsq11);
878             rinv12           = gmx_fjsp_invsqrt_v2r8(rsq12);
879             rinv13           = gmx_fjsp_invsqrt_v2r8(rsq13);
880             rinv21           = gmx_fjsp_invsqrt_v2r8(rsq21);
881             rinv22           = gmx_fjsp_invsqrt_v2r8(rsq22);
882             rinv23           = gmx_fjsp_invsqrt_v2r8(rsq23);
883             rinv31           = gmx_fjsp_invsqrt_v2r8(rsq31);
884             rinv32           = gmx_fjsp_invsqrt_v2r8(rsq32);
885             rinv33           = gmx_fjsp_invsqrt_v2r8(rsq33);
886
887             rinvsq00         = _fjsp_mul_v2r8(rinv00,rinv00);
888             rinvsq11         = _fjsp_mul_v2r8(rinv11,rinv11);
889             rinvsq12         = _fjsp_mul_v2r8(rinv12,rinv12);
890             rinvsq13         = _fjsp_mul_v2r8(rinv13,rinv13);
891             rinvsq21         = _fjsp_mul_v2r8(rinv21,rinv21);
892             rinvsq22         = _fjsp_mul_v2r8(rinv22,rinv22);
893             rinvsq23         = _fjsp_mul_v2r8(rinv23,rinv23);
894             rinvsq31         = _fjsp_mul_v2r8(rinv31,rinv31);
895             rinvsq32         = _fjsp_mul_v2r8(rinv32,rinv32);
896             rinvsq33         = _fjsp_mul_v2r8(rinv33,rinv33);
897
898             fjx0             = _fjsp_setzero_v2r8();
899             fjy0             = _fjsp_setzero_v2r8();
900             fjz0             = _fjsp_setzero_v2r8();
901             fjx1             = _fjsp_setzero_v2r8();
902             fjy1             = _fjsp_setzero_v2r8();
903             fjz1             = _fjsp_setzero_v2r8();
904             fjx2             = _fjsp_setzero_v2r8();
905             fjy2             = _fjsp_setzero_v2r8();
906             fjz2             = _fjsp_setzero_v2r8();
907             fjx3             = _fjsp_setzero_v2r8();
908             fjy3             = _fjsp_setzero_v2r8();
909             fjz3             = _fjsp_setzero_v2r8();
910
911             /**************************
912              * CALCULATE INTERACTIONS *
913              **************************/
914
915             if (gmx_fjsp_any_lt_v2r8(rsq00,rcutoff2))
916             {
917
918             r00              = _fjsp_mul_v2r8(rsq00,rinv00);
919
920             /* Analytical LJ-PME */
921             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
922             ewcljrsq         = _fjsp_mul_v2r8(ewclj2,rsq00);
923             ewclj6           = _fjsp_mul_v2r8(ewclj2,_fjsp_mul_v2r8(ewclj2,ewclj2));
924             exponent         = gmx_simd_exp_d(-ewcljrsq);
925             /* poly = exp(-(beta*r)^2) * (1 + (beta*r)^2 + (beta*r)^4 /2) */
926             poly             = _fjsp_mul_v2r8(exponent,_fjsp_madd_v2r8(_fjsp_mul_v2r8(ewcljrsq,ewcljrsq),one_half,_fjsp_sub_v2r8(one,ewcljrsq)));
927             /* vvdw6 = [C6 - C6grid * (1-poly)]/r6 */
928             vvdw6            = _fjsp_mul_v2r8(_fjsp_madd_v2r8(-c6grid_00,_fjsp_sub_v2r8(one,poly),c6_00),rinvsix);
929             vvdw12           = _fjsp_mul_v2r8(c12_00,_fjsp_mul_v2r8(rinvsix,rinvsix));
930             vvdw             = _fjsp_msub_v2r8(_fjsp_nmsub_v2r8(c12_00,_fjsp_mul_v2r8(sh_vdw_invrcut6,sh_vdw_invrcut6),vvdw12),one_twelfth,
931                                _fjsp_mul_v2r8(_fjsp_sub_v2r8(vvdw6,_fjsp_madd_v2r8(c6grid_00,sh_lj_ewald,_fjsp_mul_v2r8(c6_00,sh_vdw_invrcut6))),one_sixth));
932             /* fvdw = vvdw12/r - (vvdw6/r + (C6grid * exponent * beta^6)/r) */
933             fvdw             = _fjsp_mul_v2r8(_fjsp_add_v2r8(vvdw12,_fjsp_msub_v2r8(_fjsp_mul_v2r8(c6grid_00,one_sixth),_fjsp_mul_v2r8(exponent,ewclj6),vvdw6)),rinvsq00);
934
935             cutoff_mask      = _fjsp_cmplt_v2r8(rsq00,rcutoff2);
936
937             /* Update potential sum for this i atom from the interaction with this j atom. */
938             vvdw             = _fjsp_and_v2r8(vvdw,cutoff_mask);
939             vvdw             = _fjsp_unpacklo_v2r8(vvdw,_fjsp_setzero_v2r8());
940             vvdwsum          = _fjsp_add_v2r8(vvdwsum,vvdw);
941
942             fscal            = fvdw;
943
944             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
945
946             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
947
948             /* Update vectorial force */
949             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
950             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
951             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
952             
953             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
954             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
955             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
956
957             }
958
959             /**************************
960              * CALCULATE INTERACTIONS *
961              **************************/
962
963             if (gmx_fjsp_any_lt_v2r8(rsq11,rcutoff2))
964             {
965
966             r11              = _fjsp_mul_v2r8(rsq11,rinv11);
967
968             /* EWALD ELECTROSTATICS */
969
970             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
971             ewrt             = _fjsp_mul_v2r8(r11,ewtabscale);
972             itab_tmp         = _fjsp_dtox_v2r8(ewrt);
973             eweps            = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
974             _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
975
976             ewtabF           = _fjsp_load_v2r8( ewtab + 4*ewconv.i[0] );
977             ewtabD           = _fjsp_setzero_v2r8();
978             GMX_FJSP_TRANSPOSE2_V2R8(ewtabF,ewtabD);
979             ewtabV           = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[0] +2);
980             ewtabFn          = _fjsp_setzero_v2r8();
981             GMX_FJSP_TRANSPOSE2_V2R8(ewtabV,ewtabFn);
982             felec            = _fjsp_madd_v2r8(eweps,ewtabD,ewtabF);
983             velec            = _fjsp_nmsub_v2r8(_fjsp_mul_v2r8(ewtabhalfspace,eweps) ,_fjsp_add_v2r8(ewtabF,felec), ewtabV);
984             velec            = _fjsp_mul_v2r8(qq11,_fjsp_sub_v2r8(_fjsp_sub_v2r8(rinv11,sh_ewald),velec));
985             felec            = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq11,rinv11),_fjsp_sub_v2r8(rinvsq11,felec));
986
987             cutoff_mask      = _fjsp_cmplt_v2r8(rsq11,rcutoff2);
988
989             /* Update potential sum for this i atom from the interaction with this j atom. */
990             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
991             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
992             velecsum         = _fjsp_add_v2r8(velecsum,velec);
993
994             fscal            = felec;
995
996             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
997
998             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
999
1000             /* Update vectorial force */
1001             fix1             = _fjsp_madd_v2r8(dx11,fscal,fix1);
1002             fiy1             = _fjsp_madd_v2r8(dy11,fscal,fiy1);
1003             fiz1             = _fjsp_madd_v2r8(dz11,fscal,fiz1);
1004             
1005             fjx1             = _fjsp_madd_v2r8(dx11,fscal,fjx1);
1006             fjy1             = _fjsp_madd_v2r8(dy11,fscal,fjy1);
1007             fjz1             = _fjsp_madd_v2r8(dz11,fscal,fjz1);
1008
1009             }
1010
1011             /**************************
1012              * CALCULATE INTERACTIONS *
1013              **************************/
1014
1015             if (gmx_fjsp_any_lt_v2r8(rsq12,rcutoff2))
1016             {
1017
1018             r12              = _fjsp_mul_v2r8(rsq12,rinv12);
1019
1020             /* EWALD ELECTROSTATICS */
1021
1022             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1023             ewrt             = _fjsp_mul_v2r8(r12,ewtabscale);
1024             itab_tmp         = _fjsp_dtox_v2r8(ewrt);
1025             eweps            = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
1026             _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
1027
1028             ewtabF           = _fjsp_load_v2r8( ewtab + 4*ewconv.i[0] );
1029             ewtabD           = _fjsp_setzero_v2r8();
1030             GMX_FJSP_TRANSPOSE2_V2R8(ewtabF,ewtabD);
1031             ewtabV           = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[0] +2);
1032             ewtabFn          = _fjsp_setzero_v2r8();
1033             GMX_FJSP_TRANSPOSE2_V2R8(ewtabV,ewtabFn);
1034             felec            = _fjsp_madd_v2r8(eweps,ewtabD,ewtabF);
1035             velec            = _fjsp_nmsub_v2r8(_fjsp_mul_v2r8(ewtabhalfspace,eweps) ,_fjsp_add_v2r8(ewtabF,felec), ewtabV);
1036             velec            = _fjsp_mul_v2r8(qq12,_fjsp_sub_v2r8(_fjsp_sub_v2r8(rinv12,sh_ewald),velec));
1037             felec            = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq12,rinv12),_fjsp_sub_v2r8(rinvsq12,felec));
1038
1039             cutoff_mask      = _fjsp_cmplt_v2r8(rsq12,rcutoff2);
1040
1041             /* Update potential sum for this i atom from the interaction with this j atom. */
1042             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
1043             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
1044             velecsum         = _fjsp_add_v2r8(velecsum,velec);
1045
1046             fscal            = felec;
1047
1048             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1049
1050             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1051
1052             /* Update vectorial force */
1053             fix1             = _fjsp_madd_v2r8(dx12,fscal,fix1);
1054             fiy1             = _fjsp_madd_v2r8(dy12,fscal,fiy1);
1055             fiz1             = _fjsp_madd_v2r8(dz12,fscal,fiz1);
1056             
1057             fjx2             = _fjsp_madd_v2r8(dx12,fscal,fjx2);
1058             fjy2             = _fjsp_madd_v2r8(dy12,fscal,fjy2);
1059             fjz2             = _fjsp_madd_v2r8(dz12,fscal,fjz2);
1060
1061             }
1062
1063             /**************************
1064              * CALCULATE INTERACTIONS *
1065              **************************/
1066
1067             if (gmx_fjsp_any_lt_v2r8(rsq13,rcutoff2))
1068             {
1069
1070             r13              = _fjsp_mul_v2r8(rsq13,rinv13);
1071
1072             /* EWALD ELECTROSTATICS */
1073
1074             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1075             ewrt             = _fjsp_mul_v2r8(r13,ewtabscale);
1076             itab_tmp         = _fjsp_dtox_v2r8(ewrt);
1077             eweps            = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
1078             _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
1079
1080             ewtabF           = _fjsp_load_v2r8( ewtab + 4*ewconv.i[0] );
1081             ewtabD           = _fjsp_setzero_v2r8();
1082             GMX_FJSP_TRANSPOSE2_V2R8(ewtabF,ewtabD);
1083             ewtabV           = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[0] +2);
1084             ewtabFn          = _fjsp_setzero_v2r8();
1085             GMX_FJSP_TRANSPOSE2_V2R8(ewtabV,ewtabFn);
1086             felec            = _fjsp_madd_v2r8(eweps,ewtabD,ewtabF);
1087             velec            = _fjsp_nmsub_v2r8(_fjsp_mul_v2r8(ewtabhalfspace,eweps) ,_fjsp_add_v2r8(ewtabF,felec), ewtabV);
1088             velec            = _fjsp_mul_v2r8(qq13,_fjsp_sub_v2r8(_fjsp_sub_v2r8(rinv13,sh_ewald),velec));
1089             felec            = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq13,rinv13),_fjsp_sub_v2r8(rinvsq13,felec));
1090
1091             cutoff_mask      = _fjsp_cmplt_v2r8(rsq13,rcutoff2);
1092
1093             /* Update potential sum for this i atom from the interaction with this j atom. */
1094             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
1095             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
1096             velecsum         = _fjsp_add_v2r8(velecsum,velec);
1097
1098             fscal            = felec;
1099
1100             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1101
1102             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1103
1104             /* Update vectorial force */
1105             fix1             = _fjsp_madd_v2r8(dx13,fscal,fix1);
1106             fiy1             = _fjsp_madd_v2r8(dy13,fscal,fiy1);
1107             fiz1             = _fjsp_madd_v2r8(dz13,fscal,fiz1);
1108             
1109             fjx3             = _fjsp_madd_v2r8(dx13,fscal,fjx3);
1110             fjy3             = _fjsp_madd_v2r8(dy13,fscal,fjy3);
1111             fjz3             = _fjsp_madd_v2r8(dz13,fscal,fjz3);
1112
1113             }
1114
1115             /**************************
1116              * CALCULATE INTERACTIONS *
1117              **************************/
1118
1119             if (gmx_fjsp_any_lt_v2r8(rsq21,rcutoff2))
1120             {
1121
1122             r21              = _fjsp_mul_v2r8(rsq21,rinv21);
1123
1124             /* EWALD ELECTROSTATICS */
1125
1126             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1127             ewrt             = _fjsp_mul_v2r8(r21,ewtabscale);
1128             itab_tmp         = _fjsp_dtox_v2r8(ewrt);
1129             eweps            = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
1130             _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
1131
1132             ewtabF           = _fjsp_load_v2r8( ewtab + 4*ewconv.i[0] );
1133             ewtabD           = _fjsp_setzero_v2r8();
1134             GMX_FJSP_TRANSPOSE2_V2R8(ewtabF,ewtabD);
1135             ewtabV           = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[0] +2);
1136             ewtabFn          = _fjsp_setzero_v2r8();
1137             GMX_FJSP_TRANSPOSE2_V2R8(ewtabV,ewtabFn);
1138             felec            = _fjsp_madd_v2r8(eweps,ewtabD,ewtabF);
1139             velec            = _fjsp_nmsub_v2r8(_fjsp_mul_v2r8(ewtabhalfspace,eweps) ,_fjsp_add_v2r8(ewtabF,felec), ewtabV);
1140             velec            = _fjsp_mul_v2r8(qq21,_fjsp_sub_v2r8(_fjsp_sub_v2r8(rinv21,sh_ewald),velec));
1141             felec            = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq21,rinv21),_fjsp_sub_v2r8(rinvsq21,felec));
1142
1143             cutoff_mask      = _fjsp_cmplt_v2r8(rsq21,rcutoff2);
1144
1145             /* Update potential sum for this i atom from the interaction with this j atom. */
1146             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
1147             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
1148             velecsum         = _fjsp_add_v2r8(velecsum,velec);
1149
1150             fscal            = felec;
1151
1152             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1153
1154             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1155
1156             /* Update vectorial force */
1157             fix2             = _fjsp_madd_v2r8(dx21,fscal,fix2);
1158             fiy2             = _fjsp_madd_v2r8(dy21,fscal,fiy2);
1159             fiz2             = _fjsp_madd_v2r8(dz21,fscal,fiz2);
1160             
1161             fjx1             = _fjsp_madd_v2r8(dx21,fscal,fjx1);
1162             fjy1             = _fjsp_madd_v2r8(dy21,fscal,fjy1);
1163             fjz1             = _fjsp_madd_v2r8(dz21,fscal,fjz1);
1164
1165             }
1166
1167             /**************************
1168              * CALCULATE INTERACTIONS *
1169              **************************/
1170
1171             if (gmx_fjsp_any_lt_v2r8(rsq22,rcutoff2))
1172             {
1173
1174             r22              = _fjsp_mul_v2r8(rsq22,rinv22);
1175
1176             /* EWALD ELECTROSTATICS */
1177
1178             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1179             ewrt             = _fjsp_mul_v2r8(r22,ewtabscale);
1180             itab_tmp         = _fjsp_dtox_v2r8(ewrt);
1181             eweps            = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
1182             _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
1183
1184             ewtabF           = _fjsp_load_v2r8( ewtab + 4*ewconv.i[0] );
1185             ewtabD           = _fjsp_setzero_v2r8();
1186             GMX_FJSP_TRANSPOSE2_V2R8(ewtabF,ewtabD);
1187             ewtabV           = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[0] +2);
1188             ewtabFn          = _fjsp_setzero_v2r8();
1189             GMX_FJSP_TRANSPOSE2_V2R8(ewtabV,ewtabFn);
1190             felec            = _fjsp_madd_v2r8(eweps,ewtabD,ewtabF);
1191             velec            = _fjsp_nmsub_v2r8(_fjsp_mul_v2r8(ewtabhalfspace,eweps) ,_fjsp_add_v2r8(ewtabF,felec), ewtabV);
1192             velec            = _fjsp_mul_v2r8(qq22,_fjsp_sub_v2r8(_fjsp_sub_v2r8(rinv22,sh_ewald),velec));
1193             felec            = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq22,rinv22),_fjsp_sub_v2r8(rinvsq22,felec));
1194
1195             cutoff_mask      = _fjsp_cmplt_v2r8(rsq22,rcutoff2);
1196
1197             /* Update potential sum for this i atom from the interaction with this j atom. */
1198             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
1199             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
1200             velecsum         = _fjsp_add_v2r8(velecsum,velec);
1201
1202             fscal            = felec;
1203
1204             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1205
1206             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1207
1208             /* Update vectorial force */
1209             fix2             = _fjsp_madd_v2r8(dx22,fscal,fix2);
1210             fiy2             = _fjsp_madd_v2r8(dy22,fscal,fiy2);
1211             fiz2             = _fjsp_madd_v2r8(dz22,fscal,fiz2);
1212             
1213             fjx2             = _fjsp_madd_v2r8(dx22,fscal,fjx2);
1214             fjy2             = _fjsp_madd_v2r8(dy22,fscal,fjy2);
1215             fjz2             = _fjsp_madd_v2r8(dz22,fscal,fjz2);
1216
1217             }
1218
1219             /**************************
1220              * CALCULATE INTERACTIONS *
1221              **************************/
1222
1223             if (gmx_fjsp_any_lt_v2r8(rsq23,rcutoff2))
1224             {
1225
1226             r23              = _fjsp_mul_v2r8(rsq23,rinv23);
1227
1228             /* EWALD ELECTROSTATICS */
1229
1230             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1231             ewrt             = _fjsp_mul_v2r8(r23,ewtabscale);
1232             itab_tmp         = _fjsp_dtox_v2r8(ewrt);
1233             eweps            = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
1234             _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
1235
1236             ewtabF           = _fjsp_load_v2r8( ewtab + 4*ewconv.i[0] );
1237             ewtabD           = _fjsp_setzero_v2r8();
1238             GMX_FJSP_TRANSPOSE2_V2R8(ewtabF,ewtabD);
1239             ewtabV           = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[0] +2);
1240             ewtabFn          = _fjsp_setzero_v2r8();
1241             GMX_FJSP_TRANSPOSE2_V2R8(ewtabV,ewtabFn);
1242             felec            = _fjsp_madd_v2r8(eweps,ewtabD,ewtabF);
1243             velec            = _fjsp_nmsub_v2r8(_fjsp_mul_v2r8(ewtabhalfspace,eweps) ,_fjsp_add_v2r8(ewtabF,felec), ewtabV);
1244             velec            = _fjsp_mul_v2r8(qq23,_fjsp_sub_v2r8(_fjsp_sub_v2r8(rinv23,sh_ewald),velec));
1245             felec            = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq23,rinv23),_fjsp_sub_v2r8(rinvsq23,felec));
1246
1247             cutoff_mask      = _fjsp_cmplt_v2r8(rsq23,rcutoff2);
1248
1249             /* Update potential sum for this i atom from the interaction with this j atom. */
1250             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
1251             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
1252             velecsum         = _fjsp_add_v2r8(velecsum,velec);
1253
1254             fscal            = felec;
1255
1256             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1257
1258             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1259
1260             /* Update vectorial force */
1261             fix2             = _fjsp_madd_v2r8(dx23,fscal,fix2);
1262             fiy2             = _fjsp_madd_v2r8(dy23,fscal,fiy2);
1263             fiz2             = _fjsp_madd_v2r8(dz23,fscal,fiz2);
1264             
1265             fjx3             = _fjsp_madd_v2r8(dx23,fscal,fjx3);
1266             fjy3             = _fjsp_madd_v2r8(dy23,fscal,fjy3);
1267             fjz3             = _fjsp_madd_v2r8(dz23,fscal,fjz3);
1268
1269             }
1270
1271             /**************************
1272              * CALCULATE INTERACTIONS *
1273              **************************/
1274
1275             if (gmx_fjsp_any_lt_v2r8(rsq31,rcutoff2))
1276             {
1277
1278             r31              = _fjsp_mul_v2r8(rsq31,rinv31);
1279
1280             /* EWALD ELECTROSTATICS */
1281
1282             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1283             ewrt             = _fjsp_mul_v2r8(r31,ewtabscale);
1284             itab_tmp         = _fjsp_dtox_v2r8(ewrt);
1285             eweps            = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
1286             _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
1287
1288             ewtabF           = _fjsp_load_v2r8( ewtab + 4*ewconv.i[0] );
1289             ewtabD           = _fjsp_setzero_v2r8();
1290             GMX_FJSP_TRANSPOSE2_V2R8(ewtabF,ewtabD);
1291             ewtabV           = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[0] +2);
1292             ewtabFn          = _fjsp_setzero_v2r8();
1293             GMX_FJSP_TRANSPOSE2_V2R8(ewtabV,ewtabFn);
1294             felec            = _fjsp_madd_v2r8(eweps,ewtabD,ewtabF);
1295             velec            = _fjsp_nmsub_v2r8(_fjsp_mul_v2r8(ewtabhalfspace,eweps) ,_fjsp_add_v2r8(ewtabF,felec), ewtabV);
1296             velec            = _fjsp_mul_v2r8(qq31,_fjsp_sub_v2r8(_fjsp_sub_v2r8(rinv31,sh_ewald),velec));
1297             felec            = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq31,rinv31),_fjsp_sub_v2r8(rinvsq31,felec));
1298
1299             cutoff_mask      = _fjsp_cmplt_v2r8(rsq31,rcutoff2);
1300
1301             /* Update potential sum for this i atom from the interaction with this j atom. */
1302             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
1303             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
1304             velecsum         = _fjsp_add_v2r8(velecsum,velec);
1305
1306             fscal            = felec;
1307
1308             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1309
1310             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1311
1312             /* Update vectorial force */
1313             fix3             = _fjsp_madd_v2r8(dx31,fscal,fix3);
1314             fiy3             = _fjsp_madd_v2r8(dy31,fscal,fiy3);
1315             fiz3             = _fjsp_madd_v2r8(dz31,fscal,fiz3);
1316             
1317             fjx1             = _fjsp_madd_v2r8(dx31,fscal,fjx1);
1318             fjy1             = _fjsp_madd_v2r8(dy31,fscal,fjy1);
1319             fjz1             = _fjsp_madd_v2r8(dz31,fscal,fjz1);
1320
1321             }
1322
1323             /**************************
1324              * CALCULATE INTERACTIONS *
1325              **************************/
1326
1327             if (gmx_fjsp_any_lt_v2r8(rsq32,rcutoff2))
1328             {
1329
1330             r32              = _fjsp_mul_v2r8(rsq32,rinv32);
1331
1332             /* EWALD ELECTROSTATICS */
1333
1334             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1335             ewrt             = _fjsp_mul_v2r8(r32,ewtabscale);
1336             itab_tmp         = _fjsp_dtox_v2r8(ewrt);
1337             eweps            = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
1338             _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
1339
1340             ewtabF           = _fjsp_load_v2r8( ewtab + 4*ewconv.i[0] );
1341             ewtabD           = _fjsp_setzero_v2r8();
1342             GMX_FJSP_TRANSPOSE2_V2R8(ewtabF,ewtabD);
1343             ewtabV           = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[0] +2);
1344             ewtabFn          = _fjsp_setzero_v2r8();
1345             GMX_FJSP_TRANSPOSE2_V2R8(ewtabV,ewtabFn);
1346             felec            = _fjsp_madd_v2r8(eweps,ewtabD,ewtabF);
1347             velec            = _fjsp_nmsub_v2r8(_fjsp_mul_v2r8(ewtabhalfspace,eweps) ,_fjsp_add_v2r8(ewtabF,felec), ewtabV);
1348             velec            = _fjsp_mul_v2r8(qq32,_fjsp_sub_v2r8(_fjsp_sub_v2r8(rinv32,sh_ewald),velec));
1349             felec            = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq32,rinv32),_fjsp_sub_v2r8(rinvsq32,felec));
1350
1351             cutoff_mask      = _fjsp_cmplt_v2r8(rsq32,rcutoff2);
1352
1353             /* Update potential sum for this i atom from the interaction with this j atom. */
1354             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
1355             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
1356             velecsum         = _fjsp_add_v2r8(velecsum,velec);
1357
1358             fscal            = felec;
1359
1360             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1361
1362             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1363
1364             /* Update vectorial force */
1365             fix3             = _fjsp_madd_v2r8(dx32,fscal,fix3);
1366             fiy3             = _fjsp_madd_v2r8(dy32,fscal,fiy3);
1367             fiz3             = _fjsp_madd_v2r8(dz32,fscal,fiz3);
1368             
1369             fjx2             = _fjsp_madd_v2r8(dx32,fscal,fjx2);
1370             fjy2             = _fjsp_madd_v2r8(dy32,fscal,fjy2);
1371             fjz2             = _fjsp_madd_v2r8(dz32,fscal,fjz2);
1372
1373             }
1374
1375             /**************************
1376              * CALCULATE INTERACTIONS *
1377              **************************/
1378
1379             if (gmx_fjsp_any_lt_v2r8(rsq33,rcutoff2))
1380             {
1381
1382             r33              = _fjsp_mul_v2r8(rsq33,rinv33);
1383
1384             /* EWALD ELECTROSTATICS */
1385
1386             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1387             ewrt             = _fjsp_mul_v2r8(r33,ewtabscale);
1388             itab_tmp         = _fjsp_dtox_v2r8(ewrt);
1389             eweps            = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
1390             _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
1391
1392             ewtabF           = _fjsp_load_v2r8( ewtab + 4*ewconv.i[0] );
1393             ewtabD           = _fjsp_setzero_v2r8();
1394             GMX_FJSP_TRANSPOSE2_V2R8(ewtabF,ewtabD);
1395             ewtabV           = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[0] +2);
1396             ewtabFn          = _fjsp_setzero_v2r8();
1397             GMX_FJSP_TRANSPOSE2_V2R8(ewtabV,ewtabFn);
1398             felec            = _fjsp_madd_v2r8(eweps,ewtabD,ewtabF);
1399             velec            = _fjsp_nmsub_v2r8(_fjsp_mul_v2r8(ewtabhalfspace,eweps) ,_fjsp_add_v2r8(ewtabF,felec), ewtabV);
1400             velec            = _fjsp_mul_v2r8(qq33,_fjsp_sub_v2r8(_fjsp_sub_v2r8(rinv33,sh_ewald),velec));
1401             felec            = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq33,rinv33),_fjsp_sub_v2r8(rinvsq33,felec));
1402
1403             cutoff_mask      = _fjsp_cmplt_v2r8(rsq33,rcutoff2);
1404
1405             /* Update potential sum for this i atom from the interaction with this j atom. */
1406             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
1407             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
1408             velecsum         = _fjsp_add_v2r8(velecsum,velec);
1409
1410             fscal            = felec;
1411
1412             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1413
1414             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1415
1416             /* Update vectorial force */
1417             fix3             = _fjsp_madd_v2r8(dx33,fscal,fix3);
1418             fiy3             = _fjsp_madd_v2r8(dy33,fscal,fiy3);
1419             fiz3             = _fjsp_madd_v2r8(dz33,fscal,fiz3);
1420             
1421             fjx3             = _fjsp_madd_v2r8(dx33,fscal,fjx3);
1422             fjy3             = _fjsp_madd_v2r8(dy33,fscal,fjy3);
1423             fjz3             = _fjsp_madd_v2r8(dz33,fscal,fjz3);
1424
1425             }
1426
1427             gmx_fjsp_decrement_4rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
1428
1429             /* Inner loop uses 503 flops */
1430         }
1431
1432         /* End of innermost loop */
1433
1434         gmx_fjsp_update_iforce_4atom_swizzle_v2r8(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
1435                                               f+i_coord_offset,fshift+i_shift_offset);
1436
1437         ggid                        = gid[iidx];
1438         /* Update potential energies */
1439         gmx_fjsp_update_1pot_v2r8(velecsum,kernel_data->energygrp_elec+ggid);
1440         gmx_fjsp_update_1pot_v2r8(vvdwsum,kernel_data->energygrp_vdw+ggid);
1441
1442         /* Increment number of inner iterations */
1443         inneriter                  += j_index_end - j_index_start;
1444
1445         /* Outer loop uses 26 flops */
1446     }
1447
1448     /* Increment number of outer iterations */
1449     outeriter        += nri;
1450
1451     /* Update outer/inner flops */
1452
1453     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*26 + inneriter*503);
1454 }
1455 /*
1456  * Gromacs nonbonded kernel:   nb_kernel_ElecEwSh_VdwLJEwSh_GeomW4W4_F_sparc64_hpc_ace_double
1457  * Electrostatics interaction: Ewald
1458  * VdW interaction:            LJEwald
1459  * Geometry:                   Water4-Water4
1460  * Calculate force/pot:        Force
1461  */
1462 void
1463 nb_kernel_ElecEwSh_VdwLJEwSh_GeomW4W4_F_sparc64_hpc_ace_double
1464                     (t_nblist                    * gmx_restrict       nlist,
1465                      rvec                        * gmx_restrict          xx,
1466                      rvec                        * gmx_restrict          ff,
1467                      t_forcerec                  * gmx_restrict          fr,
1468                      t_mdatoms                   * gmx_restrict     mdatoms,
1469                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
1470                      t_nrnb                      * gmx_restrict        nrnb)
1471 {
1472     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
1473      * just 0 for non-waters.
1474      * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
1475      * jnr indices corresponding to data put in the four positions in the SIMD register.
1476      */
1477     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
1478     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
1479     int              jnrA,jnrB;
1480     int              j_coord_offsetA,j_coord_offsetB;
1481     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
1482     real             rcutoff_scalar;
1483     real             *shiftvec,*fshift,*x,*f;
1484     _fjsp_v2r8       tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
1485     int              vdwioffset0;
1486     _fjsp_v2r8       ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
1487     int              vdwioffset1;
1488     _fjsp_v2r8       ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
1489     int              vdwioffset2;
1490     _fjsp_v2r8       ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
1491     int              vdwioffset3;
1492     _fjsp_v2r8       ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
1493     int              vdwjidx0A,vdwjidx0B;
1494     _fjsp_v2r8       jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
1495     int              vdwjidx1A,vdwjidx1B;
1496     _fjsp_v2r8       jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
1497     int              vdwjidx2A,vdwjidx2B;
1498     _fjsp_v2r8       jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
1499     int              vdwjidx3A,vdwjidx3B;
1500     _fjsp_v2r8       jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
1501     _fjsp_v2r8       dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
1502     _fjsp_v2r8       dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
1503     _fjsp_v2r8       dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
1504     _fjsp_v2r8       dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13;
1505     _fjsp_v2r8       dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
1506     _fjsp_v2r8       dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
1507     _fjsp_v2r8       dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23;
1508     _fjsp_v2r8       dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31;
1509     _fjsp_v2r8       dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32;
1510     _fjsp_v2r8       dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33;
1511     _fjsp_v2r8       velec,felec,velecsum,facel,crf,krf,krf2;
1512     real             *charge;
1513     int              nvdwtype;
1514     _fjsp_v2r8       rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
1515     int              *vdwtype;
1516     real             *vdwparam;
1517     _fjsp_v2r8       one_sixth   = gmx_fjsp_set1_v2r8(1.0/6.0);
1518     _fjsp_v2r8       one_twelfth = gmx_fjsp_set1_v2r8(1.0/12.0);
1519     _fjsp_v2r8           c6grid_00;
1520     _fjsp_v2r8           c6grid_11;
1521     _fjsp_v2r8           c6grid_12;
1522     _fjsp_v2r8           c6grid_13;
1523     _fjsp_v2r8           c6grid_21;
1524     _fjsp_v2r8           c6grid_22;
1525     _fjsp_v2r8           c6grid_23;
1526     _fjsp_v2r8           c6grid_31;
1527     _fjsp_v2r8           c6grid_32;
1528     _fjsp_v2r8           c6grid_33;
1529     real                 *vdwgridparam;
1530     _fjsp_v2r8           ewclj,ewclj2,ewclj6,ewcljrsq,poly,exponent,f6A,f6B,sh_lj_ewald;
1531     _fjsp_v2r8           one_half = gmx_fjsp_set1_v2r8(0.5);
1532     _fjsp_v2r8           minus_one = gmx_fjsp_set1_v2r8(-1.0);
1533     _fjsp_v2r8       ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
1534     real             *ewtab;
1535     _fjsp_v2r8       itab_tmp;
1536     _fjsp_v2r8       dummy_mask,cutoff_mask;
1537     _fjsp_v2r8       one     = gmx_fjsp_set1_v2r8(1.0);
1538     _fjsp_v2r8       two     = gmx_fjsp_set1_v2r8(2.0);
1539     union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
1540
1541     x                = xx[0];
1542     f                = ff[0];
1543
1544     nri              = nlist->nri;
1545     iinr             = nlist->iinr;
1546     jindex           = nlist->jindex;
1547     jjnr             = nlist->jjnr;
1548     shiftidx         = nlist->shift;
1549     gid              = nlist->gid;
1550     shiftvec         = fr->shift_vec[0];
1551     fshift           = fr->fshift[0];
1552     facel            = gmx_fjsp_set1_v2r8(fr->epsfac);
1553     charge           = mdatoms->chargeA;
1554     nvdwtype         = fr->ntype;
1555     vdwparam         = fr->nbfp;
1556     vdwtype          = mdatoms->typeA;
1557     vdwgridparam     = fr->ljpme_c6grid;
1558     sh_lj_ewald      = gmx_fjsp_set1_v2r8(fr->ic->sh_lj_ewald);
1559     ewclj            = gmx_fjsp_set1_v2r8(fr->ewaldcoeff_lj);
1560     ewclj2           = _fjsp_mul_v2r8(minus_one,_fjsp_mul_v2r8(ewclj,ewclj));
1561
1562     sh_ewald         = gmx_fjsp_set1_v2r8(fr->ic->sh_ewald);
1563     ewtab            = fr->ic->tabq_coul_F;
1564     ewtabscale       = gmx_fjsp_set1_v2r8(fr->ic->tabq_scale);
1565     ewtabhalfspace   = gmx_fjsp_set1_v2r8(0.5/fr->ic->tabq_scale);
1566
1567     /* Setup water-specific parameters */
1568     inr              = nlist->iinr[0];
1569     iq1              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+1]));
1570     iq2              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+2]));
1571     iq3              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+3]));
1572     vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
1573
1574     jq1              = gmx_fjsp_set1_v2r8(charge[inr+1]);
1575     jq2              = gmx_fjsp_set1_v2r8(charge[inr+2]);
1576     jq3              = gmx_fjsp_set1_v2r8(charge[inr+3]);
1577     vdwjidx0A        = 2*vdwtype[inr+0];
1578     c6_00            = gmx_fjsp_set1_v2r8(vdwparam[vdwioffset0+vdwjidx0A]);
1579     c12_00           = gmx_fjsp_set1_v2r8(vdwparam[vdwioffset0+vdwjidx0A+1]);
1580     c6grid_00        = gmx_fjsp_set1_v2r8(vdwgridparam[vdwioffset0+vdwjidx0A]);
1581     qq11             = _fjsp_mul_v2r8(iq1,jq1);
1582     qq12             = _fjsp_mul_v2r8(iq1,jq2);
1583     qq13             = _fjsp_mul_v2r8(iq1,jq3);
1584     qq21             = _fjsp_mul_v2r8(iq2,jq1);
1585     qq22             = _fjsp_mul_v2r8(iq2,jq2);
1586     qq23             = _fjsp_mul_v2r8(iq2,jq3);
1587     qq31             = _fjsp_mul_v2r8(iq3,jq1);
1588     qq32             = _fjsp_mul_v2r8(iq3,jq2);
1589     qq33             = _fjsp_mul_v2r8(iq3,jq3);
1590
1591     /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
1592     rcutoff_scalar   = fr->rcoulomb;
1593     rcutoff          = gmx_fjsp_set1_v2r8(rcutoff_scalar);
1594     rcutoff2         = _fjsp_mul_v2r8(rcutoff,rcutoff);
1595
1596     sh_vdw_invrcut6  = gmx_fjsp_set1_v2r8(fr->ic->sh_invrc6);
1597     rvdw             = gmx_fjsp_set1_v2r8(fr->rvdw);
1598
1599     /* Avoid stupid compiler warnings */
1600     jnrA = jnrB = 0;
1601     j_coord_offsetA = 0;
1602     j_coord_offsetB = 0;
1603
1604     outeriter        = 0;
1605     inneriter        = 0;
1606
1607     /* Start outer loop over neighborlists */
1608     for(iidx=0; iidx<nri; iidx++)
1609     {
1610         /* Load shift vector for this list */
1611         i_shift_offset   = DIM*shiftidx[iidx];
1612
1613         /* Load limits for loop over neighbors */
1614         j_index_start    = jindex[iidx];
1615         j_index_end      = jindex[iidx+1];
1616
1617         /* Get outer coordinate index */
1618         inr              = iinr[iidx];
1619         i_coord_offset   = DIM*inr;
1620
1621         /* Load i particle coords and add shift vector */
1622         gmx_fjsp_load_shift_and_4rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,
1623                                                  &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
1624
1625         fix0             = _fjsp_setzero_v2r8();
1626         fiy0             = _fjsp_setzero_v2r8();
1627         fiz0             = _fjsp_setzero_v2r8();
1628         fix1             = _fjsp_setzero_v2r8();
1629         fiy1             = _fjsp_setzero_v2r8();
1630         fiz1             = _fjsp_setzero_v2r8();
1631         fix2             = _fjsp_setzero_v2r8();
1632         fiy2             = _fjsp_setzero_v2r8();
1633         fiz2             = _fjsp_setzero_v2r8();
1634         fix3             = _fjsp_setzero_v2r8();
1635         fiy3             = _fjsp_setzero_v2r8();
1636         fiz3             = _fjsp_setzero_v2r8();
1637
1638         /* Start inner kernel loop */
1639         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
1640         {
1641
1642             /* Get j neighbor index, and coordinate index */
1643             jnrA             = jjnr[jidx];
1644             jnrB             = jjnr[jidx+1];
1645             j_coord_offsetA  = DIM*jnrA;
1646             j_coord_offsetB  = DIM*jnrB;
1647
1648             /* load j atom coordinates */
1649             gmx_fjsp_load_4rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
1650                                               &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,
1651                                               &jy2,&jz2,&jx3,&jy3,&jz3);
1652
1653             /* Calculate displacement vector */
1654             dx00             = _fjsp_sub_v2r8(ix0,jx0);
1655             dy00             = _fjsp_sub_v2r8(iy0,jy0);
1656             dz00             = _fjsp_sub_v2r8(iz0,jz0);
1657             dx11             = _fjsp_sub_v2r8(ix1,jx1);
1658             dy11             = _fjsp_sub_v2r8(iy1,jy1);
1659             dz11             = _fjsp_sub_v2r8(iz1,jz1);
1660             dx12             = _fjsp_sub_v2r8(ix1,jx2);
1661             dy12             = _fjsp_sub_v2r8(iy1,jy2);
1662             dz12             = _fjsp_sub_v2r8(iz1,jz2);
1663             dx13             = _fjsp_sub_v2r8(ix1,jx3);
1664             dy13             = _fjsp_sub_v2r8(iy1,jy3);
1665             dz13             = _fjsp_sub_v2r8(iz1,jz3);
1666             dx21             = _fjsp_sub_v2r8(ix2,jx1);
1667             dy21             = _fjsp_sub_v2r8(iy2,jy1);
1668             dz21             = _fjsp_sub_v2r8(iz2,jz1);
1669             dx22             = _fjsp_sub_v2r8(ix2,jx2);
1670             dy22             = _fjsp_sub_v2r8(iy2,jy2);
1671             dz22             = _fjsp_sub_v2r8(iz2,jz2);
1672             dx23             = _fjsp_sub_v2r8(ix2,jx3);
1673             dy23             = _fjsp_sub_v2r8(iy2,jy3);
1674             dz23             = _fjsp_sub_v2r8(iz2,jz3);
1675             dx31             = _fjsp_sub_v2r8(ix3,jx1);
1676             dy31             = _fjsp_sub_v2r8(iy3,jy1);
1677             dz31             = _fjsp_sub_v2r8(iz3,jz1);
1678             dx32             = _fjsp_sub_v2r8(ix3,jx2);
1679             dy32             = _fjsp_sub_v2r8(iy3,jy2);
1680             dz32             = _fjsp_sub_v2r8(iz3,jz2);
1681             dx33             = _fjsp_sub_v2r8(ix3,jx3);
1682             dy33             = _fjsp_sub_v2r8(iy3,jy3);
1683             dz33             = _fjsp_sub_v2r8(iz3,jz3);
1684
1685             /* Calculate squared distance and things based on it */
1686             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
1687             rsq11            = gmx_fjsp_calc_rsq_v2r8(dx11,dy11,dz11);
1688             rsq12            = gmx_fjsp_calc_rsq_v2r8(dx12,dy12,dz12);
1689             rsq13            = gmx_fjsp_calc_rsq_v2r8(dx13,dy13,dz13);
1690             rsq21            = gmx_fjsp_calc_rsq_v2r8(dx21,dy21,dz21);
1691             rsq22            = gmx_fjsp_calc_rsq_v2r8(dx22,dy22,dz22);
1692             rsq23            = gmx_fjsp_calc_rsq_v2r8(dx23,dy23,dz23);
1693             rsq31            = gmx_fjsp_calc_rsq_v2r8(dx31,dy31,dz31);
1694             rsq32            = gmx_fjsp_calc_rsq_v2r8(dx32,dy32,dz32);
1695             rsq33            = gmx_fjsp_calc_rsq_v2r8(dx33,dy33,dz33);
1696
1697             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
1698             rinv11           = gmx_fjsp_invsqrt_v2r8(rsq11);
1699             rinv12           = gmx_fjsp_invsqrt_v2r8(rsq12);
1700             rinv13           = gmx_fjsp_invsqrt_v2r8(rsq13);
1701             rinv21           = gmx_fjsp_invsqrt_v2r8(rsq21);
1702             rinv22           = gmx_fjsp_invsqrt_v2r8(rsq22);
1703             rinv23           = gmx_fjsp_invsqrt_v2r8(rsq23);
1704             rinv31           = gmx_fjsp_invsqrt_v2r8(rsq31);
1705             rinv32           = gmx_fjsp_invsqrt_v2r8(rsq32);
1706             rinv33           = gmx_fjsp_invsqrt_v2r8(rsq33);
1707
1708             rinvsq00         = _fjsp_mul_v2r8(rinv00,rinv00);
1709             rinvsq11         = _fjsp_mul_v2r8(rinv11,rinv11);
1710             rinvsq12         = _fjsp_mul_v2r8(rinv12,rinv12);
1711             rinvsq13         = _fjsp_mul_v2r8(rinv13,rinv13);
1712             rinvsq21         = _fjsp_mul_v2r8(rinv21,rinv21);
1713             rinvsq22         = _fjsp_mul_v2r8(rinv22,rinv22);
1714             rinvsq23         = _fjsp_mul_v2r8(rinv23,rinv23);
1715             rinvsq31         = _fjsp_mul_v2r8(rinv31,rinv31);
1716             rinvsq32         = _fjsp_mul_v2r8(rinv32,rinv32);
1717             rinvsq33         = _fjsp_mul_v2r8(rinv33,rinv33);
1718
1719             fjx0             = _fjsp_setzero_v2r8();
1720             fjy0             = _fjsp_setzero_v2r8();
1721             fjz0             = _fjsp_setzero_v2r8();
1722             fjx1             = _fjsp_setzero_v2r8();
1723             fjy1             = _fjsp_setzero_v2r8();
1724             fjz1             = _fjsp_setzero_v2r8();
1725             fjx2             = _fjsp_setzero_v2r8();
1726             fjy2             = _fjsp_setzero_v2r8();
1727             fjz2             = _fjsp_setzero_v2r8();
1728             fjx3             = _fjsp_setzero_v2r8();
1729             fjy3             = _fjsp_setzero_v2r8();
1730             fjz3             = _fjsp_setzero_v2r8();
1731
1732             /**************************
1733              * CALCULATE INTERACTIONS *
1734              **************************/
1735
1736             if (gmx_fjsp_any_lt_v2r8(rsq00,rcutoff2))
1737             {
1738
1739             r00              = _fjsp_mul_v2r8(rsq00,rinv00);
1740
1741             /* Analytical LJ-PME */
1742             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
1743             ewcljrsq         = _fjsp_mul_v2r8(ewclj2,rsq00);
1744             ewclj6           = _fjsp_mul_v2r8(ewclj2,_fjsp_mul_v2r8(ewclj2,ewclj2));
1745             exponent         = gmx_simd_exp_d(-ewcljrsq);
1746             /* poly = exp(-(beta*r)^2) * (1 + (beta*r)^2 + (beta*r)^4 /2) */
1747             poly             = _fjsp_mul_v2r8(exponent,_fjsp_madd_v2r8(_fjsp_mul_v2r8(ewcljrsq,ewcljrsq),one_half,_fjsp_sub_v2r8(one,ewcljrsq)));
1748             /* f6A = 6 * C6grid * (1 - poly) */
1749             f6A              = _fjsp_mul_v2r8(c6grid_00,_fjsp_msub_v2r8(one,poly));
1750             /* f6B = C6grid * exponent * beta^6 */
1751             f6B              = _fjsp_mul_v2r8(_fjsp_mul_v2r8(c6grid_00,one_sixth),_fjsp_mul_v2r8(exponent,ewclj6));
1752             /* fvdw = 12*C12/r13 - ((6*C6 - f6A)/r6 + f6B)/r */
1753             fvdw              = _fjsp_mul_v2r8(_fjsp_madd_v2r8(_fjsp_msub_v2r8(c12_00,rinvsix,_fjsp_sub_v2r8(c6_00,f6A)),rinvsix,f6B),rinvsq00);
1754
1755             cutoff_mask      = _fjsp_cmplt_v2r8(rsq00,rcutoff2);
1756
1757             fscal            = fvdw;
1758
1759             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1760
1761             /* Update vectorial force */
1762             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
1763             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
1764             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
1765             
1766             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
1767             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
1768             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
1769
1770             }
1771
1772             /**************************
1773              * CALCULATE INTERACTIONS *
1774              **************************/
1775
1776             if (gmx_fjsp_any_lt_v2r8(rsq11,rcutoff2))
1777             {
1778
1779             r11              = _fjsp_mul_v2r8(rsq11,rinv11);
1780
1781             /* EWALD ELECTROSTATICS */
1782
1783             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1784             ewrt             = _fjsp_mul_v2r8(r11,ewtabscale);
1785             itab_tmp         = _fjsp_dtox_v2r8(ewrt);
1786             eweps            = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
1787             _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
1788
1789             gmx_fjsp_load_2pair_swizzle_v2r8(ewtab+ewconv.i[0],ewtab+ewconv.i[1],
1790                                          &ewtabF,&ewtabFn);
1791             felec            = _fjsp_madd_v2r8(eweps,ewtabFn,_fjsp_nmsub_v2r8(eweps,ewtabF,ewtabF));
1792             felec            = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq11,rinv11),_fjsp_sub_v2r8(rinvsq11,felec));
1793
1794             cutoff_mask      = _fjsp_cmplt_v2r8(rsq11,rcutoff2);
1795
1796             fscal            = felec;
1797
1798             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1799
1800             /* Update vectorial force */
1801             fix1             = _fjsp_madd_v2r8(dx11,fscal,fix1);
1802             fiy1             = _fjsp_madd_v2r8(dy11,fscal,fiy1);
1803             fiz1             = _fjsp_madd_v2r8(dz11,fscal,fiz1);
1804             
1805             fjx1             = _fjsp_madd_v2r8(dx11,fscal,fjx1);
1806             fjy1             = _fjsp_madd_v2r8(dy11,fscal,fjy1);
1807             fjz1             = _fjsp_madd_v2r8(dz11,fscal,fjz1);
1808
1809             }
1810
1811             /**************************
1812              * CALCULATE INTERACTIONS *
1813              **************************/
1814
1815             if (gmx_fjsp_any_lt_v2r8(rsq12,rcutoff2))
1816             {
1817
1818             r12              = _fjsp_mul_v2r8(rsq12,rinv12);
1819
1820             /* EWALD ELECTROSTATICS */
1821
1822             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1823             ewrt             = _fjsp_mul_v2r8(r12,ewtabscale);
1824             itab_tmp         = _fjsp_dtox_v2r8(ewrt);
1825             eweps            = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
1826             _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
1827
1828             gmx_fjsp_load_2pair_swizzle_v2r8(ewtab+ewconv.i[0],ewtab+ewconv.i[1],
1829                                          &ewtabF,&ewtabFn);
1830             felec            = _fjsp_madd_v2r8(eweps,ewtabFn,_fjsp_nmsub_v2r8(eweps,ewtabF,ewtabF));
1831             felec            = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq12,rinv12),_fjsp_sub_v2r8(rinvsq12,felec));
1832
1833             cutoff_mask      = _fjsp_cmplt_v2r8(rsq12,rcutoff2);
1834
1835             fscal            = felec;
1836
1837             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1838
1839             /* Update vectorial force */
1840             fix1             = _fjsp_madd_v2r8(dx12,fscal,fix1);
1841             fiy1             = _fjsp_madd_v2r8(dy12,fscal,fiy1);
1842             fiz1             = _fjsp_madd_v2r8(dz12,fscal,fiz1);
1843             
1844             fjx2             = _fjsp_madd_v2r8(dx12,fscal,fjx2);
1845             fjy2             = _fjsp_madd_v2r8(dy12,fscal,fjy2);
1846             fjz2             = _fjsp_madd_v2r8(dz12,fscal,fjz2);
1847
1848             }
1849
1850             /**************************
1851              * CALCULATE INTERACTIONS *
1852              **************************/
1853
1854             if (gmx_fjsp_any_lt_v2r8(rsq13,rcutoff2))
1855             {
1856
1857             r13              = _fjsp_mul_v2r8(rsq13,rinv13);
1858
1859             /* EWALD ELECTROSTATICS */
1860
1861             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1862             ewrt             = _fjsp_mul_v2r8(r13,ewtabscale);
1863             itab_tmp         = _fjsp_dtox_v2r8(ewrt);
1864             eweps            = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
1865             _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
1866
1867             gmx_fjsp_load_2pair_swizzle_v2r8(ewtab+ewconv.i[0],ewtab+ewconv.i[1],
1868                                          &ewtabF,&ewtabFn);
1869             felec            = _fjsp_madd_v2r8(eweps,ewtabFn,_fjsp_nmsub_v2r8(eweps,ewtabF,ewtabF));
1870             felec            = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq13,rinv13),_fjsp_sub_v2r8(rinvsq13,felec));
1871
1872             cutoff_mask      = _fjsp_cmplt_v2r8(rsq13,rcutoff2);
1873
1874             fscal            = felec;
1875
1876             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1877
1878             /* Update vectorial force */
1879             fix1             = _fjsp_madd_v2r8(dx13,fscal,fix1);
1880             fiy1             = _fjsp_madd_v2r8(dy13,fscal,fiy1);
1881             fiz1             = _fjsp_madd_v2r8(dz13,fscal,fiz1);
1882             
1883             fjx3             = _fjsp_madd_v2r8(dx13,fscal,fjx3);
1884             fjy3             = _fjsp_madd_v2r8(dy13,fscal,fjy3);
1885             fjz3             = _fjsp_madd_v2r8(dz13,fscal,fjz3);
1886
1887             }
1888
1889             /**************************
1890              * CALCULATE INTERACTIONS *
1891              **************************/
1892
1893             if (gmx_fjsp_any_lt_v2r8(rsq21,rcutoff2))
1894             {
1895
1896             r21              = _fjsp_mul_v2r8(rsq21,rinv21);
1897
1898             /* EWALD ELECTROSTATICS */
1899
1900             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1901             ewrt             = _fjsp_mul_v2r8(r21,ewtabscale);
1902             itab_tmp         = _fjsp_dtox_v2r8(ewrt);
1903             eweps            = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
1904             _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
1905
1906             gmx_fjsp_load_2pair_swizzle_v2r8(ewtab+ewconv.i[0],ewtab+ewconv.i[1],
1907                                          &ewtabF,&ewtabFn);
1908             felec            = _fjsp_madd_v2r8(eweps,ewtabFn,_fjsp_nmsub_v2r8(eweps,ewtabF,ewtabF));
1909             felec            = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq21,rinv21),_fjsp_sub_v2r8(rinvsq21,felec));
1910
1911             cutoff_mask      = _fjsp_cmplt_v2r8(rsq21,rcutoff2);
1912
1913             fscal            = felec;
1914
1915             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1916
1917             /* Update vectorial force */
1918             fix2             = _fjsp_madd_v2r8(dx21,fscal,fix2);
1919             fiy2             = _fjsp_madd_v2r8(dy21,fscal,fiy2);
1920             fiz2             = _fjsp_madd_v2r8(dz21,fscal,fiz2);
1921             
1922             fjx1             = _fjsp_madd_v2r8(dx21,fscal,fjx1);
1923             fjy1             = _fjsp_madd_v2r8(dy21,fscal,fjy1);
1924             fjz1             = _fjsp_madd_v2r8(dz21,fscal,fjz1);
1925
1926             }
1927
1928             /**************************
1929              * CALCULATE INTERACTIONS *
1930              **************************/
1931
1932             if (gmx_fjsp_any_lt_v2r8(rsq22,rcutoff2))
1933             {
1934
1935             r22              = _fjsp_mul_v2r8(rsq22,rinv22);
1936
1937             /* EWALD ELECTROSTATICS */
1938
1939             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1940             ewrt             = _fjsp_mul_v2r8(r22,ewtabscale);
1941             itab_tmp         = _fjsp_dtox_v2r8(ewrt);
1942             eweps            = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
1943             _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
1944
1945             gmx_fjsp_load_2pair_swizzle_v2r8(ewtab+ewconv.i[0],ewtab+ewconv.i[1],
1946                                          &ewtabF,&ewtabFn);
1947             felec            = _fjsp_madd_v2r8(eweps,ewtabFn,_fjsp_nmsub_v2r8(eweps,ewtabF,ewtabF));
1948             felec            = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq22,rinv22),_fjsp_sub_v2r8(rinvsq22,felec));
1949
1950             cutoff_mask      = _fjsp_cmplt_v2r8(rsq22,rcutoff2);
1951
1952             fscal            = felec;
1953
1954             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1955
1956             /* Update vectorial force */
1957             fix2             = _fjsp_madd_v2r8(dx22,fscal,fix2);
1958             fiy2             = _fjsp_madd_v2r8(dy22,fscal,fiy2);
1959             fiz2             = _fjsp_madd_v2r8(dz22,fscal,fiz2);
1960             
1961             fjx2             = _fjsp_madd_v2r8(dx22,fscal,fjx2);
1962             fjy2             = _fjsp_madd_v2r8(dy22,fscal,fjy2);
1963             fjz2             = _fjsp_madd_v2r8(dz22,fscal,fjz2);
1964
1965             }
1966
1967             /**************************
1968              * CALCULATE INTERACTIONS *
1969              **************************/
1970
1971             if (gmx_fjsp_any_lt_v2r8(rsq23,rcutoff2))
1972             {
1973
1974             r23              = _fjsp_mul_v2r8(rsq23,rinv23);
1975
1976             /* EWALD ELECTROSTATICS */
1977
1978             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1979             ewrt             = _fjsp_mul_v2r8(r23,ewtabscale);
1980             itab_tmp         = _fjsp_dtox_v2r8(ewrt);
1981             eweps            = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
1982             _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
1983
1984             gmx_fjsp_load_2pair_swizzle_v2r8(ewtab+ewconv.i[0],ewtab+ewconv.i[1],
1985                                          &ewtabF,&ewtabFn);
1986             felec            = _fjsp_madd_v2r8(eweps,ewtabFn,_fjsp_nmsub_v2r8(eweps,ewtabF,ewtabF));
1987             felec            = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq23,rinv23),_fjsp_sub_v2r8(rinvsq23,felec));
1988
1989             cutoff_mask      = _fjsp_cmplt_v2r8(rsq23,rcutoff2);
1990
1991             fscal            = felec;
1992
1993             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1994
1995             /* Update vectorial force */
1996             fix2             = _fjsp_madd_v2r8(dx23,fscal,fix2);
1997             fiy2             = _fjsp_madd_v2r8(dy23,fscal,fiy2);
1998             fiz2             = _fjsp_madd_v2r8(dz23,fscal,fiz2);
1999             
2000             fjx3             = _fjsp_madd_v2r8(dx23,fscal,fjx3);
2001             fjy3             = _fjsp_madd_v2r8(dy23,fscal,fjy3);
2002             fjz3             = _fjsp_madd_v2r8(dz23,fscal,fjz3);
2003
2004             }
2005
2006             /**************************
2007              * CALCULATE INTERACTIONS *
2008              **************************/
2009
2010             if (gmx_fjsp_any_lt_v2r8(rsq31,rcutoff2))
2011             {
2012
2013             r31              = _fjsp_mul_v2r8(rsq31,rinv31);
2014
2015             /* EWALD ELECTROSTATICS */
2016
2017             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
2018             ewrt             = _fjsp_mul_v2r8(r31,ewtabscale);
2019             itab_tmp         = _fjsp_dtox_v2r8(ewrt);
2020             eweps            = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
2021             _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
2022
2023             gmx_fjsp_load_2pair_swizzle_v2r8(ewtab+ewconv.i[0],ewtab+ewconv.i[1],
2024                                          &ewtabF,&ewtabFn);
2025             felec            = _fjsp_madd_v2r8(eweps,ewtabFn,_fjsp_nmsub_v2r8(eweps,ewtabF,ewtabF));
2026             felec            = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq31,rinv31),_fjsp_sub_v2r8(rinvsq31,felec));
2027
2028             cutoff_mask      = _fjsp_cmplt_v2r8(rsq31,rcutoff2);
2029
2030             fscal            = felec;
2031
2032             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
2033
2034             /* Update vectorial force */
2035             fix3             = _fjsp_madd_v2r8(dx31,fscal,fix3);
2036             fiy3             = _fjsp_madd_v2r8(dy31,fscal,fiy3);
2037             fiz3             = _fjsp_madd_v2r8(dz31,fscal,fiz3);
2038             
2039             fjx1             = _fjsp_madd_v2r8(dx31,fscal,fjx1);
2040             fjy1             = _fjsp_madd_v2r8(dy31,fscal,fjy1);
2041             fjz1             = _fjsp_madd_v2r8(dz31,fscal,fjz1);
2042
2043             }
2044
2045             /**************************
2046              * CALCULATE INTERACTIONS *
2047              **************************/
2048
2049             if (gmx_fjsp_any_lt_v2r8(rsq32,rcutoff2))
2050             {
2051
2052             r32              = _fjsp_mul_v2r8(rsq32,rinv32);
2053
2054             /* EWALD ELECTROSTATICS */
2055
2056             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
2057             ewrt             = _fjsp_mul_v2r8(r32,ewtabscale);
2058             itab_tmp         = _fjsp_dtox_v2r8(ewrt);
2059             eweps            = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
2060             _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
2061
2062             gmx_fjsp_load_2pair_swizzle_v2r8(ewtab+ewconv.i[0],ewtab+ewconv.i[1],
2063                                          &ewtabF,&ewtabFn);
2064             felec            = _fjsp_madd_v2r8(eweps,ewtabFn,_fjsp_nmsub_v2r8(eweps,ewtabF,ewtabF));
2065             felec            = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq32,rinv32),_fjsp_sub_v2r8(rinvsq32,felec));
2066
2067             cutoff_mask      = _fjsp_cmplt_v2r8(rsq32,rcutoff2);
2068
2069             fscal            = felec;
2070
2071             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
2072
2073             /* Update vectorial force */
2074             fix3             = _fjsp_madd_v2r8(dx32,fscal,fix3);
2075             fiy3             = _fjsp_madd_v2r8(dy32,fscal,fiy3);
2076             fiz3             = _fjsp_madd_v2r8(dz32,fscal,fiz3);
2077             
2078             fjx2             = _fjsp_madd_v2r8(dx32,fscal,fjx2);
2079             fjy2             = _fjsp_madd_v2r8(dy32,fscal,fjy2);
2080             fjz2             = _fjsp_madd_v2r8(dz32,fscal,fjz2);
2081
2082             }
2083
2084             /**************************
2085              * CALCULATE INTERACTIONS *
2086              **************************/
2087
2088             if (gmx_fjsp_any_lt_v2r8(rsq33,rcutoff2))
2089             {
2090
2091             r33              = _fjsp_mul_v2r8(rsq33,rinv33);
2092
2093             /* EWALD ELECTROSTATICS */
2094
2095             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
2096             ewrt             = _fjsp_mul_v2r8(r33,ewtabscale);
2097             itab_tmp         = _fjsp_dtox_v2r8(ewrt);
2098             eweps            = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
2099             _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
2100
2101             gmx_fjsp_load_2pair_swizzle_v2r8(ewtab+ewconv.i[0],ewtab+ewconv.i[1],
2102                                          &ewtabF,&ewtabFn);
2103             felec            = _fjsp_madd_v2r8(eweps,ewtabFn,_fjsp_nmsub_v2r8(eweps,ewtabF,ewtabF));
2104             felec            = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq33,rinv33),_fjsp_sub_v2r8(rinvsq33,felec));
2105
2106             cutoff_mask      = _fjsp_cmplt_v2r8(rsq33,rcutoff2);
2107
2108             fscal            = felec;
2109
2110             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
2111
2112             /* Update vectorial force */
2113             fix3             = _fjsp_madd_v2r8(dx33,fscal,fix3);
2114             fiy3             = _fjsp_madd_v2r8(dy33,fscal,fiy3);
2115             fiz3             = _fjsp_madd_v2r8(dz33,fscal,fiz3);
2116             
2117             fjx3             = _fjsp_madd_v2r8(dx33,fscal,fjx3);
2118             fjy3             = _fjsp_madd_v2r8(dy33,fscal,fjy3);
2119             fjz3             = _fjsp_madd_v2r8(dz33,fscal,fjz3);
2120
2121             }
2122
2123             gmx_fjsp_decrement_4rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
2124
2125             /* Inner loop uses 432 flops */
2126         }
2127
2128         if(jidx<j_index_end)
2129         {
2130
2131             jnrA             = jjnr[jidx];
2132             j_coord_offsetA  = DIM*jnrA;
2133
2134             /* load j atom coordinates */
2135             gmx_fjsp_load_4rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
2136                                               &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,
2137                                               &jy2,&jz2,&jx3,&jy3,&jz3);
2138
2139             /* Calculate displacement vector */
2140             dx00             = _fjsp_sub_v2r8(ix0,jx0);
2141             dy00             = _fjsp_sub_v2r8(iy0,jy0);
2142             dz00             = _fjsp_sub_v2r8(iz0,jz0);
2143             dx11             = _fjsp_sub_v2r8(ix1,jx1);
2144             dy11             = _fjsp_sub_v2r8(iy1,jy1);
2145             dz11             = _fjsp_sub_v2r8(iz1,jz1);
2146             dx12             = _fjsp_sub_v2r8(ix1,jx2);
2147             dy12             = _fjsp_sub_v2r8(iy1,jy2);
2148             dz12             = _fjsp_sub_v2r8(iz1,jz2);
2149             dx13             = _fjsp_sub_v2r8(ix1,jx3);
2150             dy13             = _fjsp_sub_v2r8(iy1,jy3);
2151             dz13             = _fjsp_sub_v2r8(iz1,jz3);
2152             dx21             = _fjsp_sub_v2r8(ix2,jx1);
2153             dy21             = _fjsp_sub_v2r8(iy2,jy1);
2154             dz21             = _fjsp_sub_v2r8(iz2,jz1);
2155             dx22             = _fjsp_sub_v2r8(ix2,jx2);
2156             dy22             = _fjsp_sub_v2r8(iy2,jy2);
2157             dz22             = _fjsp_sub_v2r8(iz2,jz2);
2158             dx23             = _fjsp_sub_v2r8(ix2,jx3);
2159             dy23             = _fjsp_sub_v2r8(iy2,jy3);
2160             dz23             = _fjsp_sub_v2r8(iz2,jz3);
2161             dx31             = _fjsp_sub_v2r8(ix3,jx1);
2162             dy31             = _fjsp_sub_v2r8(iy3,jy1);
2163             dz31             = _fjsp_sub_v2r8(iz3,jz1);
2164             dx32             = _fjsp_sub_v2r8(ix3,jx2);
2165             dy32             = _fjsp_sub_v2r8(iy3,jy2);
2166             dz32             = _fjsp_sub_v2r8(iz3,jz2);
2167             dx33             = _fjsp_sub_v2r8(ix3,jx3);
2168             dy33             = _fjsp_sub_v2r8(iy3,jy3);
2169             dz33             = _fjsp_sub_v2r8(iz3,jz3);
2170
2171             /* Calculate squared distance and things based on it */
2172             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
2173             rsq11            = gmx_fjsp_calc_rsq_v2r8(dx11,dy11,dz11);
2174             rsq12            = gmx_fjsp_calc_rsq_v2r8(dx12,dy12,dz12);
2175             rsq13            = gmx_fjsp_calc_rsq_v2r8(dx13,dy13,dz13);
2176             rsq21            = gmx_fjsp_calc_rsq_v2r8(dx21,dy21,dz21);
2177             rsq22            = gmx_fjsp_calc_rsq_v2r8(dx22,dy22,dz22);
2178             rsq23            = gmx_fjsp_calc_rsq_v2r8(dx23,dy23,dz23);
2179             rsq31            = gmx_fjsp_calc_rsq_v2r8(dx31,dy31,dz31);
2180             rsq32            = gmx_fjsp_calc_rsq_v2r8(dx32,dy32,dz32);
2181             rsq33            = gmx_fjsp_calc_rsq_v2r8(dx33,dy33,dz33);
2182
2183             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
2184             rinv11           = gmx_fjsp_invsqrt_v2r8(rsq11);
2185             rinv12           = gmx_fjsp_invsqrt_v2r8(rsq12);
2186             rinv13           = gmx_fjsp_invsqrt_v2r8(rsq13);
2187             rinv21           = gmx_fjsp_invsqrt_v2r8(rsq21);
2188             rinv22           = gmx_fjsp_invsqrt_v2r8(rsq22);
2189             rinv23           = gmx_fjsp_invsqrt_v2r8(rsq23);
2190             rinv31           = gmx_fjsp_invsqrt_v2r8(rsq31);
2191             rinv32           = gmx_fjsp_invsqrt_v2r8(rsq32);
2192             rinv33           = gmx_fjsp_invsqrt_v2r8(rsq33);
2193
2194             rinvsq00         = _fjsp_mul_v2r8(rinv00,rinv00);
2195             rinvsq11         = _fjsp_mul_v2r8(rinv11,rinv11);
2196             rinvsq12         = _fjsp_mul_v2r8(rinv12,rinv12);
2197             rinvsq13         = _fjsp_mul_v2r8(rinv13,rinv13);
2198             rinvsq21         = _fjsp_mul_v2r8(rinv21,rinv21);
2199             rinvsq22         = _fjsp_mul_v2r8(rinv22,rinv22);
2200             rinvsq23         = _fjsp_mul_v2r8(rinv23,rinv23);
2201             rinvsq31         = _fjsp_mul_v2r8(rinv31,rinv31);
2202             rinvsq32         = _fjsp_mul_v2r8(rinv32,rinv32);
2203             rinvsq33         = _fjsp_mul_v2r8(rinv33,rinv33);
2204
2205             fjx0             = _fjsp_setzero_v2r8();
2206             fjy0             = _fjsp_setzero_v2r8();
2207             fjz0             = _fjsp_setzero_v2r8();
2208             fjx1             = _fjsp_setzero_v2r8();
2209             fjy1             = _fjsp_setzero_v2r8();
2210             fjz1             = _fjsp_setzero_v2r8();
2211             fjx2             = _fjsp_setzero_v2r8();
2212             fjy2             = _fjsp_setzero_v2r8();
2213             fjz2             = _fjsp_setzero_v2r8();
2214             fjx3             = _fjsp_setzero_v2r8();
2215             fjy3             = _fjsp_setzero_v2r8();
2216             fjz3             = _fjsp_setzero_v2r8();
2217
2218             /**************************
2219              * CALCULATE INTERACTIONS *
2220              **************************/
2221
2222             if (gmx_fjsp_any_lt_v2r8(rsq00,rcutoff2))
2223             {
2224
2225             r00              = _fjsp_mul_v2r8(rsq00,rinv00);
2226
2227             /* Analytical LJ-PME */
2228             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
2229             ewcljrsq         = _fjsp_mul_v2r8(ewclj2,rsq00);
2230             ewclj6           = _fjsp_mul_v2r8(ewclj2,_fjsp_mul_v2r8(ewclj2,ewclj2));
2231             exponent         = gmx_simd_exp_d(-ewcljrsq);
2232             /* poly = exp(-(beta*r)^2) * (1 + (beta*r)^2 + (beta*r)^4 /2) */
2233             poly             = _fjsp_mul_v2r8(exponent,_fjsp_madd_v2r8(_fjsp_mul_v2r8(ewcljrsq,ewcljrsq),one_half,_fjsp_sub_v2r8(one,ewcljrsq)));
2234             /* f6A = 6 * C6grid * (1 - poly) */
2235             f6A              = _fjsp_mul_v2r8(c6grid_00,_fjsp_msub_v2r8(one,poly));
2236             /* f6B = C6grid * exponent * beta^6 */
2237             f6B              = _fjsp_mul_v2r8(_fjsp_mul_v2r8(c6grid_00,one_sixth),_fjsp_mul_v2r8(exponent,ewclj6));
2238             /* fvdw = 12*C12/r13 - ((6*C6 - f6A)/r6 + f6B)/r */
2239             fvdw              = _fjsp_mul_v2r8(_fjsp_madd_v2r8(_fjsp_msub_v2r8(c12_00,rinvsix,_fjsp_sub_v2r8(c6_00,f6A)),rinvsix,f6B),rinvsq00);
2240
2241             cutoff_mask      = _fjsp_cmplt_v2r8(rsq00,rcutoff2);
2242
2243             fscal            = fvdw;
2244
2245             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
2246
2247             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
2248
2249             /* Update vectorial force */
2250             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
2251             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
2252             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
2253             
2254             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
2255             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
2256             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
2257
2258             }
2259
2260             /**************************
2261              * CALCULATE INTERACTIONS *
2262              **************************/
2263
2264             if (gmx_fjsp_any_lt_v2r8(rsq11,rcutoff2))
2265             {
2266
2267             r11              = _fjsp_mul_v2r8(rsq11,rinv11);
2268
2269             /* EWALD ELECTROSTATICS */
2270
2271             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
2272             ewrt             = _fjsp_mul_v2r8(r11,ewtabscale);
2273             itab_tmp         = _fjsp_dtox_v2r8(ewrt);
2274             eweps            = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
2275             _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
2276
2277             gmx_fjsp_load_1pair_swizzle_v2r8(ewtab+ewconv.i[0],&ewtabF,&ewtabFn);
2278             felec            = _fjsp_madd_v2r8(eweps,ewtabFn,_fjsp_nmsub_v2r8(eweps,ewtabF,ewtabF));
2279             felec            = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq11,rinv11),_fjsp_sub_v2r8(rinvsq11,felec));
2280
2281             cutoff_mask      = _fjsp_cmplt_v2r8(rsq11,rcutoff2);
2282
2283             fscal            = felec;
2284
2285             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
2286
2287             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
2288
2289             /* Update vectorial force */
2290             fix1             = _fjsp_madd_v2r8(dx11,fscal,fix1);
2291             fiy1             = _fjsp_madd_v2r8(dy11,fscal,fiy1);
2292             fiz1             = _fjsp_madd_v2r8(dz11,fscal,fiz1);
2293             
2294             fjx1             = _fjsp_madd_v2r8(dx11,fscal,fjx1);
2295             fjy1             = _fjsp_madd_v2r8(dy11,fscal,fjy1);
2296             fjz1             = _fjsp_madd_v2r8(dz11,fscal,fjz1);
2297
2298             }
2299
2300             /**************************
2301              * CALCULATE INTERACTIONS *
2302              **************************/
2303
2304             if (gmx_fjsp_any_lt_v2r8(rsq12,rcutoff2))
2305             {
2306
2307             r12              = _fjsp_mul_v2r8(rsq12,rinv12);
2308
2309             /* EWALD ELECTROSTATICS */
2310
2311             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
2312             ewrt             = _fjsp_mul_v2r8(r12,ewtabscale);
2313             itab_tmp         = _fjsp_dtox_v2r8(ewrt);
2314             eweps            = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
2315             _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
2316
2317             gmx_fjsp_load_1pair_swizzle_v2r8(ewtab+ewconv.i[0],&ewtabF,&ewtabFn);
2318             felec            = _fjsp_madd_v2r8(eweps,ewtabFn,_fjsp_nmsub_v2r8(eweps,ewtabF,ewtabF));
2319             felec            = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq12,rinv12),_fjsp_sub_v2r8(rinvsq12,felec));
2320
2321             cutoff_mask      = _fjsp_cmplt_v2r8(rsq12,rcutoff2);
2322
2323             fscal            = felec;
2324
2325             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
2326
2327             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
2328
2329             /* Update vectorial force */
2330             fix1             = _fjsp_madd_v2r8(dx12,fscal,fix1);
2331             fiy1             = _fjsp_madd_v2r8(dy12,fscal,fiy1);
2332             fiz1             = _fjsp_madd_v2r8(dz12,fscal,fiz1);
2333             
2334             fjx2             = _fjsp_madd_v2r8(dx12,fscal,fjx2);
2335             fjy2             = _fjsp_madd_v2r8(dy12,fscal,fjy2);
2336             fjz2             = _fjsp_madd_v2r8(dz12,fscal,fjz2);
2337
2338             }
2339
2340             /**************************
2341              * CALCULATE INTERACTIONS *
2342              **************************/
2343
2344             if (gmx_fjsp_any_lt_v2r8(rsq13,rcutoff2))
2345             {
2346
2347             r13              = _fjsp_mul_v2r8(rsq13,rinv13);
2348
2349             /* EWALD ELECTROSTATICS */
2350
2351             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
2352             ewrt             = _fjsp_mul_v2r8(r13,ewtabscale);
2353             itab_tmp         = _fjsp_dtox_v2r8(ewrt);
2354             eweps            = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
2355             _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
2356
2357             gmx_fjsp_load_1pair_swizzle_v2r8(ewtab+ewconv.i[0],&ewtabF,&ewtabFn);
2358             felec            = _fjsp_madd_v2r8(eweps,ewtabFn,_fjsp_nmsub_v2r8(eweps,ewtabF,ewtabF));
2359             felec            = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq13,rinv13),_fjsp_sub_v2r8(rinvsq13,felec));
2360
2361             cutoff_mask      = _fjsp_cmplt_v2r8(rsq13,rcutoff2);
2362
2363             fscal            = felec;
2364
2365             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
2366
2367             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
2368
2369             /* Update vectorial force */
2370             fix1             = _fjsp_madd_v2r8(dx13,fscal,fix1);
2371             fiy1             = _fjsp_madd_v2r8(dy13,fscal,fiy1);
2372             fiz1             = _fjsp_madd_v2r8(dz13,fscal,fiz1);
2373             
2374             fjx3             = _fjsp_madd_v2r8(dx13,fscal,fjx3);
2375             fjy3             = _fjsp_madd_v2r8(dy13,fscal,fjy3);
2376             fjz3             = _fjsp_madd_v2r8(dz13,fscal,fjz3);
2377
2378             }
2379
2380             /**************************
2381              * CALCULATE INTERACTIONS *
2382              **************************/
2383
2384             if (gmx_fjsp_any_lt_v2r8(rsq21,rcutoff2))
2385             {
2386
2387             r21              = _fjsp_mul_v2r8(rsq21,rinv21);
2388
2389             /* EWALD ELECTROSTATICS */
2390
2391             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
2392             ewrt             = _fjsp_mul_v2r8(r21,ewtabscale);
2393             itab_tmp         = _fjsp_dtox_v2r8(ewrt);
2394             eweps            = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
2395             _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
2396
2397             gmx_fjsp_load_1pair_swizzle_v2r8(ewtab+ewconv.i[0],&ewtabF,&ewtabFn);
2398             felec            = _fjsp_madd_v2r8(eweps,ewtabFn,_fjsp_nmsub_v2r8(eweps,ewtabF,ewtabF));
2399             felec            = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq21,rinv21),_fjsp_sub_v2r8(rinvsq21,felec));
2400
2401             cutoff_mask      = _fjsp_cmplt_v2r8(rsq21,rcutoff2);
2402
2403             fscal            = felec;
2404
2405             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
2406
2407             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
2408
2409             /* Update vectorial force */
2410             fix2             = _fjsp_madd_v2r8(dx21,fscal,fix2);
2411             fiy2             = _fjsp_madd_v2r8(dy21,fscal,fiy2);
2412             fiz2             = _fjsp_madd_v2r8(dz21,fscal,fiz2);
2413             
2414             fjx1             = _fjsp_madd_v2r8(dx21,fscal,fjx1);
2415             fjy1             = _fjsp_madd_v2r8(dy21,fscal,fjy1);
2416             fjz1             = _fjsp_madd_v2r8(dz21,fscal,fjz1);
2417
2418             }
2419
2420             /**************************
2421              * CALCULATE INTERACTIONS *
2422              **************************/
2423
2424             if (gmx_fjsp_any_lt_v2r8(rsq22,rcutoff2))
2425             {
2426
2427             r22              = _fjsp_mul_v2r8(rsq22,rinv22);
2428
2429             /* EWALD ELECTROSTATICS */
2430
2431             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
2432             ewrt             = _fjsp_mul_v2r8(r22,ewtabscale);
2433             itab_tmp         = _fjsp_dtox_v2r8(ewrt);
2434             eweps            = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
2435             _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
2436
2437             gmx_fjsp_load_1pair_swizzle_v2r8(ewtab+ewconv.i[0],&ewtabF,&ewtabFn);
2438             felec            = _fjsp_madd_v2r8(eweps,ewtabFn,_fjsp_nmsub_v2r8(eweps,ewtabF,ewtabF));
2439             felec            = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq22,rinv22),_fjsp_sub_v2r8(rinvsq22,felec));
2440
2441             cutoff_mask      = _fjsp_cmplt_v2r8(rsq22,rcutoff2);
2442
2443             fscal            = felec;
2444
2445             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
2446
2447             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
2448
2449             /* Update vectorial force */
2450             fix2             = _fjsp_madd_v2r8(dx22,fscal,fix2);
2451             fiy2             = _fjsp_madd_v2r8(dy22,fscal,fiy2);
2452             fiz2             = _fjsp_madd_v2r8(dz22,fscal,fiz2);
2453             
2454             fjx2             = _fjsp_madd_v2r8(dx22,fscal,fjx2);
2455             fjy2             = _fjsp_madd_v2r8(dy22,fscal,fjy2);
2456             fjz2             = _fjsp_madd_v2r8(dz22,fscal,fjz2);
2457
2458             }
2459
2460             /**************************
2461              * CALCULATE INTERACTIONS *
2462              **************************/
2463
2464             if (gmx_fjsp_any_lt_v2r8(rsq23,rcutoff2))
2465             {
2466
2467             r23              = _fjsp_mul_v2r8(rsq23,rinv23);
2468
2469             /* EWALD ELECTROSTATICS */
2470
2471             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
2472             ewrt             = _fjsp_mul_v2r8(r23,ewtabscale);
2473             itab_tmp         = _fjsp_dtox_v2r8(ewrt);
2474             eweps            = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
2475             _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
2476
2477             gmx_fjsp_load_1pair_swizzle_v2r8(ewtab+ewconv.i[0],&ewtabF,&ewtabFn);
2478             felec            = _fjsp_madd_v2r8(eweps,ewtabFn,_fjsp_nmsub_v2r8(eweps,ewtabF,ewtabF));
2479             felec            = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq23,rinv23),_fjsp_sub_v2r8(rinvsq23,felec));
2480
2481             cutoff_mask      = _fjsp_cmplt_v2r8(rsq23,rcutoff2);
2482
2483             fscal            = felec;
2484
2485             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
2486
2487             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
2488
2489             /* Update vectorial force */
2490             fix2             = _fjsp_madd_v2r8(dx23,fscal,fix2);
2491             fiy2             = _fjsp_madd_v2r8(dy23,fscal,fiy2);
2492             fiz2             = _fjsp_madd_v2r8(dz23,fscal,fiz2);
2493             
2494             fjx3             = _fjsp_madd_v2r8(dx23,fscal,fjx3);
2495             fjy3             = _fjsp_madd_v2r8(dy23,fscal,fjy3);
2496             fjz3             = _fjsp_madd_v2r8(dz23,fscal,fjz3);
2497
2498             }
2499
2500             /**************************
2501              * CALCULATE INTERACTIONS *
2502              **************************/
2503
2504             if (gmx_fjsp_any_lt_v2r8(rsq31,rcutoff2))
2505             {
2506
2507             r31              = _fjsp_mul_v2r8(rsq31,rinv31);
2508
2509             /* EWALD ELECTROSTATICS */
2510
2511             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
2512             ewrt             = _fjsp_mul_v2r8(r31,ewtabscale);
2513             itab_tmp         = _fjsp_dtox_v2r8(ewrt);
2514             eweps            = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
2515             _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
2516
2517             gmx_fjsp_load_1pair_swizzle_v2r8(ewtab+ewconv.i[0],&ewtabF,&ewtabFn);
2518             felec            = _fjsp_madd_v2r8(eweps,ewtabFn,_fjsp_nmsub_v2r8(eweps,ewtabF,ewtabF));
2519             felec            = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq31,rinv31),_fjsp_sub_v2r8(rinvsq31,felec));
2520
2521             cutoff_mask      = _fjsp_cmplt_v2r8(rsq31,rcutoff2);
2522
2523             fscal            = felec;
2524
2525             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
2526
2527             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
2528
2529             /* Update vectorial force */
2530             fix3             = _fjsp_madd_v2r8(dx31,fscal,fix3);
2531             fiy3             = _fjsp_madd_v2r8(dy31,fscal,fiy3);
2532             fiz3             = _fjsp_madd_v2r8(dz31,fscal,fiz3);
2533             
2534             fjx1             = _fjsp_madd_v2r8(dx31,fscal,fjx1);
2535             fjy1             = _fjsp_madd_v2r8(dy31,fscal,fjy1);
2536             fjz1             = _fjsp_madd_v2r8(dz31,fscal,fjz1);
2537
2538             }
2539
2540             /**************************
2541              * CALCULATE INTERACTIONS *
2542              **************************/
2543
2544             if (gmx_fjsp_any_lt_v2r8(rsq32,rcutoff2))
2545             {
2546
2547             r32              = _fjsp_mul_v2r8(rsq32,rinv32);
2548
2549             /* EWALD ELECTROSTATICS */
2550
2551             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
2552             ewrt             = _fjsp_mul_v2r8(r32,ewtabscale);
2553             itab_tmp         = _fjsp_dtox_v2r8(ewrt);
2554             eweps            = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
2555             _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
2556
2557             gmx_fjsp_load_1pair_swizzle_v2r8(ewtab+ewconv.i[0],&ewtabF,&ewtabFn);
2558             felec            = _fjsp_madd_v2r8(eweps,ewtabFn,_fjsp_nmsub_v2r8(eweps,ewtabF,ewtabF));
2559             felec            = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq32,rinv32),_fjsp_sub_v2r8(rinvsq32,felec));
2560
2561             cutoff_mask      = _fjsp_cmplt_v2r8(rsq32,rcutoff2);
2562
2563             fscal            = felec;
2564
2565             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
2566
2567             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
2568
2569             /* Update vectorial force */
2570             fix3             = _fjsp_madd_v2r8(dx32,fscal,fix3);
2571             fiy3             = _fjsp_madd_v2r8(dy32,fscal,fiy3);
2572             fiz3             = _fjsp_madd_v2r8(dz32,fscal,fiz3);
2573             
2574             fjx2             = _fjsp_madd_v2r8(dx32,fscal,fjx2);
2575             fjy2             = _fjsp_madd_v2r8(dy32,fscal,fjy2);
2576             fjz2             = _fjsp_madd_v2r8(dz32,fscal,fjz2);
2577
2578             }
2579
2580             /**************************
2581              * CALCULATE INTERACTIONS *
2582              **************************/
2583
2584             if (gmx_fjsp_any_lt_v2r8(rsq33,rcutoff2))
2585             {
2586
2587             r33              = _fjsp_mul_v2r8(rsq33,rinv33);
2588
2589             /* EWALD ELECTROSTATICS */
2590
2591             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
2592             ewrt             = _fjsp_mul_v2r8(r33,ewtabscale);
2593             itab_tmp         = _fjsp_dtox_v2r8(ewrt);
2594             eweps            = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
2595             _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
2596
2597             gmx_fjsp_load_1pair_swizzle_v2r8(ewtab+ewconv.i[0],&ewtabF,&ewtabFn);
2598             felec            = _fjsp_madd_v2r8(eweps,ewtabFn,_fjsp_nmsub_v2r8(eweps,ewtabF,ewtabF));
2599             felec            = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq33,rinv33),_fjsp_sub_v2r8(rinvsq33,felec));
2600
2601             cutoff_mask      = _fjsp_cmplt_v2r8(rsq33,rcutoff2);
2602
2603             fscal            = felec;
2604
2605             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
2606
2607             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
2608
2609             /* Update vectorial force */
2610             fix3             = _fjsp_madd_v2r8(dx33,fscal,fix3);
2611             fiy3             = _fjsp_madd_v2r8(dy33,fscal,fiy3);
2612             fiz3             = _fjsp_madd_v2r8(dz33,fscal,fiz3);
2613             
2614             fjx3             = _fjsp_madd_v2r8(dx33,fscal,fjx3);
2615             fjy3             = _fjsp_madd_v2r8(dy33,fscal,fjy3);
2616             fjz3             = _fjsp_madd_v2r8(dz33,fscal,fjz3);
2617
2618             }
2619
2620             gmx_fjsp_decrement_4rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
2621
2622             /* Inner loop uses 432 flops */
2623         }
2624
2625         /* End of innermost loop */
2626
2627         gmx_fjsp_update_iforce_4atom_swizzle_v2r8(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
2628                                               f+i_coord_offset,fshift+i_shift_offset);
2629
2630         /* Increment number of inner iterations */
2631         inneriter                  += j_index_end - j_index_start;
2632
2633         /* Outer loop uses 24 flops */
2634     }
2635
2636     /* Increment number of outer iterations */
2637     outeriter        += nri;
2638
2639     /* Update outer/inner flops */
2640
2641     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*24 + inneriter*432);
2642 }