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