2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
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 "types/simple.h"
46 #include "gromacs/math/vec.h"
49 #include "gromacs/simd/math_x86_avx_128_fma_double.h"
50 #include "kernelutil_x86_avx_128_fma_double.h"
53 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwLJ_GeomW4P1_VF_avx_128_fma_double
54 * Electrostatics interaction: Coulomb
55 * VdW interaction: LennardJones
56 * Geometry: Water4-Particle
57 * Calculate force/pot: PotentialAndForce
60 nb_kernel_ElecCoul_VdwLJ_GeomW4P1_VF_avx_128_fma_double
61 (t_nblist * gmx_restrict nlist,
62 rvec * gmx_restrict xx,
63 rvec * gmx_restrict ff,
64 t_forcerec * gmx_restrict fr,
65 t_mdatoms * gmx_restrict mdatoms,
66 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
67 t_nrnb * gmx_restrict nrnb)
69 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
70 * just 0 for non-waters.
71 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
72 * jnr indices corresponding to data put in the four positions in the SIMD register.
74 int i_shift_offset,i_coord_offset,outeriter,inneriter;
75 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
77 int j_coord_offsetA,j_coord_offsetB;
78 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
80 real *shiftvec,*fshift,*x,*f;
81 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
83 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
85 __m128d ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
87 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
89 __m128d ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
90 int vdwjidx0A,vdwjidx0B;
91 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
92 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
93 __m128d dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
94 __m128d dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
95 __m128d dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
96 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
99 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
102 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
103 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
104 __m128d dummy_mask,cutoff_mask;
105 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
106 __m128d one = _mm_set1_pd(1.0);
107 __m128d two = _mm_set1_pd(2.0);
113 jindex = nlist->jindex;
115 shiftidx = nlist->shift;
117 shiftvec = fr->shift_vec[0];
118 fshift = fr->fshift[0];
119 facel = _mm_set1_pd(fr->epsfac);
120 charge = mdatoms->chargeA;
121 nvdwtype = fr->ntype;
123 vdwtype = mdatoms->typeA;
125 /* Setup water-specific parameters */
126 inr = nlist->iinr[0];
127 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
128 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
129 iq3 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+3]));
130 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
132 /* Avoid stupid compiler warnings */
140 /* Start outer loop over neighborlists */
141 for(iidx=0; iidx<nri; iidx++)
143 /* Load shift vector for this list */
144 i_shift_offset = DIM*shiftidx[iidx];
146 /* Load limits for loop over neighbors */
147 j_index_start = jindex[iidx];
148 j_index_end = jindex[iidx+1];
150 /* Get outer coordinate index */
152 i_coord_offset = DIM*inr;
154 /* Load i particle coords and add shift vector */
155 gmx_mm_load_shift_and_4rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,
156 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
158 fix0 = _mm_setzero_pd();
159 fiy0 = _mm_setzero_pd();
160 fiz0 = _mm_setzero_pd();
161 fix1 = _mm_setzero_pd();
162 fiy1 = _mm_setzero_pd();
163 fiz1 = _mm_setzero_pd();
164 fix2 = _mm_setzero_pd();
165 fiy2 = _mm_setzero_pd();
166 fiz2 = _mm_setzero_pd();
167 fix3 = _mm_setzero_pd();
168 fiy3 = _mm_setzero_pd();
169 fiz3 = _mm_setzero_pd();
171 /* Reset potential sums */
172 velecsum = _mm_setzero_pd();
173 vvdwsum = _mm_setzero_pd();
175 /* Start inner kernel loop */
176 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
179 /* Get j neighbor index, and coordinate index */
182 j_coord_offsetA = DIM*jnrA;
183 j_coord_offsetB = DIM*jnrB;
185 /* load j atom coordinates */
186 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
189 /* Calculate displacement vector */
190 dx00 = _mm_sub_pd(ix0,jx0);
191 dy00 = _mm_sub_pd(iy0,jy0);
192 dz00 = _mm_sub_pd(iz0,jz0);
193 dx10 = _mm_sub_pd(ix1,jx0);
194 dy10 = _mm_sub_pd(iy1,jy0);
195 dz10 = _mm_sub_pd(iz1,jz0);
196 dx20 = _mm_sub_pd(ix2,jx0);
197 dy20 = _mm_sub_pd(iy2,jy0);
198 dz20 = _mm_sub_pd(iz2,jz0);
199 dx30 = _mm_sub_pd(ix3,jx0);
200 dy30 = _mm_sub_pd(iy3,jy0);
201 dz30 = _mm_sub_pd(iz3,jz0);
203 /* Calculate squared distance and things based on it */
204 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
205 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
206 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
207 rsq30 = gmx_mm_calc_rsq_pd(dx30,dy30,dz30);
209 rinv10 = gmx_mm_invsqrt_pd(rsq10);
210 rinv20 = gmx_mm_invsqrt_pd(rsq20);
211 rinv30 = gmx_mm_invsqrt_pd(rsq30);
213 rinvsq00 = gmx_mm_inv_pd(rsq00);
214 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
215 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
216 rinvsq30 = _mm_mul_pd(rinv30,rinv30);
218 /* Load parameters for j particles */
219 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
220 vdwjidx0A = 2*vdwtype[jnrA+0];
221 vdwjidx0B = 2*vdwtype[jnrB+0];
223 fjx0 = _mm_setzero_pd();
224 fjy0 = _mm_setzero_pd();
225 fjz0 = _mm_setzero_pd();
227 /**************************
228 * CALCULATE INTERACTIONS *
229 **************************/
231 /* Compute parameters for interactions between i and j atoms */
232 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
233 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
235 /* LENNARD-JONES DISPERSION/REPULSION */
237 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
238 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
239 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
240 vvdw = _mm_msub_pd( vvdw12,one_twelfth, _mm_mul_pd(vvdw6,one_sixth) );
241 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
243 /* Update potential sum for this i atom from the interaction with this j atom. */
244 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
248 /* Update vectorial force */
249 fix0 = _mm_macc_pd(dx00,fscal,fix0);
250 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
251 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
253 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
254 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
255 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
257 /**************************
258 * CALCULATE INTERACTIONS *
259 **************************/
261 /* Compute parameters for interactions between i and j atoms */
262 qq10 = _mm_mul_pd(iq1,jq0);
264 /* COULOMB ELECTROSTATICS */
265 velec = _mm_mul_pd(qq10,rinv10);
266 felec = _mm_mul_pd(velec,rinvsq10);
268 /* Update potential sum for this i atom from the interaction with this j atom. */
269 velecsum = _mm_add_pd(velecsum,velec);
273 /* Update vectorial force */
274 fix1 = _mm_macc_pd(dx10,fscal,fix1);
275 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
276 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
278 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
279 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
280 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
282 /**************************
283 * CALCULATE INTERACTIONS *
284 **************************/
286 /* Compute parameters for interactions between i and j atoms */
287 qq20 = _mm_mul_pd(iq2,jq0);
289 /* COULOMB ELECTROSTATICS */
290 velec = _mm_mul_pd(qq20,rinv20);
291 felec = _mm_mul_pd(velec,rinvsq20);
293 /* Update potential sum for this i atom from the interaction with this j atom. */
294 velecsum = _mm_add_pd(velecsum,velec);
298 /* Update vectorial force */
299 fix2 = _mm_macc_pd(dx20,fscal,fix2);
300 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
301 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
303 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
304 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
305 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
307 /**************************
308 * CALCULATE INTERACTIONS *
309 **************************/
311 /* Compute parameters for interactions between i and j atoms */
312 qq30 = _mm_mul_pd(iq3,jq0);
314 /* COULOMB ELECTROSTATICS */
315 velec = _mm_mul_pd(qq30,rinv30);
316 felec = _mm_mul_pd(velec,rinvsq30);
318 /* Update potential sum for this i atom from the interaction with this j atom. */
319 velecsum = _mm_add_pd(velecsum,velec);
323 /* Update vectorial force */
324 fix3 = _mm_macc_pd(dx30,fscal,fix3);
325 fiy3 = _mm_macc_pd(dy30,fscal,fiy3);
326 fiz3 = _mm_macc_pd(dz30,fscal,fiz3);
328 fjx0 = _mm_macc_pd(dx30,fscal,fjx0);
329 fjy0 = _mm_macc_pd(dy30,fscal,fjy0);
330 fjz0 = _mm_macc_pd(dz30,fscal,fjz0);
332 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
334 /* Inner loop uses 131 flops */
341 j_coord_offsetA = DIM*jnrA;
343 /* load j atom coordinates */
344 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
347 /* Calculate displacement vector */
348 dx00 = _mm_sub_pd(ix0,jx0);
349 dy00 = _mm_sub_pd(iy0,jy0);
350 dz00 = _mm_sub_pd(iz0,jz0);
351 dx10 = _mm_sub_pd(ix1,jx0);
352 dy10 = _mm_sub_pd(iy1,jy0);
353 dz10 = _mm_sub_pd(iz1,jz0);
354 dx20 = _mm_sub_pd(ix2,jx0);
355 dy20 = _mm_sub_pd(iy2,jy0);
356 dz20 = _mm_sub_pd(iz2,jz0);
357 dx30 = _mm_sub_pd(ix3,jx0);
358 dy30 = _mm_sub_pd(iy3,jy0);
359 dz30 = _mm_sub_pd(iz3,jz0);
361 /* Calculate squared distance and things based on it */
362 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
363 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
364 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
365 rsq30 = gmx_mm_calc_rsq_pd(dx30,dy30,dz30);
367 rinv10 = gmx_mm_invsqrt_pd(rsq10);
368 rinv20 = gmx_mm_invsqrt_pd(rsq20);
369 rinv30 = gmx_mm_invsqrt_pd(rsq30);
371 rinvsq00 = gmx_mm_inv_pd(rsq00);
372 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
373 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
374 rinvsq30 = _mm_mul_pd(rinv30,rinv30);
376 /* Load parameters for j particles */
377 jq0 = _mm_load_sd(charge+jnrA+0);
378 vdwjidx0A = 2*vdwtype[jnrA+0];
380 fjx0 = _mm_setzero_pd();
381 fjy0 = _mm_setzero_pd();
382 fjz0 = _mm_setzero_pd();
384 /**************************
385 * CALCULATE INTERACTIONS *
386 **************************/
388 /* Compute parameters for interactions between i and j atoms */
389 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
391 /* LENNARD-JONES DISPERSION/REPULSION */
393 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
394 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
395 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
396 vvdw = _mm_msub_pd( vvdw12,one_twelfth, _mm_mul_pd(vvdw6,one_sixth) );
397 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
399 /* Update potential sum for this i atom from the interaction with this j atom. */
400 vvdw = _mm_unpacklo_pd(vvdw,_mm_setzero_pd());
401 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
405 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
407 /* Update vectorial force */
408 fix0 = _mm_macc_pd(dx00,fscal,fix0);
409 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
410 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
412 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
413 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
414 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
416 /**************************
417 * CALCULATE INTERACTIONS *
418 **************************/
420 /* Compute parameters for interactions between i and j atoms */
421 qq10 = _mm_mul_pd(iq1,jq0);
423 /* COULOMB ELECTROSTATICS */
424 velec = _mm_mul_pd(qq10,rinv10);
425 felec = _mm_mul_pd(velec,rinvsq10);
427 /* Update potential sum for this i atom from the interaction with this j atom. */
428 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
429 velecsum = _mm_add_pd(velecsum,velec);
433 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
435 /* Update vectorial force */
436 fix1 = _mm_macc_pd(dx10,fscal,fix1);
437 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
438 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
440 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
441 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
442 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
444 /**************************
445 * CALCULATE INTERACTIONS *
446 **************************/
448 /* Compute parameters for interactions between i and j atoms */
449 qq20 = _mm_mul_pd(iq2,jq0);
451 /* COULOMB ELECTROSTATICS */
452 velec = _mm_mul_pd(qq20,rinv20);
453 felec = _mm_mul_pd(velec,rinvsq20);
455 /* Update potential sum for this i atom from the interaction with this j atom. */
456 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
457 velecsum = _mm_add_pd(velecsum,velec);
461 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
463 /* Update vectorial force */
464 fix2 = _mm_macc_pd(dx20,fscal,fix2);
465 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
466 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
468 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
469 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
470 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
472 /**************************
473 * CALCULATE INTERACTIONS *
474 **************************/
476 /* Compute parameters for interactions between i and j atoms */
477 qq30 = _mm_mul_pd(iq3,jq0);
479 /* COULOMB ELECTROSTATICS */
480 velec = _mm_mul_pd(qq30,rinv30);
481 felec = _mm_mul_pd(velec,rinvsq30);
483 /* Update potential sum for this i atom from the interaction with this j atom. */
484 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
485 velecsum = _mm_add_pd(velecsum,velec);
489 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
491 /* Update vectorial force */
492 fix3 = _mm_macc_pd(dx30,fscal,fix3);
493 fiy3 = _mm_macc_pd(dy30,fscal,fiy3);
494 fiz3 = _mm_macc_pd(dz30,fscal,fiz3);
496 fjx0 = _mm_macc_pd(dx30,fscal,fjx0);
497 fjy0 = _mm_macc_pd(dy30,fscal,fjy0);
498 fjz0 = _mm_macc_pd(dz30,fscal,fjz0);
500 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,fjx0,fjy0,fjz0);
502 /* Inner loop uses 131 flops */
505 /* End of innermost loop */
507 gmx_mm_update_iforce_4atom_swizzle_pd(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
508 f+i_coord_offset,fshift+i_shift_offset);
511 /* Update potential energies */
512 gmx_mm_update_1pot_pd(velecsum,kernel_data->energygrp_elec+ggid);
513 gmx_mm_update_1pot_pd(vvdwsum,kernel_data->energygrp_vdw+ggid);
515 /* Increment number of inner iterations */
516 inneriter += j_index_end - j_index_start;
518 /* Outer loop uses 26 flops */
521 /* Increment number of outer iterations */
524 /* Update outer/inner flops */
526 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*26 + inneriter*131);
529 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwLJ_GeomW4P1_F_avx_128_fma_double
530 * Electrostatics interaction: Coulomb
531 * VdW interaction: LennardJones
532 * Geometry: Water4-Particle
533 * Calculate force/pot: Force
536 nb_kernel_ElecCoul_VdwLJ_GeomW4P1_F_avx_128_fma_double
537 (t_nblist * gmx_restrict nlist,
538 rvec * gmx_restrict xx,
539 rvec * gmx_restrict ff,
540 t_forcerec * gmx_restrict fr,
541 t_mdatoms * gmx_restrict mdatoms,
542 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
543 t_nrnb * gmx_restrict nrnb)
545 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
546 * just 0 for non-waters.
547 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
548 * jnr indices corresponding to data put in the four positions in the SIMD register.
550 int i_shift_offset,i_coord_offset,outeriter,inneriter;
551 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
553 int j_coord_offsetA,j_coord_offsetB;
554 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
556 real *shiftvec,*fshift,*x,*f;
557 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
559 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
561 __m128d ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
563 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
565 __m128d ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
566 int vdwjidx0A,vdwjidx0B;
567 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
568 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
569 __m128d dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
570 __m128d dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
571 __m128d dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
572 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
575 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
578 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
579 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
580 __m128d dummy_mask,cutoff_mask;
581 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
582 __m128d one = _mm_set1_pd(1.0);
583 __m128d two = _mm_set1_pd(2.0);
589 jindex = nlist->jindex;
591 shiftidx = nlist->shift;
593 shiftvec = fr->shift_vec[0];
594 fshift = fr->fshift[0];
595 facel = _mm_set1_pd(fr->epsfac);
596 charge = mdatoms->chargeA;
597 nvdwtype = fr->ntype;
599 vdwtype = mdatoms->typeA;
601 /* Setup water-specific parameters */
602 inr = nlist->iinr[0];
603 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
604 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
605 iq3 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+3]));
606 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
608 /* Avoid stupid compiler warnings */
616 /* Start outer loop over neighborlists */
617 for(iidx=0; iidx<nri; iidx++)
619 /* Load shift vector for this list */
620 i_shift_offset = DIM*shiftidx[iidx];
622 /* Load limits for loop over neighbors */
623 j_index_start = jindex[iidx];
624 j_index_end = jindex[iidx+1];
626 /* Get outer coordinate index */
628 i_coord_offset = DIM*inr;
630 /* Load i particle coords and add shift vector */
631 gmx_mm_load_shift_and_4rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,
632 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
634 fix0 = _mm_setzero_pd();
635 fiy0 = _mm_setzero_pd();
636 fiz0 = _mm_setzero_pd();
637 fix1 = _mm_setzero_pd();
638 fiy1 = _mm_setzero_pd();
639 fiz1 = _mm_setzero_pd();
640 fix2 = _mm_setzero_pd();
641 fiy2 = _mm_setzero_pd();
642 fiz2 = _mm_setzero_pd();
643 fix3 = _mm_setzero_pd();
644 fiy3 = _mm_setzero_pd();
645 fiz3 = _mm_setzero_pd();
647 /* Start inner kernel loop */
648 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
651 /* Get j neighbor index, and coordinate index */
654 j_coord_offsetA = DIM*jnrA;
655 j_coord_offsetB = DIM*jnrB;
657 /* load j atom coordinates */
658 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
661 /* Calculate displacement vector */
662 dx00 = _mm_sub_pd(ix0,jx0);
663 dy00 = _mm_sub_pd(iy0,jy0);
664 dz00 = _mm_sub_pd(iz0,jz0);
665 dx10 = _mm_sub_pd(ix1,jx0);
666 dy10 = _mm_sub_pd(iy1,jy0);
667 dz10 = _mm_sub_pd(iz1,jz0);
668 dx20 = _mm_sub_pd(ix2,jx0);
669 dy20 = _mm_sub_pd(iy2,jy0);
670 dz20 = _mm_sub_pd(iz2,jz0);
671 dx30 = _mm_sub_pd(ix3,jx0);
672 dy30 = _mm_sub_pd(iy3,jy0);
673 dz30 = _mm_sub_pd(iz3,jz0);
675 /* Calculate squared distance and things based on it */
676 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
677 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
678 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
679 rsq30 = gmx_mm_calc_rsq_pd(dx30,dy30,dz30);
681 rinv10 = gmx_mm_invsqrt_pd(rsq10);
682 rinv20 = gmx_mm_invsqrt_pd(rsq20);
683 rinv30 = gmx_mm_invsqrt_pd(rsq30);
685 rinvsq00 = gmx_mm_inv_pd(rsq00);
686 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
687 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
688 rinvsq30 = _mm_mul_pd(rinv30,rinv30);
690 /* Load parameters for j particles */
691 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
692 vdwjidx0A = 2*vdwtype[jnrA+0];
693 vdwjidx0B = 2*vdwtype[jnrB+0];
695 fjx0 = _mm_setzero_pd();
696 fjy0 = _mm_setzero_pd();
697 fjz0 = _mm_setzero_pd();
699 /**************************
700 * CALCULATE INTERACTIONS *
701 **************************/
703 /* Compute parameters for interactions between i and j atoms */
704 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
705 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
707 /* LENNARD-JONES DISPERSION/REPULSION */
709 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
710 fvdw = _mm_mul_pd(_mm_msub_pd(c12_00,rinvsix,c6_00),_mm_mul_pd(rinvsix,rinvsq00));
714 /* Update vectorial force */
715 fix0 = _mm_macc_pd(dx00,fscal,fix0);
716 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
717 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
719 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
720 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
721 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
723 /**************************
724 * CALCULATE INTERACTIONS *
725 **************************/
727 /* Compute parameters for interactions between i and j atoms */
728 qq10 = _mm_mul_pd(iq1,jq0);
730 /* COULOMB ELECTROSTATICS */
731 velec = _mm_mul_pd(qq10,rinv10);
732 felec = _mm_mul_pd(velec,rinvsq10);
736 /* Update vectorial force */
737 fix1 = _mm_macc_pd(dx10,fscal,fix1);
738 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
739 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
741 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
742 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
743 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
745 /**************************
746 * CALCULATE INTERACTIONS *
747 **************************/
749 /* Compute parameters for interactions between i and j atoms */
750 qq20 = _mm_mul_pd(iq2,jq0);
752 /* COULOMB ELECTROSTATICS */
753 velec = _mm_mul_pd(qq20,rinv20);
754 felec = _mm_mul_pd(velec,rinvsq20);
758 /* Update vectorial force */
759 fix2 = _mm_macc_pd(dx20,fscal,fix2);
760 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
761 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
763 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
764 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
765 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
767 /**************************
768 * CALCULATE INTERACTIONS *
769 **************************/
771 /* Compute parameters for interactions between i and j atoms */
772 qq30 = _mm_mul_pd(iq3,jq0);
774 /* COULOMB ELECTROSTATICS */
775 velec = _mm_mul_pd(qq30,rinv30);
776 felec = _mm_mul_pd(velec,rinvsq30);
780 /* Update vectorial force */
781 fix3 = _mm_macc_pd(dx30,fscal,fix3);
782 fiy3 = _mm_macc_pd(dy30,fscal,fiy3);
783 fiz3 = _mm_macc_pd(dz30,fscal,fiz3);
785 fjx0 = _mm_macc_pd(dx30,fscal,fjx0);
786 fjy0 = _mm_macc_pd(dy30,fscal,fjy0);
787 fjz0 = _mm_macc_pd(dz30,fscal,fjz0);
789 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
791 /* Inner loop uses 123 flops */
798 j_coord_offsetA = DIM*jnrA;
800 /* load j atom coordinates */
801 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
804 /* Calculate displacement vector */
805 dx00 = _mm_sub_pd(ix0,jx0);
806 dy00 = _mm_sub_pd(iy0,jy0);
807 dz00 = _mm_sub_pd(iz0,jz0);
808 dx10 = _mm_sub_pd(ix1,jx0);
809 dy10 = _mm_sub_pd(iy1,jy0);
810 dz10 = _mm_sub_pd(iz1,jz0);
811 dx20 = _mm_sub_pd(ix2,jx0);
812 dy20 = _mm_sub_pd(iy2,jy0);
813 dz20 = _mm_sub_pd(iz2,jz0);
814 dx30 = _mm_sub_pd(ix3,jx0);
815 dy30 = _mm_sub_pd(iy3,jy0);
816 dz30 = _mm_sub_pd(iz3,jz0);
818 /* Calculate squared distance and things based on it */
819 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
820 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
821 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
822 rsq30 = gmx_mm_calc_rsq_pd(dx30,dy30,dz30);
824 rinv10 = gmx_mm_invsqrt_pd(rsq10);
825 rinv20 = gmx_mm_invsqrt_pd(rsq20);
826 rinv30 = gmx_mm_invsqrt_pd(rsq30);
828 rinvsq00 = gmx_mm_inv_pd(rsq00);
829 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
830 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
831 rinvsq30 = _mm_mul_pd(rinv30,rinv30);
833 /* Load parameters for j particles */
834 jq0 = _mm_load_sd(charge+jnrA+0);
835 vdwjidx0A = 2*vdwtype[jnrA+0];
837 fjx0 = _mm_setzero_pd();
838 fjy0 = _mm_setzero_pd();
839 fjz0 = _mm_setzero_pd();
841 /**************************
842 * CALCULATE INTERACTIONS *
843 **************************/
845 /* Compute parameters for interactions between i and j atoms */
846 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
848 /* LENNARD-JONES DISPERSION/REPULSION */
850 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
851 fvdw = _mm_mul_pd(_mm_msub_pd(c12_00,rinvsix,c6_00),_mm_mul_pd(rinvsix,rinvsq00));
855 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
857 /* Update vectorial force */
858 fix0 = _mm_macc_pd(dx00,fscal,fix0);
859 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
860 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
862 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
863 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
864 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
866 /**************************
867 * CALCULATE INTERACTIONS *
868 **************************/
870 /* Compute parameters for interactions between i and j atoms */
871 qq10 = _mm_mul_pd(iq1,jq0);
873 /* COULOMB ELECTROSTATICS */
874 velec = _mm_mul_pd(qq10,rinv10);
875 felec = _mm_mul_pd(velec,rinvsq10);
879 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
881 /* Update vectorial force */
882 fix1 = _mm_macc_pd(dx10,fscal,fix1);
883 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
884 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
886 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
887 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
888 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
890 /**************************
891 * CALCULATE INTERACTIONS *
892 **************************/
894 /* Compute parameters for interactions between i and j atoms */
895 qq20 = _mm_mul_pd(iq2,jq0);
897 /* COULOMB ELECTROSTATICS */
898 velec = _mm_mul_pd(qq20,rinv20);
899 felec = _mm_mul_pd(velec,rinvsq20);
903 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
905 /* Update vectorial force */
906 fix2 = _mm_macc_pd(dx20,fscal,fix2);
907 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
908 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
910 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
911 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
912 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
914 /**************************
915 * CALCULATE INTERACTIONS *
916 **************************/
918 /* Compute parameters for interactions between i and j atoms */
919 qq30 = _mm_mul_pd(iq3,jq0);
921 /* COULOMB ELECTROSTATICS */
922 velec = _mm_mul_pd(qq30,rinv30);
923 felec = _mm_mul_pd(velec,rinvsq30);
927 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
929 /* Update vectorial force */
930 fix3 = _mm_macc_pd(dx30,fscal,fix3);
931 fiy3 = _mm_macc_pd(dy30,fscal,fiy3);
932 fiz3 = _mm_macc_pd(dz30,fscal,fiz3);
934 fjx0 = _mm_macc_pd(dx30,fscal,fjx0);
935 fjy0 = _mm_macc_pd(dy30,fscal,fjy0);
936 fjz0 = _mm_macc_pd(dz30,fscal,fjz0);
938 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,fjx0,fjy0,fjz0);
940 /* Inner loop uses 123 flops */
943 /* End of innermost loop */
945 gmx_mm_update_iforce_4atom_swizzle_pd(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
946 f+i_coord_offset,fshift+i_shift_offset);
948 /* Increment number of inner iterations */
949 inneriter += j_index_end - j_index_start;
951 /* Outer loop uses 24 flops */
954 /* Increment number of outer iterations */
957 /* Update outer/inner flops */
959 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*24 + inneriter*123);