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