Remove no-inline-max-size and suppress remark
[alexxy/gromacs.git] / src / gromacs / 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,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_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_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              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_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
468                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
469
470             /* Calculate table index by multiplying r with table scale and truncate to integer */
471             rt               = _fjsp_mul_v2r8(r00,vftabscale);
472             itab_tmp         = _fjsp_dtox_v2r8(rt);
473             vfeps            = _fjsp_sub_v2r8(rt, _fjsp_xtod_v2r8(itab_tmp));
474             twovfeps         = _fjsp_add_v2r8(vfeps,vfeps);
475             _fjsp_store_v2r8(&vfconv.simd,itab_tmp);
476
477             vfconv.i[0]     *= 8;
478             vfconv.i[1]     *= 8;
479
480             /* CUBIC SPLINE TABLE DISPERSION */
481             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] );
482             F                = _fjsp_setzero_v2r8();
483             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
484             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 2 );
485             H                = _fjsp_setzero_v2r8();
486             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
487             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
488             VV               = _fjsp_madd_v2r8(vfeps,Fp,Y);
489             vvdw6            = _fjsp_mul_v2r8(c6_00,VV);
490             FF               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
491             fvdw6            = _fjsp_mul_v2r8(c6_00,FF);
492
493             /* CUBIC SPLINE TABLE REPULSION */
494             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 4 );
495             F                = _fjsp_setzero_v2r8();
496             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
497             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 6 );
498             H                = _fjsp_setzero_v2r8();
499             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
500             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
501             VV               = _fjsp_madd_v2r8(vfeps,Fp,Y);
502             vvdw12           = _fjsp_mul_v2r8(c12_00,VV);
503             FF               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
504             fvdw12           = _fjsp_mul_v2r8(c12_00,FF);
505             vvdw             = _fjsp_add_v2r8(vvdw12,vvdw6);
506             fvdw             = _fjsp_neg_v2r8(_fjsp_mul_v2r8(_fjsp_add_v2r8(fvdw6,fvdw12),_fjsp_mul_v2r8(vftabscale,rinv00)));
507
508             /* Update potential sum for this i atom from the interaction with this j atom. */
509             vvdw             = _fjsp_unpacklo_v2r8(vvdw,_fjsp_setzero_v2r8());
510             vvdwsum          = _fjsp_add_v2r8(vvdwsum,vvdw);
511
512             fscal            = fvdw;
513
514             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
515
516             /* Update vectorial force */
517             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
518             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
519             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
520             
521             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
522             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
523             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
524
525             /**************************
526              * CALCULATE INTERACTIONS *
527              **************************/
528
529             if (gmx_fjsp_any_lt_v2r8(rsq10,rcutoff2))
530             {
531
532             /* Compute parameters for interactions between i and j atoms */
533             qq10             = _fjsp_mul_v2r8(iq1,jq0);
534
535             /* REACTION-FIELD ELECTROSTATICS */
536             velec            = _fjsp_mul_v2r8(qq10,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq10,rinv10),crf));
537             felec            = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
538
539             cutoff_mask      = _fjsp_cmplt_v2r8(rsq10,rcutoff2);
540
541             /* Update potential sum for this i atom from the interaction with this j atom. */
542             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
543             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
544             velecsum         = _fjsp_add_v2r8(velecsum,velec);
545
546             fscal            = felec;
547
548             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
549
550             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
551
552             /* Update vectorial force */
553             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
554             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
555             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
556             
557             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
558             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
559             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
560
561             }
562
563             /**************************
564              * CALCULATE INTERACTIONS *
565              **************************/
566
567             if (gmx_fjsp_any_lt_v2r8(rsq20,rcutoff2))
568             {
569
570             /* Compute parameters for interactions between i and j atoms */
571             qq20             = _fjsp_mul_v2r8(iq2,jq0);
572
573             /* REACTION-FIELD ELECTROSTATICS */
574             velec            = _fjsp_mul_v2r8(qq20,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq20,rinv20),crf));
575             felec            = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
576
577             cutoff_mask      = _fjsp_cmplt_v2r8(rsq20,rcutoff2);
578
579             /* Update potential sum for this i atom from the interaction with this j atom. */
580             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
581             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
582             velecsum         = _fjsp_add_v2r8(velecsum,velec);
583
584             fscal            = felec;
585
586             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
587
588             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
589
590             /* Update vectorial force */
591             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
592             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
593             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
594             
595             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
596             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
597             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
598
599             }
600
601             /**************************
602              * CALCULATE INTERACTIONS *
603              **************************/
604
605             if (gmx_fjsp_any_lt_v2r8(rsq30,rcutoff2))
606             {
607
608             /* Compute parameters for interactions between i and j atoms */
609             qq30             = _fjsp_mul_v2r8(iq3,jq0);
610
611             /* REACTION-FIELD ELECTROSTATICS */
612             velec            = _fjsp_mul_v2r8(qq30,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq30,rinv30),crf));
613             felec            = _fjsp_mul_v2r8(qq30,_fjsp_msub_v2r8(rinv30,rinvsq30,krf2));
614
615             cutoff_mask      = _fjsp_cmplt_v2r8(rsq30,rcutoff2);
616
617             /* Update potential sum for this i atom from the interaction with this j atom. */
618             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
619             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
620             velecsum         = _fjsp_add_v2r8(velecsum,velec);
621
622             fscal            = felec;
623
624             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
625
626             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
627
628             /* Update vectorial force */
629             fix3             = _fjsp_madd_v2r8(dx30,fscal,fix3);
630             fiy3             = _fjsp_madd_v2r8(dy30,fscal,fiy3);
631             fiz3             = _fjsp_madd_v2r8(dz30,fscal,fiz3);
632             
633             fjx0             = _fjsp_madd_v2r8(dx30,fscal,fjx0);
634             fjy0             = _fjsp_madd_v2r8(dy30,fscal,fjy0);
635             fjz0             = _fjsp_madd_v2r8(dz30,fscal,fjz0);
636
637             }
638
639             gmx_fjsp_decrement_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fjx0,fjy0,fjz0);
640
641             /* Inner loop uses 179 flops */
642         }
643
644         /* End of innermost loop */
645
646         gmx_fjsp_update_iforce_4atom_swizzle_v2r8(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
647                                               f+i_coord_offset,fshift+i_shift_offset);
648
649         ggid                        = gid[iidx];
650         /* Update potential energies */
651         gmx_fjsp_update_1pot_v2r8(velecsum,kernel_data->energygrp_elec+ggid);
652         gmx_fjsp_update_1pot_v2r8(vvdwsum,kernel_data->energygrp_vdw+ggid);
653
654         /* Increment number of inner iterations */
655         inneriter                  += j_index_end - j_index_start;
656
657         /* Outer loop uses 26 flops */
658     }
659
660     /* Increment number of outer iterations */
661     outeriter        += nri;
662
663     /* Update outer/inner flops */
664
665     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*26 + inneriter*179);
666 }
667 /*
668  * Gromacs nonbonded kernel:   nb_kernel_ElecRFCut_VdwCSTab_GeomW4P1_F_sparc64_hpc_ace_double
669  * Electrostatics interaction: ReactionField
670  * VdW interaction:            CubicSplineTable
671  * Geometry:                   Water4-Particle
672  * Calculate force/pot:        Force
673  */
674 void
675 nb_kernel_ElecRFCut_VdwCSTab_GeomW4P1_F_sparc64_hpc_ace_double
676                     (t_nblist                    * gmx_restrict       nlist,
677                      rvec                        * gmx_restrict          xx,
678                      rvec                        * gmx_restrict          ff,
679                      t_forcerec                  * gmx_restrict          fr,
680                      t_mdatoms                   * gmx_restrict     mdatoms,
681                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
682                      t_nrnb                      * gmx_restrict        nrnb)
683 {
684     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
685      * just 0 for non-waters.
686      * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
687      * jnr indices corresponding to data put in the four positions in the SIMD register.
688      */
689     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
690     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
691     int              jnrA,jnrB;
692     int              j_coord_offsetA,j_coord_offsetB;
693     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
694     real             rcutoff_scalar;
695     real             *shiftvec,*fshift,*x,*f;
696     _fjsp_v2r8       tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
697     int              vdwioffset0;
698     _fjsp_v2r8       ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
699     int              vdwioffset1;
700     _fjsp_v2r8       ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
701     int              vdwioffset2;
702     _fjsp_v2r8       ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
703     int              vdwioffset3;
704     _fjsp_v2r8       ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
705     int              vdwjidx0A,vdwjidx0B;
706     _fjsp_v2r8       jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
707     _fjsp_v2r8       dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
708     _fjsp_v2r8       dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
709     _fjsp_v2r8       dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
710     _fjsp_v2r8       dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
711     _fjsp_v2r8       velec,felec,velecsum,facel,crf,krf,krf2;
712     real             *charge;
713     int              nvdwtype;
714     _fjsp_v2r8       rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
715     int              *vdwtype;
716     real             *vdwparam;
717     _fjsp_v2r8       one_sixth   = gmx_fjsp_set1_v2r8(1.0/6.0);
718     _fjsp_v2r8       one_twelfth = gmx_fjsp_set1_v2r8(1.0/12.0);
719     _fjsp_v2r8       rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF,twovfeps;
720     real             *vftab;
721     _fjsp_v2r8       itab_tmp;
722     _fjsp_v2r8       dummy_mask,cutoff_mask;
723     _fjsp_v2r8       one     = gmx_fjsp_set1_v2r8(1.0);
724     _fjsp_v2r8       two     = gmx_fjsp_set1_v2r8(2.0);
725     union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
726
727     x                = xx[0];
728     f                = ff[0];
729
730     nri              = nlist->nri;
731     iinr             = nlist->iinr;
732     jindex           = nlist->jindex;
733     jjnr             = nlist->jjnr;
734     shiftidx         = nlist->shift;
735     gid              = nlist->gid;
736     shiftvec         = fr->shift_vec[0];
737     fshift           = fr->fshift[0];
738     facel            = gmx_fjsp_set1_v2r8(fr->epsfac);
739     charge           = mdatoms->chargeA;
740     krf              = gmx_fjsp_set1_v2r8(fr->ic->k_rf);
741     krf2             = gmx_fjsp_set1_v2r8(fr->ic->k_rf*2.0);
742     crf              = gmx_fjsp_set1_v2r8(fr->ic->c_rf);
743     nvdwtype         = fr->ntype;
744     vdwparam         = fr->nbfp;
745     vdwtype          = mdatoms->typeA;
746
747     vftab            = kernel_data->table_vdw->data;
748     vftabscale       = gmx_fjsp_set1_v2r8(kernel_data->table_vdw->scale);
749
750     /* Setup water-specific parameters */
751     inr              = nlist->iinr[0];
752     iq1              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+1]));
753     iq2              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+2]));
754     iq3              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+3]));
755     vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
756
757     /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
758     rcutoff_scalar   = fr->rcoulomb;
759     rcutoff          = gmx_fjsp_set1_v2r8(rcutoff_scalar);
760     rcutoff2         = _fjsp_mul_v2r8(rcutoff,rcutoff);
761
762     /* Avoid stupid compiler warnings */
763     jnrA = jnrB = 0;
764     j_coord_offsetA = 0;
765     j_coord_offsetB = 0;
766
767     outeriter        = 0;
768     inneriter        = 0;
769
770     /* Start outer loop over neighborlists */
771     for(iidx=0; iidx<nri; iidx++)
772     {
773         /* Load shift vector for this list */
774         i_shift_offset   = DIM*shiftidx[iidx];
775
776         /* Load limits for loop over neighbors */
777         j_index_start    = jindex[iidx];
778         j_index_end      = jindex[iidx+1];
779
780         /* Get outer coordinate index */
781         inr              = iinr[iidx];
782         i_coord_offset   = DIM*inr;
783
784         /* Load i particle coords and add shift vector */
785         gmx_fjsp_load_shift_and_4rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,
786                                                  &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
787
788         fix0             = _fjsp_setzero_v2r8();
789         fiy0             = _fjsp_setzero_v2r8();
790         fiz0             = _fjsp_setzero_v2r8();
791         fix1             = _fjsp_setzero_v2r8();
792         fiy1             = _fjsp_setzero_v2r8();
793         fiz1             = _fjsp_setzero_v2r8();
794         fix2             = _fjsp_setzero_v2r8();
795         fiy2             = _fjsp_setzero_v2r8();
796         fiz2             = _fjsp_setzero_v2r8();
797         fix3             = _fjsp_setzero_v2r8();
798         fiy3             = _fjsp_setzero_v2r8();
799         fiz3             = _fjsp_setzero_v2r8();
800
801         /* Start inner kernel loop */
802         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
803         {
804
805             /* Get j neighbor index, and coordinate index */
806             jnrA             = jjnr[jidx];
807             jnrB             = jjnr[jidx+1];
808             j_coord_offsetA  = DIM*jnrA;
809             j_coord_offsetB  = DIM*jnrB;
810
811             /* load j atom coordinates */
812             gmx_fjsp_load_1rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
813                                               &jx0,&jy0,&jz0);
814
815             /* Calculate displacement vector */
816             dx00             = _fjsp_sub_v2r8(ix0,jx0);
817             dy00             = _fjsp_sub_v2r8(iy0,jy0);
818             dz00             = _fjsp_sub_v2r8(iz0,jz0);
819             dx10             = _fjsp_sub_v2r8(ix1,jx0);
820             dy10             = _fjsp_sub_v2r8(iy1,jy0);
821             dz10             = _fjsp_sub_v2r8(iz1,jz0);
822             dx20             = _fjsp_sub_v2r8(ix2,jx0);
823             dy20             = _fjsp_sub_v2r8(iy2,jy0);
824             dz20             = _fjsp_sub_v2r8(iz2,jz0);
825             dx30             = _fjsp_sub_v2r8(ix3,jx0);
826             dy30             = _fjsp_sub_v2r8(iy3,jy0);
827             dz30             = _fjsp_sub_v2r8(iz3,jz0);
828
829             /* Calculate squared distance and things based on it */
830             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
831             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
832             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
833             rsq30            = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
834
835             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
836             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
837             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
838             rinv30           = gmx_fjsp_invsqrt_v2r8(rsq30);
839
840             rinvsq10         = _fjsp_mul_v2r8(rinv10,rinv10);
841             rinvsq20         = _fjsp_mul_v2r8(rinv20,rinv20);
842             rinvsq30         = _fjsp_mul_v2r8(rinv30,rinv30);
843
844             /* Load parameters for j particles */
845             jq0              = gmx_fjsp_load_2real_swizzle_v2r8(charge+jnrA+0,charge+jnrB+0);
846             vdwjidx0A        = 2*vdwtype[jnrA+0];
847             vdwjidx0B        = 2*vdwtype[jnrB+0];
848
849             fjx0             = _fjsp_setzero_v2r8();
850             fjy0             = _fjsp_setzero_v2r8();
851             fjz0             = _fjsp_setzero_v2r8();
852
853             /**************************
854              * CALCULATE INTERACTIONS *
855              **************************/
856
857             r00              = _fjsp_mul_v2r8(rsq00,rinv00);
858
859             /* Compute parameters for interactions between i and j atoms */
860             gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
861                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
862
863             /* Calculate table index by multiplying r with table scale and truncate to integer */
864             rt               = _fjsp_mul_v2r8(r00,vftabscale);
865             itab_tmp         = _fjsp_dtox_v2r8(rt);
866             vfeps            = _fjsp_sub_v2r8(rt, _fjsp_xtod_v2r8(itab_tmp));
867             twovfeps         = _fjsp_add_v2r8(vfeps,vfeps);
868             _fjsp_store_v2r8(&vfconv.simd,itab_tmp);
869
870             vfconv.i[0]     *= 8;
871             vfconv.i[1]     *= 8;
872
873             /* CUBIC SPLINE TABLE DISPERSION */
874             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] );
875             F                = _fjsp_load_v2r8( vftab + vfconv.i[1] );
876             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
877             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 2 );
878             H                = _fjsp_load_v2r8( vftab + vfconv.i[1] + 2 );
879             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
880             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
881             FF               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
882             fvdw6            = _fjsp_mul_v2r8(c6_00,FF);
883
884             /* CUBIC SPLINE TABLE REPULSION */
885             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 4 );
886             F                = _fjsp_load_v2r8( vftab + vfconv.i[1] + 4 );
887             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
888             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 6 );
889             H                = _fjsp_load_v2r8( vftab + vfconv.i[1] + 6 );
890             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
891             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
892             FF               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
893             fvdw12           = _fjsp_mul_v2r8(c12_00,FF);
894             fvdw             = _fjsp_neg_v2r8(_fjsp_mul_v2r8(_fjsp_add_v2r8(fvdw6,fvdw12),_fjsp_mul_v2r8(vftabscale,rinv00)));
895
896             fscal            = fvdw;
897
898             /* Update vectorial force */
899             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
900             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
901             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
902             
903             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
904             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
905             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
906
907             /**************************
908              * CALCULATE INTERACTIONS *
909              **************************/
910
911             if (gmx_fjsp_any_lt_v2r8(rsq10,rcutoff2))
912             {
913
914             /* Compute parameters for interactions between i and j atoms */
915             qq10             = _fjsp_mul_v2r8(iq1,jq0);
916
917             /* REACTION-FIELD ELECTROSTATICS */
918             felec            = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
919
920             cutoff_mask      = _fjsp_cmplt_v2r8(rsq10,rcutoff2);
921
922             fscal            = felec;
923
924             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
925
926             /* Update vectorial force */
927             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
928             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
929             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
930             
931             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
932             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
933             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
934
935             }
936
937             /**************************
938              * CALCULATE INTERACTIONS *
939              **************************/
940
941             if (gmx_fjsp_any_lt_v2r8(rsq20,rcutoff2))
942             {
943
944             /* Compute parameters for interactions between i and j atoms */
945             qq20             = _fjsp_mul_v2r8(iq2,jq0);
946
947             /* REACTION-FIELD ELECTROSTATICS */
948             felec            = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
949
950             cutoff_mask      = _fjsp_cmplt_v2r8(rsq20,rcutoff2);
951
952             fscal            = felec;
953
954             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
955
956             /* Update vectorial force */
957             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
958             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
959             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
960             
961             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
962             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
963             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
964
965             }
966
967             /**************************
968              * CALCULATE INTERACTIONS *
969              **************************/
970
971             if (gmx_fjsp_any_lt_v2r8(rsq30,rcutoff2))
972             {
973
974             /* Compute parameters for interactions between i and j atoms */
975             qq30             = _fjsp_mul_v2r8(iq3,jq0);
976
977             /* REACTION-FIELD ELECTROSTATICS */
978             felec            = _fjsp_mul_v2r8(qq30,_fjsp_msub_v2r8(rinv30,rinvsq30,krf2));
979
980             cutoff_mask      = _fjsp_cmplt_v2r8(rsq30,rcutoff2);
981
982             fscal            = felec;
983
984             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
985
986             /* Update vectorial force */
987             fix3             = _fjsp_madd_v2r8(dx30,fscal,fix3);
988             fiy3             = _fjsp_madd_v2r8(dy30,fscal,fiy3);
989             fiz3             = _fjsp_madd_v2r8(dz30,fscal,fiz3);
990             
991             fjx0             = _fjsp_madd_v2r8(dx30,fscal,fjx0);
992             fjy0             = _fjsp_madd_v2r8(dy30,fscal,fjy0);
993             fjz0             = _fjsp_madd_v2r8(dz30,fscal,fjz0);
994
995             }
996
997             gmx_fjsp_decrement_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
998
999             /* Inner loop uses 153 flops */
1000         }
1001
1002         if(jidx<j_index_end)
1003         {
1004
1005             jnrA             = jjnr[jidx];
1006             j_coord_offsetA  = DIM*jnrA;
1007
1008             /* load j atom coordinates */
1009             gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
1010                                               &jx0,&jy0,&jz0);
1011
1012             /* Calculate displacement vector */
1013             dx00             = _fjsp_sub_v2r8(ix0,jx0);
1014             dy00             = _fjsp_sub_v2r8(iy0,jy0);
1015             dz00             = _fjsp_sub_v2r8(iz0,jz0);
1016             dx10             = _fjsp_sub_v2r8(ix1,jx0);
1017             dy10             = _fjsp_sub_v2r8(iy1,jy0);
1018             dz10             = _fjsp_sub_v2r8(iz1,jz0);
1019             dx20             = _fjsp_sub_v2r8(ix2,jx0);
1020             dy20             = _fjsp_sub_v2r8(iy2,jy0);
1021             dz20             = _fjsp_sub_v2r8(iz2,jz0);
1022             dx30             = _fjsp_sub_v2r8(ix3,jx0);
1023             dy30             = _fjsp_sub_v2r8(iy3,jy0);
1024             dz30             = _fjsp_sub_v2r8(iz3,jz0);
1025
1026             /* Calculate squared distance and things based on it */
1027             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
1028             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
1029             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
1030             rsq30            = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
1031
1032             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
1033             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
1034             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
1035             rinv30           = gmx_fjsp_invsqrt_v2r8(rsq30);
1036
1037             rinvsq10         = _fjsp_mul_v2r8(rinv10,rinv10);
1038             rinvsq20         = _fjsp_mul_v2r8(rinv20,rinv20);
1039             rinvsq30         = _fjsp_mul_v2r8(rinv30,rinv30);
1040
1041             /* Load parameters for j particles */
1042             jq0              = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
1043             vdwjidx0A        = 2*vdwtype[jnrA+0];
1044
1045             fjx0             = _fjsp_setzero_v2r8();
1046             fjy0             = _fjsp_setzero_v2r8();
1047             fjz0             = _fjsp_setzero_v2r8();
1048
1049             /**************************
1050              * CALCULATE INTERACTIONS *
1051              **************************/
1052
1053             r00              = _fjsp_mul_v2r8(rsq00,rinv00);
1054
1055             /* Compute parameters for interactions between i and j atoms */
1056             gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
1057                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
1058
1059             /* Calculate table index by multiplying r with table scale and truncate to integer */
1060             rt               = _fjsp_mul_v2r8(r00,vftabscale);
1061             itab_tmp         = _fjsp_dtox_v2r8(rt);
1062             vfeps            = _fjsp_sub_v2r8(rt, _fjsp_xtod_v2r8(itab_tmp));
1063             twovfeps         = _fjsp_add_v2r8(vfeps,vfeps);
1064             _fjsp_store_v2r8(&vfconv.simd,itab_tmp);
1065
1066             vfconv.i[0]     *= 8;
1067             vfconv.i[1]     *= 8;
1068
1069             /* CUBIC SPLINE TABLE DISPERSION */
1070             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] );
1071             F                = _fjsp_setzero_v2r8();
1072             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
1073             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 2 );
1074             H                = _fjsp_setzero_v2r8();
1075             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
1076             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
1077             FF               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
1078             fvdw6            = _fjsp_mul_v2r8(c6_00,FF);
1079
1080             /* CUBIC SPLINE TABLE REPULSION */
1081             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 4 );
1082             F                = _fjsp_setzero_v2r8();
1083             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
1084             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 6 );
1085             H                = _fjsp_setzero_v2r8();
1086             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
1087             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
1088             FF               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
1089             fvdw12           = _fjsp_mul_v2r8(c12_00,FF);
1090             fvdw             = _fjsp_neg_v2r8(_fjsp_mul_v2r8(_fjsp_add_v2r8(fvdw6,fvdw12),_fjsp_mul_v2r8(vftabscale,rinv00)));
1091
1092             fscal            = fvdw;
1093
1094             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1095
1096             /* Update vectorial force */
1097             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
1098             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
1099             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
1100             
1101             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
1102             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
1103             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
1104
1105             /**************************
1106              * CALCULATE INTERACTIONS *
1107              **************************/
1108
1109             if (gmx_fjsp_any_lt_v2r8(rsq10,rcutoff2))
1110             {
1111
1112             /* Compute parameters for interactions between i and j atoms */
1113             qq10             = _fjsp_mul_v2r8(iq1,jq0);
1114
1115             /* REACTION-FIELD ELECTROSTATICS */
1116             felec            = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
1117
1118             cutoff_mask      = _fjsp_cmplt_v2r8(rsq10,rcutoff2);
1119
1120             fscal            = felec;
1121
1122             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1123
1124             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1125
1126             /* Update vectorial force */
1127             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
1128             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
1129             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
1130             
1131             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
1132             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
1133             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
1134
1135             }
1136
1137             /**************************
1138              * CALCULATE INTERACTIONS *
1139              **************************/
1140
1141             if (gmx_fjsp_any_lt_v2r8(rsq20,rcutoff2))
1142             {
1143
1144             /* Compute parameters for interactions between i and j atoms */
1145             qq20             = _fjsp_mul_v2r8(iq2,jq0);
1146
1147             /* REACTION-FIELD ELECTROSTATICS */
1148             felec            = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
1149
1150             cutoff_mask      = _fjsp_cmplt_v2r8(rsq20,rcutoff2);
1151
1152             fscal            = felec;
1153
1154             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1155
1156             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1157
1158             /* Update vectorial force */
1159             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
1160             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
1161             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
1162             
1163             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
1164             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
1165             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
1166
1167             }
1168
1169             /**************************
1170              * CALCULATE INTERACTIONS *
1171              **************************/
1172
1173             if (gmx_fjsp_any_lt_v2r8(rsq30,rcutoff2))
1174             {
1175
1176             /* Compute parameters for interactions between i and j atoms */
1177             qq30             = _fjsp_mul_v2r8(iq3,jq0);
1178
1179             /* REACTION-FIELD ELECTROSTATICS */
1180             felec            = _fjsp_mul_v2r8(qq30,_fjsp_msub_v2r8(rinv30,rinvsq30,krf2));
1181
1182             cutoff_mask      = _fjsp_cmplt_v2r8(rsq30,rcutoff2);
1183
1184             fscal            = felec;
1185
1186             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1187
1188             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1189
1190             /* Update vectorial force */
1191             fix3             = _fjsp_madd_v2r8(dx30,fscal,fix3);
1192             fiy3             = _fjsp_madd_v2r8(dy30,fscal,fiy3);
1193             fiz3             = _fjsp_madd_v2r8(dz30,fscal,fiz3);
1194             
1195             fjx0             = _fjsp_madd_v2r8(dx30,fscal,fjx0);
1196             fjy0             = _fjsp_madd_v2r8(dy30,fscal,fjy0);
1197             fjz0             = _fjsp_madd_v2r8(dz30,fscal,fjz0);
1198
1199             }
1200
1201             gmx_fjsp_decrement_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fjx0,fjy0,fjz0);
1202
1203             /* Inner loop uses 153 flops */
1204         }
1205
1206         /* End of innermost loop */
1207
1208         gmx_fjsp_update_iforce_4atom_swizzle_v2r8(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
1209                                               f+i_coord_offset,fshift+i_shift_offset);
1210
1211         /* Increment number of inner iterations */
1212         inneriter                  += j_index_end - j_index_start;
1213
1214         /* Outer loop uses 24 flops */
1215     }
1216
1217     /* Increment number of outer iterations */
1218     outeriter        += nri;
1219
1220     /* Update outer/inner flops */
1221
1222     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*24 + inneriter*153);
1223 }