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