b1023ffdcd608ae49731c439fe06ba18a221745f
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_sparc64_hpc_ace_double / nb_kernel_ElecRFCut_VdwCSTab_GeomW4W4_sparc64_hpc_ace_double.c
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
5  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6  * and including many others, as listed in the AUTHORS file in the
7  * top-level source directory and at http://www.gromacs.org.
8  *
9  * GROMACS is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public License
11  * as published by the Free Software Foundation; either version 2.1
12  * of the License, or (at your option) any later version.
13  *
14  * GROMACS is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with GROMACS; if not, see
21  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
23  *
24  * If you want to redistribute modifications to GROMACS, please
25  * consider that scientific software is very special. Version
26  * control is crucial - bugs must be traceable. We will be happy to
27  * consider code for inclusion in the official distribution, but
28  * derived work must not be called official GROMACS. Details are found
29  * in the README & COPYING files - if they are missing, get the
30  * official version at http://www.gromacs.org.
31  *
32  * To help us fund GROMACS development, we humbly ask that you cite
33  * the research papers on the package. Check out http://www.gromacs.org.
34  */
35 /*
36  * Note: this file was generated by the GROMACS sparc64_hpc_ace_double kernel generator.
37  */
38 #include "config.h"
39
40 #include <math.h>
41
42 #include "../nb_kernel.h"
43 #include "types/simple.h"
44 #include "gromacs/math/vec.h"
45 #include "nrnb.h"
46
47 #include "kernelutil_sparc64_hpc_ace_double.h"
48
49 /*
50  * Gromacs nonbonded kernel:   nb_kernel_ElecRFCut_VdwCSTab_GeomW4W4_VF_sparc64_hpc_ace_double
51  * Electrostatics interaction: ReactionField
52  * VdW interaction:            CubicSplineTable
53  * Geometry:                   Water4-Water4
54  * Calculate force/pot:        PotentialAndForce
55  */
56 void
57 nb_kernel_ElecRFCut_VdwCSTab_GeomW4W4_VF_sparc64_hpc_ace_double
58                     (t_nblist                    * gmx_restrict       nlist,
59                      rvec                        * gmx_restrict          xx,
60                      rvec                        * gmx_restrict          ff,
61                      t_forcerec                  * gmx_restrict          fr,
62                      t_mdatoms                   * gmx_restrict     mdatoms,
63                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
64                      t_nrnb                      * gmx_restrict        nrnb)
65 {
66     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
67      * just 0 for non-waters.
68      * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
69      * jnr indices corresponding to data put in the four positions in the SIMD register.
70      */
71     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
72     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
73     int              jnrA,jnrB;
74     int              j_coord_offsetA,j_coord_offsetB;
75     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
76     real             rcutoff_scalar;
77     real             *shiftvec,*fshift,*x,*f;
78     _fjsp_v2r8       tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
79     int              vdwioffset0;
80     _fjsp_v2r8       ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
81     int              vdwioffset1;
82     _fjsp_v2r8       ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
83     int              vdwioffset2;
84     _fjsp_v2r8       ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
85     int              vdwioffset3;
86     _fjsp_v2r8       ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
87     int              vdwjidx0A,vdwjidx0B;
88     _fjsp_v2r8       jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
89     int              vdwjidx1A,vdwjidx1B;
90     _fjsp_v2r8       jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
91     int              vdwjidx2A,vdwjidx2B;
92     _fjsp_v2r8       jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
93     int              vdwjidx3A,vdwjidx3B;
94     _fjsp_v2r8       jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
95     _fjsp_v2r8       dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
96     _fjsp_v2r8       dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
97     _fjsp_v2r8       dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
98     _fjsp_v2r8       dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13;
99     _fjsp_v2r8       dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
100     _fjsp_v2r8       dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
101     _fjsp_v2r8       dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23;
102     _fjsp_v2r8       dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31;
103     _fjsp_v2r8       dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32;
104     _fjsp_v2r8       dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33;
105     _fjsp_v2r8       velec,felec,velecsum,facel,crf,krf,krf2;
106     real             *charge;
107     int              nvdwtype;
108     _fjsp_v2r8       rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
109     int              *vdwtype;
110     real             *vdwparam;
111     _fjsp_v2r8       one_sixth   = gmx_fjsp_set1_v2r8(1.0/6.0);
112     _fjsp_v2r8       one_twelfth = gmx_fjsp_set1_v2r8(1.0/12.0);
113     _fjsp_v2r8       rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF,twovfeps;
114     real             *vftab;
115     _fjsp_v2r8       itab_tmp;
116     _fjsp_v2r8       dummy_mask,cutoff_mask;
117     _fjsp_v2r8       one     = gmx_fjsp_set1_v2r8(1.0);
118     _fjsp_v2r8       two     = gmx_fjsp_set1_v2r8(2.0);
119     union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
120
121     x                = xx[0];
122     f                = ff[0];
123
124     nri              = nlist->nri;
125     iinr             = nlist->iinr;
126     jindex           = nlist->jindex;
127     jjnr             = nlist->jjnr;
128     shiftidx         = nlist->shift;
129     gid              = nlist->gid;
130     shiftvec         = fr->shift_vec[0];
131     fshift           = fr->fshift[0];
132     facel            = gmx_fjsp_set1_v2r8(fr->epsfac);
133     charge           = mdatoms->chargeA;
134     krf              = gmx_fjsp_set1_v2r8(fr->ic->k_rf);
135     krf2             = gmx_fjsp_set1_v2r8(fr->ic->k_rf*2.0);
136     crf              = gmx_fjsp_set1_v2r8(fr->ic->c_rf);
137     nvdwtype         = fr->ntype;
138     vdwparam         = fr->nbfp;
139     vdwtype          = mdatoms->typeA;
140
141     vftab            = kernel_data->table_vdw->data;
142     vftabscale       = gmx_fjsp_set1_v2r8(kernel_data->table_vdw->scale);
143
144     /* Setup water-specific parameters */
145     inr              = nlist->iinr[0];
146     iq1              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+1]));
147     iq2              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+2]));
148     iq3              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+3]));
149     vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
150
151     jq1              = gmx_fjsp_set1_v2r8(charge[inr+1]);
152     jq2              = gmx_fjsp_set1_v2r8(charge[inr+2]);
153     jq3              = gmx_fjsp_set1_v2r8(charge[inr+3]);
154     vdwjidx0A        = 2*vdwtype[inr+0];
155     c6_00            = gmx_fjsp_set1_v2r8(vdwparam[vdwioffset0+vdwjidx0A]);
156     c12_00           = gmx_fjsp_set1_v2r8(vdwparam[vdwioffset0+vdwjidx0A+1]);
157     qq11             = _fjsp_mul_v2r8(iq1,jq1);
158     qq12             = _fjsp_mul_v2r8(iq1,jq2);
159     qq13             = _fjsp_mul_v2r8(iq1,jq3);
160     qq21             = _fjsp_mul_v2r8(iq2,jq1);
161     qq22             = _fjsp_mul_v2r8(iq2,jq2);
162     qq23             = _fjsp_mul_v2r8(iq2,jq3);
163     qq31             = _fjsp_mul_v2r8(iq3,jq1);
164     qq32             = _fjsp_mul_v2r8(iq3,jq2);
165     qq33             = _fjsp_mul_v2r8(iq3,jq3);
166
167     /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
168     rcutoff_scalar   = fr->rcoulomb;
169     rcutoff          = gmx_fjsp_set1_v2r8(rcutoff_scalar);
170     rcutoff2         = _fjsp_mul_v2r8(rcutoff,rcutoff);
171
172     /* Avoid stupid compiler warnings */
173     jnrA = jnrB = 0;
174     j_coord_offsetA = 0;
175     j_coord_offsetB = 0;
176
177     outeriter        = 0;
178     inneriter        = 0;
179
180     /* Start outer loop over neighborlists */
181     for(iidx=0; iidx<nri; iidx++)
182     {
183         /* Load shift vector for this list */
184         i_shift_offset   = DIM*shiftidx[iidx];
185
186         /* Load limits for loop over neighbors */
187         j_index_start    = jindex[iidx];
188         j_index_end      = jindex[iidx+1];
189
190         /* Get outer coordinate index */
191         inr              = iinr[iidx];
192         i_coord_offset   = DIM*inr;
193
194         /* Load i particle coords and add shift vector */
195         gmx_fjsp_load_shift_and_4rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,
196                                                  &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
197
198         fix0             = _fjsp_setzero_v2r8();
199         fiy0             = _fjsp_setzero_v2r8();
200         fiz0             = _fjsp_setzero_v2r8();
201         fix1             = _fjsp_setzero_v2r8();
202         fiy1             = _fjsp_setzero_v2r8();
203         fiz1             = _fjsp_setzero_v2r8();
204         fix2             = _fjsp_setzero_v2r8();
205         fiy2             = _fjsp_setzero_v2r8();
206         fiz2             = _fjsp_setzero_v2r8();
207         fix3             = _fjsp_setzero_v2r8();
208         fiy3             = _fjsp_setzero_v2r8();
209         fiz3             = _fjsp_setzero_v2r8();
210
211         /* Reset potential sums */
212         velecsum         = _fjsp_setzero_v2r8();
213         vvdwsum          = _fjsp_setzero_v2r8();
214
215         /* Start inner kernel loop */
216         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
217         {
218
219             /* Get j neighbor index, and coordinate index */
220             jnrA             = jjnr[jidx];
221             jnrB             = jjnr[jidx+1];
222             j_coord_offsetA  = DIM*jnrA;
223             j_coord_offsetB  = DIM*jnrB;
224
225             /* load j atom coordinates */
226             gmx_fjsp_load_4rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
227                                               &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,
228                                               &jy2,&jz2,&jx3,&jy3,&jz3);
229
230             /* Calculate displacement vector */
231             dx00             = _fjsp_sub_v2r8(ix0,jx0);
232             dy00             = _fjsp_sub_v2r8(iy0,jy0);
233             dz00             = _fjsp_sub_v2r8(iz0,jz0);
234             dx11             = _fjsp_sub_v2r8(ix1,jx1);
235             dy11             = _fjsp_sub_v2r8(iy1,jy1);
236             dz11             = _fjsp_sub_v2r8(iz1,jz1);
237             dx12             = _fjsp_sub_v2r8(ix1,jx2);
238             dy12             = _fjsp_sub_v2r8(iy1,jy2);
239             dz12             = _fjsp_sub_v2r8(iz1,jz2);
240             dx13             = _fjsp_sub_v2r8(ix1,jx3);
241             dy13             = _fjsp_sub_v2r8(iy1,jy3);
242             dz13             = _fjsp_sub_v2r8(iz1,jz3);
243             dx21             = _fjsp_sub_v2r8(ix2,jx1);
244             dy21             = _fjsp_sub_v2r8(iy2,jy1);
245             dz21             = _fjsp_sub_v2r8(iz2,jz1);
246             dx22             = _fjsp_sub_v2r8(ix2,jx2);
247             dy22             = _fjsp_sub_v2r8(iy2,jy2);
248             dz22             = _fjsp_sub_v2r8(iz2,jz2);
249             dx23             = _fjsp_sub_v2r8(ix2,jx3);
250             dy23             = _fjsp_sub_v2r8(iy2,jy3);
251             dz23             = _fjsp_sub_v2r8(iz2,jz3);
252             dx31             = _fjsp_sub_v2r8(ix3,jx1);
253             dy31             = _fjsp_sub_v2r8(iy3,jy1);
254             dz31             = _fjsp_sub_v2r8(iz3,jz1);
255             dx32             = _fjsp_sub_v2r8(ix3,jx2);
256             dy32             = _fjsp_sub_v2r8(iy3,jy2);
257             dz32             = _fjsp_sub_v2r8(iz3,jz2);
258             dx33             = _fjsp_sub_v2r8(ix3,jx3);
259             dy33             = _fjsp_sub_v2r8(iy3,jy3);
260             dz33             = _fjsp_sub_v2r8(iz3,jz3);
261
262             /* Calculate squared distance and things based on it */
263             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
264             rsq11            = gmx_fjsp_calc_rsq_v2r8(dx11,dy11,dz11);
265             rsq12            = gmx_fjsp_calc_rsq_v2r8(dx12,dy12,dz12);
266             rsq13            = gmx_fjsp_calc_rsq_v2r8(dx13,dy13,dz13);
267             rsq21            = gmx_fjsp_calc_rsq_v2r8(dx21,dy21,dz21);
268             rsq22            = gmx_fjsp_calc_rsq_v2r8(dx22,dy22,dz22);
269             rsq23            = gmx_fjsp_calc_rsq_v2r8(dx23,dy23,dz23);
270             rsq31            = gmx_fjsp_calc_rsq_v2r8(dx31,dy31,dz31);
271             rsq32            = gmx_fjsp_calc_rsq_v2r8(dx32,dy32,dz32);
272             rsq33            = gmx_fjsp_calc_rsq_v2r8(dx33,dy33,dz33);
273
274             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
275             rinv11           = gmx_fjsp_invsqrt_v2r8(rsq11);
276             rinv12           = gmx_fjsp_invsqrt_v2r8(rsq12);
277             rinv13           = gmx_fjsp_invsqrt_v2r8(rsq13);
278             rinv21           = gmx_fjsp_invsqrt_v2r8(rsq21);
279             rinv22           = gmx_fjsp_invsqrt_v2r8(rsq22);
280             rinv23           = gmx_fjsp_invsqrt_v2r8(rsq23);
281             rinv31           = gmx_fjsp_invsqrt_v2r8(rsq31);
282             rinv32           = gmx_fjsp_invsqrt_v2r8(rsq32);
283             rinv33           = gmx_fjsp_invsqrt_v2r8(rsq33);
284
285             rinvsq11         = _fjsp_mul_v2r8(rinv11,rinv11);
286             rinvsq12         = _fjsp_mul_v2r8(rinv12,rinv12);
287             rinvsq13         = _fjsp_mul_v2r8(rinv13,rinv13);
288             rinvsq21         = _fjsp_mul_v2r8(rinv21,rinv21);
289             rinvsq22         = _fjsp_mul_v2r8(rinv22,rinv22);
290             rinvsq23         = _fjsp_mul_v2r8(rinv23,rinv23);
291             rinvsq31         = _fjsp_mul_v2r8(rinv31,rinv31);
292             rinvsq32         = _fjsp_mul_v2r8(rinv32,rinv32);
293             rinvsq33         = _fjsp_mul_v2r8(rinv33,rinv33);
294
295             fjx0             = _fjsp_setzero_v2r8();
296             fjy0             = _fjsp_setzero_v2r8();
297             fjz0             = _fjsp_setzero_v2r8();
298             fjx1             = _fjsp_setzero_v2r8();
299             fjy1             = _fjsp_setzero_v2r8();
300             fjz1             = _fjsp_setzero_v2r8();
301             fjx2             = _fjsp_setzero_v2r8();
302             fjy2             = _fjsp_setzero_v2r8();
303             fjz2             = _fjsp_setzero_v2r8();
304             fjx3             = _fjsp_setzero_v2r8();
305             fjy3             = _fjsp_setzero_v2r8();
306             fjz3             = _fjsp_setzero_v2r8();
307
308             /**************************
309              * CALCULATE INTERACTIONS *
310              **************************/
311
312             r00              = _fjsp_mul_v2r8(rsq00,rinv00);
313
314             /* Calculate table index by multiplying r with table scale and truncate to integer */
315             rt               = _fjsp_mul_v2r8(r00,vftabscale);
316             itab_tmp         = _fjsp_dtox_v2r8(rt);
317             vfeps            = _fjsp_sub_v2r8(rt, _fjsp_xtod_v2r8(itab_tmp));
318             twovfeps         = _fjsp_add_v2r8(vfeps,vfeps);
319             _fjsp_store_v2r8(&vfconv.simd,itab_tmp);
320
321             vfconv.i[0]     *= 8;
322             vfconv.i[1]     *= 8;
323
324             /* CUBIC SPLINE TABLE DISPERSION */
325             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] );
326             F                = _fjsp_load_v2r8( vftab + vfconv.i[1] );
327             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
328             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 2 );
329             H                = _fjsp_load_v2r8( vftab + vfconv.i[1] + 2 );
330             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
331             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
332             VV               = _fjsp_madd_v2r8(vfeps,Fp,Y);
333             vvdw6            = _fjsp_mul_v2r8(c6_00,VV);
334             FF               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
335             fvdw6            = _fjsp_mul_v2r8(c6_00,FF);
336
337             /* CUBIC SPLINE TABLE REPULSION */
338             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 4 );
339             F                = _fjsp_load_v2r8( vftab + vfconv.i[1] + 4 );
340             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
341             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 6 );
342             H                = _fjsp_load_v2r8( vftab + vfconv.i[1] + 6 );
343             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
344             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
345             VV               = _fjsp_madd_v2r8(vfeps,Fp,Y);
346             vvdw12           = _fjsp_mul_v2r8(c12_00,VV);
347             FF               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
348             fvdw12           = _fjsp_mul_v2r8(c12_00,FF);
349             vvdw             = _fjsp_add_v2r8(vvdw12,vvdw6);
350             fvdw             = _fjsp_neg_v2r8(_fjsp_mul_v2r8(_fjsp_add_v2r8(fvdw6,fvdw12),_fjsp_mul_v2r8(vftabscale,rinv00)));
351
352             /* Update potential sum for this i atom from the interaction with this j atom. */
353             vvdwsum          = _fjsp_add_v2r8(vvdwsum,vvdw);
354
355             fscal            = fvdw;
356
357             /* Update vectorial force */
358             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
359             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
360             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
361             
362             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
363             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
364             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
365
366             /**************************
367              * CALCULATE INTERACTIONS *
368              **************************/
369
370             if (gmx_fjsp_any_lt_v2r8(rsq11,rcutoff2))
371             {
372
373             /* REACTION-FIELD ELECTROSTATICS */
374             velec            = _fjsp_mul_v2r8(qq11,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq11,rinv11),crf));
375             felec            = _fjsp_mul_v2r8(qq11,_fjsp_msub_v2r8(rinv11,rinvsq11,krf2));
376
377             cutoff_mask      = _fjsp_cmplt_v2r8(rsq11,rcutoff2);
378
379             /* Update potential sum for this i atom from the interaction with this j atom. */
380             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
381             velecsum         = _fjsp_add_v2r8(velecsum,velec);
382
383             fscal            = felec;
384
385             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
386
387             /* Update vectorial force */
388             fix1             = _fjsp_madd_v2r8(dx11,fscal,fix1);
389             fiy1             = _fjsp_madd_v2r8(dy11,fscal,fiy1);
390             fiz1             = _fjsp_madd_v2r8(dz11,fscal,fiz1);
391             
392             fjx1             = _fjsp_madd_v2r8(dx11,fscal,fjx1);
393             fjy1             = _fjsp_madd_v2r8(dy11,fscal,fjy1);
394             fjz1             = _fjsp_madd_v2r8(dz11,fscal,fjz1);
395
396             }
397
398             /**************************
399              * CALCULATE INTERACTIONS *
400              **************************/
401
402             if (gmx_fjsp_any_lt_v2r8(rsq12,rcutoff2))
403             {
404
405             /* REACTION-FIELD ELECTROSTATICS */
406             velec            = _fjsp_mul_v2r8(qq12,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq12,rinv12),crf));
407             felec            = _fjsp_mul_v2r8(qq12,_fjsp_msub_v2r8(rinv12,rinvsq12,krf2));
408
409             cutoff_mask      = _fjsp_cmplt_v2r8(rsq12,rcutoff2);
410
411             /* Update potential sum for this i atom from the interaction with this j atom. */
412             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
413             velecsum         = _fjsp_add_v2r8(velecsum,velec);
414
415             fscal            = felec;
416
417             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
418
419             /* Update vectorial force */
420             fix1             = _fjsp_madd_v2r8(dx12,fscal,fix1);
421             fiy1             = _fjsp_madd_v2r8(dy12,fscal,fiy1);
422             fiz1             = _fjsp_madd_v2r8(dz12,fscal,fiz1);
423             
424             fjx2             = _fjsp_madd_v2r8(dx12,fscal,fjx2);
425             fjy2             = _fjsp_madd_v2r8(dy12,fscal,fjy2);
426             fjz2             = _fjsp_madd_v2r8(dz12,fscal,fjz2);
427
428             }
429
430             /**************************
431              * CALCULATE INTERACTIONS *
432              **************************/
433
434             if (gmx_fjsp_any_lt_v2r8(rsq13,rcutoff2))
435             {
436
437             /* REACTION-FIELD ELECTROSTATICS */
438             velec            = _fjsp_mul_v2r8(qq13,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq13,rinv13),crf));
439             felec            = _fjsp_mul_v2r8(qq13,_fjsp_msub_v2r8(rinv13,rinvsq13,krf2));
440
441             cutoff_mask      = _fjsp_cmplt_v2r8(rsq13,rcutoff2);
442
443             /* Update potential sum for this i atom from the interaction with this j atom. */
444             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
445             velecsum         = _fjsp_add_v2r8(velecsum,velec);
446
447             fscal            = felec;
448
449             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
450
451             /* Update vectorial force */
452             fix1             = _fjsp_madd_v2r8(dx13,fscal,fix1);
453             fiy1             = _fjsp_madd_v2r8(dy13,fscal,fiy1);
454             fiz1             = _fjsp_madd_v2r8(dz13,fscal,fiz1);
455             
456             fjx3             = _fjsp_madd_v2r8(dx13,fscal,fjx3);
457             fjy3             = _fjsp_madd_v2r8(dy13,fscal,fjy3);
458             fjz3             = _fjsp_madd_v2r8(dz13,fscal,fjz3);
459
460             }
461
462             /**************************
463              * CALCULATE INTERACTIONS *
464              **************************/
465
466             if (gmx_fjsp_any_lt_v2r8(rsq21,rcutoff2))
467             {
468
469             /* REACTION-FIELD ELECTROSTATICS */
470             velec            = _fjsp_mul_v2r8(qq21,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq21,rinv21),crf));
471             felec            = _fjsp_mul_v2r8(qq21,_fjsp_msub_v2r8(rinv21,rinvsq21,krf2));
472
473             cutoff_mask      = _fjsp_cmplt_v2r8(rsq21,rcutoff2);
474
475             /* Update potential sum for this i atom from the interaction with this j atom. */
476             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
477             velecsum         = _fjsp_add_v2r8(velecsum,velec);
478
479             fscal            = felec;
480
481             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
482
483             /* Update vectorial force */
484             fix2             = _fjsp_madd_v2r8(dx21,fscal,fix2);
485             fiy2             = _fjsp_madd_v2r8(dy21,fscal,fiy2);
486             fiz2             = _fjsp_madd_v2r8(dz21,fscal,fiz2);
487             
488             fjx1             = _fjsp_madd_v2r8(dx21,fscal,fjx1);
489             fjy1             = _fjsp_madd_v2r8(dy21,fscal,fjy1);
490             fjz1             = _fjsp_madd_v2r8(dz21,fscal,fjz1);
491
492             }
493
494             /**************************
495              * CALCULATE INTERACTIONS *
496              **************************/
497
498             if (gmx_fjsp_any_lt_v2r8(rsq22,rcutoff2))
499             {
500
501             /* REACTION-FIELD ELECTROSTATICS */
502             velec            = _fjsp_mul_v2r8(qq22,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq22,rinv22),crf));
503             felec            = _fjsp_mul_v2r8(qq22,_fjsp_msub_v2r8(rinv22,rinvsq22,krf2));
504
505             cutoff_mask      = _fjsp_cmplt_v2r8(rsq22,rcutoff2);
506
507             /* Update potential sum for this i atom from the interaction with this j atom. */
508             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
509             velecsum         = _fjsp_add_v2r8(velecsum,velec);
510
511             fscal            = felec;
512
513             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
514
515             /* Update vectorial force */
516             fix2             = _fjsp_madd_v2r8(dx22,fscal,fix2);
517             fiy2             = _fjsp_madd_v2r8(dy22,fscal,fiy2);
518             fiz2             = _fjsp_madd_v2r8(dz22,fscal,fiz2);
519             
520             fjx2             = _fjsp_madd_v2r8(dx22,fscal,fjx2);
521             fjy2             = _fjsp_madd_v2r8(dy22,fscal,fjy2);
522             fjz2             = _fjsp_madd_v2r8(dz22,fscal,fjz2);
523
524             }
525
526             /**************************
527              * CALCULATE INTERACTIONS *
528              **************************/
529
530             if (gmx_fjsp_any_lt_v2r8(rsq23,rcutoff2))
531             {
532
533             /* REACTION-FIELD ELECTROSTATICS */
534             velec            = _fjsp_mul_v2r8(qq23,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq23,rinv23),crf));
535             felec            = _fjsp_mul_v2r8(qq23,_fjsp_msub_v2r8(rinv23,rinvsq23,krf2));
536
537             cutoff_mask      = _fjsp_cmplt_v2r8(rsq23,rcutoff2);
538
539             /* Update potential sum for this i atom from the interaction with this j atom. */
540             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
541             velecsum         = _fjsp_add_v2r8(velecsum,velec);
542
543             fscal            = felec;
544
545             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
546
547             /* Update vectorial force */
548             fix2             = _fjsp_madd_v2r8(dx23,fscal,fix2);
549             fiy2             = _fjsp_madd_v2r8(dy23,fscal,fiy2);
550             fiz2             = _fjsp_madd_v2r8(dz23,fscal,fiz2);
551             
552             fjx3             = _fjsp_madd_v2r8(dx23,fscal,fjx3);
553             fjy3             = _fjsp_madd_v2r8(dy23,fscal,fjy3);
554             fjz3             = _fjsp_madd_v2r8(dz23,fscal,fjz3);
555
556             }
557
558             /**************************
559              * CALCULATE INTERACTIONS *
560              **************************/
561
562             if (gmx_fjsp_any_lt_v2r8(rsq31,rcutoff2))
563             {
564
565             /* REACTION-FIELD ELECTROSTATICS */
566             velec            = _fjsp_mul_v2r8(qq31,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq31,rinv31),crf));
567             felec            = _fjsp_mul_v2r8(qq31,_fjsp_msub_v2r8(rinv31,rinvsq31,krf2));
568
569             cutoff_mask      = _fjsp_cmplt_v2r8(rsq31,rcutoff2);
570
571             /* Update potential sum for this i atom from the interaction with this j atom. */
572             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
573             velecsum         = _fjsp_add_v2r8(velecsum,velec);
574
575             fscal            = felec;
576
577             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
578
579             /* Update vectorial force */
580             fix3             = _fjsp_madd_v2r8(dx31,fscal,fix3);
581             fiy3             = _fjsp_madd_v2r8(dy31,fscal,fiy3);
582             fiz3             = _fjsp_madd_v2r8(dz31,fscal,fiz3);
583             
584             fjx1             = _fjsp_madd_v2r8(dx31,fscal,fjx1);
585             fjy1             = _fjsp_madd_v2r8(dy31,fscal,fjy1);
586             fjz1             = _fjsp_madd_v2r8(dz31,fscal,fjz1);
587
588             }
589
590             /**************************
591              * CALCULATE INTERACTIONS *
592              **************************/
593
594             if (gmx_fjsp_any_lt_v2r8(rsq32,rcutoff2))
595             {
596
597             /* REACTION-FIELD ELECTROSTATICS */
598             velec            = _fjsp_mul_v2r8(qq32,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq32,rinv32),crf));
599             felec            = _fjsp_mul_v2r8(qq32,_fjsp_msub_v2r8(rinv32,rinvsq32,krf2));
600
601             cutoff_mask      = _fjsp_cmplt_v2r8(rsq32,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             fix3             = _fjsp_madd_v2r8(dx32,fscal,fix3);
613             fiy3             = _fjsp_madd_v2r8(dy32,fscal,fiy3);
614             fiz3             = _fjsp_madd_v2r8(dz32,fscal,fiz3);
615             
616             fjx2             = _fjsp_madd_v2r8(dx32,fscal,fjx2);
617             fjy2             = _fjsp_madd_v2r8(dy32,fscal,fjy2);
618             fjz2             = _fjsp_madd_v2r8(dz32,fscal,fjz2);
619
620             }
621
622             /**************************
623              * CALCULATE INTERACTIONS *
624              **************************/
625
626             if (gmx_fjsp_any_lt_v2r8(rsq33,rcutoff2))
627             {
628
629             /* REACTION-FIELD ELECTROSTATICS */
630             velec            = _fjsp_mul_v2r8(qq33,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq33,rinv33),crf));
631             felec            = _fjsp_mul_v2r8(qq33,_fjsp_msub_v2r8(rinv33,rinvsq33,krf2));
632
633             cutoff_mask      = _fjsp_cmplt_v2r8(rsq33,rcutoff2);
634
635             /* Update potential sum for this i atom from the interaction with this j atom. */
636             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
637             velecsum         = _fjsp_add_v2r8(velecsum,velec);
638
639             fscal            = felec;
640
641             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
642
643             /* Update vectorial force */
644             fix3             = _fjsp_madd_v2r8(dx33,fscal,fix3);
645             fiy3             = _fjsp_madd_v2r8(dy33,fscal,fiy3);
646             fiz3             = _fjsp_madd_v2r8(dz33,fscal,fiz3);
647             
648             fjx3             = _fjsp_madd_v2r8(dx33,fscal,fjx3);
649             fjy3             = _fjsp_madd_v2r8(dy33,fscal,fjy3);
650             fjz3             = _fjsp_madd_v2r8(dz33,fscal,fjz3);
651
652             }
653
654             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);
655
656             /* Inner loop uses 413 flops */
657         }
658
659         if(jidx<j_index_end)
660         {
661
662             jnrA             = jjnr[jidx];
663             j_coord_offsetA  = DIM*jnrA;
664
665             /* load j atom coordinates */
666             gmx_fjsp_load_4rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
667                                               &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,
668                                               &jy2,&jz2,&jx3,&jy3,&jz3);
669
670             /* Calculate displacement vector */
671             dx00             = _fjsp_sub_v2r8(ix0,jx0);
672             dy00             = _fjsp_sub_v2r8(iy0,jy0);
673             dz00             = _fjsp_sub_v2r8(iz0,jz0);
674             dx11             = _fjsp_sub_v2r8(ix1,jx1);
675             dy11             = _fjsp_sub_v2r8(iy1,jy1);
676             dz11             = _fjsp_sub_v2r8(iz1,jz1);
677             dx12             = _fjsp_sub_v2r8(ix1,jx2);
678             dy12             = _fjsp_sub_v2r8(iy1,jy2);
679             dz12             = _fjsp_sub_v2r8(iz1,jz2);
680             dx13             = _fjsp_sub_v2r8(ix1,jx3);
681             dy13             = _fjsp_sub_v2r8(iy1,jy3);
682             dz13             = _fjsp_sub_v2r8(iz1,jz3);
683             dx21             = _fjsp_sub_v2r8(ix2,jx1);
684             dy21             = _fjsp_sub_v2r8(iy2,jy1);
685             dz21             = _fjsp_sub_v2r8(iz2,jz1);
686             dx22             = _fjsp_sub_v2r8(ix2,jx2);
687             dy22             = _fjsp_sub_v2r8(iy2,jy2);
688             dz22             = _fjsp_sub_v2r8(iz2,jz2);
689             dx23             = _fjsp_sub_v2r8(ix2,jx3);
690             dy23             = _fjsp_sub_v2r8(iy2,jy3);
691             dz23             = _fjsp_sub_v2r8(iz2,jz3);
692             dx31             = _fjsp_sub_v2r8(ix3,jx1);
693             dy31             = _fjsp_sub_v2r8(iy3,jy1);
694             dz31             = _fjsp_sub_v2r8(iz3,jz1);
695             dx32             = _fjsp_sub_v2r8(ix3,jx2);
696             dy32             = _fjsp_sub_v2r8(iy3,jy2);
697             dz32             = _fjsp_sub_v2r8(iz3,jz2);
698             dx33             = _fjsp_sub_v2r8(ix3,jx3);
699             dy33             = _fjsp_sub_v2r8(iy3,jy3);
700             dz33             = _fjsp_sub_v2r8(iz3,jz3);
701
702             /* Calculate squared distance and things based on it */
703             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
704             rsq11            = gmx_fjsp_calc_rsq_v2r8(dx11,dy11,dz11);
705             rsq12            = gmx_fjsp_calc_rsq_v2r8(dx12,dy12,dz12);
706             rsq13            = gmx_fjsp_calc_rsq_v2r8(dx13,dy13,dz13);
707             rsq21            = gmx_fjsp_calc_rsq_v2r8(dx21,dy21,dz21);
708             rsq22            = gmx_fjsp_calc_rsq_v2r8(dx22,dy22,dz22);
709             rsq23            = gmx_fjsp_calc_rsq_v2r8(dx23,dy23,dz23);
710             rsq31            = gmx_fjsp_calc_rsq_v2r8(dx31,dy31,dz31);
711             rsq32            = gmx_fjsp_calc_rsq_v2r8(dx32,dy32,dz32);
712             rsq33            = gmx_fjsp_calc_rsq_v2r8(dx33,dy33,dz33);
713
714             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
715             rinv11           = gmx_fjsp_invsqrt_v2r8(rsq11);
716             rinv12           = gmx_fjsp_invsqrt_v2r8(rsq12);
717             rinv13           = gmx_fjsp_invsqrt_v2r8(rsq13);
718             rinv21           = gmx_fjsp_invsqrt_v2r8(rsq21);
719             rinv22           = gmx_fjsp_invsqrt_v2r8(rsq22);
720             rinv23           = gmx_fjsp_invsqrt_v2r8(rsq23);
721             rinv31           = gmx_fjsp_invsqrt_v2r8(rsq31);
722             rinv32           = gmx_fjsp_invsqrt_v2r8(rsq32);
723             rinv33           = gmx_fjsp_invsqrt_v2r8(rsq33);
724
725             rinvsq11         = _fjsp_mul_v2r8(rinv11,rinv11);
726             rinvsq12         = _fjsp_mul_v2r8(rinv12,rinv12);
727             rinvsq13         = _fjsp_mul_v2r8(rinv13,rinv13);
728             rinvsq21         = _fjsp_mul_v2r8(rinv21,rinv21);
729             rinvsq22         = _fjsp_mul_v2r8(rinv22,rinv22);
730             rinvsq23         = _fjsp_mul_v2r8(rinv23,rinv23);
731             rinvsq31         = _fjsp_mul_v2r8(rinv31,rinv31);
732             rinvsq32         = _fjsp_mul_v2r8(rinv32,rinv32);
733             rinvsq33         = _fjsp_mul_v2r8(rinv33,rinv33);
734
735             fjx0             = _fjsp_setzero_v2r8();
736             fjy0             = _fjsp_setzero_v2r8();
737             fjz0             = _fjsp_setzero_v2r8();
738             fjx1             = _fjsp_setzero_v2r8();
739             fjy1             = _fjsp_setzero_v2r8();
740             fjz1             = _fjsp_setzero_v2r8();
741             fjx2             = _fjsp_setzero_v2r8();
742             fjy2             = _fjsp_setzero_v2r8();
743             fjz2             = _fjsp_setzero_v2r8();
744             fjx3             = _fjsp_setzero_v2r8();
745             fjy3             = _fjsp_setzero_v2r8();
746             fjz3             = _fjsp_setzero_v2r8();
747
748             /**************************
749              * CALCULATE INTERACTIONS *
750              **************************/
751
752             r00              = _fjsp_mul_v2r8(rsq00,rinv00);
753
754             /* Calculate table index by multiplying r with table scale and truncate to integer */
755             rt               = _fjsp_mul_v2r8(r00,vftabscale);
756             itab_tmp         = _fjsp_dtox_v2r8(rt);
757             vfeps            = _fjsp_sub_v2r8(rt, _fjsp_xtod_v2r8(itab_tmp));
758             twovfeps         = _fjsp_add_v2r8(vfeps,vfeps);
759             _fjsp_store_v2r8(&vfconv.simd,itab_tmp);
760
761             vfconv.i[0]     *= 8;
762             vfconv.i[1]     *= 8;
763
764             /* CUBIC SPLINE TABLE DISPERSION */
765             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] );
766             F                = _fjsp_setzero_v2r8();
767             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
768             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 2 );
769             H                = _fjsp_setzero_v2r8();
770             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
771             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
772             VV               = _fjsp_madd_v2r8(vfeps,Fp,Y);
773             vvdw6            = _fjsp_mul_v2r8(c6_00,VV);
774             FF               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
775             fvdw6            = _fjsp_mul_v2r8(c6_00,FF);
776
777             /* CUBIC SPLINE TABLE REPULSION */
778             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 4 );
779             F                = _fjsp_setzero_v2r8();
780             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
781             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 6 );
782             H                = _fjsp_setzero_v2r8();
783             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
784             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
785             VV               = _fjsp_madd_v2r8(vfeps,Fp,Y);
786             vvdw12           = _fjsp_mul_v2r8(c12_00,VV);
787             FF               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
788             fvdw12           = _fjsp_mul_v2r8(c12_00,FF);
789             vvdw             = _fjsp_add_v2r8(vvdw12,vvdw6);
790             fvdw             = _fjsp_neg_v2r8(_fjsp_mul_v2r8(_fjsp_add_v2r8(fvdw6,fvdw12),_fjsp_mul_v2r8(vftabscale,rinv00)));
791
792             /* Update potential sum for this i atom from the interaction with this j atom. */
793             vvdw             = _fjsp_unpacklo_v2r8(vvdw,_fjsp_setzero_v2r8());
794             vvdwsum          = _fjsp_add_v2r8(vvdwsum,vvdw);
795
796             fscal            = fvdw;
797
798             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
799
800             /* Update vectorial force */
801             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
802             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
803             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
804             
805             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
806             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
807             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
808
809             /**************************
810              * CALCULATE INTERACTIONS *
811              **************************/
812
813             if (gmx_fjsp_any_lt_v2r8(rsq11,rcutoff2))
814             {
815
816             /* REACTION-FIELD ELECTROSTATICS */
817             velec            = _fjsp_mul_v2r8(qq11,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq11,rinv11),crf));
818             felec            = _fjsp_mul_v2r8(qq11,_fjsp_msub_v2r8(rinv11,rinvsq11,krf2));
819
820             cutoff_mask      = _fjsp_cmplt_v2r8(rsq11,rcutoff2);
821
822             /* Update potential sum for this i atom from the interaction with this j atom. */
823             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
824             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
825             velecsum         = _fjsp_add_v2r8(velecsum,velec);
826
827             fscal            = felec;
828
829             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
830
831             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
832
833             /* Update vectorial force */
834             fix1             = _fjsp_madd_v2r8(dx11,fscal,fix1);
835             fiy1             = _fjsp_madd_v2r8(dy11,fscal,fiy1);
836             fiz1             = _fjsp_madd_v2r8(dz11,fscal,fiz1);
837             
838             fjx1             = _fjsp_madd_v2r8(dx11,fscal,fjx1);
839             fjy1             = _fjsp_madd_v2r8(dy11,fscal,fjy1);
840             fjz1             = _fjsp_madd_v2r8(dz11,fscal,fjz1);
841
842             }
843
844             /**************************
845              * CALCULATE INTERACTIONS *
846              **************************/
847
848             if (gmx_fjsp_any_lt_v2r8(rsq12,rcutoff2))
849             {
850
851             /* REACTION-FIELD ELECTROSTATICS */
852             velec            = _fjsp_mul_v2r8(qq12,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq12,rinv12),crf));
853             felec            = _fjsp_mul_v2r8(qq12,_fjsp_msub_v2r8(rinv12,rinvsq12,krf2));
854
855             cutoff_mask      = _fjsp_cmplt_v2r8(rsq12,rcutoff2);
856
857             /* Update potential sum for this i atom from the interaction with this j atom. */
858             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
859             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
860             velecsum         = _fjsp_add_v2r8(velecsum,velec);
861
862             fscal            = felec;
863
864             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
865
866             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
867
868             /* Update vectorial force */
869             fix1             = _fjsp_madd_v2r8(dx12,fscal,fix1);
870             fiy1             = _fjsp_madd_v2r8(dy12,fscal,fiy1);
871             fiz1             = _fjsp_madd_v2r8(dz12,fscal,fiz1);
872             
873             fjx2             = _fjsp_madd_v2r8(dx12,fscal,fjx2);
874             fjy2             = _fjsp_madd_v2r8(dy12,fscal,fjy2);
875             fjz2             = _fjsp_madd_v2r8(dz12,fscal,fjz2);
876
877             }
878
879             /**************************
880              * CALCULATE INTERACTIONS *
881              **************************/
882
883             if (gmx_fjsp_any_lt_v2r8(rsq13,rcutoff2))
884             {
885
886             /* REACTION-FIELD ELECTROSTATICS */
887             velec            = _fjsp_mul_v2r8(qq13,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq13,rinv13),crf));
888             felec            = _fjsp_mul_v2r8(qq13,_fjsp_msub_v2r8(rinv13,rinvsq13,krf2));
889
890             cutoff_mask      = _fjsp_cmplt_v2r8(rsq13,rcutoff2);
891
892             /* Update potential sum for this i atom from the interaction with this j atom. */
893             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
894             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
895             velecsum         = _fjsp_add_v2r8(velecsum,velec);
896
897             fscal            = felec;
898
899             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
900
901             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
902
903             /* Update vectorial force */
904             fix1             = _fjsp_madd_v2r8(dx13,fscal,fix1);
905             fiy1             = _fjsp_madd_v2r8(dy13,fscal,fiy1);
906             fiz1             = _fjsp_madd_v2r8(dz13,fscal,fiz1);
907             
908             fjx3             = _fjsp_madd_v2r8(dx13,fscal,fjx3);
909             fjy3             = _fjsp_madd_v2r8(dy13,fscal,fjy3);
910             fjz3             = _fjsp_madd_v2r8(dz13,fscal,fjz3);
911
912             }
913
914             /**************************
915              * CALCULATE INTERACTIONS *
916              **************************/
917
918             if (gmx_fjsp_any_lt_v2r8(rsq21,rcutoff2))
919             {
920
921             /* REACTION-FIELD ELECTROSTATICS */
922             velec            = _fjsp_mul_v2r8(qq21,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq21,rinv21),crf));
923             felec            = _fjsp_mul_v2r8(qq21,_fjsp_msub_v2r8(rinv21,rinvsq21,krf2));
924
925             cutoff_mask      = _fjsp_cmplt_v2r8(rsq21,rcutoff2);
926
927             /* Update potential sum for this i atom from the interaction with this j atom. */
928             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
929             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
930             velecsum         = _fjsp_add_v2r8(velecsum,velec);
931
932             fscal            = felec;
933
934             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
935
936             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
937
938             /* Update vectorial force */
939             fix2             = _fjsp_madd_v2r8(dx21,fscal,fix2);
940             fiy2             = _fjsp_madd_v2r8(dy21,fscal,fiy2);
941             fiz2             = _fjsp_madd_v2r8(dz21,fscal,fiz2);
942             
943             fjx1             = _fjsp_madd_v2r8(dx21,fscal,fjx1);
944             fjy1             = _fjsp_madd_v2r8(dy21,fscal,fjy1);
945             fjz1             = _fjsp_madd_v2r8(dz21,fscal,fjz1);
946
947             }
948
949             /**************************
950              * CALCULATE INTERACTIONS *
951              **************************/
952
953             if (gmx_fjsp_any_lt_v2r8(rsq22,rcutoff2))
954             {
955
956             /* REACTION-FIELD ELECTROSTATICS */
957             velec            = _fjsp_mul_v2r8(qq22,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq22,rinv22),crf));
958             felec            = _fjsp_mul_v2r8(qq22,_fjsp_msub_v2r8(rinv22,rinvsq22,krf2));
959
960             cutoff_mask      = _fjsp_cmplt_v2r8(rsq22,rcutoff2);
961
962             /* Update potential sum for this i atom from the interaction with this j atom. */
963             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
964             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
965             velecsum         = _fjsp_add_v2r8(velecsum,velec);
966
967             fscal            = felec;
968
969             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
970
971             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
972
973             /* Update vectorial force */
974             fix2             = _fjsp_madd_v2r8(dx22,fscal,fix2);
975             fiy2             = _fjsp_madd_v2r8(dy22,fscal,fiy2);
976             fiz2             = _fjsp_madd_v2r8(dz22,fscal,fiz2);
977             
978             fjx2             = _fjsp_madd_v2r8(dx22,fscal,fjx2);
979             fjy2             = _fjsp_madd_v2r8(dy22,fscal,fjy2);
980             fjz2             = _fjsp_madd_v2r8(dz22,fscal,fjz2);
981
982             }
983
984             /**************************
985              * CALCULATE INTERACTIONS *
986              **************************/
987
988             if (gmx_fjsp_any_lt_v2r8(rsq23,rcutoff2))
989             {
990
991             /* REACTION-FIELD ELECTROSTATICS */
992             velec            = _fjsp_mul_v2r8(qq23,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq23,rinv23),crf));
993             felec            = _fjsp_mul_v2r8(qq23,_fjsp_msub_v2r8(rinv23,rinvsq23,krf2));
994
995             cutoff_mask      = _fjsp_cmplt_v2r8(rsq23,rcutoff2);
996
997             /* Update potential sum for this i atom from the interaction with this j atom. */
998             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
999             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
1000             velecsum         = _fjsp_add_v2r8(velecsum,velec);
1001
1002             fscal            = felec;
1003
1004             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1005
1006             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1007
1008             /* Update vectorial force */
1009             fix2             = _fjsp_madd_v2r8(dx23,fscal,fix2);
1010             fiy2             = _fjsp_madd_v2r8(dy23,fscal,fiy2);
1011             fiz2             = _fjsp_madd_v2r8(dz23,fscal,fiz2);
1012             
1013             fjx3             = _fjsp_madd_v2r8(dx23,fscal,fjx3);
1014             fjy3             = _fjsp_madd_v2r8(dy23,fscal,fjy3);
1015             fjz3             = _fjsp_madd_v2r8(dz23,fscal,fjz3);
1016
1017             }
1018
1019             /**************************
1020              * CALCULATE INTERACTIONS *
1021              **************************/
1022
1023             if (gmx_fjsp_any_lt_v2r8(rsq31,rcutoff2))
1024             {
1025
1026             /* REACTION-FIELD ELECTROSTATICS */
1027             velec            = _fjsp_mul_v2r8(qq31,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq31,rinv31),crf));
1028             felec            = _fjsp_mul_v2r8(qq31,_fjsp_msub_v2r8(rinv31,rinvsq31,krf2));
1029
1030             cutoff_mask      = _fjsp_cmplt_v2r8(rsq31,rcutoff2);
1031
1032             /* Update potential sum for this i atom from the interaction with this j atom. */
1033             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
1034             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
1035             velecsum         = _fjsp_add_v2r8(velecsum,velec);
1036
1037             fscal            = felec;
1038
1039             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1040
1041             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1042
1043             /* Update vectorial force */
1044             fix3             = _fjsp_madd_v2r8(dx31,fscal,fix3);
1045             fiy3             = _fjsp_madd_v2r8(dy31,fscal,fiy3);
1046             fiz3             = _fjsp_madd_v2r8(dz31,fscal,fiz3);
1047             
1048             fjx1             = _fjsp_madd_v2r8(dx31,fscal,fjx1);
1049             fjy1             = _fjsp_madd_v2r8(dy31,fscal,fjy1);
1050             fjz1             = _fjsp_madd_v2r8(dz31,fscal,fjz1);
1051
1052             }
1053
1054             /**************************
1055              * CALCULATE INTERACTIONS *
1056              **************************/
1057
1058             if (gmx_fjsp_any_lt_v2r8(rsq32,rcutoff2))
1059             {
1060
1061             /* REACTION-FIELD ELECTROSTATICS */
1062             velec            = _fjsp_mul_v2r8(qq32,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq32,rinv32),crf));
1063             felec            = _fjsp_mul_v2r8(qq32,_fjsp_msub_v2r8(rinv32,rinvsq32,krf2));
1064
1065             cutoff_mask      = _fjsp_cmplt_v2r8(rsq32,rcutoff2);
1066
1067             /* Update potential sum for this i atom from the interaction with this j atom. */
1068             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
1069             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
1070             velecsum         = _fjsp_add_v2r8(velecsum,velec);
1071
1072             fscal            = felec;
1073
1074             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1075
1076             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1077
1078             /* Update vectorial force */
1079             fix3             = _fjsp_madd_v2r8(dx32,fscal,fix3);
1080             fiy3             = _fjsp_madd_v2r8(dy32,fscal,fiy3);
1081             fiz3             = _fjsp_madd_v2r8(dz32,fscal,fiz3);
1082             
1083             fjx2             = _fjsp_madd_v2r8(dx32,fscal,fjx2);
1084             fjy2             = _fjsp_madd_v2r8(dy32,fscal,fjy2);
1085             fjz2             = _fjsp_madd_v2r8(dz32,fscal,fjz2);
1086
1087             }
1088
1089             /**************************
1090              * CALCULATE INTERACTIONS *
1091              **************************/
1092
1093             if (gmx_fjsp_any_lt_v2r8(rsq33,rcutoff2))
1094             {
1095
1096             /* REACTION-FIELD ELECTROSTATICS */
1097             velec            = _fjsp_mul_v2r8(qq33,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq33,rinv33),crf));
1098             felec            = _fjsp_mul_v2r8(qq33,_fjsp_msub_v2r8(rinv33,rinvsq33,krf2));
1099
1100             cutoff_mask      = _fjsp_cmplt_v2r8(rsq33,rcutoff2);
1101
1102             /* Update potential sum for this i atom from the interaction with this j atom. */
1103             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
1104             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
1105             velecsum         = _fjsp_add_v2r8(velecsum,velec);
1106
1107             fscal            = felec;
1108
1109             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1110
1111             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1112
1113             /* Update vectorial force */
1114             fix3             = _fjsp_madd_v2r8(dx33,fscal,fix3);
1115             fiy3             = _fjsp_madd_v2r8(dy33,fscal,fiy3);
1116             fiz3             = _fjsp_madd_v2r8(dz33,fscal,fiz3);
1117             
1118             fjx3             = _fjsp_madd_v2r8(dx33,fscal,fjx3);
1119             fjy3             = _fjsp_madd_v2r8(dy33,fscal,fjy3);
1120             fjz3             = _fjsp_madd_v2r8(dz33,fscal,fjz3);
1121
1122             }
1123
1124             gmx_fjsp_decrement_4rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
1125
1126             /* Inner loop uses 413 flops */
1127         }
1128
1129         /* End of innermost loop */
1130
1131         gmx_fjsp_update_iforce_4atom_swizzle_v2r8(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
1132                                               f+i_coord_offset,fshift+i_shift_offset);
1133
1134         ggid                        = gid[iidx];
1135         /* Update potential energies */
1136         gmx_fjsp_update_1pot_v2r8(velecsum,kernel_data->energygrp_elec+ggid);
1137         gmx_fjsp_update_1pot_v2r8(vvdwsum,kernel_data->energygrp_vdw+ggid);
1138
1139         /* Increment number of inner iterations */
1140         inneriter                  += j_index_end - j_index_start;
1141
1142         /* Outer loop uses 26 flops */
1143     }
1144
1145     /* Increment number of outer iterations */
1146     outeriter        += nri;
1147
1148     /* Update outer/inner flops */
1149
1150     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*26 + inneriter*413);
1151 }
1152 /*
1153  * Gromacs nonbonded kernel:   nb_kernel_ElecRFCut_VdwCSTab_GeomW4W4_F_sparc64_hpc_ace_double
1154  * Electrostatics interaction: ReactionField
1155  * VdW interaction:            CubicSplineTable
1156  * Geometry:                   Water4-Water4
1157  * Calculate force/pot:        Force
1158  */
1159 void
1160 nb_kernel_ElecRFCut_VdwCSTab_GeomW4W4_F_sparc64_hpc_ace_double
1161                     (t_nblist                    * gmx_restrict       nlist,
1162                      rvec                        * gmx_restrict          xx,
1163                      rvec                        * gmx_restrict          ff,
1164                      t_forcerec                  * gmx_restrict          fr,
1165                      t_mdatoms                   * gmx_restrict     mdatoms,
1166                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
1167                      t_nrnb                      * gmx_restrict        nrnb)
1168 {
1169     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
1170      * just 0 for non-waters.
1171      * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
1172      * jnr indices corresponding to data put in the four positions in the SIMD register.
1173      */
1174     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
1175     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
1176     int              jnrA,jnrB;
1177     int              j_coord_offsetA,j_coord_offsetB;
1178     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
1179     real             rcutoff_scalar;
1180     real             *shiftvec,*fshift,*x,*f;
1181     _fjsp_v2r8       tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
1182     int              vdwioffset0;
1183     _fjsp_v2r8       ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
1184     int              vdwioffset1;
1185     _fjsp_v2r8       ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
1186     int              vdwioffset2;
1187     _fjsp_v2r8       ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
1188     int              vdwioffset3;
1189     _fjsp_v2r8       ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
1190     int              vdwjidx0A,vdwjidx0B;
1191     _fjsp_v2r8       jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
1192     int              vdwjidx1A,vdwjidx1B;
1193     _fjsp_v2r8       jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
1194     int              vdwjidx2A,vdwjidx2B;
1195     _fjsp_v2r8       jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
1196     int              vdwjidx3A,vdwjidx3B;
1197     _fjsp_v2r8       jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
1198     _fjsp_v2r8       dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
1199     _fjsp_v2r8       dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
1200     _fjsp_v2r8       dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
1201     _fjsp_v2r8       dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13;
1202     _fjsp_v2r8       dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
1203     _fjsp_v2r8       dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
1204     _fjsp_v2r8       dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23;
1205     _fjsp_v2r8       dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31;
1206     _fjsp_v2r8       dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32;
1207     _fjsp_v2r8       dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33;
1208     _fjsp_v2r8       velec,felec,velecsum,facel,crf,krf,krf2;
1209     real             *charge;
1210     int              nvdwtype;
1211     _fjsp_v2r8       rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
1212     int              *vdwtype;
1213     real             *vdwparam;
1214     _fjsp_v2r8       one_sixth   = gmx_fjsp_set1_v2r8(1.0/6.0);
1215     _fjsp_v2r8       one_twelfth = gmx_fjsp_set1_v2r8(1.0/12.0);
1216     _fjsp_v2r8       rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF,twovfeps;
1217     real             *vftab;
1218     _fjsp_v2r8       itab_tmp;
1219     _fjsp_v2r8       dummy_mask,cutoff_mask;
1220     _fjsp_v2r8       one     = gmx_fjsp_set1_v2r8(1.0);
1221     _fjsp_v2r8       two     = gmx_fjsp_set1_v2r8(2.0);
1222     union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
1223
1224     x                = xx[0];
1225     f                = ff[0];
1226
1227     nri              = nlist->nri;
1228     iinr             = nlist->iinr;
1229     jindex           = nlist->jindex;
1230     jjnr             = nlist->jjnr;
1231     shiftidx         = nlist->shift;
1232     gid              = nlist->gid;
1233     shiftvec         = fr->shift_vec[0];
1234     fshift           = fr->fshift[0];
1235     facel            = gmx_fjsp_set1_v2r8(fr->epsfac);
1236     charge           = mdatoms->chargeA;
1237     krf              = gmx_fjsp_set1_v2r8(fr->ic->k_rf);
1238     krf2             = gmx_fjsp_set1_v2r8(fr->ic->k_rf*2.0);
1239     crf              = gmx_fjsp_set1_v2r8(fr->ic->c_rf);
1240     nvdwtype         = fr->ntype;
1241     vdwparam         = fr->nbfp;
1242     vdwtype          = mdatoms->typeA;
1243
1244     vftab            = kernel_data->table_vdw->data;
1245     vftabscale       = gmx_fjsp_set1_v2r8(kernel_data->table_vdw->scale);
1246
1247     /* Setup water-specific parameters */
1248     inr              = nlist->iinr[0];
1249     iq1              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+1]));
1250     iq2              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+2]));
1251     iq3              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+3]));
1252     vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
1253
1254     jq1              = gmx_fjsp_set1_v2r8(charge[inr+1]);
1255     jq2              = gmx_fjsp_set1_v2r8(charge[inr+2]);
1256     jq3              = gmx_fjsp_set1_v2r8(charge[inr+3]);
1257     vdwjidx0A        = 2*vdwtype[inr+0];
1258     c6_00            = gmx_fjsp_set1_v2r8(vdwparam[vdwioffset0+vdwjidx0A]);
1259     c12_00           = gmx_fjsp_set1_v2r8(vdwparam[vdwioffset0+vdwjidx0A+1]);
1260     qq11             = _fjsp_mul_v2r8(iq1,jq1);
1261     qq12             = _fjsp_mul_v2r8(iq1,jq2);
1262     qq13             = _fjsp_mul_v2r8(iq1,jq3);
1263     qq21             = _fjsp_mul_v2r8(iq2,jq1);
1264     qq22             = _fjsp_mul_v2r8(iq2,jq2);
1265     qq23             = _fjsp_mul_v2r8(iq2,jq3);
1266     qq31             = _fjsp_mul_v2r8(iq3,jq1);
1267     qq32             = _fjsp_mul_v2r8(iq3,jq2);
1268     qq33             = _fjsp_mul_v2r8(iq3,jq3);
1269
1270     /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
1271     rcutoff_scalar   = fr->rcoulomb;
1272     rcutoff          = gmx_fjsp_set1_v2r8(rcutoff_scalar);
1273     rcutoff2         = _fjsp_mul_v2r8(rcutoff,rcutoff);
1274
1275     /* Avoid stupid compiler warnings */
1276     jnrA = jnrB = 0;
1277     j_coord_offsetA = 0;
1278     j_coord_offsetB = 0;
1279
1280     outeriter        = 0;
1281     inneriter        = 0;
1282
1283     /* Start outer loop over neighborlists */
1284     for(iidx=0; iidx<nri; iidx++)
1285     {
1286         /* Load shift vector for this list */
1287         i_shift_offset   = DIM*shiftidx[iidx];
1288
1289         /* Load limits for loop over neighbors */
1290         j_index_start    = jindex[iidx];
1291         j_index_end      = jindex[iidx+1];
1292
1293         /* Get outer coordinate index */
1294         inr              = iinr[iidx];
1295         i_coord_offset   = DIM*inr;
1296
1297         /* Load i particle coords and add shift vector */
1298         gmx_fjsp_load_shift_and_4rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,
1299                                                  &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
1300
1301         fix0             = _fjsp_setzero_v2r8();
1302         fiy0             = _fjsp_setzero_v2r8();
1303         fiz0             = _fjsp_setzero_v2r8();
1304         fix1             = _fjsp_setzero_v2r8();
1305         fiy1             = _fjsp_setzero_v2r8();
1306         fiz1             = _fjsp_setzero_v2r8();
1307         fix2             = _fjsp_setzero_v2r8();
1308         fiy2             = _fjsp_setzero_v2r8();
1309         fiz2             = _fjsp_setzero_v2r8();
1310         fix3             = _fjsp_setzero_v2r8();
1311         fiy3             = _fjsp_setzero_v2r8();
1312         fiz3             = _fjsp_setzero_v2r8();
1313
1314         /* Start inner kernel loop */
1315         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
1316         {
1317
1318             /* Get j neighbor index, and coordinate index */
1319             jnrA             = jjnr[jidx];
1320             jnrB             = jjnr[jidx+1];
1321             j_coord_offsetA  = DIM*jnrA;
1322             j_coord_offsetB  = DIM*jnrB;
1323
1324             /* load j atom coordinates */
1325             gmx_fjsp_load_4rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
1326                                               &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,
1327                                               &jy2,&jz2,&jx3,&jy3,&jz3);
1328
1329             /* Calculate displacement vector */
1330             dx00             = _fjsp_sub_v2r8(ix0,jx0);
1331             dy00             = _fjsp_sub_v2r8(iy0,jy0);
1332             dz00             = _fjsp_sub_v2r8(iz0,jz0);
1333             dx11             = _fjsp_sub_v2r8(ix1,jx1);
1334             dy11             = _fjsp_sub_v2r8(iy1,jy1);
1335             dz11             = _fjsp_sub_v2r8(iz1,jz1);
1336             dx12             = _fjsp_sub_v2r8(ix1,jx2);
1337             dy12             = _fjsp_sub_v2r8(iy1,jy2);
1338             dz12             = _fjsp_sub_v2r8(iz1,jz2);
1339             dx13             = _fjsp_sub_v2r8(ix1,jx3);
1340             dy13             = _fjsp_sub_v2r8(iy1,jy3);
1341             dz13             = _fjsp_sub_v2r8(iz1,jz3);
1342             dx21             = _fjsp_sub_v2r8(ix2,jx1);
1343             dy21             = _fjsp_sub_v2r8(iy2,jy1);
1344             dz21             = _fjsp_sub_v2r8(iz2,jz1);
1345             dx22             = _fjsp_sub_v2r8(ix2,jx2);
1346             dy22             = _fjsp_sub_v2r8(iy2,jy2);
1347             dz22             = _fjsp_sub_v2r8(iz2,jz2);
1348             dx23             = _fjsp_sub_v2r8(ix2,jx3);
1349             dy23             = _fjsp_sub_v2r8(iy2,jy3);
1350             dz23             = _fjsp_sub_v2r8(iz2,jz3);
1351             dx31             = _fjsp_sub_v2r8(ix3,jx1);
1352             dy31             = _fjsp_sub_v2r8(iy3,jy1);
1353             dz31             = _fjsp_sub_v2r8(iz3,jz1);
1354             dx32             = _fjsp_sub_v2r8(ix3,jx2);
1355             dy32             = _fjsp_sub_v2r8(iy3,jy2);
1356             dz32             = _fjsp_sub_v2r8(iz3,jz2);
1357             dx33             = _fjsp_sub_v2r8(ix3,jx3);
1358             dy33             = _fjsp_sub_v2r8(iy3,jy3);
1359             dz33             = _fjsp_sub_v2r8(iz3,jz3);
1360
1361             /* Calculate squared distance and things based on it */
1362             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
1363             rsq11            = gmx_fjsp_calc_rsq_v2r8(dx11,dy11,dz11);
1364             rsq12            = gmx_fjsp_calc_rsq_v2r8(dx12,dy12,dz12);
1365             rsq13            = gmx_fjsp_calc_rsq_v2r8(dx13,dy13,dz13);
1366             rsq21            = gmx_fjsp_calc_rsq_v2r8(dx21,dy21,dz21);
1367             rsq22            = gmx_fjsp_calc_rsq_v2r8(dx22,dy22,dz22);
1368             rsq23            = gmx_fjsp_calc_rsq_v2r8(dx23,dy23,dz23);
1369             rsq31            = gmx_fjsp_calc_rsq_v2r8(dx31,dy31,dz31);
1370             rsq32            = gmx_fjsp_calc_rsq_v2r8(dx32,dy32,dz32);
1371             rsq33            = gmx_fjsp_calc_rsq_v2r8(dx33,dy33,dz33);
1372
1373             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
1374             rinv11           = gmx_fjsp_invsqrt_v2r8(rsq11);
1375             rinv12           = gmx_fjsp_invsqrt_v2r8(rsq12);
1376             rinv13           = gmx_fjsp_invsqrt_v2r8(rsq13);
1377             rinv21           = gmx_fjsp_invsqrt_v2r8(rsq21);
1378             rinv22           = gmx_fjsp_invsqrt_v2r8(rsq22);
1379             rinv23           = gmx_fjsp_invsqrt_v2r8(rsq23);
1380             rinv31           = gmx_fjsp_invsqrt_v2r8(rsq31);
1381             rinv32           = gmx_fjsp_invsqrt_v2r8(rsq32);
1382             rinv33           = gmx_fjsp_invsqrt_v2r8(rsq33);
1383
1384             rinvsq11         = _fjsp_mul_v2r8(rinv11,rinv11);
1385             rinvsq12         = _fjsp_mul_v2r8(rinv12,rinv12);
1386             rinvsq13         = _fjsp_mul_v2r8(rinv13,rinv13);
1387             rinvsq21         = _fjsp_mul_v2r8(rinv21,rinv21);
1388             rinvsq22         = _fjsp_mul_v2r8(rinv22,rinv22);
1389             rinvsq23         = _fjsp_mul_v2r8(rinv23,rinv23);
1390             rinvsq31         = _fjsp_mul_v2r8(rinv31,rinv31);
1391             rinvsq32         = _fjsp_mul_v2r8(rinv32,rinv32);
1392             rinvsq33         = _fjsp_mul_v2r8(rinv33,rinv33);
1393
1394             fjx0             = _fjsp_setzero_v2r8();
1395             fjy0             = _fjsp_setzero_v2r8();
1396             fjz0             = _fjsp_setzero_v2r8();
1397             fjx1             = _fjsp_setzero_v2r8();
1398             fjy1             = _fjsp_setzero_v2r8();
1399             fjz1             = _fjsp_setzero_v2r8();
1400             fjx2             = _fjsp_setzero_v2r8();
1401             fjy2             = _fjsp_setzero_v2r8();
1402             fjz2             = _fjsp_setzero_v2r8();
1403             fjx3             = _fjsp_setzero_v2r8();
1404             fjy3             = _fjsp_setzero_v2r8();
1405             fjz3             = _fjsp_setzero_v2r8();
1406
1407             /**************************
1408              * CALCULATE INTERACTIONS *
1409              **************************/
1410
1411             r00              = _fjsp_mul_v2r8(rsq00,rinv00);
1412
1413             /* Calculate table index by multiplying r with table scale and truncate to integer */
1414             rt               = _fjsp_mul_v2r8(r00,vftabscale);
1415             itab_tmp         = _fjsp_dtox_v2r8(rt);
1416             vfeps            = _fjsp_sub_v2r8(rt, _fjsp_xtod_v2r8(itab_tmp));
1417             twovfeps         = _fjsp_add_v2r8(vfeps,vfeps);
1418             _fjsp_store_v2r8(&vfconv.simd,itab_tmp);
1419
1420             vfconv.i[0]     *= 8;
1421             vfconv.i[1]     *= 8;
1422
1423             /* CUBIC SPLINE TABLE DISPERSION */
1424             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] );
1425             F                = _fjsp_load_v2r8( vftab + vfconv.i[1] );
1426             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
1427             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 2 );
1428             H                = _fjsp_load_v2r8( vftab + vfconv.i[1] + 2 );
1429             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
1430             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
1431             FF               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
1432             fvdw6            = _fjsp_mul_v2r8(c6_00,FF);
1433
1434             /* CUBIC SPLINE TABLE REPULSION */
1435             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 4 );
1436             F                = _fjsp_load_v2r8( vftab + vfconv.i[1] + 4 );
1437             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
1438             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 6 );
1439             H                = _fjsp_load_v2r8( vftab + vfconv.i[1] + 6 );
1440             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
1441             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
1442             FF               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
1443             fvdw12           = _fjsp_mul_v2r8(c12_00,FF);
1444             fvdw             = _fjsp_neg_v2r8(_fjsp_mul_v2r8(_fjsp_add_v2r8(fvdw6,fvdw12),_fjsp_mul_v2r8(vftabscale,rinv00)));
1445
1446             fscal            = fvdw;
1447
1448             /* Update vectorial force */
1449             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
1450             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
1451             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
1452             
1453             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
1454             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
1455             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
1456
1457             /**************************
1458              * CALCULATE INTERACTIONS *
1459              **************************/
1460
1461             if (gmx_fjsp_any_lt_v2r8(rsq11,rcutoff2))
1462             {
1463
1464             /* REACTION-FIELD ELECTROSTATICS */
1465             felec            = _fjsp_mul_v2r8(qq11,_fjsp_msub_v2r8(rinv11,rinvsq11,krf2));
1466
1467             cutoff_mask      = _fjsp_cmplt_v2r8(rsq11,rcutoff2);
1468
1469             fscal            = felec;
1470
1471             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1472
1473             /* Update vectorial force */
1474             fix1             = _fjsp_madd_v2r8(dx11,fscal,fix1);
1475             fiy1             = _fjsp_madd_v2r8(dy11,fscal,fiy1);
1476             fiz1             = _fjsp_madd_v2r8(dz11,fscal,fiz1);
1477             
1478             fjx1             = _fjsp_madd_v2r8(dx11,fscal,fjx1);
1479             fjy1             = _fjsp_madd_v2r8(dy11,fscal,fjy1);
1480             fjz1             = _fjsp_madd_v2r8(dz11,fscal,fjz1);
1481
1482             }
1483
1484             /**************************
1485              * CALCULATE INTERACTIONS *
1486              **************************/
1487
1488             if (gmx_fjsp_any_lt_v2r8(rsq12,rcutoff2))
1489             {
1490
1491             /* REACTION-FIELD ELECTROSTATICS */
1492             felec            = _fjsp_mul_v2r8(qq12,_fjsp_msub_v2r8(rinv12,rinvsq12,krf2));
1493
1494             cutoff_mask      = _fjsp_cmplt_v2r8(rsq12,rcutoff2);
1495
1496             fscal            = felec;
1497
1498             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1499
1500             /* Update vectorial force */
1501             fix1             = _fjsp_madd_v2r8(dx12,fscal,fix1);
1502             fiy1             = _fjsp_madd_v2r8(dy12,fscal,fiy1);
1503             fiz1             = _fjsp_madd_v2r8(dz12,fscal,fiz1);
1504             
1505             fjx2             = _fjsp_madd_v2r8(dx12,fscal,fjx2);
1506             fjy2             = _fjsp_madd_v2r8(dy12,fscal,fjy2);
1507             fjz2             = _fjsp_madd_v2r8(dz12,fscal,fjz2);
1508
1509             }
1510
1511             /**************************
1512              * CALCULATE INTERACTIONS *
1513              **************************/
1514
1515             if (gmx_fjsp_any_lt_v2r8(rsq13,rcutoff2))
1516             {
1517
1518             /* REACTION-FIELD ELECTROSTATICS */
1519             felec            = _fjsp_mul_v2r8(qq13,_fjsp_msub_v2r8(rinv13,rinvsq13,krf2));
1520
1521             cutoff_mask      = _fjsp_cmplt_v2r8(rsq13,rcutoff2);
1522
1523             fscal            = felec;
1524
1525             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1526
1527             /* Update vectorial force */
1528             fix1             = _fjsp_madd_v2r8(dx13,fscal,fix1);
1529             fiy1             = _fjsp_madd_v2r8(dy13,fscal,fiy1);
1530             fiz1             = _fjsp_madd_v2r8(dz13,fscal,fiz1);
1531             
1532             fjx3             = _fjsp_madd_v2r8(dx13,fscal,fjx3);
1533             fjy3             = _fjsp_madd_v2r8(dy13,fscal,fjy3);
1534             fjz3             = _fjsp_madd_v2r8(dz13,fscal,fjz3);
1535
1536             }
1537
1538             /**************************
1539              * CALCULATE INTERACTIONS *
1540              **************************/
1541
1542             if (gmx_fjsp_any_lt_v2r8(rsq21,rcutoff2))
1543             {
1544
1545             /* REACTION-FIELD ELECTROSTATICS */
1546             felec            = _fjsp_mul_v2r8(qq21,_fjsp_msub_v2r8(rinv21,rinvsq21,krf2));
1547
1548             cutoff_mask      = _fjsp_cmplt_v2r8(rsq21,rcutoff2);
1549
1550             fscal            = felec;
1551
1552             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1553
1554             /* Update vectorial force */
1555             fix2             = _fjsp_madd_v2r8(dx21,fscal,fix2);
1556             fiy2             = _fjsp_madd_v2r8(dy21,fscal,fiy2);
1557             fiz2             = _fjsp_madd_v2r8(dz21,fscal,fiz2);
1558             
1559             fjx1             = _fjsp_madd_v2r8(dx21,fscal,fjx1);
1560             fjy1             = _fjsp_madd_v2r8(dy21,fscal,fjy1);
1561             fjz1             = _fjsp_madd_v2r8(dz21,fscal,fjz1);
1562
1563             }
1564
1565             /**************************
1566              * CALCULATE INTERACTIONS *
1567              **************************/
1568
1569             if (gmx_fjsp_any_lt_v2r8(rsq22,rcutoff2))
1570             {
1571
1572             /* REACTION-FIELD ELECTROSTATICS */
1573             felec            = _fjsp_mul_v2r8(qq22,_fjsp_msub_v2r8(rinv22,rinvsq22,krf2));
1574
1575             cutoff_mask      = _fjsp_cmplt_v2r8(rsq22,rcutoff2);
1576
1577             fscal            = felec;
1578
1579             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1580
1581             /* Update vectorial force */
1582             fix2             = _fjsp_madd_v2r8(dx22,fscal,fix2);
1583             fiy2             = _fjsp_madd_v2r8(dy22,fscal,fiy2);
1584             fiz2             = _fjsp_madd_v2r8(dz22,fscal,fiz2);
1585             
1586             fjx2             = _fjsp_madd_v2r8(dx22,fscal,fjx2);
1587             fjy2             = _fjsp_madd_v2r8(dy22,fscal,fjy2);
1588             fjz2             = _fjsp_madd_v2r8(dz22,fscal,fjz2);
1589
1590             }
1591
1592             /**************************
1593              * CALCULATE INTERACTIONS *
1594              **************************/
1595
1596             if (gmx_fjsp_any_lt_v2r8(rsq23,rcutoff2))
1597             {
1598
1599             /* REACTION-FIELD ELECTROSTATICS */
1600             felec            = _fjsp_mul_v2r8(qq23,_fjsp_msub_v2r8(rinv23,rinvsq23,krf2));
1601
1602             cutoff_mask      = _fjsp_cmplt_v2r8(rsq23,rcutoff2);
1603
1604             fscal            = felec;
1605
1606             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1607
1608             /* Update vectorial force */
1609             fix2             = _fjsp_madd_v2r8(dx23,fscal,fix2);
1610             fiy2             = _fjsp_madd_v2r8(dy23,fscal,fiy2);
1611             fiz2             = _fjsp_madd_v2r8(dz23,fscal,fiz2);
1612             
1613             fjx3             = _fjsp_madd_v2r8(dx23,fscal,fjx3);
1614             fjy3             = _fjsp_madd_v2r8(dy23,fscal,fjy3);
1615             fjz3             = _fjsp_madd_v2r8(dz23,fscal,fjz3);
1616
1617             }
1618
1619             /**************************
1620              * CALCULATE INTERACTIONS *
1621              **************************/
1622
1623             if (gmx_fjsp_any_lt_v2r8(rsq31,rcutoff2))
1624             {
1625
1626             /* REACTION-FIELD ELECTROSTATICS */
1627             felec            = _fjsp_mul_v2r8(qq31,_fjsp_msub_v2r8(rinv31,rinvsq31,krf2));
1628
1629             cutoff_mask      = _fjsp_cmplt_v2r8(rsq31,rcutoff2);
1630
1631             fscal            = felec;
1632
1633             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1634
1635             /* Update vectorial force */
1636             fix3             = _fjsp_madd_v2r8(dx31,fscal,fix3);
1637             fiy3             = _fjsp_madd_v2r8(dy31,fscal,fiy3);
1638             fiz3             = _fjsp_madd_v2r8(dz31,fscal,fiz3);
1639             
1640             fjx1             = _fjsp_madd_v2r8(dx31,fscal,fjx1);
1641             fjy1             = _fjsp_madd_v2r8(dy31,fscal,fjy1);
1642             fjz1             = _fjsp_madd_v2r8(dz31,fscal,fjz1);
1643
1644             }
1645
1646             /**************************
1647              * CALCULATE INTERACTIONS *
1648              **************************/
1649
1650             if (gmx_fjsp_any_lt_v2r8(rsq32,rcutoff2))
1651             {
1652
1653             /* REACTION-FIELD ELECTROSTATICS */
1654             felec            = _fjsp_mul_v2r8(qq32,_fjsp_msub_v2r8(rinv32,rinvsq32,krf2));
1655
1656             cutoff_mask      = _fjsp_cmplt_v2r8(rsq32,rcutoff2);
1657
1658             fscal            = felec;
1659
1660             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1661
1662             /* Update vectorial force */
1663             fix3             = _fjsp_madd_v2r8(dx32,fscal,fix3);
1664             fiy3             = _fjsp_madd_v2r8(dy32,fscal,fiy3);
1665             fiz3             = _fjsp_madd_v2r8(dz32,fscal,fiz3);
1666             
1667             fjx2             = _fjsp_madd_v2r8(dx32,fscal,fjx2);
1668             fjy2             = _fjsp_madd_v2r8(dy32,fscal,fjy2);
1669             fjz2             = _fjsp_madd_v2r8(dz32,fscal,fjz2);
1670
1671             }
1672
1673             /**************************
1674              * CALCULATE INTERACTIONS *
1675              **************************/
1676
1677             if (gmx_fjsp_any_lt_v2r8(rsq33,rcutoff2))
1678             {
1679
1680             /* REACTION-FIELD ELECTROSTATICS */
1681             felec            = _fjsp_mul_v2r8(qq33,_fjsp_msub_v2r8(rinv33,rinvsq33,krf2));
1682
1683             cutoff_mask      = _fjsp_cmplt_v2r8(rsq33,rcutoff2);
1684
1685             fscal            = felec;
1686
1687             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1688
1689             /* Update vectorial force */
1690             fix3             = _fjsp_madd_v2r8(dx33,fscal,fix3);
1691             fiy3             = _fjsp_madd_v2r8(dy33,fscal,fiy3);
1692             fiz3             = _fjsp_madd_v2r8(dz33,fscal,fiz3);
1693             
1694             fjx3             = _fjsp_madd_v2r8(dx33,fscal,fjx3);
1695             fjy3             = _fjsp_madd_v2r8(dy33,fscal,fjy3);
1696             fjz3             = _fjsp_madd_v2r8(dz33,fscal,fjz3);
1697
1698             }
1699
1700             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);
1701
1702             /* Inner loop uses 351 flops */
1703         }
1704
1705         if(jidx<j_index_end)
1706         {
1707
1708             jnrA             = jjnr[jidx];
1709             j_coord_offsetA  = DIM*jnrA;
1710
1711             /* load j atom coordinates */
1712             gmx_fjsp_load_4rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
1713                                               &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,
1714                                               &jy2,&jz2,&jx3,&jy3,&jz3);
1715
1716             /* Calculate displacement vector */
1717             dx00             = _fjsp_sub_v2r8(ix0,jx0);
1718             dy00             = _fjsp_sub_v2r8(iy0,jy0);
1719             dz00             = _fjsp_sub_v2r8(iz0,jz0);
1720             dx11             = _fjsp_sub_v2r8(ix1,jx1);
1721             dy11             = _fjsp_sub_v2r8(iy1,jy1);
1722             dz11             = _fjsp_sub_v2r8(iz1,jz1);
1723             dx12             = _fjsp_sub_v2r8(ix1,jx2);
1724             dy12             = _fjsp_sub_v2r8(iy1,jy2);
1725             dz12             = _fjsp_sub_v2r8(iz1,jz2);
1726             dx13             = _fjsp_sub_v2r8(ix1,jx3);
1727             dy13             = _fjsp_sub_v2r8(iy1,jy3);
1728             dz13             = _fjsp_sub_v2r8(iz1,jz3);
1729             dx21             = _fjsp_sub_v2r8(ix2,jx1);
1730             dy21             = _fjsp_sub_v2r8(iy2,jy1);
1731             dz21             = _fjsp_sub_v2r8(iz2,jz1);
1732             dx22             = _fjsp_sub_v2r8(ix2,jx2);
1733             dy22             = _fjsp_sub_v2r8(iy2,jy2);
1734             dz22             = _fjsp_sub_v2r8(iz2,jz2);
1735             dx23             = _fjsp_sub_v2r8(ix2,jx3);
1736             dy23             = _fjsp_sub_v2r8(iy2,jy3);
1737             dz23             = _fjsp_sub_v2r8(iz2,jz3);
1738             dx31             = _fjsp_sub_v2r8(ix3,jx1);
1739             dy31             = _fjsp_sub_v2r8(iy3,jy1);
1740             dz31             = _fjsp_sub_v2r8(iz3,jz1);
1741             dx32             = _fjsp_sub_v2r8(ix3,jx2);
1742             dy32             = _fjsp_sub_v2r8(iy3,jy2);
1743             dz32             = _fjsp_sub_v2r8(iz3,jz2);
1744             dx33             = _fjsp_sub_v2r8(ix3,jx3);
1745             dy33             = _fjsp_sub_v2r8(iy3,jy3);
1746             dz33             = _fjsp_sub_v2r8(iz3,jz3);
1747
1748             /* Calculate squared distance and things based on it */
1749             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
1750             rsq11            = gmx_fjsp_calc_rsq_v2r8(dx11,dy11,dz11);
1751             rsq12            = gmx_fjsp_calc_rsq_v2r8(dx12,dy12,dz12);
1752             rsq13            = gmx_fjsp_calc_rsq_v2r8(dx13,dy13,dz13);
1753             rsq21            = gmx_fjsp_calc_rsq_v2r8(dx21,dy21,dz21);
1754             rsq22            = gmx_fjsp_calc_rsq_v2r8(dx22,dy22,dz22);
1755             rsq23            = gmx_fjsp_calc_rsq_v2r8(dx23,dy23,dz23);
1756             rsq31            = gmx_fjsp_calc_rsq_v2r8(dx31,dy31,dz31);
1757             rsq32            = gmx_fjsp_calc_rsq_v2r8(dx32,dy32,dz32);
1758             rsq33            = gmx_fjsp_calc_rsq_v2r8(dx33,dy33,dz33);
1759
1760             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
1761             rinv11           = gmx_fjsp_invsqrt_v2r8(rsq11);
1762             rinv12           = gmx_fjsp_invsqrt_v2r8(rsq12);
1763             rinv13           = gmx_fjsp_invsqrt_v2r8(rsq13);
1764             rinv21           = gmx_fjsp_invsqrt_v2r8(rsq21);
1765             rinv22           = gmx_fjsp_invsqrt_v2r8(rsq22);
1766             rinv23           = gmx_fjsp_invsqrt_v2r8(rsq23);
1767             rinv31           = gmx_fjsp_invsqrt_v2r8(rsq31);
1768             rinv32           = gmx_fjsp_invsqrt_v2r8(rsq32);
1769             rinv33           = gmx_fjsp_invsqrt_v2r8(rsq33);
1770
1771             rinvsq11         = _fjsp_mul_v2r8(rinv11,rinv11);
1772             rinvsq12         = _fjsp_mul_v2r8(rinv12,rinv12);
1773             rinvsq13         = _fjsp_mul_v2r8(rinv13,rinv13);
1774             rinvsq21         = _fjsp_mul_v2r8(rinv21,rinv21);
1775             rinvsq22         = _fjsp_mul_v2r8(rinv22,rinv22);
1776             rinvsq23         = _fjsp_mul_v2r8(rinv23,rinv23);
1777             rinvsq31         = _fjsp_mul_v2r8(rinv31,rinv31);
1778             rinvsq32         = _fjsp_mul_v2r8(rinv32,rinv32);
1779             rinvsq33         = _fjsp_mul_v2r8(rinv33,rinv33);
1780
1781             fjx0             = _fjsp_setzero_v2r8();
1782             fjy0             = _fjsp_setzero_v2r8();
1783             fjz0             = _fjsp_setzero_v2r8();
1784             fjx1             = _fjsp_setzero_v2r8();
1785             fjy1             = _fjsp_setzero_v2r8();
1786             fjz1             = _fjsp_setzero_v2r8();
1787             fjx2             = _fjsp_setzero_v2r8();
1788             fjy2             = _fjsp_setzero_v2r8();
1789             fjz2             = _fjsp_setzero_v2r8();
1790             fjx3             = _fjsp_setzero_v2r8();
1791             fjy3             = _fjsp_setzero_v2r8();
1792             fjz3             = _fjsp_setzero_v2r8();
1793
1794             /**************************
1795              * CALCULATE INTERACTIONS *
1796              **************************/
1797
1798             r00              = _fjsp_mul_v2r8(rsq00,rinv00);
1799
1800             /* Calculate table index by multiplying r with table scale and truncate to integer */
1801             rt               = _fjsp_mul_v2r8(r00,vftabscale);
1802             itab_tmp         = _fjsp_dtox_v2r8(rt);
1803             vfeps            = _fjsp_sub_v2r8(rt, _fjsp_xtod_v2r8(itab_tmp));
1804             twovfeps         = _fjsp_add_v2r8(vfeps,vfeps);
1805             _fjsp_store_v2r8(&vfconv.simd,itab_tmp);
1806
1807             vfconv.i[0]     *= 8;
1808             vfconv.i[1]     *= 8;
1809
1810             /* CUBIC SPLINE TABLE DISPERSION */
1811             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] );
1812             F                = _fjsp_setzero_v2r8();
1813             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
1814             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 2 );
1815             H                = _fjsp_setzero_v2r8();
1816             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
1817             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
1818             FF               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
1819             fvdw6            = _fjsp_mul_v2r8(c6_00,FF);
1820
1821             /* CUBIC SPLINE TABLE REPULSION */
1822             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 4 );
1823             F                = _fjsp_setzero_v2r8();
1824             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
1825             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 6 );
1826             H                = _fjsp_setzero_v2r8();
1827             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
1828             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
1829             FF               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
1830             fvdw12           = _fjsp_mul_v2r8(c12_00,FF);
1831             fvdw             = _fjsp_neg_v2r8(_fjsp_mul_v2r8(_fjsp_add_v2r8(fvdw6,fvdw12),_fjsp_mul_v2r8(vftabscale,rinv00)));
1832
1833             fscal            = fvdw;
1834
1835             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1836
1837             /* Update vectorial force */
1838             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
1839             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
1840             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
1841             
1842             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
1843             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
1844             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
1845
1846             /**************************
1847              * CALCULATE INTERACTIONS *
1848              **************************/
1849
1850             if (gmx_fjsp_any_lt_v2r8(rsq11,rcutoff2))
1851             {
1852
1853             /* REACTION-FIELD ELECTROSTATICS */
1854             felec            = _fjsp_mul_v2r8(qq11,_fjsp_msub_v2r8(rinv11,rinvsq11,krf2));
1855
1856             cutoff_mask      = _fjsp_cmplt_v2r8(rsq11,rcutoff2);
1857
1858             fscal            = felec;
1859
1860             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1861
1862             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1863
1864             /* Update vectorial force */
1865             fix1             = _fjsp_madd_v2r8(dx11,fscal,fix1);
1866             fiy1             = _fjsp_madd_v2r8(dy11,fscal,fiy1);
1867             fiz1             = _fjsp_madd_v2r8(dz11,fscal,fiz1);
1868             
1869             fjx1             = _fjsp_madd_v2r8(dx11,fscal,fjx1);
1870             fjy1             = _fjsp_madd_v2r8(dy11,fscal,fjy1);
1871             fjz1             = _fjsp_madd_v2r8(dz11,fscal,fjz1);
1872
1873             }
1874
1875             /**************************
1876              * CALCULATE INTERACTIONS *
1877              **************************/
1878
1879             if (gmx_fjsp_any_lt_v2r8(rsq12,rcutoff2))
1880             {
1881
1882             /* REACTION-FIELD ELECTROSTATICS */
1883             felec            = _fjsp_mul_v2r8(qq12,_fjsp_msub_v2r8(rinv12,rinvsq12,krf2));
1884
1885             cutoff_mask      = _fjsp_cmplt_v2r8(rsq12,rcutoff2);
1886
1887             fscal            = felec;
1888
1889             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1890
1891             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1892
1893             /* Update vectorial force */
1894             fix1             = _fjsp_madd_v2r8(dx12,fscal,fix1);
1895             fiy1             = _fjsp_madd_v2r8(dy12,fscal,fiy1);
1896             fiz1             = _fjsp_madd_v2r8(dz12,fscal,fiz1);
1897             
1898             fjx2             = _fjsp_madd_v2r8(dx12,fscal,fjx2);
1899             fjy2             = _fjsp_madd_v2r8(dy12,fscal,fjy2);
1900             fjz2             = _fjsp_madd_v2r8(dz12,fscal,fjz2);
1901
1902             }
1903
1904             /**************************
1905              * CALCULATE INTERACTIONS *
1906              **************************/
1907
1908             if (gmx_fjsp_any_lt_v2r8(rsq13,rcutoff2))
1909             {
1910
1911             /* REACTION-FIELD ELECTROSTATICS */
1912             felec            = _fjsp_mul_v2r8(qq13,_fjsp_msub_v2r8(rinv13,rinvsq13,krf2));
1913
1914             cutoff_mask      = _fjsp_cmplt_v2r8(rsq13,rcutoff2);
1915
1916             fscal            = felec;
1917
1918             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1919
1920             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1921
1922             /* Update vectorial force */
1923             fix1             = _fjsp_madd_v2r8(dx13,fscal,fix1);
1924             fiy1             = _fjsp_madd_v2r8(dy13,fscal,fiy1);
1925             fiz1             = _fjsp_madd_v2r8(dz13,fscal,fiz1);
1926             
1927             fjx3             = _fjsp_madd_v2r8(dx13,fscal,fjx3);
1928             fjy3             = _fjsp_madd_v2r8(dy13,fscal,fjy3);
1929             fjz3             = _fjsp_madd_v2r8(dz13,fscal,fjz3);
1930
1931             }
1932
1933             /**************************
1934              * CALCULATE INTERACTIONS *
1935              **************************/
1936
1937             if (gmx_fjsp_any_lt_v2r8(rsq21,rcutoff2))
1938             {
1939
1940             /* REACTION-FIELD ELECTROSTATICS */
1941             felec            = _fjsp_mul_v2r8(qq21,_fjsp_msub_v2r8(rinv21,rinvsq21,krf2));
1942
1943             cutoff_mask      = _fjsp_cmplt_v2r8(rsq21,rcutoff2);
1944
1945             fscal            = felec;
1946
1947             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1948
1949             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1950
1951             /* Update vectorial force */
1952             fix2             = _fjsp_madd_v2r8(dx21,fscal,fix2);
1953             fiy2             = _fjsp_madd_v2r8(dy21,fscal,fiy2);
1954             fiz2             = _fjsp_madd_v2r8(dz21,fscal,fiz2);
1955             
1956             fjx1             = _fjsp_madd_v2r8(dx21,fscal,fjx1);
1957             fjy1             = _fjsp_madd_v2r8(dy21,fscal,fjy1);
1958             fjz1             = _fjsp_madd_v2r8(dz21,fscal,fjz1);
1959
1960             }
1961
1962             /**************************
1963              * CALCULATE INTERACTIONS *
1964              **************************/
1965
1966             if (gmx_fjsp_any_lt_v2r8(rsq22,rcutoff2))
1967             {
1968
1969             /* REACTION-FIELD ELECTROSTATICS */
1970             felec            = _fjsp_mul_v2r8(qq22,_fjsp_msub_v2r8(rinv22,rinvsq22,krf2));
1971
1972             cutoff_mask      = _fjsp_cmplt_v2r8(rsq22,rcutoff2);
1973
1974             fscal            = felec;
1975
1976             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1977
1978             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1979
1980             /* Update vectorial force */
1981             fix2             = _fjsp_madd_v2r8(dx22,fscal,fix2);
1982             fiy2             = _fjsp_madd_v2r8(dy22,fscal,fiy2);
1983             fiz2             = _fjsp_madd_v2r8(dz22,fscal,fiz2);
1984             
1985             fjx2             = _fjsp_madd_v2r8(dx22,fscal,fjx2);
1986             fjy2             = _fjsp_madd_v2r8(dy22,fscal,fjy2);
1987             fjz2             = _fjsp_madd_v2r8(dz22,fscal,fjz2);
1988
1989             }
1990
1991             /**************************
1992              * CALCULATE INTERACTIONS *
1993              **************************/
1994
1995             if (gmx_fjsp_any_lt_v2r8(rsq23,rcutoff2))
1996             {
1997
1998             /* REACTION-FIELD ELECTROSTATICS */
1999             felec            = _fjsp_mul_v2r8(qq23,_fjsp_msub_v2r8(rinv23,rinvsq23,krf2));
2000
2001             cutoff_mask      = _fjsp_cmplt_v2r8(rsq23,rcutoff2);
2002
2003             fscal            = felec;
2004
2005             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
2006
2007             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
2008
2009             /* Update vectorial force */
2010             fix2             = _fjsp_madd_v2r8(dx23,fscal,fix2);
2011             fiy2             = _fjsp_madd_v2r8(dy23,fscal,fiy2);
2012             fiz2             = _fjsp_madd_v2r8(dz23,fscal,fiz2);
2013             
2014             fjx3             = _fjsp_madd_v2r8(dx23,fscal,fjx3);
2015             fjy3             = _fjsp_madd_v2r8(dy23,fscal,fjy3);
2016             fjz3             = _fjsp_madd_v2r8(dz23,fscal,fjz3);
2017
2018             }
2019
2020             /**************************
2021              * CALCULATE INTERACTIONS *
2022              **************************/
2023
2024             if (gmx_fjsp_any_lt_v2r8(rsq31,rcutoff2))
2025             {
2026
2027             /* REACTION-FIELD ELECTROSTATICS */
2028             felec            = _fjsp_mul_v2r8(qq31,_fjsp_msub_v2r8(rinv31,rinvsq31,krf2));
2029
2030             cutoff_mask      = _fjsp_cmplt_v2r8(rsq31,rcutoff2);
2031
2032             fscal            = felec;
2033
2034             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
2035
2036             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
2037
2038             /* Update vectorial force */
2039             fix3             = _fjsp_madd_v2r8(dx31,fscal,fix3);
2040             fiy3             = _fjsp_madd_v2r8(dy31,fscal,fiy3);
2041             fiz3             = _fjsp_madd_v2r8(dz31,fscal,fiz3);
2042             
2043             fjx1             = _fjsp_madd_v2r8(dx31,fscal,fjx1);
2044             fjy1             = _fjsp_madd_v2r8(dy31,fscal,fjy1);
2045             fjz1             = _fjsp_madd_v2r8(dz31,fscal,fjz1);
2046
2047             }
2048
2049             /**************************
2050              * CALCULATE INTERACTIONS *
2051              **************************/
2052
2053             if (gmx_fjsp_any_lt_v2r8(rsq32,rcutoff2))
2054             {
2055
2056             /* REACTION-FIELD ELECTROSTATICS */
2057             felec            = _fjsp_mul_v2r8(qq32,_fjsp_msub_v2r8(rinv32,rinvsq32,krf2));
2058
2059             cutoff_mask      = _fjsp_cmplt_v2r8(rsq32,rcutoff2);
2060
2061             fscal            = felec;
2062
2063             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
2064
2065             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
2066
2067             /* Update vectorial force */
2068             fix3             = _fjsp_madd_v2r8(dx32,fscal,fix3);
2069             fiy3             = _fjsp_madd_v2r8(dy32,fscal,fiy3);
2070             fiz3             = _fjsp_madd_v2r8(dz32,fscal,fiz3);
2071             
2072             fjx2             = _fjsp_madd_v2r8(dx32,fscal,fjx2);
2073             fjy2             = _fjsp_madd_v2r8(dy32,fscal,fjy2);
2074             fjz2             = _fjsp_madd_v2r8(dz32,fscal,fjz2);
2075
2076             }
2077
2078             /**************************
2079              * CALCULATE INTERACTIONS *
2080              **************************/
2081
2082             if (gmx_fjsp_any_lt_v2r8(rsq33,rcutoff2))
2083             {
2084
2085             /* REACTION-FIELD ELECTROSTATICS */
2086             felec            = _fjsp_mul_v2r8(qq33,_fjsp_msub_v2r8(rinv33,rinvsq33,krf2));
2087
2088             cutoff_mask      = _fjsp_cmplt_v2r8(rsq33,rcutoff2);
2089
2090             fscal            = felec;
2091
2092             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
2093
2094             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
2095
2096             /* Update vectorial force */
2097             fix3             = _fjsp_madd_v2r8(dx33,fscal,fix3);
2098             fiy3             = _fjsp_madd_v2r8(dy33,fscal,fiy3);
2099             fiz3             = _fjsp_madd_v2r8(dz33,fscal,fiz3);
2100             
2101             fjx3             = _fjsp_madd_v2r8(dx33,fscal,fjx3);
2102             fjy3             = _fjsp_madd_v2r8(dy33,fscal,fjy3);
2103             fjz3             = _fjsp_madd_v2r8(dz33,fscal,fjz3);
2104
2105             }
2106
2107             gmx_fjsp_decrement_4rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
2108
2109             /* Inner loop uses 351 flops */
2110         }
2111
2112         /* End of innermost loop */
2113
2114         gmx_fjsp_update_iforce_4atom_swizzle_v2r8(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
2115                                               f+i_coord_offset,fshift+i_shift_offset);
2116
2117         /* Increment number of inner iterations */
2118         inneriter                  += j_index_end - j_index_start;
2119
2120         /* Outer loop uses 24 flops */
2121     }
2122
2123     /* Increment number of outer iterations */
2124     outeriter        += nri;
2125
2126     /* Update outer/inner flops */
2127
2128     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*24 + inneriter*351);
2129 }