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