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_GeomW3P1_VF_avx_128_fma_double
38 * Electrostatics interaction: Coulomb
39 * VdW interaction: LennardJones
40 * Geometry: Water3-Particle
41 * Calculate force/pot: PotentialAndForce
44 nb_kernel_ElecCoul_VdwLJ_GeomW3P1_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;
72 int vdwjidx0A,vdwjidx0B;
73 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
74 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
75 __m128d dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
76 __m128d dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
77 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
80 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
83 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
84 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
85 __m128d dummy_mask,cutoff_mask;
86 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
87 __m128d one = _mm_set1_pd(1.0);
88 __m128d two = _mm_set1_pd(2.0);
94 jindex = nlist->jindex;
96 shiftidx = nlist->shift;
98 shiftvec = fr->shift_vec[0];
99 fshift = fr->fshift[0];
100 facel = _mm_set1_pd(fr->epsfac);
101 charge = mdatoms->chargeA;
102 nvdwtype = fr->ntype;
104 vdwtype = mdatoms->typeA;
106 /* Setup water-specific parameters */
107 inr = nlist->iinr[0];
108 iq0 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+0]));
109 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
110 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
111 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
113 /* Avoid stupid compiler warnings */
121 /* Start outer loop over neighborlists */
122 for(iidx=0; iidx<nri; iidx++)
124 /* Load shift vector for this list */
125 i_shift_offset = DIM*shiftidx[iidx];
127 /* Load limits for loop over neighbors */
128 j_index_start = jindex[iidx];
129 j_index_end = jindex[iidx+1];
131 /* Get outer coordinate index */
133 i_coord_offset = DIM*inr;
135 /* Load i particle coords and add shift vector */
136 gmx_mm_load_shift_and_3rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,
137 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
139 fix0 = _mm_setzero_pd();
140 fiy0 = _mm_setzero_pd();
141 fiz0 = _mm_setzero_pd();
142 fix1 = _mm_setzero_pd();
143 fiy1 = _mm_setzero_pd();
144 fiz1 = _mm_setzero_pd();
145 fix2 = _mm_setzero_pd();
146 fiy2 = _mm_setzero_pd();
147 fiz2 = _mm_setzero_pd();
149 /* Reset potential sums */
150 velecsum = _mm_setzero_pd();
151 vvdwsum = _mm_setzero_pd();
153 /* Start inner kernel loop */
154 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
157 /* Get j neighbor index, and coordinate index */
160 j_coord_offsetA = DIM*jnrA;
161 j_coord_offsetB = DIM*jnrB;
163 /* load j atom coordinates */
164 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
167 /* Calculate displacement vector */
168 dx00 = _mm_sub_pd(ix0,jx0);
169 dy00 = _mm_sub_pd(iy0,jy0);
170 dz00 = _mm_sub_pd(iz0,jz0);
171 dx10 = _mm_sub_pd(ix1,jx0);
172 dy10 = _mm_sub_pd(iy1,jy0);
173 dz10 = _mm_sub_pd(iz1,jz0);
174 dx20 = _mm_sub_pd(ix2,jx0);
175 dy20 = _mm_sub_pd(iy2,jy0);
176 dz20 = _mm_sub_pd(iz2,jz0);
178 /* Calculate squared distance and things based on it */
179 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
180 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
181 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
183 rinv00 = gmx_mm_invsqrt_pd(rsq00);
184 rinv10 = gmx_mm_invsqrt_pd(rsq10);
185 rinv20 = gmx_mm_invsqrt_pd(rsq20);
187 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
188 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
189 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
191 /* Load parameters for j particles */
192 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
193 vdwjidx0A = 2*vdwtype[jnrA+0];
194 vdwjidx0B = 2*vdwtype[jnrB+0];
196 fjx0 = _mm_setzero_pd();
197 fjy0 = _mm_setzero_pd();
198 fjz0 = _mm_setzero_pd();
200 /**************************
201 * CALCULATE INTERACTIONS *
202 **************************/
204 /* Compute parameters for interactions between i and j atoms */
205 qq00 = _mm_mul_pd(iq0,jq0);
206 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
207 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
209 /* COULOMB ELECTROSTATICS */
210 velec = _mm_mul_pd(qq00,rinv00);
211 felec = _mm_mul_pd(velec,rinvsq00);
213 /* LENNARD-JONES DISPERSION/REPULSION */
215 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
216 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
217 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
218 vvdw = _mm_msub_pd( vvdw12,one_twelfth, _mm_mul_pd(vvdw6,one_sixth) );
219 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
221 /* Update potential sum for this i atom from the interaction with this j atom. */
222 velecsum = _mm_add_pd(velecsum,velec);
223 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
225 fscal = _mm_add_pd(felec,fvdw);
227 /* Update vectorial force */
228 fix0 = _mm_macc_pd(dx00,fscal,fix0);
229 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
230 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
232 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
233 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
234 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
236 /**************************
237 * CALCULATE INTERACTIONS *
238 **************************/
240 /* Compute parameters for interactions between i and j atoms */
241 qq10 = _mm_mul_pd(iq1,jq0);
243 /* COULOMB ELECTROSTATICS */
244 velec = _mm_mul_pd(qq10,rinv10);
245 felec = _mm_mul_pd(velec,rinvsq10);
247 /* Update potential sum for this i atom from the interaction with this j atom. */
248 velecsum = _mm_add_pd(velecsum,velec);
252 /* Update vectorial force */
253 fix1 = _mm_macc_pd(dx10,fscal,fix1);
254 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
255 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
257 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
258 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
259 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
261 /**************************
262 * CALCULATE INTERACTIONS *
263 **************************/
265 /* Compute parameters for interactions between i and j atoms */
266 qq20 = _mm_mul_pd(iq2,jq0);
268 /* COULOMB ELECTROSTATICS */
269 velec = _mm_mul_pd(qq20,rinv20);
270 felec = _mm_mul_pd(velec,rinvsq20);
272 /* Update potential sum for this i atom from the interaction with this j atom. */
273 velecsum = _mm_add_pd(velecsum,velec);
277 /* Update vectorial force */
278 fix2 = _mm_macc_pd(dx20,fscal,fix2);
279 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
280 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
282 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
283 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
284 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
286 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
288 /* Inner loop uses 108 flops */
295 j_coord_offsetA = DIM*jnrA;
297 /* load j atom coordinates */
298 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
301 /* Calculate displacement vector */
302 dx00 = _mm_sub_pd(ix0,jx0);
303 dy00 = _mm_sub_pd(iy0,jy0);
304 dz00 = _mm_sub_pd(iz0,jz0);
305 dx10 = _mm_sub_pd(ix1,jx0);
306 dy10 = _mm_sub_pd(iy1,jy0);
307 dz10 = _mm_sub_pd(iz1,jz0);
308 dx20 = _mm_sub_pd(ix2,jx0);
309 dy20 = _mm_sub_pd(iy2,jy0);
310 dz20 = _mm_sub_pd(iz2,jz0);
312 /* Calculate squared distance and things based on it */
313 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
314 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
315 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
317 rinv00 = gmx_mm_invsqrt_pd(rsq00);
318 rinv10 = gmx_mm_invsqrt_pd(rsq10);
319 rinv20 = gmx_mm_invsqrt_pd(rsq20);
321 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
322 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
323 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
325 /* Load parameters for j particles */
326 jq0 = _mm_load_sd(charge+jnrA+0);
327 vdwjidx0A = 2*vdwtype[jnrA+0];
329 fjx0 = _mm_setzero_pd();
330 fjy0 = _mm_setzero_pd();
331 fjz0 = _mm_setzero_pd();
333 /**************************
334 * CALCULATE INTERACTIONS *
335 **************************/
337 /* Compute parameters for interactions between i and j atoms */
338 qq00 = _mm_mul_pd(iq0,jq0);
339 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
341 /* COULOMB ELECTROSTATICS */
342 velec = _mm_mul_pd(qq00,rinv00);
343 felec = _mm_mul_pd(velec,rinvsq00);
345 /* LENNARD-JONES DISPERSION/REPULSION */
347 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
348 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
349 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
350 vvdw = _mm_msub_pd( vvdw12,one_twelfth, _mm_mul_pd(vvdw6,one_sixth) );
351 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
353 /* Update potential sum for this i atom from the interaction with this j atom. */
354 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
355 velecsum = _mm_add_pd(velecsum,velec);
356 vvdw = _mm_unpacklo_pd(vvdw,_mm_setzero_pd());
357 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
359 fscal = _mm_add_pd(felec,fvdw);
361 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
363 /* Update vectorial force */
364 fix0 = _mm_macc_pd(dx00,fscal,fix0);
365 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
366 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
368 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
369 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
370 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
372 /**************************
373 * CALCULATE INTERACTIONS *
374 **************************/
376 /* Compute parameters for interactions between i and j atoms */
377 qq10 = _mm_mul_pd(iq1,jq0);
379 /* COULOMB ELECTROSTATICS */
380 velec = _mm_mul_pd(qq10,rinv10);
381 felec = _mm_mul_pd(velec,rinvsq10);
383 /* Update potential sum for this i atom from the interaction with this j atom. */
384 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
385 velecsum = _mm_add_pd(velecsum,velec);
389 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
391 /* Update vectorial force */
392 fix1 = _mm_macc_pd(dx10,fscal,fix1);
393 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
394 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
396 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
397 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
398 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
400 /**************************
401 * CALCULATE INTERACTIONS *
402 **************************/
404 /* Compute parameters for interactions between i and j atoms */
405 qq20 = _mm_mul_pd(iq2,jq0);
407 /* COULOMB ELECTROSTATICS */
408 velec = _mm_mul_pd(qq20,rinv20);
409 felec = _mm_mul_pd(velec,rinvsq20);
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 fix2 = _mm_macc_pd(dx20,fscal,fix2);
421 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
422 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
424 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
425 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
426 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
428 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,fjx0,fjy0,fjz0);
430 /* Inner loop uses 108 flops */
433 /* End of innermost loop */
435 gmx_mm_update_iforce_3atom_swizzle_pd(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
436 f+i_coord_offset,fshift+i_shift_offset);
439 /* Update potential energies */
440 gmx_mm_update_1pot_pd(velecsum,kernel_data->energygrp_elec+ggid);
441 gmx_mm_update_1pot_pd(vvdwsum,kernel_data->energygrp_vdw+ggid);
443 /* Increment number of inner iterations */
444 inneriter += j_index_end - j_index_start;
446 /* Outer loop uses 20 flops */
449 /* Increment number of outer iterations */
452 /* Update outer/inner flops */
454 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*20 + inneriter*108);
457 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwLJ_GeomW3P1_F_avx_128_fma_double
458 * Electrostatics interaction: Coulomb
459 * VdW interaction: LennardJones
460 * Geometry: Water3-Particle
461 * Calculate force/pot: Force
464 nb_kernel_ElecCoul_VdwLJ_GeomW3P1_F_avx_128_fma_double
465 (t_nblist * gmx_restrict nlist,
466 rvec * gmx_restrict xx,
467 rvec * gmx_restrict ff,
468 t_forcerec * gmx_restrict fr,
469 t_mdatoms * gmx_restrict mdatoms,
470 nb_kernel_data_t * gmx_restrict kernel_data,
471 t_nrnb * gmx_restrict nrnb)
473 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
474 * just 0 for non-waters.
475 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
476 * jnr indices corresponding to data put in the four positions in the SIMD register.
478 int i_shift_offset,i_coord_offset,outeriter,inneriter;
479 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
481 int j_coord_offsetA,j_coord_offsetB;
482 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
484 real *shiftvec,*fshift,*x,*f;
485 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
487 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
489 __m128d ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
491 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
492 int vdwjidx0A,vdwjidx0B;
493 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
494 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
495 __m128d dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
496 __m128d dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
497 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
500 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
503 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
504 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
505 __m128d dummy_mask,cutoff_mask;
506 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
507 __m128d one = _mm_set1_pd(1.0);
508 __m128d two = _mm_set1_pd(2.0);
514 jindex = nlist->jindex;
516 shiftidx = nlist->shift;
518 shiftvec = fr->shift_vec[0];
519 fshift = fr->fshift[0];
520 facel = _mm_set1_pd(fr->epsfac);
521 charge = mdatoms->chargeA;
522 nvdwtype = fr->ntype;
524 vdwtype = mdatoms->typeA;
526 /* Setup water-specific parameters */
527 inr = nlist->iinr[0];
528 iq0 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+0]));
529 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
530 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
531 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
533 /* Avoid stupid compiler warnings */
541 /* Start outer loop over neighborlists */
542 for(iidx=0; iidx<nri; iidx++)
544 /* Load shift vector for this list */
545 i_shift_offset = DIM*shiftidx[iidx];
547 /* Load limits for loop over neighbors */
548 j_index_start = jindex[iidx];
549 j_index_end = jindex[iidx+1];
551 /* Get outer coordinate index */
553 i_coord_offset = DIM*inr;
555 /* Load i particle coords and add shift vector */
556 gmx_mm_load_shift_and_3rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,
557 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
559 fix0 = _mm_setzero_pd();
560 fiy0 = _mm_setzero_pd();
561 fiz0 = _mm_setzero_pd();
562 fix1 = _mm_setzero_pd();
563 fiy1 = _mm_setzero_pd();
564 fiz1 = _mm_setzero_pd();
565 fix2 = _mm_setzero_pd();
566 fiy2 = _mm_setzero_pd();
567 fiz2 = _mm_setzero_pd();
569 /* Start inner kernel loop */
570 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
573 /* Get j neighbor index, and coordinate index */
576 j_coord_offsetA = DIM*jnrA;
577 j_coord_offsetB = DIM*jnrB;
579 /* load j atom coordinates */
580 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
583 /* Calculate displacement vector */
584 dx00 = _mm_sub_pd(ix0,jx0);
585 dy00 = _mm_sub_pd(iy0,jy0);
586 dz00 = _mm_sub_pd(iz0,jz0);
587 dx10 = _mm_sub_pd(ix1,jx0);
588 dy10 = _mm_sub_pd(iy1,jy0);
589 dz10 = _mm_sub_pd(iz1,jz0);
590 dx20 = _mm_sub_pd(ix2,jx0);
591 dy20 = _mm_sub_pd(iy2,jy0);
592 dz20 = _mm_sub_pd(iz2,jz0);
594 /* Calculate squared distance and things based on it */
595 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
596 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
597 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
599 rinv00 = gmx_mm_invsqrt_pd(rsq00);
600 rinv10 = gmx_mm_invsqrt_pd(rsq10);
601 rinv20 = gmx_mm_invsqrt_pd(rsq20);
603 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
604 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
605 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
607 /* Load parameters for j particles */
608 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
609 vdwjidx0A = 2*vdwtype[jnrA+0];
610 vdwjidx0B = 2*vdwtype[jnrB+0];
612 fjx0 = _mm_setzero_pd();
613 fjy0 = _mm_setzero_pd();
614 fjz0 = _mm_setzero_pd();
616 /**************************
617 * CALCULATE INTERACTIONS *
618 **************************/
620 /* Compute parameters for interactions between i and j atoms */
621 qq00 = _mm_mul_pd(iq0,jq0);
622 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
623 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
625 /* COULOMB ELECTROSTATICS */
626 velec = _mm_mul_pd(qq00,rinv00);
627 felec = _mm_mul_pd(velec,rinvsq00);
629 /* LENNARD-JONES DISPERSION/REPULSION */
631 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
632 fvdw = _mm_mul_pd(_mm_msub_pd(c12_00,rinvsix,c6_00),_mm_mul_pd(rinvsix,rinvsq00));
634 fscal = _mm_add_pd(felec,fvdw);
636 /* Update vectorial force */
637 fix0 = _mm_macc_pd(dx00,fscal,fix0);
638 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
639 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
641 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
642 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
643 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
645 /**************************
646 * CALCULATE INTERACTIONS *
647 **************************/
649 /* Compute parameters for interactions between i and j atoms */
650 qq10 = _mm_mul_pd(iq1,jq0);
652 /* COULOMB ELECTROSTATICS */
653 velec = _mm_mul_pd(qq10,rinv10);
654 felec = _mm_mul_pd(velec,rinvsq10);
658 /* Update vectorial force */
659 fix1 = _mm_macc_pd(dx10,fscal,fix1);
660 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
661 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
663 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
664 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
665 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
667 /**************************
668 * CALCULATE INTERACTIONS *
669 **************************/
671 /* Compute parameters for interactions between i and j atoms */
672 qq20 = _mm_mul_pd(iq2,jq0);
674 /* COULOMB ELECTROSTATICS */
675 velec = _mm_mul_pd(qq20,rinv20);
676 felec = _mm_mul_pd(velec,rinvsq20);
680 /* Update vectorial force */
681 fix2 = _mm_macc_pd(dx20,fscal,fix2);
682 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
683 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
685 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
686 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
687 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
689 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
691 /* Inner loop uses 100 flops */
698 j_coord_offsetA = DIM*jnrA;
700 /* load j atom coordinates */
701 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
704 /* Calculate displacement vector */
705 dx00 = _mm_sub_pd(ix0,jx0);
706 dy00 = _mm_sub_pd(iy0,jy0);
707 dz00 = _mm_sub_pd(iz0,jz0);
708 dx10 = _mm_sub_pd(ix1,jx0);
709 dy10 = _mm_sub_pd(iy1,jy0);
710 dz10 = _mm_sub_pd(iz1,jz0);
711 dx20 = _mm_sub_pd(ix2,jx0);
712 dy20 = _mm_sub_pd(iy2,jy0);
713 dz20 = _mm_sub_pd(iz2,jz0);
715 /* Calculate squared distance and things based on it */
716 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
717 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
718 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
720 rinv00 = gmx_mm_invsqrt_pd(rsq00);
721 rinv10 = gmx_mm_invsqrt_pd(rsq10);
722 rinv20 = gmx_mm_invsqrt_pd(rsq20);
724 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
725 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
726 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
728 /* Load parameters for j particles */
729 jq0 = _mm_load_sd(charge+jnrA+0);
730 vdwjidx0A = 2*vdwtype[jnrA+0];
732 fjx0 = _mm_setzero_pd();
733 fjy0 = _mm_setzero_pd();
734 fjz0 = _mm_setzero_pd();
736 /**************************
737 * CALCULATE INTERACTIONS *
738 **************************/
740 /* Compute parameters for interactions between i and j atoms */
741 qq00 = _mm_mul_pd(iq0,jq0);
742 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
744 /* COULOMB ELECTROSTATICS */
745 velec = _mm_mul_pd(qq00,rinv00);
746 felec = _mm_mul_pd(velec,rinvsq00);
748 /* LENNARD-JONES DISPERSION/REPULSION */
750 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
751 fvdw = _mm_mul_pd(_mm_msub_pd(c12_00,rinvsix,c6_00),_mm_mul_pd(rinvsix,rinvsq00));
753 fscal = _mm_add_pd(felec,fvdw);
755 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
757 /* Update vectorial force */
758 fix0 = _mm_macc_pd(dx00,fscal,fix0);
759 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
760 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
762 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
763 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
764 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
766 /**************************
767 * CALCULATE INTERACTIONS *
768 **************************/
770 /* Compute parameters for interactions between i and j atoms */
771 qq10 = _mm_mul_pd(iq1,jq0);
773 /* COULOMB ELECTROSTATICS */
774 velec = _mm_mul_pd(qq10,rinv10);
775 felec = _mm_mul_pd(velec,rinvsq10);
779 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
781 /* Update vectorial force */
782 fix1 = _mm_macc_pd(dx10,fscal,fix1);
783 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
784 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
786 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
787 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
788 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
790 /**************************
791 * CALCULATE INTERACTIONS *
792 **************************/
794 /* Compute parameters for interactions between i and j atoms */
795 qq20 = _mm_mul_pd(iq2,jq0);
797 /* COULOMB ELECTROSTATICS */
798 velec = _mm_mul_pd(qq20,rinv20);
799 felec = _mm_mul_pd(velec,rinvsq20);
803 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
805 /* Update vectorial force */
806 fix2 = _mm_macc_pd(dx20,fscal,fix2);
807 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
808 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
810 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
811 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
812 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
814 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,fjx0,fjy0,fjz0);
816 /* Inner loop uses 100 flops */
819 /* End of innermost loop */
821 gmx_mm_update_iforce_3atom_swizzle_pd(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
822 f+i_coord_offset,fshift+i_shift_offset);
824 /* Increment number of inner iterations */
825 inneriter += j_index_end - j_index_start;
827 /* Outer loop uses 18 flops */
830 /* Increment number of outer iterations */
833 /* Update outer/inner flops */
835 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*18 + inneriter*100);