K-computer specific modifications
[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 #ifdef HAVE_CONFIG_H
39 #include <config.h>
40 #endif
41
42 #include <math.h>
43
44 #include "../nb_kernel.h"
45 #include "types/simple.h"
46 #include "gromacs/legacyheaders/vec.h"
47 #include "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_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
399                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
400
401             /* Calculate table index by multiplying r with table scale and truncate to integer */
402             rt               = _fjsp_mul_v2r8(r00,vftabscale);
403             itab_tmp         = _fjsp_dtox_v2r8(rt);
404             vfeps            = _fjsp_sub_v2r8(rt, _fjsp_xtod_v2r8(itab_tmp));
405             twovfeps         = _fjsp_add_v2r8(vfeps,vfeps);
406             _fjsp_store_v2r8(&vfconv.simd,itab_tmp);
407
408             vfconv.i[0]     *= 8;
409             vfconv.i[1]     *= 8;
410
411             /* REACTION-FIELD ELECTROSTATICS */
412             velec            = _fjsp_mul_v2r8(qq00,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq00,rinv00),crf));
413             felec            = _fjsp_mul_v2r8(qq00,_fjsp_msub_v2r8(rinv00,rinvsq00,krf2));
414
415             /* CUBIC SPLINE TABLE DISPERSION */
416             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] );
417             F                = _fjsp_setzero_v2r8();
418             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
419             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 2 );
420             H                = _fjsp_setzero_v2r8();
421             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
422             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
423             VV               = _fjsp_madd_v2r8(vfeps,Fp,Y);
424             vvdw6            = _fjsp_mul_v2r8(c6_00,VV);
425             FF               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
426             fvdw6            = _fjsp_mul_v2r8(c6_00,FF);
427
428             /* CUBIC SPLINE TABLE REPULSION */
429             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 4 );
430             F                = _fjsp_setzero_v2r8();
431             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
432             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 6 );
433             H                = _fjsp_setzero_v2r8();
434             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
435             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
436             VV               = _fjsp_madd_v2r8(vfeps,Fp,Y);
437             vvdw12           = _fjsp_mul_v2r8(c12_00,VV);
438             FF               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
439             fvdw12           = _fjsp_mul_v2r8(c12_00,FF);
440             vvdw             = _fjsp_add_v2r8(vvdw12,vvdw6);
441             fvdw             = _fjsp_neg_v2r8(_fjsp_mul_v2r8(_fjsp_add_v2r8(fvdw6,fvdw12),_fjsp_mul_v2r8(vftabscale,rinv00)));
442
443             /* Update potential sum for this i atom from the interaction with this j atom. */
444             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
445             velecsum         = _fjsp_add_v2r8(velecsum,velec);
446             vvdw             = _fjsp_unpacklo_v2r8(vvdw,_fjsp_setzero_v2r8());
447             vvdwsum          = _fjsp_add_v2r8(vvdwsum,vvdw);
448
449             fscal            = _fjsp_add_v2r8(felec,fvdw);
450
451             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
452
453             /* Update vectorial force */
454             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
455             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
456             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
457             
458             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
459             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
460             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
461
462             /**************************
463              * CALCULATE INTERACTIONS *
464              **************************/
465
466             /* Compute parameters for interactions between i and j atoms */
467             qq10             = _fjsp_mul_v2r8(iq1,jq0);
468
469             /* REACTION-FIELD ELECTROSTATICS */
470             velec            = _fjsp_mul_v2r8(qq10,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq10,rinv10),crf));
471             felec            = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
472
473             /* Update potential sum for this i atom from the interaction with this j atom. */
474             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
475             velecsum         = _fjsp_add_v2r8(velecsum,velec);
476
477             fscal            = felec;
478
479             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
480
481             /* Update vectorial force */
482             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
483             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
484             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
485             
486             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
487             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
488             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
489
490             /**************************
491              * CALCULATE INTERACTIONS *
492              **************************/
493
494             /* Compute parameters for interactions between i and j atoms */
495             qq20             = _fjsp_mul_v2r8(iq2,jq0);
496
497             /* REACTION-FIELD ELECTROSTATICS */
498             velec            = _fjsp_mul_v2r8(qq20,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq20,rinv20),crf));
499             felec            = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
500
501             /* Update potential sum for this i atom from the interaction with this j atom. */
502             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
503             velecsum         = _fjsp_add_v2r8(velecsum,velec);
504
505             fscal            = felec;
506
507             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
508
509             /* Update vectorial force */
510             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
511             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
512             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
513             
514             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
515             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
516             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
517
518             gmx_fjsp_decrement_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fjx0,fjy0,fjz0);
519
520             /* Inner loop uses 143 flops */
521         }
522
523         /* End of innermost loop */
524
525         gmx_fjsp_update_iforce_3atom_swizzle_v2r8(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
526                                               f+i_coord_offset,fshift+i_shift_offset);
527
528         ggid                        = gid[iidx];
529         /* Update potential energies */
530         gmx_fjsp_update_1pot_v2r8(velecsum,kernel_data->energygrp_elec+ggid);
531         gmx_fjsp_update_1pot_v2r8(vvdwsum,kernel_data->energygrp_vdw+ggid);
532
533         /* Increment number of inner iterations */
534         inneriter                  += j_index_end - j_index_start;
535
536         /* Outer loop uses 20 flops */
537     }
538
539     /* Increment number of outer iterations */
540     outeriter        += nri;
541
542     /* Update outer/inner flops */
543
544     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*20 + inneriter*143);
545 }
546 /*
547  * Gromacs nonbonded kernel:   nb_kernel_ElecRF_VdwCSTab_GeomW3P1_F_sparc64_hpc_ace_double
548  * Electrostatics interaction: ReactionField
549  * VdW interaction:            CubicSplineTable
550  * Geometry:                   Water3-Particle
551  * Calculate force/pot:        Force
552  */
553 void
554 nb_kernel_ElecRF_VdwCSTab_GeomW3P1_F_sparc64_hpc_ace_double
555                     (t_nblist                    * gmx_restrict       nlist,
556                      rvec                        * gmx_restrict          xx,
557                      rvec                        * gmx_restrict          ff,
558                      t_forcerec                  * gmx_restrict          fr,
559                      t_mdatoms                   * gmx_restrict     mdatoms,
560                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
561                      t_nrnb                      * gmx_restrict        nrnb)
562 {
563     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
564      * just 0 for non-waters.
565      * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
566      * jnr indices corresponding to data put in the four positions in the SIMD register.
567      */
568     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
569     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
570     int              jnrA,jnrB;
571     int              j_coord_offsetA,j_coord_offsetB;
572     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
573     real             rcutoff_scalar;
574     real             *shiftvec,*fshift,*x,*f;
575     _fjsp_v2r8       tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
576     int              vdwioffset0;
577     _fjsp_v2r8       ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
578     int              vdwioffset1;
579     _fjsp_v2r8       ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
580     int              vdwioffset2;
581     _fjsp_v2r8       ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
582     int              vdwjidx0A,vdwjidx0B;
583     _fjsp_v2r8       jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
584     _fjsp_v2r8       dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
585     _fjsp_v2r8       dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
586     _fjsp_v2r8       dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
587     _fjsp_v2r8       velec,felec,velecsum,facel,crf,krf,krf2;
588     real             *charge;
589     int              nvdwtype;
590     _fjsp_v2r8       rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
591     int              *vdwtype;
592     real             *vdwparam;
593     _fjsp_v2r8       one_sixth   = gmx_fjsp_set1_v2r8(1.0/6.0);
594     _fjsp_v2r8       one_twelfth = gmx_fjsp_set1_v2r8(1.0/12.0);
595     _fjsp_v2r8       rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF,twovfeps;
596     real             *vftab;
597     _fjsp_v2r8       itab_tmp;
598     _fjsp_v2r8       dummy_mask,cutoff_mask;
599     _fjsp_v2r8       one     = gmx_fjsp_set1_v2r8(1.0);
600     _fjsp_v2r8       two     = gmx_fjsp_set1_v2r8(2.0);
601     union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
602
603     x                = xx[0];
604     f                = ff[0];
605
606     nri              = nlist->nri;
607     iinr             = nlist->iinr;
608     jindex           = nlist->jindex;
609     jjnr             = nlist->jjnr;
610     shiftidx         = nlist->shift;
611     gid              = nlist->gid;
612     shiftvec         = fr->shift_vec[0];
613     fshift           = fr->fshift[0];
614     facel            = gmx_fjsp_set1_v2r8(fr->epsfac);
615     charge           = mdatoms->chargeA;
616     krf              = gmx_fjsp_set1_v2r8(fr->ic->k_rf);
617     krf2             = gmx_fjsp_set1_v2r8(fr->ic->k_rf*2.0);
618     crf              = gmx_fjsp_set1_v2r8(fr->ic->c_rf);
619     nvdwtype         = fr->ntype;
620     vdwparam         = fr->nbfp;
621     vdwtype          = mdatoms->typeA;
622
623     vftab            = kernel_data->table_vdw->data;
624     vftabscale       = gmx_fjsp_set1_v2r8(kernel_data->table_vdw->scale);
625
626     /* Setup water-specific parameters */
627     inr              = nlist->iinr[0];
628     iq0              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+0]));
629     iq1              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+1]));
630     iq2              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+2]));
631     vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
632
633     /* Avoid stupid compiler warnings */
634     jnrA = jnrB = 0;
635     j_coord_offsetA = 0;
636     j_coord_offsetB = 0;
637
638     outeriter        = 0;
639     inneriter        = 0;
640
641     /* Start outer loop over neighborlists */
642     for(iidx=0; iidx<nri; iidx++)
643     {
644         /* Load shift vector for this list */
645         i_shift_offset   = DIM*shiftidx[iidx];
646
647         /* Load limits for loop over neighbors */
648         j_index_start    = jindex[iidx];
649         j_index_end      = jindex[iidx+1];
650
651         /* Get outer coordinate index */
652         inr              = iinr[iidx];
653         i_coord_offset   = DIM*inr;
654
655         /* Load i particle coords and add shift vector */
656         gmx_fjsp_load_shift_and_3rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,
657                                                  &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
658
659         fix0             = _fjsp_setzero_v2r8();
660         fiy0             = _fjsp_setzero_v2r8();
661         fiz0             = _fjsp_setzero_v2r8();
662         fix1             = _fjsp_setzero_v2r8();
663         fiy1             = _fjsp_setzero_v2r8();
664         fiz1             = _fjsp_setzero_v2r8();
665         fix2             = _fjsp_setzero_v2r8();
666         fiy2             = _fjsp_setzero_v2r8();
667         fiz2             = _fjsp_setzero_v2r8();
668
669         /* Start inner kernel loop */
670         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
671         {
672
673             /* Get j neighbor index, and coordinate index */
674             jnrA             = jjnr[jidx];
675             jnrB             = jjnr[jidx+1];
676             j_coord_offsetA  = DIM*jnrA;
677             j_coord_offsetB  = DIM*jnrB;
678
679             /* load j atom coordinates */
680             gmx_fjsp_load_1rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
681                                               &jx0,&jy0,&jz0);
682
683             /* Calculate displacement vector */
684             dx00             = _fjsp_sub_v2r8(ix0,jx0);
685             dy00             = _fjsp_sub_v2r8(iy0,jy0);
686             dz00             = _fjsp_sub_v2r8(iz0,jz0);
687             dx10             = _fjsp_sub_v2r8(ix1,jx0);
688             dy10             = _fjsp_sub_v2r8(iy1,jy0);
689             dz10             = _fjsp_sub_v2r8(iz1,jz0);
690             dx20             = _fjsp_sub_v2r8(ix2,jx0);
691             dy20             = _fjsp_sub_v2r8(iy2,jy0);
692             dz20             = _fjsp_sub_v2r8(iz2,jz0);
693
694             /* Calculate squared distance and things based on it */
695             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
696             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
697             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
698
699             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
700             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
701             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
702
703             rinvsq00         = _fjsp_mul_v2r8(rinv00,rinv00);
704             rinvsq10         = _fjsp_mul_v2r8(rinv10,rinv10);
705             rinvsq20         = _fjsp_mul_v2r8(rinv20,rinv20);
706
707             /* Load parameters for j particles */
708             jq0              = gmx_fjsp_load_2real_swizzle_v2r8(charge+jnrA+0,charge+jnrB+0);
709             vdwjidx0A        = 2*vdwtype[jnrA+0];
710             vdwjidx0B        = 2*vdwtype[jnrB+0];
711
712             fjx0             = _fjsp_setzero_v2r8();
713             fjy0             = _fjsp_setzero_v2r8();
714             fjz0             = _fjsp_setzero_v2r8();
715
716             /**************************
717              * CALCULATE INTERACTIONS *
718              **************************/
719
720             r00              = _fjsp_mul_v2r8(rsq00,rinv00);
721
722             /* Compute parameters for interactions between i and j atoms */
723             qq00             = _fjsp_mul_v2r8(iq0,jq0);
724             gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
725                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
726
727             /* Calculate table index by multiplying r with table scale and truncate to integer */
728             rt               = _fjsp_mul_v2r8(r00,vftabscale);
729             itab_tmp         = _fjsp_dtox_v2r8(rt);
730             vfeps            = _fjsp_sub_v2r8(rt, _fjsp_xtod_v2r8(itab_tmp));
731             twovfeps         = _fjsp_add_v2r8(vfeps,vfeps);
732             _fjsp_store_v2r8(&vfconv.simd,itab_tmp);
733
734             vfconv.i[0]     *= 8;
735             vfconv.i[1]     *= 8;
736
737             /* REACTION-FIELD ELECTROSTATICS */
738             felec            = _fjsp_mul_v2r8(qq00,_fjsp_msub_v2r8(rinv00,rinvsq00,krf2));
739
740             /* CUBIC SPLINE TABLE DISPERSION */
741             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] );
742             F                = _fjsp_load_v2r8( vftab + vfconv.i[1] );
743             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
744             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 2 );
745             H                = _fjsp_load_v2r8( vftab + vfconv.i[1] + 2 );
746             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
747             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
748             FF               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
749             fvdw6            = _fjsp_mul_v2r8(c6_00,FF);
750
751             /* CUBIC SPLINE TABLE REPULSION */
752             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 4 );
753             F                = _fjsp_load_v2r8( vftab + vfconv.i[1] + 4 );
754             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
755             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 6 );
756             H                = _fjsp_load_v2r8( vftab + vfconv.i[1] + 6 );
757             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
758             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
759             FF               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
760             fvdw12           = _fjsp_mul_v2r8(c12_00,FF);
761             fvdw             = _fjsp_neg_v2r8(_fjsp_mul_v2r8(_fjsp_add_v2r8(fvdw6,fvdw12),_fjsp_mul_v2r8(vftabscale,rinv00)));
762
763             fscal            = _fjsp_add_v2r8(felec,fvdw);
764
765             /* Update vectorial force */
766             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
767             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
768             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
769             
770             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
771             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
772             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
773
774             /**************************
775              * CALCULATE INTERACTIONS *
776              **************************/
777
778             /* Compute parameters for interactions between i and j atoms */
779             qq10             = _fjsp_mul_v2r8(iq1,jq0);
780
781             /* REACTION-FIELD ELECTROSTATICS */
782             felec            = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
783
784             fscal            = felec;
785
786             /* Update vectorial force */
787             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
788             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
789             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
790             
791             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
792             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
793             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
794
795             /**************************
796              * CALCULATE INTERACTIONS *
797              **************************/
798
799             /* Compute parameters for interactions between i and j atoms */
800             qq20             = _fjsp_mul_v2r8(iq2,jq0);
801
802             /* REACTION-FIELD ELECTROSTATICS */
803             felec            = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
804
805             fscal            = felec;
806
807             /* Update vectorial force */
808             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
809             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
810             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
811             
812             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
813             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
814             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
815
816             gmx_fjsp_decrement_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
817
818             /* Inner loop uses 120 flops */
819         }
820
821         if(jidx<j_index_end)
822         {
823
824             jnrA             = jjnr[jidx];
825             j_coord_offsetA  = DIM*jnrA;
826
827             /* load j atom coordinates */
828             gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
829                                               &jx0,&jy0,&jz0);
830
831             /* Calculate displacement vector */
832             dx00             = _fjsp_sub_v2r8(ix0,jx0);
833             dy00             = _fjsp_sub_v2r8(iy0,jy0);
834             dz00             = _fjsp_sub_v2r8(iz0,jz0);
835             dx10             = _fjsp_sub_v2r8(ix1,jx0);
836             dy10             = _fjsp_sub_v2r8(iy1,jy0);
837             dz10             = _fjsp_sub_v2r8(iz1,jz0);
838             dx20             = _fjsp_sub_v2r8(ix2,jx0);
839             dy20             = _fjsp_sub_v2r8(iy2,jy0);
840             dz20             = _fjsp_sub_v2r8(iz2,jz0);
841
842             /* Calculate squared distance and things based on it */
843             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
844             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
845             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
846
847             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
848             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
849             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
850
851             rinvsq00         = _fjsp_mul_v2r8(rinv00,rinv00);
852             rinvsq10         = _fjsp_mul_v2r8(rinv10,rinv10);
853             rinvsq20         = _fjsp_mul_v2r8(rinv20,rinv20);
854
855             /* Load parameters for j particles */
856             jq0              = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
857             vdwjidx0A        = 2*vdwtype[jnrA+0];
858
859             fjx0             = _fjsp_setzero_v2r8();
860             fjy0             = _fjsp_setzero_v2r8();
861             fjz0             = _fjsp_setzero_v2r8();
862
863             /**************************
864              * CALCULATE INTERACTIONS *
865              **************************/
866
867             r00              = _fjsp_mul_v2r8(rsq00,rinv00);
868
869             /* Compute parameters for interactions between i and j atoms */
870             qq00             = _fjsp_mul_v2r8(iq0,jq0);
871             gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
872                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
873
874             /* Calculate table index by multiplying r with table scale and truncate to integer */
875             rt               = _fjsp_mul_v2r8(r00,vftabscale);
876             itab_tmp         = _fjsp_dtox_v2r8(rt);
877             vfeps            = _fjsp_sub_v2r8(rt, _fjsp_xtod_v2r8(itab_tmp));
878             twovfeps         = _fjsp_add_v2r8(vfeps,vfeps);
879             _fjsp_store_v2r8(&vfconv.simd,itab_tmp);
880
881             vfconv.i[0]     *= 8;
882             vfconv.i[1]     *= 8;
883
884             /* REACTION-FIELD ELECTROSTATICS */
885             felec            = _fjsp_mul_v2r8(qq00,_fjsp_msub_v2r8(rinv00,rinvsq00,krf2));
886
887             /* CUBIC SPLINE TABLE DISPERSION */
888             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] );
889             F                = _fjsp_setzero_v2r8();
890             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
891             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 2 );
892             H                = _fjsp_setzero_v2r8();
893             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
894             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
895             FF               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
896             fvdw6            = _fjsp_mul_v2r8(c6_00,FF);
897
898             /* CUBIC SPLINE TABLE REPULSION */
899             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 4 );
900             F                = _fjsp_setzero_v2r8();
901             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
902             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 6 );
903             H                = _fjsp_setzero_v2r8();
904             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
905             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
906             FF               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
907             fvdw12           = _fjsp_mul_v2r8(c12_00,FF);
908             fvdw             = _fjsp_neg_v2r8(_fjsp_mul_v2r8(_fjsp_add_v2r8(fvdw6,fvdw12),_fjsp_mul_v2r8(vftabscale,rinv00)));
909
910             fscal            = _fjsp_add_v2r8(felec,fvdw);
911
912             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
913
914             /* Update vectorial force */
915             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
916             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
917             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
918             
919             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
920             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
921             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
922
923             /**************************
924              * CALCULATE INTERACTIONS *
925              **************************/
926
927             /* Compute parameters for interactions between i and j atoms */
928             qq10             = _fjsp_mul_v2r8(iq1,jq0);
929
930             /* REACTION-FIELD ELECTROSTATICS */
931             felec            = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
932
933             fscal            = felec;
934
935             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
936
937             /* Update vectorial force */
938             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
939             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
940             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
941             
942             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
943             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
944             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
945
946             /**************************
947              * CALCULATE INTERACTIONS *
948              **************************/
949
950             /* Compute parameters for interactions between i and j atoms */
951             qq20             = _fjsp_mul_v2r8(iq2,jq0);
952
953             /* REACTION-FIELD ELECTROSTATICS */
954             felec            = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
955
956             fscal            = felec;
957
958             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
959
960             /* Update vectorial force */
961             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
962             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
963             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
964             
965             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
966             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
967             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
968
969             gmx_fjsp_decrement_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fjx0,fjy0,fjz0);
970
971             /* Inner loop uses 120 flops */
972         }
973
974         /* End of innermost loop */
975
976         gmx_fjsp_update_iforce_3atom_swizzle_v2r8(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
977                                               f+i_coord_offset,fshift+i_shift_offset);
978
979         /* Increment number of inner iterations */
980         inneriter                  += j_index_end - j_index_start;
981
982         /* Outer loop uses 18 flops */
983     }
984
985     /* Increment number of outer iterations */
986     outeriter        += nri;
987
988     /* Update outer/inner flops */
989
990     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*18 + inneriter*120);
991 }