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