Introduce gmxpre.h for truly global definitions
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_sparc64_hpc_ace_double / nb_kernel_ElecRF_VdwLJ_GeomW4P1_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_VdwLJ_GeomW4P1_VF_sparc64_hpc_ace_double
53  * Electrostatics interaction: ReactionField
54  * VdW interaction:            LennardJones
55  * Geometry:                   Water4-Particle
56  * Calculate force/pot:        PotentialAndForce
57  */
58 void
59 nb_kernel_ElecRF_VdwLJ_GeomW4P1_VF_sparc64_hpc_ace_double
60                     (t_nblist                    * gmx_restrict       nlist,
61                      rvec                        * gmx_restrict          xx,
62                      rvec                        * gmx_restrict          ff,
63                      t_forcerec                  * gmx_restrict          fr,
64                      t_mdatoms                   * gmx_restrict     mdatoms,
65                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
66                      t_nrnb                      * gmx_restrict        nrnb)
67 {
68     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
69      * just 0 for non-waters.
70      * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
71      * jnr indices corresponding to data put in the four positions in the SIMD register.
72      */
73     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
74     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
75     int              jnrA,jnrB;
76     int              j_coord_offsetA,j_coord_offsetB;
77     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
78     real             rcutoff_scalar;
79     real             *shiftvec,*fshift,*x,*f;
80     _fjsp_v2r8       tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
81     int              vdwioffset0;
82     _fjsp_v2r8       ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
83     int              vdwioffset1;
84     _fjsp_v2r8       ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
85     int              vdwioffset2;
86     _fjsp_v2r8       ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
87     int              vdwioffset3;
88     _fjsp_v2r8       ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
89     int              vdwjidx0A,vdwjidx0B;
90     _fjsp_v2r8       jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
91     _fjsp_v2r8       dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
92     _fjsp_v2r8       dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
93     _fjsp_v2r8       dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
94     _fjsp_v2r8       dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
95     _fjsp_v2r8       velec,felec,velecsum,facel,crf,krf,krf2;
96     real             *charge;
97     int              nvdwtype;
98     _fjsp_v2r8       rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
99     int              *vdwtype;
100     real             *vdwparam;
101     _fjsp_v2r8       one_sixth   = gmx_fjsp_set1_v2r8(1.0/6.0);
102     _fjsp_v2r8       one_twelfth = gmx_fjsp_set1_v2r8(1.0/12.0);
103     _fjsp_v2r8       itab_tmp;
104     _fjsp_v2r8       dummy_mask,cutoff_mask;
105     _fjsp_v2r8       one     = gmx_fjsp_set1_v2r8(1.0);
106     _fjsp_v2r8       two     = gmx_fjsp_set1_v2r8(2.0);
107     union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
108
109     x                = xx[0];
110     f                = ff[0];
111
112     nri              = nlist->nri;
113     iinr             = nlist->iinr;
114     jindex           = nlist->jindex;
115     jjnr             = nlist->jjnr;
116     shiftidx         = nlist->shift;
117     gid              = nlist->gid;
118     shiftvec         = fr->shift_vec[0];
119     fshift           = fr->fshift[0];
120     facel            = gmx_fjsp_set1_v2r8(fr->epsfac);
121     charge           = mdatoms->chargeA;
122     krf              = gmx_fjsp_set1_v2r8(fr->ic->k_rf);
123     krf2             = gmx_fjsp_set1_v2r8(fr->ic->k_rf*2.0);
124     crf              = gmx_fjsp_set1_v2r8(fr->ic->c_rf);
125     nvdwtype         = fr->ntype;
126     vdwparam         = fr->nbfp;
127     vdwtype          = mdatoms->typeA;
128
129     /* Setup water-specific parameters */
130     inr              = nlist->iinr[0];
131     iq1              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+1]));
132     iq2              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+2]));
133     iq3              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+3]));
134     vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
135
136     /* Avoid stupid compiler warnings */
137     jnrA = jnrB = 0;
138     j_coord_offsetA = 0;
139     j_coord_offsetB = 0;
140
141     outeriter        = 0;
142     inneriter        = 0;
143
144     /* Start outer loop over neighborlists */
145     for(iidx=0; iidx<nri; iidx++)
146     {
147         /* Load shift vector for this list */
148         i_shift_offset   = DIM*shiftidx[iidx];
149
150         /* Load limits for loop over neighbors */
151         j_index_start    = jindex[iidx];
152         j_index_end      = jindex[iidx+1];
153
154         /* Get outer coordinate index */
155         inr              = iinr[iidx];
156         i_coord_offset   = DIM*inr;
157
158         /* Load i particle coords and add shift vector */
159         gmx_fjsp_load_shift_and_4rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,
160                                                  &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
161
162         fix0             = _fjsp_setzero_v2r8();
163         fiy0             = _fjsp_setzero_v2r8();
164         fiz0             = _fjsp_setzero_v2r8();
165         fix1             = _fjsp_setzero_v2r8();
166         fiy1             = _fjsp_setzero_v2r8();
167         fiz1             = _fjsp_setzero_v2r8();
168         fix2             = _fjsp_setzero_v2r8();
169         fiy2             = _fjsp_setzero_v2r8();
170         fiz2             = _fjsp_setzero_v2r8();
171         fix3             = _fjsp_setzero_v2r8();
172         fiy3             = _fjsp_setzero_v2r8();
173         fiz3             = _fjsp_setzero_v2r8();
174
175         /* Reset potential sums */
176         velecsum         = _fjsp_setzero_v2r8();
177         vvdwsum          = _fjsp_setzero_v2r8();
178
179         /* Start inner kernel loop */
180         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
181         {
182
183             /* Get j neighbor index, and coordinate index */
184             jnrA             = jjnr[jidx];
185             jnrB             = jjnr[jidx+1];
186             j_coord_offsetA  = DIM*jnrA;
187             j_coord_offsetB  = DIM*jnrB;
188
189             /* load j atom coordinates */
190             gmx_fjsp_load_1rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
191                                               &jx0,&jy0,&jz0);
192
193             /* Calculate displacement vector */
194             dx00             = _fjsp_sub_v2r8(ix0,jx0);
195             dy00             = _fjsp_sub_v2r8(iy0,jy0);
196             dz00             = _fjsp_sub_v2r8(iz0,jz0);
197             dx10             = _fjsp_sub_v2r8(ix1,jx0);
198             dy10             = _fjsp_sub_v2r8(iy1,jy0);
199             dz10             = _fjsp_sub_v2r8(iz1,jz0);
200             dx20             = _fjsp_sub_v2r8(ix2,jx0);
201             dy20             = _fjsp_sub_v2r8(iy2,jy0);
202             dz20             = _fjsp_sub_v2r8(iz2,jz0);
203             dx30             = _fjsp_sub_v2r8(ix3,jx0);
204             dy30             = _fjsp_sub_v2r8(iy3,jy0);
205             dz30             = _fjsp_sub_v2r8(iz3,jz0);
206
207             /* Calculate squared distance and things based on it */
208             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
209             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
210             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
211             rsq30            = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
212
213             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
214             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
215             rinv30           = gmx_fjsp_invsqrt_v2r8(rsq30);
216
217             rinvsq00         = gmx_fjsp_inv_v2r8(rsq00);
218             rinvsq10         = _fjsp_mul_v2r8(rinv10,rinv10);
219             rinvsq20         = _fjsp_mul_v2r8(rinv20,rinv20);
220             rinvsq30         = _fjsp_mul_v2r8(rinv30,rinv30);
221
222             /* Load parameters for j particles */
223             jq0              = gmx_fjsp_load_2real_swizzle_v2r8(charge+jnrA+0,charge+jnrB+0);
224             vdwjidx0A        = 2*vdwtype[jnrA+0];
225             vdwjidx0B        = 2*vdwtype[jnrB+0];
226
227             fjx0             = _fjsp_setzero_v2r8();
228             fjy0             = _fjsp_setzero_v2r8();
229             fjz0             = _fjsp_setzero_v2r8();
230
231             /**************************
232              * CALCULATE INTERACTIONS *
233              **************************/
234
235             /* Compute parameters for interactions between i and j atoms */
236             gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
237                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
238
239             /* LENNARD-JONES DISPERSION/REPULSION */
240
241             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
242             vvdw6            = _fjsp_mul_v2r8(c6_00,rinvsix);
243             vvdw12           = _fjsp_mul_v2r8(c12_00,_fjsp_mul_v2r8(rinvsix,rinvsix));
244             vvdw             = _fjsp_msub_v2r8( vvdw12,one_twelfth, _fjsp_mul_v2r8(vvdw6,one_sixth) );
245             fvdw             = _fjsp_mul_v2r8(_fjsp_sub_v2r8(vvdw12,vvdw6),rinvsq00);
246
247             /* Update potential sum for this i atom from the interaction with this j atom. */
248             vvdwsum          = _fjsp_add_v2r8(vvdwsum,vvdw);
249
250             fscal            = fvdw;
251
252             /* Update vectorial force */
253             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
254             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
255             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
256             
257             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
258             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
259             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
260
261             /**************************
262              * CALCULATE INTERACTIONS *
263              **************************/
264
265             /* Compute parameters for interactions between i and j atoms */
266             qq10             = _fjsp_mul_v2r8(iq1,jq0);
267
268             /* REACTION-FIELD ELECTROSTATICS */
269             velec            = _fjsp_mul_v2r8(qq10,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq10,rinv10),crf));
270             felec            = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
271
272             /* Update potential sum for this i atom from the interaction with this j atom. */
273             velecsum         = _fjsp_add_v2r8(velecsum,velec);
274
275             fscal            = felec;
276
277             /* Update vectorial force */
278             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
279             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
280             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
281             
282             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
283             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
284             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
285
286             /**************************
287              * CALCULATE INTERACTIONS *
288              **************************/
289
290             /* Compute parameters for interactions between i and j atoms */
291             qq20             = _fjsp_mul_v2r8(iq2,jq0);
292
293             /* REACTION-FIELD ELECTROSTATICS */
294             velec            = _fjsp_mul_v2r8(qq20,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq20,rinv20),crf));
295             felec            = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
296
297             /* Update potential sum for this i atom from the interaction with this j atom. */
298             velecsum         = _fjsp_add_v2r8(velecsum,velec);
299
300             fscal            = felec;
301
302             /* Update vectorial force */
303             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
304             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
305             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
306             
307             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
308             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
309             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
310
311             /**************************
312              * CALCULATE INTERACTIONS *
313              **************************/
314
315             /* Compute parameters for interactions between i and j atoms */
316             qq30             = _fjsp_mul_v2r8(iq3,jq0);
317
318             /* REACTION-FIELD ELECTROSTATICS */
319             velec            = _fjsp_mul_v2r8(qq30,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq30,rinv30),crf));
320             felec            = _fjsp_mul_v2r8(qq30,_fjsp_msub_v2r8(rinv30,rinvsq30,krf2));
321
322             /* Update potential sum for this i atom from the interaction with this j atom. */
323             velecsum         = _fjsp_add_v2r8(velecsum,velec);
324
325             fscal            = felec;
326
327             /* Update vectorial force */
328             fix3             = _fjsp_madd_v2r8(dx30,fscal,fix3);
329             fiy3             = _fjsp_madd_v2r8(dy30,fscal,fiy3);
330             fiz3             = _fjsp_madd_v2r8(dz30,fscal,fiz3);
331             
332             fjx0             = _fjsp_madd_v2r8(dx30,fscal,fjx0);
333             fjy0             = _fjsp_madd_v2r8(dy30,fscal,fjy0);
334             fjz0             = _fjsp_madd_v2r8(dz30,fscal,fjz0);
335
336             gmx_fjsp_decrement_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
337
338             /* Inner loop uses 143 flops */
339         }
340
341         if(jidx<j_index_end)
342         {
343
344             jnrA             = jjnr[jidx];
345             j_coord_offsetA  = DIM*jnrA;
346
347             /* load j atom coordinates */
348             gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
349                                               &jx0,&jy0,&jz0);
350
351             /* Calculate displacement vector */
352             dx00             = _fjsp_sub_v2r8(ix0,jx0);
353             dy00             = _fjsp_sub_v2r8(iy0,jy0);
354             dz00             = _fjsp_sub_v2r8(iz0,jz0);
355             dx10             = _fjsp_sub_v2r8(ix1,jx0);
356             dy10             = _fjsp_sub_v2r8(iy1,jy0);
357             dz10             = _fjsp_sub_v2r8(iz1,jz0);
358             dx20             = _fjsp_sub_v2r8(ix2,jx0);
359             dy20             = _fjsp_sub_v2r8(iy2,jy0);
360             dz20             = _fjsp_sub_v2r8(iz2,jz0);
361             dx30             = _fjsp_sub_v2r8(ix3,jx0);
362             dy30             = _fjsp_sub_v2r8(iy3,jy0);
363             dz30             = _fjsp_sub_v2r8(iz3,jz0);
364
365             /* Calculate squared distance and things based on it */
366             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
367             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
368             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
369             rsq30            = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
370
371             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
372             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
373             rinv30           = gmx_fjsp_invsqrt_v2r8(rsq30);
374
375             rinvsq00         = gmx_fjsp_inv_v2r8(rsq00);
376             rinvsq10         = _fjsp_mul_v2r8(rinv10,rinv10);
377             rinvsq20         = _fjsp_mul_v2r8(rinv20,rinv20);
378             rinvsq30         = _fjsp_mul_v2r8(rinv30,rinv30);
379
380             /* Load parameters for j particles */
381             jq0              = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
382             vdwjidx0A        = 2*vdwtype[jnrA+0];
383
384             fjx0             = _fjsp_setzero_v2r8();
385             fjy0             = _fjsp_setzero_v2r8();
386             fjz0             = _fjsp_setzero_v2r8();
387
388             /**************************
389              * CALCULATE INTERACTIONS *
390              **************************/
391
392             /* Compute parameters for interactions between i and j atoms */
393             gmx_fjsp_load_1pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
394
395             /* LENNARD-JONES DISPERSION/REPULSION */
396
397             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
398             vvdw6            = _fjsp_mul_v2r8(c6_00,rinvsix);
399             vvdw12           = _fjsp_mul_v2r8(c12_00,_fjsp_mul_v2r8(rinvsix,rinvsix));
400             vvdw             = _fjsp_msub_v2r8( vvdw12,one_twelfth, _fjsp_mul_v2r8(vvdw6,one_sixth) );
401             fvdw             = _fjsp_mul_v2r8(_fjsp_sub_v2r8(vvdw12,vvdw6),rinvsq00);
402
403             /* Update potential sum for this i atom from the interaction with this j atom. */
404             vvdw             = _fjsp_unpacklo_v2r8(vvdw,_fjsp_setzero_v2r8());
405             vvdwsum          = _fjsp_add_v2r8(vvdwsum,vvdw);
406
407             fscal            = fvdw;
408
409             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
410
411             /* Update vectorial force */
412             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
413             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
414             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
415             
416             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
417             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
418             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
419
420             /**************************
421              * CALCULATE INTERACTIONS *
422              **************************/
423
424             /* Compute parameters for interactions between i and j atoms */
425             qq10             = _fjsp_mul_v2r8(iq1,jq0);
426
427             /* REACTION-FIELD ELECTROSTATICS */
428             velec            = _fjsp_mul_v2r8(qq10,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq10,rinv10),crf));
429             felec            = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
430
431             /* Update potential sum for this i atom from the interaction with this j atom. */
432             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
433             velecsum         = _fjsp_add_v2r8(velecsum,velec);
434
435             fscal            = felec;
436
437             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
438
439             /* Update vectorial force */
440             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
441             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
442             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
443             
444             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
445             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
446             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
447
448             /**************************
449              * CALCULATE INTERACTIONS *
450              **************************/
451
452             /* Compute parameters for interactions between i and j atoms */
453             qq20             = _fjsp_mul_v2r8(iq2,jq0);
454
455             /* REACTION-FIELD ELECTROSTATICS */
456             velec            = _fjsp_mul_v2r8(qq20,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq20,rinv20),crf));
457             felec            = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
458
459             /* Update potential sum for this i atom from the interaction with this j atom. */
460             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
461             velecsum         = _fjsp_add_v2r8(velecsum,velec);
462
463             fscal            = felec;
464
465             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
466
467             /* Update vectorial force */
468             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
469             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
470             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
471             
472             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
473             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
474             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
475
476             /**************************
477              * CALCULATE INTERACTIONS *
478              **************************/
479
480             /* Compute parameters for interactions between i and j atoms */
481             qq30             = _fjsp_mul_v2r8(iq3,jq0);
482
483             /* REACTION-FIELD ELECTROSTATICS */
484             velec            = _fjsp_mul_v2r8(qq30,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq30,rinv30),crf));
485             felec            = _fjsp_mul_v2r8(qq30,_fjsp_msub_v2r8(rinv30,rinvsq30,krf2));
486
487             /* Update potential sum for this i atom from the interaction with this j atom. */
488             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
489             velecsum         = _fjsp_add_v2r8(velecsum,velec);
490
491             fscal            = felec;
492
493             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
494
495             /* Update vectorial force */
496             fix3             = _fjsp_madd_v2r8(dx30,fscal,fix3);
497             fiy3             = _fjsp_madd_v2r8(dy30,fscal,fiy3);
498             fiz3             = _fjsp_madd_v2r8(dz30,fscal,fiz3);
499             
500             fjx0             = _fjsp_madd_v2r8(dx30,fscal,fjx0);
501             fjy0             = _fjsp_madd_v2r8(dy30,fscal,fjy0);
502             fjz0             = _fjsp_madd_v2r8(dz30,fscal,fjz0);
503
504             gmx_fjsp_decrement_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fjx0,fjy0,fjz0);
505
506             /* Inner loop uses 143 flops */
507         }
508
509         /* End of innermost loop */
510
511         gmx_fjsp_update_iforce_4atom_swizzle_v2r8(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
512                                               f+i_coord_offset,fshift+i_shift_offset);
513
514         ggid                        = gid[iidx];
515         /* Update potential energies */
516         gmx_fjsp_update_1pot_v2r8(velecsum,kernel_data->energygrp_elec+ggid);
517         gmx_fjsp_update_1pot_v2r8(vvdwsum,kernel_data->energygrp_vdw+ggid);
518
519         /* Increment number of inner iterations */
520         inneriter                  += j_index_end - j_index_start;
521
522         /* Outer loop uses 26 flops */
523     }
524
525     /* Increment number of outer iterations */
526     outeriter        += nri;
527
528     /* Update outer/inner flops */
529
530     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*26 + inneriter*143);
531 }
532 /*
533  * Gromacs nonbonded kernel:   nb_kernel_ElecRF_VdwLJ_GeomW4P1_F_sparc64_hpc_ace_double
534  * Electrostatics interaction: ReactionField
535  * VdW interaction:            LennardJones
536  * Geometry:                   Water4-Particle
537  * Calculate force/pot:        Force
538  */
539 void
540 nb_kernel_ElecRF_VdwLJ_GeomW4P1_F_sparc64_hpc_ace_double
541                     (t_nblist                    * gmx_restrict       nlist,
542                      rvec                        * gmx_restrict          xx,
543                      rvec                        * gmx_restrict          ff,
544                      t_forcerec                  * gmx_restrict          fr,
545                      t_mdatoms                   * gmx_restrict     mdatoms,
546                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
547                      t_nrnb                      * gmx_restrict        nrnb)
548 {
549     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
550      * just 0 for non-waters.
551      * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
552      * jnr indices corresponding to data put in the four positions in the SIMD register.
553      */
554     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
555     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
556     int              jnrA,jnrB;
557     int              j_coord_offsetA,j_coord_offsetB;
558     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
559     real             rcutoff_scalar;
560     real             *shiftvec,*fshift,*x,*f;
561     _fjsp_v2r8       tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
562     int              vdwioffset0;
563     _fjsp_v2r8       ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
564     int              vdwioffset1;
565     _fjsp_v2r8       ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
566     int              vdwioffset2;
567     _fjsp_v2r8       ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
568     int              vdwioffset3;
569     _fjsp_v2r8       ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
570     int              vdwjidx0A,vdwjidx0B;
571     _fjsp_v2r8       jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
572     _fjsp_v2r8       dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
573     _fjsp_v2r8       dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
574     _fjsp_v2r8       dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
575     _fjsp_v2r8       dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
576     _fjsp_v2r8       velec,felec,velecsum,facel,crf,krf,krf2;
577     real             *charge;
578     int              nvdwtype;
579     _fjsp_v2r8       rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
580     int              *vdwtype;
581     real             *vdwparam;
582     _fjsp_v2r8       one_sixth   = gmx_fjsp_set1_v2r8(1.0/6.0);
583     _fjsp_v2r8       one_twelfth = gmx_fjsp_set1_v2r8(1.0/12.0);
584     _fjsp_v2r8       itab_tmp;
585     _fjsp_v2r8       dummy_mask,cutoff_mask;
586     _fjsp_v2r8       one     = gmx_fjsp_set1_v2r8(1.0);
587     _fjsp_v2r8       two     = gmx_fjsp_set1_v2r8(2.0);
588     union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
589
590     x                = xx[0];
591     f                = ff[0];
592
593     nri              = nlist->nri;
594     iinr             = nlist->iinr;
595     jindex           = nlist->jindex;
596     jjnr             = nlist->jjnr;
597     shiftidx         = nlist->shift;
598     gid              = nlist->gid;
599     shiftvec         = fr->shift_vec[0];
600     fshift           = fr->fshift[0];
601     facel            = gmx_fjsp_set1_v2r8(fr->epsfac);
602     charge           = mdatoms->chargeA;
603     krf              = gmx_fjsp_set1_v2r8(fr->ic->k_rf);
604     krf2             = gmx_fjsp_set1_v2r8(fr->ic->k_rf*2.0);
605     crf              = gmx_fjsp_set1_v2r8(fr->ic->c_rf);
606     nvdwtype         = fr->ntype;
607     vdwparam         = fr->nbfp;
608     vdwtype          = mdatoms->typeA;
609
610     /* Setup water-specific parameters */
611     inr              = nlist->iinr[0];
612     iq1              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+1]));
613     iq2              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+2]));
614     iq3              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+3]));
615     vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
616
617     /* Avoid stupid compiler warnings */
618     jnrA = jnrB = 0;
619     j_coord_offsetA = 0;
620     j_coord_offsetB = 0;
621
622     outeriter        = 0;
623     inneriter        = 0;
624
625     /* Start outer loop over neighborlists */
626     for(iidx=0; iidx<nri; iidx++)
627     {
628         /* Load shift vector for this list */
629         i_shift_offset   = DIM*shiftidx[iidx];
630
631         /* Load limits for loop over neighbors */
632         j_index_start    = jindex[iidx];
633         j_index_end      = jindex[iidx+1];
634
635         /* Get outer coordinate index */
636         inr              = iinr[iidx];
637         i_coord_offset   = DIM*inr;
638
639         /* Load i particle coords and add shift vector */
640         gmx_fjsp_load_shift_and_4rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,
641                                                  &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
642
643         fix0             = _fjsp_setzero_v2r8();
644         fiy0             = _fjsp_setzero_v2r8();
645         fiz0             = _fjsp_setzero_v2r8();
646         fix1             = _fjsp_setzero_v2r8();
647         fiy1             = _fjsp_setzero_v2r8();
648         fiz1             = _fjsp_setzero_v2r8();
649         fix2             = _fjsp_setzero_v2r8();
650         fiy2             = _fjsp_setzero_v2r8();
651         fiz2             = _fjsp_setzero_v2r8();
652         fix3             = _fjsp_setzero_v2r8();
653         fiy3             = _fjsp_setzero_v2r8();
654         fiz3             = _fjsp_setzero_v2r8();
655
656         /* Start inner kernel loop */
657         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
658         {
659
660             /* Get j neighbor index, and coordinate index */
661             jnrA             = jjnr[jidx];
662             jnrB             = jjnr[jidx+1];
663             j_coord_offsetA  = DIM*jnrA;
664             j_coord_offsetB  = DIM*jnrB;
665
666             /* load j atom coordinates */
667             gmx_fjsp_load_1rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
668                                               &jx0,&jy0,&jz0);
669
670             /* Calculate displacement vector */
671             dx00             = _fjsp_sub_v2r8(ix0,jx0);
672             dy00             = _fjsp_sub_v2r8(iy0,jy0);
673             dz00             = _fjsp_sub_v2r8(iz0,jz0);
674             dx10             = _fjsp_sub_v2r8(ix1,jx0);
675             dy10             = _fjsp_sub_v2r8(iy1,jy0);
676             dz10             = _fjsp_sub_v2r8(iz1,jz0);
677             dx20             = _fjsp_sub_v2r8(ix2,jx0);
678             dy20             = _fjsp_sub_v2r8(iy2,jy0);
679             dz20             = _fjsp_sub_v2r8(iz2,jz0);
680             dx30             = _fjsp_sub_v2r8(ix3,jx0);
681             dy30             = _fjsp_sub_v2r8(iy3,jy0);
682             dz30             = _fjsp_sub_v2r8(iz3,jz0);
683
684             /* Calculate squared distance and things based on it */
685             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
686             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
687             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
688             rsq30            = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
689
690             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
691             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
692             rinv30           = gmx_fjsp_invsqrt_v2r8(rsq30);
693
694             rinvsq00         = gmx_fjsp_inv_v2r8(rsq00);
695             rinvsq10         = _fjsp_mul_v2r8(rinv10,rinv10);
696             rinvsq20         = _fjsp_mul_v2r8(rinv20,rinv20);
697             rinvsq30         = _fjsp_mul_v2r8(rinv30,rinv30);
698
699             /* Load parameters for j particles */
700             jq0              = gmx_fjsp_load_2real_swizzle_v2r8(charge+jnrA+0,charge+jnrB+0);
701             vdwjidx0A        = 2*vdwtype[jnrA+0];
702             vdwjidx0B        = 2*vdwtype[jnrB+0];
703
704             fjx0             = _fjsp_setzero_v2r8();
705             fjy0             = _fjsp_setzero_v2r8();
706             fjz0             = _fjsp_setzero_v2r8();
707
708             /**************************
709              * CALCULATE INTERACTIONS *
710              **************************/
711
712             /* Compute parameters for interactions between i and j atoms */
713             gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
714                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
715
716             /* LENNARD-JONES DISPERSION/REPULSION */
717
718             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
719             fvdw             = _fjsp_mul_v2r8(_fjsp_msub_v2r8(c12_00,rinvsix,c6_00),_fjsp_mul_v2r8(rinvsix,rinvsq00));
720
721             fscal            = fvdw;
722
723             /* Update vectorial force */
724             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
725             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
726             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
727             
728             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
729             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
730             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
731
732             /**************************
733              * CALCULATE INTERACTIONS *
734              **************************/
735
736             /* Compute parameters for interactions between i and j atoms */
737             qq10             = _fjsp_mul_v2r8(iq1,jq0);
738
739             /* REACTION-FIELD ELECTROSTATICS */
740             felec            = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
741
742             fscal            = felec;
743
744             /* Update vectorial force */
745             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
746             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
747             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
748             
749             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
750             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
751             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
752
753             /**************************
754              * CALCULATE INTERACTIONS *
755              **************************/
756
757             /* Compute parameters for interactions between i and j atoms */
758             qq20             = _fjsp_mul_v2r8(iq2,jq0);
759
760             /* REACTION-FIELD ELECTROSTATICS */
761             felec            = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
762
763             fscal            = felec;
764
765             /* Update vectorial force */
766             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
767             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
768             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
769             
770             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
771             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
772             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
773
774             /**************************
775              * CALCULATE INTERACTIONS *
776              **************************/
777
778             /* Compute parameters for interactions between i and j atoms */
779             qq30             = _fjsp_mul_v2r8(iq3,jq0);
780
781             /* REACTION-FIELD ELECTROSTATICS */
782             felec            = _fjsp_mul_v2r8(qq30,_fjsp_msub_v2r8(rinv30,rinvsq30,krf2));
783
784             fscal            = felec;
785
786             /* Update vectorial force */
787             fix3             = _fjsp_madd_v2r8(dx30,fscal,fix3);
788             fiy3             = _fjsp_madd_v2r8(dy30,fscal,fiy3);
789             fiz3             = _fjsp_madd_v2r8(dz30,fscal,fiz3);
790             
791             fjx0             = _fjsp_madd_v2r8(dx30,fscal,fjx0);
792             fjy0             = _fjsp_madd_v2r8(dy30,fscal,fjy0);
793             fjz0             = _fjsp_madd_v2r8(dz30,fscal,fjz0);
794
795             gmx_fjsp_decrement_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
796
797             /* Inner loop uses 123 flops */
798         }
799
800         if(jidx<j_index_end)
801         {
802
803             jnrA             = jjnr[jidx];
804             j_coord_offsetA  = DIM*jnrA;
805
806             /* load j atom coordinates */
807             gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
808                                               &jx0,&jy0,&jz0);
809
810             /* Calculate displacement vector */
811             dx00             = _fjsp_sub_v2r8(ix0,jx0);
812             dy00             = _fjsp_sub_v2r8(iy0,jy0);
813             dz00             = _fjsp_sub_v2r8(iz0,jz0);
814             dx10             = _fjsp_sub_v2r8(ix1,jx0);
815             dy10             = _fjsp_sub_v2r8(iy1,jy0);
816             dz10             = _fjsp_sub_v2r8(iz1,jz0);
817             dx20             = _fjsp_sub_v2r8(ix2,jx0);
818             dy20             = _fjsp_sub_v2r8(iy2,jy0);
819             dz20             = _fjsp_sub_v2r8(iz2,jz0);
820             dx30             = _fjsp_sub_v2r8(ix3,jx0);
821             dy30             = _fjsp_sub_v2r8(iy3,jy0);
822             dz30             = _fjsp_sub_v2r8(iz3,jz0);
823
824             /* Calculate squared distance and things based on it */
825             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
826             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
827             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
828             rsq30            = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
829
830             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
831             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
832             rinv30           = gmx_fjsp_invsqrt_v2r8(rsq30);
833
834             rinvsq00         = gmx_fjsp_inv_v2r8(rsq00);
835             rinvsq10         = _fjsp_mul_v2r8(rinv10,rinv10);
836             rinvsq20         = _fjsp_mul_v2r8(rinv20,rinv20);
837             rinvsq30         = _fjsp_mul_v2r8(rinv30,rinv30);
838
839             /* Load parameters for j particles */
840             jq0              = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
841             vdwjidx0A        = 2*vdwtype[jnrA+0];
842
843             fjx0             = _fjsp_setzero_v2r8();
844             fjy0             = _fjsp_setzero_v2r8();
845             fjz0             = _fjsp_setzero_v2r8();
846
847             /**************************
848              * CALCULATE INTERACTIONS *
849              **************************/
850
851             /* Compute parameters for interactions between i and j atoms */
852             gmx_fjsp_load_1pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
853
854             /* LENNARD-JONES DISPERSION/REPULSION */
855
856             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
857             fvdw             = _fjsp_mul_v2r8(_fjsp_msub_v2r8(c12_00,rinvsix,c6_00),_fjsp_mul_v2r8(rinvsix,rinvsq00));
858
859             fscal            = fvdw;
860
861             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
862
863             /* Update vectorial force */
864             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
865             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
866             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
867             
868             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
869             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
870             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
871
872             /**************************
873              * CALCULATE INTERACTIONS *
874              **************************/
875
876             /* Compute parameters for interactions between i and j atoms */
877             qq10             = _fjsp_mul_v2r8(iq1,jq0);
878
879             /* REACTION-FIELD ELECTROSTATICS */
880             felec            = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
881
882             fscal            = felec;
883
884             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
885
886             /* Update vectorial force */
887             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
888             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
889             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
890             
891             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
892             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
893             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
894
895             /**************************
896              * CALCULATE INTERACTIONS *
897              **************************/
898
899             /* Compute parameters for interactions between i and j atoms */
900             qq20             = _fjsp_mul_v2r8(iq2,jq0);
901
902             /* REACTION-FIELD ELECTROSTATICS */
903             felec            = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
904
905             fscal            = felec;
906
907             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
908
909             /* Update vectorial force */
910             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
911             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
912             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
913             
914             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
915             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
916             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
917
918             /**************************
919              * CALCULATE INTERACTIONS *
920              **************************/
921
922             /* Compute parameters for interactions between i and j atoms */
923             qq30             = _fjsp_mul_v2r8(iq3,jq0);
924
925             /* REACTION-FIELD ELECTROSTATICS */
926             felec            = _fjsp_mul_v2r8(qq30,_fjsp_msub_v2r8(rinv30,rinvsq30,krf2));
927
928             fscal            = felec;
929
930             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
931
932             /* Update vectorial force */
933             fix3             = _fjsp_madd_v2r8(dx30,fscal,fix3);
934             fiy3             = _fjsp_madd_v2r8(dy30,fscal,fiy3);
935             fiz3             = _fjsp_madd_v2r8(dz30,fscal,fiz3);
936             
937             fjx0             = _fjsp_madd_v2r8(dx30,fscal,fjx0);
938             fjy0             = _fjsp_madd_v2r8(dy30,fscal,fjy0);
939             fjz0             = _fjsp_madd_v2r8(dz30,fscal,fjz0);
940
941             gmx_fjsp_decrement_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fjx0,fjy0,fjz0);
942
943             /* Inner loop uses 123 flops */
944         }
945
946         /* End of innermost loop */
947
948         gmx_fjsp_update_iforce_4atom_swizzle_v2r8(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
949                                               f+i_coord_offset,fshift+i_shift_offset);
950
951         /* Increment number of inner iterations */
952         inneriter                  += j_index_end - j_index_start;
953
954         /* Outer loop uses 24 flops */
955     }
956
957     /* Increment number of outer iterations */
958     outeriter        += nri;
959
960     /* Update outer/inner flops */
961
962     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*24 + inneriter*123);
963 }