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