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_ElecRFCut_VdwNone_GeomW4P1_VF_avx_128_fma_double
38 * Electrostatics interaction: ReactionField
39 * VdW interaction: None
40 * Geometry: Water4-Particle
41 * Calculate force/pot: PotentialAndForce
44 nb_kernel_ElecRFCut_VdwNone_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 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
69 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
71 __m128d ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
72 int vdwjidx0A,vdwjidx0B;
73 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
74 __m128d dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
75 __m128d dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
76 __m128d dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
77 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
79 __m128d dummy_mask,cutoff_mask;
80 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
81 __m128d one = _mm_set1_pd(1.0);
82 __m128d two = _mm_set1_pd(2.0);
88 jindex = nlist->jindex;
90 shiftidx = nlist->shift;
92 shiftvec = fr->shift_vec[0];
93 fshift = fr->fshift[0];
94 facel = _mm_set1_pd(fr->epsfac);
95 charge = mdatoms->chargeA;
96 krf = _mm_set1_pd(fr->ic->k_rf);
97 krf2 = _mm_set1_pd(fr->ic->k_rf*2.0);
98 crf = _mm_set1_pd(fr->ic->c_rf);
100 /* Setup water-specific parameters */
101 inr = nlist->iinr[0];
102 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
103 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
104 iq3 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+3]));
106 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
107 rcutoff_scalar = fr->rcoulomb;
108 rcutoff = _mm_set1_pd(rcutoff_scalar);
109 rcutoff2 = _mm_mul_pd(rcutoff,rcutoff);
111 /* Avoid stupid compiler warnings */
119 /* Start outer loop over neighborlists */
120 for(iidx=0; iidx<nri; iidx++)
122 /* Load shift vector for this list */
123 i_shift_offset = DIM*shiftidx[iidx];
125 /* Load limits for loop over neighbors */
126 j_index_start = jindex[iidx];
127 j_index_end = jindex[iidx+1];
129 /* Get outer coordinate index */
131 i_coord_offset = DIM*inr;
133 /* Load i particle coords and add shift vector */
134 gmx_mm_load_shift_and_3rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset+DIM,
135 &ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
137 fix1 = _mm_setzero_pd();
138 fiy1 = _mm_setzero_pd();
139 fiz1 = _mm_setzero_pd();
140 fix2 = _mm_setzero_pd();
141 fiy2 = _mm_setzero_pd();
142 fiz2 = _mm_setzero_pd();
143 fix3 = _mm_setzero_pd();
144 fiy3 = _mm_setzero_pd();
145 fiz3 = _mm_setzero_pd();
147 /* Reset potential sums */
148 velecsum = _mm_setzero_pd();
150 /* Start inner kernel loop */
151 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
154 /* Get j neighbor index, and coordinate index */
157 j_coord_offsetA = DIM*jnrA;
158 j_coord_offsetB = DIM*jnrB;
160 /* load j atom coordinates */
161 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
164 /* Calculate displacement vector */
165 dx10 = _mm_sub_pd(ix1,jx0);
166 dy10 = _mm_sub_pd(iy1,jy0);
167 dz10 = _mm_sub_pd(iz1,jz0);
168 dx20 = _mm_sub_pd(ix2,jx0);
169 dy20 = _mm_sub_pd(iy2,jy0);
170 dz20 = _mm_sub_pd(iz2,jz0);
171 dx30 = _mm_sub_pd(ix3,jx0);
172 dy30 = _mm_sub_pd(iy3,jy0);
173 dz30 = _mm_sub_pd(iz3,jz0);
175 /* Calculate squared distance and things based on it */
176 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
177 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
178 rsq30 = gmx_mm_calc_rsq_pd(dx30,dy30,dz30);
180 rinv10 = gmx_mm_invsqrt_pd(rsq10);
181 rinv20 = gmx_mm_invsqrt_pd(rsq20);
182 rinv30 = gmx_mm_invsqrt_pd(rsq30);
184 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
185 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
186 rinvsq30 = _mm_mul_pd(rinv30,rinv30);
188 /* Load parameters for j particles */
189 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
191 fjx0 = _mm_setzero_pd();
192 fjy0 = _mm_setzero_pd();
193 fjz0 = _mm_setzero_pd();
195 /**************************
196 * CALCULATE INTERACTIONS *
197 **************************/
199 if (gmx_mm_any_lt(rsq10,rcutoff2))
202 /* Compute parameters for interactions between i and j atoms */
203 qq10 = _mm_mul_pd(iq1,jq0);
205 /* REACTION-FIELD ELECTROSTATICS */
206 velec = _mm_mul_pd(qq10,_mm_sub_pd(_mm_macc_pd(krf,rsq10,rinv10),crf));
207 felec = _mm_mul_pd(qq10,_mm_msub_pd(rinv10,rinvsq10,krf2));
209 cutoff_mask = _mm_cmplt_pd(rsq10,rcutoff2);
211 /* Update potential sum for this i atom from the interaction with this j atom. */
212 velec = _mm_and_pd(velec,cutoff_mask);
213 velecsum = _mm_add_pd(velecsum,velec);
217 fscal = _mm_and_pd(fscal,cutoff_mask);
219 /* Update vectorial force */
220 fix1 = _mm_macc_pd(dx10,fscal,fix1);
221 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
222 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
224 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
225 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
226 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
230 /**************************
231 * CALCULATE INTERACTIONS *
232 **************************/
234 if (gmx_mm_any_lt(rsq20,rcutoff2))
237 /* Compute parameters for interactions between i and j atoms */
238 qq20 = _mm_mul_pd(iq2,jq0);
240 /* REACTION-FIELD ELECTROSTATICS */
241 velec = _mm_mul_pd(qq20,_mm_sub_pd(_mm_macc_pd(krf,rsq20,rinv20),crf));
242 felec = _mm_mul_pd(qq20,_mm_msub_pd(rinv20,rinvsq20,krf2));
244 cutoff_mask = _mm_cmplt_pd(rsq20,rcutoff2);
246 /* Update potential sum for this i atom from the interaction with this j atom. */
247 velec = _mm_and_pd(velec,cutoff_mask);
248 velecsum = _mm_add_pd(velecsum,velec);
252 fscal = _mm_and_pd(fscal,cutoff_mask);
254 /* Update vectorial force */
255 fix2 = _mm_macc_pd(dx20,fscal,fix2);
256 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
257 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
259 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
260 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
261 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
265 /**************************
266 * CALCULATE INTERACTIONS *
267 **************************/
269 if (gmx_mm_any_lt(rsq30,rcutoff2))
272 /* Compute parameters for interactions between i and j atoms */
273 qq30 = _mm_mul_pd(iq3,jq0);
275 /* REACTION-FIELD ELECTROSTATICS */
276 velec = _mm_mul_pd(qq30,_mm_sub_pd(_mm_macc_pd(krf,rsq30,rinv30),crf));
277 felec = _mm_mul_pd(qq30,_mm_msub_pd(rinv30,rinvsq30,krf2));
279 cutoff_mask = _mm_cmplt_pd(rsq30,rcutoff2);
281 /* Update potential sum for this i atom from the interaction with this j atom. */
282 velec = _mm_and_pd(velec,cutoff_mask);
283 velecsum = _mm_add_pd(velecsum,velec);
287 fscal = _mm_and_pd(fscal,cutoff_mask);
289 /* Update vectorial force */
290 fix3 = _mm_macc_pd(dx30,fscal,fix3);
291 fiy3 = _mm_macc_pd(dy30,fscal,fiy3);
292 fiz3 = _mm_macc_pd(dz30,fscal,fiz3);
294 fjx0 = _mm_macc_pd(dx30,fscal,fjx0);
295 fjy0 = _mm_macc_pd(dy30,fscal,fjy0);
296 fjz0 = _mm_macc_pd(dz30,fscal,fjz0);
300 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
302 /* Inner loop uses 120 flops */
309 j_coord_offsetA = DIM*jnrA;
311 /* load j atom coordinates */
312 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
315 /* Calculate displacement vector */
316 dx10 = _mm_sub_pd(ix1,jx0);
317 dy10 = _mm_sub_pd(iy1,jy0);
318 dz10 = _mm_sub_pd(iz1,jz0);
319 dx20 = _mm_sub_pd(ix2,jx0);
320 dy20 = _mm_sub_pd(iy2,jy0);
321 dz20 = _mm_sub_pd(iz2,jz0);
322 dx30 = _mm_sub_pd(ix3,jx0);
323 dy30 = _mm_sub_pd(iy3,jy0);
324 dz30 = _mm_sub_pd(iz3,jz0);
326 /* Calculate squared distance and things based on it */
327 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
328 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
329 rsq30 = gmx_mm_calc_rsq_pd(dx30,dy30,dz30);
331 rinv10 = gmx_mm_invsqrt_pd(rsq10);
332 rinv20 = gmx_mm_invsqrt_pd(rsq20);
333 rinv30 = gmx_mm_invsqrt_pd(rsq30);
335 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
336 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
337 rinvsq30 = _mm_mul_pd(rinv30,rinv30);
339 /* Load parameters for j particles */
340 jq0 = _mm_load_sd(charge+jnrA+0);
342 fjx0 = _mm_setzero_pd();
343 fjy0 = _mm_setzero_pd();
344 fjz0 = _mm_setzero_pd();
346 /**************************
347 * CALCULATE INTERACTIONS *
348 **************************/
350 if (gmx_mm_any_lt(rsq10,rcutoff2))
353 /* Compute parameters for interactions between i and j atoms */
354 qq10 = _mm_mul_pd(iq1,jq0);
356 /* REACTION-FIELD ELECTROSTATICS */
357 velec = _mm_mul_pd(qq10,_mm_sub_pd(_mm_macc_pd(krf,rsq10,rinv10),crf));
358 felec = _mm_mul_pd(qq10,_mm_msub_pd(rinv10,rinvsq10,krf2));
360 cutoff_mask = _mm_cmplt_pd(rsq10,rcutoff2);
362 /* Update potential sum for this i atom from the interaction with this j atom. */
363 velec = _mm_and_pd(velec,cutoff_mask);
364 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
365 velecsum = _mm_add_pd(velecsum,velec);
369 fscal = _mm_and_pd(fscal,cutoff_mask);
371 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
373 /* Update vectorial force */
374 fix1 = _mm_macc_pd(dx10,fscal,fix1);
375 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
376 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
378 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
379 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
380 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
384 /**************************
385 * CALCULATE INTERACTIONS *
386 **************************/
388 if (gmx_mm_any_lt(rsq20,rcutoff2))
391 /* Compute parameters for interactions between i and j atoms */
392 qq20 = _mm_mul_pd(iq2,jq0);
394 /* REACTION-FIELD ELECTROSTATICS */
395 velec = _mm_mul_pd(qq20,_mm_sub_pd(_mm_macc_pd(krf,rsq20,rinv20),crf));
396 felec = _mm_mul_pd(qq20,_mm_msub_pd(rinv20,rinvsq20,krf2));
398 cutoff_mask = _mm_cmplt_pd(rsq20,rcutoff2);
400 /* Update potential sum for this i atom from the interaction with this j atom. */
401 velec = _mm_and_pd(velec,cutoff_mask);
402 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
403 velecsum = _mm_add_pd(velecsum,velec);
407 fscal = _mm_and_pd(fscal,cutoff_mask);
409 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
411 /* Update vectorial force */
412 fix2 = _mm_macc_pd(dx20,fscal,fix2);
413 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
414 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
416 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
417 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
418 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
422 /**************************
423 * CALCULATE INTERACTIONS *
424 **************************/
426 if (gmx_mm_any_lt(rsq30,rcutoff2))
429 /* Compute parameters for interactions between i and j atoms */
430 qq30 = _mm_mul_pd(iq3,jq0);
432 /* REACTION-FIELD ELECTROSTATICS */
433 velec = _mm_mul_pd(qq30,_mm_sub_pd(_mm_macc_pd(krf,rsq30,rinv30),crf));
434 felec = _mm_mul_pd(qq30,_mm_msub_pd(rinv30,rinvsq30,krf2));
436 cutoff_mask = _mm_cmplt_pd(rsq30,rcutoff2);
438 /* Update potential sum for this i atom from the interaction with this j atom. */
439 velec = _mm_and_pd(velec,cutoff_mask);
440 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
441 velecsum = _mm_add_pd(velecsum,velec);
445 fscal = _mm_and_pd(fscal,cutoff_mask);
447 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
449 /* Update vectorial force */
450 fix3 = _mm_macc_pd(dx30,fscal,fix3);
451 fiy3 = _mm_macc_pd(dy30,fscal,fiy3);
452 fiz3 = _mm_macc_pd(dz30,fscal,fiz3);
454 fjx0 = _mm_macc_pd(dx30,fscal,fjx0);
455 fjy0 = _mm_macc_pd(dy30,fscal,fjy0);
456 fjz0 = _mm_macc_pd(dz30,fscal,fjz0);
460 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,fjx0,fjy0,fjz0);
462 /* Inner loop uses 120 flops */
465 /* End of innermost loop */
467 gmx_mm_update_iforce_3atom_swizzle_pd(fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
468 f+i_coord_offset+DIM,fshift+i_shift_offset);
471 /* Update potential energies */
472 gmx_mm_update_1pot_pd(velecsum,kernel_data->energygrp_elec+ggid);
474 /* Increment number of inner iterations */
475 inneriter += j_index_end - j_index_start;
477 /* Outer loop uses 19 flops */
480 /* Increment number of outer iterations */
483 /* Update outer/inner flops */
485 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4_VF,outeriter*19 + inneriter*120);
488 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwNone_GeomW4P1_F_avx_128_fma_double
489 * Electrostatics interaction: ReactionField
490 * VdW interaction: None
491 * Geometry: Water4-Particle
492 * Calculate force/pot: Force
495 nb_kernel_ElecRFCut_VdwNone_GeomW4P1_F_avx_128_fma_double
496 (t_nblist * gmx_restrict nlist,
497 rvec * gmx_restrict xx,
498 rvec * gmx_restrict ff,
499 t_forcerec * gmx_restrict fr,
500 t_mdatoms * gmx_restrict mdatoms,
501 nb_kernel_data_t * gmx_restrict kernel_data,
502 t_nrnb * gmx_restrict nrnb)
504 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
505 * just 0 for non-waters.
506 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
507 * jnr indices corresponding to data put in the four positions in the SIMD register.
509 int i_shift_offset,i_coord_offset,outeriter,inneriter;
510 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
512 int j_coord_offsetA,j_coord_offsetB;
513 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
515 real *shiftvec,*fshift,*x,*f;
516 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
518 __m128d ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
520 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
522 __m128d ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
523 int vdwjidx0A,vdwjidx0B;
524 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
525 __m128d dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
526 __m128d dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
527 __m128d dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
528 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
530 __m128d dummy_mask,cutoff_mask;
531 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
532 __m128d one = _mm_set1_pd(1.0);
533 __m128d two = _mm_set1_pd(2.0);
539 jindex = nlist->jindex;
541 shiftidx = nlist->shift;
543 shiftvec = fr->shift_vec[0];
544 fshift = fr->fshift[0];
545 facel = _mm_set1_pd(fr->epsfac);
546 charge = mdatoms->chargeA;
547 krf = _mm_set1_pd(fr->ic->k_rf);
548 krf2 = _mm_set1_pd(fr->ic->k_rf*2.0);
549 crf = _mm_set1_pd(fr->ic->c_rf);
551 /* Setup water-specific parameters */
552 inr = nlist->iinr[0];
553 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
554 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
555 iq3 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+3]));
557 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
558 rcutoff_scalar = fr->rcoulomb;
559 rcutoff = _mm_set1_pd(rcutoff_scalar);
560 rcutoff2 = _mm_mul_pd(rcutoff,rcutoff);
562 /* Avoid stupid compiler warnings */
570 /* Start outer loop over neighborlists */
571 for(iidx=0; iidx<nri; iidx++)
573 /* Load shift vector for this list */
574 i_shift_offset = DIM*shiftidx[iidx];
576 /* Load limits for loop over neighbors */
577 j_index_start = jindex[iidx];
578 j_index_end = jindex[iidx+1];
580 /* Get outer coordinate index */
582 i_coord_offset = DIM*inr;
584 /* Load i particle coords and add shift vector */
585 gmx_mm_load_shift_and_3rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset+DIM,
586 &ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
588 fix1 = _mm_setzero_pd();
589 fiy1 = _mm_setzero_pd();
590 fiz1 = _mm_setzero_pd();
591 fix2 = _mm_setzero_pd();
592 fiy2 = _mm_setzero_pd();
593 fiz2 = _mm_setzero_pd();
594 fix3 = _mm_setzero_pd();
595 fiy3 = _mm_setzero_pd();
596 fiz3 = _mm_setzero_pd();
598 /* Start inner kernel loop */
599 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
602 /* Get j neighbor index, and coordinate index */
605 j_coord_offsetA = DIM*jnrA;
606 j_coord_offsetB = DIM*jnrB;
608 /* load j atom coordinates */
609 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
612 /* Calculate displacement vector */
613 dx10 = _mm_sub_pd(ix1,jx0);
614 dy10 = _mm_sub_pd(iy1,jy0);
615 dz10 = _mm_sub_pd(iz1,jz0);
616 dx20 = _mm_sub_pd(ix2,jx0);
617 dy20 = _mm_sub_pd(iy2,jy0);
618 dz20 = _mm_sub_pd(iz2,jz0);
619 dx30 = _mm_sub_pd(ix3,jx0);
620 dy30 = _mm_sub_pd(iy3,jy0);
621 dz30 = _mm_sub_pd(iz3,jz0);
623 /* Calculate squared distance and things based on it */
624 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
625 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
626 rsq30 = gmx_mm_calc_rsq_pd(dx30,dy30,dz30);
628 rinv10 = gmx_mm_invsqrt_pd(rsq10);
629 rinv20 = gmx_mm_invsqrt_pd(rsq20);
630 rinv30 = gmx_mm_invsqrt_pd(rsq30);
632 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
633 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
634 rinvsq30 = _mm_mul_pd(rinv30,rinv30);
636 /* Load parameters for j particles */
637 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
639 fjx0 = _mm_setzero_pd();
640 fjy0 = _mm_setzero_pd();
641 fjz0 = _mm_setzero_pd();
643 /**************************
644 * CALCULATE INTERACTIONS *
645 **************************/
647 if (gmx_mm_any_lt(rsq10,rcutoff2))
650 /* Compute parameters for interactions between i and j atoms */
651 qq10 = _mm_mul_pd(iq1,jq0);
653 /* REACTION-FIELD ELECTROSTATICS */
654 felec = _mm_mul_pd(qq10,_mm_msub_pd(rinv10,rinvsq10,krf2));
656 cutoff_mask = _mm_cmplt_pd(rsq10,rcutoff2);
660 fscal = _mm_and_pd(fscal,cutoff_mask);
662 /* Update vectorial force */
663 fix1 = _mm_macc_pd(dx10,fscal,fix1);
664 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
665 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
667 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
668 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
669 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
673 /**************************
674 * CALCULATE INTERACTIONS *
675 **************************/
677 if (gmx_mm_any_lt(rsq20,rcutoff2))
680 /* Compute parameters for interactions between i and j atoms */
681 qq20 = _mm_mul_pd(iq2,jq0);
683 /* REACTION-FIELD ELECTROSTATICS */
684 felec = _mm_mul_pd(qq20,_mm_msub_pd(rinv20,rinvsq20,krf2));
686 cutoff_mask = _mm_cmplt_pd(rsq20,rcutoff2);
690 fscal = _mm_and_pd(fscal,cutoff_mask);
692 /* Update vectorial force */
693 fix2 = _mm_macc_pd(dx20,fscal,fix2);
694 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
695 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
697 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
698 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
699 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
703 /**************************
704 * CALCULATE INTERACTIONS *
705 **************************/
707 if (gmx_mm_any_lt(rsq30,rcutoff2))
710 /* Compute parameters for interactions between i and j atoms */
711 qq30 = _mm_mul_pd(iq3,jq0);
713 /* REACTION-FIELD ELECTROSTATICS */
714 felec = _mm_mul_pd(qq30,_mm_msub_pd(rinv30,rinvsq30,krf2));
716 cutoff_mask = _mm_cmplt_pd(rsq30,rcutoff2);
720 fscal = _mm_and_pd(fscal,cutoff_mask);
722 /* Update vectorial force */
723 fix3 = _mm_macc_pd(dx30,fscal,fix3);
724 fiy3 = _mm_macc_pd(dy30,fscal,fiy3);
725 fiz3 = _mm_macc_pd(dz30,fscal,fiz3);
727 fjx0 = _mm_macc_pd(dx30,fscal,fjx0);
728 fjy0 = _mm_macc_pd(dy30,fscal,fjy0);
729 fjz0 = _mm_macc_pd(dz30,fscal,fjz0);
733 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
735 /* Inner loop uses 102 flops */
742 j_coord_offsetA = DIM*jnrA;
744 /* load j atom coordinates */
745 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
748 /* Calculate displacement vector */
749 dx10 = _mm_sub_pd(ix1,jx0);
750 dy10 = _mm_sub_pd(iy1,jy0);
751 dz10 = _mm_sub_pd(iz1,jz0);
752 dx20 = _mm_sub_pd(ix2,jx0);
753 dy20 = _mm_sub_pd(iy2,jy0);
754 dz20 = _mm_sub_pd(iz2,jz0);
755 dx30 = _mm_sub_pd(ix3,jx0);
756 dy30 = _mm_sub_pd(iy3,jy0);
757 dz30 = _mm_sub_pd(iz3,jz0);
759 /* Calculate squared distance and things based on it */
760 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
761 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
762 rsq30 = gmx_mm_calc_rsq_pd(dx30,dy30,dz30);
764 rinv10 = gmx_mm_invsqrt_pd(rsq10);
765 rinv20 = gmx_mm_invsqrt_pd(rsq20);
766 rinv30 = gmx_mm_invsqrt_pd(rsq30);
768 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
769 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
770 rinvsq30 = _mm_mul_pd(rinv30,rinv30);
772 /* Load parameters for j particles */
773 jq0 = _mm_load_sd(charge+jnrA+0);
775 fjx0 = _mm_setzero_pd();
776 fjy0 = _mm_setzero_pd();
777 fjz0 = _mm_setzero_pd();
779 /**************************
780 * CALCULATE INTERACTIONS *
781 **************************/
783 if (gmx_mm_any_lt(rsq10,rcutoff2))
786 /* Compute parameters for interactions between i and j atoms */
787 qq10 = _mm_mul_pd(iq1,jq0);
789 /* REACTION-FIELD ELECTROSTATICS */
790 felec = _mm_mul_pd(qq10,_mm_msub_pd(rinv10,rinvsq10,krf2));
792 cutoff_mask = _mm_cmplt_pd(rsq10,rcutoff2);
796 fscal = _mm_and_pd(fscal,cutoff_mask);
798 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
800 /* Update vectorial force */
801 fix1 = _mm_macc_pd(dx10,fscal,fix1);
802 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
803 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
805 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
806 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
807 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
811 /**************************
812 * CALCULATE INTERACTIONS *
813 **************************/
815 if (gmx_mm_any_lt(rsq20,rcutoff2))
818 /* Compute parameters for interactions between i and j atoms */
819 qq20 = _mm_mul_pd(iq2,jq0);
821 /* REACTION-FIELD ELECTROSTATICS */
822 felec = _mm_mul_pd(qq20,_mm_msub_pd(rinv20,rinvsq20,krf2));
824 cutoff_mask = _mm_cmplt_pd(rsq20,rcutoff2);
828 fscal = _mm_and_pd(fscal,cutoff_mask);
830 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
832 /* Update vectorial force */
833 fix2 = _mm_macc_pd(dx20,fscal,fix2);
834 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
835 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
837 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
838 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
839 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
843 /**************************
844 * CALCULATE INTERACTIONS *
845 **************************/
847 if (gmx_mm_any_lt(rsq30,rcutoff2))
850 /* Compute parameters for interactions between i and j atoms */
851 qq30 = _mm_mul_pd(iq3,jq0);
853 /* REACTION-FIELD ELECTROSTATICS */
854 felec = _mm_mul_pd(qq30,_mm_msub_pd(rinv30,rinvsq30,krf2));
856 cutoff_mask = _mm_cmplt_pd(rsq30,rcutoff2);
860 fscal = _mm_and_pd(fscal,cutoff_mask);
862 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
864 /* Update vectorial force */
865 fix3 = _mm_macc_pd(dx30,fscal,fix3);
866 fiy3 = _mm_macc_pd(dy30,fscal,fiy3);
867 fiz3 = _mm_macc_pd(dz30,fscal,fiz3);
869 fjx0 = _mm_macc_pd(dx30,fscal,fjx0);
870 fjy0 = _mm_macc_pd(dy30,fscal,fjy0);
871 fjz0 = _mm_macc_pd(dz30,fscal,fjz0);
875 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,fjx0,fjy0,fjz0);
877 /* Inner loop uses 102 flops */
880 /* End of innermost loop */
882 gmx_mm_update_iforce_3atom_swizzle_pd(fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
883 f+i_coord_offset+DIM,fshift+i_shift_offset);
885 /* Increment number of inner iterations */
886 inneriter += j_index_end - j_index_start;
888 /* Outer loop uses 18 flops */
891 /* Increment number of outer iterations */
894 /* Update outer/inner flops */
896 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4_F,outeriter*18 + inneriter*102);