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