2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014,2015, 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.
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.
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.
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.
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.
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.
36 * Note: this file was generated by the GROMACS avx_128_fma_double kernel generator.
44 #include "../nb_kernel.h"
45 #include "gromacs/math/vec.h"
46 #include "gromacs/legacyheaders/nrnb.h"
48 #include "gromacs/simd/math_x86_avx_128_fma_double.h"
49 #include "kernelutil_x86_avx_128_fma_double.h"
52 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwLJ_GeomW3P1_VF_avx_128_fma_double
53 * Electrostatics interaction: Coulomb
54 * VdW interaction: LennardJones
55 * Geometry: Water3-Particle
56 * Calculate force/pot: PotentialAndForce
59 nb_kernel_ElecCoul_VdwLJ_GeomW3P1_VF_avx_128_fma_double
60 (t_nblist
* gmx_restrict nlist
,
61 rvec
* gmx_restrict xx
,
62 rvec
* gmx_restrict ff
,
63 t_forcerec
* gmx_restrict fr
,
64 t_mdatoms
* gmx_restrict mdatoms
,
65 nb_kernel_data_t gmx_unused
* gmx_restrict kernel_data
,
66 t_nrnb
* gmx_restrict nrnb
)
68 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
69 * just 0 for non-waters.
70 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
71 * jnr indices corresponding to data put in the four positions in the SIMD register.
73 int i_shift_offset
,i_coord_offset
,outeriter
,inneriter
;
74 int j_index_start
,j_index_end
,jidx
,nri
,inr
,ggid
,iidx
;
76 int j_coord_offsetA
,j_coord_offsetB
;
77 int *iinr
,*jindex
,*jjnr
,*shiftidx
,*gid
;
79 real
*shiftvec
,*fshift
,*x
,*f
;
80 __m128d tx
,ty
,tz
,fscal
,rcutoff
,rcutoff2
,jidxall
;
82 __m128d ix0
,iy0
,iz0
,fix0
,fiy0
,fiz0
,iq0
,isai0
;
84 __m128d ix1
,iy1
,iz1
,fix1
,fiy1
,fiz1
,iq1
,isai1
;
86 __m128d ix2
,iy2
,iz2
,fix2
,fiy2
,fiz2
,iq2
,isai2
;
87 int vdwjidx0A
,vdwjidx0B
;
88 __m128d jx0
,jy0
,jz0
,fjx0
,fjy0
,fjz0
,jq0
,isaj0
;
89 __m128d dx00
,dy00
,dz00
,rsq00
,rinv00
,rinvsq00
,r00
,qq00
,c6_00
,c12_00
;
90 __m128d dx10
,dy10
,dz10
,rsq10
,rinv10
,rinvsq10
,r10
,qq10
,c6_10
,c12_10
;
91 __m128d dx20
,dy20
,dz20
,rsq20
,rinv20
,rinvsq20
,r20
,qq20
,c6_20
,c12_20
;
92 __m128d velec
,felec
,velecsum
,facel
,crf
,krf
,krf2
;
95 __m128d rinvsix
,rvdw
,vvdw
,vvdw6
,vvdw12
,fvdw
,fvdw6
,fvdw12
,vvdwsum
,sh_vdw_invrcut6
;
98 __m128d one_sixth
= _mm_set1_pd(1.0/6.0);
99 __m128d one_twelfth
= _mm_set1_pd(1.0/12.0);
100 __m128d dummy_mask
,cutoff_mask
;
101 __m128d signbit
= gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
102 __m128d one
= _mm_set1_pd(1.0);
103 __m128d two
= _mm_set1_pd(2.0);
109 jindex
= nlist
->jindex
;
111 shiftidx
= nlist
->shift
;
113 shiftvec
= fr
->shift_vec
[0];
114 fshift
= fr
->fshift
[0];
115 facel
= _mm_set1_pd(fr
->epsfac
);
116 charge
= mdatoms
->chargeA
;
117 nvdwtype
= fr
->ntype
;
119 vdwtype
= mdatoms
->typeA
;
121 /* Setup water-specific parameters */
122 inr
= nlist
->iinr
[0];
123 iq0
= _mm_mul_pd(facel
,_mm_set1_pd(charge
[inr
+0]));
124 iq1
= _mm_mul_pd(facel
,_mm_set1_pd(charge
[inr
+1]));
125 iq2
= _mm_mul_pd(facel
,_mm_set1_pd(charge
[inr
+2]));
126 vdwioffset0
= 2*nvdwtype
*vdwtype
[inr
+0];
128 /* Avoid stupid compiler warnings */
136 /* Start outer loop over neighborlists */
137 for(iidx
=0; iidx
<nri
; iidx
++)
139 /* Load shift vector for this list */
140 i_shift_offset
= DIM
*shiftidx
[iidx
];
142 /* Load limits for loop over neighbors */
143 j_index_start
= jindex
[iidx
];
144 j_index_end
= jindex
[iidx
+1];
146 /* Get outer coordinate index */
148 i_coord_offset
= DIM
*inr
;
150 /* Load i particle coords and add shift vector */
151 gmx_mm_load_shift_and_3rvec_broadcast_pd(shiftvec
+i_shift_offset
,x
+i_coord_offset
,
152 &ix0
,&iy0
,&iz0
,&ix1
,&iy1
,&iz1
,&ix2
,&iy2
,&iz2
);
154 fix0
= _mm_setzero_pd();
155 fiy0
= _mm_setzero_pd();
156 fiz0
= _mm_setzero_pd();
157 fix1
= _mm_setzero_pd();
158 fiy1
= _mm_setzero_pd();
159 fiz1
= _mm_setzero_pd();
160 fix2
= _mm_setzero_pd();
161 fiy2
= _mm_setzero_pd();
162 fiz2
= _mm_setzero_pd();
164 /* Reset potential sums */
165 velecsum
= _mm_setzero_pd();
166 vvdwsum
= _mm_setzero_pd();
168 /* Start inner kernel loop */
169 for(jidx
=j_index_start
; jidx
<j_index_end
-1; jidx
+=2)
172 /* Get j neighbor index, and coordinate index */
175 j_coord_offsetA
= DIM
*jnrA
;
176 j_coord_offsetB
= DIM
*jnrB
;
178 /* load j atom coordinates */
179 gmx_mm_load_1rvec_2ptr_swizzle_pd(x
+j_coord_offsetA
,x
+j_coord_offsetB
,
182 /* Calculate displacement vector */
183 dx00
= _mm_sub_pd(ix0
,jx0
);
184 dy00
= _mm_sub_pd(iy0
,jy0
);
185 dz00
= _mm_sub_pd(iz0
,jz0
);
186 dx10
= _mm_sub_pd(ix1
,jx0
);
187 dy10
= _mm_sub_pd(iy1
,jy0
);
188 dz10
= _mm_sub_pd(iz1
,jz0
);
189 dx20
= _mm_sub_pd(ix2
,jx0
);
190 dy20
= _mm_sub_pd(iy2
,jy0
);
191 dz20
= _mm_sub_pd(iz2
,jz0
);
193 /* Calculate squared distance and things based on it */
194 rsq00
= gmx_mm_calc_rsq_pd(dx00
,dy00
,dz00
);
195 rsq10
= gmx_mm_calc_rsq_pd(dx10
,dy10
,dz10
);
196 rsq20
= gmx_mm_calc_rsq_pd(dx20
,dy20
,dz20
);
198 rinv00
= gmx_mm_invsqrt_pd(rsq00
);
199 rinv10
= gmx_mm_invsqrt_pd(rsq10
);
200 rinv20
= gmx_mm_invsqrt_pd(rsq20
);
202 rinvsq00
= _mm_mul_pd(rinv00
,rinv00
);
203 rinvsq10
= _mm_mul_pd(rinv10
,rinv10
);
204 rinvsq20
= _mm_mul_pd(rinv20
,rinv20
);
206 /* Load parameters for j particles */
207 jq0
= gmx_mm_load_2real_swizzle_pd(charge
+jnrA
+0,charge
+jnrB
+0);
208 vdwjidx0A
= 2*vdwtype
[jnrA
+0];
209 vdwjidx0B
= 2*vdwtype
[jnrB
+0];
211 fjx0
= _mm_setzero_pd();
212 fjy0
= _mm_setzero_pd();
213 fjz0
= _mm_setzero_pd();
215 /**************************
216 * CALCULATE INTERACTIONS *
217 **************************/
219 /* Compute parameters for interactions between i and j atoms */
220 qq00
= _mm_mul_pd(iq0
,jq0
);
221 gmx_mm_load_2pair_swizzle_pd(vdwparam
+vdwioffset0
+vdwjidx0A
,
222 vdwparam
+vdwioffset0
+vdwjidx0B
,&c6_00
,&c12_00
);
224 /* COULOMB ELECTROSTATICS */
225 velec
= _mm_mul_pd(qq00
,rinv00
);
226 felec
= _mm_mul_pd(velec
,rinvsq00
);
228 /* LENNARD-JONES DISPERSION/REPULSION */
230 rinvsix
= _mm_mul_pd(_mm_mul_pd(rinvsq00
,rinvsq00
),rinvsq00
);
231 vvdw6
= _mm_mul_pd(c6_00
,rinvsix
);
232 vvdw12
= _mm_mul_pd(c12_00
,_mm_mul_pd(rinvsix
,rinvsix
));
233 vvdw
= _mm_msub_pd( vvdw12
,one_twelfth
, _mm_mul_pd(vvdw6
,one_sixth
) );
234 fvdw
= _mm_mul_pd(_mm_sub_pd(vvdw12
,vvdw6
),rinvsq00
);
236 /* Update potential sum for this i atom from the interaction with this j atom. */
237 velecsum
= _mm_add_pd(velecsum
,velec
);
238 vvdwsum
= _mm_add_pd(vvdwsum
,vvdw
);
240 fscal
= _mm_add_pd(felec
,fvdw
);
242 /* Update vectorial force */
243 fix0
= _mm_macc_pd(dx00
,fscal
,fix0
);
244 fiy0
= _mm_macc_pd(dy00
,fscal
,fiy0
);
245 fiz0
= _mm_macc_pd(dz00
,fscal
,fiz0
);
247 fjx0
= _mm_macc_pd(dx00
,fscal
,fjx0
);
248 fjy0
= _mm_macc_pd(dy00
,fscal
,fjy0
);
249 fjz0
= _mm_macc_pd(dz00
,fscal
,fjz0
);
251 /**************************
252 * CALCULATE INTERACTIONS *
253 **************************/
255 /* Compute parameters for interactions between i and j atoms */
256 qq10
= _mm_mul_pd(iq1
,jq0
);
258 /* COULOMB ELECTROSTATICS */
259 velec
= _mm_mul_pd(qq10
,rinv10
);
260 felec
= _mm_mul_pd(velec
,rinvsq10
);
262 /* Update potential sum for this i atom from the interaction with this j atom. */
263 velecsum
= _mm_add_pd(velecsum
,velec
);
267 /* Update vectorial force */
268 fix1
= _mm_macc_pd(dx10
,fscal
,fix1
);
269 fiy1
= _mm_macc_pd(dy10
,fscal
,fiy1
);
270 fiz1
= _mm_macc_pd(dz10
,fscal
,fiz1
);
272 fjx0
= _mm_macc_pd(dx10
,fscal
,fjx0
);
273 fjy0
= _mm_macc_pd(dy10
,fscal
,fjy0
);
274 fjz0
= _mm_macc_pd(dz10
,fscal
,fjz0
);
276 /**************************
277 * CALCULATE INTERACTIONS *
278 **************************/
280 /* Compute parameters for interactions between i and j atoms */
281 qq20
= _mm_mul_pd(iq2
,jq0
);
283 /* COULOMB ELECTROSTATICS */
284 velec
= _mm_mul_pd(qq20
,rinv20
);
285 felec
= _mm_mul_pd(velec
,rinvsq20
);
287 /* Update potential sum for this i atom from the interaction with this j atom. */
288 velecsum
= _mm_add_pd(velecsum
,velec
);
292 /* Update vectorial force */
293 fix2
= _mm_macc_pd(dx20
,fscal
,fix2
);
294 fiy2
= _mm_macc_pd(dy20
,fscal
,fiy2
);
295 fiz2
= _mm_macc_pd(dz20
,fscal
,fiz2
);
297 fjx0
= _mm_macc_pd(dx20
,fscal
,fjx0
);
298 fjy0
= _mm_macc_pd(dy20
,fscal
,fjy0
);
299 fjz0
= _mm_macc_pd(dz20
,fscal
,fjz0
);
301 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f
+j_coord_offsetA
,f
+j_coord_offsetB
,fjx0
,fjy0
,fjz0
);
303 /* Inner loop uses 108 flops */
310 j_coord_offsetA
= DIM
*jnrA
;
312 /* load j atom coordinates */
313 gmx_mm_load_1rvec_1ptr_swizzle_pd(x
+j_coord_offsetA
,
316 /* Calculate displacement vector */
317 dx00
= _mm_sub_pd(ix0
,jx0
);
318 dy00
= _mm_sub_pd(iy0
,jy0
);
319 dz00
= _mm_sub_pd(iz0
,jz0
);
320 dx10
= _mm_sub_pd(ix1
,jx0
);
321 dy10
= _mm_sub_pd(iy1
,jy0
);
322 dz10
= _mm_sub_pd(iz1
,jz0
);
323 dx20
= _mm_sub_pd(ix2
,jx0
);
324 dy20
= _mm_sub_pd(iy2
,jy0
);
325 dz20
= _mm_sub_pd(iz2
,jz0
);
327 /* Calculate squared distance and things based on it */
328 rsq00
= gmx_mm_calc_rsq_pd(dx00
,dy00
,dz00
);
329 rsq10
= gmx_mm_calc_rsq_pd(dx10
,dy10
,dz10
);
330 rsq20
= gmx_mm_calc_rsq_pd(dx20
,dy20
,dz20
);
332 rinv00
= gmx_mm_invsqrt_pd(rsq00
);
333 rinv10
= gmx_mm_invsqrt_pd(rsq10
);
334 rinv20
= gmx_mm_invsqrt_pd(rsq20
);
336 rinvsq00
= _mm_mul_pd(rinv00
,rinv00
);
337 rinvsq10
= _mm_mul_pd(rinv10
,rinv10
);
338 rinvsq20
= _mm_mul_pd(rinv20
,rinv20
);
340 /* Load parameters for j particles */
341 jq0
= _mm_load_sd(charge
+jnrA
+0);
342 vdwjidx0A
= 2*vdwtype
[jnrA
+0];
344 fjx0
= _mm_setzero_pd();
345 fjy0
= _mm_setzero_pd();
346 fjz0
= _mm_setzero_pd();
348 /**************************
349 * CALCULATE INTERACTIONS *
350 **************************/
352 /* Compute parameters for interactions between i and j atoms */
353 qq00
= _mm_mul_pd(iq0
,jq0
);
354 gmx_mm_load_1pair_swizzle_pd(vdwparam
+vdwioffset0
+vdwjidx0A
,&c6_00
,&c12_00
);
356 /* COULOMB ELECTROSTATICS */
357 velec
= _mm_mul_pd(qq00
,rinv00
);
358 felec
= _mm_mul_pd(velec
,rinvsq00
);
360 /* LENNARD-JONES DISPERSION/REPULSION */
362 rinvsix
= _mm_mul_pd(_mm_mul_pd(rinvsq00
,rinvsq00
),rinvsq00
);
363 vvdw6
= _mm_mul_pd(c6_00
,rinvsix
);
364 vvdw12
= _mm_mul_pd(c12_00
,_mm_mul_pd(rinvsix
,rinvsix
));
365 vvdw
= _mm_msub_pd( vvdw12
,one_twelfth
, _mm_mul_pd(vvdw6
,one_sixth
) );
366 fvdw
= _mm_mul_pd(_mm_sub_pd(vvdw12
,vvdw6
),rinvsq00
);
368 /* Update potential sum for this i atom from the interaction with this j atom. */
369 velec
= _mm_unpacklo_pd(velec
,_mm_setzero_pd());
370 velecsum
= _mm_add_pd(velecsum
,velec
);
371 vvdw
= _mm_unpacklo_pd(vvdw
,_mm_setzero_pd());
372 vvdwsum
= _mm_add_pd(vvdwsum
,vvdw
);
374 fscal
= _mm_add_pd(felec
,fvdw
);
376 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
378 /* Update vectorial force */
379 fix0
= _mm_macc_pd(dx00
,fscal
,fix0
);
380 fiy0
= _mm_macc_pd(dy00
,fscal
,fiy0
);
381 fiz0
= _mm_macc_pd(dz00
,fscal
,fiz0
);
383 fjx0
= _mm_macc_pd(dx00
,fscal
,fjx0
);
384 fjy0
= _mm_macc_pd(dy00
,fscal
,fjy0
);
385 fjz0
= _mm_macc_pd(dz00
,fscal
,fjz0
);
387 /**************************
388 * CALCULATE INTERACTIONS *
389 **************************/
391 /* Compute parameters for interactions between i and j atoms */
392 qq10
= _mm_mul_pd(iq1
,jq0
);
394 /* COULOMB ELECTROSTATICS */
395 velec
= _mm_mul_pd(qq10
,rinv10
);
396 felec
= _mm_mul_pd(velec
,rinvsq10
);
398 /* Update potential sum for this i atom from the interaction with this j atom. */
399 velec
= _mm_unpacklo_pd(velec
,_mm_setzero_pd());
400 velecsum
= _mm_add_pd(velecsum
,velec
);
404 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
406 /* Update vectorial force */
407 fix1
= _mm_macc_pd(dx10
,fscal
,fix1
);
408 fiy1
= _mm_macc_pd(dy10
,fscal
,fiy1
);
409 fiz1
= _mm_macc_pd(dz10
,fscal
,fiz1
);
411 fjx0
= _mm_macc_pd(dx10
,fscal
,fjx0
);
412 fjy0
= _mm_macc_pd(dy10
,fscal
,fjy0
);
413 fjz0
= _mm_macc_pd(dz10
,fscal
,fjz0
);
415 /**************************
416 * CALCULATE INTERACTIONS *
417 **************************/
419 /* Compute parameters for interactions between i and j atoms */
420 qq20
= _mm_mul_pd(iq2
,jq0
);
422 /* COULOMB ELECTROSTATICS */
423 velec
= _mm_mul_pd(qq20
,rinv20
);
424 felec
= _mm_mul_pd(velec
,rinvsq20
);
426 /* Update potential sum for this i atom from the interaction with this j atom. */
427 velec
= _mm_unpacklo_pd(velec
,_mm_setzero_pd());
428 velecsum
= _mm_add_pd(velecsum
,velec
);
432 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
434 /* Update vectorial force */
435 fix2
= _mm_macc_pd(dx20
,fscal
,fix2
);
436 fiy2
= _mm_macc_pd(dy20
,fscal
,fiy2
);
437 fiz2
= _mm_macc_pd(dz20
,fscal
,fiz2
);
439 fjx0
= _mm_macc_pd(dx20
,fscal
,fjx0
);
440 fjy0
= _mm_macc_pd(dy20
,fscal
,fjy0
);
441 fjz0
= _mm_macc_pd(dz20
,fscal
,fjz0
);
443 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f
+j_coord_offsetA
,fjx0
,fjy0
,fjz0
);
445 /* Inner loop uses 108 flops */
448 /* End of innermost loop */
450 gmx_mm_update_iforce_3atom_swizzle_pd(fix0
,fiy0
,fiz0
,fix1
,fiy1
,fiz1
,fix2
,fiy2
,fiz2
,
451 f
+i_coord_offset
,fshift
+i_shift_offset
);
454 /* Update potential energies */
455 gmx_mm_update_1pot_pd(velecsum
,kernel_data
->energygrp_elec
+ggid
);
456 gmx_mm_update_1pot_pd(vvdwsum
,kernel_data
->energygrp_vdw
+ggid
);
458 /* Increment number of inner iterations */
459 inneriter
+= j_index_end
- j_index_start
;
461 /* Outer loop uses 20 flops */
464 /* Increment number of outer iterations */
467 /* Update outer/inner flops */
469 inc_nrnb(nrnb
,eNR_NBKERNEL_ELEC_VDW_W3_VF
,outeriter
*20 + inneriter
*108);
472 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwLJ_GeomW3P1_F_avx_128_fma_double
473 * Electrostatics interaction: Coulomb
474 * VdW interaction: LennardJones
475 * Geometry: Water3-Particle
476 * Calculate force/pot: Force
479 nb_kernel_ElecCoul_VdwLJ_GeomW3P1_F_avx_128_fma_double
480 (t_nblist
* gmx_restrict nlist
,
481 rvec
* gmx_restrict xx
,
482 rvec
* gmx_restrict ff
,
483 t_forcerec
* gmx_restrict fr
,
484 t_mdatoms
* gmx_restrict mdatoms
,
485 nb_kernel_data_t gmx_unused
* gmx_restrict kernel_data
,
486 t_nrnb
* gmx_restrict nrnb
)
488 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
489 * just 0 for non-waters.
490 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
491 * jnr indices corresponding to data put in the four positions in the SIMD register.
493 int i_shift_offset
,i_coord_offset
,outeriter
,inneriter
;
494 int j_index_start
,j_index_end
,jidx
,nri
,inr
,ggid
,iidx
;
496 int j_coord_offsetA
,j_coord_offsetB
;
497 int *iinr
,*jindex
,*jjnr
,*shiftidx
,*gid
;
499 real
*shiftvec
,*fshift
,*x
,*f
;
500 __m128d tx
,ty
,tz
,fscal
,rcutoff
,rcutoff2
,jidxall
;
502 __m128d ix0
,iy0
,iz0
,fix0
,fiy0
,fiz0
,iq0
,isai0
;
504 __m128d ix1
,iy1
,iz1
,fix1
,fiy1
,fiz1
,iq1
,isai1
;
506 __m128d ix2
,iy2
,iz2
,fix2
,fiy2
,fiz2
,iq2
,isai2
;
507 int vdwjidx0A
,vdwjidx0B
;
508 __m128d jx0
,jy0
,jz0
,fjx0
,fjy0
,fjz0
,jq0
,isaj0
;
509 __m128d dx00
,dy00
,dz00
,rsq00
,rinv00
,rinvsq00
,r00
,qq00
,c6_00
,c12_00
;
510 __m128d dx10
,dy10
,dz10
,rsq10
,rinv10
,rinvsq10
,r10
,qq10
,c6_10
,c12_10
;
511 __m128d dx20
,dy20
,dz20
,rsq20
,rinv20
,rinvsq20
,r20
,qq20
,c6_20
,c12_20
;
512 __m128d velec
,felec
,velecsum
,facel
,crf
,krf
,krf2
;
515 __m128d rinvsix
,rvdw
,vvdw
,vvdw6
,vvdw12
,fvdw
,fvdw6
,fvdw12
,vvdwsum
,sh_vdw_invrcut6
;
518 __m128d one_sixth
= _mm_set1_pd(1.0/6.0);
519 __m128d one_twelfth
= _mm_set1_pd(1.0/12.0);
520 __m128d dummy_mask
,cutoff_mask
;
521 __m128d signbit
= gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
522 __m128d one
= _mm_set1_pd(1.0);
523 __m128d two
= _mm_set1_pd(2.0);
529 jindex
= nlist
->jindex
;
531 shiftidx
= nlist
->shift
;
533 shiftvec
= fr
->shift_vec
[0];
534 fshift
= fr
->fshift
[0];
535 facel
= _mm_set1_pd(fr
->epsfac
);
536 charge
= mdatoms
->chargeA
;
537 nvdwtype
= fr
->ntype
;
539 vdwtype
= mdatoms
->typeA
;
541 /* Setup water-specific parameters */
542 inr
= nlist
->iinr
[0];
543 iq0
= _mm_mul_pd(facel
,_mm_set1_pd(charge
[inr
+0]));
544 iq1
= _mm_mul_pd(facel
,_mm_set1_pd(charge
[inr
+1]));
545 iq2
= _mm_mul_pd(facel
,_mm_set1_pd(charge
[inr
+2]));
546 vdwioffset0
= 2*nvdwtype
*vdwtype
[inr
+0];
548 /* Avoid stupid compiler warnings */
556 /* Start outer loop over neighborlists */
557 for(iidx
=0; iidx
<nri
; iidx
++)
559 /* Load shift vector for this list */
560 i_shift_offset
= DIM
*shiftidx
[iidx
];
562 /* Load limits for loop over neighbors */
563 j_index_start
= jindex
[iidx
];
564 j_index_end
= jindex
[iidx
+1];
566 /* Get outer coordinate index */
568 i_coord_offset
= DIM
*inr
;
570 /* Load i particle coords and add shift vector */
571 gmx_mm_load_shift_and_3rvec_broadcast_pd(shiftvec
+i_shift_offset
,x
+i_coord_offset
,
572 &ix0
,&iy0
,&iz0
,&ix1
,&iy1
,&iz1
,&ix2
,&iy2
,&iz2
);
574 fix0
= _mm_setzero_pd();
575 fiy0
= _mm_setzero_pd();
576 fiz0
= _mm_setzero_pd();
577 fix1
= _mm_setzero_pd();
578 fiy1
= _mm_setzero_pd();
579 fiz1
= _mm_setzero_pd();
580 fix2
= _mm_setzero_pd();
581 fiy2
= _mm_setzero_pd();
582 fiz2
= _mm_setzero_pd();
584 /* Start inner kernel loop */
585 for(jidx
=j_index_start
; jidx
<j_index_end
-1; jidx
+=2)
588 /* Get j neighbor index, and coordinate index */
591 j_coord_offsetA
= DIM
*jnrA
;
592 j_coord_offsetB
= DIM
*jnrB
;
594 /* load j atom coordinates */
595 gmx_mm_load_1rvec_2ptr_swizzle_pd(x
+j_coord_offsetA
,x
+j_coord_offsetB
,
598 /* Calculate displacement vector */
599 dx00
= _mm_sub_pd(ix0
,jx0
);
600 dy00
= _mm_sub_pd(iy0
,jy0
);
601 dz00
= _mm_sub_pd(iz0
,jz0
);
602 dx10
= _mm_sub_pd(ix1
,jx0
);
603 dy10
= _mm_sub_pd(iy1
,jy0
);
604 dz10
= _mm_sub_pd(iz1
,jz0
);
605 dx20
= _mm_sub_pd(ix2
,jx0
);
606 dy20
= _mm_sub_pd(iy2
,jy0
);
607 dz20
= _mm_sub_pd(iz2
,jz0
);
609 /* Calculate squared distance and things based on it */
610 rsq00
= gmx_mm_calc_rsq_pd(dx00
,dy00
,dz00
);
611 rsq10
= gmx_mm_calc_rsq_pd(dx10
,dy10
,dz10
);
612 rsq20
= gmx_mm_calc_rsq_pd(dx20
,dy20
,dz20
);
614 rinv00
= gmx_mm_invsqrt_pd(rsq00
);
615 rinv10
= gmx_mm_invsqrt_pd(rsq10
);
616 rinv20
= gmx_mm_invsqrt_pd(rsq20
);
618 rinvsq00
= _mm_mul_pd(rinv00
,rinv00
);
619 rinvsq10
= _mm_mul_pd(rinv10
,rinv10
);
620 rinvsq20
= _mm_mul_pd(rinv20
,rinv20
);
622 /* Load parameters for j particles */
623 jq0
= gmx_mm_load_2real_swizzle_pd(charge
+jnrA
+0,charge
+jnrB
+0);
624 vdwjidx0A
= 2*vdwtype
[jnrA
+0];
625 vdwjidx0B
= 2*vdwtype
[jnrB
+0];
627 fjx0
= _mm_setzero_pd();
628 fjy0
= _mm_setzero_pd();
629 fjz0
= _mm_setzero_pd();
631 /**************************
632 * CALCULATE INTERACTIONS *
633 **************************/
635 /* Compute parameters for interactions between i and j atoms */
636 qq00
= _mm_mul_pd(iq0
,jq0
);
637 gmx_mm_load_2pair_swizzle_pd(vdwparam
+vdwioffset0
+vdwjidx0A
,
638 vdwparam
+vdwioffset0
+vdwjidx0B
,&c6_00
,&c12_00
);
640 /* COULOMB ELECTROSTATICS */
641 velec
= _mm_mul_pd(qq00
,rinv00
);
642 felec
= _mm_mul_pd(velec
,rinvsq00
);
644 /* LENNARD-JONES DISPERSION/REPULSION */
646 rinvsix
= _mm_mul_pd(_mm_mul_pd(rinvsq00
,rinvsq00
),rinvsq00
);
647 fvdw
= _mm_mul_pd(_mm_msub_pd(c12_00
,rinvsix
,c6_00
),_mm_mul_pd(rinvsix
,rinvsq00
));
649 fscal
= _mm_add_pd(felec
,fvdw
);
651 /* Update vectorial force */
652 fix0
= _mm_macc_pd(dx00
,fscal
,fix0
);
653 fiy0
= _mm_macc_pd(dy00
,fscal
,fiy0
);
654 fiz0
= _mm_macc_pd(dz00
,fscal
,fiz0
);
656 fjx0
= _mm_macc_pd(dx00
,fscal
,fjx0
);
657 fjy0
= _mm_macc_pd(dy00
,fscal
,fjy0
);
658 fjz0
= _mm_macc_pd(dz00
,fscal
,fjz0
);
660 /**************************
661 * CALCULATE INTERACTIONS *
662 **************************/
664 /* Compute parameters for interactions between i and j atoms */
665 qq10
= _mm_mul_pd(iq1
,jq0
);
667 /* COULOMB ELECTROSTATICS */
668 velec
= _mm_mul_pd(qq10
,rinv10
);
669 felec
= _mm_mul_pd(velec
,rinvsq10
);
673 /* Update vectorial force */
674 fix1
= _mm_macc_pd(dx10
,fscal
,fix1
);
675 fiy1
= _mm_macc_pd(dy10
,fscal
,fiy1
);
676 fiz1
= _mm_macc_pd(dz10
,fscal
,fiz1
);
678 fjx0
= _mm_macc_pd(dx10
,fscal
,fjx0
);
679 fjy0
= _mm_macc_pd(dy10
,fscal
,fjy0
);
680 fjz0
= _mm_macc_pd(dz10
,fscal
,fjz0
);
682 /**************************
683 * CALCULATE INTERACTIONS *
684 **************************/
686 /* Compute parameters for interactions between i and j atoms */
687 qq20
= _mm_mul_pd(iq2
,jq0
);
689 /* COULOMB ELECTROSTATICS */
690 velec
= _mm_mul_pd(qq20
,rinv20
);
691 felec
= _mm_mul_pd(velec
,rinvsq20
);
695 /* Update vectorial force */
696 fix2
= _mm_macc_pd(dx20
,fscal
,fix2
);
697 fiy2
= _mm_macc_pd(dy20
,fscal
,fiy2
);
698 fiz2
= _mm_macc_pd(dz20
,fscal
,fiz2
);
700 fjx0
= _mm_macc_pd(dx20
,fscal
,fjx0
);
701 fjy0
= _mm_macc_pd(dy20
,fscal
,fjy0
);
702 fjz0
= _mm_macc_pd(dz20
,fscal
,fjz0
);
704 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f
+j_coord_offsetA
,f
+j_coord_offsetB
,fjx0
,fjy0
,fjz0
);
706 /* Inner loop uses 100 flops */
713 j_coord_offsetA
= DIM
*jnrA
;
715 /* load j atom coordinates */
716 gmx_mm_load_1rvec_1ptr_swizzle_pd(x
+j_coord_offsetA
,
719 /* Calculate displacement vector */
720 dx00
= _mm_sub_pd(ix0
,jx0
);
721 dy00
= _mm_sub_pd(iy0
,jy0
);
722 dz00
= _mm_sub_pd(iz0
,jz0
);
723 dx10
= _mm_sub_pd(ix1
,jx0
);
724 dy10
= _mm_sub_pd(iy1
,jy0
);
725 dz10
= _mm_sub_pd(iz1
,jz0
);
726 dx20
= _mm_sub_pd(ix2
,jx0
);
727 dy20
= _mm_sub_pd(iy2
,jy0
);
728 dz20
= _mm_sub_pd(iz2
,jz0
);
730 /* Calculate squared distance and things based on it */
731 rsq00
= gmx_mm_calc_rsq_pd(dx00
,dy00
,dz00
);
732 rsq10
= gmx_mm_calc_rsq_pd(dx10
,dy10
,dz10
);
733 rsq20
= gmx_mm_calc_rsq_pd(dx20
,dy20
,dz20
);
735 rinv00
= gmx_mm_invsqrt_pd(rsq00
);
736 rinv10
= gmx_mm_invsqrt_pd(rsq10
);
737 rinv20
= gmx_mm_invsqrt_pd(rsq20
);
739 rinvsq00
= _mm_mul_pd(rinv00
,rinv00
);
740 rinvsq10
= _mm_mul_pd(rinv10
,rinv10
);
741 rinvsq20
= _mm_mul_pd(rinv20
,rinv20
);
743 /* Load parameters for j particles */
744 jq0
= _mm_load_sd(charge
+jnrA
+0);
745 vdwjidx0A
= 2*vdwtype
[jnrA
+0];
747 fjx0
= _mm_setzero_pd();
748 fjy0
= _mm_setzero_pd();
749 fjz0
= _mm_setzero_pd();
751 /**************************
752 * CALCULATE INTERACTIONS *
753 **************************/
755 /* Compute parameters for interactions between i and j atoms */
756 qq00
= _mm_mul_pd(iq0
,jq0
);
757 gmx_mm_load_1pair_swizzle_pd(vdwparam
+vdwioffset0
+vdwjidx0A
,&c6_00
,&c12_00
);
759 /* COULOMB ELECTROSTATICS */
760 velec
= _mm_mul_pd(qq00
,rinv00
);
761 felec
= _mm_mul_pd(velec
,rinvsq00
);
763 /* LENNARD-JONES DISPERSION/REPULSION */
765 rinvsix
= _mm_mul_pd(_mm_mul_pd(rinvsq00
,rinvsq00
),rinvsq00
);
766 fvdw
= _mm_mul_pd(_mm_msub_pd(c12_00
,rinvsix
,c6_00
),_mm_mul_pd(rinvsix
,rinvsq00
));
768 fscal
= _mm_add_pd(felec
,fvdw
);
770 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
772 /* Update vectorial force */
773 fix0
= _mm_macc_pd(dx00
,fscal
,fix0
);
774 fiy0
= _mm_macc_pd(dy00
,fscal
,fiy0
);
775 fiz0
= _mm_macc_pd(dz00
,fscal
,fiz0
);
777 fjx0
= _mm_macc_pd(dx00
,fscal
,fjx0
);
778 fjy0
= _mm_macc_pd(dy00
,fscal
,fjy0
);
779 fjz0
= _mm_macc_pd(dz00
,fscal
,fjz0
);
781 /**************************
782 * CALCULATE INTERACTIONS *
783 **************************/
785 /* Compute parameters for interactions between i and j atoms */
786 qq10
= _mm_mul_pd(iq1
,jq0
);
788 /* COULOMB ELECTROSTATICS */
789 velec
= _mm_mul_pd(qq10
,rinv10
);
790 felec
= _mm_mul_pd(velec
,rinvsq10
);
794 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
796 /* Update vectorial force */
797 fix1
= _mm_macc_pd(dx10
,fscal
,fix1
);
798 fiy1
= _mm_macc_pd(dy10
,fscal
,fiy1
);
799 fiz1
= _mm_macc_pd(dz10
,fscal
,fiz1
);
801 fjx0
= _mm_macc_pd(dx10
,fscal
,fjx0
);
802 fjy0
= _mm_macc_pd(dy10
,fscal
,fjy0
);
803 fjz0
= _mm_macc_pd(dz10
,fscal
,fjz0
);
805 /**************************
806 * CALCULATE INTERACTIONS *
807 **************************/
809 /* Compute parameters for interactions between i and j atoms */
810 qq20
= _mm_mul_pd(iq2
,jq0
);
812 /* COULOMB ELECTROSTATICS */
813 velec
= _mm_mul_pd(qq20
,rinv20
);
814 felec
= _mm_mul_pd(velec
,rinvsq20
);
818 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
820 /* Update vectorial force */
821 fix2
= _mm_macc_pd(dx20
,fscal
,fix2
);
822 fiy2
= _mm_macc_pd(dy20
,fscal
,fiy2
);
823 fiz2
= _mm_macc_pd(dz20
,fscal
,fiz2
);
825 fjx0
= _mm_macc_pd(dx20
,fscal
,fjx0
);
826 fjy0
= _mm_macc_pd(dy20
,fscal
,fjy0
);
827 fjz0
= _mm_macc_pd(dz20
,fscal
,fjz0
);
829 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f
+j_coord_offsetA
,fjx0
,fjy0
,fjz0
);
831 /* Inner loop uses 100 flops */
834 /* End of innermost loop */
836 gmx_mm_update_iforce_3atom_swizzle_pd(fix0
,fiy0
,fiz0
,fix1
,fiy1
,fiz1
,fix2
,fiy2
,fiz2
,
837 f
+i_coord_offset
,fshift
+i_shift_offset
);
839 /* Increment number of inner iterations */
840 inneriter
+= j_index_end
- j_index_start
;
842 /* Outer loop uses 18 flops */
845 /* Increment number of outer iterations */
848 /* Update outer/inner flops */
850 inc_nrnb(nrnb
,eNR_NBKERNEL_ELEC_VDW_W3_F
,outeriter
*18 + inneriter
*100);