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