made errors during GPU detection non-fatal
[alexxy/gromacs.git] / src / gmxlib / nonbonded / nb_kernel_avx_128_fma_double / nb_kernel_ElecNone_VdwLJSw_GeomP1P1_avx_128_fma_double.c
1 /*
2  * Note: this file was generated by the Gromacs avx_128_fma_double kernel generator.
3  *
4  *                This source code is part of
5  *
6  *                 G   R   O   M   A   C   S
7  *
8  * Copyright (c) 2001-2012, The GROMACS Development Team
9  *
10  * Gromacs is a library for molecular simulation and trajectory analysis,
11  * written by Erik Lindahl, David van der Spoel, Berk Hess, and others - for
12  * a full list of developers and information, check out http://www.gromacs.org
13  *
14  * This program is free software; you can redistribute it and/or modify it under
15  * the terms of the GNU Lesser General Public License as published by the Free
16  * Software Foundation; either version 2 of the License, or (at your option) any
17  * later version.
18  *
19  * To help fund GROMACS development, we humbly ask that you cite
20  * the papers people have written on it - you can find them on the website.
21  */
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
25
26 #include <math.h>
27
28 #include "../nb_kernel.h"
29 #include "types/simple.h"
30 #include "vec.h"
31 #include "nrnb.h"
32
33 #include "gmx_math_x86_avx_128_fma_double.h"
34 #include "kernelutil_x86_avx_128_fma_double.h"
35
36 /*
37  * Gromacs nonbonded kernel:   nb_kernel_ElecNone_VdwLJSw_GeomP1P1_VF_avx_128_fma_double
38  * Electrostatics interaction: None
39  * VdW interaction:            LennardJones
40  * Geometry:                   Particle-Particle
41  * Calculate force/pot:        PotentialAndForce
42  */
43 void
44 nb_kernel_ElecNone_VdwLJSw_GeomP1P1_VF_avx_128_fma_double
45                     (t_nblist * gmx_restrict                nlist,
46                      rvec * gmx_restrict                    xx,
47                      rvec * gmx_restrict                    ff,
48                      t_forcerec * gmx_restrict              fr,
49                      t_mdatoms * gmx_restrict               mdatoms,
50                      nb_kernel_data_t * gmx_restrict        kernel_data,
51                      t_nrnb * gmx_restrict                  nrnb)
52 {
53     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
54      * just 0 for non-waters.
55      * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
56      * jnr indices corresponding to data put in the four positions in the SIMD register.
57      */
58     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
59     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
60     int              jnrA,jnrB;
61     int              j_coord_offsetA,j_coord_offsetB;
62     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
63     real             rcutoff_scalar;
64     real             *shiftvec,*fshift,*x,*f;
65     __m128d          tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
66     int              vdwioffset0;
67     __m128d          ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
68     int              vdwjidx0A,vdwjidx0B;
69     __m128d          jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
70     __m128d          dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
71     int              nvdwtype;
72     __m128d          rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
73     int              *vdwtype;
74     real             *vdwparam;
75     __m128d          one_sixth   = _mm_set1_pd(1.0/6.0);
76     __m128d          one_twelfth = _mm_set1_pd(1.0/12.0);
77     __m128d          rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
78     real             rswitch_scalar,d_scalar;
79     __m128d          dummy_mask,cutoff_mask;
80     __m128d          signbit   = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
81     __m128d          one     = _mm_set1_pd(1.0);
82     __m128d          two     = _mm_set1_pd(2.0);
83     x                = xx[0];
84     f                = ff[0];
85
86     nri              = nlist->nri;
87     iinr             = nlist->iinr;
88     jindex           = nlist->jindex;
89     jjnr             = nlist->jjnr;
90     shiftidx         = nlist->shift;
91     gid              = nlist->gid;
92     shiftvec         = fr->shift_vec[0];
93     fshift           = fr->fshift[0];
94     nvdwtype         = fr->ntype;
95     vdwparam         = fr->nbfp;
96     vdwtype          = mdatoms->typeA;
97
98     rcutoff_scalar   = fr->rvdw;
99     rcutoff          = _mm_set1_pd(rcutoff_scalar);
100     rcutoff2         = _mm_mul_pd(rcutoff,rcutoff);
101
102     rswitch_scalar   = fr->rvdw_switch;
103     rswitch          = _mm_set1_pd(rswitch_scalar);
104     /* Setup switch parameters */
105     d_scalar         = rcutoff_scalar-rswitch_scalar;
106     d                = _mm_set1_pd(d_scalar);
107     swV3             = _mm_set1_pd(-10.0/(d_scalar*d_scalar*d_scalar));
108     swV4             = _mm_set1_pd( 15.0/(d_scalar*d_scalar*d_scalar*d_scalar));
109     swV5             = _mm_set1_pd( -6.0/(d_scalar*d_scalar*d_scalar*d_scalar*d_scalar));
110     swF2             = _mm_set1_pd(-30.0/(d_scalar*d_scalar*d_scalar));
111     swF3             = _mm_set1_pd( 60.0/(d_scalar*d_scalar*d_scalar*d_scalar));
112     swF4             = _mm_set1_pd(-30.0/(d_scalar*d_scalar*d_scalar*d_scalar*d_scalar));
113
114     /* Avoid stupid compiler warnings */
115     jnrA = jnrB = 0;
116     j_coord_offsetA = 0;
117     j_coord_offsetB = 0;
118
119     outeriter        = 0;
120     inneriter        = 0;
121
122     /* Start outer loop over neighborlists */
123     for(iidx=0; iidx<nri; iidx++)
124     {
125         /* Load shift vector for this list */
126         i_shift_offset   = DIM*shiftidx[iidx];
127
128         /* Load limits for loop over neighbors */
129         j_index_start    = jindex[iidx];
130         j_index_end      = jindex[iidx+1];
131
132         /* Get outer coordinate index */
133         inr              = iinr[iidx];
134         i_coord_offset   = DIM*inr;
135
136         /* Load i particle coords and add shift vector */
137         gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
138
139         fix0             = _mm_setzero_pd();
140         fiy0             = _mm_setzero_pd();
141         fiz0             = _mm_setzero_pd();
142
143         /* Load parameters for i particles */
144         vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
145
146         /* Reset potential sums */
147         vvdwsum          = _mm_setzero_pd();
148
149         /* Start inner kernel loop */
150         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
151         {
152
153             /* Get j neighbor index, and coordinate index */
154             jnrA             = jjnr[jidx];
155             jnrB             = jjnr[jidx+1];
156             j_coord_offsetA  = DIM*jnrA;
157             j_coord_offsetB  = DIM*jnrB;
158
159             /* load j atom coordinates */
160             gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
161                                               &jx0,&jy0,&jz0);
162
163             /* Calculate displacement vector */
164             dx00             = _mm_sub_pd(ix0,jx0);
165             dy00             = _mm_sub_pd(iy0,jy0);
166             dz00             = _mm_sub_pd(iz0,jz0);
167
168             /* Calculate squared distance and things based on it */
169             rsq00            = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
170
171             rinv00           = gmx_mm_invsqrt_pd(rsq00);
172
173             rinvsq00         = _mm_mul_pd(rinv00,rinv00);
174
175             /* Load parameters for j particles */
176             vdwjidx0A        = 2*vdwtype[jnrA+0];
177             vdwjidx0B        = 2*vdwtype[jnrB+0];
178
179             /**************************
180              * CALCULATE INTERACTIONS *
181              **************************/
182
183             if (gmx_mm_any_lt(rsq00,rcutoff2))
184             {
185
186             r00              = _mm_mul_pd(rsq00,rinv00);
187
188             /* Compute parameters for interactions between i and j atoms */
189             gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
190                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
191
192             /* LENNARD-JONES DISPERSION/REPULSION */
193
194             rinvsix          = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
195             vvdw6            = _mm_mul_pd(c6_00,rinvsix);
196             vvdw12           = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
197             vvdw             = _mm_msub_pd( vvdw12,one_twelfth, _mm_mul_pd(vvdw6,one_sixth) );
198             fvdw             = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
199
200             d                = _mm_sub_pd(r00,rswitch);
201             d                = _mm_max_pd(d,_mm_setzero_pd());
202             d2               = _mm_mul_pd(d,d);
203             sw               = _mm_add_pd(one,_mm_mul_pd(d2,_mm_mul_pd(d,_mm_macc_pd(d,_mm_macc_pd(d,swV5,swV4),swV3))));
204
205             dsw              = _mm_mul_pd(d2,_mm_macc_pd(d,_mm_macc_pd(d,swF4,swF3),swF2));
206
207             /* Evaluate switch function */
208             /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
209             fvdw             = _mm_msub_pd( fvdw,sw , _mm_mul_pd(rinv00,_mm_mul_pd(vvdw,dsw)) );
210             vvdw             = _mm_mul_pd(vvdw,sw);
211             cutoff_mask      = _mm_cmplt_pd(rsq00,rcutoff2);
212
213             /* Update potential sum for this i atom from the interaction with this j atom. */
214             vvdw             = _mm_and_pd(vvdw,cutoff_mask);
215             vvdwsum          = _mm_add_pd(vvdwsum,vvdw);
216
217             fscal            = fvdw;
218
219             fscal            = _mm_and_pd(fscal,cutoff_mask);
220
221             /* Update vectorial force */
222             fix0             = _mm_macc_pd(dx00,fscal,fix0);
223             fiy0             = _mm_macc_pd(dy00,fscal,fiy0);
224             fiz0             = _mm_macc_pd(dz00,fscal,fiz0);
225             
226             gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,
227                                                    _mm_mul_pd(dx00,fscal),
228                                                    _mm_mul_pd(dy00,fscal),
229                                                    _mm_mul_pd(dz00,fscal));
230
231             }
232
233             /* Inner loop uses 62 flops */
234         }
235
236         if(jidx<j_index_end)
237         {
238
239             jnrA             = jjnr[jidx];
240             j_coord_offsetA  = DIM*jnrA;
241
242             /* load j atom coordinates */
243             gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
244                                               &jx0,&jy0,&jz0);
245
246             /* Calculate displacement vector */
247             dx00             = _mm_sub_pd(ix0,jx0);
248             dy00             = _mm_sub_pd(iy0,jy0);
249             dz00             = _mm_sub_pd(iz0,jz0);
250
251             /* Calculate squared distance and things based on it */
252             rsq00            = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
253
254             rinv00           = gmx_mm_invsqrt_pd(rsq00);
255
256             rinvsq00         = _mm_mul_pd(rinv00,rinv00);
257
258             /* Load parameters for j particles */
259             vdwjidx0A        = 2*vdwtype[jnrA+0];
260
261             /**************************
262              * CALCULATE INTERACTIONS *
263              **************************/
264
265             if (gmx_mm_any_lt(rsq00,rcutoff2))
266             {
267
268             r00              = _mm_mul_pd(rsq00,rinv00);
269
270             /* Compute parameters for interactions between i and j atoms */
271             gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
272
273             /* LENNARD-JONES DISPERSION/REPULSION */
274
275             rinvsix          = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
276             vvdw6            = _mm_mul_pd(c6_00,rinvsix);
277             vvdw12           = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
278             vvdw             = _mm_msub_pd( vvdw12,one_twelfth, _mm_mul_pd(vvdw6,one_sixth) );
279             fvdw             = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
280
281             d                = _mm_sub_pd(r00,rswitch);
282             d                = _mm_max_pd(d,_mm_setzero_pd());
283             d2               = _mm_mul_pd(d,d);
284             sw               = _mm_add_pd(one,_mm_mul_pd(d2,_mm_mul_pd(d,_mm_macc_pd(d,_mm_macc_pd(d,swV5,swV4),swV3))));
285
286             dsw              = _mm_mul_pd(d2,_mm_macc_pd(d,_mm_macc_pd(d,swF4,swF3),swF2));
287
288             /* Evaluate switch function */
289             /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
290             fvdw             = _mm_msub_pd( fvdw,sw , _mm_mul_pd(rinv00,_mm_mul_pd(vvdw,dsw)) );
291             vvdw             = _mm_mul_pd(vvdw,sw);
292             cutoff_mask      = _mm_cmplt_pd(rsq00,rcutoff2);
293
294             /* Update potential sum for this i atom from the interaction with this j atom. */
295             vvdw             = _mm_and_pd(vvdw,cutoff_mask);
296             vvdw             = _mm_unpacklo_pd(vvdw,_mm_setzero_pd());
297             vvdwsum          = _mm_add_pd(vvdwsum,vvdw);
298
299             fscal            = fvdw;
300
301             fscal            = _mm_and_pd(fscal,cutoff_mask);
302
303             fscal            = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
304
305             /* Update vectorial force */
306             fix0             = _mm_macc_pd(dx00,fscal,fix0);
307             fiy0             = _mm_macc_pd(dy00,fscal,fiy0);
308             fiz0             = _mm_macc_pd(dz00,fscal,fiz0);
309             
310             gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,
311                                                    _mm_mul_pd(dx00,fscal),
312                                                    _mm_mul_pd(dy00,fscal),
313                                                    _mm_mul_pd(dz00,fscal));
314
315             }
316
317             /* Inner loop uses 62 flops */
318         }
319
320         /* End of innermost loop */
321
322         gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
323                                               f+i_coord_offset,fshift+i_shift_offset);
324
325         ggid                        = gid[iidx];
326         /* Update potential energies */
327         gmx_mm_update_1pot_pd(vvdwsum,kernel_data->energygrp_vdw+ggid);
328
329         /* Increment number of inner iterations */
330         inneriter                  += j_index_end - j_index_start;
331
332         /* Outer loop uses 7 flops */
333     }
334
335     /* Increment number of outer iterations */
336     outeriter        += nri;
337
338     /* Update outer/inner flops */
339
340     inc_nrnb(nrnb,eNR_NBKERNEL_VDW_VF,outeriter*7 + inneriter*62);
341 }
342 /*
343  * Gromacs nonbonded kernel:   nb_kernel_ElecNone_VdwLJSw_GeomP1P1_F_avx_128_fma_double
344  * Electrostatics interaction: None
345  * VdW interaction:            LennardJones
346  * Geometry:                   Particle-Particle
347  * Calculate force/pot:        Force
348  */
349 void
350 nb_kernel_ElecNone_VdwLJSw_GeomP1P1_F_avx_128_fma_double
351                     (t_nblist * gmx_restrict                nlist,
352                      rvec * gmx_restrict                    xx,
353                      rvec * gmx_restrict                    ff,
354                      t_forcerec * gmx_restrict              fr,
355                      t_mdatoms * gmx_restrict               mdatoms,
356                      nb_kernel_data_t * gmx_restrict        kernel_data,
357                      t_nrnb * gmx_restrict                  nrnb)
358 {
359     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
360      * just 0 for non-waters.
361      * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
362      * jnr indices corresponding to data put in the four positions in the SIMD register.
363      */
364     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
365     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
366     int              jnrA,jnrB;
367     int              j_coord_offsetA,j_coord_offsetB;
368     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
369     real             rcutoff_scalar;
370     real             *shiftvec,*fshift,*x,*f;
371     __m128d          tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
372     int              vdwioffset0;
373     __m128d          ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
374     int              vdwjidx0A,vdwjidx0B;
375     __m128d          jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
376     __m128d          dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
377     int              nvdwtype;
378     __m128d          rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
379     int              *vdwtype;
380     real             *vdwparam;
381     __m128d          one_sixth   = _mm_set1_pd(1.0/6.0);
382     __m128d          one_twelfth = _mm_set1_pd(1.0/12.0);
383     __m128d          rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
384     real             rswitch_scalar,d_scalar;
385     __m128d          dummy_mask,cutoff_mask;
386     __m128d          signbit   = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
387     __m128d          one     = _mm_set1_pd(1.0);
388     __m128d          two     = _mm_set1_pd(2.0);
389     x                = xx[0];
390     f                = ff[0];
391
392     nri              = nlist->nri;
393     iinr             = nlist->iinr;
394     jindex           = nlist->jindex;
395     jjnr             = nlist->jjnr;
396     shiftidx         = nlist->shift;
397     gid              = nlist->gid;
398     shiftvec         = fr->shift_vec[0];
399     fshift           = fr->fshift[0];
400     nvdwtype         = fr->ntype;
401     vdwparam         = fr->nbfp;
402     vdwtype          = mdatoms->typeA;
403
404     rcutoff_scalar   = fr->rvdw;
405     rcutoff          = _mm_set1_pd(rcutoff_scalar);
406     rcutoff2         = _mm_mul_pd(rcutoff,rcutoff);
407
408     rswitch_scalar   = fr->rvdw_switch;
409     rswitch          = _mm_set1_pd(rswitch_scalar);
410     /* Setup switch parameters */
411     d_scalar         = rcutoff_scalar-rswitch_scalar;
412     d                = _mm_set1_pd(d_scalar);
413     swV3             = _mm_set1_pd(-10.0/(d_scalar*d_scalar*d_scalar));
414     swV4             = _mm_set1_pd( 15.0/(d_scalar*d_scalar*d_scalar*d_scalar));
415     swV5             = _mm_set1_pd( -6.0/(d_scalar*d_scalar*d_scalar*d_scalar*d_scalar));
416     swF2             = _mm_set1_pd(-30.0/(d_scalar*d_scalar*d_scalar));
417     swF3             = _mm_set1_pd( 60.0/(d_scalar*d_scalar*d_scalar*d_scalar));
418     swF4             = _mm_set1_pd(-30.0/(d_scalar*d_scalar*d_scalar*d_scalar*d_scalar));
419
420     /* Avoid stupid compiler warnings */
421     jnrA = jnrB = 0;
422     j_coord_offsetA = 0;
423     j_coord_offsetB = 0;
424
425     outeriter        = 0;
426     inneriter        = 0;
427
428     /* Start outer loop over neighborlists */
429     for(iidx=0; iidx<nri; iidx++)
430     {
431         /* Load shift vector for this list */
432         i_shift_offset   = DIM*shiftidx[iidx];
433
434         /* Load limits for loop over neighbors */
435         j_index_start    = jindex[iidx];
436         j_index_end      = jindex[iidx+1];
437
438         /* Get outer coordinate index */
439         inr              = iinr[iidx];
440         i_coord_offset   = DIM*inr;
441
442         /* Load i particle coords and add shift vector */
443         gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
444
445         fix0             = _mm_setzero_pd();
446         fiy0             = _mm_setzero_pd();
447         fiz0             = _mm_setzero_pd();
448
449         /* Load parameters for i particles */
450         vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
451
452         /* Start inner kernel loop */
453         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
454         {
455
456             /* Get j neighbor index, and coordinate index */
457             jnrA             = jjnr[jidx];
458             jnrB             = jjnr[jidx+1];
459             j_coord_offsetA  = DIM*jnrA;
460             j_coord_offsetB  = DIM*jnrB;
461
462             /* load j atom coordinates */
463             gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
464                                               &jx0,&jy0,&jz0);
465
466             /* Calculate displacement vector */
467             dx00             = _mm_sub_pd(ix0,jx0);
468             dy00             = _mm_sub_pd(iy0,jy0);
469             dz00             = _mm_sub_pd(iz0,jz0);
470
471             /* Calculate squared distance and things based on it */
472             rsq00            = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
473
474             rinv00           = gmx_mm_invsqrt_pd(rsq00);
475
476             rinvsq00         = _mm_mul_pd(rinv00,rinv00);
477
478             /* Load parameters for j particles */
479             vdwjidx0A        = 2*vdwtype[jnrA+0];
480             vdwjidx0B        = 2*vdwtype[jnrB+0];
481
482             /**************************
483              * CALCULATE INTERACTIONS *
484              **************************/
485
486             if (gmx_mm_any_lt(rsq00,rcutoff2))
487             {
488
489             r00              = _mm_mul_pd(rsq00,rinv00);
490
491             /* Compute parameters for interactions between i and j atoms */
492             gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
493                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
494
495             /* LENNARD-JONES DISPERSION/REPULSION */
496
497             rinvsix          = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
498             vvdw6            = _mm_mul_pd(c6_00,rinvsix);
499             vvdw12           = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
500             vvdw             = _mm_msub_pd( vvdw12,one_twelfth, _mm_mul_pd(vvdw6,one_sixth) );
501             fvdw             = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
502
503             d                = _mm_sub_pd(r00,rswitch);
504             d                = _mm_max_pd(d,_mm_setzero_pd());
505             d2               = _mm_mul_pd(d,d);
506             sw               = _mm_add_pd(one,_mm_mul_pd(d2,_mm_mul_pd(d,_mm_macc_pd(d,_mm_macc_pd(d,swV5,swV4),swV3))));
507
508             dsw              = _mm_mul_pd(d2,_mm_macc_pd(d,_mm_macc_pd(d,swF4,swF3),swF2));
509
510             /* Evaluate switch function */
511             /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
512             fvdw             = _mm_msub_pd( fvdw,sw , _mm_mul_pd(rinv00,_mm_mul_pd(vvdw,dsw)) );
513             cutoff_mask      = _mm_cmplt_pd(rsq00,rcutoff2);
514
515             fscal            = fvdw;
516
517             fscal            = _mm_and_pd(fscal,cutoff_mask);
518
519             /* Update vectorial force */
520             fix0             = _mm_macc_pd(dx00,fscal,fix0);
521             fiy0             = _mm_macc_pd(dy00,fscal,fiy0);
522             fiz0             = _mm_macc_pd(dz00,fscal,fiz0);
523             
524             gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,
525                                                    _mm_mul_pd(dx00,fscal),
526                                                    _mm_mul_pd(dy00,fscal),
527                                                    _mm_mul_pd(dz00,fscal));
528
529             }
530
531             /* Inner loop uses 59 flops */
532         }
533
534         if(jidx<j_index_end)
535         {
536
537             jnrA             = jjnr[jidx];
538             j_coord_offsetA  = DIM*jnrA;
539
540             /* load j atom coordinates */
541             gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
542                                               &jx0,&jy0,&jz0);
543
544             /* Calculate displacement vector */
545             dx00             = _mm_sub_pd(ix0,jx0);
546             dy00             = _mm_sub_pd(iy0,jy0);
547             dz00             = _mm_sub_pd(iz0,jz0);
548
549             /* Calculate squared distance and things based on it */
550             rsq00            = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
551
552             rinv00           = gmx_mm_invsqrt_pd(rsq00);
553
554             rinvsq00         = _mm_mul_pd(rinv00,rinv00);
555
556             /* Load parameters for j particles */
557             vdwjidx0A        = 2*vdwtype[jnrA+0];
558
559             /**************************
560              * CALCULATE INTERACTIONS *
561              **************************/
562
563             if (gmx_mm_any_lt(rsq00,rcutoff2))
564             {
565
566             r00              = _mm_mul_pd(rsq00,rinv00);
567
568             /* Compute parameters for interactions between i and j atoms */
569             gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
570
571             /* LENNARD-JONES DISPERSION/REPULSION */
572
573             rinvsix          = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
574             vvdw6            = _mm_mul_pd(c6_00,rinvsix);
575             vvdw12           = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
576             vvdw             = _mm_msub_pd( vvdw12,one_twelfth, _mm_mul_pd(vvdw6,one_sixth) );
577             fvdw             = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
578
579             d                = _mm_sub_pd(r00,rswitch);
580             d                = _mm_max_pd(d,_mm_setzero_pd());
581             d2               = _mm_mul_pd(d,d);
582             sw               = _mm_add_pd(one,_mm_mul_pd(d2,_mm_mul_pd(d,_mm_macc_pd(d,_mm_macc_pd(d,swV5,swV4),swV3))));
583
584             dsw              = _mm_mul_pd(d2,_mm_macc_pd(d,_mm_macc_pd(d,swF4,swF3),swF2));
585
586             /* Evaluate switch function */
587             /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
588             fvdw             = _mm_msub_pd( fvdw,sw , _mm_mul_pd(rinv00,_mm_mul_pd(vvdw,dsw)) );
589             cutoff_mask      = _mm_cmplt_pd(rsq00,rcutoff2);
590
591             fscal            = fvdw;
592
593             fscal            = _mm_and_pd(fscal,cutoff_mask);
594
595             fscal            = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
596
597             /* Update vectorial force */
598             fix0             = _mm_macc_pd(dx00,fscal,fix0);
599             fiy0             = _mm_macc_pd(dy00,fscal,fiy0);
600             fiz0             = _mm_macc_pd(dz00,fscal,fiz0);
601             
602             gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,
603                                                    _mm_mul_pd(dx00,fscal),
604                                                    _mm_mul_pd(dy00,fscal),
605                                                    _mm_mul_pd(dz00,fscal));
606
607             }
608
609             /* Inner loop uses 59 flops */
610         }
611
612         /* End of innermost loop */
613
614         gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
615                                               f+i_coord_offset,fshift+i_shift_offset);
616
617         /* Increment number of inner iterations */
618         inneriter                  += j_index_end - j_index_start;
619
620         /* Outer loop uses 6 flops */
621     }
622
623     /* Increment number of outer iterations */
624     outeriter        += nri;
625
626     /* Update outer/inner flops */
627
628     inc_nrnb(nrnb,eNR_NBKERNEL_VDW_F,outeriter*6 + inneriter*59);
629 }