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