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