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