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.
44 #include "../nb_kernel.h"
45 #include "gromacs/legacyheaders/types/simple.h"
46 #include "gromacs/math/vec.h"
47 #include "gromacs/legacyheaders/nrnb.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_ElecRF_VdwNone_GeomW4P1_VF_avx_128_fma_double
54 * Electrostatics interaction: ReactionField
55 * VdW interaction: None
56 * Geometry: Water4-Particle
57 * Calculate force/pot: PotentialAndForce
60 nb_kernel_ElecRF_VdwNone_GeomW4P1_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 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
85 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
87 __m128d ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
88 int vdwjidx0A,vdwjidx0B;
89 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
90 __m128d dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
91 __m128d dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
92 __m128d dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
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;
112 krf = _mm_set1_pd(fr->ic->k_rf);
113 krf2 = _mm_set1_pd(fr->ic->k_rf*2.0);
114 crf = _mm_set1_pd(fr->ic->c_rf);
116 /* Setup water-specific parameters */
117 inr = nlist->iinr[0];
118 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
119 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
120 iq3 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+3]));
122 /* Avoid stupid compiler warnings */
130 /* Start outer loop over neighborlists */
131 for(iidx=0; iidx<nri; iidx++)
133 /* Load shift vector for this list */
134 i_shift_offset = DIM*shiftidx[iidx];
136 /* Load limits for loop over neighbors */
137 j_index_start = jindex[iidx];
138 j_index_end = jindex[iidx+1];
140 /* Get outer coordinate index */
142 i_coord_offset = DIM*inr;
144 /* Load i particle coords and add shift vector */
145 gmx_mm_load_shift_and_3rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset+DIM,
146 &ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
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();
154 fix3 = _mm_setzero_pd();
155 fiy3 = _mm_setzero_pd();
156 fiz3 = _mm_setzero_pd();
158 /* Reset potential sums */
159 velecsum = _mm_setzero_pd();
161 /* Start inner kernel loop */
162 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
165 /* Get j neighbor index, and coordinate index */
168 j_coord_offsetA = DIM*jnrA;
169 j_coord_offsetB = DIM*jnrB;
171 /* load j atom coordinates */
172 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
175 /* Calculate displacement vector */
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);
182 dx30 = _mm_sub_pd(ix3,jx0);
183 dy30 = _mm_sub_pd(iy3,jy0);
184 dz30 = _mm_sub_pd(iz3,jz0);
186 /* Calculate squared distance and things based on it */
187 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
188 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
189 rsq30 = gmx_mm_calc_rsq_pd(dx30,dy30,dz30);
191 rinv10 = gmx_mm_invsqrt_pd(rsq10);
192 rinv20 = gmx_mm_invsqrt_pd(rsq20);
193 rinv30 = gmx_mm_invsqrt_pd(rsq30);
195 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
196 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
197 rinvsq30 = _mm_mul_pd(rinv30,rinv30);
199 /* Load parameters for j particles */
200 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
202 fjx0 = _mm_setzero_pd();
203 fjy0 = _mm_setzero_pd();
204 fjz0 = _mm_setzero_pd();
206 /**************************
207 * CALCULATE INTERACTIONS *
208 **************************/
210 /* Compute parameters for interactions between i and j atoms */
211 qq10 = _mm_mul_pd(iq1,jq0);
213 /* REACTION-FIELD ELECTROSTATICS */
214 velec = _mm_mul_pd(qq10,_mm_sub_pd(_mm_macc_pd(krf,rsq10,rinv10),crf));
215 felec = _mm_mul_pd(qq10,_mm_msub_pd(rinv10,rinvsq10,krf2));
217 /* Update potential sum for this i atom from the interaction with this j atom. */
218 velecsum = _mm_add_pd(velecsum,velec);
222 /* Update vectorial force */
223 fix1 = _mm_macc_pd(dx10,fscal,fix1);
224 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
225 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
227 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
228 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
229 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
231 /**************************
232 * CALCULATE INTERACTIONS *
233 **************************/
235 /* Compute parameters for interactions between i and j atoms */
236 qq20 = _mm_mul_pd(iq2,jq0);
238 /* REACTION-FIELD ELECTROSTATICS */
239 velec = _mm_mul_pd(qq20,_mm_sub_pd(_mm_macc_pd(krf,rsq20,rinv20),crf));
240 felec = _mm_mul_pd(qq20,_mm_msub_pd(rinv20,rinvsq20,krf2));
242 /* Update potential sum for this i atom from the interaction with this j atom. */
243 velecsum = _mm_add_pd(velecsum,velec);
247 /* Update vectorial force */
248 fix2 = _mm_macc_pd(dx20,fscal,fix2);
249 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
250 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
252 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
253 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
254 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
256 /**************************
257 * CALCULATE INTERACTIONS *
258 **************************/
260 /* Compute parameters for interactions between i and j atoms */
261 qq30 = _mm_mul_pd(iq3,jq0);
263 /* REACTION-FIELD ELECTROSTATICS */
264 velec = _mm_mul_pd(qq30,_mm_sub_pd(_mm_macc_pd(krf,rsq30,rinv30),crf));
265 felec = _mm_mul_pd(qq30,_mm_msub_pd(rinv30,rinvsq30,krf2));
267 /* Update potential sum for this i atom from the interaction with this j atom. */
268 velecsum = _mm_add_pd(velecsum,velec);
272 /* Update vectorial force */
273 fix3 = _mm_macc_pd(dx30,fscal,fix3);
274 fiy3 = _mm_macc_pd(dy30,fscal,fiy3);
275 fiz3 = _mm_macc_pd(dz30,fscal,fiz3);
277 fjx0 = _mm_macc_pd(dx30,fscal,fjx0);
278 fjy0 = _mm_macc_pd(dy30,fscal,fjy0);
279 fjz0 = _mm_macc_pd(dz30,fscal,fjz0);
281 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
283 /* Inner loop uses 108 flops */
290 j_coord_offsetA = DIM*jnrA;
292 /* load j atom coordinates */
293 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
296 /* Calculate displacement vector */
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);
303 dx30 = _mm_sub_pd(ix3,jx0);
304 dy30 = _mm_sub_pd(iy3,jy0);
305 dz30 = _mm_sub_pd(iz3,jz0);
307 /* Calculate squared distance and things based on it */
308 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
309 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
310 rsq30 = gmx_mm_calc_rsq_pd(dx30,dy30,dz30);
312 rinv10 = gmx_mm_invsqrt_pd(rsq10);
313 rinv20 = gmx_mm_invsqrt_pd(rsq20);
314 rinv30 = gmx_mm_invsqrt_pd(rsq30);
316 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
317 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
318 rinvsq30 = _mm_mul_pd(rinv30,rinv30);
320 /* Load parameters for j particles */
321 jq0 = _mm_load_sd(charge+jnrA+0);
323 fjx0 = _mm_setzero_pd();
324 fjy0 = _mm_setzero_pd();
325 fjz0 = _mm_setzero_pd();
327 /**************************
328 * CALCULATE INTERACTIONS *
329 **************************/
331 /* Compute parameters for interactions between i and j atoms */
332 qq10 = _mm_mul_pd(iq1,jq0);
334 /* REACTION-FIELD ELECTROSTATICS */
335 velec = _mm_mul_pd(qq10,_mm_sub_pd(_mm_macc_pd(krf,rsq10,rinv10),crf));
336 felec = _mm_mul_pd(qq10,_mm_msub_pd(rinv10,rinvsq10,krf2));
338 /* Update potential sum for this i atom from the interaction with this j atom. */
339 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
340 velecsum = _mm_add_pd(velecsum,velec);
344 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
346 /* Update vectorial force */
347 fix1 = _mm_macc_pd(dx10,fscal,fix1);
348 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
349 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
351 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
352 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
353 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
355 /**************************
356 * CALCULATE INTERACTIONS *
357 **************************/
359 /* Compute parameters for interactions between i and j atoms */
360 qq20 = _mm_mul_pd(iq2,jq0);
362 /* REACTION-FIELD ELECTROSTATICS */
363 velec = _mm_mul_pd(qq20,_mm_sub_pd(_mm_macc_pd(krf,rsq20,rinv20),crf));
364 felec = _mm_mul_pd(qq20,_mm_msub_pd(rinv20,rinvsq20,krf2));
366 /* Update potential sum for this i atom from the interaction with this j atom. */
367 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
368 velecsum = _mm_add_pd(velecsum,velec);
372 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
374 /* Update vectorial force */
375 fix2 = _mm_macc_pd(dx20,fscal,fix2);
376 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
377 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
379 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
380 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
381 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
383 /**************************
384 * CALCULATE INTERACTIONS *
385 **************************/
387 /* Compute parameters for interactions between i and j atoms */
388 qq30 = _mm_mul_pd(iq3,jq0);
390 /* REACTION-FIELD ELECTROSTATICS */
391 velec = _mm_mul_pd(qq30,_mm_sub_pd(_mm_macc_pd(krf,rsq30,rinv30),crf));
392 felec = _mm_mul_pd(qq30,_mm_msub_pd(rinv30,rinvsq30,krf2));
394 /* Update potential sum for this i atom from the interaction with this j atom. */
395 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
396 velecsum = _mm_add_pd(velecsum,velec);
400 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
402 /* Update vectorial force */
403 fix3 = _mm_macc_pd(dx30,fscal,fix3);
404 fiy3 = _mm_macc_pd(dy30,fscal,fiy3);
405 fiz3 = _mm_macc_pd(dz30,fscal,fiz3);
407 fjx0 = _mm_macc_pd(dx30,fscal,fjx0);
408 fjy0 = _mm_macc_pd(dy30,fscal,fjy0);
409 fjz0 = _mm_macc_pd(dz30,fscal,fjz0);
411 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,fjx0,fjy0,fjz0);
413 /* Inner loop uses 108 flops */
416 /* End of innermost loop */
418 gmx_mm_update_iforce_3atom_swizzle_pd(fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
419 f+i_coord_offset+DIM,fshift+i_shift_offset);
422 /* Update potential energies */
423 gmx_mm_update_1pot_pd(velecsum,kernel_data->energygrp_elec+ggid);
425 /* Increment number of inner iterations */
426 inneriter += j_index_end - j_index_start;
428 /* Outer loop uses 19 flops */
431 /* Increment number of outer iterations */
434 /* Update outer/inner flops */
436 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4_VF,outeriter*19 + inneriter*108);
439 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwNone_GeomW4P1_F_avx_128_fma_double
440 * Electrostatics interaction: ReactionField
441 * VdW interaction: None
442 * Geometry: Water4-Particle
443 * Calculate force/pot: Force
446 nb_kernel_ElecRF_VdwNone_GeomW4P1_F_avx_128_fma_double
447 (t_nblist * gmx_restrict nlist,
448 rvec * gmx_restrict xx,
449 rvec * gmx_restrict ff,
450 t_forcerec * gmx_restrict fr,
451 t_mdatoms * gmx_restrict mdatoms,
452 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
453 t_nrnb * gmx_restrict nrnb)
455 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
456 * just 0 for non-waters.
457 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
458 * jnr indices corresponding to data put in the four positions in the SIMD register.
460 int i_shift_offset,i_coord_offset,outeriter,inneriter;
461 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
463 int j_coord_offsetA,j_coord_offsetB;
464 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
466 real *shiftvec,*fshift,*x,*f;
467 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
469 __m128d ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
471 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
473 __m128d ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
474 int vdwjidx0A,vdwjidx0B;
475 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
476 __m128d dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
477 __m128d dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
478 __m128d dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
479 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
481 __m128d dummy_mask,cutoff_mask;
482 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
483 __m128d one = _mm_set1_pd(1.0);
484 __m128d two = _mm_set1_pd(2.0);
490 jindex = nlist->jindex;
492 shiftidx = nlist->shift;
494 shiftvec = fr->shift_vec[0];
495 fshift = fr->fshift[0];
496 facel = _mm_set1_pd(fr->epsfac);
497 charge = mdatoms->chargeA;
498 krf = _mm_set1_pd(fr->ic->k_rf);
499 krf2 = _mm_set1_pd(fr->ic->k_rf*2.0);
500 crf = _mm_set1_pd(fr->ic->c_rf);
502 /* Setup water-specific parameters */
503 inr = nlist->iinr[0];
504 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
505 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
506 iq3 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+3]));
508 /* Avoid stupid compiler warnings */
516 /* Start outer loop over neighborlists */
517 for(iidx=0; iidx<nri; iidx++)
519 /* Load shift vector for this list */
520 i_shift_offset = DIM*shiftidx[iidx];
522 /* Load limits for loop over neighbors */
523 j_index_start = jindex[iidx];
524 j_index_end = jindex[iidx+1];
526 /* Get outer coordinate index */
528 i_coord_offset = DIM*inr;
530 /* Load i particle coords and add shift vector */
531 gmx_mm_load_shift_and_3rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset+DIM,
532 &ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
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();
540 fix3 = _mm_setzero_pd();
541 fiy3 = _mm_setzero_pd();
542 fiz3 = _mm_setzero_pd();
544 /* Start inner kernel loop */
545 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
548 /* Get j neighbor index, and coordinate index */
551 j_coord_offsetA = DIM*jnrA;
552 j_coord_offsetB = DIM*jnrB;
554 /* load j atom coordinates */
555 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
558 /* Calculate displacement vector */
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);
565 dx30 = _mm_sub_pd(ix3,jx0);
566 dy30 = _mm_sub_pd(iy3,jy0);
567 dz30 = _mm_sub_pd(iz3,jz0);
569 /* Calculate squared distance and things based on it */
570 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
571 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
572 rsq30 = gmx_mm_calc_rsq_pd(dx30,dy30,dz30);
574 rinv10 = gmx_mm_invsqrt_pd(rsq10);
575 rinv20 = gmx_mm_invsqrt_pd(rsq20);
576 rinv30 = gmx_mm_invsqrt_pd(rsq30);
578 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
579 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
580 rinvsq30 = _mm_mul_pd(rinv30,rinv30);
582 /* Load parameters for j particles */
583 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
585 fjx0 = _mm_setzero_pd();
586 fjy0 = _mm_setzero_pd();
587 fjz0 = _mm_setzero_pd();
589 /**************************
590 * CALCULATE INTERACTIONS *
591 **************************/
593 /* Compute parameters for interactions between i and j atoms */
594 qq10 = _mm_mul_pd(iq1,jq0);
596 /* REACTION-FIELD ELECTROSTATICS */
597 felec = _mm_mul_pd(qq10,_mm_msub_pd(rinv10,rinvsq10,krf2));
601 /* Update vectorial force */
602 fix1 = _mm_macc_pd(dx10,fscal,fix1);
603 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
604 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
606 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
607 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
608 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
610 /**************************
611 * CALCULATE INTERACTIONS *
612 **************************/
614 /* Compute parameters for interactions between i and j atoms */
615 qq20 = _mm_mul_pd(iq2,jq0);
617 /* REACTION-FIELD ELECTROSTATICS */
618 felec = _mm_mul_pd(qq20,_mm_msub_pd(rinv20,rinvsq20,krf2));
622 /* Update vectorial force */
623 fix2 = _mm_macc_pd(dx20,fscal,fix2);
624 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
625 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
627 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
628 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
629 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
631 /**************************
632 * CALCULATE INTERACTIONS *
633 **************************/
635 /* Compute parameters for interactions between i and j atoms */
636 qq30 = _mm_mul_pd(iq3,jq0);
638 /* REACTION-FIELD ELECTROSTATICS */
639 felec = _mm_mul_pd(qq30,_mm_msub_pd(rinv30,rinvsq30,krf2));
643 /* Update vectorial force */
644 fix3 = _mm_macc_pd(dx30,fscal,fix3);
645 fiy3 = _mm_macc_pd(dy30,fscal,fiy3);
646 fiz3 = _mm_macc_pd(dz30,fscal,fiz3);
648 fjx0 = _mm_macc_pd(dx30,fscal,fjx0);
649 fjy0 = _mm_macc_pd(dy30,fscal,fjy0);
650 fjz0 = _mm_macc_pd(dz30,fscal,fjz0);
652 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
654 /* Inner loop uses 93 flops */
661 j_coord_offsetA = DIM*jnrA;
663 /* load j atom coordinates */
664 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
667 /* Calculate displacement vector */
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);
674 dx30 = _mm_sub_pd(ix3,jx0);
675 dy30 = _mm_sub_pd(iy3,jy0);
676 dz30 = _mm_sub_pd(iz3,jz0);
678 /* Calculate squared distance and things based on it */
679 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
680 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
681 rsq30 = gmx_mm_calc_rsq_pd(dx30,dy30,dz30);
683 rinv10 = gmx_mm_invsqrt_pd(rsq10);
684 rinv20 = gmx_mm_invsqrt_pd(rsq20);
685 rinv30 = gmx_mm_invsqrt_pd(rsq30);
687 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
688 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
689 rinvsq30 = _mm_mul_pd(rinv30,rinv30);
691 /* Load parameters for j particles */
692 jq0 = _mm_load_sd(charge+jnrA+0);
694 fjx0 = _mm_setzero_pd();
695 fjy0 = _mm_setzero_pd();
696 fjz0 = _mm_setzero_pd();
698 /**************************
699 * CALCULATE INTERACTIONS *
700 **************************/
702 /* Compute parameters for interactions between i and j atoms */
703 qq10 = _mm_mul_pd(iq1,jq0);
705 /* REACTION-FIELD ELECTROSTATICS */
706 felec = _mm_mul_pd(qq10,_mm_msub_pd(rinv10,rinvsq10,krf2));
710 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
712 /* Update vectorial force */
713 fix1 = _mm_macc_pd(dx10,fscal,fix1);
714 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
715 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
717 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
718 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
719 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
721 /**************************
722 * CALCULATE INTERACTIONS *
723 **************************/
725 /* Compute parameters for interactions between i and j atoms */
726 qq20 = _mm_mul_pd(iq2,jq0);
728 /* REACTION-FIELD ELECTROSTATICS */
729 felec = _mm_mul_pd(qq20,_mm_msub_pd(rinv20,rinvsq20,krf2));
733 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
735 /* Update vectorial force */
736 fix2 = _mm_macc_pd(dx20,fscal,fix2);
737 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
738 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
740 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
741 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
742 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
744 /**************************
745 * CALCULATE INTERACTIONS *
746 **************************/
748 /* Compute parameters for interactions between i and j atoms */
749 qq30 = _mm_mul_pd(iq3,jq0);
751 /* REACTION-FIELD ELECTROSTATICS */
752 felec = _mm_mul_pd(qq30,_mm_msub_pd(rinv30,rinvsq30,krf2));
756 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
758 /* Update vectorial force */
759 fix3 = _mm_macc_pd(dx30,fscal,fix3);
760 fiy3 = _mm_macc_pd(dy30,fscal,fiy3);
761 fiz3 = _mm_macc_pd(dz30,fscal,fiz3);
763 fjx0 = _mm_macc_pd(dx30,fscal,fjx0);
764 fjy0 = _mm_macc_pd(dy30,fscal,fjy0);
765 fjz0 = _mm_macc_pd(dz30,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(fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
775 f+i_coord_offset+DIM,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_W4_F,outeriter*18 + inneriter*93);