2 * Note: this file was generated by the Gromacs avx_128_fma_double kernel generator.
4 * This source code is part of
8 * Copyright (c) 2001-2012, The GROMACS Development Team
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
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
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.
28 #include "../nb_kernel.h"
29 #include "types/simple.h"
33 #include "gmx_math_x86_avx_128_fma_double.h"
34 #include "kernelutil_x86_avx_128_fma_double.h"
37 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwLJ_GeomW4P1_VF_avx_128_fma_double
38 * Electrostatics interaction: Coulomb
39 * VdW interaction: LennardJones
40 * Geometry: Water4-Particle
41 * Calculate force/pot: PotentialAndForce
44 nb_kernel_ElecCoul_VdwLJ_GeomW4P1_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)
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.
58 int i_shift_offset,i_coord_offset,outeriter,inneriter;
59 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
61 int j_coord_offsetA,j_coord_offsetB;
62 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
64 real *shiftvec,*fshift,*x,*f;
65 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
67 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
69 __m128d ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
71 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
73 __m128d ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
74 int vdwjidx0A,vdwjidx0B;
75 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
76 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
77 __m128d dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
78 __m128d dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
79 __m128d dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
80 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
83 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
86 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
87 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
88 __m128d dummy_mask,cutoff_mask;
89 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
90 __m128d one = _mm_set1_pd(1.0);
91 __m128d two = _mm_set1_pd(2.0);
97 jindex = nlist->jindex;
99 shiftidx = nlist->shift;
101 shiftvec = fr->shift_vec[0];
102 fshift = fr->fshift[0];
103 facel = _mm_set1_pd(fr->epsfac);
104 charge = mdatoms->chargeA;
105 nvdwtype = fr->ntype;
107 vdwtype = mdatoms->typeA;
109 /* Setup water-specific parameters */
110 inr = nlist->iinr[0];
111 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
112 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
113 iq3 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+3]));
114 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
116 /* Avoid stupid compiler warnings */
124 /* Start outer loop over neighborlists */
125 for(iidx=0; iidx<nri; iidx++)
127 /* Load shift vector for this list */
128 i_shift_offset = DIM*shiftidx[iidx];
130 /* Load limits for loop over neighbors */
131 j_index_start = jindex[iidx];
132 j_index_end = jindex[iidx+1];
134 /* Get outer coordinate index */
136 i_coord_offset = DIM*inr;
138 /* Load i particle coords and add shift vector */
139 gmx_mm_load_shift_and_4rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,
140 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
142 fix0 = _mm_setzero_pd();
143 fiy0 = _mm_setzero_pd();
144 fiz0 = _mm_setzero_pd();
145 fix1 = _mm_setzero_pd();
146 fiy1 = _mm_setzero_pd();
147 fiz1 = _mm_setzero_pd();
148 fix2 = _mm_setzero_pd();
149 fiy2 = _mm_setzero_pd();
150 fiz2 = _mm_setzero_pd();
151 fix3 = _mm_setzero_pd();
152 fiy3 = _mm_setzero_pd();
153 fiz3 = _mm_setzero_pd();
155 /* Reset potential sums */
156 velecsum = _mm_setzero_pd();
157 vvdwsum = _mm_setzero_pd();
159 /* Start inner kernel loop */
160 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
163 /* Get j neighbor index, and coordinate index */
166 j_coord_offsetA = DIM*jnrA;
167 j_coord_offsetB = DIM*jnrB;
169 /* load j atom coordinates */
170 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
173 /* Calculate displacement vector */
174 dx00 = _mm_sub_pd(ix0,jx0);
175 dy00 = _mm_sub_pd(iy0,jy0);
176 dz00 = _mm_sub_pd(iz0,jz0);
177 dx10 = _mm_sub_pd(ix1,jx0);
178 dy10 = _mm_sub_pd(iy1,jy0);
179 dz10 = _mm_sub_pd(iz1,jz0);
180 dx20 = _mm_sub_pd(ix2,jx0);
181 dy20 = _mm_sub_pd(iy2,jy0);
182 dz20 = _mm_sub_pd(iz2,jz0);
183 dx30 = _mm_sub_pd(ix3,jx0);
184 dy30 = _mm_sub_pd(iy3,jy0);
185 dz30 = _mm_sub_pd(iz3,jz0);
187 /* Calculate squared distance and things based on it */
188 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
189 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
190 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
191 rsq30 = gmx_mm_calc_rsq_pd(dx30,dy30,dz30);
193 rinv10 = gmx_mm_invsqrt_pd(rsq10);
194 rinv20 = gmx_mm_invsqrt_pd(rsq20);
195 rinv30 = gmx_mm_invsqrt_pd(rsq30);
197 rinvsq00 = gmx_mm_inv_pd(rsq00);
198 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
199 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
200 rinvsq30 = _mm_mul_pd(rinv30,rinv30);
202 /* Load parameters for j particles */
203 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
204 vdwjidx0A = 2*vdwtype[jnrA+0];
205 vdwjidx0B = 2*vdwtype[jnrB+0];
207 fjx0 = _mm_setzero_pd();
208 fjy0 = _mm_setzero_pd();
209 fjz0 = _mm_setzero_pd();
211 /**************************
212 * CALCULATE INTERACTIONS *
213 **************************/
215 /* Compute parameters for interactions between i and j atoms */
216 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
217 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
219 /* LENNARD-JONES DISPERSION/REPULSION */
221 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
222 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
223 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
224 vvdw = _mm_msub_pd( vvdw12,one_twelfth, _mm_mul_pd(vvdw6,one_sixth) );
225 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
227 /* Update potential sum for this i atom from the interaction with this j atom. */
228 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
232 /* Update vectorial force */
233 fix0 = _mm_macc_pd(dx00,fscal,fix0);
234 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
235 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
237 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
238 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
239 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
241 /**************************
242 * CALCULATE INTERACTIONS *
243 **************************/
245 /* Compute parameters for interactions between i and j atoms */
246 qq10 = _mm_mul_pd(iq1,jq0);
248 /* COULOMB ELECTROSTATICS */
249 velec = _mm_mul_pd(qq10,rinv10);
250 felec = _mm_mul_pd(velec,rinvsq10);
252 /* Update potential sum for this i atom from the interaction with this j atom. */
253 velecsum = _mm_add_pd(velecsum,velec);
257 /* Update vectorial force */
258 fix1 = _mm_macc_pd(dx10,fscal,fix1);
259 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
260 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
262 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
263 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
264 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
266 /**************************
267 * CALCULATE INTERACTIONS *
268 **************************/
270 /* Compute parameters for interactions between i and j atoms */
271 qq20 = _mm_mul_pd(iq2,jq0);
273 /* COULOMB ELECTROSTATICS */
274 velec = _mm_mul_pd(qq20,rinv20);
275 felec = _mm_mul_pd(velec,rinvsq20);
277 /* Update potential sum for this i atom from the interaction with this j atom. */
278 velecsum = _mm_add_pd(velecsum,velec);
282 /* Update vectorial force */
283 fix2 = _mm_macc_pd(dx20,fscal,fix2);
284 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
285 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
287 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
288 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
289 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
291 /**************************
292 * CALCULATE INTERACTIONS *
293 **************************/
295 /* Compute parameters for interactions between i and j atoms */
296 qq30 = _mm_mul_pd(iq3,jq0);
298 /* COULOMB ELECTROSTATICS */
299 velec = _mm_mul_pd(qq30,rinv30);
300 felec = _mm_mul_pd(velec,rinvsq30);
302 /* Update potential sum for this i atom from the interaction with this j atom. */
303 velecsum = _mm_add_pd(velecsum,velec);
307 /* Update vectorial force */
308 fix3 = _mm_macc_pd(dx30,fscal,fix3);
309 fiy3 = _mm_macc_pd(dy30,fscal,fiy3);
310 fiz3 = _mm_macc_pd(dz30,fscal,fiz3);
312 fjx0 = _mm_macc_pd(dx30,fscal,fjx0);
313 fjy0 = _mm_macc_pd(dy30,fscal,fjy0);
314 fjz0 = _mm_macc_pd(dz30,fscal,fjz0);
316 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
318 /* Inner loop uses 131 flops */
325 j_coord_offsetA = DIM*jnrA;
327 /* load j atom coordinates */
328 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
331 /* Calculate displacement vector */
332 dx00 = _mm_sub_pd(ix0,jx0);
333 dy00 = _mm_sub_pd(iy0,jy0);
334 dz00 = _mm_sub_pd(iz0,jz0);
335 dx10 = _mm_sub_pd(ix1,jx0);
336 dy10 = _mm_sub_pd(iy1,jy0);
337 dz10 = _mm_sub_pd(iz1,jz0);
338 dx20 = _mm_sub_pd(ix2,jx0);
339 dy20 = _mm_sub_pd(iy2,jy0);
340 dz20 = _mm_sub_pd(iz2,jz0);
341 dx30 = _mm_sub_pd(ix3,jx0);
342 dy30 = _mm_sub_pd(iy3,jy0);
343 dz30 = _mm_sub_pd(iz3,jz0);
345 /* Calculate squared distance and things based on it */
346 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
347 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
348 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
349 rsq30 = gmx_mm_calc_rsq_pd(dx30,dy30,dz30);
351 rinv10 = gmx_mm_invsqrt_pd(rsq10);
352 rinv20 = gmx_mm_invsqrt_pd(rsq20);
353 rinv30 = gmx_mm_invsqrt_pd(rsq30);
355 rinvsq00 = gmx_mm_inv_pd(rsq00);
356 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
357 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
358 rinvsq30 = _mm_mul_pd(rinv30,rinv30);
360 /* Load parameters for j particles */
361 jq0 = _mm_load_sd(charge+jnrA+0);
362 vdwjidx0A = 2*vdwtype[jnrA+0];
364 fjx0 = _mm_setzero_pd();
365 fjy0 = _mm_setzero_pd();
366 fjz0 = _mm_setzero_pd();
368 /**************************
369 * CALCULATE INTERACTIONS *
370 **************************/
372 /* Compute parameters for interactions between i and j atoms */
373 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
375 /* LENNARD-JONES DISPERSION/REPULSION */
377 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
378 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
379 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
380 vvdw = _mm_msub_pd( vvdw12,one_twelfth, _mm_mul_pd(vvdw6,one_sixth) );
381 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
383 /* Update potential sum for this i atom from the interaction with this j atom. */
384 vvdw = _mm_unpacklo_pd(vvdw,_mm_setzero_pd());
385 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
389 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
391 /* Update vectorial force */
392 fix0 = _mm_macc_pd(dx00,fscal,fix0);
393 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
394 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
396 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
397 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
398 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
400 /**************************
401 * CALCULATE INTERACTIONS *
402 **************************/
404 /* Compute parameters for interactions between i and j atoms */
405 qq10 = _mm_mul_pd(iq1,jq0);
407 /* COULOMB ELECTROSTATICS */
408 velec = _mm_mul_pd(qq10,rinv10);
409 felec = _mm_mul_pd(velec,rinvsq10);
411 /* Update potential sum for this i atom from the interaction with this j atom. */
412 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
413 velecsum = _mm_add_pd(velecsum,velec);
417 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
419 /* Update vectorial force */
420 fix1 = _mm_macc_pd(dx10,fscal,fix1);
421 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
422 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
424 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
425 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
426 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
428 /**************************
429 * CALCULATE INTERACTIONS *
430 **************************/
432 /* Compute parameters for interactions between i and j atoms */
433 qq20 = _mm_mul_pd(iq2,jq0);
435 /* COULOMB ELECTROSTATICS */
436 velec = _mm_mul_pd(qq20,rinv20);
437 felec = _mm_mul_pd(velec,rinvsq20);
439 /* Update potential sum for this i atom from the interaction with this j atom. */
440 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
441 velecsum = _mm_add_pd(velecsum,velec);
445 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
447 /* Update vectorial force */
448 fix2 = _mm_macc_pd(dx20,fscal,fix2);
449 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
450 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
452 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
453 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
454 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
456 /**************************
457 * CALCULATE INTERACTIONS *
458 **************************/
460 /* Compute parameters for interactions between i and j atoms */
461 qq30 = _mm_mul_pd(iq3,jq0);
463 /* COULOMB ELECTROSTATICS */
464 velec = _mm_mul_pd(qq30,rinv30);
465 felec = _mm_mul_pd(velec,rinvsq30);
467 /* Update potential sum for this i atom from the interaction with this j atom. */
468 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
469 velecsum = _mm_add_pd(velecsum,velec);
473 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
475 /* Update vectorial force */
476 fix3 = _mm_macc_pd(dx30,fscal,fix3);
477 fiy3 = _mm_macc_pd(dy30,fscal,fiy3);
478 fiz3 = _mm_macc_pd(dz30,fscal,fiz3);
480 fjx0 = _mm_macc_pd(dx30,fscal,fjx0);
481 fjy0 = _mm_macc_pd(dy30,fscal,fjy0);
482 fjz0 = _mm_macc_pd(dz30,fscal,fjz0);
484 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,fjx0,fjy0,fjz0);
486 /* Inner loop uses 131 flops */
489 /* End of innermost loop */
491 gmx_mm_update_iforce_4atom_swizzle_pd(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
492 f+i_coord_offset,fshift+i_shift_offset);
495 /* Update potential energies */
496 gmx_mm_update_1pot_pd(velecsum,kernel_data->energygrp_elec+ggid);
497 gmx_mm_update_1pot_pd(vvdwsum,kernel_data->energygrp_vdw+ggid);
499 /* Increment number of inner iterations */
500 inneriter += j_index_end - j_index_start;
502 /* Outer loop uses 26 flops */
505 /* Increment number of outer iterations */
508 /* Update outer/inner flops */
510 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*26 + inneriter*131);
513 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwLJ_GeomW4P1_F_avx_128_fma_double
514 * Electrostatics interaction: Coulomb
515 * VdW interaction: LennardJones
516 * Geometry: Water4-Particle
517 * Calculate force/pot: Force
520 nb_kernel_ElecCoul_VdwLJ_GeomW4P1_F_avx_128_fma_double
521 (t_nblist * gmx_restrict nlist,
522 rvec * gmx_restrict xx,
523 rvec * gmx_restrict ff,
524 t_forcerec * gmx_restrict fr,
525 t_mdatoms * gmx_restrict mdatoms,
526 nb_kernel_data_t * gmx_restrict kernel_data,
527 t_nrnb * gmx_restrict nrnb)
529 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
530 * just 0 for non-waters.
531 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
532 * jnr indices corresponding to data put in the four positions in the SIMD register.
534 int i_shift_offset,i_coord_offset,outeriter,inneriter;
535 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
537 int j_coord_offsetA,j_coord_offsetB;
538 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
540 real *shiftvec,*fshift,*x,*f;
541 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
543 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
545 __m128d ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
547 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
549 __m128d ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
550 int vdwjidx0A,vdwjidx0B;
551 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
552 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
553 __m128d dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
554 __m128d dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
555 __m128d dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
556 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
559 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
562 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
563 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
564 __m128d dummy_mask,cutoff_mask;
565 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
566 __m128d one = _mm_set1_pd(1.0);
567 __m128d two = _mm_set1_pd(2.0);
573 jindex = nlist->jindex;
575 shiftidx = nlist->shift;
577 shiftvec = fr->shift_vec[0];
578 fshift = fr->fshift[0];
579 facel = _mm_set1_pd(fr->epsfac);
580 charge = mdatoms->chargeA;
581 nvdwtype = fr->ntype;
583 vdwtype = mdatoms->typeA;
585 /* Setup water-specific parameters */
586 inr = nlist->iinr[0];
587 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
588 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
589 iq3 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+3]));
590 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
592 /* Avoid stupid compiler warnings */
600 /* Start outer loop over neighborlists */
601 for(iidx=0; iidx<nri; iidx++)
603 /* Load shift vector for this list */
604 i_shift_offset = DIM*shiftidx[iidx];
606 /* Load limits for loop over neighbors */
607 j_index_start = jindex[iidx];
608 j_index_end = jindex[iidx+1];
610 /* Get outer coordinate index */
612 i_coord_offset = DIM*inr;
614 /* Load i particle coords and add shift vector */
615 gmx_mm_load_shift_and_4rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,
616 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
618 fix0 = _mm_setzero_pd();
619 fiy0 = _mm_setzero_pd();
620 fiz0 = _mm_setzero_pd();
621 fix1 = _mm_setzero_pd();
622 fiy1 = _mm_setzero_pd();
623 fiz1 = _mm_setzero_pd();
624 fix2 = _mm_setzero_pd();
625 fiy2 = _mm_setzero_pd();
626 fiz2 = _mm_setzero_pd();
627 fix3 = _mm_setzero_pd();
628 fiy3 = _mm_setzero_pd();
629 fiz3 = _mm_setzero_pd();
631 /* Start inner kernel loop */
632 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
635 /* Get j neighbor index, and coordinate index */
638 j_coord_offsetA = DIM*jnrA;
639 j_coord_offsetB = DIM*jnrB;
641 /* load j atom coordinates */
642 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
645 /* Calculate displacement vector */
646 dx00 = _mm_sub_pd(ix0,jx0);
647 dy00 = _mm_sub_pd(iy0,jy0);
648 dz00 = _mm_sub_pd(iz0,jz0);
649 dx10 = _mm_sub_pd(ix1,jx0);
650 dy10 = _mm_sub_pd(iy1,jy0);
651 dz10 = _mm_sub_pd(iz1,jz0);
652 dx20 = _mm_sub_pd(ix2,jx0);
653 dy20 = _mm_sub_pd(iy2,jy0);
654 dz20 = _mm_sub_pd(iz2,jz0);
655 dx30 = _mm_sub_pd(ix3,jx0);
656 dy30 = _mm_sub_pd(iy3,jy0);
657 dz30 = _mm_sub_pd(iz3,jz0);
659 /* Calculate squared distance and things based on it */
660 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
661 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
662 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
663 rsq30 = gmx_mm_calc_rsq_pd(dx30,dy30,dz30);
665 rinv10 = gmx_mm_invsqrt_pd(rsq10);
666 rinv20 = gmx_mm_invsqrt_pd(rsq20);
667 rinv30 = gmx_mm_invsqrt_pd(rsq30);
669 rinvsq00 = gmx_mm_inv_pd(rsq00);
670 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
671 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
672 rinvsq30 = _mm_mul_pd(rinv30,rinv30);
674 /* Load parameters for j particles */
675 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
676 vdwjidx0A = 2*vdwtype[jnrA+0];
677 vdwjidx0B = 2*vdwtype[jnrB+0];
679 fjx0 = _mm_setzero_pd();
680 fjy0 = _mm_setzero_pd();
681 fjz0 = _mm_setzero_pd();
683 /**************************
684 * CALCULATE INTERACTIONS *
685 **************************/
687 /* Compute parameters for interactions between i and j atoms */
688 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
689 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
691 /* LENNARD-JONES DISPERSION/REPULSION */
693 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
694 fvdw = _mm_mul_pd(_mm_msub_pd(c12_00,rinvsix,c6_00),_mm_mul_pd(rinvsix,rinvsq00));
698 /* Update vectorial force */
699 fix0 = _mm_macc_pd(dx00,fscal,fix0);
700 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
701 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
703 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
704 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
705 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
707 /**************************
708 * CALCULATE INTERACTIONS *
709 **************************/
711 /* Compute parameters for interactions between i and j atoms */
712 qq10 = _mm_mul_pd(iq1,jq0);
714 /* COULOMB ELECTROSTATICS */
715 velec = _mm_mul_pd(qq10,rinv10);
716 felec = _mm_mul_pd(velec,rinvsq10);
720 /* Update vectorial force */
721 fix1 = _mm_macc_pd(dx10,fscal,fix1);
722 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
723 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
725 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
726 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
727 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
729 /**************************
730 * CALCULATE INTERACTIONS *
731 **************************/
733 /* Compute parameters for interactions between i and j atoms */
734 qq20 = _mm_mul_pd(iq2,jq0);
736 /* COULOMB ELECTROSTATICS */
737 velec = _mm_mul_pd(qq20,rinv20);
738 felec = _mm_mul_pd(velec,rinvsq20);
742 /* Update vectorial force */
743 fix2 = _mm_macc_pd(dx20,fscal,fix2);
744 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
745 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
747 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
748 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
749 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
751 /**************************
752 * CALCULATE INTERACTIONS *
753 **************************/
755 /* Compute parameters for interactions between i and j atoms */
756 qq30 = _mm_mul_pd(iq3,jq0);
758 /* COULOMB ELECTROSTATICS */
759 velec = _mm_mul_pd(qq30,rinv30);
760 felec = _mm_mul_pd(velec,rinvsq30);
764 /* Update vectorial force */
765 fix3 = _mm_macc_pd(dx30,fscal,fix3);
766 fiy3 = _mm_macc_pd(dy30,fscal,fiy3);
767 fiz3 = _mm_macc_pd(dz30,fscal,fiz3);
769 fjx0 = _mm_macc_pd(dx30,fscal,fjx0);
770 fjy0 = _mm_macc_pd(dy30,fscal,fjy0);
771 fjz0 = _mm_macc_pd(dz30,fscal,fjz0);
773 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
775 /* Inner loop uses 123 flops */
782 j_coord_offsetA = DIM*jnrA;
784 /* load j atom coordinates */
785 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
788 /* Calculate displacement vector */
789 dx00 = _mm_sub_pd(ix0,jx0);
790 dy00 = _mm_sub_pd(iy0,jy0);
791 dz00 = _mm_sub_pd(iz0,jz0);
792 dx10 = _mm_sub_pd(ix1,jx0);
793 dy10 = _mm_sub_pd(iy1,jy0);
794 dz10 = _mm_sub_pd(iz1,jz0);
795 dx20 = _mm_sub_pd(ix2,jx0);
796 dy20 = _mm_sub_pd(iy2,jy0);
797 dz20 = _mm_sub_pd(iz2,jz0);
798 dx30 = _mm_sub_pd(ix3,jx0);
799 dy30 = _mm_sub_pd(iy3,jy0);
800 dz30 = _mm_sub_pd(iz3,jz0);
802 /* Calculate squared distance and things based on it */
803 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
804 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
805 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
806 rsq30 = gmx_mm_calc_rsq_pd(dx30,dy30,dz30);
808 rinv10 = gmx_mm_invsqrt_pd(rsq10);
809 rinv20 = gmx_mm_invsqrt_pd(rsq20);
810 rinv30 = gmx_mm_invsqrt_pd(rsq30);
812 rinvsq00 = gmx_mm_inv_pd(rsq00);
813 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
814 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
815 rinvsq30 = _mm_mul_pd(rinv30,rinv30);
817 /* Load parameters for j particles */
818 jq0 = _mm_load_sd(charge+jnrA+0);
819 vdwjidx0A = 2*vdwtype[jnrA+0];
821 fjx0 = _mm_setzero_pd();
822 fjy0 = _mm_setzero_pd();
823 fjz0 = _mm_setzero_pd();
825 /**************************
826 * CALCULATE INTERACTIONS *
827 **************************/
829 /* Compute parameters for interactions between i and j atoms */
830 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
832 /* LENNARD-JONES DISPERSION/REPULSION */
834 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
835 fvdw = _mm_mul_pd(_mm_msub_pd(c12_00,rinvsix,c6_00),_mm_mul_pd(rinvsix,rinvsq00));
839 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
841 /* Update vectorial force */
842 fix0 = _mm_macc_pd(dx00,fscal,fix0);
843 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
844 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
846 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
847 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
848 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
850 /**************************
851 * CALCULATE INTERACTIONS *
852 **************************/
854 /* Compute parameters for interactions between i and j atoms */
855 qq10 = _mm_mul_pd(iq1,jq0);
857 /* COULOMB ELECTROSTATICS */
858 velec = _mm_mul_pd(qq10,rinv10);
859 felec = _mm_mul_pd(velec,rinvsq10);
863 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
865 /* Update vectorial force */
866 fix1 = _mm_macc_pd(dx10,fscal,fix1);
867 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
868 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
870 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
871 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
872 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
874 /**************************
875 * CALCULATE INTERACTIONS *
876 **************************/
878 /* Compute parameters for interactions between i and j atoms */
879 qq20 = _mm_mul_pd(iq2,jq0);
881 /* COULOMB ELECTROSTATICS */
882 velec = _mm_mul_pd(qq20,rinv20);
883 felec = _mm_mul_pd(velec,rinvsq20);
887 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
889 /* Update vectorial force */
890 fix2 = _mm_macc_pd(dx20,fscal,fix2);
891 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
892 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
894 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
895 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
896 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
898 /**************************
899 * CALCULATE INTERACTIONS *
900 **************************/
902 /* Compute parameters for interactions between i and j atoms */
903 qq30 = _mm_mul_pd(iq3,jq0);
905 /* COULOMB ELECTROSTATICS */
906 velec = _mm_mul_pd(qq30,rinv30);
907 felec = _mm_mul_pd(velec,rinvsq30);
911 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
913 /* Update vectorial force */
914 fix3 = _mm_macc_pd(dx30,fscal,fix3);
915 fiy3 = _mm_macc_pd(dy30,fscal,fiy3);
916 fiz3 = _mm_macc_pd(dz30,fscal,fiz3);
918 fjx0 = _mm_macc_pd(dx30,fscal,fjx0);
919 fjy0 = _mm_macc_pd(dy30,fscal,fjy0);
920 fjz0 = _mm_macc_pd(dz30,fscal,fjz0);
922 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,fjx0,fjy0,fjz0);
924 /* Inner loop uses 123 flops */
927 /* End of innermost loop */
929 gmx_mm_update_iforce_4atom_swizzle_pd(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
930 f+i_coord_offset,fshift+i_shift_offset);
932 /* Increment number of inner iterations */
933 inneriter += j_index_end - j_index_start;
935 /* Outer loop uses 24 flops */
938 /* Increment number of outer iterations */
941 /* Update outer/inner flops */
943 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*24 + inneriter*123);