Add C++ version of t_ilist
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_sparc64_hpc_ace_double / nb_kernel_ElecRFCut_VdwCSTab_GeomW4P1_sparc64_hpc_ace_double.cpp
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 2012,2013,2014,2015,2017,2018, by the GROMACS development team, led by
5  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6  * and including many others, as listed in the AUTHORS file in the
7  * top-level source directory and at http://www.gromacs.org.
8  *
9  * GROMACS is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public License
11  * as published by the Free Software Foundation; either version 2.1
12  * of the License, or (at your option) any later version.
13  *
14  * GROMACS is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with GROMACS; if not, see
21  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
23  *
24  * If you want to redistribute modifications to GROMACS, please
25  * consider that scientific software is very special. Version
26  * control is crucial - bugs must be traceable. We will be happy to
27  * consider code for inclusion in the official distribution, but
28  * derived work must not be called official GROMACS. Details are found
29  * in the README & COPYING files - if they are missing, get the
30  * official version at http://www.gromacs.org.
31  *
32  * To help us fund GROMACS development, we humbly ask that you cite
33  * the research papers on the package. Check out http://www.gromacs.org.
34  */
35 /*
36  * Note: this file was generated by the GROMACS sparc64_hpc_ace_double kernel generator.
37  */
38 #include "gmxpre.h"
39
40 #include "config.h"
41
42 #include <math.h>
43
44 #include "../nb_kernel.h"
45 #include "gromacs/gmxlib/nrnb.h"
46
47 #include "kernelutil_sparc64_hpc_ace_double.h"
48
49 /*
50  * Gromacs nonbonded kernel:   nb_kernel_ElecRFCut_VdwCSTab_GeomW4P1_VF_sparc64_hpc_ace_double
51  * Electrostatics interaction: ReactionField
52  * VdW interaction:            CubicSplineTable
53  * Geometry:                   Water4-Particle
54  * Calculate force/pot:        PotentialAndForce
55  */
56 void
57 nb_kernel_ElecRFCut_VdwCSTab_GeomW4P1_VF_sparc64_hpc_ace_double
58                     (t_nblist                    * gmx_restrict       nlist,
59                      rvec                        * gmx_restrict          xx,
60                      rvec                        * gmx_restrict          ff,
61                      struct t_forcerec           * gmx_restrict          fr,
62                      t_mdatoms                   * gmx_restrict     mdatoms,
63                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
64                      t_nrnb                      * gmx_restrict        nrnb)
65 {
66     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
67      * just 0 for non-waters.
68      * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
69      * jnr indices corresponding to data put in the four positions in the SIMD register.
70      */
71     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
72     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
73     int              jnrA,jnrB;
74     int              j_coord_offsetA,j_coord_offsetB;
75     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
76     real             rcutoff_scalar;
77     real             *shiftvec,*fshift,*x,*f;
78     _fjsp_v2r8       tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
79     int              vdwioffset0;
80     _fjsp_v2r8       ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
81     int              vdwioffset1;
82     _fjsp_v2r8       ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
83     int              vdwioffset2;
84     _fjsp_v2r8       ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
85     int              vdwioffset3;
86     _fjsp_v2r8       ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
87     int              vdwjidx0A,vdwjidx0B;
88     _fjsp_v2r8       jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
89     _fjsp_v2r8       dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
90     _fjsp_v2r8       dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
91     _fjsp_v2r8       dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
92     _fjsp_v2r8       dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
93     _fjsp_v2r8       velec,felec,velecsum,facel,crf,krf,krf2;
94     real             *charge;
95     int              nvdwtype;
96     _fjsp_v2r8       rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
97     int              *vdwtype;
98     real             *vdwparam;
99     _fjsp_v2r8       one_sixth   = gmx_fjsp_set1_v2r8(1.0/6.0);
100     _fjsp_v2r8       one_twelfth = gmx_fjsp_set1_v2r8(1.0/12.0);
101     _fjsp_v2r8       rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF,twovfeps;
102     real             *vftab;
103     _fjsp_v2r8       itab_tmp;
104     _fjsp_v2r8       dummy_mask,cutoff_mask;
105     _fjsp_v2r8       one     = gmx_fjsp_set1_v2r8(1.0);
106     _fjsp_v2r8       two     = gmx_fjsp_set1_v2r8(2.0);
107     union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
108
109     x                = xx[0];
110     f                = ff[0];
111
112     nri              = nlist->nri;
113     iinr             = nlist->iinr;
114     jindex           = nlist->jindex;
115     jjnr             = nlist->jjnr;
116     shiftidx         = nlist->shift;
117     gid              = nlist->gid;
118     shiftvec         = fr->shift_vec[0];
119     fshift           = fr->fshift[0];
120     facel            = gmx_fjsp_set1_v2r8(fr->ic->epsfac);
121     charge           = mdatoms->chargeA;
122     krf              = gmx_fjsp_set1_v2r8(fr->ic->k_rf);
123     krf2             = gmx_fjsp_set1_v2r8(fr->ic->k_rf*2.0);
124     crf              = gmx_fjsp_set1_v2r8(fr->ic->c_rf);
125     nvdwtype         = fr->ntype;
126     vdwparam         = fr->nbfp;
127     vdwtype          = mdatoms->typeA;
128
129     vftab            = kernel_data->table_vdw->data;
130     vftabscale       = gmx_fjsp_set1_v2r8(kernel_data->table_vdw->scale);
131
132     /* Setup water-specific parameters */
133     inr              = nlist->iinr[0];
134     iq1              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+1]));
135     iq2              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+2]));
136     iq3              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+3]));
137     vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
138
139     /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
140     rcutoff_scalar   = fr->ic->rcoulomb;
141     rcutoff          = gmx_fjsp_set1_v2r8(rcutoff_scalar);
142     rcutoff2         = _fjsp_mul_v2r8(rcutoff,rcutoff);
143
144     /* Avoid stupid compiler warnings */
145     jnrA = jnrB = 0;
146     j_coord_offsetA = 0;
147     j_coord_offsetB = 0;
148
149     outeriter        = 0;
150     inneriter        = 0;
151
152     /* Start outer loop over neighborlists */
153     for(iidx=0; iidx<nri; iidx++)
154     {
155         /* Load shift vector for this list */
156         i_shift_offset   = DIM*shiftidx[iidx];
157
158         /* Load limits for loop over neighbors */
159         j_index_start    = jindex[iidx];
160         j_index_end      = jindex[iidx+1];
161
162         /* Get outer coordinate index */
163         inr              = iinr[iidx];
164         i_coord_offset   = DIM*inr;
165
166         /* Load i particle coords and add shift vector */
167         gmx_fjsp_load_shift_and_4rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,
168                                                  &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
169
170         fix0             = _fjsp_setzero_v2r8();
171         fiy0             = _fjsp_setzero_v2r8();
172         fiz0             = _fjsp_setzero_v2r8();
173         fix1             = _fjsp_setzero_v2r8();
174         fiy1             = _fjsp_setzero_v2r8();
175         fiz1             = _fjsp_setzero_v2r8();
176         fix2             = _fjsp_setzero_v2r8();
177         fiy2             = _fjsp_setzero_v2r8();
178         fiz2             = _fjsp_setzero_v2r8();
179         fix3             = _fjsp_setzero_v2r8();
180         fiy3             = _fjsp_setzero_v2r8();
181         fiz3             = _fjsp_setzero_v2r8();
182
183         /* Reset potential sums */
184         velecsum         = _fjsp_setzero_v2r8();
185         vvdwsum          = _fjsp_setzero_v2r8();
186
187         /* Start inner kernel loop */
188         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
189         {
190
191             /* Get j neighbor index, and coordinate index */
192             jnrA             = jjnr[jidx];
193             jnrB             = jjnr[jidx+1];
194             j_coord_offsetA  = DIM*jnrA;
195             j_coord_offsetB  = DIM*jnrB;
196
197             /* load j atom coordinates */
198             gmx_fjsp_load_1rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
199                                               &jx0,&jy0,&jz0);
200
201             /* Calculate displacement vector */
202             dx00             = _fjsp_sub_v2r8(ix0,jx0);
203             dy00             = _fjsp_sub_v2r8(iy0,jy0);
204             dz00             = _fjsp_sub_v2r8(iz0,jz0);
205             dx10             = _fjsp_sub_v2r8(ix1,jx0);
206             dy10             = _fjsp_sub_v2r8(iy1,jy0);
207             dz10             = _fjsp_sub_v2r8(iz1,jz0);
208             dx20             = _fjsp_sub_v2r8(ix2,jx0);
209             dy20             = _fjsp_sub_v2r8(iy2,jy0);
210             dz20             = _fjsp_sub_v2r8(iz2,jz0);
211             dx30             = _fjsp_sub_v2r8(ix3,jx0);
212             dy30             = _fjsp_sub_v2r8(iy3,jy0);
213             dz30             = _fjsp_sub_v2r8(iz3,jz0);
214
215             /* Calculate squared distance and things based on it */
216             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
217             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
218             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
219             rsq30            = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
220
221             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
222             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
223             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
224             rinv30           = gmx_fjsp_invsqrt_v2r8(rsq30);
225
226             rinvsq10         = _fjsp_mul_v2r8(rinv10,rinv10);
227             rinvsq20         = _fjsp_mul_v2r8(rinv20,rinv20);
228             rinvsq30         = _fjsp_mul_v2r8(rinv30,rinv30);
229
230             /* Load parameters for j particles */
231             jq0              = gmx_fjsp_load_2real_swizzle_v2r8(charge+jnrA+0,charge+jnrB+0);
232             vdwjidx0A        = 2*vdwtype[jnrA+0];
233             vdwjidx0B        = 2*vdwtype[jnrB+0];
234
235             fjx0             = _fjsp_setzero_v2r8();
236             fjy0             = _fjsp_setzero_v2r8();
237             fjz0             = _fjsp_setzero_v2r8();
238
239             /**************************
240              * CALCULATE INTERACTIONS *
241              **************************/
242
243             r00              = _fjsp_mul_v2r8(rsq00,rinv00);
244
245             /* Compute parameters for interactions between i and j atoms */
246             gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
247                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
248
249             /* Calculate table index by multiplying r with table scale and truncate to integer */
250             rt               = _fjsp_mul_v2r8(r00,vftabscale);
251             itab_tmp         = _fjsp_dtox_v2r8(rt);
252             vfeps            = _fjsp_sub_v2r8(rt, _fjsp_xtod_v2r8(itab_tmp));
253             twovfeps         = _fjsp_add_v2r8(vfeps,vfeps);
254             _fjsp_store_v2r8(&vfconv.simd,itab_tmp);
255
256             vfconv.i[0]     *= 8;
257             vfconv.i[1]     *= 8;
258
259             /* CUBIC SPLINE TABLE DISPERSION */
260             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] );
261             F                = _fjsp_load_v2r8( vftab + vfconv.i[1] );
262             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
263             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 2 );
264             H                = _fjsp_load_v2r8( vftab + vfconv.i[1] + 2 );
265             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
266             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
267             VV               = _fjsp_madd_v2r8(vfeps,Fp,Y);
268             vvdw6            = _fjsp_mul_v2r8(c6_00,VV);
269             FF               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
270             fvdw6            = _fjsp_mul_v2r8(c6_00,FF);
271
272             /* CUBIC SPLINE TABLE REPULSION */
273             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 4 );
274             F                = _fjsp_load_v2r8( vftab + vfconv.i[1] + 4 );
275             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
276             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 6 );
277             H                = _fjsp_load_v2r8( vftab + vfconv.i[1] + 6 );
278             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
279             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
280             VV               = _fjsp_madd_v2r8(vfeps,Fp,Y);
281             vvdw12           = _fjsp_mul_v2r8(c12_00,VV);
282             FF               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
283             fvdw12           = _fjsp_mul_v2r8(c12_00,FF);
284             vvdw             = _fjsp_add_v2r8(vvdw12,vvdw6);
285             fvdw             = _fjsp_neg_v2r8(_fjsp_mul_v2r8(_fjsp_add_v2r8(fvdw6,fvdw12),_fjsp_mul_v2r8(vftabscale,rinv00)));
286
287             /* Update potential sum for this i atom from the interaction with this j atom. */
288             vvdwsum          = _fjsp_add_v2r8(vvdwsum,vvdw);
289
290             fscal            = fvdw;
291
292             /* Update vectorial force */
293             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
294             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
295             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
296             
297             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
298             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
299             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
300
301             /**************************
302              * CALCULATE INTERACTIONS *
303              **************************/
304
305             if (gmx_fjsp_any_lt_v2r8(rsq10,rcutoff2))
306             {
307
308             /* Compute parameters for interactions between i and j atoms */
309             qq10             = _fjsp_mul_v2r8(iq1,jq0);
310
311             /* REACTION-FIELD ELECTROSTATICS */
312             velec            = _fjsp_mul_v2r8(qq10,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq10,rinv10),crf));
313             felec            = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
314
315             cutoff_mask      = _fjsp_cmplt_v2r8(rsq10,rcutoff2);
316
317             /* Update potential sum for this i atom from the interaction with this j atom. */
318             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
319             velecsum         = _fjsp_add_v2r8(velecsum,velec);
320
321             fscal            = felec;
322
323             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
324
325             /* Update vectorial force */
326             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
327             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
328             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
329             
330             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
331             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
332             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
333
334             }
335
336             /**************************
337              * CALCULATE INTERACTIONS *
338              **************************/
339
340             if (gmx_fjsp_any_lt_v2r8(rsq20,rcutoff2))
341             {
342
343             /* Compute parameters for interactions between i and j atoms */
344             qq20             = _fjsp_mul_v2r8(iq2,jq0);
345
346             /* REACTION-FIELD ELECTROSTATICS */
347             velec            = _fjsp_mul_v2r8(qq20,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq20,rinv20),crf));
348             felec            = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
349
350             cutoff_mask      = _fjsp_cmplt_v2r8(rsq20,rcutoff2);
351
352             /* Update potential sum for this i atom from the interaction with this j atom. */
353             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
354             velecsum         = _fjsp_add_v2r8(velecsum,velec);
355
356             fscal            = felec;
357
358             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
359
360             /* Update vectorial force */
361             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
362             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
363             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
364             
365             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
366             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
367             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
368
369             }
370
371             /**************************
372              * CALCULATE INTERACTIONS *
373              **************************/
374
375             if (gmx_fjsp_any_lt_v2r8(rsq30,rcutoff2))
376             {
377
378             /* Compute parameters for interactions between i and j atoms */
379             qq30             = _fjsp_mul_v2r8(iq3,jq0);
380
381             /* REACTION-FIELD ELECTROSTATICS */
382             velec            = _fjsp_mul_v2r8(qq30,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq30,rinv30),crf));
383             felec            = _fjsp_mul_v2r8(qq30,_fjsp_msub_v2r8(rinv30,rinvsq30,krf2));
384
385             cutoff_mask      = _fjsp_cmplt_v2r8(rsq30,rcutoff2);
386
387             /* Update potential sum for this i atom from the interaction with this j atom. */
388             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
389             velecsum         = _fjsp_add_v2r8(velecsum,velec);
390
391             fscal            = felec;
392
393             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
394
395             /* Update vectorial force */
396             fix3             = _fjsp_madd_v2r8(dx30,fscal,fix3);
397             fiy3             = _fjsp_madd_v2r8(dy30,fscal,fiy3);
398             fiz3             = _fjsp_madd_v2r8(dz30,fscal,fiz3);
399             
400             fjx0             = _fjsp_madd_v2r8(dx30,fscal,fjx0);
401             fjy0             = _fjsp_madd_v2r8(dy30,fscal,fjy0);
402             fjz0             = _fjsp_madd_v2r8(dz30,fscal,fjz0);
403
404             }
405
406             gmx_fjsp_decrement_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
407
408             /* Inner loop uses 179 flops */
409         }
410
411         if(jidx<j_index_end)
412         {
413
414             jnrA             = jjnr[jidx];
415             j_coord_offsetA  = DIM*jnrA;
416
417             /* load j atom coordinates */
418             gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
419                                               &jx0,&jy0,&jz0);
420
421             /* Calculate displacement vector */
422             dx00             = _fjsp_sub_v2r8(ix0,jx0);
423             dy00             = _fjsp_sub_v2r8(iy0,jy0);
424             dz00             = _fjsp_sub_v2r8(iz0,jz0);
425             dx10             = _fjsp_sub_v2r8(ix1,jx0);
426             dy10             = _fjsp_sub_v2r8(iy1,jy0);
427             dz10             = _fjsp_sub_v2r8(iz1,jz0);
428             dx20             = _fjsp_sub_v2r8(ix2,jx0);
429             dy20             = _fjsp_sub_v2r8(iy2,jy0);
430             dz20             = _fjsp_sub_v2r8(iz2,jz0);
431             dx30             = _fjsp_sub_v2r8(ix3,jx0);
432             dy30             = _fjsp_sub_v2r8(iy3,jy0);
433             dz30             = _fjsp_sub_v2r8(iz3,jz0);
434
435             /* Calculate squared distance and things based on it */
436             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
437             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
438             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
439             rsq30            = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
440
441             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
442             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
443             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
444             rinv30           = gmx_fjsp_invsqrt_v2r8(rsq30);
445
446             rinvsq10         = _fjsp_mul_v2r8(rinv10,rinv10);
447             rinvsq20         = _fjsp_mul_v2r8(rinv20,rinv20);
448             rinvsq30         = _fjsp_mul_v2r8(rinv30,rinv30);
449
450             /* Load parameters for j particles */
451             jq0              = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
452             vdwjidx0A        = 2*vdwtype[jnrA+0];
453
454             fjx0             = _fjsp_setzero_v2r8();
455             fjy0             = _fjsp_setzero_v2r8();
456             fjz0             = _fjsp_setzero_v2r8();
457
458             /**************************
459              * CALCULATE INTERACTIONS *
460              **************************/
461
462             r00              = _fjsp_mul_v2r8(rsq00,rinv00);
463
464             /* Compute parameters for interactions between i and j atoms */
465             gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
466                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
467
468             /* Calculate table index by multiplying r with table scale and truncate to integer */
469             rt               = _fjsp_mul_v2r8(r00,vftabscale);
470             itab_tmp         = _fjsp_dtox_v2r8(rt);
471             vfeps            = _fjsp_sub_v2r8(rt, _fjsp_xtod_v2r8(itab_tmp));
472             twovfeps         = _fjsp_add_v2r8(vfeps,vfeps);
473             _fjsp_store_v2r8(&vfconv.simd,itab_tmp);
474
475             vfconv.i[0]     *= 8;
476             vfconv.i[1]     *= 8;
477
478             /* CUBIC SPLINE TABLE DISPERSION */
479             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] );
480             F                = _fjsp_setzero_v2r8();
481             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
482             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 2 );
483             H                = _fjsp_setzero_v2r8();
484             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
485             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
486             VV               = _fjsp_madd_v2r8(vfeps,Fp,Y);
487             vvdw6            = _fjsp_mul_v2r8(c6_00,VV);
488             FF               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
489             fvdw6            = _fjsp_mul_v2r8(c6_00,FF);
490
491             /* CUBIC SPLINE TABLE REPULSION */
492             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 4 );
493             F                = _fjsp_setzero_v2r8();
494             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
495             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 6 );
496             H                = _fjsp_setzero_v2r8();
497             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
498             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
499             VV               = _fjsp_madd_v2r8(vfeps,Fp,Y);
500             vvdw12           = _fjsp_mul_v2r8(c12_00,VV);
501             FF               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
502             fvdw12           = _fjsp_mul_v2r8(c12_00,FF);
503             vvdw             = _fjsp_add_v2r8(vvdw12,vvdw6);
504             fvdw             = _fjsp_neg_v2r8(_fjsp_mul_v2r8(_fjsp_add_v2r8(fvdw6,fvdw12),_fjsp_mul_v2r8(vftabscale,rinv00)));
505
506             /* Update potential sum for this i atom from the interaction with this j atom. */
507             vvdw             = _fjsp_unpacklo_v2r8(vvdw,_fjsp_setzero_v2r8());
508             vvdwsum          = _fjsp_add_v2r8(vvdwsum,vvdw);
509
510             fscal            = fvdw;
511
512             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
513
514             /* Update vectorial force */
515             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
516             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
517             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
518             
519             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
520             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
521             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
522
523             /**************************
524              * CALCULATE INTERACTIONS *
525              **************************/
526
527             if (gmx_fjsp_any_lt_v2r8(rsq10,rcutoff2))
528             {
529
530             /* Compute parameters for interactions between i and j atoms */
531             qq10             = _fjsp_mul_v2r8(iq1,jq0);
532
533             /* REACTION-FIELD ELECTROSTATICS */
534             velec            = _fjsp_mul_v2r8(qq10,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq10,rinv10),crf));
535             felec            = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
536
537             cutoff_mask      = _fjsp_cmplt_v2r8(rsq10,rcutoff2);
538
539             /* Update potential sum for this i atom from the interaction with this j atom. */
540             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
541             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
542             velecsum         = _fjsp_add_v2r8(velecsum,velec);
543
544             fscal            = felec;
545
546             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
547
548             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
549
550             /* Update vectorial force */
551             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
552             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
553             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
554             
555             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
556             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
557             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
558
559             }
560
561             /**************************
562              * CALCULATE INTERACTIONS *
563              **************************/
564
565             if (gmx_fjsp_any_lt_v2r8(rsq20,rcutoff2))
566             {
567
568             /* Compute parameters for interactions between i and j atoms */
569             qq20             = _fjsp_mul_v2r8(iq2,jq0);
570
571             /* REACTION-FIELD ELECTROSTATICS */
572             velec            = _fjsp_mul_v2r8(qq20,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq20,rinv20),crf));
573             felec            = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
574
575             cutoff_mask      = _fjsp_cmplt_v2r8(rsq20,rcutoff2);
576
577             /* Update potential sum for this i atom from the interaction with this j atom. */
578             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
579             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
580             velecsum         = _fjsp_add_v2r8(velecsum,velec);
581
582             fscal            = felec;
583
584             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
585
586             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
587
588             /* Update vectorial force */
589             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
590             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
591             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
592             
593             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
594             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
595             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
596
597             }
598
599             /**************************
600              * CALCULATE INTERACTIONS *
601              **************************/
602
603             if (gmx_fjsp_any_lt_v2r8(rsq30,rcutoff2))
604             {
605
606             /* Compute parameters for interactions between i and j atoms */
607             qq30             = _fjsp_mul_v2r8(iq3,jq0);
608
609             /* REACTION-FIELD ELECTROSTATICS */
610             velec            = _fjsp_mul_v2r8(qq30,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq30,rinv30),crf));
611             felec            = _fjsp_mul_v2r8(qq30,_fjsp_msub_v2r8(rinv30,rinvsq30,krf2));
612
613             cutoff_mask      = _fjsp_cmplt_v2r8(rsq30,rcutoff2);
614
615             /* Update potential sum for this i atom from the interaction with this j atom. */
616             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
617             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
618             velecsum         = _fjsp_add_v2r8(velecsum,velec);
619
620             fscal            = felec;
621
622             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
623
624             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
625
626             /* Update vectorial force */
627             fix3             = _fjsp_madd_v2r8(dx30,fscal,fix3);
628             fiy3             = _fjsp_madd_v2r8(dy30,fscal,fiy3);
629             fiz3             = _fjsp_madd_v2r8(dz30,fscal,fiz3);
630             
631             fjx0             = _fjsp_madd_v2r8(dx30,fscal,fjx0);
632             fjy0             = _fjsp_madd_v2r8(dy30,fscal,fjy0);
633             fjz0             = _fjsp_madd_v2r8(dz30,fscal,fjz0);
634
635             }
636
637             gmx_fjsp_decrement_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fjx0,fjy0,fjz0);
638
639             /* Inner loop uses 179 flops */
640         }
641
642         /* End of innermost loop */
643
644         gmx_fjsp_update_iforce_4atom_swizzle_v2r8(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
645                                               f+i_coord_offset,fshift+i_shift_offset);
646
647         ggid                        = gid[iidx];
648         /* Update potential energies */
649         gmx_fjsp_update_1pot_v2r8(velecsum,kernel_data->energygrp_elec+ggid);
650         gmx_fjsp_update_1pot_v2r8(vvdwsum,kernel_data->energygrp_vdw+ggid);
651
652         /* Increment number of inner iterations */
653         inneriter                  += j_index_end - j_index_start;
654
655         /* Outer loop uses 26 flops */
656     }
657
658     /* Increment number of outer iterations */
659     outeriter        += nri;
660
661     /* Update outer/inner flops */
662
663     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*26 + inneriter*179);
664 }
665 /*
666  * Gromacs nonbonded kernel:   nb_kernel_ElecRFCut_VdwCSTab_GeomW4P1_F_sparc64_hpc_ace_double
667  * Electrostatics interaction: ReactionField
668  * VdW interaction:            CubicSplineTable
669  * Geometry:                   Water4-Particle
670  * Calculate force/pot:        Force
671  */
672 void
673 nb_kernel_ElecRFCut_VdwCSTab_GeomW4P1_F_sparc64_hpc_ace_double
674                     (t_nblist                    * gmx_restrict       nlist,
675                      rvec                        * gmx_restrict          xx,
676                      rvec                        * gmx_restrict          ff,
677                      struct t_forcerec           * gmx_restrict          fr,
678                      t_mdatoms                   * gmx_restrict     mdatoms,
679                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
680                      t_nrnb                      * gmx_restrict        nrnb)
681 {
682     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
683      * just 0 for non-waters.
684      * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
685      * jnr indices corresponding to data put in the four positions in the SIMD register.
686      */
687     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
688     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
689     int              jnrA,jnrB;
690     int              j_coord_offsetA,j_coord_offsetB;
691     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
692     real             rcutoff_scalar;
693     real             *shiftvec,*fshift,*x,*f;
694     _fjsp_v2r8       tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
695     int              vdwioffset0;
696     _fjsp_v2r8       ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
697     int              vdwioffset1;
698     _fjsp_v2r8       ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
699     int              vdwioffset2;
700     _fjsp_v2r8       ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
701     int              vdwioffset3;
702     _fjsp_v2r8       ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
703     int              vdwjidx0A,vdwjidx0B;
704     _fjsp_v2r8       jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
705     _fjsp_v2r8       dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
706     _fjsp_v2r8       dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
707     _fjsp_v2r8       dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
708     _fjsp_v2r8       dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
709     _fjsp_v2r8       velec,felec,velecsum,facel,crf,krf,krf2;
710     real             *charge;
711     int              nvdwtype;
712     _fjsp_v2r8       rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
713     int              *vdwtype;
714     real             *vdwparam;
715     _fjsp_v2r8       one_sixth   = gmx_fjsp_set1_v2r8(1.0/6.0);
716     _fjsp_v2r8       one_twelfth = gmx_fjsp_set1_v2r8(1.0/12.0);
717     _fjsp_v2r8       rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF,twovfeps;
718     real             *vftab;
719     _fjsp_v2r8       itab_tmp;
720     _fjsp_v2r8       dummy_mask,cutoff_mask;
721     _fjsp_v2r8       one     = gmx_fjsp_set1_v2r8(1.0);
722     _fjsp_v2r8       two     = gmx_fjsp_set1_v2r8(2.0);
723     union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
724
725     x                = xx[0];
726     f                = ff[0];
727
728     nri              = nlist->nri;
729     iinr             = nlist->iinr;
730     jindex           = nlist->jindex;
731     jjnr             = nlist->jjnr;
732     shiftidx         = nlist->shift;
733     gid              = nlist->gid;
734     shiftvec         = fr->shift_vec[0];
735     fshift           = fr->fshift[0];
736     facel            = gmx_fjsp_set1_v2r8(fr->ic->epsfac);
737     charge           = mdatoms->chargeA;
738     krf              = gmx_fjsp_set1_v2r8(fr->ic->k_rf);
739     krf2             = gmx_fjsp_set1_v2r8(fr->ic->k_rf*2.0);
740     crf              = gmx_fjsp_set1_v2r8(fr->ic->c_rf);
741     nvdwtype         = fr->ntype;
742     vdwparam         = fr->nbfp;
743     vdwtype          = mdatoms->typeA;
744
745     vftab            = kernel_data->table_vdw->data;
746     vftabscale       = gmx_fjsp_set1_v2r8(kernel_data->table_vdw->scale);
747
748     /* Setup water-specific parameters */
749     inr              = nlist->iinr[0];
750     iq1              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+1]));
751     iq2              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+2]));
752     iq3              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+3]));
753     vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
754
755     /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
756     rcutoff_scalar   = fr->ic->rcoulomb;
757     rcutoff          = gmx_fjsp_set1_v2r8(rcutoff_scalar);
758     rcutoff2         = _fjsp_mul_v2r8(rcutoff,rcutoff);
759
760     /* Avoid stupid compiler warnings */
761     jnrA = jnrB = 0;
762     j_coord_offsetA = 0;
763     j_coord_offsetB = 0;
764
765     outeriter        = 0;
766     inneriter        = 0;
767
768     /* Start outer loop over neighborlists */
769     for(iidx=0; iidx<nri; iidx++)
770     {
771         /* Load shift vector for this list */
772         i_shift_offset   = DIM*shiftidx[iidx];
773
774         /* Load limits for loop over neighbors */
775         j_index_start    = jindex[iidx];
776         j_index_end      = jindex[iidx+1];
777
778         /* Get outer coordinate index */
779         inr              = iinr[iidx];
780         i_coord_offset   = DIM*inr;
781
782         /* Load i particle coords and add shift vector */
783         gmx_fjsp_load_shift_and_4rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,
784                                                  &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
785
786         fix0             = _fjsp_setzero_v2r8();
787         fiy0             = _fjsp_setzero_v2r8();
788         fiz0             = _fjsp_setzero_v2r8();
789         fix1             = _fjsp_setzero_v2r8();
790         fiy1             = _fjsp_setzero_v2r8();
791         fiz1             = _fjsp_setzero_v2r8();
792         fix2             = _fjsp_setzero_v2r8();
793         fiy2             = _fjsp_setzero_v2r8();
794         fiz2             = _fjsp_setzero_v2r8();
795         fix3             = _fjsp_setzero_v2r8();
796         fiy3             = _fjsp_setzero_v2r8();
797         fiz3             = _fjsp_setzero_v2r8();
798
799         /* Start inner kernel loop */
800         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
801         {
802
803             /* Get j neighbor index, and coordinate index */
804             jnrA             = jjnr[jidx];
805             jnrB             = jjnr[jidx+1];
806             j_coord_offsetA  = DIM*jnrA;
807             j_coord_offsetB  = DIM*jnrB;
808
809             /* load j atom coordinates */
810             gmx_fjsp_load_1rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
811                                               &jx0,&jy0,&jz0);
812
813             /* Calculate displacement vector */
814             dx00             = _fjsp_sub_v2r8(ix0,jx0);
815             dy00             = _fjsp_sub_v2r8(iy0,jy0);
816             dz00             = _fjsp_sub_v2r8(iz0,jz0);
817             dx10             = _fjsp_sub_v2r8(ix1,jx0);
818             dy10             = _fjsp_sub_v2r8(iy1,jy0);
819             dz10             = _fjsp_sub_v2r8(iz1,jz0);
820             dx20             = _fjsp_sub_v2r8(ix2,jx0);
821             dy20             = _fjsp_sub_v2r8(iy2,jy0);
822             dz20             = _fjsp_sub_v2r8(iz2,jz0);
823             dx30             = _fjsp_sub_v2r8(ix3,jx0);
824             dy30             = _fjsp_sub_v2r8(iy3,jy0);
825             dz30             = _fjsp_sub_v2r8(iz3,jz0);
826
827             /* Calculate squared distance and things based on it */
828             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
829             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
830             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
831             rsq30            = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
832
833             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
834             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
835             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
836             rinv30           = gmx_fjsp_invsqrt_v2r8(rsq30);
837
838             rinvsq10         = _fjsp_mul_v2r8(rinv10,rinv10);
839             rinvsq20         = _fjsp_mul_v2r8(rinv20,rinv20);
840             rinvsq30         = _fjsp_mul_v2r8(rinv30,rinv30);
841
842             /* Load parameters for j particles */
843             jq0              = gmx_fjsp_load_2real_swizzle_v2r8(charge+jnrA+0,charge+jnrB+0);
844             vdwjidx0A        = 2*vdwtype[jnrA+0];
845             vdwjidx0B        = 2*vdwtype[jnrB+0];
846
847             fjx0             = _fjsp_setzero_v2r8();
848             fjy0             = _fjsp_setzero_v2r8();
849             fjz0             = _fjsp_setzero_v2r8();
850
851             /**************************
852              * CALCULATE INTERACTIONS *
853              **************************/
854
855             r00              = _fjsp_mul_v2r8(rsq00,rinv00);
856
857             /* Compute parameters for interactions between i and j atoms */
858             gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
859                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
860
861             /* Calculate table index by multiplying r with table scale and truncate to integer */
862             rt               = _fjsp_mul_v2r8(r00,vftabscale);
863             itab_tmp         = _fjsp_dtox_v2r8(rt);
864             vfeps            = _fjsp_sub_v2r8(rt, _fjsp_xtod_v2r8(itab_tmp));
865             twovfeps         = _fjsp_add_v2r8(vfeps,vfeps);
866             _fjsp_store_v2r8(&vfconv.simd,itab_tmp);
867
868             vfconv.i[0]     *= 8;
869             vfconv.i[1]     *= 8;
870
871             /* CUBIC SPLINE TABLE DISPERSION */
872             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] );
873             F                = _fjsp_load_v2r8( vftab + vfconv.i[1] );
874             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
875             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 2 );
876             H                = _fjsp_load_v2r8( vftab + vfconv.i[1] + 2 );
877             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
878             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
879             FF               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
880             fvdw6            = _fjsp_mul_v2r8(c6_00,FF);
881
882             /* CUBIC SPLINE TABLE REPULSION */
883             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 4 );
884             F                = _fjsp_load_v2r8( vftab + vfconv.i[1] + 4 );
885             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
886             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 6 );
887             H                = _fjsp_load_v2r8( vftab + vfconv.i[1] + 6 );
888             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
889             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
890             FF               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
891             fvdw12           = _fjsp_mul_v2r8(c12_00,FF);
892             fvdw             = _fjsp_neg_v2r8(_fjsp_mul_v2r8(_fjsp_add_v2r8(fvdw6,fvdw12),_fjsp_mul_v2r8(vftabscale,rinv00)));
893
894             fscal            = fvdw;
895
896             /* Update vectorial force */
897             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
898             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
899             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
900             
901             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
902             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
903             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
904
905             /**************************
906              * CALCULATE INTERACTIONS *
907              **************************/
908
909             if (gmx_fjsp_any_lt_v2r8(rsq10,rcutoff2))
910             {
911
912             /* Compute parameters for interactions between i and j atoms */
913             qq10             = _fjsp_mul_v2r8(iq1,jq0);
914
915             /* REACTION-FIELD ELECTROSTATICS */
916             felec            = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
917
918             cutoff_mask      = _fjsp_cmplt_v2r8(rsq10,rcutoff2);
919
920             fscal            = felec;
921
922             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
923
924             /* Update vectorial force */
925             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
926             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
927             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
928             
929             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
930             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
931             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
932
933             }
934
935             /**************************
936              * CALCULATE INTERACTIONS *
937              **************************/
938
939             if (gmx_fjsp_any_lt_v2r8(rsq20,rcutoff2))
940             {
941
942             /* Compute parameters for interactions between i and j atoms */
943             qq20             = _fjsp_mul_v2r8(iq2,jq0);
944
945             /* REACTION-FIELD ELECTROSTATICS */
946             felec            = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
947
948             cutoff_mask      = _fjsp_cmplt_v2r8(rsq20,rcutoff2);
949
950             fscal            = felec;
951
952             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
953
954             /* Update vectorial force */
955             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
956             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
957             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
958             
959             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
960             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
961             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
962
963             }
964
965             /**************************
966              * CALCULATE INTERACTIONS *
967              **************************/
968
969             if (gmx_fjsp_any_lt_v2r8(rsq30,rcutoff2))
970             {
971
972             /* Compute parameters for interactions between i and j atoms */
973             qq30             = _fjsp_mul_v2r8(iq3,jq0);
974
975             /* REACTION-FIELD ELECTROSTATICS */
976             felec            = _fjsp_mul_v2r8(qq30,_fjsp_msub_v2r8(rinv30,rinvsq30,krf2));
977
978             cutoff_mask      = _fjsp_cmplt_v2r8(rsq30,rcutoff2);
979
980             fscal            = felec;
981
982             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
983
984             /* Update vectorial force */
985             fix3             = _fjsp_madd_v2r8(dx30,fscal,fix3);
986             fiy3             = _fjsp_madd_v2r8(dy30,fscal,fiy3);
987             fiz3             = _fjsp_madd_v2r8(dz30,fscal,fiz3);
988             
989             fjx0             = _fjsp_madd_v2r8(dx30,fscal,fjx0);
990             fjy0             = _fjsp_madd_v2r8(dy30,fscal,fjy0);
991             fjz0             = _fjsp_madd_v2r8(dz30,fscal,fjz0);
992
993             }
994
995             gmx_fjsp_decrement_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
996
997             /* Inner loop uses 153 flops */
998         }
999
1000         if(jidx<j_index_end)
1001         {
1002
1003             jnrA             = jjnr[jidx];
1004             j_coord_offsetA  = DIM*jnrA;
1005
1006             /* load j atom coordinates */
1007             gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
1008                                               &jx0,&jy0,&jz0);
1009
1010             /* Calculate displacement vector */
1011             dx00             = _fjsp_sub_v2r8(ix0,jx0);
1012             dy00             = _fjsp_sub_v2r8(iy0,jy0);
1013             dz00             = _fjsp_sub_v2r8(iz0,jz0);
1014             dx10             = _fjsp_sub_v2r8(ix1,jx0);
1015             dy10             = _fjsp_sub_v2r8(iy1,jy0);
1016             dz10             = _fjsp_sub_v2r8(iz1,jz0);
1017             dx20             = _fjsp_sub_v2r8(ix2,jx0);
1018             dy20             = _fjsp_sub_v2r8(iy2,jy0);
1019             dz20             = _fjsp_sub_v2r8(iz2,jz0);
1020             dx30             = _fjsp_sub_v2r8(ix3,jx0);
1021             dy30             = _fjsp_sub_v2r8(iy3,jy0);
1022             dz30             = _fjsp_sub_v2r8(iz3,jz0);
1023
1024             /* Calculate squared distance and things based on it */
1025             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
1026             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
1027             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
1028             rsq30            = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
1029
1030             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
1031             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
1032             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
1033             rinv30           = gmx_fjsp_invsqrt_v2r8(rsq30);
1034
1035             rinvsq10         = _fjsp_mul_v2r8(rinv10,rinv10);
1036             rinvsq20         = _fjsp_mul_v2r8(rinv20,rinv20);
1037             rinvsq30         = _fjsp_mul_v2r8(rinv30,rinv30);
1038
1039             /* Load parameters for j particles */
1040             jq0              = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
1041             vdwjidx0A        = 2*vdwtype[jnrA+0];
1042
1043             fjx0             = _fjsp_setzero_v2r8();
1044             fjy0             = _fjsp_setzero_v2r8();
1045             fjz0             = _fjsp_setzero_v2r8();
1046
1047             /**************************
1048              * CALCULATE INTERACTIONS *
1049              **************************/
1050
1051             r00              = _fjsp_mul_v2r8(rsq00,rinv00);
1052
1053             /* Compute parameters for interactions between i and j atoms */
1054             gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
1055                                          vdwparam+vdwioffset0+vdwjidx0B,&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 }