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