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