2 * Note: this file was generated by the Gromacs sse2_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_sse2_double.h"
34 #include "kernelutil_x86_sse2_double.h"
37 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwLJ_GeomW4P1_VF_sse2_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_sse2_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_sub_pd( _mm_mul_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 /* Calculate temporary vectorial force */
233 tx = _mm_mul_pd(fscal,dx00);
234 ty = _mm_mul_pd(fscal,dy00);
235 tz = _mm_mul_pd(fscal,dz00);
237 /* Update vectorial force */
238 fix0 = _mm_add_pd(fix0,tx);
239 fiy0 = _mm_add_pd(fiy0,ty);
240 fiz0 = _mm_add_pd(fiz0,tz);
242 fjx0 = _mm_add_pd(fjx0,tx);
243 fjy0 = _mm_add_pd(fjy0,ty);
244 fjz0 = _mm_add_pd(fjz0,tz);
246 /**************************
247 * CALCULATE INTERACTIONS *
248 **************************/
250 /* Compute parameters for interactions between i and j atoms */
251 qq10 = _mm_mul_pd(iq1,jq0);
253 /* COULOMB ELECTROSTATICS */
254 velec = _mm_mul_pd(qq10,rinv10);
255 felec = _mm_mul_pd(velec,rinvsq10);
257 /* Update potential sum for this i atom from the interaction with this j atom. */
258 velecsum = _mm_add_pd(velecsum,velec);
262 /* Calculate temporary vectorial force */
263 tx = _mm_mul_pd(fscal,dx10);
264 ty = _mm_mul_pd(fscal,dy10);
265 tz = _mm_mul_pd(fscal,dz10);
267 /* Update vectorial force */
268 fix1 = _mm_add_pd(fix1,tx);
269 fiy1 = _mm_add_pd(fiy1,ty);
270 fiz1 = _mm_add_pd(fiz1,tz);
272 fjx0 = _mm_add_pd(fjx0,tx);
273 fjy0 = _mm_add_pd(fjy0,ty);
274 fjz0 = _mm_add_pd(fjz0,tz);
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 /* Calculate temporary vectorial force */
293 tx = _mm_mul_pd(fscal,dx20);
294 ty = _mm_mul_pd(fscal,dy20);
295 tz = _mm_mul_pd(fscal,dz20);
297 /* Update vectorial force */
298 fix2 = _mm_add_pd(fix2,tx);
299 fiy2 = _mm_add_pd(fiy2,ty);
300 fiz2 = _mm_add_pd(fiz2,tz);
302 fjx0 = _mm_add_pd(fjx0,tx);
303 fjy0 = _mm_add_pd(fjy0,ty);
304 fjz0 = _mm_add_pd(fjz0,tz);
306 /**************************
307 * CALCULATE INTERACTIONS *
308 **************************/
310 /* Compute parameters for interactions between i and j atoms */
311 qq30 = _mm_mul_pd(iq3,jq0);
313 /* COULOMB ELECTROSTATICS */
314 velec = _mm_mul_pd(qq30,rinv30);
315 felec = _mm_mul_pd(velec,rinvsq30);
317 /* Update potential sum for this i atom from the interaction with this j atom. */
318 velecsum = _mm_add_pd(velecsum,velec);
322 /* Calculate temporary vectorial force */
323 tx = _mm_mul_pd(fscal,dx30);
324 ty = _mm_mul_pd(fscal,dy30);
325 tz = _mm_mul_pd(fscal,dz30);
327 /* Update vectorial force */
328 fix3 = _mm_add_pd(fix3,tx);
329 fiy3 = _mm_add_pd(fiy3,ty);
330 fiz3 = _mm_add_pd(fiz3,tz);
332 fjx0 = _mm_add_pd(fjx0,tx);
333 fjy0 = _mm_add_pd(fjy0,ty);
334 fjz0 = _mm_add_pd(fjz0,tz);
336 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
338 /* Inner loop uses 119 flops */
345 j_coord_offsetA = DIM*jnrA;
347 /* load j atom coordinates */
348 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
351 /* Calculate displacement vector */
352 dx00 = _mm_sub_pd(ix0,jx0);
353 dy00 = _mm_sub_pd(iy0,jy0);
354 dz00 = _mm_sub_pd(iz0,jz0);
355 dx10 = _mm_sub_pd(ix1,jx0);
356 dy10 = _mm_sub_pd(iy1,jy0);
357 dz10 = _mm_sub_pd(iz1,jz0);
358 dx20 = _mm_sub_pd(ix2,jx0);
359 dy20 = _mm_sub_pd(iy2,jy0);
360 dz20 = _mm_sub_pd(iz2,jz0);
361 dx30 = _mm_sub_pd(ix3,jx0);
362 dy30 = _mm_sub_pd(iy3,jy0);
363 dz30 = _mm_sub_pd(iz3,jz0);
365 /* Calculate squared distance and things based on it */
366 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
367 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
368 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
369 rsq30 = gmx_mm_calc_rsq_pd(dx30,dy30,dz30);
371 rinv10 = gmx_mm_invsqrt_pd(rsq10);
372 rinv20 = gmx_mm_invsqrt_pd(rsq20);
373 rinv30 = gmx_mm_invsqrt_pd(rsq30);
375 rinvsq00 = gmx_mm_inv_pd(rsq00);
376 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
377 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
378 rinvsq30 = _mm_mul_pd(rinv30,rinv30);
380 /* Load parameters for j particles */
381 jq0 = _mm_load_sd(charge+jnrA+0);
382 vdwjidx0A = 2*vdwtype[jnrA+0];
384 fjx0 = _mm_setzero_pd();
385 fjy0 = _mm_setzero_pd();
386 fjz0 = _mm_setzero_pd();
388 /**************************
389 * CALCULATE INTERACTIONS *
390 **************************/
392 /* Compute parameters for interactions between i and j atoms */
393 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
395 /* LENNARD-JONES DISPERSION/REPULSION */
397 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
398 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
399 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
400 vvdw = _mm_sub_pd( _mm_mul_pd(vvdw12,one_twelfth) , _mm_mul_pd(vvdw6,one_sixth) );
401 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
403 /* Update potential sum for this i atom from the interaction with this j atom. */
404 vvdw = _mm_unpacklo_pd(vvdw,_mm_setzero_pd());
405 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
409 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
411 /* Calculate temporary vectorial force */
412 tx = _mm_mul_pd(fscal,dx00);
413 ty = _mm_mul_pd(fscal,dy00);
414 tz = _mm_mul_pd(fscal,dz00);
416 /* Update vectorial force */
417 fix0 = _mm_add_pd(fix0,tx);
418 fiy0 = _mm_add_pd(fiy0,ty);
419 fiz0 = _mm_add_pd(fiz0,tz);
421 fjx0 = _mm_add_pd(fjx0,tx);
422 fjy0 = _mm_add_pd(fjy0,ty);
423 fjz0 = _mm_add_pd(fjz0,tz);
425 /**************************
426 * CALCULATE INTERACTIONS *
427 **************************/
429 /* Compute parameters for interactions between i and j atoms */
430 qq10 = _mm_mul_pd(iq1,jq0);
432 /* COULOMB ELECTROSTATICS */
433 velec = _mm_mul_pd(qq10,rinv10);
434 felec = _mm_mul_pd(velec,rinvsq10);
436 /* Update potential sum for this i atom from the interaction with this j atom. */
437 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
438 velecsum = _mm_add_pd(velecsum,velec);
442 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
444 /* Calculate temporary vectorial force */
445 tx = _mm_mul_pd(fscal,dx10);
446 ty = _mm_mul_pd(fscal,dy10);
447 tz = _mm_mul_pd(fscal,dz10);
449 /* Update vectorial force */
450 fix1 = _mm_add_pd(fix1,tx);
451 fiy1 = _mm_add_pd(fiy1,ty);
452 fiz1 = _mm_add_pd(fiz1,tz);
454 fjx0 = _mm_add_pd(fjx0,tx);
455 fjy0 = _mm_add_pd(fjy0,ty);
456 fjz0 = _mm_add_pd(fjz0,tz);
458 /**************************
459 * CALCULATE INTERACTIONS *
460 **************************/
462 /* Compute parameters for interactions between i and j atoms */
463 qq20 = _mm_mul_pd(iq2,jq0);
465 /* COULOMB ELECTROSTATICS */
466 velec = _mm_mul_pd(qq20,rinv20);
467 felec = _mm_mul_pd(velec,rinvsq20);
469 /* Update potential sum for this i atom from the interaction with this j atom. */
470 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
471 velecsum = _mm_add_pd(velecsum,velec);
475 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
477 /* Calculate temporary vectorial force */
478 tx = _mm_mul_pd(fscal,dx20);
479 ty = _mm_mul_pd(fscal,dy20);
480 tz = _mm_mul_pd(fscal,dz20);
482 /* Update vectorial force */
483 fix2 = _mm_add_pd(fix2,tx);
484 fiy2 = _mm_add_pd(fiy2,ty);
485 fiz2 = _mm_add_pd(fiz2,tz);
487 fjx0 = _mm_add_pd(fjx0,tx);
488 fjy0 = _mm_add_pd(fjy0,ty);
489 fjz0 = _mm_add_pd(fjz0,tz);
491 /**************************
492 * CALCULATE INTERACTIONS *
493 **************************/
495 /* Compute parameters for interactions between i and j atoms */
496 qq30 = _mm_mul_pd(iq3,jq0);
498 /* COULOMB ELECTROSTATICS */
499 velec = _mm_mul_pd(qq30,rinv30);
500 felec = _mm_mul_pd(velec,rinvsq30);
502 /* Update potential sum for this i atom from the interaction with this j atom. */
503 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
504 velecsum = _mm_add_pd(velecsum,velec);
508 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
510 /* Calculate temporary vectorial force */
511 tx = _mm_mul_pd(fscal,dx30);
512 ty = _mm_mul_pd(fscal,dy30);
513 tz = _mm_mul_pd(fscal,dz30);
515 /* Update vectorial force */
516 fix3 = _mm_add_pd(fix3,tx);
517 fiy3 = _mm_add_pd(fiy3,ty);
518 fiz3 = _mm_add_pd(fiz3,tz);
520 fjx0 = _mm_add_pd(fjx0,tx);
521 fjy0 = _mm_add_pd(fjy0,ty);
522 fjz0 = _mm_add_pd(fjz0,tz);
524 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,fjx0,fjy0,fjz0);
526 /* Inner loop uses 119 flops */
529 /* End of innermost loop */
531 gmx_mm_update_iforce_4atom_swizzle_pd(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
532 f+i_coord_offset,fshift+i_shift_offset);
535 /* Update potential energies */
536 gmx_mm_update_1pot_pd(velecsum,kernel_data->energygrp_elec+ggid);
537 gmx_mm_update_1pot_pd(vvdwsum,kernel_data->energygrp_vdw+ggid);
539 /* Increment number of inner iterations */
540 inneriter += j_index_end - j_index_start;
542 /* Outer loop uses 26 flops */
545 /* Increment number of outer iterations */
548 /* Update outer/inner flops */
550 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*26 + inneriter*119);
553 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwLJ_GeomW4P1_F_sse2_double
554 * Electrostatics interaction: Coulomb
555 * VdW interaction: LennardJones
556 * Geometry: Water4-Particle
557 * Calculate force/pot: Force
560 nb_kernel_ElecCoul_VdwLJ_GeomW4P1_F_sse2_double
561 (t_nblist * gmx_restrict nlist,
562 rvec * gmx_restrict xx,
563 rvec * gmx_restrict ff,
564 t_forcerec * gmx_restrict fr,
565 t_mdatoms * gmx_restrict mdatoms,
566 nb_kernel_data_t * gmx_restrict kernel_data,
567 t_nrnb * gmx_restrict nrnb)
569 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
570 * just 0 for non-waters.
571 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
572 * jnr indices corresponding to data put in the four positions in the SIMD register.
574 int i_shift_offset,i_coord_offset,outeriter,inneriter;
575 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
577 int j_coord_offsetA,j_coord_offsetB;
578 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
580 real *shiftvec,*fshift,*x,*f;
581 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
583 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
585 __m128d ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
587 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
589 __m128d ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
590 int vdwjidx0A,vdwjidx0B;
591 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
592 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
593 __m128d dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
594 __m128d dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
595 __m128d dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
596 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
599 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
602 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
603 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
604 __m128d dummy_mask,cutoff_mask;
605 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
606 __m128d one = _mm_set1_pd(1.0);
607 __m128d two = _mm_set1_pd(2.0);
613 jindex = nlist->jindex;
615 shiftidx = nlist->shift;
617 shiftvec = fr->shift_vec[0];
618 fshift = fr->fshift[0];
619 facel = _mm_set1_pd(fr->epsfac);
620 charge = mdatoms->chargeA;
621 nvdwtype = fr->ntype;
623 vdwtype = mdatoms->typeA;
625 /* Setup water-specific parameters */
626 inr = nlist->iinr[0];
627 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
628 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
629 iq3 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+3]));
630 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
632 /* Avoid stupid compiler warnings */
640 /* Start outer loop over neighborlists */
641 for(iidx=0; iidx<nri; iidx++)
643 /* Load shift vector for this list */
644 i_shift_offset = DIM*shiftidx[iidx];
646 /* Load limits for loop over neighbors */
647 j_index_start = jindex[iidx];
648 j_index_end = jindex[iidx+1];
650 /* Get outer coordinate index */
652 i_coord_offset = DIM*inr;
654 /* Load i particle coords and add shift vector */
655 gmx_mm_load_shift_and_4rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,
656 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
658 fix0 = _mm_setzero_pd();
659 fiy0 = _mm_setzero_pd();
660 fiz0 = _mm_setzero_pd();
661 fix1 = _mm_setzero_pd();
662 fiy1 = _mm_setzero_pd();
663 fiz1 = _mm_setzero_pd();
664 fix2 = _mm_setzero_pd();
665 fiy2 = _mm_setzero_pd();
666 fiz2 = _mm_setzero_pd();
667 fix3 = _mm_setzero_pd();
668 fiy3 = _mm_setzero_pd();
669 fiz3 = _mm_setzero_pd();
671 /* Start inner kernel loop */
672 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
675 /* Get j neighbor index, and coordinate index */
678 j_coord_offsetA = DIM*jnrA;
679 j_coord_offsetB = DIM*jnrB;
681 /* load j atom coordinates */
682 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
685 /* Calculate displacement vector */
686 dx00 = _mm_sub_pd(ix0,jx0);
687 dy00 = _mm_sub_pd(iy0,jy0);
688 dz00 = _mm_sub_pd(iz0,jz0);
689 dx10 = _mm_sub_pd(ix1,jx0);
690 dy10 = _mm_sub_pd(iy1,jy0);
691 dz10 = _mm_sub_pd(iz1,jz0);
692 dx20 = _mm_sub_pd(ix2,jx0);
693 dy20 = _mm_sub_pd(iy2,jy0);
694 dz20 = _mm_sub_pd(iz2,jz0);
695 dx30 = _mm_sub_pd(ix3,jx0);
696 dy30 = _mm_sub_pd(iy3,jy0);
697 dz30 = _mm_sub_pd(iz3,jz0);
699 /* Calculate squared distance and things based on it */
700 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
701 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
702 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
703 rsq30 = gmx_mm_calc_rsq_pd(dx30,dy30,dz30);
705 rinv10 = gmx_mm_invsqrt_pd(rsq10);
706 rinv20 = gmx_mm_invsqrt_pd(rsq20);
707 rinv30 = gmx_mm_invsqrt_pd(rsq30);
709 rinvsq00 = gmx_mm_inv_pd(rsq00);
710 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
711 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
712 rinvsq30 = _mm_mul_pd(rinv30,rinv30);
714 /* Load parameters for j particles */
715 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
716 vdwjidx0A = 2*vdwtype[jnrA+0];
717 vdwjidx0B = 2*vdwtype[jnrB+0];
719 fjx0 = _mm_setzero_pd();
720 fjy0 = _mm_setzero_pd();
721 fjz0 = _mm_setzero_pd();
723 /**************************
724 * CALCULATE INTERACTIONS *
725 **************************/
727 /* Compute parameters for interactions between i and j atoms */
728 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
729 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
731 /* LENNARD-JONES DISPERSION/REPULSION */
733 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
734 fvdw = _mm_mul_pd(_mm_sub_pd(_mm_mul_pd(c12_00,rinvsix),c6_00),_mm_mul_pd(rinvsix,rinvsq00));
738 /* Calculate temporary vectorial force */
739 tx = _mm_mul_pd(fscal,dx00);
740 ty = _mm_mul_pd(fscal,dy00);
741 tz = _mm_mul_pd(fscal,dz00);
743 /* Update vectorial force */
744 fix0 = _mm_add_pd(fix0,tx);
745 fiy0 = _mm_add_pd(fiy0,ty);
746 fiz0 = _mm_add_pd(fiz0,tz);
748 fjx0 = _mm_add_pd(fjx0,tx);
749 fjy0 = _mm_add_pd(fjy0,ty);
750 fjz0 = _mm_add_pd(fjz0,tz);
752 /**************************
753 * CALCULATE INTERACTIONS *
754 **************************/
756 /* Compute parameters for interactions between i and j atoms */
757 qq10 = _mm_mul_pd(iq1,jq0);
759 /* COULOMB ELECTROSTATICS */
760 velec = _mm_mul_pd(qq10,rinv10);
761 felec = _mm_mul_pd(velec,rinvsq10);
765 /* Calculate temporary vectorial force */
766 tx = _mm_mul_pd(fscal,dx10);
767 ty = _mm_mul_pd(fscal,dy10);
768 tz = _mm_mul_pd(fscal,dz10);
770 /* Update vectorial force */
771 fix1 = _mm_add_pd(fix1,tx);
772 fiy1 = _mm_add_pd(fiy1,ty);
773 fiz1 = _mm_add_pd(fiz1,tz);
775 fjx0 = _mm_add_pd(fjx0,tx);
776 fjy0 = _mm_add_pd(fjy0,ty);
777 fjz0 = _mm_add_pd(fjz0,tz);
779 /**************************
780 * CALCULATE INTERACTIONS *
781 **************************/
783 /* Compute parameters for interactions between i and j atoms */
784 qq20 = _mm_mul_pd(iq2,jq0);
786 /* COULOMB ELECTROSTATICS */
787 velec = _mm_mul_pd(qq20,rinv20);
788 felec = _mm_mul_pd(velec,rinvsq20);
792 /* Calculate temporary vectorial force */
793 tx = _mm_mul_pd(fscal,dx20);
794 ty = _mm_mul_pd(fscal,dy20);
795 tz = _mm_mul_pd(fscal,dz20);
797 /* Update vectorial force */
798 fix2 = _mm_add_pd(fix2,tx);
799 fiy2 = _mm_add_pd(fiy2,ty);
800 fiz2 = _mm_add_pd(fiz2,tz);
802 fjx0 = _mm_add_pd(fjx0,tx);
803 fjy0 = _mm_add_pd(fjy0,ty);
804 fjz0 = _mm_add_pd(fjz0,tz);
806 /**************************
807 * CALCULATE INTERACTIONS *
808 **************************/
810 /* Compute parameters for interactions between i and j atoms */
811 qq30 = _mm_mul_pd(iq3,jq0);
813 /* COULOMB ELECTROSTATICS */
814 velec = _mm_mul_pd(qq30,rinv30);
815 felec = _mm_mul_pd(velec,rinvsq30);
819 /* Calculate temporary vectorial force */
820 tx = _mm_mul_pd(fscal,dx30);
821 ty = _mm_mul_pd(fscal,dy30);
822 tz = _mm_mul_pd(fscal,dz30);
824 /* Update vectorial force */
825 fix3 = _mm_add_pd(fix3,tx);
826 fiy3 = _mm_add_pd(fiy3,ty);
827 fiz3 = _mm_add_pd(fiz3,tz);
829 fjx0 = _mm_add_pd(fjx0,tx);
830 fjy0 = _mm_add_pd(fjy0,ty);
831 fjz0 = _mm_add_pd(fjz0,tz);
833 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
835 /* Inner loop uses 111 flops */
842 j_coord_offsetA = DIM*jnrA;
844 /* load j atom coordinates */
845 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
848 /* Calculate displacement vector */
849 dx00 = _mm_sub_pd(ix0,jx0);
850 dy00 = _mm_sub_pd(iy0,jy0);
851 dz00 = _mm_sub_pd(iz0,jz0);
852 dx10 = _mm_sub_pd(ix1,jx0);
853 dy10 = _mm_sub_pd(iy1,jy0);
854 dz10 = _mm_sub_pd(iz1,jz0);
855 dx20 = _mm_sub_pd(ix2,jx0);
856 dy20 = _mm_sub_pd(iy2,jy0);
857 dz20 = _mm_sub_pd(iz2,jz0);
858 dx30 = _mm_sub_pd(ix3,jx0);
859 dy30 = _mm_sub_pd(iy3,jy0);
860 dz30 = _mm_sub_pd(iz3,jz0);
862 /* Calculate squared distance and things based on it */
863 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
864 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
865 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
866 rsq30 = gmx_mm_calc_rsq_pd(dx30,dy30,dz30);
868 rinv10 = gmx_mm_invsqrt_pd(rsq10);
869 rinv20 = gmx_mm_invsqrt_pd(rsq20);
870 rinv30 = gmx_mm_invsqrt_pd(rsq30);
872 rinvsq00 = gmx_mm_inv_pd(rsq00);
873 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
874 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
875 rinvsq30 = _mm_mul_pd(rinv30,rinv30);
877 /* Load parameters for j particles */
878 jq0 = _mm_load_sd(charge+jnrA+0);
879 vdwjidx0A = 2*vdwtype[jnrA+0];
881 fjx0 = _mm_setzero_pd();
882 fjy0 = _mm_setzero_pd();
883 fjz0 = _mm_setzero_pd();
885 /**************************
886 * CALCULATE INTERACTIONS *
887 **************************/
889 /* Compute parameters for interactions between i and j atoms */
890 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
892 /* LENNARD-JONES DISPERSION/REPULSION */
894 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
895 fvdw = _mm_mul_pd(_mm_sub_pd(_mm_mul_pd(c12_00,rinvsix),c6_00),_mm_mul_pd(rinvsix,rinvsq00));
899 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
901 /* Calculate temporary vectorial force */
902 tx = _mm_mul_pd(fscal,dx00);
903 ty = _mm_mul_pd(fscal,dy00);
904 tz = _mm_mul_pd(fscal,dz00);
906 /* Update vectorial force */
907 fix0 = _mm_add_pd(fix0,tx);
908 fiy0 = _mm_add_pd(fiy0,ty);
909 fiz0 = _mm_add_pd(fiz0,tz);
911 fjx0 = _mm_add_pd(fjx0,tx);
912 fjy0 = _mm_add_pd(fjy0,ty);
913 fjz0 = _mm_add_pd(fjz0,tz);
915 /**************************
916 * CALCULATE INTERACTIONS *
917 **************************/
919 /* Compute parameters for interactions between i and j atoms */
920 qq10 = _mm_mul_pd(iq1,jq0);
922 /* COULOMB ELECTROSTATICS */
923 velec = _mm_mul_pd(qq10,rinv10);
924 felec = _mm_mul_pd(velec,rinvsq10);
928 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
930 /* Calculate temporary vectorial force */
931 tx = _mm_mul_pd(fscal,dx10);
932 ty = _mm_mul_pd(fscal,dy10);
933 tz = _mm_mul_pd(fscal,dz10);
935 /* Update vectorial force */
936 fix1 = _mm_add_pd(fix1,tx);
937 fiy1 = _mm_add_pd(fiy1,ty);
938 fiz1 = _mm_add_pd(fiz1,tz);
940 fjx0 = _mm_add_pd(fjx0,tx);
941 fjy0 = _mm_add_pd(fjy0,ty);
942 fjz0 = _mm_add_pd(fjz0,tz);
944 /**************************
945 * CALCULATE INTERACTIONS *
946 **************************/
948 /* Compute parameters for interactions between i and j atoms */
949 qq20 = _mm_mul_pd(iq2,jq0);
951 /* COULOMB ELECTROSTATICS */
952 velec = _mm_mul_pd(qq20,rinv20);
953 felec = _mm_mul_pd(velec,rinvsq20);
957 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
959 /* Calculate temporary vectorial force */
960 tx = _mm_mul_pd(fscal,dx20);
961 ty = _mm_mul_pd(fscal,dy20);
962 tz = _mm_mul_pd(fscal,dz20);
964 /* Update vectorial force */
965 fix2 = _mm_add_pd(fix2,tx);
966 fiy2 = _mm_add_pd(fiy2,ty);
967 fiz2 = _mm_add_pd(fiz2,tz);
969 fjx0 = _mm_add_pd(fjx0,tx);
970 fjy0 = _mm_add_pd(fjy0,ty);
971 fjz0 = _mm_add_pd(fjz0,tz);
973 /**************************
974 * CALCULATE INTERACTIONS *
975 **************************/
977 /* Compute parameters for interactions between i and j atoms */
978 qq30 = _mm_mul_pd(iq3,jq0);
980 /* COULOMB ELECTROSTATICS */
981 velec = _mm_mul_pd(qq30,rinv30);
982 felec = _mm_mul_pd(velec,rinvsq30);
986 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
988 /* Calculate temporary vectorial force */
989 tx = _mm_mul_pd(fscal,dx30);
990 ty = _mm_mul_pd(fscal,dy30);
991 tz = _mm_mul_pd(fscal,dz30);
993 /* Update vectorial force */
994 fix3 = _mm_add_pd(fix3,tx);
995 fiy3 = _mm_add_pd(fiy3,ty);
996 fiz3 = _mm_add_pd(fiz3,tz);
998 fjx0 = _mm_add_pd(fjx0,tx);
999 fjy0 = _mm_add_pd(fjy0,ty);
1000 fjz0 = _mm_add_pd(fjz0,tz);
1002 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,fjx0,fjy0,fjz0);
1004 /* Inner loop uses 111 flops */
1007 /* End of innermost loop */
1009 gmx_mm_update_iforce_4atom_swizzle_pd(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
1010 f+i_coord_offset,fshift+i_shift_offset);
1012 /* Increment number of inner iterations */
1013 inneriter += j_index_end - j_index_start;
1015 /* Outer loop uses 24 flops */
1018 /* Increment number of outer iterations */
1021 /* Update outer/inner flops */
1023 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*24 + inneriter*111);