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_ElecRFCut_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_ElecRFCut_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 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
121 rcutoff_scalar = fr->rcoulomb;
122 rcutoff = _mm_set1_pd(rcutoff_scalar);
123 rcutoff2 = _mm_mul_pd(rcutoff,rcutoff);
125 /* Avoid stupid compiler warnings */
133 /* Start outer loop over neighborlists */
134 for(iidx=0; iidx<nri; iidx++)
136 /* Load shift vector for this list */
137 i_shift_offset = DIM*shiftidx[iidx];
139 /* Load limits for loop over neighbors */
140 j_index_start = jindex[iidx];
141 j_index_end = jindex[iidx+1];
143 /* Get outer coordinate index */
145 i_coord_offset = DIM*inr;
147 /* Load i particle coords and add shift vector */
148 gmx_mm_load_shift_and_3rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,
149 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
151 fix0 = _mm_setzero_pd();
152 fiy0 = _mm_setzero_pd();
153 fiz0 = _mm_setzero_pd();
154 fix1 = _mm_setzero_pd();
155 fiy1 = _mm_setzero_pd();
156 fiz1 = _mm_setzero_pd();
157 fix2 = _mm_setzero_pd();
158 fiy2 = _mm_setzero_pd();
159 fiz2 = _mm_setzero_pd();
161 /* Reset potential sums */
162 velecsum = _mm_setzero_pd();
164 /* Start inner kernel loop */
165 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
168 /* Get j neighbor index, and coordinate index */
171 j_coord_offsetA = DIM*jnrA;
172 j_coord_offsetB = DIM*jnrB;
174 /* load j atom coordinates */
175 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
178 /* Calculate displacement vector */
179 dx00 = _mm_sub_pd(ix0,jx0);
180 dy00 = _mm_sub_pd(iy0,jy0);
181 dz00 = _mm_sub_pd(iz0,jz0);
182 dx10 = _mm_sub_pd(ix1,jx0);
183 dy10 = _mm_sub_pd(iy1,jy0);
184 dz10 = _mm_sub_pd(iz1,jz0);
185 dx20 = _mm_sub_pd(ix2,jx0);
186 dy20 = _mm_sub_pd(iy2,jy0);
187 dz20 = _mm_sub_pd(iz2,jz0);
189 /* Calculate squared distance and things based on it */
190 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
191 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
192 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
194 rinv00 = gmx_mm_invsqrt_pd(rsq00);
195 rinv10 = gmx_mm_invsqrt_pd(rsq10);
196 rinv20 = gmx_mm_invsqrt_pd(rsq20);
198 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
199 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
200 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
202 /* Load parameters for j particles */
203 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
205 fjx0 = _mm_setzero_pd();
206 fjy0 = _mm_setzero_pd();
207 fjz0 = _mm_setzero_pd();
209 /**************************
210 * CALCULATE INTERACTIONS *
211 **************************/
213 if (gmx_mm_any_lt(rsq00,rcutoff2))
216 /* Compute parameters for interactions between i and j atoms */
217 qq00 = _mm_mul_pd(iq0,jq0);
219 /* REACTION-FIELD ELECTROSTATICS */
220 velec = _mm_mul_pd(qq00,_mm_sub_pd(_mm_macc_pd(krf,rsq00,rinv00),crf));
221 felec = _mm_mul_pd(qq00,_mm_msub_pd(rinv00,rinvsq00,krf2));
223 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
225 /* Update potential sum for this i atom from the interaction with this j atom. */
226 velec = _mm_and_pd(velec,cutoff_mask);
227 velecsum = _mm_add_pd(velecsum,velec);
231 fscal = _mm_and_pd(fscal,cutoff_mask);
233 /* Update vectorial force */
234 fix0 = _mm_macc_pd(dx00,fscal,fix0);
235 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
236 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
238 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
239 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
240 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
244 /**************************
245 * CALCULATE INTERACTIONS *
246 **************************/
248 if (gmx_mm_any_lt(rsq10,rcutoff2))
251 /* Compute parameters for interactions between i and j atoms */
252 qq10 = _mm_mul_pd(iq1,jq0);
254 /* REACTION-FIELD ELECTROSTATICS */
255 velec = _mm_mul_pd(qq10,_mm_sub_pd(_mm_macc_pd(krf,rsq10,rinv10),crf));
256 felec = _mm_mul_pd(qq10,_mm_msub_pd(rinv10,rinvsq10,krf2));
258 cutoff_mask = _mm_cmplt_pd(rsq10,rcutoff2);
260 /* Update potential sum for this i atom from the interaction with this j atom. */
261 velec = _mm_and_pd(velec,cutoff_mask);
262 velecsum = _mm_add_pd(velecsum,velec);
266 fscal = _mm_and_pd(fscal,cutoff_mask);
268 /* Update vectorial force */
269 fix1 = _mm_macc_pd(dx10,fscal,fix1);
270 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
271 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
273 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
274 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
275 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
279 /**************************
280 * CALCULATE INTERACTIONS *
281 **************************/
283 if (gmx_mm_any_lt(rsq20,rcutoff2))
286 /* Compute parameters for interactions between i and j atoms */
287 qq20 = _mm_mul_pd(iq2,jq0);
289 /* REACTION-FIELD ELECTROSTATICS */
290 velec = _mm_mul_pd(qq20,_mm_sub_pd(_mm_macc_pd(krf,rsq20,rinv20),crf));
291 felec = _mm_mul_pd(qq20,_mm_msub_pd(rinv20,rinvsq20,krf2));
293 cutoff_mask = _mm_cmplt_pd(rsq20,rcutoff2);
295 /* Update potential sum for this i atom from the interaction with this j atom. */
296 velec = _mm_and_pd(velec,cutoff_mask);
297 velecsum = _mm_add_pd(velecsum,velec);
301 fscal = _mm_and_pd(fscal,cutoff_mask);
303 /* Update vectorial force */
304 fix2 = _mm_macc_pd(dx20,fscal,fix2);
305 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
306 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
308 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
309 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
310 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
314 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
316 /* Inner loop uses 120 flops */
323 j_coord_offsetA = DIM*jnrA;
325 /* load j atom coordinates */
326 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
329 /* Calculate displacement vector */
330 dx00 = _mm_sub_pd(ix0,jx0);
331 dy00 = _mm_sub_pd(iy0,jy0);
332 dz00 = _mm_sub_pd(iz0,jz0);
333 dx10 = _mm_sub_pd(ix1,jx0);
334 dy10 = _mm_sub_pd(iy1,jy0);
335 dz10 = _mm_sub_pd(iz1,jz0);
336 dx20 = _mm_sub_pd(ix2,jx0);
337 dy20 = _mm_sub_pd(iy2,jy0);
338 dz20 = _mm_sub_pd(iz2,jz0);
340 /* Calculate squared distance and things based on it */
341 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
342 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
343 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
345 rinv00 = gmx_mm_invsqrt_pd(rsq00);
346 rinv10 = gmx_mm_invsqrt_pd(rsq10);
347 rinv20 = gmx_mm_invsqrt_pd(rsq20);
349 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
350 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
351 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
353 /* Load parameters for j particles */
354 jq0 = _mm_load_sd(charge+jnrA+0);
356 fjx0 = _mm_setzero_pd();
357 fjy0 = _mm_setzero_pd();
358 fjz0 = _mm_setzero_pd();
360 /**************************
361 * CALCULATE INTERACTIONS *
362 **************************/
364 if (gmx_mm_any_lt(rsq00,rcutoff2))
367 /* Compute parameters for interactions between i and j atoms */
368 qq00 = _mm_mul_pd(iq0,jq0);
370 /* REACTION-FIELD ELECTROSTATICS */
371 velec = _mm_mul_pd(qq00,_mm_sub_pd(_mm_macc_pd(krf,rsq00,rinv00),crf));
372 felec = _mm_mul_pd(qq00,_mm_msub_pd(rinv00,rinvsq00,krf2));
374 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
376 /* Update potential sum for this i atom from the interaction with this j atom. */
377 velec = _mm_and_pd(velec,cutoff_mask);
378 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
379 velecsum = _mm_add_pd(velecsum,velec);
383 fscal = _mm_and_pd(fscal,cutoff_mask);
385 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
387 /* Update vectorial force */
388 fix0 = _mm_macc_pd(dx00,fscal,fix0);
389 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
390 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
392 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
393 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
394 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
398 /**************************
399 * CALCULATE INTERACTIONS *
400 **************************/
402 if (gmx_mm_any_lt(rsq10,rcutoff2))
405 /* Compute parameters for interactions between i and j atoms */
406 qq10 = _mm_mul_pd(iq1,jq0);
408 /* REACTION-FIELD ELECTROSTATICS */
409 velec = _mm_mul_pd(qq10,_mm_sub_pd(_mm_macc_pd(krf,rsq10,rinv10),crf));
410 felec = _mm_mul_pd(qq10,_mm_msub_pd(rinv10,rinvsq10,krf2));
412 cutoff_mask = _mm_cmplt_pd(rsq10,rcutoff2);
414 /* Update potential sum for this i atom from the interaction with this j atom. */
415 velec = _mm_and_pd(velec,cutoff_mask);
416 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
417 velecsum = _mm_add_pd(velecsum,velec);
421 fscal = _mm_and_pd(fscal,cutoff_mask);
423 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
425 /* Update vectorial force */
426 fix1 = _mm_macc_pd(dx10,fscal,fix1);
427 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
428 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
430 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
431 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
432 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
436 /**************************
437 * CALCULATE INTERACTIONS *
438 **************************/
440 if (gmx_mm_any_lt(rsq20,rcutoff2))
443 /* Compute parameters for interactions between i and j atoms */
444 qq20 = _mm_mul_pd(iq2,jq0);
446 /* REACTION-FIELD ELECTROSTATICS */
447 velec = _mm_mul_pd(qq20,_mm_sub_pd(_mm_macc_pd(krf,rsq20,rinv20),crf));
448 felec = _mm_mul_pd(qq20,_mm_msub_pd(rinv20,rinvsq20,krf2));
450 cutoff_mask = _mm_cmplt_pd(rsq20,rcutoff2);
452 /* Update potential sum for this i atom from the interaction with this j atom. */
453 velec = _mm_and_pd(velec,cutoff_mask);
454 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
455 velecsum = _mm_add_pd(velecsum,velec);
459 fscal = _mm_and_pd(fscal,cutoff_mask);
461 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
463 /* Update vectorial force */
464 fix2 = _mm_macc_pd(dx20,fscal,fix2);
465 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
466 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
468 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
469 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
470 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
474 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,fjx0,fjy0,fjz0);
476 /* Inner loop uses 120 flops */
479 /* End of innermost loop */
481 gmx_mm_update_iforce_3atom_swizzle_pd(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
482 f+i_coord_offset,fshift+i_shift_offset);
485 /* Update potential energies */
486 gmx_mm_update_1pot_pd(velecsum,kernel_data->energygrp_elec+ggid);
488 /* Increment number of inner iterations */
489 inneriter += j_index_end - j_index_start;
491 /* Outer loop uses 19 flops */
494 /* Increment number of outer iterations */
497 /* Update outer/inner flops */
499 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3_VF,outeriter*19 + inneriter*120);
502 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwNone_GeomW3P1_F_avx_128_fma_double
503 * Electrostatics interaction: ReactionField
504 * VdW interaction: None
505 * Geometry: Water3-Particle
506 * Calculate force/pot: Force
509 nb_kernel_ElecRFCut_VdwNone_GeomW3P1_F_avx_128_fma_double
510 (t_nblist * gmx_restrict nlist,
511 rvec * gmx_restrict xx,
512 rvec * gmx_restrict ff,
513 t_forcerec * gmx_restrict fr,
514 t_mdatoms * gmx_restrict mdatoms,
515 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
516 t_nrnb * gmx_restrict nrnb)
518 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
519 * just 0 for non-waters.
520 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
521 * jnr indices corresponding to data put in the four positions in the SIMD register.
523 int i_shift_offset,i_coord_offset,outeriter,inneriter;
524 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
526 int j_coord_offsetA,j_coord_offsetB;
527 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
529 real *shiftvec,*fshift,*x,*f;
530 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
532 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
534 __m128d ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
536 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
537 int vdwjidx0A,vdwjidx0B;
538 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
539 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
540 __m128d dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
541 __m128d dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
542 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
544 __m128d dummy_mask,cutoff_mask;
545 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
546 __m128d one = _mm_set1_pd(1.0);
547 __m128d two = _mm_set1_pd(2.0);
553 jindex = nlist->jindex;
555 shiftidx = nlist->shift;
557 shiftvec = fr->shift_vec[0];
558 fshift = fr->fshift[0];
559 facel = _mm_set1_pd(fr->epsfac);
560 charge = mdatoms->chargeA;
561 krf = _mm_set1_pd(fr->ic->k_rf);
562 krf2 = _mm_set1_pd(fr->ic->k_rf*2.0);
563 crf = _mm_set1_pd(fr->ic->c_rf);
565 /* Setup water-specific parameters */
566 inr = nlist->iinr[0];
567 iq0 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+0]));
568 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
569 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
571 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
572 rcutoff_scalar = fr->rcoulomb;
573 rcutoff = _mm_set1_pd(rcutoff_scalar);
574 rcutoff2 = _mm_mul_pd(rcutoff,rcutoff);
576 /* Avoid stupid compiler warnings */
584 /* Start outer loop over neighborlists */
585 for(iidx=0; iidx<nri; iidx++)
587 /* Load shift vector for this list */
588 i_shift_offset = DIM*shiftidx[iidx];
590 /* Load limits for loop over neighbors */
591 j_index_start = jindex[iidx];
592 j_index_end = jindex[iidx+1];
594 /* Get outer coordinate index */
596 i_coord_offset = DIM*inr;
598 /* Load i particle coords and add shift vector */
599 gmx_mm_load_shift_and_3rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,
600 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
602 fix0 = _mm_setzero_pd();
603 fiy0 = _mm_setzero_pd();
604 fiz0 = _mm_setzero_pd();
605 fix1 = _mm_setzero_pd();
606 fiy1 = _mm_setzero_pd();
607 fiz1 = _mm_setzero_pd();
608 fix2 = _mm_setzero_pd();
609 fiy2 = _mm_setzero_pd();
610 fiz2 = _mm_setzero_pd();
612 /* Start inner kernel loop */
613 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
616 /* Get j neighbor index, and coordinate index */
619 j_coord_offsetA = DIM*jnrA;
620 j_coord_offsetB = DIM*jnrB;
622 /* load j atom coordinates */
623 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
626 /* Calculate displacement vector */
627 dx00 = _mm_sub_pd(ix0,jx0);
628 dy00 = _mm_sub_pd(iy0,jy0);
629 dz00 = _mm_sub_pd(iz0,jz0);
630 dx10 = _mm_sub_pd(ix1,jx0);
631 dy10 = _mm_sub_pd(iy1,jy0);
632 dz10 = _mm_sub_pd(iz1,jz0);
633 dx20 = _mm_sub_pd(ix2,jx0);
634 dy20 = _mm_sub_pd(iy2,jy0);
635 dz20 = _mm_sub_pd(iz2,jz0);
637 /* Calculate squared distance and things based on it */
638 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
639 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
640 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
642 rinv00 = gmx_mm_invsqrt_pd(rsq00);
643 rinv10 = gmx_mm_invsqrt_pd(rsq10);
644 rinv20 = gmx_mm_invsqrt_pd(rsq20);
646 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
647 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
648 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
650 /* Load parameters for j particles */
651 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
653 fjx0 = _mm_setzero_pd();
654 fjy0 = _mm_setzero_pd();
655 fjz0 = _mm_setzero_pd();
657 /**************************
658 * CALCULATE INTERACTIONS *
659 **************************/
661 if (gmx_mm_any_lt(rsq00,rcutoff2))
664 /* Compute parameters for interactions between i and j atoms */
665 qq00 = _mm_mul_pd(iq0,jq0);
667 /* REACTION-FIELD ELECTROSTATICS */
668 felec = _mm_mul_pd(qq00,_mm_msub_pd(rinv00,rinvsq00,krf2));
670 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
674 fscal = _mm_and_pd(fscal,cutoff_mask);
676 /* Update vectorial force */
677 fix0 = _mm_macc_pd(dx00,fscal,fix0);
678 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
679 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
681 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
682 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
683 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
687 /**************************
688 * CALCULATE INTERACTIONS *
689 **************************/
691 if (gmx_mm_any_lt(rsq10,rcutoff2))
694 /* Compute parameters for interactions between i and j atoms */
695 qq10 = _mm_mul_pd(iq1,jq0);
697 /* REACTION-FIELD ELECTROSTATICS */
698 felec = _mm_mul_pd(qq10,_mm_msub_pd(rinv10,rinvsq10,krf2));
700 cutoff_mask = _mm_cmplt_pd(rsq10,rcutoff2);
704 fscal = _mm_and_pd(fscal,cutoff_mask);
706 /* Update vectorial force */
707 fix1 = _mm_macc_pd(dx10,fscal,fix1);
708 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
709 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
711 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
712 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
713 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
717 /**************************
718 * CALCULATE INTERACTIONS *
719 **************************/
721 if (gmx_mm_any_lt(rsq20,rcutoff2))
724 /* Compute parameters for interactions between i and j atoms */
725 qq20 = _mm_mul_pd(iq2,jq0);
727 /* REACTION-FIELD ELECTROSTATICS */
728 felec = _mm_mul_pd(qq20,_mm_msub_pd(rinv20,rinvsq20,krf2));
730 cutoff_mask = _mm_cmplt_pd(rsq20,rcutoff2);
734 fscal = _mm_and_pd(fscal,cutoff_mask);
736 /* Update vectorial force */
737 fix2 = _mm_macc_pd(dx20,fscal,fix2);
738 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
739 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
741 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
742 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
743 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
747 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
749 /* Inner loop uses 102 flops */
756 j_coord_offsetA = DIM*jnrA;
758 /* load j atom coordinates */
759 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
762 /* Calculate displacement vector */
763 dx00 = _mm_sub_pd(ix0,jx0);
764 dy00 = _mm_sub_pd(iy0,jy0);
765 dz00 = _mm_sub_pd(iz0,jz0);
766 dx10 = _mm_sub_pd(ix1,jx0);
767 dy10 = _mm_sub_pd(iy1,jy0);
768 dz10 = _mm_sub_pd(iz1,jz0);
769 dx20 = _mm_sub_pd(ix2,jx0);
770 dy20 = _mm_sub_pd(iy2,jy0);
771 dz20 = _mm_sub_pd(iz2,jz0);
773 /* Calculate squared distance and things based on it */
774 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
775 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
776 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
778 rinv00 = gmx_mm_invsqrt_pd(rsq00);
779 rinv10 = gmx_mm_invsqrt_pd(rsq10);
780 rinv20 = gmx_mm_invsqrt_pd(rsq20);
782 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
783 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
784 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
786 /* Load parameters for j particles */
787 jq0 = _mm_load_sd(charge+jnrA+0);
789 fjx0 = _mm_setzero_pd();
790 fjy0 = _mm_setzero_pd();
791 fjz0 = _mm_setzero_pd();
793 /**************************
794 * CALCULATE INTERACTIONS *
795 **************************/
797 if (gmx_mm_any_lt(rsq00,rcutoff2))
800 /* Compute parameters for interactions between i and j atoms */
801 qq00 = _mm_mul_pd(iq0,jq0);
803 /* REACTION-FIELD ELECTROSTATICS */
804 felec = _mm_mul_pd(qq00,_mm_msub_pd(rinv00,rinvsq00,krf2));
806 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
810 fscal = _mm_and_pd(fscal,cutoff_mask);
812 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
814 /* Update vectorial force */
815 fix0 = _mm_macc_pd(dx00,fscal,fix0);
816 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
817 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
819 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
820 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
821 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
825 /**************************
826 * CALCULATE INTERACTIONS *
827 **************************/
829 if (gmx_mm_any_lt(rsq10,rcutoff2))
832 /* Compute parameters for interactions between i and j atoms */
833 qq10 = _mm_mul_pd(iq1,jq0);
835 /* REACTION-FIELD ELECTROSTATICS */
836 felec = _mm_mul_pd(qq10,_mm_msub_pd(rinv10,rinvsq10,krf2));
838 cutoff_mask = _mm_cmplt_pd(rsq10,rcutoff2);
842 fscal = _mm_and_pd(fscal,cutoff_mask);
844 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
846 /* Update vectorial force */
847 fix1 = _mm_macc_pd(dx10,fscal,fix1);
848 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
849 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
851 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
852 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
853 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
857 /**************************
858 * CALCULATE INTERACTIONS *
859 **************************/
861 if (gmx_mm_any_lt(rsq20,rcutoff2))
864 /* Compute parameters for interactions between i and j atoms */
865 qq20 = _mm_mul_pd(iq2,jq0);
867 /* REACTION-FIELD ELECTROSTATICS */
868 felec = _mm_mul_pd(qq20,_mm_msub_pd(rinv20,rinvsq20,krf2));
870 cutoff_mask = _mm_cmplt_pd(rsq20,rcutoff2);
874 fscal = _mm_and_pd(fscal,cutoff_mask);
876 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
878 /* Update vectorial force */
879 fix2 = _mm_macc_pd(dx20,fscal,fix2);
880 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
881 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
883 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
884 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
885 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
889 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,fjx0,fjy0,fjz0);
891 /* Inner loop uses 102 flops */
894 /* End of innermost loop */
896 gmx_mm_update_iforce_3atom_swizzle_pd(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
897 f+i_coord_offset,fshift+i_shift_offset);
899 /* Increment number of inner iterations */
900 inneriter += j_index_end - j_index_start;
902 /* Outer loop uses 18 flops */
905 /* Increment number of outer iterations */
908 /* Update outer/inner flops */
910 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3_F,outeriter*18 + inneriter*102);