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