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