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