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