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