2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014,2015,2017, 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 "gromacs/gmxlib/nrnb.h"
47 #include "kernelutil_x86_avx_128_fma_double.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwNone_GeomW3P1_VF_avx_128_fma_double
51 * Electrostatics interaction: ReactionField
52 * VdW interaction: None
53 * Geometry: Water3-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecRF_VdwNone_GeomW3P1_VF_avx_128_fma_double
58 (t_nblist * gmx_restrict nlist,
59 rvec * gmx_restrict xx,
60 rvec * gmx_restrict ff,
61 struct t_forcerec * gmx_restrict fr,
62 t_mdatoms * gmx_restrict mdatoms,
63 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
64 t_nrnb * gmx_restrict nrnb)
66 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
67 * just 0 for non-waters.
68 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
69 * jnr indices corresponding to data put in the four positions in the SIMD register.
71 int i_shift_offset,i_coord_offset,outeriter,inneriter;
72 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
74 int j_coord_offsetA,j_coord_offsetB;
75 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
77 real *shiftvec,*fshift,*x,*f;
78 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
80 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
82 __m128d ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
84 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
85 int vdwjidx0A,vdwjidx0B;
86 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
87 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
88 __m128d dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
89 __m128d dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
90 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
92 __m128d dummy_mask,cutoff_mask;
93 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
94 __m128d one = _mm_set1_pd(1.0);
95 __m128d two = _mm_set1_pd(2.0);
101 jindex = nlist->jindex;
103 shiftidx = nlist->shift;
105 shiftvec = fr->shift_vec[0];
106 fshift = fr->fshift[0];
107 facel = _mm_set1_pd(fr->ic->epsfac);
108 charge = mdatoms->chargeA;
109 krf = _mm_set1_pd(fr->ic->k_rf);
110 krf2 = _mm_set1_pd(fr->ic->k_rf*2.0);
111 crf = _mm_set1_pd(fr->ic->c_rf);
113 /* Setup water-specific parameters */
114 inr = nlist->iinr[0];
115 iq0 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+0]));
116 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
117 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
119 /* Avoid stupid compiler warnings */
127 /* Start outer loop over neighborlists */
128 for(iidx=0; iidx<nri; iidx++)
130 /* Load shift vector for this list */
131 i_shift_offset = DIM*shiftidx[iidx];
133 /* Load limits for loop over neighbors */
134 j_index_start = jindex[iidx];
135 j_index_end = jindex[iidx+1];
137 /* Get outer coordinate index */
139 i_coord_offset = DIM*inr;
141 /* Load i particle coords and add shift vector */
142 gmx_mm_load_shift_and_3rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,
143 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
145 fix0 = _mm_setzero_pd();
146 fiy0 = _mm_setzero_pd();
147 fiz0 = _mm_setzero_pd();
148 fix1 = _mm_setzero_pd();
149 fiy1 = _mm_setzero_pd();
150 fiz1 = _mm_setzero_pd();
151 fix2 = _mm_setzero_pd();
152 fiy2 = _mm_setzero_pd();
153 fiz2 = _mm_setzero_pd();
155 /* Reset potential sums */
156 velecsum = _mm_setzero_pd();
158 /* Start inner kernel loop */
159 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
162 /* Get j neighbor index, and coordinate index */
165 j_coord_offsetA = DIM*jnrA;
166 j_coord_offsetB = DIM*jnrB;
168 /* load j atom coordinates */
169 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
172 /* Calculate displacement vector */
173 dx00 = _mm_sub_pd(ix0,jx0);
174 dy00 = _mm_sub_pd(iy0,jy0);
175 dz00 = _mm_sub_pd(iz0,jz0);
176 dx10 = _mm_sub_pd(ix1,jx0);
177 dy10 = _mm_sub_pd(iy1,jy0);
178 dz10 = _mm_sub_pd(iz1,jz0);
179 dx20 = _mm_sub_pd(ix2,jx0);
180 dy20 = _mm_sub_pd(iy2,jy0);
181 dz20 = _mm_sub_pd(iz2,jz0);
183 /* Calculate squared distance and things based on it */
184 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
185 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
186 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
188 rinv00 = avx128fma_invsqrt_d(rsq00);
189 rinv10 = avx128fma_invsqrt_d(rsq10);
190 rinv20 = avx128fma_invsqrt_d(rsq20);
192 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
193 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
194 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
196 /* Load parameters for j particles */
197 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
199 fjx0 = _mm_setzero_pd();
200 fjy0 = _mm_setzero_pd();
201 fjz0 = _mm_setzero_pd();
203 /**************************
204 * CALCULATE INTERACTIONS *
205 **************************/
207 /* Compute parameters for interactions between i and j atoms */
208 qq00 = _mm_mul_pd(iq0,jq0);
210 /* REACTION-FIELD ELECTROSTATICS */
211 velec = _mm_mul_pd(qq00,_mm_sub_pd(_mm_macc_pd(krf,rsq00,rinv00),crf));
212 felec = _mm_mul_pd(qq00,_mm_msub_pd(rinv00,rinvsq00,krf2));
214 /* Update potential sum for this i atom from the interaction with this j atom. */
215 velecsum = _mm_add_pd(velecsum,velec);
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);
228 /**************************
229 * CALCULATE INTERACTIONS *
230 **************************/
232 /* Compute parameters for interactions between i and j atoms */
233 qq10 = _mm_mul_pd(iq1,jq0);
235 /* REACTION-FIELD ELECTROSTATICS */
236 velec = _mm_mul_pd(qq10,_mm_sub_pd(_mm_macc_pd(krf,rsq10,rinv10),crf));
237 felec = _mm_mul_pd(qq10,_mm_msub_pd(rinv10,rinvsq10,krf2));
239 /* Update potential sum for this i atom from the interaction with this j atom. */
240 velecsum = _mm_add_pd(velecsum,velec);
244 /* Update vectorial force */
245 fix1 = _mm_macc_pd(dx10,fscal,fix1);
246 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
247 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
249 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
250 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
251 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
253 /**************************
254 * CALCULATE INTERACTIONS *
255 **************************/
257 /* Compute parameters for interactions between i and j atoms */
258 qq20 = _mm_mul_pd(iq2,jq0);
260 /* REACTION-FIELD ELECTROSTATICS */
261 velec = _mm_mul_pd(qq20,_mm_sub_pd(_mm_macc_pd(krf,rsq20,rinv20),crf));
262 felec = _mm_mul_pd(qq20,_mm_msub_pd(rinv20,rinvsq20,krf2));
264 /* Update potential sum for this i atom from the interaction with this j atom. */
265 velecsum = _mm_add_pd(velecsum,velec);
269 /* Update vectorial force */
270 fix2 = _mm_macc_pd(dx20,fscal,fix2);
271 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
272 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
274 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
275 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
276 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
278 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
280 /* Inner loop uses 108 flops */
287 j_coord_offsetA = DIM*jnrA;
289 /* load j atom coordinates */
290 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
293 /* Calculate displacement vector */
294 dx00 = _mm_sub_pd(ix0,jx0);
295 dy00 = _mm_sub_pd(iy0,jy0);
296 dz00 = _mm_sub_pd(iz0,jz0);
297 dx10 = _mm_sub_pd(ix1,jx0);
298 dy10 = _mm_sub_pd(iy1,jy0);
299 dz10 = _mm_sub_pd(iz1,jz0);
300 dx20 = _mm_sub_pd(ix2,jx0);
301 dy20 = _mm_sub_pd(iy2,jy0);
302 dz20 = _mm_sub_pd(iz2,jz0);
304 /* Calculate squared distance and things based on it */
305 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
306 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
307 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
309 rinv00 = avx128fma_invsqrt_d(rsq00);
310 rinv10 = avx128fma_invsqrt_d(rsq10);
311 rinv20 = avx128fma_invsqrt_d(rsq20);
313 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
314 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
315 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
317 /* Load parameters for j particles */
318 jq0 = _mm_load_sd(charge+jnrA+0);
320 fjx0 = _mm_setzero_pd();
321 fjy0 = _mm_setzero_pd();
322 fjz0 = _mm_setzero_pd();
324 /**************************
325 * CALCULATE INTERACTIONS *
326 **************************/
328 /* Compute parameters for interactions between i and j atoms */
329 qq00 = _mm_mul_pd(iq0,jq0);
331 /* REACTION-FIELD ELECTROSTATICS */
332 velec = _mm_mul_pd(qq00,_mm_sub_pd(_mm_macc_pd(krf,rsq00,rinv00),crf));
333 felec = _mm_mul_pd(qq00,_mm_msub_pd(rinv00,rinvsq00,krf2));
335 /* Update potential sum for this i atom from the interaction with this j atom. */
336 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
337 velecsum = _mm_add_pd(velecsum,velec);
341 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
343 /* Update vectorial force */
344 fix0 = _mm_macc_pd(dx00,fscal,fix0);
345 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
346 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
348 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
349 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
350 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
352 /**************************
353 * CALCULATE INTERACTIONS *
354 **************************/
356 /* Compute parameters for interactions between i and j atoms */
357 qq10 = _mm_mul_pd(iq1,jq0);
359 /* REACTION-FIELD ELECTROSTATICS */
360 velec = _mm_mul_pd(qq10,_mm_sub_pd(_mm_macc_pd(krf,rsq10,rinv10),crf));
361 felec = _mm_mul_pd(qq10,_mm_msub_pd(rinv10,rinvsq10,krf2));
363 /* Update potential sum for this i atom from the interaction with this j atom. */
364 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
365 velecsum = _mm_add_pd(velecsum,velec);
369 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
371 /* Update vectorial force */
372 fix1 = _mm_macc_pd(dx10,fscal,fix1);
373 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
374 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
376 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
377 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
378 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
380 /**************************
381 * CALCULATE INTERACTIONS *
382 **************************/
384 /* Compute parameters for interactions between i and j atoms */
385 qq20 = _mm_mul_pd(iq2,jq0);
387 /* REACTION-FIELD ELECTROSTATICS */
388 velec = _mm_mul_pd(qq20,_mm_sub_pd(_mm_macc_pd(krf,rsq20,rinv20),crf));
389 felec = _mm_mul_pd(qq20,_mm_msub_pd(rinv20,rinvsq20,krf2));
391 /* Update potential sum for this i atom from the interaction with this j atom. */
392 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
393 velecsum = _mm_add_pd(velecsum,velec);
397 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
399 /* Update vectorial force */
400 fix2 = _mm_macc_pd(dx20,fscal,fix2);
401 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
402 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
404 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
405 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
406 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
408 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,fjx0,fjy0,fjz0);
410 /* Inner loop uses 108 flops */
413 /* End of innermost loop */
415 gmx_mm_update_iforce_3atom_swizzle_pd(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
416 f+i_coord_offset,fshift+i_shift_offset);
419 /* Update potential energies */
420 gmx_mm_update_1pot_pd(velecsum,kernel_data->energygrp_elec+ggid);
422 /* Increment number of inner iterations */
423 inneriter += j_index_end - j_index_start;
425 /* Outer loop uses 19 flops */
428 /* Increment number of outer iterations */
431 /* Update outer/inner flops */
433 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3_VF,outeriter*19 + inneriter*108);
436 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwNone_GeomW3P1_F_avx_128_fma_double
437 * Electrostatics interaction: ReactionField
438 * VdW interaction: None
439 * Geometry: Water3-Particle
440 * Calculate force/pot: Force
443 nb_kernel_ElecRF_VdwNone_GeomW3P1_F_avx_128_fma_double
444 (t_nblist * gmx_restrict nlist,
445 rvec * gmx_restrict xx,
446 rvec * gmx_restrict ff,
447 struct t_forcerec * gmx_restrict fr,
448 t_mdatoms * gmx_restrict mdatoms,
449 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
450 t_nrnb * gmx_restrict nrnb)
452 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
453 * just 0 for non-waters.
454 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
455 * jnr indices corresponding to data put in the four positions in the SIMD register.
457 int i_shift_offset,i_coord_offset,outeriter,inneriter;
458 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
460 int j_coord_offsetA,j_coord_offsetB;
461 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
463 real *shiftvec,*fshift,*x,*f;
464 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
466 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
468 __m128d ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
470 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
471 int vdwjidx0A,vdwjidx0B;
472 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
473 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
474 __m128d dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
475 __m128d dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
476 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
478 __m128d dummy_mask,cutoff_mask;
479 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
480 __m128d one = _mm_set1_pd(1.0);
481 __m128d two = _mm_set1_pd(2.0);
487 jindex = nlist->jindex;
489 shiftidx = nlist->shift;
491 shiftvec = fr->shift_vec[0];
492 fshift = fr->fshift[0];
493 facel = _mm_set1_pd(fr->ic->epsfac);
494 charge = mdatoms->chargeA;
495 krf = _mm_set1_pd(fr->ic->k_rf);
496 krf2 = _mm_set1_pd(fr->ic->k_rf*2.0);
497 crf = _mm_set1_pd(fr->ic->c_rf);
499 /* Setup water-specific parameters */
500 inr = nlist->iinr[0];
501 iq0 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+0]));
502 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
503 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
505 /* Avoid stupid compiler warnings */
513 /* Start outer loop over neighborlists */
514 for(iidx=0; iidx<nri; iidx++)
516 /* Load shift vector for this list */
517 i_shift_offset = DIM*shiftidx[iidx];
519 /* Load limits for loop over neighbors */
520 j_index_start = jindex[iidx];
521 j_index_end = jindex[iidx+1];
523 /* Get outer coordinate index */
525 i_coord_offset = DIM*inr;
527 /* Load i particle coords and add shift vector */
528 gmx_mm_load_shift_and_3rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,
529 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
531 fix0 = _mm_setzero_pd();
532 fiy0 = _mm_setzero_pd();
533 fiz0 = _mm_setzero_pd();
534 fix1 = _mm_setzero_pd();
535 fiy1 = _mm_setzero_pd();
536 fiz1 = _mm_setzero_pd();
537 fix2 = _mm_setzero_pd();
538 fiy2 = _mm_setzero_pd();
539 fiz2 = _mm_setzero_pd();
541 /* Start inner kernel loop */
542 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
545 /* Get j neighbor index, and coordinate index */
548 j_coord_offsetA = DIM*jnrA;
549 j_coord_offsetB = DIM*jnrB;
551 /* load j atom coordinates */
552 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
555 /* Calculate displacement vector */
556 dx00 = _mm_sub_pd(ix0,jx0);
557 dy00 = _mm_sub_pd(iy0,jy0);
558 dz00 = _mm_sub_pd(iz0,jz0);
559 dx10 = _mm_sub_pd(ix1,jx0);
560 dy10 = _mm_sub_pd(iy1,jy0);
561 dz10 = _mm_sub_pd(iz1,jz0);
562 dx20 = _mm_sub_pd(ix2,jx0);
563 dy20 = _mm_sub_pd(iy2,jy0);
564 dz20 = _mm_sub_pd(iz2,jz0);
566 /* Calculate squared distance and things based on it */
567 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
568 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
569 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
571 rinv00 = avx128fma_invsqrt_d(rsq00);
572 rinv10 = avx128fma_invsqrt_d(rsq10);
573 rinv20 = avx128fma_invsqrt_d(rsq20);
575 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
576 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
577 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
579 /* Load parameters for j particles */
580 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
582 fjx0 = _mm_setzero_pd();
583 fjy0 = _mm_setzero_pd();
584 fjz0 = _mm_setzero_pd();
586 /**************************
587 * CALCULATE INTERACTIONS *
588 **************************/
590 /* Compute parameters for interactions between i and j atoms */
591 qq00 = _mm_mul_pd(iq0,jq0);
593 /* REACTION-FIELD ELECTROSTATICS */
594 felec = _mm_mul_pd(qq00,_mm_msub_pd(rinv00,rinvsq00,krf2));
598 /* Update vectorial force */
599 fix0 = _mm_macc_pd(dx00,fscal,fix0);
600 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
601 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
603 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
604 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
605 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
607 /**************************
608 * CALCULATE INTERACTIONS *
609 **************************/
611 /* Compute parameters for interactions between i and j atoms */
612 qq10 = _mm_mul_pd(iq1,jq0);
614 /* REACTION-FIELD ELECTROSTATICS */
615 felec = _mm_mul_pd(qq10,_mm_msub_pd(rinv10,rinvsq10,krf2));
619 /* Update vectorial force */
620 fix1 = _mm_macc_pd(dx10,fscal,fix1);
621 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
622 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
624 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
625 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
626 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
628 /**************************
629 * CALCULATE INTERACTIONS *
630 **************************/
632 /* Compute parameters for interactions between i and j atoms */
633 qq20 = _mm_mul_pd(iq2,jq0);
635 /* REACTION-FIELD ELECTROSTATICS */
636 felec = _mm_mul_pd(qq20,_mm_msub_pd(rinv20,rinvsq20,krf2));
640 /* Update vectorial force */
641 fix2 = _mm_macc_pd(dx20,fscal,fix2);
642 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
643 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
645 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
646 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
647 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
649 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
651 /* Inner loop uses 93 flops */
658 j_coord_offsetA = DIM*jnrA;
660 /* load j atom coordinates */
661 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
664 /* Calculate displacement vector */
665 dx00 = _mm_sub_pd(ix0,jx0);
666 dy00 = _mm_sub_pd(iy0,jy0);
667 dz00 = _mm_sub_pd(iz0,jz0);
668 dx10 = _mm_sub_pd(ix1,jx0);
669 dy10 = _mm_sub_pd(iy1,jy0);
670 dz10 = _mm_sub_pd(iz1,jz0);
671 dx20 = _mm_sub_pd(ix2,jx0);
672 dy20 = _mm_sub_pd(iy2,jy0);
673 dz20 = _mm_sub_pd(iz2,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);
680 rinv00 = avx128fma_invsqrt_d(rsq00);
681 rinv10 = avx128fma_invsqrt_d(rsq10);
682 rinv20 = avx128fma_invsqrt_d(rsq20);
684 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
685 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
686 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
688 /* Load parameters for j particles */
689 jq0 = _mm_load_sd(charge+jnrA+0);
691 fjx0 = _mm_setzero_pd();
692 fjy0 = _mm_setzero_pd();
693 fjz0 = _mm_setzero_pd();
695 /**************************
696 * CALCULATE INTERACTIONS *
697 **************************/
699 /* Compute parameters for interactions between i and j atoms */
700 qq00 = _mm_mul_pd(iq0,jq0);
702 /* REACTION-FIELD ELECTROSTATICS */
703 felec = _mm_mul_pd(qq00,_mm_msub_pd(rinv00,rinvsq00,krf2));
707 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
709 /* Update vectorial force */
710 fix0 = _mm_macc_pd(dx00,fscal,fix0);
711 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
712 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
714 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
715 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
716 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
718 /**************************
719 * CALCULATE INTERACTIONS *
720 **************************/
722 /* Compute parameters for interactions between i and j atoms */
723 qq10 = _mm_mul_pd(iq1,jq0);
725 /* REACTION-FIELD ELECTROSTATICS */
726 felec = _mm_mul_pd(qq10,_mm_msub_pd(rinv10,rinvsq10,krf2));
730 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
732 /* Update vectorial force */
733 fix1 = _mm_macc_pd(dx10,fscal,fix1);
734 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
735 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
737 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
738 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
739 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
741 /**************************
742 * CALCULATE INTERACTIONS *
743 **************************/
745 /* Compute parameters for interactions between i and j atoms */
746 qq20 = _mm_mul_pd(iq2,jq0);
748 /* REACTION-FIELD ELECTROSTATICS */
749 felec = _mm_mul_pd(qq20,_mm_msub_pd(rinv20,rinvsq20,krf2));
753 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
755 /* Update vectorial force */
756 fix2 = _mm_macc_pd(dx20,fscal,fix2);
757 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
758 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
760 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
761 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
762 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
764 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,fjx0,fjy0,fjz0);
766 /* Inner loop uses 93 flops */
769 /* End of innermost loop */
771 gmx_mm_update_iforce_3atom_swizzle_pd(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
772 f+i_coord_offset,fshift+i_shift_offset);
774 /* Increment number of inner iterations */
775 inneriter += j_index_end - j_index_start;
777 /* Outer loop uses 18 flops */
780 /* Increment number of outer iterations */
783 /* Update outer/inner flops */
785 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3_F,outeriter*18 + inneriter*93);