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