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