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