Compile nonbonded kernels as C++
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_sparc64_hpc_ace_double / nb_kernel_ElecRF_VdwLJ_GeomW4W4_sparc64_hpc_ace_double.cpp
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 2012,2013,2014,2015,2017,2018, by the GROMACS development team, led by
5  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6  * and including many others, as listed in the AUTHORS file in the
7  * top-level source directory and at http://www.gromacs.org.
8  *
9  * GROMACS is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public License
11  * as published by the Free Software Foundation; either version 2.1
12  * of the License, or (at your option) any later version.
13  *
14  * GROMACS is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with GROMACS; if not, see
21  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
23  *
24  * If you want to redistribute modifications to GROMACS, please
25  * consider that scientific software is very special. Version
26  * control is crucial - bugs must be traceable. We will be happy to
27  * consider code for inclusion in the official distribution, but
28  * derived work must not be called official GROMACS. Details are found
29  * in the README & COPYING files - if they are missing, get the
30  * official version at http://www.gromacs.org.
31  *
32  * To help us fund GROMACS development, we humbly ask that you cite
33  * the research papers on the package. Check out http://www.gromacs.org.
34  */
35 /*
36  * Note: this file was generated by the GROMACS sparc64_hpc_ace_double kernel generator.
37  */
38 #include "gmxpre.h"
39
40 #include "config.h"
41
42 #include <math.h>
43
44 #include "../nb_kernel.h"
45 #include "gromacs/gmxlib/nrnb.h"
46
47 #include "kernelutil_sparc64_hpc_ace_double.h"
48
49 /*
50  * Gromacs nonbonded kernel:   nb_kernel_ElecRF_VdwLJ_GeomW4W4_VF_sparc64_hpc_ace_double
51  * Electrostatics interaction: ReactionField
52  * VdW interaction:            LennardJones
53  * Geometry:                   Water4-Water4
54  * Calculate force/pot:        PotentialAndForce
55  */
56 void
57 nb_kernel_ElecRF_VdwLJ_GeomW4W4_VF_sparc64_hpc_ace_double
58                     (t_nblist                    * gmx_restrict       nlist,
59                      rvec                        * gmx_restrict          xx,
60                      rvec                        * gmx_restrict          ff,
61                      struct 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       itab_tmp;
114     _fjsp_v2r8       dummy_mask,cutoff_mask;
115     _fjsp_v2r8       one     = gmx_fjsp_set1_v2r8(1.0);
116     _fjsp_v2r8       two     = gmx_fjsp_set1_v2r8(2.0);
117     union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
118
119     x                = xx[0];
120     f                = ff[0];
121
122     nri              = nlist->nri;
123     iinr             = nlist->iinr;
124     jindex           = nlist->jindex;
125     jjnr             = nlist->jjnr;
126     shiftidx         = nlist->shift;
127     gid              = nlist->gid;
128     shiftvec         = fr->shift_vec[0];
129     fshift           = fr->fshift[0];
130     facel            = gmx_fjsp_set1_v2r8(fr->ic->epsfac);
131     charge           = mdatoms->chargeA;
132     krf              = gmx_fjsp_set1_v2r8(fr->ic->k_rf);
133     krf2             = gmx_fjsp_set1_v2r8(fr->ic->k_rf*2.0);
134     crf              = gmx_fjsp_set1_v2r8(fr->ic->c_rf);
135     nvdwtype         = fr->ntype;
136     vdwparam         = fr->nbfp;
137     vdwtype          = mdatoms->typeA;
138
139     /* Setup water-specific parameters */
140     inr              = nlist->iinr[0];
141     iq1              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+1]));
142     iq2              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+2]));
143     iq3              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+3]));
144     vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
145
146     jq1              = gmx_fjsp_set1_v2r8(charge[inr+1]);
147     jq2              = gmx_fjsp_set1_v2r8(charge[inr+2]);
148     jq3              = gmx_fjsp_set1_v2r8(charge[inr+3]);
149     vdwjidx0A        = 2*vdwtype[inr+0];
150     c6_00            = gmx_fjsp_set1_v2r8(vdwparam[vdwioffset0+vdwjidx0A]);
151     c12_00           = gmx_fjsp_set1_v2r8(vdwparam[vdwioffset0+vdwjidx0A+1]);
152     qq11             = _fjsp_mul_v2r8(iq1,jq1);
153     qq12             = _fjsp_mul_v2r8(iq1,jq2);
154     qq13             = _fjsp_mul_v2r8(iq1,jq3);
155     qq21             = _fjsp_mul_v2r8(iq2,jq1);
156     qq22             = _fjsp_mul_v2r8(iq2,jq2);
157     qq23             = _fjsp_mul_v2r8(iq2,jq3);
158     qq31             = _fjsp_mul_v2r8(iq3,jq1);
159     qq32             = _fjsp_mul_v2r8(iq3,jq2);
160     qq33             = _fjsp_mul_v2r8(iq3,jq3);
161
162     /* Avoid stupid compiler warnings */
163     jnrA = jnrB = 0;
164     j_coord_offsetA = 0;
165     j_coord_offsetB = 0;
166
167     outeriter        = 0;
168     inneriter        = 0;
169
170     /* Start outer loop over neighborlists */
171     for(iidx=0; iidx<nri; iidx++)
172     {
173         /* Load shift vector for this list */
174         i_shift_offset   = DIM*shiftidx[iidx];
175
176         /* Load limits for loop over neighbors */
177         j_index_start    = jindex[iidx];
178         j_index_end      = jindex[iidx+1];
179
180         /* Get outer coordinate index */
181         inr              = iinr[iidx];
182         i_coord_offset   = DIM*inr;
183
184         /* Load i particle coords and add shift vector */
185         gmx_fjsp_load_shift_and_4rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,
186                                                  &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
187
188         fix0             = _fjsp_setzero_v2r8();
189         fiy0             = _fjsp_setzero_v2r8();
190         fiz0             = _fjsp_setzero_v2r8();
191         fix1             = _fjsp_setzero_v2r8();
192         fiy1             = _fjsp_setzero_v2r8();
193         fiz1             = _fjsp_setzero_v2r8();
194         fix2             = _fjsp_setzero_v2r8();
195         fiy2             = _fjsp_setzero_v2r8();
196         fiz2             = _fjsp_setzero_v2r8();
197         fix3             = _fjsp_setzero_v2r8();
198         fiy3             = _fjsp_setzero_v2r8();
199         fiz3             = _fjsp_setzero_v2r8();
200
201         /* Reset potential sums */
202         velecsum         = _fjsp_setzero_v2r8();
203         vvdwsum          = _fjsp_setzero_v2r8();
204
205         /* Start inner kernel loop */
206         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
207         {
208
209             /* Get j neighbor index, and coordinate index */
210             jnrA             = jjnr[jidx];
211             jnrB             = jjnr[jidx+1];
212             j_coord_offsetA  = DIM*jnrA;
213             j_coord_offsetB  = DIM*jnrB;
214
215             /* load j atom coordinates */
216             gmx_fjsp_load_4rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
217                                               &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,
218                                               &jy2,&jz2,&jx3,&jy3,&jz3);
219
220             /* Calculate displacement vector */
221             dx00             = _fjsp_sub_v2r8(ix0,jx0);
222             dy00             = _fjsp_sub_v2r8(iy0,jy0);
223             dz00             = _fjsp_sub_v2r8(iz0,jz0);
224             dx11             = _fjsp_sub_v2r8(ix1,jx1);
225             dy11             = _fjsp_sub_v2r8(iy1,jy1);
226             dz11             = _fjsp_sub_v2r8(iz1,jz1);
227             dx12             = _fjsp_sub_v2r8(ix1,jx2);
228             dy12             = _fjsp_sub_v2r8(iy1,jy2);
229             dz12             = _fjsp_sub_v2r8(iz1,jz2);
230             dx13             = _fjsp_sub_v2r8(ix1,jx3);
231             dy13             = _fjsp_sub_v2r8(iy1,jy3);
232             dz13             = _fjsp_sub_v2r8(iz1,jz3);
233             dx21             = _fjsp_sub_v2r8(ix2,jx1);
234             dy21             = _fjsp_sub_v2r8(iy2,jy1);
235             dz21             = _fjsp_sub_v2r8(iz2,jz1);
236             dx22             = _fjsp_sub_v2r8(ix2,jx2);
237             dy22             = _fjsp_sub_v2r8(iy2,jy2);
238             dz22             = _fjsp_sub_v2r8(iz2,jz2);
239             dx23             = _fjsp_sub_v2r8(ix2,jx3);
240             dy23             = _fjsp_sub_v2r8(iy2,jy3);
241             dz23             = _fjsp_sub_v2r8(iz2,jz3);
242             dx31             = _fjsp_sub_v2r8(ix3,jx1);
243             dy31             = _fjsp_sub_v2r8(iy3,jy1);
244             dz31             = _fjsp_sub_v2r8(iz3,jz1);
245             dx32             = _fjsp_sub_v2r8(ix3,jx2);
246             dy32             = _fjsp_sub_v2r8(iy3,jy2);
247             dz32             = _fjsp_sub_v2r8(iz3,jz2);
248             dx33             = _fjsp_sub_v2r8(ix3,jx3);
249             dy33             = _fjsp_sub_v2r8(iy3,jy3);
250             dz33             = _fjsp_sub_v2r8(iz3,jz3);
251
252             /* Calculate squared distance and things based on it */
253             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
254             rsq11            = gmx_fjsp_calc_rsq_v2r8(dx11,dy11,dz11);
255             rsq12            = gmx_fjsp_calc_rsq_v2r8(dx12,dy12,dz12);
256             rsq13            = gmx_fjsp_calc_rsq_v2r8(dx13,dy13,dz13);
257             rsq21            = gmx_fjsp_calc_rsq_v2r8(dx21,dy21,dz21);
258             rsq22            = gmx_fjsp_calc_rsq_v2r8(dx22,dy22,dz22);
259             rsq23            = gmx_fjsp_calc_rsq_v2r8(dx23,dy23,dz23);
260             rsq31            = gmx_fjsp_calc_rsq_v2r8(dx31,dy31,dz31);
261             rsq32            = gmx_fjsp_calc_rsq_v2r8(dx32,dy32,dz32);
262             rsq33            = gmx_fjsp_calc_rsq_v2r8(dx33,dy33,dz33);
263
264             rinv11           = gmx_fjsp_invsqrt_v2r8(rsq11);
265             rinv12           = gmx_fjsp_invsqrt_v2r8(rsq12);
266             rinv13           = gmx_fjsp_invsqrt_v2r8(rsq13);
267             rinv21           = gmx_fjsp_invsqrt_v2r8(rsq21);
268             rinv22           = gmx_fjsp_invsqrt_v2r8(rsq22);
269             rinv23           = gmx_fjsp_invsqrt_v2r8(rsq23);
270             rinv31           = gmx_fjsp_invsqrt_v2r8(rsq31);
271             rinv32           = gmx_fjsp_invsqrt_v2r8(rsq32);
272             rinv33           = gmx_fjsp_invsqrt_v2r8(rsq33);
273
274             rinvsq00         = gmx_fjsp_inv_v2r8(rsq00);
275             rinvsq11         = _fjsp_mul_v2r8(rinv11,rinv11);
276             rinvsq12         = _fjsp_mul_v2r8(rinv12,rinv12);
277             rinvsq13         = _fjsp_mul_v2r8(rinv13,rinv13);
278             rinvsq21         = _fjsp_mul_v2r8(rinv21,rinv21);
279             rinvsq22         = _fjsp_mul_v2r8(rinv22,rinv22);
280             rinvsq23         = _fjsp_mul_v2r8(rinv23,rinv23);
281             rinvsq31         = _fjsp_mul_v2r8(rinv31,rinv31);
282             rinvsq32         = _fjsp_mul_v2r8(rinv32,rinv32);
283             rinvsq33         = _fjsp_mul_v2r8(rinv33,rinv33);
284
285             fjx0             = _fjsp_setzero_v2r8();
286             fjy0             = _fjsp_setzero_v2r8();
287             fjz0             = _fjsp_setzero_v2r8();
288             fjx1             = _fjsp_setzero_v2r8();
289             fjy1             = _fjsp_setzero_v2r8();
290             fjz1             = _fjsp_setzero_v2r8();
291             fjx2             = _fjsp_setzero_v2r8();
292             fjy2             = _fjsp_setzero_v2r8();
293             fjz2             = _fjsp_setzero_v2r8();
294             fjx3             = _fjsp_setzero_v2r8();
295             fjy3             = _fjsp_setzero_v2r8();
296             fjz3             = _fjsp_setzero_v2r8();
297
298             /**************************
299              * CALCULATE INTERACTIONS *
300              **************************/
301
302             /* LENNARD-JONES DISPERSION/REPULSION */
303
304             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
305             vvdw6            = _fjsp_mul_v2r8(c6_00,rinvsix);
306             vvdw12           = _fjsp_mul_v2r8(c12_00,_fjsp_mul_v2r8(rinvsix,rinvsix));
307             vvdw             = _fjsp_msub_v2r8( vvdw12,one_twelfth, _fjsp_mul_v2r8(vvdw6,one_sixth) );
308             fvdw             = _fjsp_mul_v2r8(_fjsp_sub_v2r8(vvdw12,vvdw6),rinvsq00);
309
310             /* Update potential sum for this i atom from the interaction with this j atom. */
311             vvdwsum          = _fjsp_add_v2r8(vvdwsum,vvdw);
312
313             fscal            = fvdw;
314
315             /* Update vectorial force */
316             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
317             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
318             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
319             
320             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
321             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
322             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
323
324             /**************************
325              * CALCULATE INTERACTIONS *
326              **************************/
327
328             /* REACTION-FIELD ELECTROSTATICS */
329             velec            = _fjsp_mul_v2r8(qq11,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq11,rinv11),crf));
330             felec            = _fjsp_mul_v2r8(qq11,_fjsp_msub_v2r8(rinv11,rinvsq11,krf2));
331
332             /* Update potential sum for this i atom from the interaction with this j atom. */
333             velecsum         = _fjsp_add_v2r8(velecsum,velec);
334
335             fscal            = felec;
336
337             /* Update vectorial force */
338             fix1             = _fjsp_madd_v2r8(dx11,fscal,fix1);
339             fiy1             = _fjsp_madd_v2r8(dy11,fscal,fiy1);
340             fiz1             = _fjsp_madd_v2r8(dz11,fscal,fiz1);
341             
342             fjx1             = _fjsp_madd_v2r8(dx11,fscal,fjx1);
343             fjy1             = _fjsp_madd_v2r8(dy11,fscal,fjy1);
344             fjz1             = _fjsp_madd_v2r8(dz11,fscal,fjz1);
345
346             /**************************
347              * CALCULATE INTERACTIONS *
348              **************************/
349
350             /* REACTION-FIELD ELECTROSTATICS */
351             velec            = _fjsp_mul_v2r8(qq12,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq12,rinv12),crf));
352             felec            = _fjsp_mul_v2r8(qq12,_fjsp_msub_v2r8(rinv12,rinvsq12,krf2));
353
354             /* Update potential sum for this i atom from the interaction with this j atom. */
355             velecsum         = _fjsp_add_v2r8(velecsum,velec);
356
357             fscal            = felec;
358
359             /* Update vectorial force */
360             fix1             = _fjsp_madd_v2r8(dx12,fscal,fix1);
361             fiy1             = _fjsp_madd_v2r8(dy12,fscal,fiy1);
362             fiz1             = _fjsp_madd_v2r8(dz12,fscal,fiz1);
363             
364             fjx2             = _fjsp_madd_v2r8(dx12,fscal,fjx2);
365             fjy2             = _fjsp_madd_v2r8(dy12,fscal,fjy2);
366             fjz2             = _fjsp_madd_v2r8(dz12,fscal,fjz2);
367
368             /**************************
369              * CALCULATE INTERACTIONS *
370              **************************/
371
372             /* REACTION-FIELD ELECTROSTATICS */
373             velec            = _fjsp_mul_v2r8(qq13,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq13,rinv13),crf));
374             felec            = _fjsp_mul_v2r8(qq13,_fjsp_msub_v2r8(rinv13,rinvsq13,krf2));
375
376             /* Update potential sum for this i atom from the interaction with this j atom. */
377             velecsum         = _fjsp_add_v2r8(velecsum,velec);
378
379             fscal            = felec;
380
381             /* Update vectorial force */
382             fix1             = _fjsp_madd_v2r8(dx13,fscal,fix1);
383             fiy1             = _fjsp_madd_v2r8(dy13,fscal,fiy1);
384             fiz1             = _fjsp_madd_v2r8(dz13,fscal,fiz1);
385             
386             fjx3             = _fjsp_madd_v2r8(dx13,fscal,fjx3);
387             fjy3             = _fjsp_madd_v2r8(dy13,fscal,fjy3);
388             fjz3             = _fjsp_madd_v2r8(dz13,fscal,fjz3);
389
390             /**************************
391              * CALCULATE INTERACTIONS *
392              **************************/
393
394             /* REACTION-FIELD ELECTROSTATICS */
395             velec            = _fjsp_mul_v2r8(qq21,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq21,rinv21),crf));
396             felec            = _fjsp_mul_v2r8(qq21,_fjsp_msub_v2r8(rinv21,rinvsq21,krf2));
397
398             /* Update potential sum for this i atom from the interaction with this j atom. */
399             velecsum         = _fjsp_add_v2r8(velecsum,velec);
400
401             fscal            = felec;
402
403             /* Update vectorial force */
404             fix2             = _fjsp_madd_v2r8(dx21,fscal,fix2);
405             fiy2             = _fjsp_madd_v2r8(dy21,fscal,fiy2);
406             fiz2             = _fjsp_madd_v2r8(dz21,fscal,fiz2);
407             
408             fjx1             = _fjsp_madd_v2r8(dx21,fscal,fjx1);
409             fjy1             = _fjsp_madd_v2r8(dy21,fscal,fjy1);
410             fjz1             = _fjsp_madd_v2r8(dz21,fscal,fjz1);
411
412             /**************************
413              * CALCULATE INTERACTIONS *
414              **************************/
415
416             /* REACTION-FIELD ELECTROSTATICS */
417             velec            = _fjsp_mul_v2r8(qq22,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq22,rinv22),crf));
418             felec            = _fjsp_mul_v2r8(qq22,_fjsp_msub_v2r8(rinv22,rinvsq22,krf2));
419
420             /* Update potential sum for this i atom from the interaction with this j atom. */
421             velecsum         = _fjsp_add_v2r8(velecsum,velec);
422
423             fscal            = felec;
424
425             /* Update vectorial force */
426             fix2             = _fjsp_madd_v2r8(dx22,fscal,fix2);
427             fiy2             = _fjsp_madd_v2r8(dy22,fscal,fiy2);
428             fiz2             = _fjsp_madd_v2r8(dz22,fscal,fiz2);
429             
430             fjx2             = _fjsp_madd_v2r8(dx22,fscal,fjx2);
431             fjy2             = _fjsp_madd_v2r8(dy22,fscal,fjy2);
432             fjz2             = _fjsp_madd_v2r8(dz22,fscal,fjz2);
433
434             /**************************
435              * CALCULATE INTERACTIONS *
436              **************************/
437
438             /* REACTION-FIELD ELECTROSTATICS */
439             velec            = _fjsp_mul_v2r8(qq23,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq23,rinv23),crf));
440             felec            = _fjsp_mul_v2r8(qq23,_fjsp_msub_v2r8(rinv23,rinvsq23,krf2));
441
442             /* Update potential sum for this i atom from the interaction with this j atom. */
443             velecsum         = _fjsp_add_v2r8(velecsum,velec);
444
445             fscal            = felec;
446
447             /* Update vectorial force */
448             fix2             = _fjsp_madd_v2r8(dx23,fscal,fix2);
449             fiy2             = _fjsp_madd_v2r8(dy23,fscal,fiy2);
450             fiz2             = _fjsp_madd_v2r8(dz23,fscal,fiz2);
451             
452             fjx3             = _fjsp_madd_v2r8(dx23,fscal,fjx3);
453             fjy3             = _fjsp_madd_v2r8(dy23,fscal,fjy3);
454             fjz3             = _fjsp_madd_v2r8(dz23,fscal,fjz3);
455
456             /**************************
457              * CALCULATE INTERACTIONS *
458              **************************/
459
460             /* REACTION-FIELD ELECTROSTATICS */
461             velec            = _fjsp_mul_v2r8(qq31,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq31,rinv31),crf));
462             felec            = _fjsp_mul_v2r8(qq31,_fjsp_msub_v2r8(rinv31,rinvsq31,krf2));
463
464             /* Update potential sum for this i atom from the interaction with this j atom. */
465             velecsum         = _fjsp_add_v2r8(velecsum,velec);
466
467             fscal            = felec;
468
469             /* Update vectorial force */
470             fix3             = _fjsp_madd_v2r8(dx31,fscal,fix3);
471             fiy3             = _fjsp_madd_v2r8(dy31,fscal,fiy3);
472             fiz3             = _fjsp_madd_v2r8(dz31,fscal,fiz3);
473             
474             fjx1             = _fjsp_madd_v2r8(dx31,fscal,fjx1);
475             fjy1             = _fjsp_madd_v2r8(dy31,fscal,fjy1);
476             fjz1             = _fjsp_madd_v2r8(dz31,fscal,fjz1);
477
478             /**************************
479              * CALCULATE INTERACTIONS *
480              **************************/
481
482             /* REACTION-FIELD ELECTROSTATICS */
483             velec            = _fjsp_mul_v2r8(qq32,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq32,rinv32),crf));
484             felec            = _fjsp_mul_v2r8(qq32,_fjsp_msub_v2r8(rinv32,rinvsq32,krf2));
485
486             /* Update potential sum for this i atom from the interaction with this j atom. */
487             velecsum         = _fjsp_add_v2r8(velecsum,velec);
488
489             fscal            = felec;
490
491             /* Update vectorial force */
492             fix3             = _fjsp_madd_v2r8(dx32,fscal,fix3);
493             fiy3             = _fjsp_madd_v2r8(dy32,fscal,fiy3);
494             fiz3             = _fjsp_madd_v2r8(dz32,fscal,fiz3);
495             
496             fjx2             = _fjsp_madd_v2r8(dx32,fscal,fjx2);
497             fjy2             = _fjsp_madd_v2r8(dy32,fscal,fjy2);
498             fjz2             = _fjsp_madd_v2r8(dz32,fscal,fjz2);
499
500             /**************************
501              * CALCULATE INTERACTIONS *
502              **************************/
503
504             /* REACTION-FIELD ELECTROSTATICS */
505             velec            = _fjsp_mul_v2r8(qq33,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq33,rinv33),crf));
506             felec            = _fjsp_mul_v2r8(qq33,_fjsp_msub_v2r8(rinv33,rinvsq33,krf2));
507
508             /* Update potential sum for this i atom from the interaction with this j atom. */
509             velecsum         = _fjsp_add_v2r8(velecsum,velec);
510
511             fscal            = felec;
512
513             /* Update vectorial force */
514             fix3             = _fjsp_madd_v2r8(dx33,fscal,fix3);
515             fiy3             = _fjsp_madd_v2r8(dy33,fscal,fiy3);
516             fiz3             = _fjsp_madd_v2r8(dz33,fscal,fiz3);
517             
518             fjx3             = _fjsp_madd_v2r8(dx33,fscal,fjx3);
519             fjy3             = _fjsp_madd_v2r8(dy33,fscal,fjy3);
520             fjz3             = _fjsp_madd_v2r8(dz33,fscal,fjz3);
521
522             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);
523
524             /* Inner loop uses 353 flops */
525         }
526
527         if(jidx<j_index_end)
528         {
529
530             jnrA             = jjnr[jidx];
531             j_coord_offsetA  = DIM*jnrA;
532
533             /* load j atom coordinates */
534             gmx_fjsp_load_4rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
535                                               &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,
536                                               &jy2,&jz2,&jx3,&jy3,&jz3);
537
538             /* Calculate displacement vector */
539             dx00             = _fjsp_sub_v2r8(ix0,jx0);
540             dy00             = _fjsp_sub_v2r8(iy0,jy0);
541             dz00             = _fjsp_sub_v2r8(iz0,jz0);
542             dx11             = _fjsp_sub_v2r8(ix1,jx1);
543             dy11             = _fjsp_sub_v2r8(iy1,jy1);
544             dz11             = _fjsp_sub_v2r8(iz1,jz1);
545             dx12             = _fjsp_sub_v2r8(ix1,jx2);
546             dy12             = _fjsp_sub_v2r8(iy1,jy2);
547             dz12             = _fjsp_sub_v2r8(iz1,jz2);
548             dx13             = _fjsp_sub_v2r8(ix1,jx3);
549             dy13             = _fjsp_sub_v2r8(iy1,jy3);
550             dz13             = _fjsp_sub_v2r8(iz1,jz3);
551             dx21             = _fjsp_sub_v2r8(ix2,jx1);
552             dy21             = _fjsp_sub_v2r8(iy2,jy1);
553             dz21             = _fjsp_sub_v2r8(iz2,jz1);
554             dx22             = _fjsp_sub_v2r8(ix2,jx2);
555             dy22             = _fjsp_sub_v2r8(iy2,jy2);
556             dz22             = _fjsp_sub_v2r8(iz2,jz2);
557             dx23             = _fjsp_sub_v2r8(ix2,jx3);
558             dy23             = _fjsp_sub_v2r8(iy2,jy3);
559             dz23             = _fjsp_sub_v2r8(iz2,jz3);
560             dx31             = _fjsp_sub_v2r8(ix3,jx1);
561             dy31             = _fjsp_sub_v2r8(iy3,jy1);
562             dz31             = _fjsp_sub_v2r8(iz3,jz1);
563             dx32             = _fjsp_sub_v2r8(ix3,jx2);
564             dy32             = _fjsp_sub_v2r8(iy3,jy2);
565             dz32             = _fjsp_sub_v2r8(iz3,jz2);
566             dx33             = _fjsp_sub_v2r8(ix3,jx3);
567             dy33             = _fjsp_sub_v2r8(iy3,jy3);
568             dz33             = _fjsp_sub_v2r8(iz3,jz3);
569
570             /* Calculate squared distance and things based on it */
571             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
572             rsq11            = gmx_fjsp_calc_rsq_v2r8(dx11,dy11,dz11);
573             rsq12            = gmx_fjsp_calc_rsq_v2r8(dx12,dy12,dz12);
574             rsq13            = gmx_fjsp_calc_rsq_v2r8(dx13,dy13,dz13);
575             rsq21            = gmx_fjsp_calc_rsq_v2r8(dx21,dy21,dz21);
576             rsq22            = gmx_fjsp_calc_rsq_v2r8(dx22,dy22,dz22);
577             rsq23            = gmx_fjsp_calc_rsq_v2r8(dx23,dy23,dz23);
578             rsq31            = gmx_fjsp_calc_rsq_v2r8(dx31,dy31,dz31);
579             rsq32            = gmx_fjsp_calc_rsq_v2r8(dx32,dy32,dz32);
580             rsq33            = gmx_fjsp_calc_rsq_v2r8(dx33,dy33,dz33);
581
582             rinv11           = gmx_fjsp_invsqrt_v2r8(rsq11);
583             rinv12           = gmx_fjsp_invsqrt_v2r8(rsq12);
584             rinv13           = gmx_fjsp_invsqrt_v2r8(rsq13);
585             rinv21           = gmx_fjsp_invsqrt_v2r8(rsq21);
586             rinv22           = gmx_fjsp_invsqrt_v2r8(rsq22);
587             rinv23           = gmx_fjsp_invsqrt_v2r8(rsq23);
588             rinv31           = gmx_fjsp_invsqrt_v2r8(rsq31);
589             rinv32           = gmx_fjsp_invsqrt_v2r8(rsq32);
590             rinv33           = gmx_fjsp_invsqrt_v2r8(rsq33);
591
592             rinvsq00         = gmx_fjsp_inv_v2r8(rsq00);
593             rinvsq11         = _fjsp_mul_v2r8(rinv11,rinv11);
594             rinvsq12         = _fjsp_mul_v2r8(rinv12,rinv12);
595             rinvsq13         = _fjsp_mul_v2r8(rinv13,rinv13);
596             rinvsq21         = _fjsp_mul_v2r8(rinv21,rinv21);
597             rinvsq22         = _fjsp_mul_v2r8(rinv22,rinv22);
598             rinvsq23         = _fjsp_mul_v2r8(rinv23,rinv23);
599             rinvsq31         = _fjsp_mul_v2r8(rinv31,rinv31);
600             rinvsq32         = _fjsp_mul_v2r8(rinv32,rinv32);
601             rinvsq33         = _fjsp_mul_v2r8(rinv33,rinv33);
602
603             fjx0             = _fjsp_setzero_v2r8();
604             fjy0             = _fjsp_setzero_v2r8();
605             fjz0             = _fjsp_setzero_v2r8();
606             fjx1             = _fjsp_setzero_v2r8();
607             fjy1             = _fjsp_setzero_v2r8();
608             fjz1             = _fjsp_setzero_v2r8();
609             fjx2             = _fjsp_setzero_v2r8();
610             fjy2             = _fjsp_setzero_v2r8();
611             fjz2             = _fjsp_setzero_v2r8();
612             fjx3             = _fjsp_setzero_v2r8();
613             fjy3             = _fjsp_setzero_v2r8();
614             fjz3             = _fjsp_setzero_v2r8();
615
616             /**************************
617              * CALCULATE INTERACTIONS *
618              **************************/
619
620             /* LENNARD-JONES DISPERSION/REPULSION */
621
622             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
623             vvdw6            = _fjsp_mul_v2r8(c6_00,rinvsix);
624             vvdw12           = _fjsp_mul_v2r8(c12_00,_fjsp_mul_v2r8(rinvsix,rinvsix));
625             vvdw             = _fjsp_msub_v2r8( vvdw12,one_twelfth, _fjsp_mul_v2r8(vvdw6,one_sixth) );
626             fvdw             = _fjsp_mul_v2r8(_fjsp_sub_v2r8(vvdw12,vvdw6),rinvsq00);
627
628             /* Update potential sum for this i atom from the interaction with this j atom. */
629             vvdw             = _fjsp_unpacklo_v2r8(vvdw,_fjsp_setzero_v2r8());
630             vvdwsum          = _fjsp_add_v2r8(vvdwsum,vvdw);
631
632             fscal            = fvdw;
633
634             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
635
636             /* Update vectorial force */
637             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
638             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
639             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
640             
641             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
642             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
643             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
644
645             /**************************
646              * CALCULATE INTERACTIONS *
647              **************************/
648
649             /* REACTION-FIELD ELECTROSTATICS */
650             velec            = _fjsp_mul_v2r8(qq11,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq11,rinv11),crf));
651             felec            = _fjsp_mul_v2r8(qq11,_fjsp_msub_v2r8(rinv11,rinvsq11,krf2));
652
653             /* Update potential sum for this i atom from the interaction with this j atom. */
654             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
655             velecsum         = _fjsp_add_v2r8(velecsum,velec);
656
657             fscal            = felec;
658
659             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
660
661             /* Update vectorial force */
662             fix1             = _fjsp_madd_v2r8(dx11,fscal,fix1);
663             fiy1             = _fjsp_madd_v2r8(dy11,fscal,fiy1);
664             fiz1             = _fjsp_madd_v2r8(dz11,fscal,fiz1);
665             
666             fjx1             = _fjsp_madd_v2r8(dx11,fscal,fjx1);
667             fjy1             = _fjsp_madd_v2r8(dy11,fscal,fjy1);
668             fjz1             = _fjsp_madd_v2r8(dz11,fscal,fjz1);
669
670             /**************************
671              * CALCULATE INTERACTIONS *
672              **************************/
673
674             /* REACTION-FIELD ELECTROSTATICS */
675             velec            = _fjsp_mul_v2r8(qq12,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq12,rinv12),crf));
676             felec            = _fjsp_mul_v2r8(qq12,_fjsp_msub_v2r8(rinv12,rinvsq12,krf2));
677
678             /* Update potential sum for this i atom from the interaction with this j atom. */
679             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
680             velecsum         = _fjsp_add_v2r8(velecsum,velec);
681
682             fscal            = felec;
683
684             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
685
686             /* Update vectorial force */
687             fix1             = _fjsp_madd_v2r8(dx12,fscal,fix1);
688             fiy1             = _fjsp_madd_v2r8(dy12,fscal,fiy1);
689             fiz1             = _fjsp_madd_v2r8(dz12,fscal,fiz1);
690             
691             fjx2             = _fjsp_madd_v2r8(dx12,fscal,fjx2);
692             fjy2             = _fjsp_madd_v2r8(dy12,fscal,fjy2);
693             fjz2             = _fjsp_madd_v2r8(dz12,fscal,fjz2);
694
695             /**************************
696              * CALCULATE INTERACTIONS *
697              **************************/
698
699             /* REACTION-FIELD ELECTROSTATICS */
700             velec            = _fjsp_mul_v2r8(qq13,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq13,rinv13),crf));
701             felec            = _fjsp_mul_v2r8(qq13,_fjsp_msub_v2r8(rinv13,rinvsq13,krf2));
702
703             /* Update potential sum for this i atom from the interaction with this j atom. */
704             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
705             velecsum         = _fjsp_add_v2r8(velecsum,velec);
706
707             fscal            = felec;
708
709             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
710
711             /* Update vectorial force */
712             fix1             = _fjsp_madd_v2r8(dx13,fscal,fix1);
713             fiy1             = _fjsp_madd_v2r8(dy13,fscal,fiy1);
714             fiz1             = _fjsp_madd_v2r8(dz13,fscal,fiz1);
715             
716             fjx3             = _fjsp_madd_v2r8(dx13,fscal,fjx3);
717             fjy3             = _fjsp_madd_v2r8(dy13,fscal,fjy3);
718             fjz3             = _fjsp_madd_v2r8(dz13,fscal,fjz3);
719
720             /**************************
721              * CALCULATE INTERACTIONS *
722              **************************/
723
724             /* REACTION-FIELD ELECTROSTATICS */
725             velec            = _fjsp_mul_v2r8(qq21,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq21,rinv21),crf));
726             felec            = _fjsp_mul_v2r8(qq21,_fjsp_msub_v2r8(rinv21,rinvsq21,krf2));
727
728             /* Update potential sum for this i atom from the interaction with this j atom. */
729             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
730             velecsum         = _fjsp_add_v2r8(velecsum,velec);
731
732             fscal            = felec;
733
734             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
735
736             /* Update vectorial force */
737             fix2             = _fjsp_madd_v2r8(dx21,fscal,fix2);
738             fiy2             = _fjsp_madd_v2r8(dy21,fscal,fiy2);
739             fiz2             = _fjsp_madd_v2r8(dz21,fscal,fiz2);
740             
741             fjx1             = _fjsp_madd_v2r8(dx21,fscal,fjx1);
742             fjy1             = _fjsp_madd_v2r8(dy21,fscal,fjy1);
743             fjz1             = _fjsp_madd_v2r8(dz21,fscal,fjz1);
744
745             /**************************
746              * CALCULATE INTERACTIONS *
747              **************************/
748
749             /* REACTION-FIELD ELECTROSTATICS */
750             velec            = _fjsp_mul_v2r8(qq22,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq22,rinv22),crf));
751             felec            = _fjsp_mul_v2r8(qq22,_fjsp_msub_v2r8(rinv22,rinvsq22,krf2));
752
753             /* Update potential sum for this i atom from the interaction with this j atom. */
754             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
755             velecsum         = _fjsp_add_v2r8(velecsum,velec);
756
757             fscal            = felec;
758
759             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
760
761             /* Update vectorial force */
762             fix2             = _fjsp_madd_v2r8(dx22,fscal,fix2);
763             fiy2             = _fjsp_madd_v2r8(dy22,fscal,fiy2);
764             fiz2             = _fjsp_madd_v2r8(dz22,fscal,fiz2);
765             
766             fjx2             = _fjsp_madd_v2r8(dx22,fscal,fjx2);
767             fjy2             = _fjsp_madd_v2r8(dy22,fscal,fjy2);
768             fjz2             = _fjsp_madd_v2r8(dz22,fscal,fjz2);
769
770             /**************************
771              * CALCULATE INTERACTIONS *
772              **************************/
773
774             /* REACTION-FIELD ELECTROSTATICS */
775             velec            = _fjsp_mul_v2r8(qq23,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq23,rinv23),crf));
776             felec            = _fjsp_mul_v2r8(qq23,_fjsp_msub_v2r8(rinv23,rinvsq23,krf2));
777
778             /* Update potential sum for this i atom from the interaction with this j atom. */
779             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
780             velecsum         = _fjsp_add_v2r8(velecsum,velec);
781
782             fscal            = felec;
783
784             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
785
786             /* Update vectorial force */
787             fix2             = _fjsp_madd_v2r8(dx23,fscal,fix2);
788             fiy2             = _fjsp_madd_v2r8(dy23,fscal,fiy2);
789             fiz2             = _fjsp_madd_v2r8(dz23,fscal,fiz2);
790             
791             fjx3             = _fjsp_madd_v2r8(dx23,fscal,fjx3);
792             fjy3             = _fjsp_madd_v2r8(dy23,fscal,fjy3);
793             fjz3             = _fjsp_madd_v2r8(dz23,fscal,fjz3);
794
795             /**************************
796              * CALCULATE INTERACTIONS *
797              **************************/
798
799             /* REACTION-FIELD ELECTROSTATICS */
800             velec            = _fjsp_mul_v2r8(qq31,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq31,rinv31),crf));
801             felec            = _fjsp_mul_v2r8(qq31,_fjsp_msub_v2r8(rinv31,rinvsq31,krf2));
802
803             /* Update potential sum for this i atom from the interaction with this j atom. */
804             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
805             velecsum         = _fjsp_add_v2r8(velecsum,velec);
806
807             fscal            = felec;
808
809             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
810
811             /* Update vectorial force */
812             fix3             = _fjsp_madd_v2r8(dx31,fscal,fix3);
813             fiy3             = _fjsp_madd_v2r8(dy31,fscal,fiy3);
814             fiz3             = _fjsp_madd_v2r8(dz31,fscal,fiz3);
815             
816             fjx1             = _fjsp_madd_v2r8(dx31,fscal,fjx1);
817             fjy1             = _fjsp_madd_v2r8(dy31,fscal,fjy1);
818             fjz1             = _fjsp_madd_v2r8(dz31,fscal,fjz1);
819
820             /**************************
821              * CALCULATE INTERACTIONS *
822              **************************/
823
824             /* REACTION-FIELD ELECTROSTATICS */
825             velec            = _fjsp_mul_v2r8(qq32,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq32,rinv32),crf));
826             felec            = _fjsp_mul_v2r8(qq32,_fjsp_msub_v2r8(rinv32,rinvsq32,krf2));
827
828             /* Update potential sum for this i atom from the interaction with this j atom. */
829             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
830             velecsum         = _fjsp_add_v2r8(velecsum,velec);
831
832             fscal            = felec;
833
834             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
835
836             /* Update vectorial force */
837             fix3             = _fjsp_madd_v2r8(dx32,fscal,fix3);
838             fiy3             = _fjsp_madd_v2r8(dy32,fscal,fiy3);
839             fiz3             = _fjsp_madd_v2r8(dz32,fscal,fiz3);
840             
841             fjx2             = _fjsp_madd_v2r8(dx32,fscal,fjx2);
842             fjy2             = _fjsp_madd_v2r8(dy32,fscal,fjy2);
843             fjz2             = _fjsp_madd_v2r8(dz32,fscal,fjz2);
844
845             /**************************
846              * CALCULATE INTERACTIONS *
847              **************************/
848
849             /* REACTION-FIELD ELECTROSTATICS */
850             velec            = _fjsp_mul_v2r8(qq33,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq33,rinv33),crf));
851             felec            = _fjsp_mul_v2r8(qq33,_fjsp_msub_v2r8(rinv33,rinvsq33,krf2));
852
853             /* Update potential sum for this i atom from the interaction with this j atom. */
854             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
855             velecsum         = _fjsp_add_v2r8(velecsum,velec);
856
857             fscal            = felec;
858
859             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
860
861             /* Update vectorial force */
862             fix3             = _fjsp_madd_v2r8(dx33,fscal,fix3);
863             fiy3             = _fjsp_madd_v2r8(dy33,fscal,fiy3);
864             fiz3             = _fjsp_madd_v2r8(dz33,fscal,fiz3);
865             
866             fjx3             = _fjsp_madd_v2r8(dx33,fscal,fjx3);
867             fjy3             = _fjsp_madd_v2r8(dy33,fscal,fjy3);
868             fjz3             = _fjsp_madd_v2r8(dz33,fscal,fjz3);
869
870             gmx_fjsp_decrement_4rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
871
872             /* Inner loop uses 353 flops */
873         }
874
875         /* End of innermost loop */
876
877         gmx_fjsp_update_iforce_4atom_swizzle_v2r8(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
878                                               f+i_coord_offset,fshift+i_shift_offset);
879
880         ggid                        = gid[iidx];
881         /* Update potential energies */
882         gmx_fjsp_update_1pot_v2r8(velecsum,kernel_data->energygrp_elec+ggid);
883         gmx_fjsp_update_1pot_v2r8(vvdwsum,kernel_data->energygrp_vdw+ggid);
884
885         /* Increment number of inner iterations */
886         inneriter                  += j_index_end - j_index_start;
887
888         /* Outer loop uses 26 flops */
889     }
890
891     /* Increment number of outer iterations */
892     outeriter        += nri;
893
894     /* Update outer/inner flops */
895
896     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*26 + inneriter*353);
897 }
898 /*
899  * Gromacs nonbonded kernel:   nb_kernel_ElecRF_VdwLJ_GeomW4W4_F_sparc64_hpc_ace_double
900  * Electrostatics interaction: ReactionField
901  * VdW interaction:            LennardJones
902  * Geometry:                   Water4-Water4
903  * Calculate force/pot:        Force
904  */
905 void
906 nb_kernel_ElecRF_VdwLJ_GeomW4W4_F_sparc64_hpc_ace_double
907                     (t_nblist                    * gmx_restrict       nlist,
908                      rvec                        * gmx_restrict          xx,
909                      rvec                        * gmx_restrict          ff,
910                      struct t_forcerec           * gmx_restrict          fr,
911                      t_mdatoms                   * gmx_restrict     mdatoms,
912                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
913                      t_nrnb                      * gmx_restrict        nrnb)
914 {
915     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
916      * just 0 for non-waters.
917      * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
918      * jnr indices corresponding to data put in the four positions in the SIMD register.
919      */
920     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
921     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
922     int              jnrA,jnrB;
923     int              j_coord_offsetA,j_coord_offsetB;
924     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
925     real             rcutoff_scalar;
926     real             *shiftvec,*fshift,*x,*f;
927     _fjsp_v2r8       tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
928     int              vdwioffset0;
929     _fjsp_v2r8       ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
930     int              vdwioffset1;
931     _fjsp_v2r8       ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
932     int              vdwioffset2;
933     _fjsp_v2r8       ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
934     int              vdwioffset3;
935     _fjsp_v2r8       ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
936     int              vdwjidx0A,vdwjidx0B;
937     _fjsp_v2r8       jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
938     int              vdwjidx1A,vdwjidx1B;
939     _fjsp_v2r8       jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
940     int              vdwjidx2A,vdwjidx2B;
941     _fjsp_v2r8       jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
942     int              vdwjidx3A,vdwjidx3B;
943     _fjsp_v2r8       jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
944     _fjsp_v2r8       dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
945     _fjsp_v2r8       dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
946     _fjsp_v2r8       dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
947     _fjsp_v2r8       dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13;
948     _fjsp_v2r8       dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
949     _fjsp_v2r8       dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
950     _fjsp_v2r8       dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23;
951     _fjsp_v2r8       dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31;
952     _fjsp_v2r8       dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32;
953     _fjsp_v2r8       dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33;
954     _fjsp_v2r8       velec,felec,velecsum,facel,crf,krf,krf2;
955     real             *charge;
956     int              nvdwtype;
957     _fjsp_v2r8       rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
958     int              *vdwtype;
959     real             *vdwparam;
960     _fjsp_v2r8       one_sixth   = gmx_fjsp_set1_v2r8(1.0/6.0);
961     _fjsp_v2r8       one_twelfth = gmx_fjsp_set1_v2r8(1.0/12.0);
962     _fjsp_v2r8       itab_tmp;
963     _fjsp_v2r8       dummy_mask,cutoff_mask;
964     _fjsp_v2r8       one     = gmx_fjsp_set1_v2r8(1.0);
965     _fjsp_v2r8       two     = gmx_fjsp_set1_v2r8(2.0);
966     union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
967
968     x                = xx[0];
969     f                = ff[0];
970
971     nri              = nlist->nri;
972     iinr             = nlist->iinr;
973     jindex           = nlist->jindex;
974     jjnr             = nlist->jjnr;
975     shiftidx         = nlist->shift;
976     gid              = nlist->gid;
977     shiftvec         = fr->shift_vec[0];
978     fshift           = fr->fshift[0];
979     facel            = gmx_fjsp_set1_v2r8(fr->ic->epsfac);
980     charge           = mdatoms->chargeA;
981     krf              = gmx_fjsp_set1_v2r8(fr->ic->k_rf);
982     krf2             = gmx_fjsp_set1_v2r8(fr->ic->k_rf*2.0);
983     crf              = gmx_fjsp_set1_v2r8(fr->ic->c_rf);
984     nvdwtype         = fr->ntype;
985     vdwparam         = fr->nbfp;
986     vdwtype          = mdatoms->typeA;
987
988     /* Setup water-specific parameters */
989     inr              = nlist->iinr[0];
990     iq1              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+1]));
991     iq2              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+2]));
992     iq3              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+3]));
993     vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
994
995     jq1              = gmx_fjsp_set1_v2r8(charge[inr+1]);
996     jq2              = gmx_fjsp_set1_v2r8(charge[inr+2]);
997     jq3              = gmx_fjsp_set1_v2r8(charge[inr+3]);
998     vdwjidx0A        = 2*vdwtype[inr+0];
999     c6_00            = gmx_fjsp_set1_v2r8(vdwparam[vdwioffset0+vdwjidx0A]);
1000     c12_00           = gmx_fjsp_set1_v2r8(vdwparam[vdwioffset0+vdwjidx0A+1]);
1001     qq11             = _fjsp_mul_v2r8(iq1,jq1);
1002     qq12             = _fjsp_mul_v2r8(iq1,jq2);
1003     qq13             = _fjsp_mul_v2r8(iq1,jq3);
1004     qq21             = _fjsp_mul_v2r8(iq2,jq1);
1005     qq22             = _fjsp_mul_v2r8(iq2,jq2);
1006     qq23             = _fjsp_mul_v2r8(iq2,jq3);
1007     qq31             = _fjsp_mul_v2r8(iq3,jq1);
1008     qq32             = _fjsp_mul_v2r8(iq3,jq2);
1009     qq33             = _fjsp_mul_v2r8(iq3,jq3);
1010
1011     /* Avoid stupid compiler warnings */
1012     jnrA = jnrB = 0;
1013     j_coord_offsetA = 0;
1014     j_coord_offsetB = 0;
1015
1016     outeriter        = 0;
1017     inneriter        = 0;
1018
1019     /* Start outer loop over neighborlists */
1020     for(iidx=0; iidx<nri; iidx++)
1021     {
1022         /* Load shift vector for this list */
1023         i_shift_offset   = DIM*shiftidx[iidx];
1024
1025         /* Load limits for loop over neighbors */
1026         j_index_start    = jindex[iidx];
1027         j_index_end      = jindex[iidx+1];
1028
1029         /* Get outer coordinate index */
1030         inr              = iinr[iidx];
1031         i_coord_offset   = DIM*inr;
1032
1033         /* Load i particle coords and add shift vector */
1034         gmx_fjsp_load_shift_and_4rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,
1035                                                  &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
1036
1037         fix0             = _fjsp_setzero_v2r8();
1038         fiy0             = _fjsp_setzero_v2r8();
1039         fiz0             = _fjsp_setzero_v2r8();
1040         fix1             = _fjsp_setzero_v2r8();
1041         fiy1             = _fjsp_setzero_v2r8();
1042         fiz1             = _fjsp_setzero_v2r8();
1043         fix2             = _fjsp_setzero_v2r8();
1044         fiy2             = _fjsp_setzero_v2r8();
1045         fiz2             = _fjsp_setzero_v2r8();
1046         fix3             = _fjsp_setzero_v2r8();
1047         fiy3             = _fjsp_setzero_v2r8();
1048         fiz3             = _fjsp_setzero_v2r8();
1049
1050         /* Start inner kernel loop */
1051         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
1052         {
1053
1054             /* Get j neighbor index, and coordinate index */
1055             jnrA             = jjnr[jidx];
1056             jnrB             = jjnr[jidx+1];
1057             j_coord_offsetA  = DIM*jnrA;
1058             j_coord_offsetB  = DIM*jnrB;
1059
1060             /* load j atom coordinates */
1061             gmx_fjsp_load_4rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
1062                                               &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,
1063                                               &jy2,&jz2,&jx3,&jy3,&jz3);
1064
1065             /* Calculate displacement vector */
1066             dx00             = _fjsp_sub_v2r8(ix0,jx0);
1067             dy00             = _fjsp_sub_v2r8(iy0,jy0);
1068             dz00             = _fjsp_sub_v2r8(iz0,jz0);
1069             dx11             = _fjsp_sub_v2r8(ix1,jx1);
1070             dy11             = _fjsp_sub_v2r8(iy1,jy1);
1071             dz11             = _fjsp_sub_v2r8(iz1,jz1);
1072             dx12             = _fjsp_sub_v2r8(ix1,jx2);
1073             dy12             = _fjsp_sub_v2r8(iy1,jy2);
1074             dz12             = _fjsp_sub_v2r8(iz1,jz2);
1075             dx13             = _fjsp_sub_v2r8(ix1,jx3);
1076             dy13             = _fjsp_sub_v2r8(iy1,jy3);
1077             dz13             = _fjsp_sub_v2r8(iz1,jz3);
1078             dx21             = _fjsp_sub_v2r8(ix2,jx1);
1079             dy21             = _fjsp_sub_v2r8(iy2,jy1);
1080             dz21             = _fjsp_sub_v2r8(iz2,jz1);
1081             dx22             = _fjsp_sub_v2r8(ix2,jx2);
1082             dy22             = _fjsp_sub_v2r8(iy2,jy2);
1083             dz22             = _fjsp_sub_v2r8(iz2,jz2);
1084             dx23             = _fjsp_sub_v2r8(ix2,jx3);
1085             dy23             = _fjsp_sub_v2r8(iy2,jy3);
1086             dz23             = _fjsp_sub_v2r8(iz2,jz3);
1087             dx31             = _fjsp_sub_v2r8(ix3,jx1);
1088             dy31             = _fjsp_sub_v2r8(iy3,jy1);
1089             dz31             = _fjsp_sub_v2r8(iz3,jz1);
1090             dx32             = _fjsp_sub_v2r8(ix3,jx2);
1091             dy32             = _fjsp_sub_v2r8(iy3,jy2);
1092             dz32             = _fjsp_sub_v2r8(iz3,jz2);
1093             dx33             = _fjsp_sub_v2r8(ix3,jx3);
1094             dy33             = _fjsp_sub_v2r8(iy3,jy3);
1095             dz33             = _fjsp_sub_v2r8(iz3,jz3);
1096
1097             /* Calculate squared distance and things based on it */
1098             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
1099             rsq11            = gmx_fjsp_calc_rsq_v2r8(dx11,dy11,dz11);
1100             rsq12            = gmx_fjsp_calc_rsq_v2r8(dx12,dy12,dz12);
1101             rsq13            = gmx_fjsp_calc_rsq_v2r8(dx13,dy13,dz13);
1102             rsq21            = gmx_fjsp_calc_rsq_v2r8(dx21,dy21,dz21);
1103             rsq22            = gmx_fjsp_calc_rsq_v2r8(dx22,dy22,dz22);
1104             rsq23            = gmx_fjsp_calc_rsq_v2r8(dx23,dy23,dz23);
1105             rsq31            = gmx_fjsp_calc_rsq_v2r8(dx31,dy31,dz31);
1106             rsq32            = gmx_fjsp_calc_rsq_v2r8(dx32,dy32,dz32);
1107             rsq33            = gmx_fjsp_calc_rsq_v2r8(dx33,dy33,dz33);
1108
1109             rinv11           = gmx_fjsp_invsqrt_v2r8(rsq11);
1110             rinv12           = gmx_fjsp_invsqrt_v2r8(rsq12);
1111             rinv13           = gmx_fjsp_invsqrt_v2r8(rsq13);
1112             rinv21           = gmx_fjsp_invsqrt_v2r8(rsq21);
1113             rinv22           = gmx_fjsp_invsqrt_v2r8(rsq22);
1114             rinv23           = gmx_fjsp_invsqrt_v2r8(rsq23);
1115             rinv31           = gmx_fjsp_invsqrt_v2r8(rsq31);
1116             rinv32           = gmx_fjsp_invsqrt_v2r8(rsq32);
1117             rinv33           = gmx_fjsp_invsqrt_v2r8(rsq33);
1118
1119             rinvsq00         = gmx_fjsp_inv_v2r8(rsq00);
1120             rinvsq11         = _fjsp_mul_v2r8(rinv11,rinv11);
1121             rinvsq12         = _fjsp_mul_v2r8(rinv12,rinv12);
1122             rinvsq13         = _fjsp_mul_v2r8(rinv13,rinv13);
1123             rinvsq21         = _fjsp_mul_v2r8(rinv21,rinv21);
1124             rinvsq22         = _fjsp_mul_v2r8(rinv22,rinv22);
1125             rinvsq23         = _fjsp_mul_v2r8(rinv23,rinv23);
1126             rinvsq31         = _fjsp_mul_v2r8(rinv31,rinv31);
1127             rinvsq32         = _fjsp_mul_v2r8(rinv32,rinv32);
1128             rinvsq33         = _fjsp_mul_v2r8(rinv33,rinv33);
1129
1130             fjx0             = _fjsp_setzero_v2r8();
1131             fjy0             = _fjsp_setzero_v2r8();
1132             fjz0             = _fjsp_setzero_v2r8();
1133             fjx1             = _fjsp_setzero_v2r8();
1134             fjy1             = _fjsp_setzero_v2r8();
1135             fjz1             = _fjsp_setzero_v2r8();
1136             fjx2             = _fjsp_setzero_v2r8();
1137             fjy2             = _fjsp_setzero_v2r8();
1138             fjz2             = _fjsp_setzero_v2r8();
1139             fjx3             = _fjsp_setzero_v2r8();
1140             fjy3             = _fjsp_setzero_v2r8();
1141             fjz3             = _fjsp_setzero_v2r8();
1142
1143             /**************************
1144              * CALCULATE INTERACTIONS *
1145              **************************/
1146
1147             /* LENNARD-JONES DISPERSION/REPULSION */
1148
1149             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
1150             fvdw             = _fjsp_mul_v2r8(_fjsp_msub_v2r8(c12_00,rinvsix,c6_00),_fjsp_mul_v2r8(rinvsix,rinvsq00));
1151
1152             fscal            = fvdw;
1153
1154             /* Update vectorial force */
1155             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
1156             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
1157             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
1158             
1159             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
1160             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
1161             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
1162
1163             /**************************
1164              * CALCULATE INTERACTIONS *
1165              **************************/
1166
1167             /* REACTION-FIELD ELECTROSTATICS */
1168             felec            = _fjsp_mul_v2r8(qq11,_fjsp_msub_v2r8(rinv11,rinvsq11,krf2));
1169
1170             fscal            = felec;
1171
1172             /* Update vectorial force */
1173             fix1             = _fjsp_madd_v2r8(dx11,fscal,fix1);
1174             fiy1             = _fjsp_madd_v2r8(dy11,fscal,fiy1);
1175             fiz1             = _fjsp_madd_v2r8(dz11,fscal,fiz1);
1176             
1177             fjx1             = _fjsp_madd_v2r8(dx11,fscal,fjx1);
1178             fjy1             = _fjsp_madd_v2r8(dy11,fscal,fjy1);
1179             fjz1             = _fjsp_madd_v2r8(dz11,fscal,fjz1);
1180
1181             /**************************
1182              * CALCULATE INTERACTIONS *
1183              **************************/
1184
1185             /* REACTION-FIELD ELECTROSTATICS */
1186             felec            = _fjsp_mul_v2r8(qq12,_fjsp_msub_v2r8(rinv12,rinvsq12,krf2));
1187
1188             fscal            = felec;
1189
1190             /* Update vectorial force */
1191             fix1             = _fjsp_madd_v2r8(dx12,fscal,fix1);
1192             fiy1             = _fjsp_madd_v2r8(dy12,fscal,fiy1);
1193             fiz1             = _fjsp_madd_v2r8(dz12,fscal,fiz1);
1194             
1195             fjx2             = _fjsp_madd_v2r8(dx12,fscal,fjx2);
1196             fjy2             = _fjsp_madd_v2r8(dy12,fscal,fjy2);
1197             fjz2             = _fjsp_madd_v2r8(dz12,fscal,fjz2);
1198
1199             /**************************
1200              * CALCULATE INTERACTIONS *
1201              **************************/
1202
1203             /* REACTION-FIELD ELECTROSTATICS */
1204             felec            = _fjsp_mul_v2r8(qq13,_fjsp_msub_v2r8(rinv13,rinvsq13,krf2));
1205
1206             fscal            = felec;
1207
1208             /* Update vectorial force */
1209             fix1             = _fjsp_madd_v2r8(dx13,fscal,fix1);
1210             fiy1             = _fjsp_madd_v2r8(dy13,fscal,fiy1);
1211             fiz1             = _fjsp_madd_v2r8(dz13,fscal,fiz1);
1212             
1213             fjx3             = _fjsp_madd_v2r8(dx13,fscal,fjx3);
1214             fjy3             = _fjsp_madd_v2r8(dy13,fscal,fjy3);
1215             fjz3             = _fjsp_madd_v2r8(dz13,fscal,fjz3);
1216
1217             /**************************
1218              * CALCULATE INTERACTIONS *
1219              **************************/
1220
1221             /* REACTION-FIELD ELECTROSTATICS */
1222             felec            = _fjsp_mul_v2r8(qq21,_fjsp_msub_v2r8(rinv21,rinvsq21,krf2));
1223
1224             fscal            = felec;
1225
1226             /* Update vectorial force */
1227             fix2             = _fjsp_madd_v2r8(dx21,fscal,fix2);
1228             fiy2             = _fjsp_madd_v2r8(dy21,fscal,fiy2);
1229             fiz2             = _fjsp_madd_v2r8(dz21,fscal,fiz2);
1230             
1231             fjx1             = _fjsp_madd_v2r8(dx21,fscal,fjx1);
1232             fjy1             = _fjsp_madd_v2r8(dy21,fscal,fjy1);
1233             fjz1             = _fjsp_madd_v2r8(dz21,fscal,fjz1);
1234
1235             /**************************
1236              * CALCULATE INTERACTIONS *
1237              **************************/
1238
1239             /* REACTION-FIELD ELECTROSTATICS */
1240             felec            = _fjsp_mul_v2r8(qq22,_fjsp_msub_v2r8(rinv22,rinvsq22,krf2));
1241
1242             fscal            = felec;
1243
1244             /* Update vectorial force */
1245             fix2             = _fjsp_madd_v2r8(dx22,fscal,fix2);
1246             fiy2             = _fjsp_madd_v2r8(dy22,fscal,fiy2);
1247             fiz2             = _fjsp_madd_v2r8(dz22,fscal,fiz2);
1248             
1249             fjx2             = _fjsp_madd_v2r8(dx22,fscal,fjx2);
1250             fjy2             = _fjsp_madd_v2r8(dy22,fscal,fjy2);
1251             fjz2             = _fjsp_madd_v2r8(dz22,fscal,fjz2);
1252
1253             /**************************
1254              * CALCULATE INTERACTIONS *
1255              **************************/
1256
1257             /* REACTION-FIELD ELECTROSTATICS */
1258             felec            = _fjsp_mul_v2r8(qq23,_fjsp_msub_v2r8(rinv23,rinvsq23,krf2));
1259
1260             fscal            = felec;
1261
1262             /* Update vectorial force */
1263             fix2             = _fjsp_madd_v2r8(dx23,fscal,fix2);
1264             fiy2             = _fjsp_madd_v2r8(dy23,fscal,fiy2);
1265             fiz2             = _fjsp_madd_v2r8(dz23,fscal,fiz2);
1266             
1267             fjx3             = _fjsp_madd_v2r8(dx23,fscal,fjx3);
1268             fjy3             = _fjsp_madd_v2r8(dy23,fscal,fjy3);
1269             fjz3             = _fjsp_madd_v2r8(dz23,fscal,fjz3);
1270
1271             /**************************
1272              * CALCULATE INTERACTIONS *
1273              **************************/
1274
1275             /* REACTION-FIELD ELECTROSTATICS */
1276             felec            = _fjsp_mul_v2r8(qq31,_fjsp_msub_v2r8(rinv31,rinvsq31,krf2));
1277
1278             fscal            = felec;
1279
1280             /* Update vectorial force */
1281             fix3             = _fjsp_madd_v2r8(dx31,fscal,fix3);
1282             fiy3             = _fjsp_madd_v2r8(dy31,fscal,fiy3);
1283             fiz3             = _fjsp_madd_v2r8(dz31,fscal,fiz3);
1284             
1285             fjx1             = _fjsp_madd_v2r8(dx31,fscal,fjx1);
1286             fjy1             = _fjsp_madd_v2r8(dy31,fscal,fjy1);
1287             fjz1             = _fjsp_madd_v2r8(dz31,fscal,fjz1);
1288
1289             /**************************
1290              * CALCULATE INTERACTIONS *
1291              **************************/
1292
1293             /* REACTION-FIELD ELECTROSTATICS */
1294             felec            = _fjsp_mul_v2r8(qq32,_fjsp_msub_v2r8(rinv32,rinvsq32,krf2));
1295
1296             fscal            = felec;
1297
1298             /* Update vectorial force */
1299             fix3             = _fjsp_madd_v2r8(dx32,fscal,fix3);
1300             fiy3             = _fjsp_madd_v2r8(dy32,fscal,fiy3);
1301             fiz3             = _fjsp_madd_v2r8(dz32,fscal,fiz3);
1302             
1303             fjx2             = _fjsp_madd_v2r8(dx32,fscal,fjx2);
1304             fjy2             = _fjsp_madd_v2r8(dy32,fscal,fjy2);
1305             fjz2             = _fjsp_madd_v2r8(dz32,fscal,fjz2);
1306
1307             /**************************
1308              * CALCULATE INTERACTIONS *
1309              **************************/
1310
1311             /* REACTION-FIELD ELECTROSTATICS */
1312             felec            = _fjsp_mul_v2r8(qq33,_fjsp_msub_v2r8(rinv33,rinvsq33,krf2));
1313
1314             fscal            = felec;
1315
1316             /* Update vectorial force */
1317             fix3             = _fjsp_madd_v2r8(dx33,fscal,fix3);
1318             fiy3             = _fjsp_madd_v2r8(dy33,fscal,fiy3);
1319             fiz3             = _fjsp_madd_v2r8(dz33,fscal,fiz3);
1320             
1321             fjx3             = _fjsp_madd_v2r8(dx33,fscal,fjx3);
1322             fjy3             = _fjsp_madd_v2r8(dy33,fscal,fjy3);
1323             fjz3             = _fjsp_madd_v2r8(dz33,fscal,fjz3);
1324
1325             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);
1326
1327             /* Inner loop uses 303 flops */
1328         }
1329
1330         if(jidx<j_index_end)
1331         {
1332
1333             jnrA             = jjnr[jidx];
1334             j_coord_offsetA  = DIM*jnrA;
1335
1336             /* load j atom coordinates */
1337             gmx_fjsp_load_4rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
1338                                               &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,
1339                                               &jy2,&jz2,&jx3,&jy3,&jz3);
1340
1341             /* Calculate displacement vector */
1342             dx00             = _fjsp_sub_v2r8(ix0,jx0);
1343             dy00             = _fjsp_sub_v2r8(iy0,jy0);
1344             dz00             = _fjsp_sub_v2r8(iz0,jz0);
1345             dx11             = _fjsp_sub_v2r8(ix1,jx1);
1346             dy11             = _fjsp_sub_v2r8(iy1,jy1);
1347             dz11             = _fjsp_sub_v2r8(iz1,jz1);
1348             dx12             = _fjsp_sub_v2r8(ix1,jx2);
1349             dy12             = _fjsp_sub_v2r8(iy1,jy2);
1350             dz12             = _fjsp_sub_v2r8(iz1,jz2);
1351             dx13             = _fjsp_sub_v2r8(ix1,jx3);
1352             dy13             = _fjsp_sub_v2r8(iy1,jy3);
1353             dz13             = _fjsp_sub_v2r8(iz1,jz3);
1354             dx21             = _fjsp_sub_v2r8(ix2,jx1);
1355             dy21             = _fjsp_sub_v2r8(iy2,jy1);
1356             dz21             = _fjsp_sub_v2r8(iz2,jz1);
1357             dx22             = _fjsp_sub_v2r8(ix2,jx2);
1358             dy22             = _fjsp_sub_v2r8(iy2,jy2);
1359             dz22             = _fjsp_sub_v2r8(iz2,jz2);
1360             dx23             = _fjsp_sub_v2r8(ix2,jx3);
1361             dy23             = _fjsp_sub_v2r8(iy2,jy3);
1362             dz23             = _fjsp_sub_v2r8(iz2,jz3);
1363             dx31             = _fjsp_sub_v2r8(ix3,jx1);
1364             dy31             = _fjsp_sub_v2r8(iy3,jy1);
1365             dz31             = _fjsp_sub_v2r8(iz3,jz1);
1366             dx32             = _fjsp_sub_v2r8(ix3,jx2);
1367             dy32             = _fjsp_sub_v2r8(iy3,jy2);
1368             dz32             = _fjsp_sub_v2r8(iz3,jz2);
1369             dx33             = _fjsp_sub_v2r8(ix3,jx3);
1370             dy33             = _fjsp_sub_v2r8(iy3,jy3);
1371             dz33             = _fjsp_sub_v2r8(iz3,jz3);
1372
1373             /* Calculate squared distance and things based on it */
1374             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
1375             rsq11            = gmx_fjsp_calc_rsq_v2r8(dx11,dy11,dz11);
1376             rsq12            = gmx_fjsp_calc_rsq_v2r8(dx12,dy12,dz12);
1377             rsq13            = gmx_fjsp_calc_rsq_v2r8(dx13,dy13,dz13);
1378             rsq21            = gmx_fjsp_calc_rsq_v2r8(dx21,dy21,dz21);
1379             rsq22            = gmx_fjsp_calc_rsq_v2r8(dx22,dy22,dz22);
1380             rsq23            = gmx_fjsp_calc_rsq_v2r8(dx23,dy23,dz23);
1381             rsq31            = gmx_fjsp_calc_rsq_v2r8(dx31,dy31,dz31);
1382             rsq32            = gmx_fjsp_calc_rsq_v2r8(dx32,dy32,dz32);
1383             rsq33            = gmx_fjsp_calc_rsq_v2r8(dx33,dy33,dz33);
1384
1385             rinv11           = gmx_fjsp_invsqrt_v2r8(rsq11);
1386             rinv12           = gmx_fjsp_invsqrt_v2r8(rsq12);
1387             rinv13           = gmx_fjsp_invsqrt_v2r8(rsq13);
1388             rinv21           = gmx_fjsp_invsqrt_v2r8(rsq21);
1389             rinv22           = gmx_fjsp_invsqrt_v2r8(rsq22);
1390             rinv23           = gmx_fjsp_invsqrt_v2r8(rsq23);
1391             rinv31           = gmx_fjsp_invsqrt_v2r8(rsq31);
1392             rinv32           = gmx_fjsp_invsqrt_v2r8(rsq32);
1393             rinv33           = gmx_fjsp_invsqrt_v2r8(rsq33);
1394
1395             rinvsq00         = gmx_fjsp_inv_v2r8(rsq00);
1396             rinvsq11         = _fjsp_mul_v2r8(rinv11,rinv11);
1397             rinvsq12         = _fjsp_mul_v2r8(rinv12,rinv12);
1398             rinvsq13         = _fjsp_mul_v2r8(rinv13,rinv13);
1399             rinvsq21         = _fjsp_mul_v2r8(rinv21,rinv21);
1400             rinvsq22         = _fjsp_mul_v2r8(rinv22,rinv22);
1401             rinvsq23         = _fjsp_mul_v2r8(rinv23,rinv23);
1402             rinvsq31         = _fjsp_mul_v2r8(rinv31,rinv31);
1403             rinvsq32         = _fjsp_mul_v2r8(rinv32,rinv32);
1404             rinvsq33         = _fjsp_mul_v2r8(rinv33,rinv33);
1405
1406             fjx0             = _fjsp_setzero_v2r8();
1407             fjy0             = _fjsp_setzero_v2r8();
1408             fjz0             = _fjsp_setzero_v2r8();
1409             fjx1             = _fjsp_setzero_v2r8();
1410             fjy1             = _fjsp_setzero_v2r8();
1411             fjz1             = _fjsp_setzero_v2r8();
1412             fjx2             = _fjsp_setzero_v2r8();
1413             fjy2             = _fjsp_setzero_v2r8();
1414             fjz2             = _fjsp_setzero_v2r8();
1415             fjx3             = _fjsp_setzero_v2r8();
1416             fjy3             = _fjsp_setzero_v2r8();
1417             fjz3             = _fjsp_setzero_v2r8();
1418
1419             /**************************
1420              * CALCULATE INTERACTIONS *
1421              **************************/
1422
1423             /* LENNARD-JONES DISPERSION/REPULSION */
1424
1425             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
1426             fvdw             = _fjsp_mul_v2r8(_fjsp_msub_v2r8(c12_00,rinvsix,c6_00),_fjsp_mul_v2r8(rinvsix,rinvsq00));
1427
1428             fscal            = fvdw;
1429
1430             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1431
1432             /* Update vectorial force */
1433             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
1434             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
1435             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
1436             
1437             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
1438             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
1439             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
1440
1441             /**************************
1442              * CALCULATE INTERACTIONS *
1443              **************************/
1444
1445             /* REACTION-FIELD ELECTROSTATICS */
1446             felec            = _fjsp_mul_v2r8(qq11,_fjsp_msub_v2r8(rinv11,rinvsq11,krf2));
1447
1448             fscal            = felec;
1449
1450             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1451
1452             /* Update vectorial force */
1453             fix1             = _fjsp_madd_v2r8(dx11,fscal,fix1);
1454             fiy1             = _fjsp_madd_v2r8(dy11,fscal,fiy1);
1455             fiz1             = _fjsp_madd_v2r8(dz11,fscal,fiz1);
1456             
1457             fjx1             = _fjsp_madd_v2r8(dx11,fscal,fjx1);
1458             fjy1             = _fjsp_madd_v2r8(dy11,fscal,fjy1);
1459             fjz1             = _fjsp_madd_v2r8(dz11,fscal,fjz1);
1460
1461             /**************************
1462              * CALCULATE INTERACTIONS *
1463              **************************/
1464
1465             /* REACTION-FIELD ELECTROSTATICS */
1466             felec            = _fjsp_mul_v2r8(qq12,_fjsp_msub_v2r8(rinv12,rinvsq12,krf2));
1467
1468             fscal            = felec;
1469
1470             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1471
1472             /* Update vectorial force */
1473             fix1             = _fjsp_madd_v2r8(dx12,fscal,fix1);
1474             fiy1             = _fjsp_madd_v2r8(dy12,fscal,fiy1);
1475             fiz1             = _fjsp_madd_v2r8(dz12,fscal,fiz1);
1476             
1477             fjx2             = _fjsp_madd_v2r8(dx12,fscal,fjx2);
1478             fjy2             = _fjsp_madd_v2r8(dy12,fscal,fjy2);
1479             fjz2             = _fjsp_madd_v2r8(dz12,fscal,fjz2);
1480
1481             /**************************
1482              * CALCULATE INTERACTIONS *
1483              **************************/
1484
1485             /* REACTION-FIELD ELECTROSTATICS */
1486             felec            = _fjsp_mul_v2r8(qq13,_fjsp_msub_v2r8(rinv13,rinvsq13,krf2));
1487
1488             fscal            = felec;
1489
1490             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1491
1492             /* Update vectorial force */
1493             fix1             = _fjsp_madd_v2r8(dx13,fscal,fix1);
1494             fiy1             = _fjsp_madd_v2r8(dy13,fscal,fiy1);
1495             fiz1             = _fjsp_madd_v2r8(dz13,fscal,fiz1);
1496             
1497             fjx3             = _fjsp_madd_v2r8(dx13,fscal,fjx3);
1498             fjy3             = _fjsp_madd_v2r8(dy13,fscal,fjy3);
1499             fjz3             = _fjsp_madd_v2r8(dz13,fscal,fjz3);
1500
1501             /**************************
1502              * CALCULATE INTERACTIONS *
1503              **************************/
1504
1505             /* REACTION-FIELD ELECTROSTATICS */
1506             felec            = _fjsp_mul_v2r8(qq21,_fjsp_msub_v2r8(rinv21,rinvsq21,krf2));
1507
1508             fscal            = felec;
1509
1510             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1511
1512             /* Update vectorial force */
1513             fix2             = _fjsp_madd_v2r8(dx21,fscal,fix2);
1514             fiy2             = _fjsp_madd_v2r8(dy21,fscal,fiy2);
1515             fiz2             = _fjsp_madd_v2r8(dz21,fscal,fiz2);
1516             
1517             fjx1             = _fjsp_madd_v2r8(dx21,fscal,fjx1);
1518             fjy1             = _fjsp_madd_v2r8(dy21,fscal,fjy1);
1519             fjz1             = _fjsp_madd_v2r8(dz21,fscal,fjz1);
1520
1521             /**************************
1522              * CALCULATE INTERACTIONS *
1523              **************************/
1524
1525             /* REACTION-FIELD ELECTROSTATICS */
1526             felec            = _fjsp_mul_v2r8(qq22,_fjsp_msub_v2r8(rinv22,rinvsq22,krf2));
1527
1528             fscal            = felec;
1529
1530             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1531
1532             /* Update vectorial force */
1533             fix2             = _fjsp_madd_v2r8(dx22,fscal,fix2);
1534             fiy2             = _fjsp_madd_v2r8(dy22,fscal,fiy2);
1535             fiz2             = _fjsp_madd_v2r8(dz22,fscal,fiz2);
1536             
1537             fjx2             = _fjsp_madd_v2r8(dx22,fscal,fjx2);
1538             fjy2             = _fjsp_madd_v2r8(dy22,fscal,fjy2);
1539             fjz2             = _fjsp_madd_v2r8(dz22,fscal,fjz2);
1540
1541             /**************************
1542              * CALCULATE INTERACTIONS *
1543              **************************/
1544
1545             /* REACTION-FIELD ELECTROSTATICS */
1546             felec            = _fjsp_mul_v2r8(qq23,_fjsp_msub_v2r8(rinv23,rinvsq23,krf2));
1547
1548             fscal            = felec;
1549
1550             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1551
1552             /* Update vectorial force */
1553             fix2             = _fjsp_madd_v2r8(dx23,fscal,fix2);
1554             fiy2             = _fjsp_madd_v2r8(dy23,fscal,fiy2);
1555             fiz2             = _fjsp_madd_v2r8(dz23,fscal,fiz2);
1556             
1557             fjx3             = _fjsp_madd_v2r8(dx23,fscal,fjx3);
1558             fjy3             = _fjsp_madd_v2r8(dy23,fscal,fjy3);
1559             fjz3             = _fjsp_madd_v2r8(dz23,fscal,fjz3);
1560
1561             /**************************
1562              * CALCULATE INTERACTIONS *
1563              **************************/
1564
1565             /* REACTION-FIELD ELECTROSTATICS */
1566             felec            = _fjsp_mul_v2r8(qq31,_fjsp_msub_v2r8(rinv31,rinvsq31,krf2));
1567
1568             fscal            = felec;
1569
1570             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1571
1572             /* Update vectorial force */
1573             fix3             = _fjsp_madd_v2r8(dx31,fscal,fix3);
1574             fiy3             = _fjsp_madd_v2r8(dy31,fscal,fiy3);
1575             fiz3             = _fjsp_madd_v2r8(dz31,fscal,fiz3);
1576             
1577             fjx1             = _fjsp_madd_v2r8(dx31,fscal,fjx1);
1578             fjy1             = _fjsp_madd_v2r8(dy31,fscal,fjy1);
1579             fjz1             = _fjsp_madd_v2r8(dz31,fscal,fjz1);
1580
1581             /**************************
1582              * CALCULATE INTERACTIONS *
1583              **************************/
1584
1585             /* REACTION-FIELD ELECTROSTATICS */
1586             felec            = _fjsp_mul_v2r8(qq32,_fjsp_msub_v2r8(rinv32,rinvsq32,krf2));
1587
1588             fscal            = felec;
1589
1590             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1591
1592             /* Update vectorial force */
1593             fix3             = _fjsp_madd_v2r8(dx32,fscal,fix3);
1594             fiy3             = _fjsp_madd_v2r8(dy32,fscal,fiy3);
1595             fiz3             = _fjsp_madd_v2r8(dz32,fscal,fiz3);
1596             
1597             fjx2             = _fjsp_madd_v2r8(dx32,fscal,fjx2);
1598             fjy2             = _fjsp_madd_v2r8(dy32,fscal,fjy2);
1599             fjz2             = _fjsp_madd_v2r8(dz32,fscal,fjz2);
1600
1601             /**************************
1602              * CALCULATE INTERACTIONS *
1603              **************************/
1604
1605             /* REACTION-FIELD ELECTROSTATICS */
1606             felec            = _fjsp_mul_v2r8(qq33,_fjsp_msub_v2r8(rinv33,rinvsq33,krf2));
1607
1608             fscal            = felec;
1609
1610             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1611
1612             /* Update vectorial force */
1613             fix3             = _fjsp_madd_v2r8(dx33,fscal,fix3);
1614             fiy3             = _fjsp_madd_v2r8(dy33,fscal,fiy3);
1615             fiz3             = _fjsp_madd_v2r8(dz33,fscal,fiz3);
1616             
1617             fjx3             = _fjsp_madd_v2r8(dx33,fscal,fjx3);
1618             fjy3             = _fjsp_madd_v2r8(dy33,fscal,fjy3);
1619             fjz3             = _fjsp_madd_v2r8(dz33,fscal,fjz3);
1620
1621             gmx_fjsp_decrement_4rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
1622
1623             /* Inner loop uses 303 flops */
1624         }
1625
1626         /* End of innermost loop */
1627
1628         gmx_fjsp_update_iforce_4atom_swizzle_v2r8(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
1629                                               f+i_coord_offset,fshift+i_shift_offset);
1630
1631         /* Increment number of inner iterations */
1632         inneriter                  += j_index_end - j_index_start;
1633
1634         /* Outer loop uses 24 flops */
1635     }
1636
1637     /* Increment number of outer iterations */
1638     outeriter        += nri;
1639
1640     /* Update outer/inner flops */
1641
1642     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*24 + inneriter*303);
1643 }