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.
42 #include "../nb_kernel.h"
43 #include "gromacs/legacyheaders/types/simple.h"
44 #include "gromacs/math/vec.h"
45 #include "gromacs/legacyheaders/nrnb.h"
47 #include "gromacs/simd/math_x86_avx_128_fma_double.h"
48 #include "kernelutil_x86_avx_128_fma_double.h"
51 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwNone_GeomW3P1_VF_avx_128_fma_double
52 * Electrostatics interaction: ReactionField
53 * VdW interaction: None
54 * Geometry: Water3-Particle
55 * Calculate force/pot: PotentialAndForce
58 nb_kernel_ElecRF_VdwNone_GeomW3P1_VF_avx_128_fma_double
59 (t_nblist * gmx_restrict nlist,
60 rvec * gmx_restrict xx,
61 rvec * gmx_restrict ff,
62 t_forcerec * gmx_restrict fr,
63 t_mdatoms * gmx_restrict mdatoms,
64 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
65 t_nrnb * gmx_restrict nrnb)
67 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
68 * just 0 for non-waters.
69 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
70 * jnr indices corresponding to data put in the four positions in the SIMD register.
72 int i_shift_offset,i_coord_offset,outeriter,inneriter;
73 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
75 int j_coord_offsetA,j_coord_offsetB;
76 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
78 real *shiftvec,*fshift,*x,*f;
79 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
81 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
83 __m128d ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
85 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
86 int vdwjidx0A,vdwjidx0B;
87 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
88 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
89 __m128d dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
90 __m128d dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
91 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
93 __m128d dummy_mask,cutoff_mask;
94 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
95 __m128d one = _mm_set1_pd(1.0);
96 __m128d two = _mm_set1_pd(2.0);
102 jindex = nlist->jindex;
104 shiftidx = nlist->shift;
106 shiftvec = fr->shift_vec[0];
107 fshift = fr->fshift[0];
108 facel = _mm_set1_pd(fr->epsfac);
109 charge = mdatoms->chargeA;
110 krf = _mm_set1_pd(fr->ic->k_rf);
111 krf2 = _mm_set1_pd(fr->ic->k_rf*2.0);
112 crf = _mm_set1_pd(fr->ic->c_rf);
114 /* Setup water-specific parameters */
115 inr = nlist->iinr[0];
116 iq0 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+0]));
117 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
118 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
120 /* Avoid stupid compiler warnings */
128 /* Start outer loop over neighborlists */
129 for(iidx=0; iidx<nri; iidx++)
131 /* Load shift vector for this list */
132 i_shift_offset = DIM*shiftidx[iidx];
134 /* Load limits for loop over neighbors */
135 j_index_start = jindex[iidx];
136 j_index_end = jindex[iidx+1];
138 /* Get outer coordinate index */
140 i_coord_offset = DIM*inr;
142 /* Load i particle coords and add shift vector */
143 gmx_mm_load_shift_and_3rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,
144 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
146 fix0 = _mm_setzero_pd();
147 fiy0 = _mm_setzero_pd();
148 fiz0 = _mm_setzero_pd();
149 fix1 = _mm_setzero_pd();
150 fiy1 = _mm_setzero_pd();
151 fiz1 = _mm_setzero_pd();
152 fix2 = _mm_setzero_pd();
153 fiy2 = _mm_setzero_pd();
154 fiz2 = _mm_setzero_pd();
156 /* Reset potential sums */
157 velecsum = _mm_setzero_pd();
159 /* Start inner kernel loop */
160 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
163 /* Get j neighbor index, and coordinate index */
166 j_coord_offsetA = DIM*jnrA;
167 j_coord_offsetB = DIM*jnrB;
169 /* load j atom coordinates */
170 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
173 /* Calculate displacement vector */
174 dx00 = _mm_sub_pd(ix0,jx0);
175 dy00 = _mm_sub_pd(iy0,jy0);
176 dz00 = _mm_sub_pd(iz0,jz0);
177 dx10 = _mm_sub_pd(ix1,jx0);
178 dy10 = _mm_sub_pd(iy1,jy0);
179 dz10 = _mm_sub_pd(iz1,jz0);
180 dx20 = _mm_sub_pd(ix2,jx0);
181 dy20 = _mm_sub_pd(iy2,jy0);
182 dz20 = _mm_sub_pd(iz2,jz0);
184 /* Calculate squared distance and things based on it */
185 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
186 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
187 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
189 rinv00 = gmx_mm_invsqrt_pd(rsq00);
190 rinv10 = gmx_mm_invsqrt_pd(rsq10);
191 rinv20 = gmx_mm_invsqrt_pd(rsq20);
193 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
194 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
195 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
197 /* Load parameters for j particles */
198 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
200 fjx0 = _mm_setzero_pd();
201 fjy0 = _mm_setzero_pd();
202 fjz0 = _mm_setzero_pd();
204 /**************************
205 * CALCULATE INTERACTIONS *
206 **************************/
208 /* Compute parameters for interactions between i and j atoms */
209 qq00 = _mm_mul_pd(iq0,jq0);
211 /* REACTION-FIELD ELECTROSTATICS */
212 velec = _mm_mul_pd(qq00,_mm_sub_pd(_mm_macc_pd(krf,rsq00,rinv00),crf));
213 felec = _mm_mul_pd(qq00,_mm_msub_pd(rinv00,rinvsq00,krf2));
215 /* Update potential sum for this i atom from the interaction with this j atom. */
216 velecsum = _mm_add_pd(velecsum,velec);
220 /* Update vectorial force */
221 fix0 = _mm_macc_pd(dx00,fscal,fix0);
222 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
223 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
225 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
226 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
227 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
229 /**************************
230 * CALCULATE INTERACTIONS *
231 **************************/
233 /* Compute parameters for interactions between i and j atoms */
234 qq10 = _mm_mul_pd(iq1,jq0);
236 /* REACTION-FIELD ELECTROSTATICS */
237 velec = _mm_mul_pd(qq10,_mm_sub_pd(_mm_macc_pd(krf,rsq10,rinv10),crf));
238 felec = _mm_mul_pd(qq10,_mm_msub_pd(rinv10,rinvsq10,krf2));
240 /* Update potential sum for this i atom from the interaction with this j atom. */
241 velecsum = _mm_add_pd(velecsum,velec);
245 /* Update vectorial force */
246 fix1 = _mm_macc_pd(dx10,fscal,fix1);
247 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
248 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
250 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
251 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
252 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
254 /**************************
255 * CALCULATE INTERACTIONS *
256 **************************/
258 /* Compute parameters for interactions between i and j atoms */
259 qq20 = _mm_mul_pd(iq2,jq0);
261 /* REACTION-FIELD ELECTROSTATICS */
262 velec = _mm_mul_pd(qq20,_mm_sub_pd(_mm_macc_pd(krf,rsq20,rinv20),crf));
263 felec = _mm_mul_pd(qq20,_mm_msub_pd(rinv20,rinvsq20,krf2));
265 /* Update potential sum for this i atom from the interaction with this j atom. */
266 velecsum = _mm_add_pd(velecsum,velec);
270 /* Update vectorial force */
271 fix2 = _mm_macc_pd(dx20,fscal,fix2);
272 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
273 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
275 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
276 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
277 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
279 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
281 /* Inner loop uses 108 flops */
288 j_coord_offsetA = DIM*jnrA;
290 /* load j atom coordinates */
291 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
294 /* Calculate displacement vector */
295 dx00 = _mm_sub_pd(ix0,jx0);
296 dy00 = _mm_sub_pd(iy0,jy0);
297 dz00 = _mm_sub_pd(iz0,jz0);
298 dx10 = _mm_sub_pd(ix1,jx0);
299 dy10 = _mm_sub_pd(iy1,jy0);
300 dz10 = _mm_sub_pd(iz1,jz0);
301 dx20 = _mm_sub_pd(ix2,jx0);
302 dy20 = _mm_sub_pd(iy2,jy0);
303 dz20 = _mm_sub_pd(iz2,jz0);
305 /* Calculate squared distance and things based on it */
306 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
307 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
308 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
310 rinv00 = gmx_mm_invsqrt_pd(rsq00);
311 rinv10 = gmx_mm_invsqrt_pd(rsq10);
312 rinv20 = gmx_mm_invsqrt_pd(rsq20);
314 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
315 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
316 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
318 /* Load parameters for j particles */
319 jq0 = _mm_load_sd(charge+jnrA+0);
321 fjx0 = _mm_setzero_pd();
322 fjy0 = _mm_setzero_pd();
323 fjz0 = _mm_setzero_pd();
325 /**************************
326 * CALCULATE INTERACTIONS *
327 **************************/
329 /* Compute parameters for interactions between i and j atoms */
330 qq00 = _mm_mul_pd(iq0,jq0);
332 /* REACTION-FIELD ELECTROSTATICS */
333 velec = _mm_mul_pd(qq00,_mm_sub_pd(_mm_macc_pd(krf,rsq00,rinv00),crf));
334 felec = _mm_mul_pd(qq00,_mm_msub_pd(rinv00,rinvsq00,krf2));
336 /* Update potential sum for this i atom from the interaction with this j atom. */
337 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
338 velecsum = _mm_add_pd(velecsum,velec);
342 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
344 /* Update vectorial force */
345 fix0 = _mm_macc_pd(dx00,fscal,fix0);
346 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
347 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
349 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
350 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
351 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
353 /**************************
354 * CALCULATE INTERACTIONS *
355 **************************/
357 /* Compute parameters for interactions between i and j atoms */
358 qq10 = _mm_mul_pd(iq1,jq0);
360 /* REACTION-FIELD ELECTROSTATICS */
361 velec = _mm_mul_pd(qq10,_mm_sub_pd(_mm_macc_pd(krf,rsq10,rinv10),crf));
362 felec = _mm_mul_pd(qq10,_mm_msub_pd(rinv10,rinvsq10,krf2));
364 /* Update potential sum for this i atom from the interaction with this j atom. */
365 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
366 velecsum = _mm_add_pd(velecsum,velec);
370 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
372 /* Update vectorial force */
373 fix1 = _mm_macc_pd(dx10,fscal,fix1);
374 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
375 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
377 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
378 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
379 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
381 /**************************
382 * CALCULATE INTERACTIONS *
383 **************************/
385 /* Compute parameters for interactions between i and j atoms */
386 qq20 = _mm_mul_pd(iq2,jq0);
388 /* REACTION-FIELD ELECTROSTATICS */
389 velec = _mm_mul_pd(qq20,_mm_sub_pd(_mm_macc_pd(krf,rsq20,rinv20),crf));
390 felec = _mm_mul_pd(qq20,_mm_msub_pd(rinv20,rinvsq20,krf2));
392 /* Update potential sum for this i atom from the interaction with this j atom. */
393 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
394 velecsum = _mm_add_pd(velecsum,velec);
398 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
400 /* Update vectorial force */
401 fix2 = _mm_macc_pd(dx20,fscal,fix2);
402 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
403 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
405 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
406 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
407 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
409 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,fjx0,fjy0,fjz0);
411 /* Inner loop uses 108 flops */
414 /* End of innermost loop */
416 gmx_mm_update_iforce_3atom_swizzle_pd(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
417 f+i_coord_offset,fshift+i_shift_offset);
420 /* Update potential energies */
421 gmx_mm_update_1pot_pd(velecsum,kernel_data->energygrp_elec+ggid);
423 /* Increment number of inner iterations */
424 inneriter += j_index_end - j_index_start;
426 /* Outer loop uses 19 flops */
429 /* Increment number of outer iterations */
432 /* Update outer/inner flops */
434 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3_VF,outeriter*19 + inneriter*108);
437 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwNone_GeomW3P1_F_avx_128_fma_double
438 * Electrostatics interaction: ReactionField
439 * VdW interaction: None
440 * Geometry: Water3-Particle
441 * Calculate force/pot: Force
444 nb_kernel_ElecRF_VdwNone_GeomW3P1_F_avx_128_fma_double
445 (t_nblist * gmx_restrict nlist,
446 rvec * gmx_restrict xx,
447 rvec * gmx_restrict ff,
448 t_forcerec * gmx_restrict fr,
449 t_mdatoms * gmx_restrict mdatoms,
450 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
451 t_nrnb * gmx_restrict nrnb)
453 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
454 * just 0 for non-waters.
455 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
456 * jnr indices corresponding to data put in the four positions in the SIMD register.
458 int i_shift_offset,i_coord_offset,outeriter,inneriter;
459 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
461 int j_coord_offsetA,j_coord_offsetB;
462 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
464 real *shiftvec,*fshift,*x,*f;
465 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
467 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
469 __m128d ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
471 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
472 int vdwjidx0A,vdwjidx0B;
473 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
474 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
475 __m128d dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
476 __m128d dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
477 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
479 __m128d dummy_mask,cutoff_mask;
480 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
481 __m128d one = _mm_set1_pd(1.0);
482 __m128d two = _mm_set1_pd(2.0);
488 jindex = nlist->jindex;
490 shiftidx = nlist->shift;
492 shiftvec = fr->shift_vec[0];
493 fshift = fr->fshift[0];
494 facel = _mm_set1_pd(fr->epsfac);
495 charge = mdatoms->chargeA;
496 krf = _mm_set1_pd(fr->ic->k_rf);
497 krf2 = _mm_set1_pd(fr->ic->k_rf*2.0);
498 crf = _mm_set1_pd(fr->ic->c_rf);
500 /* Setup water-specific parameters */
501 inr = nlist->iinr[0];
502 iq0 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+0]));
503 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
504 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
506 /* Avoid stupid compiler warnings */
514 /* Start outer loop over neighborlists */
515 for(iidx=0; iidx<nri; iidx++)
517 /* Load shift vector for this list */
518 i_shift_offset = DIM*shiftidx[iidx];
520 /* Load limits for loop over neighbors */
521 j_index_start = jindex[iidx];
522 j_index_end = jindex[iidx+1];
524 /* Get outer coordinate index */
526 i_coord_offset = DIM*inr;
528 /* Load i particle coords and add shift vector */
529 gmx_mm_load_shift_and_3rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,
530 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
532 fix0 = _mm_setzero_pd();
533 fiy0 = _mm_setzero_pd();
534 fiz0 = _mm_setzero_pd();
535 fix1 = _mm_setzero_pd();
536 fiy1 = _mm_setzero_pd();
537 fiz1 = _mm_setzero_pd();
538 fix2 = _mm_setzero_pd();
539 fiy2 = _mm_setzero_pd();
540 fiz2 = _mm_setzero_pd();
542 /* Start inner kernel loop */
543 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
546 /* Get j neighbor index, and coordinate index */
549 j_coord_offsetA = DIM*jnrA;
550 j_coord_offsetB = DIM*jnrB;
552 /* load j atom coordinates */
553 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
556 /* Calculate displacement vector */
557 dx00 = _mm_sub_pd(ix0,jx0);
558 dy00 = _mm_sub_pd(iy0,jy0);
559 dz00 = _mm_sub_pd(iz0,jz0);
560 dx10 = _mm_sub_pd(ix1,jx0);
561 dy10 = _mm_sub_pd(iy1,jy0);
562 dz10 = _mm_sub_pd(iz1,jz0);
563 dx20 = _mm_sub_pd(ix2,jx0);
564 dy20 = _mm_sub_pd(iy2,jy0);
565 dz20 = _mm_sub_pd(iz2,jz0);
567 /* Calculate squared distance and things based on it */
568 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
569 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
570 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
572 rinv00 = gmx_mm_invsqrt_pd(rsq00);
573 rinv10 = gmx_mm_invsqrt_pd(rsq10);
574 rinv20 = gmx_mm_invsqrt_pd(rsq20);
576 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
577 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
578 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
580 /* Load parameters for j particles */
581 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
583 fjx0 = _mm_setzero_pd();
584 fjy0 = _mm_setzero_pd();
585 fjz0 = _mm_setzero_pd();
587 /**************************
588 * CALCULATE INTERACTIONS *
589 **************************/
591 /* Compute parameters for interactions between i and j atoms */
592 qq00 = _mm_mul_pd(iq0,jq0);
594 /* REACTION-FIELD ELECTROSTATICS */
595 felec = _mm_mul_pd(qq00,_mm_msub_pd(rinv00,rinvsq00,krf2));
599 /* Update vectorial force */
600 fix0 = _mm_macc_pd(dx00,fscal,fix0);
601 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
602 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
604 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
605 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
606 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
608 /**************************
609 * CALCULATE INTERACTIONS *
610 **************************/
612 /* Compute parameters for interactions between i and j atoms */
613 qq10 = _mm_mul_pd(iq1,jq0);
615 /* REACTION-FIELD ELECTROSTATICS */
616 felec = _mm_mul_pd(qq10,_mm_msub_pd(rinv10,rinvsq10,krf2));
620 /* Update vectorial force */
621 fix1 = _mm_macc_pd(dx10,fscal,fix1);
622 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
623 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
625 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
626 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
627 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
629 /**************************
630 * CALCULATE INTERACTIONS *
631 **************************/
633 /* Compute parameters for interactions between i and j atoms */
634 qq20 = _mm_mul_pd(iq2,jq0);
636 /* REACTION-FIELD ELECTROSTATICS */
637 felec = _mm_mul_pd(qq20,_mm_msub_pd(rinv20,rinvsq20,krf2));
641 /* Update vectorial force */
642 fix2 = _mm_macc_pd(dx20,fscal,fix2);
643 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
644 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
646 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
647 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
648 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
650 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
652 /* Inner loop uses 93 flops */
659 j_coord_offsetA = DIM*jnrA;
661 /* load j atom coordinates */
662 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
665 /* Calculate displacement vector */
666 dx00 = _mm_sub_pd(ix0,jx0);
667 dy00 = _mm_sub_pd(iy0,jy0);
668 dz00 = _mm_sub_pd(iz0,jz0);
669 dx10 = _mm_sub_pd(ix1,jx0);
670 dy10 = _mm_sub_pd(iy1,jy0);
671 dz10 = _mm_sub_pd(iz1,jz0);
672 dx20 = _mm_sub_pd(ix2,jx0);
673 dy20 = _mm_sub_pd(iy2,jy0);
674 dz20 = _mm_sub_pd(iz2,jz0);
676 /* Calculate squared distance and things based on it */
677 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
678 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
679 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
681 rinv00 = gmx_mm_invsqrt_pd(rsq00);
682 rinv10 = gmx_mm_invsqrt_pd(rsq10);
683 rinv20 = gmx_mm_invsqrt_pd(rsq20);
685 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
686 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
687 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
689 /* Load parameters for j particles */
690 jq0 = _mm_load_sd(charge+jnrA+0);
692 fjx0 = _mm_setzero_pd();
693 fjy0 = _mm_setzero_pd();
694 fjz0 = _mm_setzero_pd();
696 /**************************
697 * CALCULATE INTERACTIONS *
698 **************************/
700 /* Compute parameters for interactions between i and j atoms */
701 qq00 = _mm_mul_pd(iq0,jq0);
703 /* REACTION-FIELD ELECTROSTATICS */
704 felec = _mm_mul_pd(qq00,_mm_msub_pd(rinv00,rinvsq00,krf2));
708 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
710 /* Update vectorial force */
711 fix0 = _mm_macc_pd(dx00,fscal,fix0);
712 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
713 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
715 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
716 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
717 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
719 /**************************
720 * CALCULATE INTERACTIONS *
721 **************************/
723 /* Compute parameters for interactions between i and j atoms */
724 qq10 = _mm_mul_pd(iq1,jq0);
726 /* REACTION-FIELD ELECTROSTATICS */
727 felec = _mm_mul_pd(qq10,_mm_msub_pd(rinv10,rinvsq10,krf2));
731 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
733 /* Update vectorial force */
734 fix1 = _mm_macc_pd(dx10,fscal,fix1);
735 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
736 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
738 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
739 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
740 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
742 /**************************
743 * CALCULATE INTERACTIONS *
744 **************************/
746 /* Compute parameters for interactions between i and j atoms */
747 qq20 = _mm_mul_pd(iq2,jq0);
749 /* REACTION-FIELD ELECTROSTATICS */
750 felec = _mm_mul_pd(qq20,_mm_msub_pd(rinv20,rinvsq20,krf2));
754 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
756 /* Update vectorial force */
757 fix2 = _mm_macc_pd(dx20,fscal,fix2);
758 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
759 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
761 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
762 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
763 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
765 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,fjx0,fjy0,fjz0);
767 /* Inner loop uses 93 flops */
770 /* End of innermost loop */
772 gmx_mm_update_iforce_3atom_swizzle_pd(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
773 f+i_coord_offset,fshift+i_shift_offset);
775 /* Increment number of inner iterations */
776 inneriter += j_index_end - j_index_start;
778 /* Outer loop uses 18 flops */
781 /* Increment number of outer iterations */
784 /* Update outer/inner flops */
786 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3_F,outeriter*18 + inneriter*93);