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