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