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