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