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