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 "types/simple.h"
44 #include "gromacs/math/vec.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_ElecCoul_VdwNone_GeomW3P1_VF_avx_128_fma_double
52 * Electrostatics interaction: Coulomb
53 * VdW interaction: None
54 * Geometry: Water3-Particle
55 * Calculate force/pot: PotentialAndForce
58 nb_kernel_ElecCoul_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;
111 /* Setup water-specific parameters */
112 inr = nlist->iinr[0];
113 iq0 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+0]));
114 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
115 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
117 /* Avoid stupid compiler warnings */
125 /* Start outer loop over neighborlists */
126 for(iidx=0; iidx<nri; iidx++)
128 /* Load shift vector for this list */
129 i_shift_offset = DIM*shiftidx[iidx];
131 /* Load limits for loop over neighbors */
132 j_index_start = jindex[iidx];
133 j_index_end = jindex[iidx+1];
135 /* Get outer coordinate index */
137 i_coord_offset = DIM*inr;
139 /* Load i particle coords and add shift vector */
140 gmx_mm_load_shift_and_3rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,
141 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
143 fix0 = _mm_setzero_pd();
144 fiy0 = _mm_setzero_pd();
145 fiz0 = _mm_setzero_pd();
146 fix1 = _mm_setzero_pd();
147 fiy1 = _mm_setzero_pd();
148 fiz1 = _mm_setzero_pd();
149 fix2 = _mm_setzero_pd();
150 fiy2 = _mm_setzero_pd();
151 fiz2 = _mm_setzero_pd();
153 /* Reset potential sums */
154 velecsum = _mm_setzero_pd();
156 /* Start inner kernel loop */
157 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
160 /* Get j neighbor index, and coordinate index */
163 j_coord_offsetA = DIM*jnrA;
164 j_coord_offsetB = DIM*jnrB;
166 /* load j atom coordinates */
167 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
170 /* Calculate displacement vector */
171 dx00 = _mm_sub_pd(ix0,jx0);
172 dy00 = _mm_sub_pd(iy0,jy0);
173 dz00 = _mm_sub_pd(iz0,jz0);
174 dx10 = _mm_sub_pd(ix1,jx0);
175 dy10 = _mm_sub_pd(iy1,jy0);
176 dz10 = _mm_sub_pd(iz1,jz0);
177 dx20 = _mm_sub_pd(ix2,jx0);
178 dy20 = _mm_sub_pd(iy2,jy0);
179 dz20 = _mm_sub_pd(iz2,jz0);
181 /* Calculate squared distance and things based on it */
182 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
183 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
184 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
186 rinv00 = gmx_mm_invsqrt_pd(rsq00);
187 rinv10 = gmx_mm_invsqrt_pd(rsq10);
188 rinv20 = gmx_mm_invsqrt_pd(rsq20);
190 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
191 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
192 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
194 /* Load parameters for j particles */
195 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
197 fjx0 = _mm_setzero_pd();
198 fjy0 = _mm_setzero_pd();
199 fjz0 = _mm_setzero_pd();
201 /**************************
202 * CALCULATE INTERACTIONS *
203 **************************/
205 /* Compute parameters for interactions between i and j atoms */
206 qq00 = _mm_mul_pd(iq0,jq0);
208 /* COULOMB ELECTROSTATICS */
209 velec = _mm_mul_pd(qq00,rinv00);
210 felec = _mm_mul_pd(velec,rinvsq00);
212 /* Update potential sum for this i atom from the interaction with this j atom. */
213 velecsum = _mm_add_pd(velecsum,velec);
217 /* Update vectorial force */
218 fix0 = _mm_macc_pd(dx00,fscal,fix0);
219 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
220 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
222 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
223 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
224 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
226 /**************************
227 * CALCULATE INTERACTIONS *
228 **************************/
230 /* Compute parameters for interactions between i and j atoms */
231 qq10 = _mm_mul_pd(iq1,jq0);
233 /* COULOMB ELECTROSTATICS */
234 velec = _mm_mul_pd(qq10,rinv10);
235 felec = _mm_mul_pd(velec,rinvsq10);
237 /* Update potential sum for this i atom from the interaction with this j atom. */
238 velecsum = _mm_add_pd(velecsum,velec);
242 /* Update vectorial force */
243 fix1 = _mm_macc_pd(dx10,fscal,fix1);
244 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
245 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
247 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
248 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
249 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
251 /**************************
252 * CALCULATE INTERACTIONS *
253 **************************/
255 /* Compute parameters for interactions between i and j atoms */
256 qq20 = _mm_mul_pd(iq2,jq0);
258 /* COULOMB ELECTROSTATICS */
259 velec = _mm_mul_pd(qq20,rinv20);
260 felec = _mm_mul_pd(velec,rinvsq20);
262 /* Update potential sum for this i atom from the interaction with this j atom. */
263 velecsum = _mm_add_pd(velecsum,velec);
267 /* Update vectorial force */
268 fix2 = _mm_macc_pd(dx20,fscal,fix2);
269 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
270 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
272 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
273 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
274 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
276 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
278 /* Inner loop uses 96 flops */
285 j_coord_offsetA = DIM*jnrA;
287 /* load j atom coordinates */
288 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
291 /* Calculate displacement vector */
292 dx00 = _mm_sub_pd(ix0,jx0);
293 dy00 = _mm_sub_pd(iy0,jy0);
294 dz00 = _mm_sub_pd(iz0,jz0);
295 dx10 = _mm_sub_pd(ix1,jx0);
296 dy10 = _mm_sub_pd(iy1,jy0);
297 dz10 = _mm_sub_pd(iz1,jz0);
298 dx20 = _mm_sub_pd(ix2,jx0);
299 dy20 = _mm_sub_pd(iy2,jy0);
300 dz20 = _mm_sub_pd(iz2,jz0);
302 /* Calculate squared distance and things based on it */
303 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
304 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
305 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
307 rinv00 = gmx_mm_invsqrt_pd(rsq00);
308 rinv10 = gmx_mm_invsqrt_pd(rsq10);
309 rinv20 = gmx_mm_invsqrt_pd(rsq20);
311 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
312 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
313 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
315 /* Load parameters for j particles */
316 jq0 = _mm_load_sd(charge+jnrA+0);
318 fjx0 = _mm_setzero_pd();
319 fjy0 = _mm_setzero_pd();
320 fjz0 = _mm_setzero_pd();
322 /**************************
323 * CALCULATE INTERACTIONS *
324 **************************/
326 /* Compute parameters for interactions between i and j atoms */
327 qq00 = _mm_mul_pd(iq0,jq0);
329 /* COULOMB ELECTROSTATICS */
330 velec = _mm_mul_pd(qq00,rinv00);
331 felec = _mm_mul_pd(velec,rinvsq00);
333 /* Update potential sum for this i atom from the interaction with this j atom. */
334 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
335 velecsum = _mm_add_pd(velecsum,velec);
339 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
341 /* Update vectorial force */
342 fix0 = _mm_macc_pd(dx00,fscal,fix0);
343 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
344 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
346 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
347 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
348 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
350 /**************************
351 * CALCULATE INTERACTIONS *
352 **************************/
354 /* Compute parameters for interactions between i and j atoms */
355 qq10 = _mm_mul_pd(iq1,jq0);
357 /* COULOMB ELECTROSTATICS */
358 velec = _mm_mul_pd(qq10,rinv10);
359 felec = _mm_mul_pd(velec,rinvsq10);
361 /* Update potential sum for this i atom from the interaction with this j atom. */
362 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
363 velecsum = _mm_add_pd(velecsum,velec);
367 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
369 /* Update vectorial force */
370 fix1 = _mm_macc_pd(dx10,fscal,fix1);
371 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
372 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
374 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
375 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
376 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
378 /**************************
379 * CALCULATE INTERACTIONS *
380 **************************/
382 /* Compute parameters for interactions between i and j atoms */
383 qq20 = _mm_mul_pd(iq2,jq0);
385 /* COULOMB ELECTROSTATICS */
386 velec = _mm_mul_pd(qq20,rinv20);
387 felec = _mm_mul_pd(velec,rinvsq20);
389 /* Update potential sum for this i atom from the interaction with this j atom. */
390 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
391 velecsum = _mm_add_pd(velecsum,velec);
395 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
397 /* Update vectorial force */
398 fix2 = _mm_macc_pd(dx20,fscal,fix2);
399 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
400 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
402 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
403 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
404 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
406 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,fjx0,fjy0,fjz0);
408 /* Inner loop uses 96 flops */
411 /* End of innermost loop */
413 gmx_mm_update_iforce_3atom_swizzle_pd(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
414 f+i_coord_offset,fshift+i_shift_offset);
417 /* Update potential energies */
418 gmx_mm_update_1pot_pd(velecsum,kernel_data->energygrp_elec+ggid);
420 /* Increment number of inner iterations */
421 inneriter += j_index_end - j_index_start;
423 /* Outer loop uses 19 flops */
426 /* Increment number of outer iterations */
429 /* Update outer/inner flops */
431 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3_VF,outeriter*19 + inneriter*96);
434 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwNone_GeomW3P1_F_avx_128_fma_double
435 * Electrostatics interaction: Coulomb
436 * VdW interaction: None
437 * Geometry: Water3-Particle
438 * Calculate force/pot: Force
441 nb_kernel_ElecCoul_VdwNone_GeomW3P1_F_avx_128_fma_double
442 (t_nblist * gmx_restrict nlist,
443 rvec * gmx_restrict xx,
444 rvec * gmx_restrict ff,
445 t_forcerec * gmx_restrict fr,
446 t_mdatoms * gmx_restrict mdatoms,
447 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
448 t_nrnb * gmx_restrict nrnb)
450 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
451 * just 0 for non-waters.
452 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
453 * jnr indices corresponding to data put in the four positions in the SIMD register.
455 int i_shift_offset,i_coord_offset,outeriter,inneriter;
456 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
458 int j_coord_offsetA,j_coord_offsetB;
459 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
461 real *shiftvec,*fshift,*x,*f;
462 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
464 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
466 __m128d ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
468 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
469 int vdwjidx0A,vdwjidx0B;
470 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
471 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
472 __m128d dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
473 __m128d dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
474 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
476 __m128d dummy_mask,cutoff_mask;
477 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
478 __m128d one = _mm_set1_pd(1.0);
479 __m128d two = _mm_set1_pd(2.0);
485 jindex = nlist->jindex;
487 shiftidx = nlist->shift;
489 shiftvec = fr->shift_vec[0];
490 fshift = fr->fshift[0];
491 facel = _mm_set1_pd(fr->epsfac);
492 charge = mdatoms->chargeA;
494 /* Setup water-specific parameters */
495 inr = nlist->iinr[0];
496 iq0 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+0]));
497 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
498 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
500 /* Avoid stupid compiler warnings */
508 /* Start outer loop over neighborlists */
509 for(iidx=0; iidx<nri; iidx++)
511 /* Load shift vector for this list */
512 i_shift_offset = DIM*shiftidx[iidx];
514 /* Load limits for loop over neighbors */
515 j_index_start = jindex[iidx];
516 j_index_end = jindex[iidx+1];
518 /* Get outer coordinate index */
520 i_coord_offset = DIM*inr;
522 /* Load i particle coords and add shift vector */
523 gmx_mm_load_shift_and_3rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,
524 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
526 fix0 = _mm_setzero_pd();
527 fiy0 = _mm_setzero_pd();
528 fiz0 = _mm_setzero_pd();
529 fix1 = _mm_setzero_pd();
530 fiy1 = _mm_setzero_pd();
531 fiz1 = _mm_setzero_pd();
532 fix2 = _mm_setzero_pd();
533 fiy2 = _mm_setzero_pd();
534 fiz2 = _mm_setzero_pd();
536 /* Start inner kernel loop */
537 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
540 /* Get j neighbor index, and coordinate index */
543 j_coord_offsetA = DIM*jnrA;
544 j_coord_offsetB = DIM*jnrB;
546 /* load j atom coordinates */
547 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
550 /* Calculate displacement vector */
551 dx00 = _mm_sub_pd(ix0,jx0);
552 dy00 = _mm_sub_pd(iy0,jy0);
553 dz00 = _mm_sub_pd(iz0,jz0);
554 dx10 = _mm_sub_pd(ix1,jx0);
555 dy10 = _mm_sub_pd(iy1,jy0);
556 dz10 = _mm_sub_pd(iz1,jz0);
557 dx20 = _mm_sub_pd(ix2,jx0);
558 dy20 = _mm_sub_pd(iy2,jy0);
559 dz20 = _mm_sub_pd(iz2,jz0);
561 /* Calculate squared distance and things based on it */
562 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
563 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
564 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
566 rinv00 = gmx_mm_invsqrt_pd(rsq00);
567 rinv10 = gmx_mm_invsqrt_pd(rsq10);
568 rinv20 = gmx_mm_invsqrt_pd(rsq20);
570 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
571 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
572 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
574 /* Load parameters for j particles */
575 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
577 fjx0 = _mm_setzero_pd();
578 fjy0 = _mm_setzero_pd();
579 fjz0 = _mm_setzero_pd();
581 /**************************
582 * CALCULATE INTERACTIONS *
583 **************************/
585 /* Compute parameters for interactions between i and j atoms */
586 qq00 = _mm_mul_pd(iq0,jq0);
588 /* COULOMB ELECTROSTATICS */
589 velec = _mm_mul_pd(qq00,rinv00);
590 felec = _mm_mul_pd(velec,rinvsq00);
594 /* Update vectorial force */
595 fix0 = _mm_macc_pd(dx00,fscal,fix0);
596 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
597 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
599 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
600 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
601 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
603 /**************************
604 * CALCULATE INTERACTIONS *
605 **************************/
607 /* Compute parameters for interactions between i and j atoms */
608 qq10 = _mm_mul_pd(iq1,jq0);
610 /* COULOMB ELECTROSTATICS */
611 velec = _mm_mul_pd(qq10,rinv10);
612 felec = _mm_mul_pd(velec,rinvsq10);
616 /* Update vectorial force */
617 fix1 = _mm_macc_pd(dx10,fscal,fix1);
618 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
619 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
621 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
622 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
623 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
625 /**************************
626 * CALCULATE INTERACTIONS *
627 **************************/
629 /* Compute parameters for interactions between i and j atoms */
630 qq20 = _mm_mul_pd(iq2,jq0);
632 /* COULOMB ELECTROSTATICS */
633 velec = _mm_mul_pd(qq20,rinv20);
634 felec = _mm_mul_pd(velec,rinvsq20);
638 /* Update vectorial force */
639 fix2 = _mm_macc_pd(dx20,fscal,fix2);
640 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
641 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
643 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
644 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
645 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
647 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
649 /* Inner loop uses 93 flops */
656 j_coord_offsetA = DIM*jnrA;
658 /* load j atom coordinates */
659 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
662 /* Calculate displacement vector */
663 dx00 = _mm_sub_pd(ix0,jx0);
664 dy00 = _mm_sub_pd(iy0,jy0);
665 dz00 = _mm_sub_pd(iz0,jz0);
666 dx10 = _mm_sub_pd(ix1,jx0);
667 dy10 = _mm_sub_pd(iy1,jy0);
668 dz10 = _mm_sub_pd(iz1,jz0);
669 dx20 = _mm_sub_pd(ix2,jx0);
670 dy20 = _mm_sub_pd(iy2,jy0);
671 dz20 = _mm_sub_pd(iz2,jz0);
673 /* Calculate squared distance and things based on it */
674 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
675 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
676 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
678 rinv00 = gmx_mm_invsqrt_pd(rsq00);
679 rinv10 = gmx_mm_invsqrt_pd(rsq10);
680 rinv20 = gmx_mm_invsqrt_pd(rsq20);
682 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
683 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
684 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
686 /* Load parameters for j particles */
687 jq0 = _mm_load_sd(charge+jnrA+0);
689 fjx0 = _mm_setzero_pd();
690 fjy0 = _mm_setzero_pd();
691 fjz0 = _mm_setzero_pd();
693 /**************************
694 * CALCULATE INTERACTIONS *
695 **************************/
697 /* Compute parameters for interactions between i and j atoms */
698 qq00 = _mm_mul_pd(iq0,jq0);
700 /* COULOMB ELECTROSTATICS */
701 velec = _mm_mul_pd(qq00,rinv00);
702 felec = _mm_mul_pd(velec,rinvsq00);
706 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
708 /* Update vectorial force */
709 fix0 = _mm_macc_pd(dx00,fscal,fix0);
710 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
711 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
713 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
714 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
715 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
717 /**************************
718 * CALCULATE INTERACTIONS *
719 **************************/
721 /* Compute parameters for interactions between i and j atoms */
722 qq10 = _mm_mul_pd(iq1,jq0);
724 /* COULOMB ELECTROSTATICS */
725 velec = _mm_mul_pd(qq10,rinv10);
726 felec = _mm_mul_pd(velec,rinvsq10);
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 /* COULOMB ELECTROSTATICS */
749 velec = _mm_mul_pd(qq20,rinv20);
750 felec = _mm_mul_pd(velec,rinvsq20);
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);