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