Remove all unnecessary HAVE_CONFIG_H
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_avx_128_fma_double / nb_kernel_ElecNone_VdwLJEw_GeomP1P1_avx_128_fma_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 avx_128_fma_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 "gromacs/simd/math_x86_avx_128_fma_double.h"
48 #include "kernelutil_x86_avx_128_fma_double.h"
49
50 /*
51  * Gromacs nonbonded kernel:   nb_kernel_ElecNone_VdwLJEw_GeomP1P1_VF_avx_128_fma_double
52  * Electrostatics interaction: None
53  * VdW interaction:            LJEwald
54  * Geometry:                   Particle-Particle
55  * Calculate force/pot:        PotentialAndForce
56  */
57 void
58 nb_kernel_ElecNone_VdwLJEw_GeomP1P1_VF_avx_128_fma_double
59                     (t_nblist                    * gmx_restrict       nlist,
60                      rvec                        * gmx_restrict          xx,
61                      rvec                        * gmx_restrict          ff,
62                      t_forcerec                  * gmx_restrict          fr,
63                      t_mdatoms                   * gmx_restrict     mdatoms,
64                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
65                      t_nrnb                      * gmx_restrict        nrnb)
66 {
67     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
68      * just 0 for non-waters.
69      * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
70      * jnr indices corresponding to data put in the four positions in the SIMD register.
71      */
72     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
73     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
74     int              jnrA,jnrB;
75     int              j_coord_offsetA,j_coord_offsetB;
76     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
77     real             rcutoff_scalar;
78     real             *shiftvec,*fshift,*x,*f;
79     __m128d          tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
80     int              vdwioffset0;
81     __m128d          ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
82     int              vdwjidx0A,vdwjidx0B;
83     __m128d          jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
84     __m128d          dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
85     int              nvdwtype;
86     __m128d          rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
87     int              *vdwtype;
88     real             *vdwparam;
89     __m128d          one_sixth   = _mm_set1_pd(1.0/6.0);
90     __m128d          one_twelfth = _mm_set1_pd(1.0/12.0);
91     __m128d           c6grid_00;
92     real             *vdwgridparam;
93     __m128d           ewclj,ewclj2,ewclj6,ewcljrsq,poly,exponent,f6A,f6B,sh_lj_ewald;
94     __m128d           one_half  = _mm_set1_pd(0.5);
95     __m128d           minus_one = _mm_set1_pd(-1.0);
96     __m128d          dummy_mask,cutoff_mask;
97     __m128d          signbit   = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
98     __m128d          one     = _mm_set1_pd(1.0);
99     __m128d          two     = _mm_set1_pd(2.0);
100     x                = xx[0];
101     f                = ff[0];
102
103     nri              = nlist->nri;
104     iinr             = nlist->iinr;
105     jindex           = nlist->jindex;
106     jjnr             = nlist->jjnr;
107     shiftidx         = nlist->shift;
108     gid              = nlist->gid;
109     shiftvec         = fr->shift_vec[0];
110     fshift           = fr->fshift[0];
111     nvdwtype         = fr->ntype;
112     vdwparam         = fr->nbfp;
113     vdwtype          = mdatoms->typeA;
114     vdwgridparam     = fr->ljpme_c6grid;
115     sh_lj_ewald      = _mm_set1_pd(fr->ic->sh_lj_ewald);
116     ewclj            = _mm_set1_pd(fr->ewaldcoeff_lj);
117     ewclj2           = _mm_mul_pd(minus_one,_mm_mul_pd(ewclj,ewclj));
118
119     /* Avoid stupid compiler warnings */
120     jnrA = jnrB = 0;
121     j_coord_offsetA = 0;
122     j_coord_offsetB = 0;
123
124     outeriter        = 0;
125     inneriter        = 0;
126
127     /* Start outer loop over neighborlists */
128     for(iidx=0; iidx<nri; iidx++)
129     {
130         /* Load shift vector for this list */
131         i_shift_offset   = DIM*shiftidx[iidx];
132
133         /* Load limits for loop over neighbors */
134         j_index_start    = jindex[iidx];
135         j_index_end      = jindex[iidx+1];
136
137         /* Get outer coordinate index */
138         inr              = iinr[iidx];
139         i_coord_offset   = DIM*inr;
140
141         /* Load i particle coords and add shift vector */
142         gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
143
144         fix0             = _mm_setzero_pd();
145         fiy0             = _mm_setzero_pd();
146         fiz0             = _mm_setzero_pd();
147
148         /* Load parameters for i particles */
149         vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
150
151         /* Reset potential sums */
152         vvdwsum          = _mm_setzero_pd();
153
154         /* Start inner kernel loop */
155         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
156         {
157
158             /* Get j neighbor index, and coordinate index */
159             jnrA             = jjnr[jidx];
160             jnrB             = jjnr[jidx+1];
161             j_coord_offsetA  = DIM*jnrA;
162             j_coord_offsetB  = DIM*jnrB;
163
164             /* load j atom coordinates */
165             gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
166                                               &jx0,&jy0,&jz0);
167
168             /* Calculate displacement vector */
169             dx00             = _mm_sub_pd(ix0,jx0);
170             dy00             = _mm_sub_pd(iy0,jy0);
171             dz00             = _mm_sub_pd(iz0,jz0);
172
173             /* Calculate squared distance and things based on it */
174             rsq00            = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
175
176             rinv00           = gmx_mm_invsqrt_pd(rsq00);
177
178             rinvsq00         = _mm_mul_pd(rinv00,rinv00);
179
180             /* Load parameters for j particles */
181             vdwjidx0A        = 2*vdwtype[jnrA+0];
182             vdwjidx0B        = 2*vdwtype[jnrB+0];
183
184             /**************************
185              * CALCULATE INTERACTIONS *
186              **************************/
187
188             r00              = _mm_mul_pd(rsq00,rinv00);
189
190             /* Compute parameters for interactions between i and j atoms */
191             gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
192                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
193             c6grid_00       = gmx_mm_load_2real_swizzle_pd(vdwgridparam+vdwioffset0+vdwjidx0A,
194                                                                vdwgridparam+vdwioffset0+vdwjidx0B);
195
196             /* Analytical LJ-PME */
197             rinvsix          = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
198             ewcljrsq         = _mm_mul_pd(ewclj2,rsq00);
199             ewclj6           = _mm_mul_pd(ewclj2,_mm_mul_pd(ewclj2,ewclj2));
200             exponent         = gmx_simd_exp_d(ewcljrsq);
201             /* poly = exp(-(beta*r)^2) * (1 + (beta*r)^2 + (beta*r)^4 /2) */
202             poly             = _mm_mul_pd(exponent,_mm_macc_pd(_mm_mul_pd(ewcljrsq,ewcljrsq),one_half,_mm_sub_pd(one,ewcljrsq)));
203             /* vvdw6 = [C6 - C6grid * (1-poly)]/r6 */
204             vvdw6            = _mm_mul_pd(_mm_macc_pd(-c6grid_00,_mm_sub_pd(one,poly),c6_00),rinvsix);
205             vvdw12           = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
206             vvdw             = _mm_msub_pd(vvdw12,one_twelfth,_mm_mul_pd(vvdw6,one_sixth));
207             /* fvdw = vvdw12/r - (vvdw6/r + (C6grid * exponent * beta^6)/r) */
208             fvdw             = _mm_mul_pd(_mm_add_pd(vvdw12,_mm_msub_pd(_mm_mul_pd(c6grid_00,one_sixth),_mm_mul_pd(exponent,ewclj6),vvdw6)),rinvsq00);
209
210             /* Update potential sum for this i atom from the interaction with this j atom. */
211             vvdwsum          = _mm_add_pd(vvdwsum,vvdw);
212
213             fscal            = fvdw;
214
215             /* Update vectorial force */
216             fix0             = _mm_macc_pd(dx00,fscal,fix0);
217             fiy0             = _mm_macc_pd(dy00,fscal,fiy0);
218             fiz0             = _mm_macc_pd(dz00,fscal,fiz0);
219             
220             gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,
221                                                    _mm_mul_pd(dx00,fscal),
222                                                    _mm_mul_pd(dy00,fscal),
223                                                    _mm_mul_pd(dz00,fscal));
224
225             /* Inner loop uses 50 flops */
226         }
227
228         if(jidx<j_index_end)
229         {
230
231             jnrA             = jjnr[jidx];
232             j_coord_offsetA  = DIM*jnrA;
233
234             /* load j atom coordinates */
235             gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
236                                               &jx0,&jy0,&jz0);
237
238             /* Calculate displacement vector */
239             dx00             = _mm_sub_pd(ix0,jx0);
240             dy00             = _mm_sub_pd(iy0,jy0);
241             dz00             = _mm_sub_pd(iz0,jz0);
242
243             /* Calculate squared distance and things based on it */
244             rsq00            = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
245
246             rinv00           = gmx_mm_invsqrt_pd(rsq00);
247
248             rinvsq00         = _mm_mul_pd(rinv00,rinv00);
249
250             /* Load parameters for j particles */
251             vdwjidx0A        = 2*vdwtype[jnrA+0];
252
253             /**************************
254              * CALCULATE INTERACTIONS *
255              **************************/
256
257             r00              = _mm_mul_pd(rsq00,rinv00);
258
259             /* Compute parameters for interactions between i and j atoms */
260             gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
261             c6grid_00       = gmx_mm_load_1real_pd(vdwgridparam+vdwioffset0+vdwjidx0A);
262
263             /* Analytical LJ-PME */
264             rinvsix          = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
265             ewcljrsq         = _mm_mul_pd(ewclj2,rsq00);
266             ewclj6           = _mm_mul_pd(ewclj2,_mm_mul_pd(ewclj2,ewclj2));
267             exponent         = gmx_simd_exp_d(ewcljrsq);
268             /* poly = exp(-(beta*r)^2) * (1 + (beta*r)^2 + (beta*r)^4 /2) */
269             poly             = _mm_mul_pd(exponent,_mm_macc_pd(_mm_mul_pd(ewcljrsq,ewcljrsq),one_half,_mm_sub_pd(one,ewcljrsq)));
270             /* vvdw6 = [C6 - C6grid * (1-poly)]/r6 */
271             vvdw6            = _mm_mul_pd(_mm_macc_pd(-c6grid_00,_mm_sub_pd(one,poly),c6_00),rinvsix);
272             vvdw12           = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
273             vvdw             = _mm_msub_pd(vvdw12,one_twelfth,_mm_mul_pd(vvdw6,one_sixth));
274             /* fvdw = vvdw12/r - (vvdw6/r + (C6grid * exponent * beta^6)/r) */
275             fvdw             = _mm_mul_pd(_mm_add_pd(vvdw12,_mm_msub_pd(_mm_mul_pd(c6grid_00,one_sixth),_mm_mul_pd(exponent,ewclj6),vvdw6)),rinvsq00);
276
277             /* Update potential sum for this i atom from the interaction with this j atom. */
278             vvdw             = _mm_unpacklo_pd(vvdw,_mm_setzero_pd());
279             vvdwsum          = _mm_add_pd(vvdwsum,vvdw);
280
281             fscal            = fvdw;
282
283             fscal            = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
284
285             /* Update vectorial force */
286             fix0             = _mm_macc_pd(dx00,fscal,fix0);
287             fiy0             = _mm_macc_pd(dy00,fscal,fiy0);
288             fiz0             = _mm_macc_pd(dz00,fscal,fiz0);
289             
290             gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,
291                                                    _mm_mul_pd(dx00,fscal),
292                                                    _mm_mul_pd(dy00,fscal),
293                                                    _mm_mul_pd(dz00,fscal));
294
295             /* Inner loop uses 50 flops */
296         }
297
298         /* End of innermost loop */
299
300         gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
301                                               f+i_coord_offset,fshift+i_shift_offset);
302
303         ggid                        = gid[iidx];
304         /* Update potential energies */
305         gmx_mm_update_1pot_pd(vvdwsum,kernel_data->energygrp_vdw+ggid);
306
307         /* Increment number of inner iterations */
308         inneriter                  += j_index_end - j_index_start;
309
310         /* Outer loop uses 7 flops */
311     }
312
313     /* Increment number of outer iterations */
314     outeriter        += nri;
315
316     /* Update outer/inner flops */
317
318     inc_nrnb(nrnb,eNR_NBKERNEL_VDW_VF,outeriter*7 + inneriter*50);
319 }
320 /*
321  * Gromacs nonbonded kernel:   nb_kernel_ElecNone_VdwLJEw_GeomP1P1_F_avx_128_fma_double
322  * Electrostatics interaction: None
323  * VdW interaction:            LJEwald
324  * Geometry:                   Particle-Particle
325  * Calculate force/pot:        Force
326  */
327 void
328 nb_kernel_ElecNone_VdwLJEw_GeomP1P1_F_avx_128_fma_double
329                     (t_nblist                    * gmx_restrict       nlist,
330                      rvec                        * gmx_restrict          xx,
331                      rvec                        * gmx_restrict          ff,
332                      t_forcerec                  * gmx_restrict          fr,
333                      t_mdatoms                   * gmx_restrict     mdatoms,
334                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
335                      t_nrnb                      * gmx_restrict        nrnb)
336 {
337     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
338      * just 0 for non-waters.
339      * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
340      * jnr indices corresponding to data put in the four positions in the SIMD register.
341      */
342     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
343     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
344     int              jnrA,jnrB;
345     int              j_coord_offsetA,j_coord_offsetB;
346     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
347     real             rcutoff_scalar;
348     real             *shiftvec,*fshift,*x,*f;
349     __m128d          tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
350     int              vdwioffset0;
351     __m128d          ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
352     int              vdwjidx0A,vdwjidx0B;
353     __m128d          jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
354     __m128d          dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
355     int              nvdwtype;
356     __m128d          rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
357     int              *vdwtype;
358     real             *vdwparam;
359     __m128d          one_sixth   = _mm_set1_pd(1.0/6.0);
360     __m128d          one_twelfth = _mm_set1_pd(1.0/12.0);
361     __m128d           c6grid_00;
362     real             *vdwgridparam;
363     __m128d           ewclj,ewclj2,ewclj6,ewcljrsq,poly,exponent,f6A,f6B,sh_lj_ewald;
364     __m128d           one_half  = _mm_set1_pd(0.5);
365     __m128d           minus_one = _mm_set1_pd(-1.0);
366     __m128d          dummy_mask,cutoff_mask;
367     __m128d          signbit   = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
368     __m128d          one     = _mm_set1_pd(1.0);
369     __m128d          two     = _mm_set1_pd(2.0);
370     x                = xx[0];
371     f                = ff[0];
372
373     nri              = nlist->nri;
374     iinr             = nlist->iinr;
375     jindex           = nlist->jindex;
376     jjnr             = nlist->jjnr;
377     shiftidx         = nlist->shift;
378     gid              = nlist->gid;
379     shiftvec         = fr->shift_vec[0];
380     fshift           = fr->fshift[0];
381     nvdwtype         = fr->ntype;
382     vdwparam         = fr->nbfp;
383     vdwtype          = mdatoms->typeA;
384     vdwgridparam     = fr->ljpme_c6grid;
385     sh_lj_ewald      = _mm_set1_pd(fr->ic->sh_lj_ewald);
386     ewclj            = _mm_set1_pd(fr->ewaldcoeff_lj);
387     ewclj2           = _mm_mul_pd(minus_one,_mm_mul_pd(ewclj,ewclj));
388
389     /* Avoid stupid compiler warnings */
390     jnrA = jnrB = 0;
391     j_coord_offsetA = 0;
392     j_coord_offsetB = 0;
393
394     outeriter        = 0;
395     inneriter        = 0;
396
397     /* Start outer loop over neighborlists */
398     for(iidx=0; iidx<nri; iidx++)
399     {
400         /* Load shift vector for this list */
401         i_shift_offset   = DIM*shiftidx[iidx];
402
403         /* Load limits for loop over neighbors */
404         j_index_start    = jindex[iidx];
405         j_index_end      = jindex[iidx+1];
406
407         /* Get outer coordinate index */
408         inr              = iinr[iidx];
409         i_coord_offset   = DIM*inr;
410
411         /* Load i particle coords and add shift vector */
412         gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
413
414         fix0             = _mm_setzero_pd();
415         fiy0             = _mm_setzero_pd();
416         fiz0             = _mm_setzero_pd();
417
418         /* Load parameters for i particles */
419         vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
420
421         /* Start inner kernel loop */
422         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
423         {
424
425             /* Get j neighbor index, and coordinate index */
426             jnrA             = jjnr[jidx];
427             jnrB             = jjnr[jidx+1];
428             j_coord_offsetA  = DIM*jnrA;
429             j_coord_offsetB  = DIM*jnrB;
430
431             /* load j atom coordinates */
432             gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
433                                               &jx0,&jy0,&jz0);
434
435             /* Calculate displacement vector */
436             dx00             = _mm_sub_pd(ix0,jx0);
437             dy00             = _mm_sub_pd(iy0,jy0);
438             dz00             = _mm_sub_pd(iz0,jz0);
439
440             /* Calculate squared distance and things based on it */
441             rsq00            = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
442
443             rinv00           = gmx_mm_invsqrt_pd(rsq00);
444
445             rinvsq00         = _mm_mul_pd(rinv00,rinv00);
446
447             /* Load parameters for j particles */
448             vdwjidx0A        = 2*vdwtype[jnrA+0];
449             vdwjidx0B        = 2*vdwtype[jnrB+0];
450
451             /**************************
452              * CALCULATE INTERACTIONS *
453              **************************/
454
455             r00              = _mm_mul_pd(rsq00,rinv00);
456
457             /* Compute parameters for interactions between i and j atoms */
458             gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
459                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
460             c6grid_00       = gmx_mm_load_2real_swizzle_pd(vdwgridparam+vdwioffset0+vdwjidx0A,
461                                                                vdwgridparam+vdwioffset0+vdwjidx0B);
462
463             /* Analytical LJ-PME */
464             rinvsix          = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
465             ewcljrsq         = _mm_mul_pd(ewclj2,rsq00);
466             ewclj6           = _mm_mul_pd(ewclj2,_mm_mul_pd(ewclj2,ewclj2));
467             exponent         = gmx_simd_exp_d(ewcljrsq);
468             /* poly = exp(-(beta*r)^2) * (1 + (beta*r)^2 + (beta*r)^4 /2) */
469             poly             = _mm_mul_pd(exponent,_mm_macc_pd(_mm_mul_pd(ewcljrsq,ewcljrsq),one_half,_mm_sub_pd(one,ewcljrsq)));
470             /* f6A = 6 * C6grid * (1 - poly) */
471             f6A              = _mm_mul_pd(c6grid_00,_mm_sub_pd(one,poly));
472             /* f6B = C6grid * exponent * beta^6 */
473             f6B              = _mm_mul_pd(_mm_mul_pd(c6grid_00,one_sixth),_mm_mul_pd(exponent,ewclj6));
474             /* fvdw = 12*C12/r13 - ((6*C6 - f6A)/r6 + f6B)/r */
475             fvdw              = _mm_mul_pd(_mm_macc_pd(_mm_msub_pd(c12_00,rinvsix,_mm_sub_pd(c6_00,f6A)),rinvsix,f6B),rinvsq00);
476
477             fscal            = fvdw;
478
479             /* Update vectorial force */
480             fix0             = _mm_macc_pd(dx00,fscal,fix0);
481             fiy0             = _mm_macc_pd(dy00,fscal,fiy0);
482             fiz0             = _mm_macc_pd(dz00,fscal,fiz0);
483             
484             gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,
485                                                    _mm_mul_pd(dx00,fscal),
486                                                    _mm_mul_pd(dy00,fscal),
487                                                    _mm_mul_pd(dz00,fscal));
488
489             /* Inner loop uses 47 flops */
490         }
491
492         if(jidx<j_index_end)
493         {
494
495             jnrA             = jjnr[jidx];
496             j_coord_offsetA  = DIM*jnrA;
497
498             /* load j atom coordinates */
499             gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
500                                               &jx0,&jy0,&jz0);
501
502             /* Calculate displacement vector */
503             dx00             = _mm_sub_pd(ix0,jx0);
504             dy00             = _mm_sub_pd(iy0,jy0);
505             dz00             = _mm_sub_pd(iz0,jz0);
506
507             /* Calculate squared distance and things based on it */
508             rsq00            = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
509
510             rinv00           = gmx_mm_invsqrt_pd(rsq00);
511
512             rinvsq00         = _mm_mul_pd(rinv00,rinv00);
513
514             /* Load parameters for j particles */
515             vdwjidx0A        = 2*vdwtype[jnrA+0];
516
517             /**************************
518              * CALCULATE INTERACTIONS *
519              **************************/
520
521             r00              = _mm_mul_pd(rsq00,rinv00);
522
523             /* Compute parameters for interactions between i and j atoms */
524             gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
525             c6grid_00       = gmx_mm_load_1real_pd(vdwgridparam+vdwioffset0+vdwjidx0A);
526
527             /* Analytical LJ-PME */
528             rinvsix          = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
529             ewcljrsq         = _mm_mul_pd(ewclj2,rsq00);
530             ewclj6           = _mm_mul_pd(ewclj2,_mm_mul_pd(ewclj2,ewclj2));
531             exponent         = gmx_simd_exp_d(ewcljrsq);
532             /* poly = exp(-(beta*r)^2) * (1 + (beta*r)^2 + (beta*r)^4 /2) */
533             poly             = _mm_mul_pd(exponent,_mm_macc_pd(_mm_mul_pd(ewcljrsq,ewcljrsq),one_half,_mm_sub_pd(one,ewcljrsq)));
534             /* f6A = 6 * C6grid * (1 - poly) */
535             f6A              = _mm_mul_pd(c6grid_00,_mm_sub_pd(one,poly));
536             /* f6B = C6grid * exponent * beta^6 */
537             f6B              = _mm_mul_pd(_mm_mul_pd(c6grid_00,one_sixth),_mm_mul_pd(exponent,ewclj6));
538             /* fvdw = 12*C12/r13 - ((6*C6 - f6A)/r6 + f6B)/r */
539             fvdw              = _mm_mul_pd(_mm_macc_pd(_mm_msub_pd(c12_00,rinvsix,_mm_sub_pd(c6_00,f6A)),rinvsix,f6B),rinvsq00);
540
541             fscal            = fvdw;
542
543             fscal            = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
544
545             /* Update vectorial force */
546             fix0             = _mm_macc_pd(dx00,fscal,fix0);
547             fiy0             = _mm_macc_pd(dy00,fscal,fiy0);
548             fiz0             = _mm_macc_pd(dz00,fscal,fiz0);
549             
550             gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,
551                                                    _mm_mul_pd(dx00,fscal),
552                                                    _mm_mul_pd(dy00,fscal),
553                                                    _mm_mul_pd(dz00,fscal));
554
555             /* Inner loop uses 47 flops */
556         }
557
558         /* End of innermost loop */
559
560         gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
561                                               f+i_coord_offset,fshift+i_shift_offset);
562
563         /* Increment number of inner iterations */
564         inneriter                  += j_index_end - j_index_start;
565
566         /* Outer loop uses 6 flops */
567     }
568
569     /* Increment number of outer iterations */
570     outeriter        += nri;
571
572     /* Update outer/inner flops */
573
574     inc_nrnb(nrnb,eNR_NBKERNEL_VDW_F,outeriter*6 + inneriter*47);
575 }