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_GeomW3P1_VF_avx_128_fma_double
38 * Electrostatics interaction: ReactionField
39 * VdW interaction: None
40 * Geometry: Water3-Particle
41 * Calculate force/pot: PotentialAndForce
44 nb_kernel_ElecRFCut_VdwNone_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;
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 iq0 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+0]));
103 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
104 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
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,
135 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
137 fix0 = _mm_setzero_pd();
138 fiy0 = _mm_setzero_pd();
139 fiz0 = _mm_setzero_pd();
140 fix1 = _mm_setzero_pd();
141 fiy1 = _mm_setzero_pd();
142 fiz1 = _mm_setzero_pd();
143 fix2 = _mm_setzero_pd();
144 fiy2 = _mm_setzero_pd();
145 fiz2 = _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 dx00 = _mm_sub_pd(ix0,jx0);
166 dy00 = _mm_sub_pd(iy0,jy0);
167 dz00 = _mm_sub_pd(iz0,jz0);
168 dx10 = _mm_sub_pd(ix1,jx0);
169 dy10 = _mm_sub_pd(iy1,jy0);
170 dz10 = _mm_sub_pd(iz1,jz0);
171 dx20 = _mm_sub_pd(ix2,jx0);
172 dy20 = _mm_sub_pd(iy2,jy0);
173 dz20 = _mm_sub_pd(iz2,jz0);
175 /* Calculate squared distance and things based on it */
176 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
177 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
178 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
180 rinv00 = gmx_mm_invsqrt_pd(rsq00);
181 rinv10 = gmx_mm_invsqrt_pd(rsq10);
182 rinv20 = gmx_mm_invsqrt_pd(rsq20);
184 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
185 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
186 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
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(rsq00,rcutoff2))
202 /* Compute parameters for interactions between i and j atoms */
203 qq00 = _mm_mul_pd(iq0,jq0);
205 /* REACTION-FIELD ELECTROSTATICS */
206 velec = _mm_mul_pd(qq00,_mm_sub_pd(_mm_macc_pd(krf,rsq00,rinv00),crf));
207 felec = _mm_mul_pd(qq00,_mm_msub_pd(rinv00,rinvsq00,krf2));
209 cutoff_mask = _mm_cmplt_pd(rsq00,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 fix0 = _mm_macc_pd(dx00,fscal,fix0);
221 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
222 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
224 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
225 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
226 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
230 /**************************
231 * CALCULATE INTERACTIONS *
232 **************************/
234 if (gmx_mm_any_lt(rsq10,rcutoff2))
237 /* Compute parameters for interactions between i and j atoms */
238 qq10 = _mm_mul_pd(iq1,jq0);
240 /* REACTION-FIELD ELECTROSTATICS */
241 velec = _mm_mul_pd(qq10,_mm_sub_pd(_mm_macc_pd(krf,rsq10,rinv10),crf));
242 felec = _mm_mul_pd(qq10,_mm_msub_pd(rinv10,rinvsq10,krf2));
244 cutoff_mask = _mm_cmplt_pd(rsq10,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 fix1 = _mm_macc_pd(dx10,fscal,fix1);
256 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
257 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
259 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
260 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
261 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
265 /**************************
266 * CALCULATE INTERACTIONS *
267 **************************/
269 if (gmx_mm_any_lt(rsq20,rcutoff2))
272 /* Compute parameters for interactions between i and j atoms */
273 qq20 = _mm_mul_pd(iq2,jq0);
275 /* REACTION-FIELD ELECTROSTATICS */
276 velec = _mm_mul_pd(qq20,_mm_sub_pd(_mm_macc_pd(krf,rsq20,rinv20),crf));
277 felec = _mm_mul_pd(qq20,_mm_msub_pd(rinv20,rinvsq20,krf2));
279 cutoff_mask = _mm_cmplt_pd(rsq20,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 fix2 = _mm_macc_pd(dx20,fscal,fix2);
291 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
292 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
294 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
295 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
296 fjz0 = _mm_macc_pd(dz20,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 dx00 = _mm_sub_pd(ix0,jx0);
317 dy00 = _mm_sub_pd(iy0,jy0);
318 dz00 = _mm_sub_pd(iz0,jz0);
319 dx10 = _mm_sub_pd(ix1,jx0);
320 dy10 = _mm_sub_pd(iy1,jy0);
321 dz10 = _mm_sub_pd(iz1,jz0);
322 dx20 = _mm_sub_pd(ix2,jx0);
323 dy20 = _mm_sub_pd(iy2,jy0);
324 dz20 = _mm_sub_pd(iz2,jz0);
326 /* Calculate squared distance and things based on it */
327 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
328 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
329 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
331 rinv00 = gmx_mm_invsqrt_pd(rsq00);
332 rinv10 = gmx_mm_invsqrt_pd(rsq10);
333 rinv20 = gmx_mm_invsqrt_pd(rsq20);
335 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
336 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
337 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
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(rsq00,rcutoff2))
353 /* Compute parameters for interactions between i and j atoms */
354 qq00 = _mm_mul_pd(iq0,jq0);
356 /* REACTION-FIELD ELECTROSTATICS */
357 velec = _mm_mul_pd(qq00,_mm_sub_pd(_mm_macc_pd(krf,rsq00,rinv00),crf));
358 felec = _mm_mul_pd(qq00,_mm_msub_pd(rinv00,rinvsq00,krf2));
360 cutoff_mask = _mm_cmplt_pd(rsq00,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 fix0 = _mm_macc_pd(dx00,fscal,fix0);
375 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
376 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
378 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
379 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
380 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
384 /**************************
385 * CALCULATE INTERACTIONS *
386 **************************/
388 if (gmx_mm_any_lt(rsq10,rcutoff2))
391 /* Compute parameters for interactions between i and j atoms */
392 qq10 = _mm_mul_pd(iq1,jq0);
394 /* REACTION-FIELD ELECTROSTATICS */
395 velec = _mm_mul_pd(qq10,_mm_sub_pd(_mm_macc_pd(krf,rsq10,rinv10),crf));
396 felec = _mm_mul_pd(qq10,_mm_msub_pd(rinv10,rinvsq10,krf2));
398 cutoff_mask = _mm_cmplt_pd(rsq10,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 fix1 = _mm_macc_pd(dx10,fscal,fix1);
413 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
414 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
416 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
417 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
418 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
422 /**************************
423 * CALCULATE INTERACTIONS *
424 **************************/
426 if (gmx_mm_any_lt(rsq20,rcutoff2))
429 /* Compute parameters for interactions between i and j atoms */
430 qq20 = _mm_mul_pd(iq2,jq0);
432 /* REACTION-FIELD ELECTROSTATICS */
433 velec = _mm_mul_pd(qq20,_mm_sub_pd(_mm_macc_pd(krf,rsq20,rinv20),crf));
434 felec = _mm_mul_pd(qq20,_mm_msub_pd(rinv20,rinvsq20,krf2));
436 cutoff_mask = _mm_cmplt_pd(rsq20,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 fix2 = _mm_macc_pd(dx20,fscal,fix2);
451 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
452 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
454 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
455 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
456 fjz0 = _mm_macc_pd(dz20,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(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
468 f+i_coord_offset,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_W3_VF,outeriter*19 + inneriter*120);
488 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwNone_GeomW3P1_F_avx_128_fma_double
489 * Electrostatics interaction: ReactionField
490 * VdW interaction: None
491 * Geometry: Water3-Particle
492 * Calculate force/pot: Force
495 nb_kernel_ElecRFCut_VdwNone_GeomW3P1_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 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
520 __m128d ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
522 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
523 int vdwjidx0A,vdwjidx0B;
524 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
525 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
526 __m128d dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
527 __m128d dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
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 iq0 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+0]));
554 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
555 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
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,
586 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
588 fix0 = _mm_setzero_pd();
589 fiy0 = _mm_setzero_pd();
590 fiz0 = _mm_setzero_pd();
591 fix1 = _mm_setzero_pd();
592 fiy1 = _mm_setzero_pd();
593 fiz1 = _mm_setzero_pd();
594 fix2 = _mm_setzero_pd();
595 fiy2 = _mm_setzero_pd();
596 fiz2 = _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 dx00 = _mm_sub_pd(ix0,jx0);
614 dy00 = _mm_sub_pd(iy0,jy0);
615 dz00 = _mm_sub_pd(iz0,jz0);
616 dx10 = _mm_sub_pd(ix1,jx0);
617 dy10 = _mm_sub_pd(iy1,jy0);
618 dz10 = _mm_sub_pd(iz1,jz0);
619 dx20 = _mm_sub_pd(ix2,jx0);
620 dy20 = _mm_sub_pd(iy2,jy0);
621 dz20 = _mm_sub_pd(iz2,jz0);
623 /* Calculate squared distance and things based on it */
624 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
625 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
626 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
628 rinv00 = gmx_mm_invsqrt_pd(rsq00);
629 rinv10 = gmx_mm_invsqrt_pd(rsq10);
630 rinv20 = gmx_mm_invsqrt_pd(rsq20);
632 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
633 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
634 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
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(rsq00,rcutoff2))
650 /* Compute parameters for interactions between i and j atoms */
651 qq00 = _mm_mul_pd(iq0,jq0);
653 /* REACTION-FIELD ELECTROSTATICS */
654 felec = _mm_mul_pd(qq00,_mm_msub_pd(rinv00,rinvsq00,krf2));
656 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
660 fscal = _mm_and_pd(fscal,cutoff_mask);
662 /* Update vectorial force */
663 fix0 = _mm_macc_pd(dx00,fscal,fix0);
664 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
665 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
667 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
668 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
669 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
673 /**************************
674 * CALCULATE INTERACTIONS *
675 **************************/
677 if (gmx_mm_any_lt(rsq10,rcutoff2))
680 /* Compute parameters for interactions between i and j atoms */
681 qq10 = _mm_mul_pd(iq1,jq0);
683 /* REACTION-FIELD ELECTROSTATICS */
684 felec = _mm_mul_pd(qq10,_mm_msub_pd(rinv10,rinvsq10,krf2));
686 cutoff_mask = _mm_cmplt_pd(rsq10,rcutoff2);
690 fscal = _mm_and_pd(fscal,cutoff_mask);
692 /* Update vectorial force */
693 fix1 = _mm_macc_pd(dx10,fscal,fix1);
694 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
695 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
697 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
698 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
699 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
703 /**************************
704 * CALCULATE INTERACTIONS *
705 **************************/
707 if (gmx_mm_any_lt(rsq20,rcutoff2))
710 /* Compute parameters for interactions between i and j atoms */
711 qq20 = _mm_mul_pd(iq2,jq0);
713 /* REACTION-FIELD ELECTROSTATICS */
714 felec = _mm_mul_pd(qq20,_mm_msub_pd(rinv20,rinvsq20,krf2));
716 cutoff_mask = _mm_cmplt_pd(rsq20,rcutoff2);
720 fscal = _mm_and_pd(fscal,cutoff_mask);
722 /* Update vectorial force */
723 fix2 = _mm_macc_pd(dx20,fscal,fix2);
724 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
725 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
727 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
728 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
729 fjz0 = _mm_macc_pd(dz20,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 dx00 = _mm_sub_pd(ix0,jx0);
750 dy00 = _mm_sub_pd(iy0,jy0);
751 dz00 = _mm_sub_pd(iz0,jz0);
752 dx10 = _mm_sub_pd(ix1,jx0);
753 dy10 = _mm_sub_pd(iy1,jy0);
754 dz10 = _mm_sub_pd(iz1,jz0);
755 dx20 = _mm_sub_pd(ix2,jx0);
756 dy20 = _mm_sub_pd(iy2,jy0);
757 dz20 = _mm_sub_pd(iz2,jz0);
759 /* Calculate squared distance and things based on it */
760 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
761 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
762 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
764 rinv00 = gmx_mm_invsqrt_pd(rsq00);
765 rinv10 = gmx_mm_invsqrt_pd(rsq10);
766 rinv20 = gmx_mm_invsqrt_pd(rsq20);
768 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
769 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
770 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
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(rsq00,rcutoff2))
786 /* Compute parameters for interactions between i and j atoms */
787 qq00 = _mm_mul_pd(iq0,jq0);
789 /* REACTION-FIELD ELECTROSTATICS */
790 felec = _mm_mul_pd(qq00,_mm_msub_pd(rinv00,rinvsq00,krf2));
792 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
796 fscal = _mm_and_pd(fscal,cutoff_mask);
798 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
800 /* Update vectorial force */
801 fix0 = _mm_macc_pd(dx00,fscal,fix0);
802 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
803 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
805 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
806 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
807 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
811 /**************************
812 * CALCULATE INTERACTIONS *
813 **************************/
815 if (gmx_mm_any_lt(rsq10,rcutoff2))
818 /* Compute parameters for interactions between i and j atoms */
819 qq10 = _mm_mul_pd(iq1,jq0);
821 /* REACTION-FIELD ELECTROSTATICS */
822 felec = _mm_mul_pd(qq10,_mm_msub_pd(rinv10,rinvsq10,krf2));
824 cutoff_mask = _mm_cmplt_pd(rsq10,rcutoff2);
828 fscal = _mm_and_pd(fscal,cutoff_mask);
830 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
832 /* Update vectorial force */
833 fix1 = _mm_macc_pd(dx10,fscal,fix1);
834 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
835 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
837 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
838 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
839 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
843 /**************************
844 * CALCULATE INTERACTIONS *
845 **************************/
847 if (gmx_mm_any_lt(rsq20,rcutoff2))
850 /* Compute parameters for interactions between i and j atoms */
851 qq20 = _mm_mul_pd(iq2,jq0);
853 /* REACTION-FIELD ELECTROSTATICS */
854 felec = _mm_mul_pd(qq20,_mm_msub_pd(rinv20,rinvsq20,krf2));
856 cutoff_mask = _mm_cmplt_pd(rsq20,rcutoff2);
860 fscal = _mm_and_pd(fscal,cutoff_mask);
862 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
864 /* Update vectorial force */
865 fix2 = _mm_macc_pd(dx20,fscal,fix2);
866 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
867 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
869 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
870 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
871 fjz0 = _mm_macc_pd(dz20,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(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
883 f+i_coord_offset,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_W3_F,outeriter*18 + inneriter*102);