K-computer specific modifications
[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 #ifdef HAVE_CONFIG_H
39 #include <config.h>
40 #endif
41
42 #include <math.h>
43
44 #include "../nb_kernel.h"
45 #include "types/simple.h"
46 #include "gromacs/legacyheaders/vec.h"
47 #include "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_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
394                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
395
396             /* LENNARD-JONES DISPERSION/REPULSION */
397
398             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
399             vvdw6            = _fjsp_mul_v2r8(c6_00,rinvsix);
400             vvdw12           = _fjsp_mul_v2r8(c12_00,_fjsp_mul_v2r8(rinvsix,rinvsix));
401             vvdw             = _fjsp_msub_v2r8( vvdw12,one_twelfth, _fjsp_mul_v2r8(vvdw6,one_sixth) );
402             fvdw             = _fjsp_mul_v2r8(_fjsp_sub_v2r8(vvdw12,vvdw6),rinvsq00);
403
404             /* Update potential sum for this i atom from the interaction with this j atom. */
405             vvdw             = _fjsp_unpacklo_v2r8(vvdw,_fjsp_setzero_v2r8());
406             vvdwsum          = _fjsp_add_v2r8(vvdwsum,vvdw);
407
408             fscal            = fvdw;
409
410             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
411
412             /* Update vectorial force */
413             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
414             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
415             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
416             
417             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
418             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
419             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
420
421             /**************************
422              * CALCULATE INTERACTIONS *
423              **************************/
424
425             /* Compute parameters for interactions between i and j atoms */
426             qq10             = _fjsp_mul_v2r8(iq1,jq0);
427
428             /* REACTION-FIELD ELECTROSTATICS */
429             velec            = _fjsp_mul_v2r8(qq10,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq10,rinv10),crf));
430             felec            = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
431
432             /* Update potential sum for this i atom from the interaction with this j atom. */
433             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
434             velecsum         = _fjsp_add_v2r8(velecsum,velec);
435
436             fscal            = felec;
437
438             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
439
440             /* Update vectorial force */
441             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
442             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
443             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
444             
445             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
446             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
447             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
448
449             /**************************
450              * CALCULATE INTERACTIONS *
451              **************************/
452
453             /* Compute parameters for interactions between i and j atoms */
454             qq20             = _fjsp_mul_v2r8(iq2,jq0);
455
456             /* REACTION-FIELD ELECTROSTATICS */
457             velec            = _fjsp_mul_v2r8(qq20,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq20,rinv20),crf));
458             felec            = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
459
460             /* Update potential sum for this i atom from the interaction with this j atom. */
461             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
462             velecsum         = _fjsp_add_v2r8(velecsum,velec);
463
464             fscal            = felec;
465
466             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
467
468             /* Update vectorial force */
469             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
470             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
471             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
472             
473             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
474             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
475             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
476
477             /**************************
478              * CALCULATE INTERACTIONS *
479              **************************/
480
481             /* Compute parameters for interactions between i and j atoms */
482             qq30             = _fjsp_mul_v2r8(iq3,jq0);
483
484             /* REACTION-FIELD ELECTROSTATICS */
485             velec            = _fjsp_mul_v2r8(qq30,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq30,rinv30),crf));
486             felec            = _fjsp_mul_v2r8(qq30,_fjsp_msub_v2r8(rinv30,rinvsq30,krf2));
487
488             /* Update potential sum for this i atom from the interaction with this j atom. */
489             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
490             velecsum         = _fjsp_add_v2r8(velecsum,velec);
491
492             fscal            = felec;
493
494             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
495
496             /* Update vectorial force */
497             fix3             = _fjsp_madd_v2r8(dx30,fscal,fix3);
498             fiy3             = _fjsp_madd_v2r8(dy30,fscal,fiy3);
499             fiz3             = _fjsp_madd_v2r8(dz30,fscal,fiz3);
500             
501             fjx0             = _fjsp_madd_v2r8(dx30,fscal,fjx0);
502             fjy0             = _fjsp_madd_v2r8(dy30,fscal,fjy0);
503             fjz0             = _fjsp_madd_v2r8(dz30,fscal,fjz0);
504
505             gmx_fjsp_decrement_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fjx0,fjy0,fjz0);
506
507             /* Inner loop uses 143 flops */
508         }
509
510         /* End of innermost loop */
511
512         gmx_fjsp_update_iforce_4atom_swizzle_v2r8(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
513                                               f+i_coord_offset,fshift+i_shift_offset);
514
515         ggid                        = gid[iidx];
516         /* Update potential energies */
517         gmx_fjsp_update_1pot_v2r8(velecsum,kernel_data->energygrp_elec+ggid);
518         gmx_fjsp_update_1pot_v2r8(vvdwsum,kernel_data->energygrp_vdw+ggid);
519
520         /* Increment number of inner iterations */
521         inneriter                  += j_index_end - j_index_start;
522
523         /* Outer loop uses 26 flops */
524     }
525
526     /* Increment number of outer iterations */
527     outeriter        += nri;
528
529     /* Update outer/inner flops */
530
531     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*26 + inneriter*143);
532 }
533 /*
534  * Gromacs nonbonded kernel:   nb_kernel_ElecRF_VdwLJ_GeomW4P1_F_sparc64_hpc_ace_double
535  * Electrostatics interaction: ReactionField
536  * VdW interaction:            LennardJones
537  * Geometry:                   Water4-Particle
538  * Calculate force/pot:        Force
539  */
540 void
541 nb_kernel_ElecRF_VdwLJ_GeomW4P1_F_sparc64_hpc_ace_double
542                     (t_nblist                    * gmx_restrict       nlist,
543                      rvec                        * gmx_restrict          xx,
544                      rvec                        * gmx_restrict          ff,
545                      t_forcerec                  * gmx_restrict          fr,
546                      t_mdatoms                   * gmx_restrict     mdatoms,
547                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
548                      t_nrnb                      * gmx_restrict        nrnb)
549 {
550     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
551      * just 0 for non-waters.
552      * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
553      * jnr indices corresponding to data put in the four positions in the SIMD register.
554      */
555     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
556     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
557     int              jnrA,jnrB;
558     int              j_coord_offsetA,j_coord_offsetB;
559     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
560     real             rcutoff_scalar;
561     real             *shiftvec,*fshift,*x,*f;
562     _fjsp_v2r8       tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
563     int              vdwioffset0;
564     _fjsp_v2r8       ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
565     int              vdwioffset1;
566     _fjsp_v2r8       ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
567     int              vdwioffset2;
568     _fjsp_v2r8       ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
569     int              vdwioffset3;
570     _fjsp_v2r8       ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
571     int              vdwjidx0A,vdwjidx0B;
572     _fjsp_v2r8       jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
573     _fjsp_v2r8       dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
574     _fjsp_v2r8       dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
575     _fjsp_v2r8       dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
576     _fjsp_v2r8       dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
577     _fjsp_v2r8       velec,felec,velecsum,facel,crf,krf,krf2;
578     real             *charge;
579     int              nvdwtype;
580     _fjsp_v2r8       rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
581     int              *vdwtype;
582     real             *vdwparam;
583     _fjsp_v2r8       one_sixth   = gmx_fjsp_set1_v2r8(1.0/6.0);
584     _fjsp_v2r8       one_twelfth = gmx_fjsp_set1_v2r8(1.0/12.0);
585     _fjsp_v2r8       itab_tmp;
586     _fjsp_v2r8       dummy_mask,cutoff_mask;
587     _fjsp_v2r8       one     = gmx_fjsp_set1_v2r8(1.0);
588     _fjsp_v2r8       two     = gmx_fjsp_set1_v2r8(2.0);
589     union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
590
591     x                = xx[0];
592     f                = ff[0];
593
594     nri              = nlist->nri;
595     iinr             = nlist->iinr;
596     jindex           = nlist->jindex;
597     jjnr             = nlist->jjnr;
598     shiftidx         = nlist->shift;
599     gid              = nlist->gid;
600     shiftvec         = fr->shift_vec[0];
601     fshift           = fr->fshift[0];
602     facel            = gmx_fjsp_set1_v2r8(fr->epsfac);
603     charge           = mdatoms->chargeA;
604     krf              = gmx_fjsp_set1_v2r8(fr->ic->k_rf);
605     krf2             = gmx_fjsp_set1_v2r8(fr->ic->k_rf*2.0);
606     crf              = gmx_fjsp_set1_v2r8(fr->ic->c_rf);
607     nvdwtype         = fr->ntype;
608     vdwparam         = fr->nbfp;
609     vdwtype          = mdatoms->typeA;
610
611     /* Setup water-specific parameters */
612     inr              = nlist->iinr[0];
613     iq1              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+1]));
614     iq2              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+2]));
615     iq3              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+3]));
616     vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
617
618     /* Avoid stupid compiler warnings */
619     jnrA = jnrB = 0;
620     j_coord_offsetA = 0;
621     j_coord_offsetB = 0;
622
623     outeriter        = 0;
624     inneriter        = 0;
625
626     /* Start outer loop over neighborlists */
627     for(iidx=0; iidx<nri; iidx++)
628     {
629         /* Load shift vector for this list */
630         i_shift_offset   = DIM*shiftidx[iidx];
631
632         /* Load limits for loop over neighbors */
633         j_index_start    = jindex[iidx];
634         j_index_end      = jindex[iidx+1];
635
636         /* Get outer coordinate index */
637         inr              = iinr[iidx];
638         i_coord_offset   = DIM*inr;
639
640         /* Load i particle coords and add shift vector */
641         gmx_fjsp_load_shift_and_4rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,
642                                                  &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
643
644         fix0             = _fjsp_setzero_v2r8();
645         fiy0             = _fjsp_setzero_v2r8();
646         fiz0             = _fjsp_setzero_v2r8();
647         fix1             = _fjsp_setzero_v2r8();
648         fiy1             = _fjsp_setzero_v2r8();
649         fiz1             = _fjsp_setzero_v2r8();
650         fix2             = _fjsp_setzero_v2r8();
651         fiy2             = _fjsp_setzero_v2r8();
652         fiz2             = _fjsp_setzero_v2r8();
653         fix3             = _fjsp_setzero_v2r8();
654         fiy3             = _fjsp_setzero_v2r8();
655         fiz3             = _fjsp_setzero_v2r8();
656
657         /* Start inner kernel loop */
658         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
659         {
660
661             /* Get j neighbor index, and coordinate index */
662             jnrA             = jjnr[jidx];
663             jnrB             = jjnr[jidx+1];
664             j_coord_offsetA  = DIM*jnrA;
665             j_coord_offsetB  = DIM*jnrB;
666
667             /* load j atom coordinates */
668             gmx_fjsp_load_1rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
669                                               &jx0,&jy0,&jz0);
670
671             /* Calculate displacement vector */
672             dx00             = _fjsp_sub_v2r8(ix0,jx0);
673             dy00             = _fjsp_sub_v2r8(iy0,jy0);
674             dz00             = _fjsp_sub_v2r8(iz0,jz0);
675             dx10             = _fjsp_sub_v2r8(ix1,jx0);
676             dy10             = _fjsp_sub_v2r8(iy1,jy0);
677             dz10             = _fjsp_sub_v2r8(iz1,jz0);
678             dx20             = _fjsp_sub_v2r8(ix2,jx0);
679             dy20             = _fjsp_sub_v2r8(iy2,jy0);
680             dz20             = _fjsp_sub_v2r8(iz2,jz0);
681             dx30             = _fjsp_sub_v2r8(ix3,jx0);
682             dy30             = _fjsp_sub_v2r8(iy3,jy0);
683             dz30             = _fjsp_sub_v2r8(iz3,jz0);
684
685             /* Calculate squared distance and things based on it */
686             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
687             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
688             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
689             rsq30            = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
690
691             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
692             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
693             rinv30           = gmx_fjsp_invsqrt_v2r8(rsq30);
694
695             rinvsq00         = gmx_fjsp_inv_v2r8(rsq00);
696             rinvsq10         = _fjsp_mul_v2r8(rinv10,rinv10);
697             rinvsq20         = _fjsp_mul_v2r8(rinv20,rinv20);
698             rinvsq30         = _fjsp_mul_v2r8(rinv30,rinv30);
699
700             /* Load parameters for j particles */
701             jq0              = gmx_fjsp_load_2real_swizzle_v2r8(charge+jnrA+0,charge+jnrB+0);
702             vdwjidx0A        = 2*vdwtype[jnrA+0];
703             vdwjidx0B        = 2*vdwtype[jnrB+0];
704
705             fjx0             = _fjsp_setzero_v2r8();
706             fjy0             = _fjsp_setzero_v2r8();
707             fjz0             = _fjsp_setzero_v2r8();
708
709             /**************************
710              * CALCULATE INTERACTIONS *
711              **************************/
712
713             /* Compute parameters for interactions between i and j atoms */
714             gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
715                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
716
717             /* LENNARD-JONES DISPERSION/REPULSION */
718
719             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
720             fvdw             = _fjsp_mul_v2r8(_fjsp_msub_v2r8(c12_00,rinvsix,c6_00),_fjsp_mul_v2r8(rinvsix,rinvsq00));
721
722             fscal            = fvdw;
723
724             /* Update vectorial force */
725             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
726             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
727             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
728             
729             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
730             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
731             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
732
733             /**************************
734              * CALCULATE INTERACTIONS *
735              **************************/
736
737             /* Compute parameters for interactions between i and j atoms */
738             qq10             = _fjsp_mul_v2r8(iq1,jq0);
739
740             /* REACTION-FIELD ELECTROSTATICS */
741             felec            = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
742
743             fscal            = felec;
744
745             /* Update vectorial force */
746             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
747             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
748             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
749             
750             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
751             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
752             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
753
754             /**************************
755              * CALCULATE INTERACTIONS *
756              **************************/
757
758             /* Compute parameters for interactions between i and j atoms */
759             qq20             = _fjsp_mul_v2r8(iq2,jq0);
760
761             /* REACTION-FIELD ELECTROSTATICS */
762             felec            = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
763
764             fscal            = felec;
765
766             /* Update vectorial force */
767             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
768             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
769             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
770             
771             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
772             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
773             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
774
775             /**************************
776              * CALCULATE INTERACTIONS *
777              **************************/
778
779             /* Compute parameters for interactions between i and j atoms */
780             qq30             = _fjsp_mul_v2r8(iq3,jq0);
781
782             /* REACTION-FIELD ELECTROSTATICS */
783             felec            = _fjsp_mul_v2r8(qq30,_fjsp_msub_v2r8(rinv30,rinvsq30,krf2));
784
785             fscal            = felec;
786
787             /* Update vectorial force */
788             fix3             = _fjsp_madd_v2r8(dx30,fscal,fix3);
789             fiy3             = _fjsp_madd_v2r8(dy30,fscal,fiy3);
790             fiz3             = _fjsp_madd_v2r8(dz30,fscal,fiz3);
791             
792             fjx0             = _fjsp_madd_v2r8(dx30,fscal,fjx0);
793             fjy0             = _fjsp_madd_v2r8(dy30,fscal,fjy0);
794             fjz0             = _fjsp_madd_v2r8(dz30,fscal,fjz0);
795
796             gmx_fjsp_decrement_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
797
798             /* Inner loop uses 123 flops */
799         }
800
801         if(jidx<j_index_end)
802         {
803
804             jnrA             = jjnr[jidx];
805             j_coord_offsetA  = DIM*jnrA;
806
807             /* load j atom coordinates */
808             gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
809                                               &jx0,&jy0,&jz0);
810
811             /* Calculate displacement vector */
812             dx00             = _fjsp_sub_v2r8(ix0,jx0);
813             dy00             = _fjsp_sub_v2r8(iy0,jy0);
814             dz00             = _fjsp_sub_v2r8(iz0,jz0);
815             dx10             = _fjsp_sub_v2r8(ix1,jx0);
816             dy10             = _fjsp_sub_v2r8(iy1,jy0);
817             dz10             = _fjsp_sub_v2r8(iz1,jz0);
818             dx20             = _fjsp_sub_v2r8(ix2,jx0);
819             dy20             = _fjsp_sub_v2r8(iy2,jy0);
820             dz20             = _fjsp_sub_v2r8(iz2,jz0);
821             dx30             = _fjsp_sub_v2r8(ix3,jx0);
822             dy30             = _fjsp_sub_v2r8(iy3,jy0);
823             dz30             = _fjsp_sub_v2r8(iz3,jz0);
824
825             /* Calculate squared distance and things based on it */
826             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
827             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
828             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
829             rsq30            = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
830
831             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
832             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
833             rinv30           = gmx_fjsp_invsqrt_v2r8(rsq30);
834
835             rinvsq00         = gmx_fjsp_inv_v2r8(rsq00);
836             rinvsq10         = _fjsp_mul_v2r8(rinv10,rinv10);
837             rinvsq20         = _fjsp_mul_v2r8(rinv20,rinv20);
838             rinvsq30         = _fjsp_mul_v2r8(rinv30,rinv30);
839
840             /* Load parameters for j particles */
841             jq0              = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
842             vdwjidx0A        = 2*vdwtype[jnrA+0];
843
844             fjx0             = _fjsp_setzero_v2r8();
845             fjy0             = _fjsp_setzero_v2r8();
846             fjz0             = _fjsp_setzero_v2r8();
847
848             /**************************
849              * CALCULATE INTERACTIONS *
850              **************************/
851
852             /* Compute parameters for interactions between i and j atoms */
853             gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
854                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
855
856             /* LENNARD-JONES DISPERSION/REPULSION */
857
858             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
859             fvdw             = _fjsp_mul_v2r8(_fjsp_msub_v2r8(c12_00,rinvsix,c6_00),_fjsp_mul_v2r8(rinvsix,rinvsq00));
860
861             fscal            = fvdw;
862
863             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
864
865             /* Update vectorial force */
866             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
867             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
868             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
869             
870             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
871             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
872             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
873
874             /**************************
875              * CALCULATE INTERACTIONS *
876              **************************/
877
878             /* Compute parameters for interactions between i and j atoms */
879             qq10             = _fjsp_mul_v2r8(iq1,jq0);
880
881             /* REACTION-FIELD ELECTROSTATICS */
882             felec            = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
883
884             fscal            = felec;
885
886             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
887
888             /* Update vectorial force */
889             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
890             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
891             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
892             
893             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
894             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
895             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
896
897             /**************************
898              * CALCULATE INTERACTIONS *
899              **************************/
900
901             /* Compute parameters for interactions between i and j atoms */
902             qq20             = _fjsp_mul_v2r8(iq2,jq0);
903
904             /* REACTION-FIELD ELECTROSTATICS */
905             felec            = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
906
907             fscal            = felec;
908
909             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
910
911             /* Update vectorial force */
912             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
913             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
914             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
915             
916             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
917             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
918             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
919
920             /**************************
921              * CALCULATE INTERACTIONS *
922              **************************/
923
924             /* Compute parameters for interactions between i and j atoms */
925             qq30             = _fjsp_mul_v2r8(iq3,jq0);
926
927             /* REACTION-FIELD ELECTROSTATICS */
928             felec            = _fjsp_mul_v2r8(qq30,_fjsp_msub_v2r8(rinv30,rinvsq30,krf2));
929
930             fscal            = felec;
931
932             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
933
934             /* Update vectorial force */
935             fix3             = _fjsp_madd_v2r8(dx30,fscal,fix3);
936             fiy3             = _fjsp_madd_v2r8(dy30,fscal,fiy3);
937             fiz3             = _fjsp_madd_v2r8(dz30,fscal,fiz3);
938             
939             fjx0             = _fjsp_madd_v2r8(dx30,fscal,fjx0);
940             fjy0             = _fjsp_madd_v2r8(dy30,fscal,fjy0);
941             fjz0             = _fjsp_madd_v2r8(dz30,fscal,fjz0);
942
943             gmx_fjsp_decrement_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fjx0,fjy0,fjz0);
944
945             /* Inner loop uses 123 flops */
946         }
947
948         /* End of innermost loop */
949
950         gmx_fjsp_update_iforce_4atom_swizzle_v2r8(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
951                                               f+i_coord_offset,fshift+i_shift_offset);
952
953         /* Increment number of inner iterations */
954         inneriter                  += j_index_end - j_index_start;
955
956         /* Outer loop uses 24 flops */
957     }
958
959     /* Increment number of outer iterations */
960     outeriter        += nri;
961
962     /* Update outer/inner flops */
963
964     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*24 + inneriter*123);
965 }