Added option to gmx nmeig to print ZPE.
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_sparc64_hpc_ace_double / nb_kernel_ElecCoul_VdwCSTab_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,2015,2017, by the GROMACS development team, led by
5  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6  * and including many others, as listed in the AUTHORS file in the
7  * top-level source directory and at http://www.gromacs.org.
8  *
9  * GROMACS is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public License
11  * as published by the Free Software Foundation; either version 2.1
12  * of the License, or (at your option) any later version.
13  *
14  * GROMACS is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with GROMACS; if not, see
21  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
23  *
24  * If you want to redistribute modifications to GROMACS, please
25  * consider that scientific software is very special. Version
26  * control is crucial - bugs must be traceable. We will be happy to
27  * consider code for inclusion in the official distribution, but
28  * derived work must not be called official GROMACS. Details are found
29  * in the README & COPYING files - if they are missing, get the
30  * official version at http://www.gromacs.org.
31  *
32  * To help us fund GROMACS development, we humbly ask that you cite
33  * the research papers on the package. Check out http://www.gromacs.org.
34  */
35 /*
36  * Note: this file was generated by the GROMACS sparc64_hpc_ace_double kernel generator.
37  */
38 #include "gmxpre.h"
39
40 #include "config.h"
41
42 #include <math.h>
43
44 #include "../nb_kernel.h"
45 #include "gromacs/gmxlib/nrnb.h"
46
47 #include "kernelutil_sparc64_hpc_ace_double.h"
48
49 /*
50  * Gromacs nonbonded kernel:   nb_kernel_ElecCoul_VdwCSTab_GeomW4P1_VF_sparc64_hpc_ace_double
51  * Electrostatics interaction: Coulomb
52  * VdW interaction:            CubicSplineTable
53  * Geometry:                   Water4-Particle
54  * Calculate force/pot:        PotentialAndForce
55  */
56 void
57 nb_kernel_ElecCoul_VdwCSTab_GeomW4P1_VF_sparc64_hpc_ace_double
58                     (t_nblist                    * gmx_restrict       nlist,
59                      rvec                        * gmx_restrict          xx,
60                      rvec                        * gmx_restrict          ff,
61                      struct t_forcerec           * gmx_restrict          fr,
62                      t_mdatoms                   * gmx_restrict     mdatoms,
63                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
64                      t_nrnb                      * gmx_restrict        nrnb)
65 {
66     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
67      * just 0 for non-waters.
68      * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
69      * jnr indices corresponding to data put in the four positions in the SIMD register.
70      */
71     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
72     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
73     int              jnrA,jnrB;
74     int              j_coord_offsetA,j_coord_offsetB;
75     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
76     real             rcutoff_scalar;
77     real             *shiftvec,*fshift,*x,*f;
78     _fjsp_v2r8       tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
79     int              vdwioffset0;
80     _fjsp_v2r8       ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
81     int              vdwioffset1;
82     _fjsp_v2r8       ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
83     int              vdwioffset2;
84     _fjsp_v2r8       ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
85     int              vdwioffset3;
86     _fjsp_v2r8       ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
87     int              vdwjidx0A,vdwjidx0B;
88     _fjsp_v2r8       jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
89     _fjsp_v2r8       dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
90     _fjsp_v2r8       dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
91     _fjsp_v2r8       dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
92     _fjsp_v2r8       dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
93     _fjsp_v2r8       velec,felec,velecsum,facel,crf,krf,krf2;
94     real             *charge;
95     int              nvdwtype;
96     _fjsp_v2r8       rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
97     int              *vdwtype;
98     real             *vdwparam;
99     _fjsp_v2r8       one_sixth   = gmx_fjsp_set1_v2r8(1.0/6.0);
100     _fjsp_v2r8       one_twelfth = gmx_fjsp_set1_v2r8(1.0/12.0);
101     _fjsp_v2r8       rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF,twovfeps;
102     real             *vftab;
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->ic->epsfac);
121     charge           = mdatoms->chargeA;
122     nvdwtype         = fr->ntype;
123     vdwparam         = fr->nbfp;
124     vdwtype          = mdatoms->typeA;
125
126     vftab            = kernel_data->table_vdw->data;
127     vftabscale       = gmx_fjsp_set1_v2r8(kernel_data->table_vdw->scale);
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             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
214             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
215             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
216             rinv30           = gmx_fjsp_invsqrt_v2r8(rsq30);
217
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             r00              = _fjsp_mul_v2r8(rsq00,rinv00);
236
237             /* Compute parameters for interactions between i and j atoms */
238             gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
239                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
240
241             /* Calculate table index by multiplying r with table scale and truncate to integer */
242             rt               = _fjsp_mul_v2r8(r00,vftabscale);
243             itab_tmp         = _fjsp_dtox_v2r8(rt);
244             vfeps            = _fjsp_sub_v2r8(rt, _fjsp_xtod_v2r8(itab_tmp));
245             twovfeps         = _fjsp_add_v2r8(vfeps,vfeps);
246             _fjsp_store_v2r8(&vfconv.simd,itab_tmp);
247
248             vfconv.i[0]     *= 8;
249             vfconv.i[1]     *= 8;
250
251             /* CUBIC SPLINE TABLE DISPERSION */
252             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] );
253             F                = _fjsp_load_v2r8( vftab + vfconv.i[1] );
254             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
255             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 2 );
256             H                = _fjsp_load_v2r8( vftab + vfconv.i[1] + 2 );
257             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
258             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
259             VV               = _fjsp_madd_v2r8(vfeps,Fp,Y);
260             vvdw6            = _fjsp_mul_v2r8(c6_00,VV);
261             FF               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
262             fvdw6            = _fjsp_mul_v2r8(c6_00,FF);
263
264             /* CUBIC SPLINE TABLE REPULSION */
265             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 4 );
266             F                = _fjsp_load_v2r8( vftab + vfconv.i[1] + 4 );
267             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
268             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 6 );
269             H                = _fjsp_load_v2r8( vftab + vfconv.i[1] + 6 );
270             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
271             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
272             VV               = _fjsp_madd_v2r8(vfeps,Fp,Y);
273             vvdw12           = _fjsp_mul_v2r8(c12_00,VV);
274             FF               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
275             fvdw12           = _fjsp_mul_v2r8(c12_00,FF);
276             vvdw             = _fjsp_add_v2r8(vvdw12,vvdw6);
277             fvdw             = _fjsp_neg_v2r8(_fjsp_mul_v2r8(_fjsp_add_v2r8(fvdw6,fvdw12),_fjsp_mul_v2r8(vftabscale,rinv00)));
278
279             /* Update potential sum for this i atom from the interaction with this j atom. */
280             vvdwsum          = _fjsp_add_v2r8(vvdwsum,vvdw);
281
282             fscal            = fvdw;
283
284             /* Update vectorial force */
285             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
286             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
287             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
288             
289             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
290             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
291             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
292
293             /**************************
294              * CALCULATE INTERACTIONS *
295              **************************/
296
297             /* Compute parameters for interactions between i and j atoms */
298             qq10             = _fjsp_mul_v2r8(iq1,jq0);
299
300             /* COULOMB ELECTROSTATICS */
301             velec            = _fjsp_mul_v2r8(qq10,rinv10);
302             felec            = _fjsp_mul_v2r8(velec,rinvsq10);
303
304             /* Update potential sum for this i atom from the interaction with this j atom. */
305             velecsum         = _fjsp_add_v2r8(velecsum,velec);
306
307             fscal            = felec;
308
309             /* Update vectorial force */
310             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
311             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
312             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
313             
314             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
315             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
316             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
317
318             /**************************
319              * CALCULATE INTERACTIONS *
320              **************************/
321
322             /* Compute parameters for interactions between i and j atoms */
323             qq20             = _fjsp_mul_v2r8(iq2,jq0);
324
325             /* COULOMB ELECTROSTATICS */
326             velec            = _fjsp_mul_v2r8(qq20,rinv20);
327             felec            = _fjsp_mul_v2r8(velec,rinvsq20);
328
329             /* Update potential sum for this i atom from the interaction with this j atom. */
330             velecsum         = _fjsp_add_v2r8(velecsum,velec);
331
332             fscal            = felec;
333
334             /* Update vectorial force */
335             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
336             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
337             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
338             
339             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
340             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
341             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
342
343             /**************************
344              * CALCULATE INTERACTIONS *
345              **************************/
346
347             /* Compute parameters for interactions between i and j atoms */
348             qq30             = _fjsp_mul_v2r8(iq3,jq0);
349
350             /* COULOMB ELECTROSTATICS */
351             velec            = _fjsp_mul_v2r8(qq30,rinv30);
352             felec            = _fjsp_mul_v2r8(velec,rinvsq30);
353
354             /* Update potential sum for this i atom from the interaction with this j atom. */
355             velecsum         = _fjsp_add_v2r8(velecsum,velec);
356
357             fscal            = felec;
358
359             /* Update vectorial force */
360             fix3             = _fjsp_madd_v2r8(dx30,fscal,fix3);
361             fiy3             = _fjsp_madd_v2r8(dy30,fscal,fiy3);
362             fiz3             = _fjsp_madd_v2r8(dz30,fscal,fiz3);
363             
364             fjx0             = _fjsp_madd_v2r8(dx30,fscal,fjx0);
365             fjy0             = _fjsp_madd_v2r8(dy30,fscal,fjy0);
366             fjz0             = _fjsp_madd_v2r8(dz30,fscal,fjz0);
367
368             gmx_fjsp_decrement_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
369
370             /* Inner loop uses 155 flops */
371         }
372
373         if(jidx<j_index_end)
374         {
375
376             jnrA             = jjnr[jidx];
377             j_coord_offsetA  = DIM*jnrA;
378
379             /* load j atom coordinates */
380             gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
381                                               &jx0,&jy0,&jz0);
382
383             /* Calculate displacement vector */
384             dx00             = _fjsp_sub_v2r8(ix0,jx0);
385             dy00             = _fjsp_sub_v2r8(iy0,jy0);
386             dz00             = _fjsp_sub_v2r8(iz0,jz0);
387             dx10             = _fjsp_sub_v2r8(ix1,jx0);
388             dy10             = _fjsp_sub_v2r8(iy1,jy0);
389             dz10             = _fjsp_sub_v2r8(iz1,jz0);
390             dx20             = _fjsp_sub_v2r8(ix2,jx0);
391             dy20             = _fjsp_sub_v2r8(iy2,jy0);
392             dz20             = _fjsp_sub_v2r8(iz2,jz0);
393             dx30             = _fjsp_sub_v2r8(ix3,jx0);
394             dy30             = _fjsp_sub_v2r8(iy3,jy0);
395             dz30             = _fjsp_sub_v2r8(iz3,jz0);
396
397             /* Calculate squared distance and things based on it */
398             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
399             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
400             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
401             rsq30            = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
402
403             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
404             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
405             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
406             rinv30           = gmx_fjsp_invsqrt_v2r8(rsq30);
407
408             rinvsq10         = _fjsp_mul_v2r8(rinv10,rinv10);
409             rinvsq20         = _fjsp_mul_v2r8(rinv20,rinv20);
410             rinvsq30         = _fjsp_mul_v2r8(rinv30,rinv30);
411
412             /* Load parameters for j particles */
413             jq0              = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
414             vdwjidx0A        = 2*vdwtype[jnrA+0];
415
416             fjx0             = _fjsp_setzero_v2r8();
417             fjy0             = _fjsp_setzero_v2r8();
418             fjz0             = _fjsp_setzero_v2r8();
419
420             /**************************
421              * CALCULATE INTERACTIONS *
422              **************************/
423
424             r00              = _fjsp_mul_v2r8(rsq00,rinv00);
425
426             /* Compute parameters for interactions between i and j atoms */
427             gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
428                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
429
430             /* Calculate table index by multiplying r with table scale and truncate to integer */
431             rt               = _fjsp_mul_v2r8(r00,vftabscale);
432             itab_tmp         = _fjsp_dtox_v2r8(rt);
433             vfeps            = _fjsp_sub_v2r8(rt, _fjsp_xtod_v2r8(itab_tmp));
434             twovfeps         = _fjsp_add_v2r8(vfeps,vfeps);
435             _fjsp_store_v2r8(&vfconv.simd,itab_tmp);
436
437             vfconv.i[0]     *= 8;
438             vfconv.i[1]     *= 8;
439
440             /* CUBIC SPLINE TABLE DISPERSION */
441             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] );
442             F                = _fjsp_setzero_v2r8();
443             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
444             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 2 );
445             H                = _fjsp_setzero_v2r8();
446             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
447             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
448             VV               = _fjsp_madd_v2r8(vfeps,Fp,Y);
449             vvdw6            = _fjsp_mul_v2r8(c6_00,VV);
450             FF               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
451             fvdw6            = _fjsp_mul_v2r8(c6_00,FF);
452
453             /* CUBIC SPLINE TABLE REPULSION */
454             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 4 );
455             F                = _fjsp_setzero_v2r8();
456             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
457             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 6 );
458             H                = _fjsp_setzero_v2r8();
459             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
460             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
461             VV               = _fjsp_madd_v2r8(vfeps,Fp,Y);
462             vvdw12           = _fjsp_mul_v2r8(c12_00,VV);
463             FF               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
464             fvdw12           = _fjsp_mul_v2r8(c12_00,FF);
465             vvdw             = _fjsp_add_v2r8(vvdw12,vvdw6);
466             fvdw             = _fjsp_neg_v2r8(_fjsp_mul_v2r8(_fjsp_add_v2r8(fvdw6,fvdw12),_fjsp_mul_v2r8(vftabscale,rinv00)));
467
468             /* Update potential sum for this i atom from the interaction with this j atom. */
469             vvdw             = _fjsp_unpacklo_v2r8(vvdw,_fjsp_setzero_v2r8());
470             vvdwsum          = _fjsp_add_v2r8(vvdwsum,vvdw);
471
472             fscal            = fvdw;
473
474             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
475
476             /* Update vectorial force */
477             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
478             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
479             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
480             
481             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
482             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
483             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
484
485             /**************************
486              * CALCULATE INTERACTIONS *
487              **************************/
488
489             /* Compute parameters for interactions between i and j atoms */
490             qq10             = _fjsp_mul_v2r8(iq1,jq0);
491
492             /* COULOMB ELECTROSTATICS */
493             velec            = _fjsp_mul_v2r8(qq10,rinv10);
494             felec            = _fjsp_mul_v2r8(velec,rinvsq10);
495
496             /* Update potential sum for this i atom from the interaction with this j atom. */
497             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
498             velecsum         = _fjsp_add_v2r8(velecsum,velec);
499
500             fscal            = felec;
501
502             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
503
504             /* Update vectorial force */
505             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
506             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
507             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
508             
509             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
510             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
511             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
512
513             /**************************
514              * CALCULATE INTERACTIONS *
515              **************************/
516
517             /* Compute parameters for interactions between i and j atoms */
518             qq20             = _fjsp_mul_v2r8(iq2,jq0);
519
520             /* COULOMB ELECTROSTATICS */
521             velec            = _fjsp_mul_v2r8(qq20,rinv20);
522             felec            = _fjsp_mul_v2r8(velec,rinvsq20);
523
524             /* Update potential sum for this i atom from the interaction with this j atom. */
525             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
526             velecsum         = _fjsp_add_v2r8(velecsum,velec);
527
528             fscal            = felec;
529
530             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
531
532             /* Update vectorial force */
533             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
534             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
535             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
536             
537             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
538             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
539             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
540
541             /**************************
542              * CALCULATE INTERACTIONS *
543              **************************/
544
545             /* Compute parameters for interactions between i and j atoms */
546             qq30             = _fjsp_mul_v2r8(iq3,jq0);
547
548             /* COULOMB ELECTROSTATICS */
549             velec            = _fjsp_mul_v2r8(qq30,rinv30);
550             felec            = _fjsp_mul_v2r8(velec,rinvsq30);
551
552             /* Update potential sum for this i atom from the interaction with this j atom. */
553             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
554             velecsum         = _fjsp_add_v2r8(velecsum,velec);
555
556             fscal            = felec;
557
558             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
559
560             /* Update vectorial force */
561             fix3             = _fjsp_madd_v2r8(dx30,fscal,fix3);
562             fiy3             = _fjsp_madd_v2r8(dy30,fscal,fiy3);
563             fiz3             = _fjsp_madd_v2r8(dz30,fscal,fiz3);
564             
565             fjx0             = _fjsp_madd_v2r8(dx30,fscal,fjx0);
566             fjy0             = _fjsp_madd_v2r8(dy30,fscal,fjy0);
567             fjz0             = _fjsp_madd_v2r8(dz30,fscal,fjz0);
568
569             gmx_fjsp_decrement_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fjx0,fjy0,fjz0);
570
571             /* Inner loop uses 155 flops */
572         }
573
574         /* End of innermost loop */
575
576         gmx_fjsp_update_iforce_4atom_swizzle_v2r8(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
577                                               f+i_coord_offset,fshift+i_shift_offset);
578
579         ggid                        = gid[iidx];
580         /* Update potential energies */
581         gmx_fjsp_update_1pot_v2r8(velecsum,kernel_data->energygrp_elec+ggid);
582         gmx_fjsp_update_1pot_v2r8(vvdwsum,kernel_data->energygrp_vdw+ggid);
583
584         /* Increment number of inner iterations */
585         inneriter                  += j_index_end - j_index_start;
586
587         /* Outer loop uses 26 flops */
588     }
589
590     /* Increment number of outer iterations */
591     outeriter        += nri;
592
593     /* Update outer/inner flops */
594
595     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*26 + inneriter*155);
596 }
597 /*
598  * Gromacs nonbonded kernel:   nb_kernel_ElecCoul_VdwCSTab_GeomW4P1_F_sparc64_hpc_ace_double
599  * Electrostatics interaction: Coulomb
600  * VdW interaction:            CubicSplineTable
601  * Geometry:                   Water4-Particle
602  * Calculate force/pot:        Force
603  */
604 void
605 nb_kernel_ElecCoul_VdwCSTab_GeomW4P1_F_sparc64_hpc_ace_double
606                     (t_nblist                    * gmx_restrict       nlist,
607                      rvec                        * gmx_restrict          xx,
608                      rvec                        * gmx_restrict          ff,
609                      struct t_forcerec           * gmx_restrict          fr,
610                      t_mdatoms                   * gmx_restrict     mdatoms,
611                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
612                      t_nrnb                      * gmx_restrict        nrnb)
613 {
614     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
615      * just 0 for non-waters.
616      * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
617      * jnr indices corresponding to data put in the four positions in the SIMD register.
618      */
619     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
620     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
621     int              jnrA,jnrB;
622     int              j_coord_offsetA,j_coord_offsetB;
623     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
624     real             rcutoff_scalar;
625     real             *shiftvec,*fshift,*x,*f;
626     _fjsp_v2r8       tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
627     int              vdwioffset0;
628     _fjsp_v2r8       ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
629     int              vdwioffset1;
630     _fjsp_v2r8       ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
631     int              vdwioffset2;
632     _fjsp_v2r8       ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
633     int              vdwioffset3;
634     _fjsp_v2r8       ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
635     int              vdwjidx0A,vdwjidx0B;
636     _fjsp_v2r8       jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
637     _fjsp_v2r8       dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
638     _fjsp_v2r8       dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
639     _fjsp_v2r8       dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
640     _fjsp_v2r8       dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
641     _fjsp_v2r8       velec,felec,velecsum,facel,crf,krf,krf2;
642     real             *charge;
643     int              nvdwtype;
644     _fjsp_v2r8       rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
645     int              *vdwtype;
646     real             *vdwparam;
647     _fjsp_v2r8       one_sixth   = gmx_fjsp_set1_v2r8(1.0/6.0);
648     _fjsp_v2r8       one_twelfth = gmx_fjsp_set1_v2r8(1.0/12.0);
649     _fjsp_v2r8       rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF,twovfeps;
650     real             *vftab;
651     _fjsp_v2r8       itab_tmp;
652     _fjsp_v2r8       dummy_mask,cutoff_mask;
653     _fjsp_v2r8       one     = gmx_fjsp_set1_v2r8(1.0);
654     _fjsp_v2r8       two     = gmx_fjsp_set1_v2r8(2.0);
655     union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
656
657     x                = xx[0];
658     f                = ff[0];
659
660     nri              = nlist->nri;
661     iinr             = nlist->iinr;
662     jindex           = nlist->jindex;
663     jjnr             = nlist->jjnr;
664     shiftidx         = nlist->shift;
665     gid              = nlist->gid;
666     shiftvec         = fr->shift_vec[0];
667     fshift           = fr->fshift[0];
668     facel            = gmx_fjsp_set1_v2r8(fr->ic->epsfac);
669     charge           = mdatoms->chargeA;
670     nvdwtype         = fr->ntype;
671     vdwparam         = fr->nbfp;
672     vdwtype          = mdatoms->typeA;
673
674     vftab            = kernel_data->table_vdw->data;
675     vftabscale       = gmx_fjsp_set1_v2r8(kernel_data->table_vdw->scale);
676
677     /* Setup water-specific parameters */
678     inr              = nlist->iinr[0];
679     iq1              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+1]));
680     iq2              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+2]));
681     iq3              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+3]));
682     vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
683
684     /* Avoid stupid compiler warnings */
685     jnrA = jnrB = 0;
686     j_coord_offsetA = 0;
687     j_coord_offsetB = 0;
688
689     outeriter        = 0;
690     inneriter        = 0;
691
692     /* Start outer loop over neighborlists */
693     for(iidx=0; iidx<nri; iidx++)
694     {
695         /* Load shift vector for this list */
696         i_shift_offset   = DIM*shiftidx[iidx];
697
698         /* Load limits for loop over neighbors */
699         j_index_start    = jindex[iidx];
700         j_index_end      = jindex[iidx+1];
701
702         /* Get outer coordinate index */
703         inr              = iinr[iidx];
704         i_coord_offset   = DIM*inr;
705
706         /* Load i particle coords and add shift vector */
707         gmx_fjsp_load_shift_and_4rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,
708                                                  &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
709
710         fix0             = _fjsp_setzero_v2r8();
711         fiy0             = _fjsp_setzero_v2r8();
712         fiz0             = _fjsp_setzero_v2r8();
713         fix1             = _fjsp_setzero_v2r8();
714         fiy1             = _fjsp_setzero_v2r8();
715         fiz1             = _fjsp_setzero_v2r8();
716         fix2             = _fjsp_setzero_v2r8();
717         fiy2             = _fjsp_setzero_v2r8();
718         fiz2             = _fjsp_setzero_v2r8();
719         fix3             = _fjsp_setzero_v2r8();
720         fiy3             = _fjsp_setzero_v2r8();
721         fiz3             = _fjsp_setzero_v2r8();
722
723         /* Start inner kernel loop */
724         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
725         {
726
727             /* Get j neighbor index, and coordinate index */
728             jnrA             = jjnr[jidx];
729             jnrB             = jjnr[jidx+1];
730             j_coord_offsetA  = DIM*jnrA;
731             j_coord_offsetB  = DIM*jnrB;
732
733             /* load j atom coordinates */
734             gmx_fjsp_load_1rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
735                                               &jx0,&jy0,&jz0);
736
737             /* Calculate displacement vector */
738             dx00             = _fjsp_sub_v2r8(ix0,jx0);
739             dy00             = _fjsp_sub_v2r8(iy0,jy0);
740             dz00             = _fjsp_sub_v2r8(iz0,jz0);
741             dx10             = _fjsp_sub_v2r8(ix1,jx0);
742             dy10             = _fjsp_sub_v2r8(iy1,jy0);
743             dz10             = _fjsp_sub_v2r8(iz1,jz0);
744             dx20             = _fjsp_sub_v2r8(ix2,jx0);
745             dy20             = _fjsp_sub_v2r8(iy2,jy0);
746             dz20             = _fjsp_sub_v2r8(iz2,jz0);
747             dx30             = _fjsp_sub_v2r8(ix3,jx0);
748             dy30             = _fjsp_sub_v2r8(iy3,jy0);
749             dz30             = _fjsp_sub_v2r8(iz3,jz0);
750
751             /* Calculate squared distance and things based on it */
752             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
753             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
754             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
755             rsq30            = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
756
757             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
758             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
759             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
760             rinv30           = gmx_fjsp_invsqrt_v2r8(rsq30);
761
762             rinvsq10         = _fjsp_mul_v2r8(rinv10,rinv10);
763             rinvsq20         = _fjsp_mul_v2r8(rinv20,rinv20);
764             rinvsq30         = _fjsp_mul_v2r8(rinv30,rinv30);
765
766             /* Load parameters for j particles */
767             jq0              = gmx_fjsp_load_2real_swizzle_v2r8(charge+jnrA+0,charge+jnrB+0);
768             vdwjidx0A        = 2*vdwtype[jnrA+0];
769             vdwjidx0B        = 2*vdwtype[jnrB+0];
770
771             fjx0             = _fjsp_setzero_v2r8();
772             fjy0             = _fjsp_setzero_v2r8();
773             fjz0             = _fjsp_setzero_v2r8();
774
775             /**************************
776              * CALCULATE INTERACTIONS *
777              **************************/
778
779             r00              = _fjsp_mul_v2r8(rsq00,rinv00);
780
781             /* Compute parameters for interactions between i and j atoms */
782             gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
783                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
784
785             /* Calculate table index by multiplying r with table scale and truncate to integer */
786             rt               = _fjsp_mul_v2r8(r00,vftabscale);
787             itab_tmp         = _fjsp_dtox_v2r8(rt);
788             vfeps            = _fjsp_sub_v2r8(rt, _fjsp_xtod_v2r8(itab_tmp));
789             twovfeps         = _fjsp_add_v2r8(vfeps,vfeps);
790             _fjsp_store_v2r8(&vfconv.simd,itab_tmp);
791
792             vfconv.i[0]     *= 8;
793             vfconv.i[1]     *= 8;
794
795             /* CUBIC SPLINE TABLE DISPERSION */
796             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] );
797             F                = _fjsp_load_v2r8( vftab + vfconv.i[1] );
798             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
799             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 2 );
800             H                = _fjsp_load_v2r8( vftab + vfconv.i[1] + 2 );
801             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
802             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
803             FF               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
804             fvdw6            = _fjsp_mul_v2r8(c6_00,FF);
805
806             /* CUBIC SPLINE TABLE REPULSION */
807             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 4 );
808             F                = _fjsp_load_v2r8( vftab + vfconv.i[1] + 4 );
809             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
810             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 6 );
811             H                = _fjsp_load_v2r8( vftab + vfconv.i[1] + 6 );
812             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
813             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
814             FF               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
815             fvdw12           = _fjsp_mul_v2r8(c12_00,FF);
816             fvdw             = _fjsp_neg_v2r8(_fjsp_mul_v2r8(_fjsp_add_v2r8(fvdw6,fvdw12),_fjsp_mul_v2r8(vftabscale,rinv00)));
817
818             fscal            = fvdw;
819
820             /* Update vectorial force */
821             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
822             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
823             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
824             
825             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
826             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
827             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
828
829             /**************************
830              * CALCULATE INTERACTIONS *
831              **************************/
832
833             /* Compute parameters for interactions between i and j atoms */
834             qq10             = _fjsp_mul_v2r8(iq1,jq0);
835
836             /* COULOMB ELECTROSTATICS */
837             velec            = _fjsp_mul_v2r8(qq10,rinv10);
838             felec            = _fjsp_mul_v2r8(velec,rinvsq10);
839
840             fscal            = felec;
841
842             /* Update vectorial force */
843             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
844             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
845             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
846             
847             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
848             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
849             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
850
851             /**************************
852              * CALCULATE INTERACTIONS *
853              **************************/
854
855             /* Compute parameters for interactions between i and j atoms */
856             qq20             = _fjsp_mul_v2r8(iq2,jq0);
857
858             /* COULOMB ELECTROSTATICS */
859             velec            = _fjsp_mul_v2r8(qq20,rinv20);
860             felec            = _fjsp_mul_v2r8(velec,rinvsq20);
861
862             fscal            = felec;
863
864             /* Update vectorial force */
865             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
866             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
867             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
868             
869             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
870             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
871             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
872
873             /**************************
874              * CALCULATE INTERACTIONS *
875              **************************/
876
877             /* Compute parameters for interactions between i and j atoms */
878             qq30             = _fjsp_mul_v2r8(iq3,jq0);
879
880             /* COULOMB ELECTROSTATICS */
881             velec            = _fjsp_mul_v2r8(qq30,rinv30);
882             felec            = _fjsp_mul_v2r8(velec,rinvsq30);
883
884             fscal            = felec;
885
886             /* Update vectorial force */
887             fix3             = _fjsp_madd_v2r8(dx30,fscal,fix3);
888             fiy3             = _fjsp_madd_v2r8(dy30,fscal,fiy3);
889             fiz3             = _fjsp_madd_v2r8(dz30,fscal,fiz3);
890             
891             fjx0             = _fjsp_madd_v2r8(dx30,fscal,fjx0);
892             fjy0             = _fjsp_madd_v2r8(dy30,fscal,fjy0);
893             fjz0             = _fjsp_madd_v2r8(dz30,fscal,fjz0);
894
895             gmx_fjsp_decrement_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
896
897             /* Inner loop uses 144 flops */
898         }
899
900         if(jidx<j_index_end)
901         {
902
903             jnrA             = jjnr[jidx];
904             j_coord_offsetA  = DIM*jnrA;
905
906             /* load j atom coordinates */
907             gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
908                                               &jx0,&jy0,&jz0);
909
910             /* Calculate displacement vector */
911             dx00             = _fjsp_sub_v2r8(ix0,jx0);
912             dy00             = _fjsp_sub_v2r8(iy0,jy0);
913             dz00             = _fjsp_sub_v2r8(iz0,jz0);
914             dx10             = _fjsp_sub_v2r8(ix1,jx0);
915             dy10             = _fjsp_sub_v2r8(iy1,jy0);
916             dz10             = _fjsp_sub_v2r8(iz1,jz0);
917             dx20             = _fjsp_sub_v2r8(ix2,jx0);
918             dy20             = _fjsp_sub_v2r8(iy2,jy0);
919             dz20             = _fjsp_sub_v2r8(iz2,jz0);
920             dx30             = _fjsp_sub_v2r8(ix3,jx0);
921             dy30             = _fjsp_sub_v2r8(iy3,jy0);
922             dz30             = _fjsp_sub_v2r8(iz3,jz0);
923
924             /* Calculate squared distance and things based on it */
925             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
926             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
927             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
928             rsq30            = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
929
930             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
931             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
932             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
933             rinv30           = gmx_fjsp_invsqrt_v2r8(rsq30);
934
935             rinvsq10         = _fjsp_mul_v2r8(rinv10,rinv10);
936             rinvsq20         = _fjsp_mul_v2r8(rinv20,rinv20);
937             rinvsq30         = _fjsp_mul_v2r8(rinv30,rinv30);
938
939             /* Load parameters for j particles */
940             jq0              = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
941             vdwjidx0A        = 2*vdwtype[jnrA+0];
942
943             fjx0             = _fjsp_setzero_v2r8();
944             fjy0             = _fjsp_setzero_v2r8();
945             fjz0             = _fjsp_setzero_v2r8();
946
947             /**************************
948              * CALCULATE INTERACTIONS *
949              **************************/
950
951             r00              = _fjsp_mul_v2r8(rsq00,rinv00);
952
953             /* Compute parameters for interactions between i and j atoms */
954             gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
955                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
956
957             /* Calculate table index by multiplying r with table scale and truncate to integer */
958             rt               = _fjsp_mul_v2r8(r00,vftabscale);
959             itab_tmp         = _fjsp_dtox_v2r8(rt);
960             vfeps            = _fjsp_sub_v2r8(rt, _fjsp_xtod_v2r8(itab_tmp));
961             twovfeps         = _fjsp_add_v2r8(vfeps,vfeps);
962             _fjsp_store_v2r8(&vfconv.simd,itab_tmp);
963
964             vfconv.i[0]     *= 8;
965             vfconv.i[1]     *= 8;
966
967             /* CUBIC SPLINE TABLE DISPERSION */
968             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] );
969             F                = _fjsp_setzero_v2r8();
970             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
971             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 2 );
972             H                = _fjsp_setzero_v2r8();
973             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
974             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
975             FF               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
976             fvdw6            = _fjsp_mul_v2r8(c6_00,FF);
977
978             /* CUBIC SPLINE TABLE REPULSION */
979             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 4 );
980             F                = _fjsp_setzero_v2r8();
981             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
982             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 6 );
983             H                = _fjsp_setzero_v2r8();
984             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
985             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
986             FF               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
987             fvdw12           = _fjsp_mul_v2r8(c12_00,FF);
988             fvdw             = _fjsp_neg_v2r8(_fjsp_mul_v2r8(_fjsp_add_v2r8(fvdw6,fvdw12),_fjsp_mul_v2r8(vftabscale,rinv00)));
989
990             fscal            = fvdw;
991
992             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
993
994             /* Update vectorial force */
995             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
996             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
997             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
998             
999             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
1000             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
1001             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
1002
1003             /**************************
1004              * CALCULATE INTERACTIONS *
1005              **************************/
1006
1007             /* Compute parameters for interactions between i and j atoms */
1008             qq10             = _fjsp_mul_v2r8(iq1,jq0);
1009
1010             /* COULOMB ELECTROSTATICS */
1011             velec            = _fjsp_mul_v2r8(qq10,rinv10);
1012             felec            = _fjsp_mul_v2r8(velec,rinvsq10);
1013
1014             fscal            = felec;
1015
1016             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1017
1018             /* Update vectorial force */
1019             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
1020             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
1021             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
1022             
1023             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
1024             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
1025             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
1026
1027             /**************************
1028              * CALCULATE INTERACTIONS *
1029              **************************/
1030
1031             /* Compute parameters for interactions between i and j atoms */
1032             qq20             = _fjsp_mul_v2r8(iq2,jq0);
1033
1034             /* COULOMB ELECTROSTATICS */
1035             velec            = _fjsp_mul_v2r8(qq20,rinv20);
1036             felec            = _fjsp_mul_v2r8(velec,rinvsq20);
1037
1038             fscal            = felec;
1039
1040             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1041
1042             /* Update vectorial force */
1043             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
1044             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
1045             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
1046             
1047             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
1048             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
1049             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
1050
1051             /**************************
1052              * CALCULATE INTERACTIONS *
1053              **************************/
1054
1055             /* Compute parameters for interactions between i and j atoms */
1056             qq30             = _fjsp_mul_v2r8(iq3,jq0);
1057
1058             /* COULOMB ELECTROSTATICS */
1059             velec            = _fjsp_mul_v2r8(qq30,rinv30);
1060             felec            = _fjsp_mul_v2r8(velec,rinvsq30);
1061
1062             fscal            = felec;
1063
1064             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1065
1066             /* Update vectorial force */
1067             fix3             = _fjsp_madd_v2r8(dx30,fscal,fix3);
1068             fiy3             = _fjsp_madd_v2r8(dy30,fscal,fiy3);
1069             fiz3             = _fjsp_madd_v2r8(dz30,fscal,fiz3);
1070             
1071             fjx0             = _fjsp_madd_v2r8(dx30,fscal,fjx0);
1072             fjy0             = _fjsp_madd_v2r8(dy30,fscal,fjy0);
1073             fjz0             = _fjsp_madd_v2r8(dz30,fscal,fjz0);
1074
1075             gmx_fjsp_decrement_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fjx0,fjy0,fjz0);
1076
1077             /* Inner loop uses 144 flops */
1078         }
1079
1080         /* End of innermost loop */
1081
1082         gmx_fjsp_update_iforce_4atom_swizzle_v2r8(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
1083                                               f+i_coord_offset,fshift+i_shift_offset);
1084
1085         /* Increment number of inner iterations */
1086         inneriter                  += j_index_end - j_index_start;
1087
1088         /* Outer loop uses 24 flops */
1089     }
1090
1091     /* Increment number of outer iterations */
1092     outeriter        += nri;
1093
1094     /* Update outer/inner flops */
1095
1096     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*24 + inneriter*144);
1097 }