Remove all unnecessary HAVE_CONFIG_H
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_sparc64_hpc_ace_double / nb_kernel_ElecRFCut_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 "config.h"
39
40 #include <math.h>
41
42 #include "../nb_kernel.h"
43 #include "types/simple.h"
44 #include "gromacs/math/vec.h"
45 #include "nrnb.h"
46
47 #include "kernelutil_sparc64_hpc_ace_double.h"
48
49 /*
50  * Gromacs nonbonded kernel:   nb_kernel_ElecRFCut_VdwNone_GeomW4W4_VF_sparc64_hpc_ace_double
51  * Electrostatics interaction: ReactionField
52  * VdW interaction:            None
53  * Geometry:                   Water4-Water4
54  * Calculate force/pot:        PotentialAndForce
55  */
56 void
57 nb_kernel_ElecRFCut_VdwNone_GeomW4W4_VF_sparc64_hpc_ace_double
58                     (t_nblist                    * gmx_restrict       nlist,
59                      rvec                        * gmx_restrict          xx,
60                      rvec                        * gmx_restrict          ff,
61                      t_forcerec                  * gmx_restrict          fr,
62                      t_mdatoms                   * gmx_restrict     mdatoms,
63                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
64                      t_nrnb                      * gmx_restrict        nrnb)
65 {
66     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
67      * just 0 for non-waters.
68      * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
69      * jnr indices corresponding to data put in the four positions in the SIMD register.
70      */
71     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
72     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
73     int              jnrA,jnrB;
74     int              j_coord_offsetA,j_coord_offsetB;
75     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
76     real             rcutoff_scalar;
77     real             *shiftvec,*fshift,*x,*f;
78     _fjsp_v2r8       tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
79     int              vdwioffset1;
80     _fjsp_v2r8       ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
81     int              vdwioffset2;
82     _fjsp_v2r8       ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
83     int              vdwioffset3;
84     _fjsp_v2r8       ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
85     int              vdwjidx1A,vdwjidx1B;
86     _fjsp_v2r8       jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
87     int              vdwjidx2A,vdwjidx2B;
88     _fjsp_v2r8       jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
89     int              vdwjidx3A,vdwjidx3B;
90     _fjsp_v2r8       jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
91     _fjsp_v2r8       dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
92     _fjsp_v2r8       dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
93     _fjsp_v2r8       dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13;
94     _fjsp_v2r8       dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
95     _fjsp_v2r8       dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
96     _fjsp_v2r8       dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23;
97     _fjsp_v2r8       dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31;
98     _fjsp_v2r8       dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32;
99     _fjsp_v2r8       dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33;
100     _fjsp_v2r8       velec,felec,velecsum,facel,crf,krf,krf2;
101     real             *charge;
102     _fjsp_v2r8       itab_tmp;
103     _fjsp_v2r8       dummy_mask,cutoff_mask;
104     _fjsp_v2r8       one     = gmx_fjsp_set1_v2r8(1.0);
105     _fjsp_v2r8       two     = gmx_fjsp_set1_v2r8(2.0);
106     union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
107
108     x                = xx[0];
109     f                = ff[0];
110
111     nri              = nlist->nri;
112     iinr             = nlist->iinr;
113     jindex           = nlist->jindex;
114     jjnr             = nlist->jjnr;
115     shiftidx         = nlist->shift;
116     gid              = nlist->gid;
117     shiftvec         = fr->shift_vec[0];
118     fshift           = fr->fshift[0];
119     facel            = gmx_fjsp_set1_v2r8(fr->epsfac);
120     charge           = mdatoms->chargeA;
121     krf              = gmx_fjsp_set1_v2r8(fr->ic->k_rf);
122     krf2             = gmx_fjsp_set1_v2r8(fr->ic->k_rf*2.0);
123     crf              = gmx_fjsp_set1_v2r8(fr->ic->c_rf);
124
125     /* Setup water-specific parameters */
126     inr              = nlist->iinr[0];
127     iq1              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+1]));
128     iq2              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+2]));
129     iq3              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+3]));
130
131     jq1              = gmx_fjsp_set1_v2r8(charge[inr+1]);
132     jq2              = gmx_fjsp_set1_v2r8(charge[inr+2]);
133     jq3              = gmx_fjsp_set1_v2r8(charge[inr+3]);
134     qq11             = _fjsp_mul_v2r8(iq1,jq1);
135     qq12             = _fjsp_mul_v2r8(iq1,jq2);
136     qq13             = _fjsp_mul_v2r8(iq1,jq3);
137     qq21             = _fjsp_mul_v2r8(iq2,jq1);
138     qq22             = _fjsp_mul_v2r8(iq2,jq2);
139     qq23             = _fjsp_mul_v2r8(iq2,jq3);
140     qq31             = _fjsp_mul_v2r8(iq3,jq1);
141     qq32             = _fjsp_mul_v2r8(iq3,jq2);
142     qq33             = _fjsp_mul_v2r8(iq3,jq3);
143
144     /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
145     rcutoff_scalar   = fr->rcoulomb;
146     rcutoff          = gmx_fjsp_set1_v2r8(rcutoff_scalar);
147     rcutoff2         = _fjsp_mul_v2r8(rcutoff,rcutoff);
148
149     /* Avoid stupid compiler warnings */
150     jnrA = jnrB = 0;
151     j_coord_offsetA = 0;
152     j_coord_offsetB = 0;
153
154     outeriter        = 0;
155     inneriter        = 0;
156
157     /* Start outer loop over neighborlists */
158     for(iidx=0; iidx<nri; iidx++)
159     {
160         /* Load shift vector for this list */
161         i_shift_offset   = DIM*shiftidx[iidx];
162
163         /* Load limits for loop over neighbors */
164         j_index_start    = jindex[iidx];
165         j_index_end      = jindex[iidx+1];
166
167         /* Get outer coordinate index */
168         inr              = iinr[iidx];
169         i_coord_offset   = DIM*inr;
170
171         /* Load i particle coords and add shift vector */
172         gmx_fjsp_load_shift_and_3rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset+DIM,
173                                                  &ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
174
175         fix1             = _fjsp_setzero_v2r8();
176         fiy1             = _fjsp_setzero_v2r8();
177         fiz1             = _fjsp_setzero_v2r8();
178         fix2             = _fjsp_setzero_v2r8();
179         fiy2             = _fjsp_setzero_v2r8();
180         fiz2             = _fjsp_setzero_v2r8();
181         fix3             = _fjsp_setzero_v2r8();
182         fiy3             = _fjsp_setzero_v2r8();
183         fiz3             = _fjsp_setzero_v2r8();
184
185         /* Reset potential sums */
186         velecsum         = _fjsp_setzero_v2r8();
187
188         /* Start inner kernel loop */
189         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
190         {
191
192             /* Get j neighbor index, and coordinate index */
193             jnrA             = jjnr[jidx];
194             jnrB             = jjnr[jidx+1];
195             j_coord_offsetA  = DIM*jnrA;
196             j_coord_offsetB  = DIM*jnrB;
197
198             /* load j atom coordinates */
199             gmx_fjsp_load_3rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA+DIM,x+j_coord_offsetB+DIM,
200                                               &jx1,&jy1,&jz1,&jx2,&jy2,&jz2,&jx3,&jy3,&jz3);
201
202             /* Calculate displacement vector */
203             dx11             = _fjsp_sub_v2r8(ix1,jx1);
204             dy11             = _fjsp_sub_v2r8(iy1,jy1);
205             dz11             = _fjsp_sub_v2r8(iz1,jz1);
206             dx12             = _fjsp_sub_v2r8(ix1,jx2);
207             dy12             = _fjsp_sub_v2r8(iy1,jy2);
208             dz12             = _fjsp_sub_v2r8(iz1,jz2);
209             dx13             = _fjsp_sub_v2r8(ix1,jx3);
210             dy13             = _fjsp_sub_v2r8(iy1,jy3);
211             dz13             = _fjsp_sub_v2r8(iz1,jz3);
212             dx21             = _fjsp_sub_v2r8(ix2,jx1);
213             dy21             = _fjsp_sub_v2r8(iy2,jy1);
214             dz21             = _fjsp_sub_v2r8(iz2,jz1);
215             dx22             = _fjsp_sub_v2r8(ix2,jx2);
216             dy22             = _fjsp_sub_v2r8(iy2,jy2);
217             dz22             = _fjsp_sub_v2r8(iz2,jz2);
218             dx23             = _fjsp_sub_v2r8(ix2,jx3);
219             dy23             = _fjsp_sub_v2r8(iy2,jy3);
220             dz23             = _fjsp_sub_v2r8(iz2,jz3);
221             dx31             = _fjsp_sub_v2r8(ix3,jx1);
222             dy31             = _fjsp_sub_v2r8(iy3,jy1);
223             dz31             = _fjsp_sub_v2r8(iz3,jz1);
224             dx32             = _fjsp_sub_v2r8(ix3,jx2);
225             dy32             = _fjsp_sub_v2r8(iy3,jy2);
226             dz32             = _fjsp_sub_v2r8(iz3,jz2);
227             dx33             = _fjsp_sub_v2r8(ix3,jx3);
228             dy33             = _fjsp_sub_v2r8(iy3,jy3);
229             dz33             = _fjsp_sub_v2r8(iz3,jz3);
230
231             /* Calculate squared distance and things based on it */
232             rsq11            = gmx_fjsp_calc_rsq_v2r8(dx11,dy11,dz11);
233             rsq12            = gmx_fjsp_calc_rsq_v2r8(dx12,dy12,dz12);
234             rsq13            = gmx_fjsp_calc_rsq_v2r8(dx13,dy13,dz13);
235             rsq21            = gmx_fjsp_calc_rsq_v2r8(dx21,dy21,dz21);
236             rsq22            = gmx_fjsp_calc_rsq_v2r8(dx22,dy22,dz22);
237             rsq23            = gmx_fjsp_calc_rsq_v2r8(dx23,dy23,dz23);
238             rsq31            = gmx_fjsp_calc_rsq_v2r8(dx31,dy31,dz31);
239             rsq32            = gmx_fjsp_calc_rsq_v2r8(dx32,dy32,dz32);
240             rsq33            = gmx_fjsp_calc_rsq_v2r8(dx33,dy33,dz33);
241
242             rinv11           = gmx_fjsp_invsqrt_v2r8(rsq11);
243             rinv12           = gmx_fjsp_invsqrt_v2r8(rsq12);
244             rinv13           = gmx_fjsp_invsqrt_v2r8(rsq13);
245             rinv21           = gmx_fjsp_invsqrt_v2r8(rsq21);
246             rinv22           = gmx_fjsp_invsqrt_v2r8(rsq22);
247             rinv23           = gmx_fjsp_invsqrt_v2r8(rsq23);
248             rinv31           = gmx_fjsp_invsqrt_v2r8(rsq31);
249             rinv32           = gmx_fjsp_invsqrt_v2r8(rsq32);
250             rinv33           = gmx_fjsp_invsqrt_v2r8(rsq33);
251
252             rinvsq11         = _fjsp_mul_v2r8(rinv11,rinv11);
253             rinvsq12         = _fjsp_mul_v2r8(rinv12,rinv12);
254             rinvsq13         = _fjsp_mul_v2r8(rinv13,rinv13);
255             rinvsq21         = _fjsp_mul_v2r8(rinv21,rinv21);
256             rinvsq22         = _fjsp_mul_v2r8(rinv22,rinv22);
257             rinvsq23         = _fjsp_mul_v2r8(rinv23,rinv23);
258             rinvsq31         = _fjsp_mul_v2r8(rinv31,rinv31);
259             rinvsq32         = _fjsp_mul_v2r8(rinv32,rinv32);
260             rinvsq33         = _fjsp_mul_v2r8(rinv33,rinv33);
261
262             fjx1             = _fjsp_setzero_v2r8();
263             fjy1             = _fjsp_setzero_v2r8();
264             fjz1             = _fjsp_setzero_v2r8();
265             fjx2             = _fjsp_setzero_v2r8();
266             fjy2             = _fjsp_setzero_v2r8();
267             fjz2             = _fjsp_setzero_v2r8();
268             fjx3             = _fjsp_setzero_v2r8();
269             fjy3             = _fjsp_setzero_v2r8();
270             fjz3             = _fjsp_setzero_v2r8();
271
272             /**************************
273              * CALCULATE INTERACTIONS *
274              **************************/
275
276             if (gmx_fjsp_any_lt_v2r8(rsq11,rcutoff2))
277             {
278
279             /* REACTION-FIELD ELECTROSTATICS */
280             velec            = _fjsp_mul_v2r8(qq11,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq11,rinv11),crf));
281             felec            = _fjsp_mul_v2r8(qq11,_fjsp_msub_v2r8(rinv11,rinvsq11,krf2));
282
283             cutoff_mask      = _fjsp_cmplt_v2r8(rsq11,rcutoff2);
284
285             /* Update potential sum for this i atom from the interaction with this j atom. */
286             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
287             velecsum         = _fjsp_add_v2r8(velecsum,velec);
288
289             fscal            = felec;
290
291             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
292
293             /* Update vectorial force */
294             fix1             = _fjsp_madd_v2r8(dx11,fscal,fix1);
295             fiy1             = _fjsp_madd_v2r8(dy11,fscal,fiy1);
296             fiz1             = _fjsp_madd_v2r8(dz11,fscal,fiz1);
297             
298             fjx1             = _fjsp_madd_v2r8(dx11,fscal,fjx1);
299             fjy1             = _fjsp_madd_v2r8(dy11,fscal,fjy1);
300             fjz1             = _fjsp_madd_v2r8(dz11,fscal,fjz1);
301
302             }
303
304             /**************************
305              * CALCULATE INTERACTIONS *
306              **************************/
307
308             if (gmx_fjsp_any_lt_v2r8(rsq12,rcutoff2))
309             {
310
311             /* REACTION-FIELD ELECTROSTATICS */
312             velec            = _fjsp_mul_v2r8(qq12,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq12,rinv12),crf));
313             felec            = _fjsp_mul_v2r8(qq12,_fjsp_msub_v2r8(rinv12,rinvsq12,krf2));
314
315             cutoff_mask      = _fjsp_cmplt_v2r8(rsq12,rcutoff2);
316
317             /* Update potential sum for this i atom from the interaction with this j atom. */
318             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
319             velecsum         = _fjsp_add_v2r8(velecsum,velec);
320
321             fscal            = felec;
322
323             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
324
325             /* Update vectorial force */
326             fix1             = _fjsp_madd_v2r8(dx12,fscal,fix1);
327             fiy1             = _fjsp_madd_v2r8(dy12,fscal,fiy1);
328             fiz1             = _fjsp_madd_v2r8(dz12,fscal,fiz1);
329             
330             fjx2             = _fjsp_madd_v2r8(dx12,fscal,fjx2);
331             fjy2             = _fjsp_madd_v2r8(dy12,fscal,fjy2);
332             fjz2             = _fjsp_madd_v2r8(dz12,fscal,fjz2);
333
334             }
335
336             /**************************
337              * CALCULATE INTERACTIONS *
338              **************************/
339
340             if (gmx_fjsp_any_lt_v2r8(rsq13,rcutoff2))
341             {
342
343             /* REACTION-FIELD ELECTROSTATICS */
344             velec            = _fjsp_mul_v2r8(qq13,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq13,rinv13),crf));
345             felec            = _fjsp_mul_v2r8(qq13,_fjsp_msub_v2r8(rinv13,rinvsq13,krf2));
346
347             cutoff_mask      = _fjsp_cmplt_v2r8(rsq13,rcutoff2);
348
349             /* Update potential sum for this i atom from the interaction with this j atom. */
350             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
351             velecsum         = _fjsp_add_v2r8(velecsum,velec);
352
353             fscal            = felec;
354
355             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
356
357             /* Update vectorial force */
358             fix1             = _fjsp_madd_v2r8(dx13,fscal,fix1);
359             fiy1             = _fjsp_madd_v2r8(dy13,fscal,fiy1);
360             fiz1             = _fjsp_madd_v2r8(dz13,fscal,fiz1);
361             
362             fjx3             = _fjsp_madd_v2r8(dx13,fscal,fjx3);
363             fjy3             = _fjsp_madd_v2r8(dy13,fscal,fjy3);
364             fjz3             = _fjsp_madd_v2r8(dz13,fscal,fjz3);
365
366             }
367
368             /**************************
369              * CALCULATE INTERACTIONS *
370              **************************/
371
372             if (gmx_fjsp_any_lt_v2r8(rsq21,rcutoff2))
373             {
374
375             /* REACTION-FIELD ELECTROSTATICS */
376             velec            = _fjsp_mul_v2r8(qq21,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq21,rinv21),crf));
377             felec            = _fjsp_mul_v2r8(qq21,_fjsp_msub_v2r8(rinv21,rinvsq21,krf2));
378
379             cutoff_mask      = _fjsp_cmplt_v2r8(rsq21,rcutoff2);
380
381             /* Update potential sum for this i atom from the interaction with this j atom. */
382             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
383             velecsum         = _fjsp_add_v2r8(velecsum,velec);
384
385             fscal            = felec;
386
387             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
388
389             /* Update vectorial force */
390             fix2             = _fjsp_madd_v2r8(dx21,fscal,fix2);
391             fiy2             = _fjsp_madd_v2r8(dy21,fscal,fiy2);
392             fiz2             = _fjsp_madd_v2r8(dz21,fscal,fiz2);
393             
394             fjx1             = _fjsp_madd_v2r8(dx21,fscal,fjx1);
395             fjy1             = _fjsp_madd_v2r8(dy21,fscal,fjy1);
396             fjz1             = _fjsp_madd_v2r8(dz21,fscal,fjz1);
397
398             }
399
400             /**************************
401              * CALCULATE INTERACTIONS *
402              **************************/
403
404             if (gmx_fjsp_any_lt_v2r8(rsq22,rcutoff2))
405             {
406
407             /* REACTION-FIELD ELECTROSTATICS */
408             velec            = _fjsp_mul_v2r8(qq22,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq22,rinv22),crf));
409             felec            = _fjsp_mul_v2r8(qq22,_fjsp_msub_v2r8(rinv22,rinvsq22,krf2));
410
411             cutoff_mask      = _fjsp_cmplt_v2r8(rsq22,rcutoff2);
412
413             /* Update potential sum for this i atom from the interaction with this j atom. */
414             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
415             velecsum         = _fjsp_add_v2r8(velecsum,velec);
416
417             fscal            = felec;
418
419             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
420
421             /* Update vectorial force */
422             fix2             = _fjsp_madd_v2r8(dx22,fscal,fix2);
423             fiy2             = _fjsp_madd_v2r8(dy22,fscal,fiy2);
424             fiz2             = _fjsp_madd_v2r8(dz22,fscal,fiz2);
425             
426             fjx2             = _fjsp_madd_v2r8(dx22,fscal,fjx2);
427             fjy2             = _fjsp_madd_v2r8(dy22,fscal,fjy2);
428             fjz2             = _fjsp_madd_v2r8(dz22,fscal,fjz2);
429
430             }
431
432             /**************************
433              * CALCULATE INTERACTIONS *
434              **************************/
435
436             if (gmx_fjsp_any_lt_v2r8(rsq23,rcutoff2))
437             {
438
439             /* REACTION-FIELD ELECTROSTATICS */
440             velec            = _fjsp_mul_v2r8(qq23,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq23,rinv23),crf));
441             felec            = _fjsp_mul_v2r8(qq23,_fjsp_msub_v2r8(rinv23,rinvsq23,krf2));
442
443             cutoff_mask      = _fjsp_cmplt_v2r8(rsq23,rcutoff2);
444
445             /* Update potential sum for this i atom from the interaction with this j atom. */
446             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
447             velecsum         = _fjsp_add_v2r8(velecsum,velec);
448
449             fscal            = felec;
450
451             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
452
453             /* Update vectorial force */
454             fix2             = _fjsp_madd_v2r8(dx23,fscal,fix2);
455             fiy2             = _fjsp_madd_v2r8(dy23,fscal,fiy2);
456             fiz2             = _fjsp_madd_v2r8(dz23,fscal,fiz2);
457             
458             fjx3             = _fjsp_madd_v2r8(dx23,fscal,fjx3);
459             fjy3             = _fjsp_madd_v2r8(dy23,fscal,fjy3);
460             fjz3             = _fjsp_madd_v2r8(dz23,fscal,fjz3);
461
462             }
463
464             /**************************
465              * CALCULATE INTERACTIONS *
466              **************************/
467
468             if (gmx_fjsp_any_lt_v2r8(rsq31,rcutoff2))
469             {
470
471             /* REACTION-FIELD ELECTROSTATICS */
472             velec            = _fjsp_mul_v2r8(qq31,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq31,rinv31),crf));
473             felec            = _fjsp_mul_v2r8(qq31,_fjsp_msub_v2r8(rinv31,rinvsq31,krf2));
474
475             cutoff_mask      = _fjsp_cmplt_v2r8(rsq31,rcutoff2);
476
477             /* Update potential sum for this i atom from the interaction with this j atom. */
478             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
479             velecsum         = _fjsp_add_v2r8(velecsum,velec);
480
481             fscal            = felec;
482
483             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
484
485             /* Update vectorial force */
486             fix3             = _fjsp_madd_v2r8(dx31,fscal,fix3);
487             fiy3             = _fjsp_madd_v2r8(dy31,fscal,fiy3);
488             fiz3             = _fjsp_madd_v2r8(dz31,fscal,fiz3);
489             
490             fjx1             = _fjsp_madd_v2r8(dx31,fscal,fjx1);
491             fjy1             = _fjsp_madd_v2r8(dy31,fscal,fjy1);
492             fjz1             = _fjsp_madd_v2r8(dz31,fscal,fjz1);
493
494             }
495
496             /**************************
497              * CALCULATE INTERACTIONS *
498              **************************/
499
500             if (gmx_fjsp_any_lt_v2r8(rsq32,rcutoff2))
501             {
502
503             /* REACTION-FIELD ELECTROSTATICS */
504             velec            = _fjsp_mul_v2r8(qq32,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq32,rinv32),crf));
505             felec            = _fjsp_mul_v2r8(qq32,_fjsp_msub_v2r8(rinv32,rinvsq32,krf2));
506
507             cutoff_mask      = _fjsp_cmplt_v2r8(rsq32,rcutoff2);
508
509             /* Update potential sum for this i atom from the interaction with this j atom. */
510             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
511             velecsum         = _fjsp_add_v2r8(velecsum,velec);
512
513             fscal            = felec;
514
515             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
516
517             /* Update vectorial force */
518             fix3             = _fjsp_madd_v2r8(dx32,fscal,fix3);
519             fiy3             = _fjsp_madd_v2r8(dy32,fscal,fiy3);
520             fiz3             = _fjsp_madd_v2r8(dz32,fscal,fiz3);
521             
522             fjx2             = _fjsp_madd_v2r8(dx32,fscal,fjx2);
523             fjy2             = _fjsp_madd_v2r8(dy32,fscal,fjy2);
524             fjz2             = _fjsp_madd_v2r8(dz32,fscal,fjz2);
525
526             }
527
528             /**************************
529              * CALCULATE INTERACTIONS *
530              **************************/
531
532             if (gmx_fjsp_any_lt_v2r8(rsq33,rcutoff2))
533             {
534
535             /* REACTION-FIELD ELECTROSTATICS */
536             velec            = _fjsp_mul_v2r8(qq33,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq33,rinv33),crf));
537             felec            = _fjsp_mul_v2r8(qq33,_fjsp_msub_v2r8(rinv33,rinvsq33,krf2));
538
539             cutoff_mask      = _fjsp_cmplt_v2r8(rsq33,rcutoff2);
540
541             /* Update potential sum for this i atom from the interaction with this j atom. */
542             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
543             velecsum         = _fjsp_add_v2r8(velecsum,velec);
544
545             fscal            = felec;
546
547             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
548
549             /* Update vectorial force */
550             fix3             = _fjsp_madd_v2r8(dx33,fscal,fix3);
551             fiy3             = _fjsp_madd_v2r8(dy33,fscal,fiy3);
552             fiz3             = _fjsp_madd_v2r8(dz33,fscal,fiz3);
553             
554             fjx3             = _fjsp_madd_v2r8(dx33,fscal,fjx3);
555             fjy3             = _fjsp_madd_v2r8(dy33,fscal,fjy3);
556             fjz3             = _fjsp_madd_v2r8(dz33,fscal,fjz3);
557
558             }
559
560             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);
561
562             /* Inner loop uses 351 flops */
563         }
564
565         if(jidx<j_index_end)
566         {
567
568             jnrA             = jjnr[jidx];
569             j_coord_offsetA  = DIM*jnrA;
570
571             /* load j atom coordinates */
572             gmx_fjsp_load_3rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA+DIM,
573                                               &jx1,&jy1,&jz1,&jx2,&jy2,&jz2,&jx3,&jy3,&jz3);
574
575             /* Calculate displacement vector */
576             dx11             = _fjsp_sub_v2r8(ix1,jx1);
577             dy11             = _fjsp_sub_v2r8(iy1,jy1);
578             dz11             = _fjsp_sub_v2r8(iz1,jz1);
579             dx12             = _fjsp_sub_v2r8(ix1,jx2);
580             dy12             = _fjsp_sub_v2r8(iy1,jy2);
581             dz12             = _fjsp_sub_v2r8(iz1,jz2);
582             dx13             = _fjsp_sub_v2r8(ix1,jx3);
583             dy13             = _fjsp_sub_v2r8(iy1,jy3);
584             dz13             = _fjsp_sub_v2r8(iz1,jz3);
585             dx21             = _fjsp_sub_v2r8(ix2,jx1);
586             dy21             = _fjsp_sub_v2r8(iy2,jy1);
587             dz21             = _fjsp_sub_v2r8(iz2,jz1);
588             dx22             = _fjsp_sub_v2r8(ix2,jx2);
589             dy22             = _fjsp_sub_v2r8(iy2,jy2);
590             dz22             = _fjsp_sub_v2r8(iz2,jz2);
591             dx23             = _fjsp_sub_v2r8(ix2,jx3);
592             dy23             = _fjsp_sub_v2r8(iy2,jy3);
593             dz23             = _fjsp_sub_v2r8(iz2,jz3);
594             dx31             = _fjsp_sub_v2r8(ix3,jx1);
595             dy31             = _fjsp_sub_v2r8(iy3,jy1);
596             dz31             = _fjsp_sub_v2r8(iz3,jz1);
597             dx32             = _fjsp_sub_v2r8(ix3,jx2);
598             dy32             = _fjsp_sub_v2r8(iy3,jy2);
599             dz32             = _fjsp_sub_v2r8(iz3,jz2);
600             dx33             = _fjsp_sub_v2r8(ix3,jx3);
601             dy33             = _fjsp_sub_v2r8(iy3,jy3);
602             dz33             = _fjsp_sub_v2r8(iz3,jz3);
603
604             /* Calculate squared distance and things based on it */
605             rsq11            = gmx_fjsp_calc_rsq_v2r8(dx11,dy11,dz11);
606             rsq12            = gmx_fjsp_calc_rsq_v2r8(dx12,dy12,dz12);
607             rsq13            = gmx_fjsp_calc_rsq_v2r8(dx13,dy13,dz13);
608             rsq21            = gmx_fjsp_calc_rsq_v2r8(dx21,dy21,dz21);
609             rsq22            = gmx_fjsp_calc_rsq_v2r8(dx22,dy22,dz22);
610             rsq23            = gmx_fjsp_calc_rsq_v2r8(dx23,dy23,dz23);
611             rsq31            = gmx_fjsp_calc_rsq_v2r8(dx31,dy31,dz31);
612             rsq32            = gmx_fjsp_calc_rsq_v2r8(dx32,dy32,dz32);
613             rsq33            = gmx_fjsp_calc_rsq_v2r8(dx33,dy33,dz33);
614
615             rinv11           = gmx_fjsp_invsqrt_v2r8(rsq11);
616             rinv12           = gmx_fjsp_invsqrt_v2r8(rsq12);
617             rinv13           = gmx_fjsp_invsqrt_v2r8(rsq13);
618             rinv21           = gmx_fjsp_invsqrt_v2r8(rsq21);
619             rinv22           = gmx_fjsp_invsqrt_v2r8(rsq22);
620             rinv23           = gmx_fjsp_invsqrt_v2r8(rsq23);
621             rinv31           = gmx_fjsp_invsqrt_v2r8(rsq31);
622             rinv32           = gmx_fjsp_invsqrt_v2r8(rsq32);
623             rinv33           = gmx_fjsp_invsqrt_v2r8(rsq33);
624
625             rinvsq11         = _fjsp_mul_v2r8(rinv11,rinv11);
626             rinvsq12         = _fjsp_mul_v2r8(rinv12,rinv12);
627             rinvsq13         = _fjsp_mul_v2r8(rinv13,rinv13);
628             rinvsq21         = _fjsp_mul_v2r8(rinv21,rinv21);
629             rinvsq22         = _fjsp_mul_v2r8(rinv22,rinv22);
630             rinvsq23         = _fjsp_mul_v2r8(rinv23,rinv23);
631             rinvsq31         = _fjsp_mul_v2r8(rinv31,rinv31);
632             rinvsq32         = _fjsp_mul_v2r8(rinv32,rinv32);
633             rinvsq33         = _fjsp_mul_v2r8(rinv33,rinv33);
634
635             fjx1             = _fjsp_setzero_v2r8();
636             fjy1             = _fjsp_setzero_v2r8();
637             fjz1             = _fjsp_setzero_v2r8();
638             fjx2             = _fjsp_setzero_v2r8();
639             fjy2             = _fjsp_setzero_v2r8();
640             fjz2             = _fjsp_setzero_v2r8();
641             fjx3             = _fjsp_setzero_v2r8();
642             fjy3             = _fjsp_setzero_v2r8();
643             fjz3             = _fjsp_setzero_v2r8();
644
645             /**************************
646              * CALCULATE INTERACTIONS *
647              **************************/
648
649             if (gmx_fjsp_any_lt_v2r8(rsq11,rcutoff2))
650             {
651
652             /* REACTION-FIELD ELECTROSTATICS */
653             velec            = _fjsp_mul_v2r8(qq11,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq11,rinv11),crf));
654             felec            = _fjsp_mul_v2r8(qq11,_fjsp_msub_v2r8(rinv11,rinvsq11,krf2));
655
656             cutoff_mask      = _fjsp_cmplt_v2r8(rsq11,rcutoff2);
657
658             /* Update potential sum for this i atom from the interaction with this j atom. */
659             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
660             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
661             velecsum         = _fjsp_add_v2r8(velecsum,velec);
662
663             fscal            = felec;
664
665             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
666
667             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
668
669             /* Update vectorial force */
670             fix1             = _fjsp_madd_v2r8(dx11,fscal,fix1);
671             fiy1             = _fjsp_madd_v2r8(dy11,fscal,fiy1);
672             fiz1             = _fjsp_madd_v2r8(dz11,fscal,fiz1);
673             
674             fjx1             = _fjsp_madd_v2r8(dx11,fscal,fjx1);
675             fjy1             = _fjsp_madd_v2r8(dy11,fscal,fjy1);
676             fjz1             = _fjsp_madd_v2r8(dz11,fscal,fjz1);
677
678             }
679
680             /**************************
681              * CALCULATE INTERACTIONS *
682              **************************/
683
684             if (gmx_fjsp_any_lt_v2r8(rsq12,rcutoff2))
685             {
686
687             /* REACTION-FIELD ELECTROSTATICS */
688             velec            = _fjsp_mul_v2r8(qq12,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq12,rinv12),crf));
689             felec            = _fjsp_mul_v2r8(qq12,_fjsp_msub_v2r8(rinv12,rinvsq12,krf2));
690
691             cutoff_mask      = _fjsp_cmplt_v2r8(rsq12,rcutoff2);
692
693             /* Update potential sum for this i atom from the interaction with this j atom. */
694             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
695             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
696             velecsum         = _fjsp_add_v2r8(velecsum,velec);
697
698             fscal            = felec;
699
700             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
701
702             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
703
704             /* Update vectorial force */
705             fix1             = _fjsp_madd_v2r8(dx12,fscal,fix1);
706             fiy1             = _fjsp_madd_v2r8(dy12,fscal,fiy1);
707             fiz1             = _fjsp_madd_v2r8(dz12,fscal,fiz1);
708             
709             fjx2             = _fjsp_madd_v2r8(dx12,fscal,fjx2);
710             fjy2             = _fjsp_madd_v2r8(dy12,fscal,fjy2);
711             fjz2             = _fjsp_madd_v2r8(dz12,fscal,fjz2);
712
713             }
714
715             /**************************
716              * CALCULATE INTERACTIONS *
717              **************************/
718
719             if (gmx_fjsp_any_lt_v2r8(rsq13,rcutoff2))
720             {
721
722             /* REACTION-FIELD ELECTROSTATICS */
723             velec            = _fjsp_mul_v2r8(qq13,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq13,rinv13),crf));
724             felec            = _fjsp_mul_v2r8(qq13,_fjsp_msub_v2r8(rinv13,rinvsq13,krf2));
725
726             cutoff_mask      = _fjsp_cmplt_v2r8(rsq13,rcutoff2);
727
728             /* Update potential sum for this i atom from the interaction with this j atom. */
729             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
730             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
731             velecsum         = _fjsp_add_v2r8(velecsum,velec);
732
733             fscal            = felec;
734
735             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
736
737             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
738
739             /* Update vectorial force */
740             fix1             = _fjsp_madd_v2r8(dx13,fscal,fix1);
741             fiy1             = _fjsp_madd_v2r8(dy13,fscal,fiy1);
742             fiz1             = _fjsp_madd_v2r8(dz13,fscal,fiz1);
743             
744             fjx3             = _fjsp_madd_v2r8(dx13,fscal,fjx3);
745             fjy3             = _fjsp_madd_v2r8(dy13,fscal,fjy3);
746             fjz3             = _fjsp_madd_v2r8(dz13,fscal,fjz3);
747
748             }
749
750             /**************************
751              * CALCULATE INTERACTIONS *
752              **************************/
753
754             if (gmx_fjsp_any_lt_v2r8(rsq21,rcutoff2))
755             {
756
757             /* REACTION-FIELD ELECTROSTATICS */
758             velec            = _fjsp_mul_v2r8(qq21,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq21,rinv21),crf));
759             felec            = _fjsp_mul_v2r8(qq21,_fjsp_msub_v2r8(rinv21,rinvsq21,krf2));
760
761             cutoff_mask      = _fjsp_cmplt_v2r8(rsq21,rcutoff2);
762
763             /* Update potential sum for this i atom from the interaction with this j atom. */
764             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
765             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
766             velecsum         = _fjsp_add_v2r8(velecsum,velec);
767
768             fscal            = felec;
769
770             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
771
772             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
773
774             /* Update vectorial force */
775             fix2             = _fjsp_madd_v2r8(dx21,fscal,fix2);
776             fiy2             = _fjsp_madd_v2r8(dy21,fscal,fiy2);
777             fiz2             = _fjsp_madd_v2r8(dz21,fscal,fiz2);
778             
779             fjx1             = _fjsp_madd_v2r8(dx21,fscal,fjx1);
780             fjy1             = _fjsp_madd_v2r8(dy21,fscal,fjy1);
781             fjz1             = _fjsp_madd_v2r8(dz21,fscal,fjz1);
782
783             }
784
785             /**************************
786              * CALCULATE INTERACTIONS *
787              **************************/
788
789             if (gmx_fjsp_any_lt_v2r8(rsq22,rcutoff2))
790             {
791
792             /* REACTION-FIELD ELECTROSTATICS */
793             velec            = _fjsp_mul_v2r8(qq22,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq22,rinv22),crf));
794             felec            = _fjsp_mul_v2r8(qq22,_fjsp_msub_v2r8(rinv22,rinvsq22,krf2));
795
796             cutoff_mask      = _fjsp_cmplt_v2r8(rsq22,rcutoff2);
797
798             /* Update potential sum for this i atom from the interaction with this j atom. */
799             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
800             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
801             velecsum         = _fjsp_add_v2r8(velecsum,velec);
802
803             fscal            = felec;
804
805             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
806
807             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
808
809             /* Update vectorial force */
810             fix2             = _fjsp_madd_v2r8(dx22,fscal,fix2);
811             fiy2             = _fjsp_madd_v2r8(dy22,fscal,fiy2);
812             fiz2             = _fjsp_madd_v2r8(dz22,fscal,fiz2);
813             
814             fjx2             = _fjsp_madd_v2r8(dx22,fscal,fjx2);
815             fjy2             = _fjsp_madd_v2r8(dy22,fscal,fjy2);
816             fjz2             = _fjsp_madd_v2r8(dz22,fscal,fjz2);
817
818             }
819
820             /**************************
821              * CALCULATE INTERACTIONS *
822              **************************/
823
824             if (gmx_fjsp_any_lt_v2r8(rsq23,rcutoff2))
825             {
826
827             /* REACTION-FIELD ELECTROSTATICS */
828             velec            = _fjsp_mul_v2r8(qq23,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq23,rinv23),crf));
829             felec            = _fjsp_mul_v2r8(qq23,_fjsp_msub_v2r8(rinv23,rinvsq23,krf2));
830
831             cutoff_mask      = _fjsp_cmplt_v2r8(rsq23,rcutoff2);
832
833             /* Update potential sum for this i atom from the interaction with this j atom. */
834             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
835             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
836             velecsum         = _fjsp_add_v2r8(velecsum,velec);
837
838             fscal            = felec;
839
840             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
841
842             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
843
844             /* Update vectorial force */
845             fix2             = _fjsp_madd_v2r8(dx23,fscal,fix2);
846             fiy2             = _fjsp_madd_v2r8(dy23,fscal,fiy2);
847             fiz2             = _fjsp_madd_v2r8(dz23,fscal,fiz2);
848             
849             fjx3             = _fjsp_madd_v2r8(dx23,fscal,fjx3);
850             fjy3             = _fjsp_madd_v2r8(dy23,fscal,fjy3);
851             fjz3             = _fjsp_madd_v2r8(dz23,fscal,fjz3);
852
853             }
854
855             /**************************
856              * CALCULATE INTERACTIONS *
857              **************************/
858
859             if (gmx_fjsp_any_lt_v2r8(rsq31,rcutoff2))
860             {
861
862             /* REACTION-FIELD ELECTROSTATICS */
863             velec            = _fjsp_mul_v2r8(qq31,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq31,rinv31),crf));
864             felec            = _fjsp_mul_v2r8(qq31,_fjsp_msub_v2r8(rinv31,rinvsq31,krf2));
865
866             cutoff_mask      = _fjsp_cmplt_v2r8(rsq31,rcutoff2);
867
868             /* Update potential sum for this i atom from the interaction with this j atom. */
869             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
870             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
871             velecsum         = _fjsp_add_v2r8(velecsum,velec);
872
873             fscal            = felec;
874
875             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
876
877             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
878
879             /* Update vectorial force */
880             fix3             = _fjsp_madd_v2r8(dx31,fscal,fix3);
881             fiy3             = _fjsp_madd_v2r8(dy31,fscal,fiy3);
882             fiz3             = _fjsp_madd_v2r8(dz31,fscal,fiz3);
883             
884             fjx1             = _fjsp_madd_v2r8(dx31,fscal,fjx1);
885             fjy1             = _fjsp_madd_v2r8(dy31,fscal,fjy1);
886             fjz1             = _fjsp_madd_v2r8(dz31,fscal,fjz1);
887
888             }
889
890             /**************************
891              * CALCULATE INTERACTIONS *
892              **************************/
893
894             if (gmx_fjsp_any_lt_v2r8(rsq32,rcutoff2))
895             {
896
897             /* REACTION-FIELD ELECTROSTATICS */
898             velec            = _fjsp_mul_v2r8(qq32,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq32,rinv32),crf));
899             felec            = _fjsp_mul_v2r8(qq32,_fjsp_msub_v2r8(rinv32,rinvsq32,krf2));
900
901             cutoff_mask      = _fjsp_cmplt_v2r8(rsq32,rcutoff2);
902
903             /* Update potential sum for this i atom from the interaction with this j atom. */
904             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
905             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
906             velecsum         = _fjsp_add_v2r8(velecsum,velec);
907
908             fscal            = felec;
909
910             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
911
912             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
913
914             /* Update vectorial force */
915             fix3             = _fjsp_madd_v2r8(dx32,fscal,fix3);
916             fiy3             = _fjsp_madd_v2r8(dy32,fscal,fiy3);
917             fiz3             = _fjsp_madd_v2r8(dz32,fscal,fiz3);
918             
919             fjx2             = _fjsp_madd_v2r8(dx32,fscal,fjx2);
920             fjy2             = _fjsp_madd_v2r8(dy32,fscal,fjy2);
921             fjz2             = _fjsp_madd_v2r8(dz32,fscal,fjz2);
922
923             }
924
925             /**************************
926              * CALCULATE INTERACTIONS *
927              **************************/
928
929             if (gmx_fjsp_any_lt_v2r8(rsq33,rcutoff2))
930             {
931
932             /* REACTION-FIELD ELECTROSTATICS */
933             velec            = _fjsp_mul_v2r8(qq33,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq33,rinv33),crf));
934             felec            = _fjsp_mul_v2r8(qq33,_fjsp_msub_v2r8(rinv33,rinvsq33,krf2));
935
936             cutoff_mask      = _fjsp_cmplt_v2r8(rsq33,rcutoff2);
937
938             /* Update potential sum for this i atom from the interaction with this j atom. */
939             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
940             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
941             velecsum         = _fjsp_add_v2r8(velecsum,velec);
942
943             fscal            = felec;
944
945             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
946
947             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
948
949             /* Update vectorial force */
950             fix3             = _fjsp_madd_v2r8(dx33,fscal,fix3);
951             fiy3             = _fjsp_madd_v2r8(dy33,fscal,fiy3);
952             fiz3             = _fjsp_madd_v2r8(dz33,fscal,fiz3);
953             
954             fjx3             = _fjsp_madd_v2r8(dx33,fscal,fjx3);
955             fjy3             = _fjsp_madd_v2r8(dy33,fscal,fjy3);
956             fjz3             = _fjsp_madd_v2r8(dz33,fscal,fjz3);
957
958             }
959
960             gmx_fjsp_decrement_3rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA+DIM,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
961
962             /* Inner loop uses 351 flops */
963         }
964
965         /* End of innermost loop */
966
967         gmx_fjsp_update_iforce_3atom_swizzle_v2r8(fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
968                                               f+i_coord_offset+DIM,fshift+i_shift_offset);
969
970         ggid                        = gid[iidx];
971         /* Update potential energies */
972         gmx_fjsp_update_1pot_v2r8(velecsum,kernel_data->energygrp_elec+ggid);
973
974         /* Increment number of inner iterations */
975         inneriter                  += j_index_end - j_index_start;
976
977         /* Outer loop uses 19 flops */
978     }
979
980     /* Increment number of outer iterations */
981     outeriter        += nri;
982
983     /* Update outer/inner flops */
984
985     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4W4_VF,outeriter*19 + inneriter*351);
986 }
987 /*
988  * Gromacs nonbonded kernel:   nb_kernel_ElecRFCut_VdwNone_GeomW4W4_F_sparc64_hpc_ace_double
989  * Electrostatics interaction: ReactionField
990  * VdW interaction:            None
991  * Geometry:                   Water4-Water4
992  * Calculate force/pot:        Force
993  */
994 void
995 nb_kernel_ElecRFCut_VdwNone_GeomW4W4_F_sparc64_hpc_ace_double
996                     (t_nblist                    * gmx_restrict       nlist,
997                      rvec                        * gmx_restrict          xx,
998                      rvec                        * gmx_restrict          ff,
999                      t_forcerec                  * gmx_restrict          fr,
1000                      t_mdatoms                   * gmx_restrict     mdatoms,
1001                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
1002                      t_nrnb                      * gmx_restrict        nrnb)
1003 {
1004     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
1005      * just 0 for non-waters.
1006      * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
1007      * jnr indices corresponding to data put in the four positions in the SIMD register.
1008      */
1009     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
1010     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
1011     int              jnrA,jnrB;
1012     int              j_coord_offsetA,j_coord_offsetB;
1013     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
1014     real             rcutoff_scalar;
1015     real             *shiftvec,*fshift,*x,*f;
1016     _fjsp_v2r8       tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
1017     int              vdwioffset1;
1018     _fjsp_v2r8       ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
1019     int              vdwioffset2;
1020     _fjsp_v2r8       ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
1021     int              vdwioffset3;
1022     _fjsp_v2r8       ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
1023     int              vdwjidx1A,vdwjidx1B;
1024     _fjsp_v2r8       jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
1025     int              vdwjidx2A,vdwjidx2B;
1026     _fjsp_v2r8       jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
1027     int              vdwjidx3A,vdwjidx3B;
1028     _fjsp_v2r8       jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
1029     _fjsp_v2r8       dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
1030     _fjsp_v2r8       dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
1031     _fjsp_v2r8       dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13;
1032     _fjsp_v2r8       dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
1033     _fjsp_v2r8       dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
1034     _fjsp_v2r8       dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23;
1035     _fjsp_v2r8       dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31;
1036     _fjsp_v2r8       dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32;
1037     _fjsp_v2r8       dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33;
1038     _fjsp_v2r8       velec,felec,velecsum,facel,crf,krf,krf2;
1039     real             *charge;
1040     _fjsp_v2r8       itab_tmp;
1041     _fjsp_v2r8       dummy_mask,cutoff_mask;
1042     _fjsp_v2r8       one     = gmx_fjsp_set1_v2r8(1.0);
1043     _fjsp_v2r8       two     = gmx_fjsp_set1_v2r8(2.0);
1044     union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
1045
1046     x                = xx[0];
1047     f                = ff[0];
1048
1049     nri              = nlist->nri;
1050     iinr             = nlist->iinr;
1051     jindex           = nlist->jindex;
1052     jjnr             = nlist->jjnr;
1053     shiftidx         = nlist->shift;
1054     gid              = nlist->gid;
1055     shiftvec         = fr->shift_vec[0];
1056     fshift           = fr->fshift[0];
1057     facel            = gmx_fjsp_set1_v2r8(fr->epsfac);
1058     charge           = mdatoms->chargeA;
1059     krf              = gmx_fjsp_set1_v2r8(fr->ic->k_rf);
1060     krf2             = gmx_fjsp_set1_v2r8(fr->ic->k_rf*2.0);
1061     crf              = gmx_fjsp_set1_v2r8(fr->ic->c_rf);
1062
1063     /* Setup water-specific parameters */
1064     inr              = nlist->iinr[0];
1065     iq1              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+1]));
1066     iq2              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+2]));
1067     iq3              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+3]));
1068
1069     jq1              = gmx_fjsp_set1_v2r8(charge[inr+1]);
1070     jq2              = gmx_fjsp_set1_v2r8(charge[inr+2]);
1071     jq3              = gmx_fjsp_set1_v2r8(charge[inr+3]);
1072     qq11             = _fjsp_mul_v2r8(iq1,jq1);
1073     qq12             = _fjsp_mul_v2r8(iq1,jq2);
1074     qq13             = _fjsp_mul_v2r8(iq1,jq3);
1075     qq21             = _fjsp_mul_v2r8(iq2,jq1);
1076     qq22             = _fjsp_mul_v2r8(iq2,jq2);
1077     qq23             = _fjsp_mul_v2r8(iq2,jq3);
1078     qq31             = _fjsp_mul_v2r8(iq3,jq1);
1079     qq32             = _fjsp_mul_v2r8(iq3,jq2);
1080     qq33             = _fjsp_mul_v2r8(iq3,jq3);
1081
1082     /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
1083     rcutoff_scalar   = fr->rcoulomb;
1084     rcutoff          = gmx_fjsp_set1_v2r8(rcutoff_scalar);
1085     rcutoff2         = _fjsp_mul_v2r8(rcutoff,rcutoff);
1086
1087     /* Avoid stupid compiler warnings */
1088     jnrA = jnrB = 0;
1089     j_coord_offsetA = 0;
1090     j_coord_offsetB = 0;
1091
1092     outeriter        = 0;
1093     inneriter        = 0;
1094
1095     /* Start outer loop over neighborlists */
1096     for(iidx=0; iidx<nri; iidx++)
1097     {
1098         /* Load shift vector for this list */
1099         i_shift_offset   = DIM*shiftidx[iidx];
1100
1101         /* Load limits for loop over neighbors */
1102         j_index_start    = jindex[iidx];
1103         j_index_end      = jindex[iidx+1];
1104
1105         /* Get outer coordinate index */
1106         inr              = iinr[iidx];
1107         i_coord_offset   = DIM*inr;
1108
1109         /* Load i particle coords and add shift vector */
1110         gmx_fjsp_load_shift_and_3rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset+DIM,
1111                                                  &ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
1112
1113         fix1             = _fjsp_setzero_v2r8();
1114         fiy1             = _fjsp_setzero_v2r8();
1115         fiz1             = _fjsp_setzero_v2r8();
1116         fix2             = _fjsp_setzero_v2r8();
1117         fiy2             = _fjsp_setzero_v2r8();
1118         fiz2             = _fjsp_setzero_v2r8();
1119         fix3             = _fjsp_setzero_v2r8();
1120         fiy3             = _fjsp_setzero_v2r8();
1121         fiz3             = _fjsp_setzero_v2r8();
1122
1123         /* Start inner kernel loop */
1124         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
1125         {
1126
1127             /* Get j neighbor index, and coordinate index */
1128             jnrA             = jjnr[jidx];
1129             jnrB             = jjnr[jidx+1];
1130             j_coord_offsetA  = DIM*jnrA;
1131             j_coord_offsetB  = DIM*jnrB;
1132
1133             /* load j atom coordinates */
1134             gmx_fjsp_load_3rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA+DIM,x+j_coord_offsetB+DIM,
1135                                               &jx1,&jy1,&jz1,&jx2,&jy2,&jz2,&jx3,&jy3,&jz3);
1136
1137             /* Calculate displacement vector */
1138             dx11             = _fjsp_sub_v2r8(ix1,jx1);
1139             dy11             = _fjsp_sub_v2r8(iy1,jy1);
1140             dz11             = _fjsp_sub_v2r8(iz1,jz1);
1141             dx12             = _fjsp_sub_v2r8(ix1,jx2);
1142             dy12             = _fjsp_sub_v2r8(iy1,jy2);
1143             dz12             = _fjsp_sub_v2r8(iz1,jz2);
1144             dx13             = _fjsp_sub_v2r8(ix1,jx3);
1145             dy13             = _fjsp_sub_v2r8(iy1,jy3);
1146             dz13             = _fjsp_sub_v2r8(iz1,jz3);
1147             dx21             = _fjsp_sub_v2r8(ix2,jx1);
1148             dy21             = _fjsp_sub_v2r8(iy2,jy1);
1149             dz21             = _fjsp_sub_v2r8(iz2,jz1);
1150             dx22             = _fjsp_sub_v2r8(ix2,jx2);
1151             dy22             = _fjsp_sub_v2r8(iy2,jy2);
1152             dz22             = _fjsp_sub_v2r8(iz2,jz2);
1153             dx23             = _fjsp_sub_v2r8(ix2,jx3);
1154             dy23             = _fjsp_sub_v2r8(iy2,jy3);
1155             dz23             = _fjsp_sub_v2r8(iz2,jz3);
1156             dx31             = _fjsp_sub_v2r8(ix3,jx1);
1157             dy31             = _fjsp_sub_v2r8(iy3,jy1);
1158             dz31             = _fjsp_sub_v2r8(iz3,jz1);
1159             dx32             = _fjsp_sub_v2r8(ix3,jx2);
1160             dy32             = _fjsp_sub_v2r8(iy3,jy2);
1161             dz32             = _fjsp_sub_v2r8(iz3,jz2);
1162             dx33             = _fjsp_sub_v2r8(ix3,jx3);
1163             dy33             = _fjsp_sub_v2r8(iy3,jy3);
1164             dz33             = _fjsp_sub_v2r8(iz3,jz3);
1165
1166             /* Calculate squared distance and things based on it */
1167             rsq11            = gmx_fjsp_calc_rsq_v2r8(dx11,dy11,dz11);
1168             rsq12            = gmx_fjsp_calc_rsq_v2r8(dx12,dy12,dz12);
1169             rsq13            = gmx_fjsp_calc_rsq_v2r8(dx13,dy13,dz13);
1170             rsq21            = gmx_fjsp_calc_rsq_v2r8(dx21,dy21,dz21);
1171             rsq22            = gmx_fjsp_calc_rsq_v2r8(dx22,dy22,dz22);
1172             rsq23            = gmx_fjsp_calc_rsq_v2r8(dx23,dy23,dz23);
1173             rsq31            = gmx_fjsp_calc_rsq_v2r8(dx31,dy31,dz31);
1174             rsq32            = gmx_fjsp_calc_rsq_v2r8(dx32,dy32,dz32);
1175             rsq33            = gmx_fjsp_calc_rsq_v2r8(dx33,dy33,dz33);
1176
1177             rinv11           = gmx_fjsp_invsqrt_v2r8(rsq11);
1178             rinv12           = gmx_fjsp_invsqrt_v2r8(rsq12);
1179             rinv13           = gmx_fjsp_invsqrt_v2r8(rsq13);
1180             rinv21           = gmx_fjsp_invsqrt_v2r8(rsq21);
1181             rinv22           = gmx_fjsp_invsqrt_v2r8(rsq22);
1182             rinv23           = gmx_fjsp_invsqrt_v2r8(rsq23);
1183             rinv31           = gmx_fjsp_invsqrt_v2r8(rsq31);
1184             rinv32           = gmx_fjsp_invsqrt_v2r8(rsq32);
1185             rinv33           = gmx_fjsp_invsqrt_v2r8(rsq33);
1186
1187             rinvsq11         = _fjsp_mul_v2r8(rinv11,rinv11);
1188             rinvsq12         = _fjsp_mul_v2r8(rinv12,rinv12);
1189             rinvsq13         = _fjsp_mul_v2r8(rinv13,rinv13);
1190             rinvsq21         = _fjsp_mul_v2r8(rinv21,rinv21);
1191             rinvsq22         = _fjsp_mul_v2r8(rinv22,rinv22);
1192             rinvsq23         = _fjsp_mul_v2r8(rinv23,rinv23);
1193             rinvsq31         = _fjsp_mul_v2r8(rinv31,rinv31);
1194             rinvsq32         = _fjsp_mul_v2r8(rinv32,rinv32);
1195             rinvsq33         = _fjsp_mul_v2r8(rinv33,rinv33);
1196
1197             fjx1             = _fjsp_setzero_v2r8();
1198             fjy1             = _fjsp_setzero_v2r8();
1199             fjz1             = _fjsp_setzero_v2r8();
1200             fjx2             = _fjsp_setzero_v2r8();
1201             fjy2             = _fjsp_setzero_v2r8();
1202             fjz2             = _fjsp_setzero_v2r8();
1203             fjx3             = _fjsp_setzero_v2r8();
1204             fjy3             = _fjsp_setzero_v2r8();
1205             fjz3             = _fjsp_setzero_v2r8();
1206
1207             /**************************
1208              * CALCULATE INTERACTIONS *
1209              **************************/
1210
1211             if (gmx_fjsp_any_lt_v2r8(rsq11,rcutoff2))
1212             {
1213
1214             /* REACTION-FIELD ELECTROSTATICS */
1215             felec            = _fjsp_mul_v2r8(qq11,_fjsp_msub_v2r8(rinv11,rinvsq11,krf2));
1216
1217             cutoff_mask      = _fjsp_cmplt_v2r8(rsq11,rcutoff2);
1218
1219             fscal            = felec;
1220
1221             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1222
1223             /* Update vectorial force */
1224             fix1             = _fjsp_madd_v2r8(dx11,fscal,fix1);
1225             fiy1             = _fjsp_madd_v2r8(dy11,fscal,fiy1);
1226             fiz1             = _fjsp_madd_v2r8(dz11,fscal,fiz1);
1227             
1228             fjx1             = _fjsp_madd_v2r8(dx11,fscal,fjx1);
1229             fjy1             = _fjsp_madd_v2r8(dy11,fscal,fjy1);
1230             fjz1             = _fjsp_madd_v2r8(dz11,fscal,fjz1);
1231
1232             }
1233
1234             /**************************
1235              * CALCULATE INTERACTIONS *
1236              **************************/
1237
1238             if (gmx_fjsp_any_lt_v2r8(rsq12,rcutoff2))
1239             {
1240
1241             /* REACTION-FIELD ELECTROSTATICS */
1242             felec            = _fjsp_mul_v2r8(qq12,_fjsp_msub_v2r8(rinv12,rinvsq12,krf2));
1243
1244             cutoff_mask      = _fjsp_cmplt_v2r8(rsq12,rcutoff2);
1245
1246             fscal            = felec;
1247
1248             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1249
1250             /* Update vectorial force */
1251             fix1             = _fjsp_madd_v2r8(dx12,fscal,fix1);
1252             fiy1             = _fjsp_madd_v2r8(dy12,fscal,fiy1);
1253             fiz1             = _fjsp_madd_v2r8(dz12,fscal,fiz1);
1254             
1255             fjx2             = _fjsp_madd_v2r8(dx12,fscal,fjx2);
1256             fjy2             = _fjsp_madd_v2r8(dy12,fscal,fjy2);
1257             fjz2             = _fjsp_madd_v2r8(dz12,fscal,fjz2);
1258
1259             }
1260
1261             /**************************
1262              * CALCULATE INTERACTIONS *
1263              **************************/
1264
1265             if (gmx_fjsp_any_lt_v2r8(rsq13,rcutoff2))
1266             {
1267
1268             /* REACTION-FIELD ELECTROSTATICS */
1269             felec            = _fjsp_mul_v2r8(qq13,_fjsp_msub_v2r8(rinv13,rinvsq13,krf2));
1270
1271             cutoff_mask      = _fjsp_cmplt_v2r8(rsq13,rcutoff2);
1272
1273             fscal            = felec;
1274
1275             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1276
1277             /* Update vectorial force */
1278             fix1             = _fjsp_madd_v2r8(dx13,fscal,fix1);
1279             fiy1             = _fjsp_madd_v2r8(dy13,fscal,fiy1);
1280             fiz1             = _fjsp_madd_v2r8(dz13,fscal,fiz1);
1281             
1282             fjx3             = _fjsp_madd_v2r8(dx13,fscal,fjx3);
1283             fjy3             = _fjsp_madd_v2r8(dy13,fscal,fjy3);
1284             fjz3             = _fjsp_madd_v2r8(dz13,fscal,fjz3);
1285
1286             }
1287
1288             /**************************
1289              * CALCULATE INTERACTIONS *
1290              **************************/
1291
1292             if (gmx_fjsp_any_lt_v2r8(rsq21,rcutoff2))
1293             {
1294
1295             /* REACTION-FIELD ELECTROSTATICS */
1296             felec            = _fjsp_mul_v2r8(qq21,_fjsp_msub_v2r8(rinv21,rinvsq21,krf2));
1297
1298             cutoff_mask      = _fjsp_cmplt_v2r8(rsq21,rcutoff2);
1299
1300             fscal            = felec;
1301
1302             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1303
1304             /* Update vectorial force */
1305             fix2             = _fjsp_madd_v2r8(dx21,fscal,fix2);
1306             fiy2             = _fjsp_madd_v2r8(dy21,fscal,fiy2);
1307             fiz2             = _fjsp_madd_v2r8(dz21,fscal,fiz2);
1308             
1309             fjx1             = _fjsp_madd_v2r8(dx21,fscal,fjx1);
1310             fjy1             = _fjsp_madd_v2r8(dy21,fscal,fjy1);
1311             fjz1             = _fjsp_madd_v2r8(dz21,fscal,fjz1);
1312
1313             }
1314
1315             /**************************
1316              * CALCULATE INTERACTIONS *
1317              **************************/
1318
1319             if (gmx_fjsp_any_lt_v2r8(rsq22,rcutoff2))
1320             {
1321
1322             /* REACTION-FIELD ELECTROSTATICS */
1323             felec            = _fjsp_mul_v2r8(qq22,_fjsp_msub_v2r8(rinv22,rinvsq22,krf2));
1324
1325             cutoff_mask      = _fjsp_cmplt_v2r8(rsq22,rcutoff2);
1326
1327             fscal            = felec;
1328
1329             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1330
1331             /* Update vectorial force */
1332             fix2             = _fjsp_madd_v2r8(dx22,fscal,fix2);
1333             fiy2             = _fjsp_madd_v2r8(dy22,fscal,fiy2);
1334             fiz2             = _fjsp_madd_v2r8(dz22,fscal,fiz2);
1335             
1336             fjx2             = _fjsp_madd_v2r8(dx22,fscal,fjx2);
1337             fjy2             = _fjsp_madd_v2r8(dy22,fscal,fjy2);
1338             fjz2             = _fjsp_madd_v2r8(dz22,fscal,fjz2);
1339
1340             }
1341
1342             /**************************
1343              * CALCULATE INTERACTIONS *
1344              **************************/
1345
1346             if (gmx_fjsp_any_lt_v2r8(rsq23,rcutoff2))
1347             {
1348
1349             /* REACTION-FIELD ELECTROSTATICS */
1350             felec            = _fjsp_mul_v2r8(qq23,_fjsp_msub_v2r8(rinv23,rinvsq23,krf2));
1351
1352             cutoff_mask      = _fjsp_cmplt_v2r8(rsq23,rcutoff2);
1353
1354             fscal            = felec;
1355
1356             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1357
1358             /* Update vectorial force */
1359             fix2             = _fjsp_madd_v2r8(dx23,fscal,fix2);
1360             fiy2             = _fjsp_madd_v2r8(dy23,fscal,fiy2);
1361             fiz2             = _fjsp_madd_v2r8(dz23,fscal,fiz2);
1362             
1363             fjx3             = _fjsp_madd_v2r8(dx23,fscal,fjx3);
1364             fjy3             = _fjsp_madd_v2r8(dy23,fscal,fjy3);
1365             fjz3             = _fjsp_madd_v2r8(dz23,fscal,fjz3);
1366
1367             }
1368
1369             /**************************
1370              * CALCULATE INTERACTIONS *
1371              **************************/
1372
1373             if (gmx_fjsp_any_lt_v2r8(rsq31,rcutoff2))
1374             {
1375
1376             /* REACTION-FIELD ELECTROSTATICS */
1377             felec            = _fjsp_mul_v2r8(qq31,_fjsp_msub_v2r8(rinv31,rinvsq31,krf2));
1378
1379             cutoff_mask      = _fjsp_cmplt_v2r8(rsq31,rcutoff2);
1380
1381             fscal            = felec;
1382
1383             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1384
1385             /* Update vectorial force */
1386             fix3             = _fjsp_madd_v2r8(dx31,fscal,fix3);
1387             fiy3             = _fjsp_madd_v2r8(dy31,fscal,fiy3);
1388             fiz3             = _fjsp_madd_v2r8(dz31,fscal,fiz3);
1389             
1390             fjx1             = _fjsp_madd_v2r8(dx31,fscal,fjx1);
1391             fjy1             = _fjsp_madd_v2r8(dy31,fscal,fjy1);
1392             fjz1             = _fjsp_madd_v2r8(dz31,fscal,fjz1);
1393
1394             }
1395
1396             /**************************
1397              * CALCULATE INTERACTIONS *
1398              **************************/
1399
1400             if (gmx_fjsp_any_lt_v2r8(rsq32,rcutoff2))
1401             {
1402
1403             /* REACTION-FIELD ELECTROSTATICS */
1404             felec            = _fjsp_mul_v2r8(qq32,_fjsp_msub_v2r8(rinv32,rinvsq32,krf2));
1405
1406             cutoff_mask      = _fjsp_cmplt_v2r8(rsq32,rcutoff2);
1407
1408             fscal            = felec;
1409
1410             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1411
1412             /* Update vectorial force */
1413             fix3             = _fjsp_madd_v2r8(dx32,fscal,fix3);
1414             fiy3             = _fjsp_madd_v2r8(dy32,fscal,fiy3);
1415             fiz3             = _fjsp_madd_v2r8(dz32,fscal,fiz3);
1416             
1417             fjx2             = _fjsp_madd_v2r8(dx32,fscal,fjx2);
1418             fjy2             = _fjsp_madd_v2r8(dy32,fscal,fjy2);
1419             fjz2             = _fjsp_madd_v2r8(dz32,fscal,fjz2);
1420
1421             }
1422
1423             /**************************
1424              * CALCULATE INTERACTIONS *
1425              **************************/
1426
1427             if (gmx_fjsp_any_lt_v2r8(rsq33,rcutoff2))
1428             {
1429
1430             /* REACTION-FIELD ELECTROSTATICS */
1431             felec            = _fjsp_mul_v2r8(qq33,_fjsp_msub_v2r8(rinv33,rinvsq33,krf2));
1432
1433             cutoff_mask      = _fjsp_cmplt_v2r8(rsq33,rcutoff2);
1434
1435             fscal            = felec;
1436
1437             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1438
1439             /* Update vectorial force */
1440             fix3             = _fjsp_madd_v2r8(dx33,fscal,fix3);
1441             fiy3             = _fjsp_madd_v2r8(dy33,fscal,fiy3);
1442             fiz3             = _fjsp_madd_v2r8(dz33,fscal,fiz3);
1443             
1444             fjx3             = _fjsp_madd_v2r8(dx33,fscal,fjx3);
1445             fjy3             = _fjsp_madd_v2r8(dy33,fscal,fjy3);
1446             fjz3             = _fjsp_madd_v2r8(dz33,fscal,fjz3);
1447
1448             }
1449
1450             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);
1451
1452             /* Inner loop uses 297 flops */
1453         }
1454
1455         if(jidx<j_index_end)
1456         {
1457
1458             jnrA             = jjnr[jidx];
1459             j_coord_offsetA  = DIM*jnrA;
1460
1461             /* load j atom coordinates */
1462             gmx_fjsp_load_3rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA+DIM,
1463                                               &jx1,&jy1,&jz1,&jx2,&jy2,&jz2,&jx3,&jy3,&jz3);
1464
1465             /* Calculate displacement vector */
1466             dx11             = _fjsp_sub_v2r8(ix1,jx1);
1467             dy11             = _fjsp_sub_v2r8(iy1,jy1);
1468             dz11             = _fjsp_sub_v2r8(iz1,jz1);
1469             dx12             = _fjsp_sub_v2r8(ix1,jx2);
1470             dy12             = _fjsp_sub_v2r8(iy1,jy2);
1471             dz12             = _fjsp_sub_v2r8(iz1,jz2);
1472             dx13             = _fjsp_sub_v2r8(ix1,jx3);
1473             dy13             = _fjsp_sub_v2r8(iy1,jy3);
1474             dz13             = _fjsp_sub_v2r8(iz1,jz3);
1475             dx21             = _fjsp_sub_v2r8(ix2,jx1);
1476             dy21             = _fjsp_sub_v2r8(iy2,jy1);
1477             dz21             = _fjsp_sub_v2r8(iz2,jz1);
1478             dx22             = _fjsp_sub_v2r8(ix2,jx2);
1479             dy22             = _fjsp_sub_v2r8(iy2,jy2);
1480             dz22             = _fjsp_sub_v2r8(iz2,jz2);
1481             dx23             = _fjsp_sub_v2r8(ix2,jx3);
1482             dy23             = _fjsp_sub_v2r8(iy2,jy3);
1483             dz23             = _fjsp_sub_v2r8(iz2,jz3);
1484             dx31             = _fjsp_sub_v2r8(ix3,jx1);
1485             dy31             = _fjsp_sub_v2r8(iy3,jy1);
1486             dz31             = _fjsp_sub_v2r8(iz3,jz1);
1487             dx32             = _fjsp_sub_v2r8(ix3,jx2);
1488             dy32             = _fjsp_sub_v2r8(iy3,jy2);
1489             dz32             = _fjsp_sub_v2r8(iz3,jz2);
1490             dx33             = _fjsp_sub_v2r8(ix3,jx3);
1491             dy33             = _fjsp_sub_v2r8(iy3,jy3);
1492             dz33             = _fjsp_sub_v2r8(iz3,jz3);
1493
1494             /* Calculate squared distance and things based on it */
1495             rsq11            = gmx_fjsp_calc_rsq_v2r8(dx11,dy11,dz11);
1496             rsq12            = gmx_fjsp_calc_rsq_v2r8(dx12,dy12,dz12);
1497             rsq13            = gmx_fjsp_calc_rsq_v2r8(dx13,dy13,dz13);
1498             rsq21            = gmx_fjsp_calc_rsq_v2r8(dx21,dy21,dz21);
1499             rsq22            = gmx_fjsp_calc_rsq_v2r8(dx22,dy22,dz22);
1500             rsq23            = gmx_fjsp_calc_rsq_v2r8(dx23,dy23,dz23);
1501             rsq31            = gmx_fjsp_calc_rsq_v2r8(dx31,dy31,dz31);
1502             rsq32            = gmx_fjsp_calc_rsq_v2r8(dx32,dy32,dz32);
1503             rsq33            = gmx_fjsp_calc_rsq_v2r8(dx33,dy33,dz33);
1504
1505             rinv11           = gmx_fjsp_invsqrt_v2r8(rsq11);
1506             rinv12           = gmx_fjsp_invsqrt_v2r8(rsq12);
1507             rinv13           = gmx_fjsp_invsqrt_v2r8(rsq13);
1508             rinv21           = gmx_fjsp_invsqrt_v2r8(rsq21);
1509             rinv22           = gmx_fjsp_invsqrt_v2r8(rsq22);
1510             rinv23           = gmx_fjsp_invsqrt_v2r8(rsq23);
1511             rinv31           = gmx_fjsp_invsqrt_v2r8(rsq31);
1512             rinv32           = gmx_fjsp_invsqrt_v2r8(rsq32);
1513             rinv33           = gmx_fjsp_invsqrt_v2r8(rsq33);
1514
1515             rinvsq11         = _fjsp_mul_v2r8(rinv11,rinv11);
1516             rinvsq12         = _fjsp_mul_v2r8(rinv12,rinv12);
1517             rinvsq13         = _fjsp_mul_v2r8(rinv13,rinv13);
1518             rinvsq21         = _fjsp_mul_v2r8(rinv21,rinv21);
1519             rinvsq22         = _fjsp_mul_v2r8(rinv22,rinv22);
1520             rinvsq23         = _fjsp_mul_v2r8(rinv23,rinv23);
1521             rinvsq31         = _fjsp_mul_v2r8(rinv31,rinv31);
1522             rinvsq32         = _fjsp_mul_v2r8(rinv32,rinv32);
1523             rinvsq33         = _fjsp_mul_v2r8(rinv33,rinv33);
1524
1525             fjx1             = _fjsp_setzero_v2r8();
1526             fjy1             = _fjsp_setzero_v2r8();
1527             fjz1             = _fjsp_setzero_v2r8();
1528             fjx2             = _fjsp_setzero_v2r8();
1529             fjy2             = _fjsp_setzero_v2r8();
1530             fjz2             = _fjsp_setzero_v2r8();
1531             fjx3             = _fjsp_setzero_v2r8();
1532             fjy3             = _fjsp_setzero_v2r8();
1533             fjz3             = _fjsp_setzero_v2r8();
1534
1535             /**************************
1536              * CALCULATE INTERACTIONS *
1537              **************************/
1538
1539             if (gmx_fjsp_any_lt_v2r8(rsq11,rcutoff2))
1540             {
1541
1542             /* REACTION-FIELD ELECTROSTATICS */
1543             felec            = _fjsp_mul_v2r8(qq11,_fjsp_msub_v2r8(rinv11,rinvsq11,krf2));
1544
1545             cutoff_mask      = _fjsp_cmplt_v2r8(rsq11,rcutoff2);
1546
1547             fscal            = felec;
1548
1549             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1550
1551             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1552
1553             /* Update vectorial force */
1554             fix1             = _fjsp_madd_v2r8(dx11,fscal,fix1);
1555             fiy1             = _fjsp_madd_v2r8(dy11,fscal,fiy1);
1556             fiz1             = _fjsp_madd_v2r8(dz11,fscal,fiz1);
1557             
1558             fjx1             = _fjsp_madd_v2r8(dx11,fscal,fjx1);
1559             fjy1             = _fjsp_madd_v2r8(dy11,fscal,fjy1);
1560             fjz1             = _fjsp_madd_v2r8(dz11,fscal,fjz1);
1561
1562             }
1563
1564             /**************************
1565              * CALCULATE INTERACTIONS *
1566              **************************/
1567
1568             if (gmx_fjsp_any_lt_v2r8(rsq12,rcutoff2))
1569             {
1570
1571             /* REACTION-FIELD ELECTROSTATICS */
1572             felec            = _fjsp_mul_v2r8(qq12,_fjsp_msub_v2r8(rinv12,rinvsq12,krf2));
1573
1574             cutoff_mask      = _fjsp_cmplt_v2r8(rsq12,rcutoff2);
1575
1576             fscal            = felec;
1577
1578             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1579
1580             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1581
1582             /* Update vectorial force */
1583             fix1             = _fjsp_madd_v2r8(dx12,fscal,fix1);
1584             fiy1             = _fjsp_madd_v2r8(dy12,fscal,fiy1);
1585             fiz1             = _fjsp_madd_v2r8(dz12,fscal,fiz1);
1586             
1587             fjx2             = _fjsp_madd_v2r8(dx12,fscal,fjx2);
1588             fjy2             = _fjsp_madd_v2r8(dy12,fscal,fjy2);
1589             fjz2             = _fjsp_madd_v2r8(dz12,fscal,fjz2);
1590
1591             }
1592
1593             /**************************
1594              * CALCULATE INTERACTIONS *
1595              **************************/
1596
1597             if (gmx_fjsp_any_lt_v2r8(rsq13,rcutoff2))
1598             {
1599
1600             /* REACTION-FIELD ELECTROSTATICS */
1601             felec            = _fjsp_mul_v2r8(qq13,_fjsp_msub_v2r8(rinv13,rinvsq13,krf2));
1602
1603             cutoff_mask      = _fjsp_cmplt_v2r8(rsq13,rcutoff2);
1604
1605             fscal            = felec;
1606
1607             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1608
1609             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1610
1611             /* Update vectorial force */
1612             fix1             = _fjsp_madd_v2r8(dx13,fscal,fix1);
1613             fiy1             = _fjsp_madd_v2r8(dy13,fscal,fiy1);
1614             fiz1             = _fjsp_madd_v2r8(dz13,fscal,fiz1);
1615             
1616             fjx3             = _fjsp_madd_v2r8(dx13,fscal,fjx3);
1617             fjy3             = _fjsp_madd_v2r8(dy13,fscal,fjy3);
1618             fjz3             = _fjsp_madd_v2r8(dz13,fscal,fjz3);
1619
1620             }
1621
1622             /**************************
1623              * CALCULATE INTERACTIONS *
1624              **************************/
1625
1626             if (gmx_fjsp_any_lt_v2r8(rsq21,rcutoff2))
1627             {
1628
1629             /* REACTION-FIELD ELECTROSTATICS */
1630             felec            = _fjsp_mul_v2r8(qq21,_fjsp_msub_v2r8(rinv21,rinvsq21,krf2));
1631
1632             cutoff_mask      = _fjsp_cmplt_v2r8(rsq21,rcutoff2);
1633
1634             fscal            = felec;
1635
1636             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1637
1638             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1639
1640             /* Update vectorial force */
1641             fix2             = _fjsp_madd_v2r8(dx21,fscal,fix2);
1642             fiy2             = _fjsp_madd_v2r8(dy21,fscal,fiy2);
1643             fiz2             = _fjsp_madd_v2r8(dz21,fscal,fiz2);
1644             
1645             fjx1             = _fjsp_madd_v2r8(dx21,fscal,fjx1);
1646             fjy1             = _fjsp_madd_v2r8(dy21,fscal,fjy1);
1647             fjz1             = _fjsp_madd_v2r8(dz21,fscal,fjz1);
1648
1649             }
1650
1651             /**************************
1652              * CALCULATE INTERACTIONS *
1653              **************************/
1654
1655             if (gmx_fjsp_any_lt_v2r8(rsq22,rcutoff2))
1656             {
1657
1658             /* REACTION-FIELD ELECTROSTATICS */
1659             felec            = _fjsp_mul_v2r8(qq22,_fjsp_msub_v2r8(rinv22,rinvsq22,krf2));
1660
1661             cutoff_mask      = _fjsp_cmplt_v2r8(rsq22,rcutoff2);
1662
1663             fscal            = felec;
1664
1665             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1666
1667             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1668
1669             /* Update vectorial force */
1670             fix2             = _fjsp_madd_v2r8(dx22,fscal,fix2);
1671             fiy2             = _fjsp_madd_v2r8(dy22,fscal,fiy2);
1672             fiz2             = _fjsp_madd_v2r8(dz22,fscal,fiz2);
1673             
1674             fjx2             = _fjsp_madd_v2r8(dx22,fscal,fjx2);
1675             fjy2             = _fjsp_madd_v2r8(dy22,fscal,fjy2);
1676             fjz2             = _fjsp_madd_v2r8(dz22,fscal,fjz2);
1677
1678             }
1679
1680             /**************************
1681              * CALCULATE INTERACTIONS *
1682              **************************/
1683
1684             if (gmx_fjsp_any_lt_v2r8(rsq23,rcutoff2))
1685             {
1686
1687             /* REACTION-FIELD ELECTROSTATICS */
1688             felec            = _fjsp_mul_v2r8(qq23,_fjsp_msub_v2r8(rinv23,rinvsq23,krf2));
1689
1690             cutoff_mask      = _fjsp_cmplt_v2r8(rsq23,rcutoff2);
1691
1692             fscal            = felec;
1693
1694             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1695
1696             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1697
1698             /* Update vectorial force */
1699             fix2             = _fjsp_madd_v2r8(dx23,fscal,fix2);
1700             fiy2             = _fjsp_madd_v2r8(dy23,fscal,fiy2);
1701             fiz2             = _fjsp_madd_v2r8(dz23,fscal,fiz2);
1702             
1703             fjx3             = _fjsp_madd_v2r8(dx23,fscal,fjx3);
1704             fjy3             = _fjsp_madd_v2r8(dy23,fscal,fjy3);
1705             fjz3             = _fjsp_madd_v2r8(dz23,fscal,fjz3);
1706
1707             }
1708
1709             /**************************
1710              * CALCULATE INTERACTIONS *
1711              **************************/
1712
1713             if (gmx_fjsp_any_lt_v2r8(rsq31,rcutoff2))
1714             {
1715
1716             /* REACTION-FIELD ELECTROSTATICS */
1717             felec            = _fjsp_mul_v2r8(qq31,_fjsp_msub_v2r8(rinv31,rinvsq31,krf2));
1718
1719             cutoff_mask      = _fjsp_cmplt_v2r8(rsq31,rcutoff2);
1720
1721             fscal            = felec;
1722
1723             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1724
1725             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1726
1727             /* Update vectorial force */
1728             fix3             = _fjsp_madd_v2r8(dx31,fscal,fix3);
1729             fiy3             = _fjsp_madd_v2r8(dy31,fscal,fiy3);
1730             fiz3             = _fjsp_madd_v2r8(dz31,fscal,fiz3);
1731             
1732             fjx1             = _fjsp_madd_v2r8(dx31,fscal,fjx1);
1733             fjy1             = _fjsp_madd_v2r8(dy31,fscal,fjy1);
1734             fjz1             = _fjsp_madd_v2r8(dz31,fscal,fjz1);
1735
1736             }
1737
1738             /**************************
1739              * CALCULATE INTERACTIONS *
1740              **************************/
1741
1742             if (gmx_fjsp_any_lt_v2r8(rsq32,rcutoff2))
1743             {
1744
1745             /* REACTION-FIELD ELECTROSTATICS */
1746             felec            = _fjsp_mul_v2r8(qq32,_fjsp_msub_v2r8(rinv32,rinvsq32,krf2));
1747
1748             cutoff_mask      = _fjsp_cmplt_v2r8(rsq32,rcutoff2);
1749
1750             fscal            = felec;
1751
1752             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1753
1754             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1755
1756             /* Update vectorial force */
1757             fix3             = _fjsp_madd_v2r8(dx32,fscal,fix3);
1758             fiy3             = _fjsp_madd_v2r8(dy32,fscal,fiy3);
1759             fiz3             = _fjsp_madd_v2r8(dz32,fscal,fiz3);
1760             
1761             fjx2             = _fjsp_madd_v2r8(dx32,fscal,fjx2);
1762             fjy2             = _fjsp_madd_v2r8(dy32,fscal,fjy2);
1763             fjz2             = _fjsp_madd_v2r8(dz32,fscal,fjz2);
1764
1765             }
1766
1767             /**************************
1768              * CALCULATE INTERACTIONS *
1769              **************************/
1770
1771             if (gmx_fjsp_any_lt_v2r8(rsq33,rcutoff2))
1772             {
1773
1774             /* REACTION-FIELD ELECTROSTATICS */
1775             felec            = _fjsp_mul_v2r8(qq33,_fjsp_msub_v2r8(rinv33,rinvsq33,krf2));
1776
1777             cutoff_mask      = _fjsp_cmplt_v2r8(rsq33,rcutoff2);
1778
1779             fscal            = felec;
1780
1781             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1782
1783             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1784
1785             /* Update vectorial force */
1786             fix3             = _fjsp_madd_v2r8(dx33,fscal,fix3);
1787             fiy3             = _fjsp_madd_v2r8(dy33,fscal,fiy3);
1788             fiz3             = _fjsp_madd_v2r8(dz33,fscal,fiz3);
1789             
1790             fjx3             = _fjsp_madd_v2r8(dx33,fscal,fjx3);
1791             fjy3             = _fjsp_madd_v2r8(dy33,fscal,fjy3);
1792             fjz3             = _fjsp_madd_v2r8(dz33,fscal,fjz3);
1793
1794             }
1795
1796             gmx_fjsp_decrement_3rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA+DIM,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
1797
1798             /* Inner loop uses 297 flops */
1799         }
1800
1801         /* End of innermost loop */
1802
1803         gmx_fjsp_update_iforce_3atom_swizzle_v2r8(fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
1804                                               f+i_coord_offset+DIM,fshift+i_shift_offset);
1805
1806         /* Increment number of inner iterations */
1807         inneriter                  += j_index_end - j_index_start;
1808
1809         /* Outer loop uses 18 flops */
1810     }
1811
1812     /* Increment number of outer iterations */
1813     outeriter        += nri;
1814
1815     /* Update outer/inner flops */
1816
1817     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4W4_F,outeriter*18 + inneriter*297);
1818 }