2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013, 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 "types/simple.h"
49 #include "gromacs/simd/math_x86_avx_128_fma_double.h"
50 #include "kernelutil_x86_avx_128_fma_double.h"
53 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwNone_GeomW3P1_VF_avx_128_fma_double
54 * Electrostatics interaction: Coulomb
55 * VdW interaction: None
56 * Geometry: Water3-Particle
57 * Calculate force/pot: PotentialAndForce
60 nb_kernel_ElecCoul_VdwNone_GeomW3P1_VF_avx_128_fma_double
61 (t_nblist * gmx_restrict nlist,
62 rvec * gmx_restrict xx,
63 rvec * gmx_restrict ff,
64 t_forcerec * gmx_restrict fr,
65 t_mdatoms * gmx_restrict mdatoms,
66 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
67 t_nrnb * gmx_restrict nrnb)
69 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
70 * just 0 for non-waters.
71 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
72 * jnr indices corresponding to data put in the four positions in the SIMD register.
74 int i_shift_offset,i_coord_offset,outeriter,inneriter;
75 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
77 int j_coord_offsetA,j_coord_offsetB;
78 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
80 real *shiftvec,*fshift,*x,*f;
81 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
83 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
85 __m128d ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
87 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
88 int vdwjidx0A,vdwjidx0B;
89 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
90 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
91 __m128d dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
92 __m128d dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
93 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
95 __m128d dummy_mask,cutoff_mask;
96 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
97 __m128d one = _mm_set1_pd(1.0);
98 __m128d two = _mm_set1_pd(2.0);
104 jindex = nlist->jindex;
106 shiftidx = nlist->shift;
108 shiftvec = fr->shift_vec[0];
109 fshift = fr->fshift[0];
110 facel = _mm_set1_pd(fr->epsfac);
111 charge = mdatoms->chargeA;
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 = gmx_mm_invsqrt_pd(rsq00);
189 rinv10 = gmx_mm_invsqrt_pd(rsq10);
190 rinv20 = gmx_mm_invsqrt_pd(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 /* COULOMB ELECTROSTATICS */
211 velec = _mm_mul_pd(qq00,rinv00);
212 felec = _mm_mul_pd(velec,rinvsq00);
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 /* COULOMB ELECTROSTATICS */
236 velec = _mm_mul_pd(qq10,rinv10);
237 felec = _mm_mul_pd(velec,rinvsq10);
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 /* COULOMB ELECTROSTATICS */
261 velec = _mm_mul_pd(qq20,rinv20);
262 felec = _mm_mul_pd(velec,rinvsq20);
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 96 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 = gmx_mm_invsqrt_pd(rsq00);
310 rinv10 = gmx_mm_invsqrt_pd(rsq10);
311 rinv20 = gmx_mm_invsqrt_pd(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 /* COULOMB ELECTROSTATICS */
332 velec = _mm_mul_pd(qq00,rinv00);
333 felec = _mm_mul_pd(velec,rinvsq00);
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 /* COULOMB ELECTROSTATICS */
360 velec = _mm_mul_pd(qq10,rinv10);
361 felec = _mm_mul_pd(velec,rinvsq10);
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 /* COULOMB ELECTROSTATICS */
388 velec = _mm_mul_pd(qq20,rinv20);
389 felec = _mm_mul_pd(velec,rinvsq20);
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 96 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*96);
436 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwNone_GeomW3P1_F_avx_128_fma_double
437 * Electrostatics interaction: Coulomb
438 * VdW interaction: None
439 * Geometry: Water3-Particle
440 * Calculate force/pot: Force
443 nb_kernel_ElecCoul_VdwNone_GeomW3P1_F_avx_128_fma_double
444 (t_nblist * gmx_restrict nlist,
445 rvec * gmx_restrict xx,
446 rvec * gmx_restrict ff,
447 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->epsfac);
494 charge = mdatoms->chargeA;
496 /* Setup water-specific parameters */
497 inr = nlist->iinr[0];
498 iq0 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+0]));
499 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
500 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
502 /* Avoid stupid compiler warnings */
510 /* Start outer loop over neighborlists */
511 for(iidx=0; iidx<nri; iidx++)
513 /* Load shift vector for this list */
514 i_shift_offset = DIM*shiftidx[iidx];
516 /* Load limits for loop over neighbors */
517 j_index_start = jindex[iidx];
518 j_index_end = jindex[iidx+1];
520 /* Get outer coordinate index */
522 i_coord_offset = DIM*inr;
524 /* Load i particle coords and add shift vector */
525 gmx_mm_load_shift_and_3rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,
526 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
528 fix0 = _mm_setzero_pd();
529 fiy0 = _mm_setzero_pd();
530 fiz0 = _mm_setzero_pd();
531 fix1 = _mm_setzero_pd();
532 fiy1 = _mm_setzero_pd();
533 fiz1 = _mm_setzero_pd();
534 fix2 = _mm_setzero_pd();
535 fiy2 = _mm_setzero_pd();
536 fiz2 = _mm_setzero_pd();
538 /* Start inner kernel loop */
539 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
542 /* Get j neighbor index, and coordinate index */
545 j_coord_offsetA = DIM*jnrA;
546 j_coord_offsetB = DIM*jnrB;
548 /* load j atom coordinates */
549 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
552 /* Calculate displacement vector */
553 dx00 = _mm_sub_pd(ix0,jx0);
554 dy00 = _mm_sub_pd(iy0,jy0);
555 dz00 = _mm_sub_pd(iz0,jz0);
556 dx10 = _mm_sub_pd(ix1,jx0);
557 dy10 = _mm_sub_pd(iy1,jy0);
558 dz10 = _mm_sub_pd(iz1,jz0);
559 dx20 = _mm_sub_pd(ix2,jx0);
560 dy20 = _mm_sub_pd(iy2,jy0);
561 dz20 = _mm_sub_pd(iz2,jz0);
563 /* Calculate squared distance and things based on it */
564 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
565 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
566 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
568 rinv00 = gmx_mm_invsqrt_pd(rsq00);
569 rinv10 = gmx_mm_invsqrt_pd(rsq10);
570 rinv20 = gmx_mm_invsqrt_pd(rsq20);
572 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
573 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
574 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
576 /* Load parameters for j particles */
577 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
579 fjx0 = _mm_setzero_pd();
580 fjy0 = _mm_setzero_pd();
581 fjz0 = _mm_setzero_pd();
583 /**************************
584 * CALCULATE INTERACTIONS *
585 **************************/
587 /* Compute parameters for interactions between i and j atoms */
588 qq00 = _mm_mul_pd(iq0,jq0);
590 /* COULOMB ELECTROSTATICS */
591 velec = _mm_mul_pd(qq00,rinv00);
592 felec = _mm_mul_pd(velec,rinvsq00);
596 /* Update vectorial force */
597 fix0 = _mm_macc_pd(dx00,fscal,fix0);
598 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
599 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
601 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
602 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
603 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
605 /**************************
606 * CALCULATE INTERACTIONS *
607 **************************/
609 /* Compute parameters for interactions between i and j atoms */
610 qq10 = _mm_mul_pd(iq1,jq0);
612 /* COULOMB ELECTROSTATICS */
613 velec = _mm_mul_pd(qq10,rinv10);
614 felec = _mm_mul_pd(velec,rinvsq10);
618 /* Update vectorial force */
619 fix1 = _mm_macc_pd(dx10,fscal,fix1);
620 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
621 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
623 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
624 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
625 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
627 /**************************
628 * CALCULATE INTERACTIONS *
629 **************************/
631 /* Compute parameters for interactions between i and j atoms */
632 qq20 = _mm_mul_pd(iq2,jq0);
634 /* COULOMB ELECTROSTATICS */
635 velec = _mm_mul_pd(qq20,rinv20);
636 felec = _mm_mul_pd(velec,rinvsq20);
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 = gmx_mm_invsqrt_pd(rsq00);
681 rinv10 = gmx_mm_invsqrt_pd(rsq10);
682 rinv20 = gmx_mm_invsqrt_pd(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 /* COULOMB ELECTROSTATICS */
703 velec = _mm_mul_pd(qq00,rinv00);
704 felec = _mm_mul_pd(velec,rinvsq00);
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 /* COULOMB ELECTROSTATICS */
727 velec = _mm_mul_pd(qq10,rinv10);
728 felec = _mm_mul_pd(velec,rinvsq10);
732 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
734 /* Update vectorial force */
735 fix1 = _mm_macc_pd(dx10,fscal,fix1);
736 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
737 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
739 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
740 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
741 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
743 /**************************
744 * CALCULATE INTERACTIONS *
745 **************************/
747 /* Compute parameters for interactions between i and j atoms */
748 qq20 = _mm_mul_pd(iq2,jq0);
750 /* COULOMB ELECTROSTATICS */
751 velec = _mm_mul_pd(qq20,rinv20);
752 felec = _mm_mul_pd(velec,rinvsq20);
756 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
758 /* Update vectorial force */
759 fix2 = _mm_macc_pd(dx20,fscal,fix2);
760 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
761 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
763 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
764 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
765 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
767 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,fjx0,fjy0,fjz0);
769 /* Inner loop uses 93 flops */
772 /* End of innermost loop */
774 gmx_mm_update_iforce_3atom_swizzle_pd(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
775 f+i_coord_offset,fshift+i_shift_offset);
777 /* Increment number of inner iterations */
778 inneriter += j_index_end - j_index_start;
780 /* Outer loop uses 18 flops */
783 /* Increment number of outer iterations */
786 /* Update outer/inner flops */
788 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3_F,outeriter*18 + inneriter*93);