2 * Note: this file was generated by the Gromacs avx_128_fma_double kernel generator.
4 * This source code is part of
8 * Copyright (c) 2001-2012, The GROMACS Development Team
10 * Gromacs is a library for molecular simulation and trajectory analysis,
11 * written by Erik Lindahl, David van der Spoel, Berk Hess, and others - for
12 * a full list of developers and information, check out http://www.gromacs.org
14 * This program is free software; you can redistribute it and/or modify it under
15 * the terms of the GNU Lesser General Public License as published by the Free
16 * Software Foundation; either version 2 of the License, or (at your option) any
19 * To help fund GROMACS development, we humbly ask that you cite
20 * the papers people have written on it - you can find them on the website.
28 #include "../nb_kernel.h"
29 #include "types/simple.h"
33 #include "gmx_math_x86_avx_128_fma_double.h"
34 #include "kernelutil_x86_avx_128_fma_double.h"
37 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwNone_GeomW3W3_VF_avx_128_fma_double
38 * Electrostatics interaction: ReactionField
39 * VdW interaction: None
40 * Geometry: Water3-Water3
41 * Calculate force/pot: PotentialAndForce
44 nb_kernel_ElecRF_VdwNone_GeomW3W3_VF_avx_128_fma_double
45 (t_nblist * gmx_restrict nlist,
46 rvec * gmx_restrict xx,
47 rvec * gmx_restrict ff,
48 t_forcerec * gmx_restrict fr,
49 t_mdatoms * gmx_restrict mdatoms,
50 nb_kernel_data_t * gmx_restrict kernel_data,
51 t_nrnb * gmx_restrict nrnb)
53 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
54 * just 0 for non-waters.
55 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
56 * jnr indices corresponding to data put in the four positions in the SIMD register.
58 int i_shift_offset,i_coord_offset,outeriter,inneriter;
59 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
61 int j_coord_offsetA,j_coord_offsetB;
62 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
64 real *shiftvec,*fshift,*x,*f;
65 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
67 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
69 __m128d ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
71 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
72 int vdwjidx0A,vdwjidx0B;
73 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
74 int vdwjidx1A,vdwjidx1B;
75 __m128d jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
76 int vdwjidx2A,vdwjidx2B;
77 __m128d jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
78 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
79 __m128d dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01;
80 __m128d dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02;
81 __m128d dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
82 __m128d dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
83 __m128d dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
84 __m128d dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
85 __m128d dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
86 __m128d dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
87 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
89 __m128d dummy_mask,cutoff_mask;
90 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
91 __m128d one = _mm_set1_pd(1.0);
92 __m128d two = _mm_set1_pd(2.0);
98 jindex = nlist->jindex;
100 shiftidx = nlist->shift;
102 shiftvec = fr->shift_vec[0];
103 fshift = fr->fshift[0];
104 facel = _mm_set1_pd(fr->epsfac);
105 charge = mdatoms->chargeA;
106 krf = _mm_set1_pd(fr->ic->k_rf);
107 krf2 = _mm_set1_pd(fr->ic->k_rf*2.0);
108 crf = _mm_set1_pd(fr->ic->c_rf);
110 /* Setup water-specific parameters */
111 inr = nlist->iinr[0];
112 iq0 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+0]));
113 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
114 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
116 jq0 = _mm_set1_pd(charge[inr+0]);
117 jq1 = _mm_set1_pd(charge[inr+1]);
118 jq2 = _mm_set1_pd(charge[inr+2]);
119 qq00 = _mm_mul_pd(iq0,jq0);
120 qq01 = _mm_mul_pd(iq0,jq1);
121 qq02 = _mm_mul_pd(iq0,jq2);
122 qq10 = _mm_mul_pd(iq1,jq0);
123 qq11 = _mm_mul_pd(iq1,jq1);
124 qq12 = _mm_mul_pd(iq1,jq2);
125 qq20 = _mm_mul_pd(iq2,jq0);
126 qq21 = _mm_mul_pd(iq2,jq1);
127 qq22 = _mm_mul_pd(iq2,jq2);
129 /* Avoid stupid compiler warnings */
137 /* Start outer loop over neighborlists */
138 for(iidx=0; iidx<nri; iidx++)
140 /* Load shift vector for this list */
141 i_shift_offset = DIM*shiftidx[iidx];
143 /* Load limits for loop over neighbors */
144 j_index_start = jindex[iidx];
145 j_index_end = jindex[iidx+1];
147 /* Get outer coordinate index */
149 i_coord_offset = DIM*inr;
151 /* Load i particle coords and add shift vector */
152 gmx_mm_load_shift_and_3rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,
153 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
155 fix0 = _mm_setzero_pd();
156 fiy0 = _mm_setzero_pd();
157 fiz0 = _mm_setzero_pd();
158 fix1 = _mm_setzero_pd();
159 fiy1 = _mm_setzero_pd();
160 fiz1 = _mm_setzero_pd();
161 fix2 = _mm_setzero_pd();
162 fiy2 = _mm_setzero_pd();
163 fiz2 = _mm_setzero_pd();
165 /* Reset potential sums */
166 velecsum = _mm_setzero_pd();
168 /* Start inner kernel loop */
169 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
172 /* Get j neighbor index, and coordinate index */
175 j_coord_offsetA = DIM*jnrA;
176 j_coord_offsetB = DIM*jnrB;
178 /* load j atom coordinates */
179 gmx_mm_load_3rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
180 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
182 /* Calculate displacement vector */
183 dx00 = _mm_sub_pd(ix0,jx0);
184 dy00 = _mm_sub_pd(iy0,jy0);
185 dz00 = _mm_sub_pd(iz0,jz0);
186 dx01 = _mm_sub_pd(ix0,jx1);
187 dy01 = _mm_sub_pd(iy0,jy1);
188 dz01 = _mm_sub_pd(iz0,jz1);
189 dx02 = _mm_sub_pd(ix0,jx2);
190 dy02 = _mm_sub_pd(iy0,jy2);
191 dz02 = _mm_sub_pd(iz0,jz2);
192 dx10 = _mm_sub_pd(ix1,jx0);
193 dy10 = _mm_sub_pd(iy1,jy0);
194 dz10 = _mm_sub_pd(iz1,jz0);
195 dx11 = _mm_sub_pd(ix1,jx1);
196 dy11 = _mm_sub_pd(iy1,jy1);
197 dz11 = _mm_sub_pd(iz1,jz1);
198 dx12 = _mm_sub_pd(ix1,jx2);
199 dy12 = _mm_sub_pd(iy1,jy2);
200 dz12 = _mm_sub_pd(iz1,jz2);
201 dx20 = _mm_sub_pd(ix2,jx0);
202 dy20 = _mm_sub_pd(iy2,jy0);
203 dz20 = _mm_sub_pd(iz2,jz0);
204 dx21 = _mm_sub_pd(ix2,jx1);
205 dy21 = _mm_sub_pd(iy2,jy1);
206 dz21 = _mm_sub_pd(iz2,jz1);
207 dx22 = _mm_sub_pd(ix2,jx2);
208 dy22 = _mm_sub_pd(iy2,jy2);
209 dz22 = _mm_sub_pd(iz2,jz2);
211 /* Calculate squared distance and things based on it */
212 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
213 rsq01 = gmx_mm_calc_rsq_pd(dx01,dy01,dz01);
214 rsq02 = gmx_mm_calc_rsq_pd(dx02,dy02,dz02);
215 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
216 rsq11 = gmx_mm_calc_rsq_pd(dx11,dy11,dz11);
217 rsq12 = gmx_mm_calc_rsq_pd(dx12,dy12,dz12);
218 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
219 rsq21 = gmx_mm_calc_rsq_pd(dx21,dy21,dz21);
220 rsq22 = gmx_mm_calc_rsq_pd(dx22,dy22,dz22);
222 rinv00 = gmx_mm_invsqrt_pd(rsq00);
223 rinv01 = gmx_mm_invsqrt_pd(rsq01);
224 rinv02 = gmx_mm_invsqrt_pd(rsq02);
225 rinv10 = gmx_mm_invsqrt_pd(rsq10);
226 rinv11 = gmx_mm_invsqrt_pd(rsq11);
227 rinv12 = gmx_mm_invsqrt_pd(rsq12);
228 rinv20 = gmx_mm_invsqrt_pd(rsq20);
229 rinv21 = gmx_mm_invsqrt_pd(rsq21);
230 rinv22 = gmx_mm_invsqrt_pd(rsq22);
232 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
233 rinvsq01 = _mm_mul_pd(rinv01,rinv01);
234 rinvsq02 = _mm_mul_pd(rinv02,rinv02);
235 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
236 rinvsq11 = _mm_mul_pd(rinv11,rinv11);
237 rinvsq12 = _mm_mul_pd(rinv12,rinv12);
238 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
239 rinvsq21 = _mm_mul_pd(rinv21,rinv21);
240 rinvsq22 = _mm_mul_pd(rinv22,rinv22);
242 fjx0 = _mm_setzero_pd();
243 fjy0 = _mm_setzero_pd();
244 fjz0 = _mm_setzero_pd();
245 fjx1 = _mm_setzero_pd();
246 fjy1 = _mm_setzero_pd();
247 fjz1 = _mm_setzero_pd();
248 fjx2 = _mm_setzero_pd();
249 fjy2 = _mm_setzero_pd();
250 fjz2 = _mm_setzero_pd();
252 /**************************
253 * CALCULATE INTERACTIONS *
254 **************************/
256 /* REACTION-FIELD ELECTROSTATICS */
257 velec = _mm_mul_pd(qq00,_mm_sub_pd(_mm_macc_pd(krf,rsq00,rinv00),crf));
258 felec = _mm_mul_pd(qq00,_mm_msub_pd(rinv00,rinvsq00,krf2));
260 /* Update potential sum for this i atom from the interaction with this j atom. */
261 velecsum = _mm_add_pd(velecsum,velec);
265 /* Update vectorial force */
266 fix0 = _mm_macc_pd(dx00,fscal,fix0);
267 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
268 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
270 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
271 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
272 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
274 /**************************
275 * CALCULATE INTERACTIONS *
276 **************************/
278 /* REACTION-FIELD ELECTROSTATICS */
279 velec = _mm_mul_pd(qq01,_mm_sub_pd(_mm_macc_pd(krf,rsq01,rinv01),crf));
280 felec = _mm_mul_pd(qq01,_mm_msub_pd(rinv01,rinvsq01,krf2));
282 /* Update potential sum for this i atom from the interaction with this j atom. */
283 velecsum = _mm_add_pd(velecsum,velec);
287 /* Update vectorial force */
288 fix0 = _mm_macc_pd(dx01,fscal,fix0);
289 fiy0 = _mm_macc_pd(dy01,fscal,fiy0);
290 fiz0 = _mm_macc_pd(dz01,fscal,fiz0);
292 fjx1 = _mm_macc_pd(dx01,fscal,fjx1);
293 fjy1 = _mm_macc_pd(dy01,fscal,fjy1);
294 fjz1 = _mm_macc_pd(dz01,fscal,fjz1);
296 /**************************
297 * CALCULATE INTERACTIONS *
298 **************************/
300 /* REACTION-FIELD ELECTROSTATICS */
301 velec = _mm_mul_pd(qq02,_mm_sub_pd(_mm_macc_pd(krf,rsq02,rinv02),crf));
302 felec = _mm_mul_pd(qq02,_mm_msub_pd(rinv02,rinvsq02,krf2));
304 /* Update potential sum for this i atom from the interaction with this j atom. */
305 velecsum = _mm_add_pd(velecsum,velec);
309 /* Update vectorial force */
310 fix0 = _mm_macc_pd(dx02,fscal,fix0);
311 fiy0 = _mm_macc_pd(dy02,fscal,fiy0);
312 fiz0 = _mm_macc_pd(dz02,fscal,fiz0);
314 fjx2 = _mm_macc_pd(dx02,fscal,fjx2);
315 fjy2 = _mm_macc_pd(dy02,fscal,fjy2);
316 fjz2 = _mm_macc_pd(dz02,fscal,fjz2);
318 /**************************
319 * CALCULATE INTERACTIONS *
320 **************************/
322 /* REACTION-FIELD ELECTROSTATICS */
323 velec = _mm_mul_pd(qq10,_mm_sub_pd(_mm_macc_pd(krf,rsq10,rinv10),crf));
324 felec = _mm_mul_pd(qq10,_mm_msub_pd(rinv10,rinvsq10,krf2));
326 /* Update potential sum for this i atom from the interaction with this j atom. */
327 velecsum = _mm_add_pd(velecsum,velec);
331 /* Update vectorial force */
332 fix1 = _mm_macc_pd(dx10,fscal,fix1);
333 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
334 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
336 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
337 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
338 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
340 /**************************
341 * CALCULATE INTERACTIONS *
342 **************************/
344 /* REACTION-FIELD ELECTROSTATICS */
345 velec = _mm_mul_pd(qq11,_mm_sub_pd(_mm_macc_pd(krf,rsq11,rinv11),crf));
346 felec = _mm_mul_pd(qq11,_mm_msub_pd(rinv11,rinvsq11,krf2));
348 /* Update potential sum for this i atom from the interaction with this j atom. */
349 velecsum = _mm_add_pd(velecsum,velec);
353 /* Update vectorial force */
354 fix1 = _mm_macc_pd(dx11,fscal,fix1);
355 fiy1 = _mm_macc_pd(dy11,fscal,fiy1);
356 fiz1 = _mm_macc_pd(dz11,fscal,fiz1);
358 fjx1 = _mm_macc_pd(dx11,fscal,fjx1);
359 fjy1 = _mm_macc_pd(dy11,fscal,fjy1);
360 fjz1 = _mm_macc_pd(dz11,fscal,fjz1);
362 /**************************
363 * CALCULATE INTERACTIONS *
364 **************************/
366 /* REACTION-FIELD ELECTROSTATICS */
367 velec = _mm_mul_pd(qq12,_mm_sub_pd(_mm_macc_pd(krf,rsq12,rinv12),crf));
368 felec = _mm_mul_pd(qq12,_mm_msub_pd(rinv12,rinvsq12,krf2));
370 /* Update potential sum for this i atom from the interaction with this j atom. */
371 velecsum = _mm_add_pd(velecsum,velec);
375 /* Update vectorial force */
376 fix1 = _mm_macc_pd(dx12,fscal,fix1);
377 fiy1 = _mm_macc_pd(dy12,fscal,fiy1);
378 fiz1 = _mm_macc_pd(dz12,fscal,fiz1);
380 fjx2 = _mm_macc_pd(dx12,fscal,fjx2);
381 fjy2 = _mm_macc_pd(dy12,fscal,fjy2);
382 fjz2 = _mm_macc_pd(dz12,fscal,fjz2);
384 /**************************
385 * CALCULATE INTERACTIONS *
386 **************************/
388 /* REACTION-FIELD ELECTROSTATICS */
389 velec = _mm_mul_pd(qq20,_mm_sub_pd(_mm_macc_pd(krf,rsq20,rinv20),crf));
390 felec = _mm_mul_pd(qq20,_mm_msub_pd(rinv20,rinvsq20,krf2));
392 /* Update potential sum for this i atom from the interaction with this j atom. */
393 velecsum = _mm_add_pd(velecsum,velec);
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 /**************************
407 * CALCULATE INTERACTIONS *
408 **************************/
410 /* REACTION-FIELD ELECTROSTATICS */
411 velec = _mm_mul_pd(qq21,_mm_sub_pd(_mm_macc_pd(krf,rsq21,rinv21),crf));
412 felec = _mm_mul_pd(qq21,_mm_msub_pd(rinv21,rinvsq21,krf2));
414 /* Update potential sum for this i atom from the interaction with this j atom. */
415 velecsum = _mm_add_pd(velecsum,velec);
419 /* Update vectorial force */
420 fix2 = _mm_macc_pd(dx21,fscal,fix2);
421 fiy2 = _mm_macc_pd(dy21,fscal,fiy2);
422 fiz2 = _mm_macc_pd(dz21,fscal,fiz2);
424 fjx1 = _mm_macc_pd(dx21,fscal,fjx1);
425 fjy1 = _mm_macc_pd(dy21,fscal,fjy1);
426 fjz1 = _mm_macc_pd(dz21,fscal,fjz1);
428 /**************************
429 * CALCULATE INTERACTIONS *
430 **************************/
432 /* REACTION-FIELD ELECTROSTATICS */
433 velec = _mm_mul_pd(qq22,_mm_sub_pd(_mm_macc_pd(krf,rsq22,rinv22),crf));
434 felec = _mm_mul_pd(qq22,_mm_msub_pd(rinv22,rinvsq22,krf2));
436 /* Update potential sum for this i atom from the interaction with this j atom. */
437 velecsum = _mm_add_pd(velecsum,velec);
441 /* Update vectorial force */
442 fix2 = _mm_macc_pd(dx22,fscal,fix2);
443 fiy2 = _mm_macc_pd(dy22,fscal,fiy2);
444 fiz2 = _mm_macc_pd(dz22,fscal,fiz2);
446 fjx2 = _mm_macc_pd(dx22,fscal,fjx2);
447 fjy2 = _mm_macc_pd(dy22,fscal,fjy2);
448 fjz2 = _mm_macc_pd(dz22,fscal,fjz2);
450 gmx_mm_decrement_3rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
452 /* Inner loop uses 315 flops */
459 j_coord_offsetA = DIM*jnrA;
461 /* load j atom coordinates */
462 gmx_mm_load_3rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
463 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
465 /* Calculate displacement vector */
466 dx00 = _mm_sub_pd(ix0,jx0);
467 dy00 = _mm_sub_pd(iy0,jy0);
468 dz00 = _mm_sub_pd(iz0,jz0);
469 dx01 = _mm_sub_pd(ix0,jx1);
470 dy01 = _mm_sub_pd(iy0,jy1);
471 dz01 = _mm_sub_pd(iz0,jz1);
472 dx02 = _mm_sub_pd(ix0,jx2);
473 dy02 = _mm_sub_pd(iy0,jy2);
474 dz02 = _mm_sub_pd(iz0,jz2);
475 dx10 = _mm_sub_pd(ix1,jx0);
476 dy10 = _mm_sub_pd(iy1,jy0);
477 dz10 = _mm_sub_pd(iz1,jz0);
478 dx11 = _mm_sub_pd(ix1,jx1);
479 dy11 = _mm_sub_pd(iy1,jy1);
480 dz11 = _mm_sub_pd(iz1,jz1);
481 dx12 = _mm_sub_pd(ix1,jx2);
482 dy12 = _mm_sub_pd(iy1,jy2);
483 dz12 = _mm_sub_pd(iz1,jz2);
484 dx20 = _mm_sub_pd(ix2,jx0);
485 dy20 = _mm_sub_pd(iy2,jy0);
486 dz20 = _mm_sub_pd(iz2,jz0);
487 dx21 = _mm_sub_pd(ix2,jx1);
488 dy21 = _mm_sub_pd(iy2,jy1);
489 dz21 = _mm_sub_pd(iz2,jz1);
490 dx22 = _mm_sub_pd(ix2,jx2);
491 dy22 = _mm_sub_pd(iy2,jy2);
492 dz22 = _mm_sub_pd(iz2,jz2);
494 /* Calculate squared distance and things based on it */
495 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
496 rsq01 = gmx_mm_calc_rsq_pd(dx01,dy01,dz01);
497 rsq02 = gmx_mm_calc_rsq_pd(dx02,dy02,dz02);
498 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
499 rsq11 = gmx_mm_calc_rsq_pd(dx11,dy11,dz11);
500 rsq12 = gmx_mm_calc_rsq_pd(dx12,dy12,dz12);
501 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
502 rsq21 = gmx_mm_calc_rsq_pd(dx21,dy21,dz21);
503 rsq22 = gmx_mm_calc_rsq_pd(dx22,dy22,dz22);
505 rinv00 = gmx_mm_invsqrt_pd(rsq00);
506 rinv01 = gmx_mm_invsqrt_pd(rsq01);
507 rinv02 = gmx_mm_invsqrt_pd(rsq02);
508 rinv10 = gmx_mm_invsqrt_pd(rsq10);
509 rinv11 = gmx_mm_invsqrt_pd(rsq11);
510 rinv12 = gmx_mm_invsqrt_pd(rsq12);
511 rinv20 = gmx_mm_invsqrt_pd(rsq20);
512 rinv21 = gmx_mm_invsqrt_pd(rsq21);
513 rinv22 = gmx_mm_invsqrt_pd(rsq22);
515 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
516 rinvsq01 = _mm_mul_pd(rinv01,rinv01);
517 rinvsq02 = _mm_mul_pd(rinv02,rinv02);
518 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
519 rinvsq11 = _mm_mul_pd(rinv11,rinv11);
520 rinvsq12 = _mm_mul_pd(rinv12,rinv12);
521 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
522 rinvsq21 = _mm_mul_pd(rinv21,rinv21);
523 rinvsq22 = _mm_mul_pd(rinv22,rinv22);
525 fjx0 = _mm_setzero_pd();
526 fjy0 = _mm_setzero_pd();
527 fjz0 = _mm_setzero_pd();
528 fjx1 = _mm_setzero_pd();
529 fjy1 = _mm_setzero_pd();
530 fjz1 = _mm_setzero_pd();
531 fjx2 = _mm_setzero_pd();
532 fjy2 = _mm_setzero_pd();
533 fjz2 = _mm_setzero_pd();
535 /**************************
536 * CALCULATE INTERACTIONS *
537 **************************/
539 /* REACTION-FIELD ELECTROSTATICS */
540 velec = _mm_mul_pd(qq00,_mm_sub_pd(_mm_macc_pd(krf,rsq00,rinv00),crf));
541 felec = _mm_mul_pd(qq00,_mm_msub_pd(rinv00,rinvsq00,krf2));
543 /* Update potential sum for this i atom from the interaction with this j atom. */
544 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
545 velecsum = _mm_add_pd(velecsum,velec);
549 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
551 /* Update vectorial force */
552 fix0 = _mm_macc_pd(dx00,fscal,fix0);
553 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
554 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
556 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
557 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
558 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
560 /**************************
561 * CALCULATE INTERACTIONS *
562 **************************/
564 /* REACTION-FIELD ELECTROSTATICS */
565 velec = _mm_mul_pd(qq01,_mm_sub_pd(_mm_macc_pd(krf,rsq01,rinv01),crf));
566 felec = _mm_mul_pd(qq01,_mm_msub_pd(rinv01,rinvsq01,krf2));
568 /* Update potential sum for this i atom from the interaction with this j atom. */
569 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
570 velecsum = _mm_add_pd(velecsum,velec);
574 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
576 /* Update vectorial force */
577 fix0 = _mm_macc_pd(dx01,fscal,fix0);
578 fiy0 = _mm_macc_pd(dy01,fscal,fiy0);
579 fiz0 = _mm_macc_pd(dz01,fscal,fiz0);
581 fjx1 = _mm_macc_pd(dx01,fscal,fjx1);
582 fjy1 = _mm_macc_pd(dy01,fscal,fjy1);
583 fjz1 = _mm_macc_pd(dz01,fscal,fjz1);
585 /**************************
586 * CALCULATE INTERACTIONS *
587 **************************/
589 /* REACTION-FIELD ELECTROSTATICS */
590 velec = _mm_mul_pd(qq02,_mm_sub_pd(_mm_macc_pd(krf,rsq02,rinv02),crf));
591 felec = _mm_mul_pd(qq02,_mm_msub_pd(rinv02,rinvsq02,krf2));
593 /* Update potential sum for this i atom from the interaction with this j atom. */
594 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
595 velecsum = _mm_add_pd(velecsum,velec);
599 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
601 /* Update vectorial force */
602 fix0 = _mm_macc_pd(dx02,fscal,fix0);
603 fiy0 = _mm_macc_pd(dy02,fscal,fiy0);
604 fiz0 = _mm_macc_pd(dz02,fscal,fiz0);
606 fjx2 = _mm_macc_pd(dx02,fscal,fjx2);
607 fjy2 = _mm_macc_pd(dy02,fscal,fjy2);
608 fjz2 = _mm_macc_pd(dz02,fscal,fjz2);
610 /**************************
611 * CALCULATE INTERACTIONS *
612 **************************/
614 /* REACTION-FIELD ELECTROSTATICS */
615 velec = _mm_mul_pd(qq10,_mm_sub_pd(_mm_macc_pd(krf,rsq10,rinv10),crf));
616 felec = _mm_mul_pd(qq10,_mm_msub_pd(rinv10,rinvsq10,krf2));
618 /* Update potential sum for this i atom from the interaction with this j atom. */
619 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
620 velecsum = _mm_add_pd(velecsum,velec);
624 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
626 /* Update vectorial force */
627 fix1 = _mm_macc_pd(dx10,fscal,fix1);
628 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
629 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
631 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
632 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
633 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
635 /**************************
636 * CALCULATE INTERACTIONS *
637 **************************/
639 /* REACTION-FIELD ELECTROSTATICS */
640 velec = _mm_mul_pd(qq11,_mm_sub_pd(_mm_macc_pd(krf,rsq11,rinv11),crf));
641 felec = _mm_mul_pd(qq11,_mm_msub_pd(rinv11,rinvsq11,krf2));
643 /* Update potential sum for this i atom from the interaction with this j atom. */
644 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
645 velecsum = _mm_add_pd(velecsum,velec);
649 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
651 /* Update vectorial force */
652 fix1 = _mm_macc_pd(dx11,fscal,fix1);
653 fiy1 = _mm_macc_pd(dy11,fscal,fiy1);
654 fiz1 = _mm_macc_pd(dz11,fscal,fiz1);
656 fjx1 = _mm_macc_pd(dx11,fscal,fjx1);
657 fjy1 = _mm_macc_pd(dy11,fscal,fjy1);
658 fjz1 = _mm_macc_pd(dz11,fscal,fjz1);
660 /**************************
661 * CALCULATE INTERACTIONS *
662 **************************/
664 /* REACTION-FIELD ELECTROSTATICS */
665 velec = _mm_mul_pd(qq12,_mm_sub_pd(_mm_macc_pd(krf,rsq12,rinv12),crf));
666 felec = _mm_mul_pd(qq12,_mm_msub_pd(rinv12,rinvsq12,krf2));
668 /* Update potential sum for this i atom from the interaction with this j atom. */
669 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
670 velecsum = _mm_add_pd(velecsum,velec);
674 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
676 /* Update vectorial force */
677 fix1 = _mm_macc_pd(dx12,fscal,fix1);
678 fiy1 = _mm_macc_pd(dy12,fscal,fiy1);
679 fiz1 = _mm_macc_pd(dz12,fscal,fiz1);
681 fjx2 = _mm_macc_pd(dx12,fscal,fjx2);
682 fjy2 = _mm_macc_pd(dy12,fscal,fjy2);
683 fjz2 = _mm_macc_pd(dz12,fscal,fjz2);
685 /**************************
686 * CALCULATE INTERACTIONS *
687 **************************/
689 /* REACTION-FIELD ELECTROSTATICS */
690 velec = _mm_mul_pd(qq20,_mm_sub_pd(_mm_macc_pd(krf,rsq20,rinv20),crf));
691 felec = _mm_mul_pd(qq20,_mm_msub_pd(rinv20,rinvsq20,krf2));
693 /* Update potential sum for this i atom from the interaction with this j atom. */
694 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
695 velecsum = _mm_add_pd(velecsum,velec);
699 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
701 /* Update vectorial force */
702 fix2 = _mm_macc_pd(dx20,fscal,fix2);
703 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
704 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
706 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
707 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
708 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
710 /**************************
711 * CALCULATE INTERACTIONS *
712 **************************/
714 /* REACTION-FIELD ELECTROSTATICS */
715 velec = _mm_mul_pd(qq21,_mm_sub_pd(_mm_macc_pd(krf,rsq21,rinv21),crf));
716 felec = _mm_mul_pd(qq21,_mm_msub_pd(rinv21,rinvsq21,krf2));
718 /* Update potential sum for this i atom from the interaction with this j atom. */
719 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
720 velecsum = _mm_add_pd(velecsum,velec);
724 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
726 /* Update vectorial force */
727 fix2 = _mm_macc_pd(dx21,fscal,fix2);
728 fiy2 = _mm_macc_pd(dy21,fscal,fiy2);
729 fiz2 = _mm_macc_pd(dz21,fscal,fiz2);
731 fjx1 = _mm_macc_pd(dx21,fscal,fjx1);
732 fjy1 = _mm_macc_pd(dy21,fscal,fjy1);
733 fjz1 = _mm_macc_pd(dz21,fscal,fjz1);
735 /**************************
736 * CALCULATE INTERACTIONS *
737 **************************/
739 /* REACTION-FIELD ELECTROSTATICS */
740 velec = _mm_mul_pd(qq22,_mm_sub_pd(_mm_macc_pd(krf,rsq22,rinv22),crf));
741 felec = _mm_mul_pd(qq22,_mm_msub_pd(rinv22,rinvsq22,krf2));
743 /* Update potential sum for this i atom from the interaction with this j atom. */
744 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
745 velecsum = _mm_add_pd(velecsum,velec);
749 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
751 /* Update vectorial force */
752 fix2 = _mm_macc_pd(dx22,fscal,fix2);
753 fiy2 = _mm_macc_pd(dy22,fscal,fiy2);
754 fiz2 = _mm_macc_pd(dz22,fscal,fiz2);
756 fjx2 = _mm_macc_pd(dx22,fscal,fjx2);
757 fjy2 = _mm_macc_pd(dy22,fscal,fjy2);
758 fjz2 = _mm_macc_pd(dz22,fscal,fjz2);
760 gmx_mm_decrement_3rvec_1ptr_swizzle_pd(f+j_coord_offsetA,fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
762 /* Inner loop uses 315 flops */
765 /* End of innermost loop */
767 gmx_mm_update_iforce_3atom_swizzle_pd(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
768 f+i_coord_offset,fshift+i_shift_offset);
771 /* Update potential energies */
772 gmx_mm_update_1pot_pd(velecsum,kernel_data->energygrp_elec+ggid);
774 /* Increment number of inner iterations */
775 inneriter += j_index_end - j_index_start;
777 /* Outer loop uses 19 flops */
780 /* Increment number of outer iterations */
783 /* Update outer/inner flops */
785 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3W3_VF,outeriter*19 + inneriter*315);
788 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwNone_GeomW3W3_F_avx_128_fma_double
789 * Electrostatics interaction: ReactionField
790 * VdW interaction: None
791 * Geometry: Water3-Water3
792 * Calculate force/pot: Force
795 nb_kernel_ElecRF_VdwNone_GeomW3W3_F_avx_128_fma_double
796 (t_nblist * gmx_restrict nlist,
797 rvec * gmx_restrict xx,
798 rvec * gmx_restrict ff,
799 t_forcerec * gmx_restrict fr,
800 t_mdatoms * gmx_restrict mdatoms,
801 nb_kernel_data_t * gmx_restrict kernel_data,
802 t_nrnb * gmx_restrict nrnb)
804 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
805 * just 0 for non-waters.
806 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
807 * jnr indices corresponding to data put in the four positions in the SIMD register.
809 int i_shift_offset,i_coord_offset,outeriter,inneriter;
810 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
812 int j_coord_offsetA,j_coord_offsetB;
813 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
815 real *shiftvec,*fshift,*x,*f;
816 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
818 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
820 __m128d ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
822 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
823 int vdwjidx0A,vdwjidx0B;
824 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
825 int vdwjidx1A,vdwjidx1B;
826 __m128d jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
827 int vdwjidx2A,vdwjidx2B;
828 __m128d jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
829 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
830 __m128d dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01;
831 __m128d dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02;
832 __m128d dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
833 __m128d dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
834 __m128d dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
835 __m128d dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
836 __m128d dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
837 __m128d dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
838 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
840 __m128d dummy_mask,cutoff_mask;
841 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
842 __m128d one = _mm_set1_pd(1.0);
843 __m128d two = _mm_set1_pd(2.0);
849 jindex = nlist->jindex;
851 shiftidx = nlist->shift;
853 shiftvec = fr->shift_vec[0];
854 fshift = fr->fshift[0];
855 facel = _mm_set1_pd(fr->epsfac);
856 charge = mdatoms->chargeA;
857 krf = _mm_set1_pd(fr->ic->k_rf);
858 krf2 = _mm_set1_pd(fr->ic->k_rf*2.0);
859 crf = _mm_set1_pd(fr->ic->c_rf);
861 /* Setup water-specific parameters */
862 inr = nlist->iinr[0];
863 iq0 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+0]));
864 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
865 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
867 jq0 = _mm_set1_pd(charge[inr+0]);
868 jq1 = _mm_set1_pd(charge[inr+1]);
869 jq2 = _mm_set1_pd(charge[inr+2]);
870 qq00 = _mm_mul_pd(iq0,jq0);
871 qq01 = _mm_mul_pd(iq0,jq1);
872 qq02 = _mm_mul_pd(iq0,jq2);
873 qq10 = _mm_mul_pd(iq1,jq0);
874 qq11 = _mm_mul_pd(iq1,jq1);
875 qq12 = _mm_mul_pd(iq1,jq2);
876 qq20 = _mm_mul_pd(iq2,jq0);
877 qq21 = _mm_mul_pd(iq2,jq1);
878 qq22 = _mm_mul_pd(iq2,jq2);
880 /* Avoid stupid compiler warnings */
888 /* Start outer loop over neighborlists */
889 for(iidx=0; iidx<nri; iidx++)
891 /* Load shift vector for this list */
892 i_shift_offset = DIM*shiftidx[iidx];
894 /* Load limits for loop over neighbors */
895 j_index_start = jindex[iidx];
896 j_index_end = jindex[iidx+1];
898 /* Get outer coordinate index */
900 i_coord_offset = DIM*inr;
902 /* Load i particle coords and add shift vector */
903 gmx_mm_load_shift_and_3rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,
904 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
906 fix0 = _mm_setzero_pd();
907 fiy0 = _mm_setzero_pd();
908 fiz0 = _mm_setzero_pd();
909 fix1 = _mm_setzero_pd();
910 fiy1 = _mm_setzero_pd();
911 fiz1 = _mm_setzero_pd();
912 fix2 = _mm_setzero_pd();
913 fiy2 = _mm_setzero_pd();
914 fiz2 = _mm_setzero_pd();
916 /* Start inner kernel loop */
917 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
920 /* Get j neighbor index, and coordinate index */
923 j_coord_offsetA = DIM*jnrA;
924 j_coord_offsetB = DIM*jnrB;
926 /* load j atom coordinates */
927 gmx_mm_load_3rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
928 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
930 /* Calculate displacement vector */
931 dx00 = _mm_sub_pd(ix0,jx0);
932 dy00 = _mm_sub_pd(iy0,jy0);
933 dz00 = _mm_sub_pd(iz0,jz0);
934 dx01 = _mm_sub_pd(ix0,jx1);
935 dy01 = _mm_sub_pd(iy0,jy1);
936 dz01 = _mm_sub_pd(iz0,jz1);
937 dx02 = _mm_sub_pd(ix0,jx2);
938 dy02 = _mm_sub_pd(iy0,jy2);
939 dz02 = _mm_sub_pd(iz0,jz2);
940 dx10 = _mm_sub_pd(ix1,jx0);
941 dy10 = _mm_sub_pd(iy1,jy0);
942 dz10 = _mm_sub_pd(iz1,jz0);
943 dx11 = _mm_sub_pd(ix1,jx1);
944 dy11 = _mm_sub_pd(iy1,jy1);
945 dz11 = _mm_sub_pd(iz1,jz1);
946 dx12 = _mm_sub_pd(ix1,jx2);
947 dy12 = _mm_sub_pd(iy1,jy2);
948 dz12 = _mm_sub_pd(iz1,jz2);
949 dx20 = _mm_sub_pd(ix2,jx0);
950 dy20 = _mm_sub_pd(iy2,jy0);
951 dz20 = _mm_sub_pd(iz2,jz0);
952 dx21 = _mm_sub_pd(ix2,jx1);
953 dy21 = _mm_sub_pd(iy2,jy1);
954 dz21 = _mm_sub_pd(iz2,jz1);
955 dx22 = _mm_sub_pd(ix2,jx2);
956 dy22 = _mm_sub_pd(iy2,jy2);
957 dz22 = _mm_sub_pd(iz2,jz2);
959 /* Calculate squared distance and things based on it */
960 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
961 rsq01 = gmx_mm_calc_rsq_pd(dx01,dy01,dz01);
962 rsq02 = gmx_mm_calc_rsq_pd(dx02,dy02,dz02);
963 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
964 rsq11 = gmx_mm_calc_rsq_pd(dx11,dy11,dz11);
965 rsq12 = gmx_mm_calc_rsq_pd(dx12,dy12,dz12);
966 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
967 rsq21 = gmx_mm_calc_rsq_pd(dx21,dy21,dz21);
968 rsq22 = gmx_mm_calc_rsq_pd(dx22,dy22,dz22);
970 rinv00 = gmx_mm_invsqrt_pd(rsq00);
971 rinv01 = gmx_mm_invsqrt_pd(rsq01);
972 rinv02 = gmx_mm_invsqrt_pd(rsq02);
973 rinv10 = gmx_mm_invsqrt_pd(rsq10);
974 rinv11 = gmx_mm_invsqrt_pd(rsq11);
975 rinv12 = gmx_mm_invsqrt_pd(rsq12);
976 rinv20 = gmx_mm_invsqrt_pd(rsq20);
977 rinv21 = gmx_mm_invsqrt_pd(rsq21);
978 rinv22 = gmx_mm_invsqrt_pd(rsq22);
980 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
981 rinvsq01 = _mm_mul_pd(rinv01,rinv01);
982 rinvsq02 = _mm_mul_pd(rinv02,rinv02);
983 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
984 rinvsq11 = _mm_mul_pd(rinv11,rinv11);
985 rinvsq12 = _mm_mul_pd(rinv12,rinv12);
986 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
987 rinvsq21 = _mm_mul_pd(rinv21,rinv21);
988 rinvsq22 = _mm_mul_pd(rinv22,rinv22);
990 fjx0 = _mm_setzero_pd();
991 fjy0 = _mm_setzero_pd();
992 fjz0 = _mm_setzero_pd();
993 fjx1 = _mm_setzero_pd();
994 fjy1 = _mm_setzero_pd();
995 fjz1 = _mm_setzero_pd();
996 fjx2 = _mm_setzero_pd();
997 fjy2 = _mm_setzero_pd();
998 fjz2 = _mm_setzero_pd();
1000 /**************************
1001 * CALCULATE INTERACTIONS *
1002 **************************/
1004 /* REACTION-FIELD ELECTROSTATICS */
1005 felec = _mm_mul_pd(qq00,_mm_msub_pd(rinv00,rinvsq00,krf2));
1009 /* Update vectorial force */
1010 fix0 = _mm_macc_pd(dx00,fscal,fix0);
1011 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
1012 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
1014 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
1015 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
1016 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
1018 /**************************
1019 * CALCULATE INTERACTIONS *
1020 **************************/
1022 /* REACTION-FIELD ELECTROSTATICS */
1023 felec = _mm_mul_pd(qq01,_mm_msub_pd(rinv01,rinvsq01,krf2));
1027 /* Update vectorial force */
1028 fix0 = _mm_macc_pd(dx01,fscal,fix0);
1029 fiy0 = _mm_macc_pd(dy01,fscal,fiy0);
1030 fiz0 = _mm_macc_pd(dz01,fscal,fiz0);
1032 fjx1 = _mm_macc_pd(dx01,fscal,fjx1);
1033 fjy1 = _mm_macc_pd(dy01,fscal,fjy1);
1034 fjz1 = _mm_macc_pd(dz01,fscal,fjz1);
1036 /**************************
1037 * CALCULATE INTERACTIONS *
1038 **************************/
1040 /* REACTION-FIELD ELECTROSTATICS */
1041 felec = _mm_mul_pd(qq02,_mm_msub_pd(rinv02,rinvsq02,krf2));
1045 /* Update vectorial force */
1046 fix0 = _mm_macc_pd(dx02,fscal,fix0);
1047 fiy0 = _mm_macc_pd(dy02,fscal,fiy0);
1048 fiz0 = _mm_macc_pd(dz02,fscal,fiz0);
1050 fjx2 = _mm_macc_pd(dx02,fscal,fjx2);
1051 fjy2 = _mm_macc_pd(dy02,fscal,fjy2);
1052 fjz2 = _mm_macc_pd(dz02,fscal,fjz2);
1054 /**************************
1055 * CALCULATE INTERACTIONS *
1056 **************************/
1058 /* REACTION-FIELD ELECTROSTATICS */
1059 felec = _mm_mul_pd(qq10,_mm_msub_pd(rinv10,rinvsq10,krf2));
1063 /* Update vectorial force */
1064 fix1 = _mm_macc_pd(dx10,fscal,fix1);
1065 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
1066 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
1068 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
1069 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
1070 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
1072 /**************************
1073 * CALCULATE INTERACTIONS *
1074 **************************/
1076 /* REACTION-FIELD ELECTROSTATICS */
1077 felec = _mm_mul_pd(qq11,_mm_msub_pd(rinv11,rinvsq11,krf2));
1081 /* Update vectorial force */
1082 fix1 = _mm_macc_pd(dx11,fscal,fix1);
1083 fiy1 = _mm_macc_pd(dy11,fscal,fiy1);
1084 fiz1 = _mm_macc_pd(dz11,fscal,fiz1);
1086 fjx1 = _mm_macc_pd(dx11,fscal,fjx1);
1087 fjy1 = _mm_macc_pd(dy11,fscal,fjy1);
1088 fjz1 = _mm_macc_pd(dz11,fscal,fjz1);
1090 /**************************
1091 * CALCULATE INTERACTIONS *
1092 **************************/
1094 /* REACTION-FIELD ELECTROSTATICS */
1095 felec = _mm_mul_pd(qq12,_mm_msub_pd(rinv12,rinvsq12,krf2));
1099 /* Update vectorial force */
1100 fix1 = _mm_macc_pd(dx12,fscal,fix1);
1101 fiy1 = _mm_macc_pd(dy12,fscal,fiy1);
1102 fiz1 = _mm_macc_pd(dz12,fscal,fiz1);
1104 fjx2 = _mm_macc_pd(dx12,fscal,fjx2);
1105 fjy2 = _mm_macc_pd(dy12,fscal,fjy2);
1106 fjz2 = _mm_macc_pd(dz12,fscal,fjz2);
1108 /**************************
1109 * CALCULATE INTERACTIONS *
1110 **************************/
1112 /* REACTION-FIELD ELECTROSTATICS */
1113 felec = _mm_mul_pd(qq20,_mm_msub_pd(rinv20,rinvsq20,krf2));
1117 /* Update vectorial force */
1118 fix2 = _mm_macc_pd(dx20,fscal,fix2);
1119 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
1120 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
1122 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
1123 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
1124 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
1126 /**************************
1127 * CALCULATE INTERACTIONS *
1128 **************************/
1130 /* REACTION-FIELD ELECTROSTATICS */
1131 felec = _mm_mul_pd(qq21,_mm_msub_pd(rinv21,rinvsq21,krf2));
1135 /* Update vectorial force */
1136 fix2 = _mm_macc_pd(dx21,fscal,fix2);
1137 fiy2 = _mm_macc_pd(dy21,fscal,fiy2);
1138 fiz2 = _mm_macc_pd(dz21,fscal,fiz2);
1140 fjx1 = _mm_macc_pd(dx21,fscal,fjx1);
1141 fjy1 = _mm_macc_pd(dy21,fscal,fjy1);
1142 fjz1 = _mm_macc_pd(dz21,fscal,fjz1);
1144 /**************************
1145 * CALCULATE INTERACTIONS *
1146 **************************/
1148 /* REACTION-FIELD ELECTROSTATICS */
1149 felec = _mm_mul_pd(qq22,_mm_msub_pd(rinv22,rinvsq22,krf2));
1153 /* Update vectorial force */
1154 fix2 = _mm_macc_pd(dx22,fscal,fix2);
1155 fiy2 = _mm_macc_pd(dy22,fscal,fiy2);
1156 fiz2 = _mm_macc_pd(dz22,fscal,fiz2);
1158 fjx2 = _mm_macc_pd(dx22,fscal,fjx2);
1159 fjy2 = _mm_macc_pd(dy22,fscal,fjy2);
1160 fjz2 = _mm_macc_pd(dz22,fscal,fjz2);
1162 gmx_mm_decrement_3rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
1164 /* Inner loop uses 270 flops */
1167 if(jidx<j_index_end)
1171 j_coord_offsetA = DIM*jnrA;
1173 /* load j atom coordinates */
1174 gmx_mm_load_3rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
1175 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
1177 /* Calculate displacement vector */
1178 dx00 = _mm_sub_pd(ix0,jx0);
1179 dy00 = _mm_sub_pd(iy0,jy0);
1180 dz00 = _mm_sub_pd(iz0,jz0);
1181 dx01 = _mm_sub_pd(ix0,jx1);
1182 dy01 = _mm_sub_pd(iy0,jy1);
1183 dz01 = _mm_sub_pd(iz0,jz1);
1184 dx02 = _mm_sub_pd(ix0,jx2);
1185 dy02 = _mm_sub_pd(iy0,jy2);
1186 dz02 = _mm_sub_pd(iz0,jz2);
1187 dx10 = _mm_sub_pd(ix1,jx0);
1188 dy10 = _mm_sub_pd(iy1,jy0);
1189 dz10 = _mm_sub_pd(iz1,jz0);
1190 dx11 = _mm_sub_pd(ix1,jx1);
1191 dy11 = _mm_sub_pd(iy1,jy1);
1192 dz11 = _mm_sub_pd(iz1,jz1);
1193 dx12 = _mm_sub_pd(ix1,jx2);
1194 dy12 = _mm_sub_pd(iy1,jy2);
1195 dz12 = _mm_sub_pd(iz1,jz2);
1196 dx20 = _mm_sub_pd(ix2,jx0);
1197 dy20 = _mm_sub_pd(iy2,jy0);
1198 dz20 = _mm_sub_pd(iz2,jz0);
1199 dx21 = _mm_sub_pd(ix2,jx1);
1200 dy21 = _mm_sub_pd(iy2,jy1);
1201 dz21 = _mm_sub_pd(iz2,jz1);
1202 dx22 = _mm_sub_pd(ix2,jx2);
1203 dy22 = _mm_sub_pd(iy2,jy2);
1204 dz22 = _mm_sub_pd(iz2,jz2);
1206 /* Calculate squared distance and things based on it */
1207 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
1208 rsq01 = gmx_mm_calc_rsq_pd(dx01,dy01,dz01);
1209 rsq02 = gmx_mm_calc_rsq_pd(dx02,dy02,dz02);
1210 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
1211 rsq11 = gmx_mm_calc_rsq_pd(dx11,dy11,dz11);
1212 rsq12 = gmx_mm_calc_rsq_pd(dx12,dy12,dz12);
1213 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
1214 rsq21 = gmx_mm_calc_rsq_pd(dx21,dy21,dz21);
1215 rsq22 = gmx_mm_calc_rsq_pd(dx22,dy22,dz22);
1217 rinv00 = gmx_mm_invsqrt_pd(rsq00);
1218 rinv01 = gmx_mm_invsqrt_pd(rsq01);
1219 rinv02 = gmx_mm_invsqrt_pd(rsq02);
1220 rinv10 = gmx_mm_invsqrt_pd(rsq10);
1221 rinv11 = gmx_mm_invsqrt_pd(rsq11);
1222 rinv12 = gmx_mm_invsqrt_pd(rsq12);
1223 rinv20 = gmx_mm_invsqrt_pd(rsq20);
1224 rinv21 = gmx_mm_invsqrt_pd(rsq21);
1225 rinv22 = gmx_mm_invsqrt_pd(rsq22);
1227 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
1228 rinvsq01 = _mm_mul_pd(rinv01,rinv01);
1229 rinvsq02 = _mm_mul_pd(rinv02,rinv02);
1230 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
1231 rinvsq11 = _mm_mul_pd(rinv11,rinv11);
1232 rinvsq12 = _mm_mul_pd(rinv12,rinv12);
1233 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
1234 rinvsq21 = _mm_mul_pd(rinv21,rinv21);
1235 rinvsq22 = _mm_mul_pd(rinv22,rinv22);
1237 fjx0 = _mm_setzero_pd();
1238 fjy0 = _mm_setzero_pd();
1239 fjz0 = _mm_setzero_pd();
1240 fjx1 = _mm_setzero_pd();
1241 fjy1 = _mm_setzero_pd();
1242 fjz1 = _mm_setzero_pd();
1243 fjx2 = _mm_setzero_pd();
1244 fjy2 = _mm_setzero_pd();
1245 fjz2 = _mm_setzero_pd();
1247 /**************************
1248 * CALCULATE INTERACTIONS *
1249 **************************/
1251 /* REACTION-FIELD ELECTROSTATICS */
1252 felec = _mm_mul_pd(qq00,_mm_msub_pd(rinv00,rinvsq00,krf2));
1256 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1258 /* Update vectorial force */
1259 fix0 = _mm_macc_pd(dx00,fscal,fix0);
1260 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
1261 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
1263 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
1264 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
1265 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
1267 /**************************
1268 * CALCULATE INTERACTIONS *
1269 **************************/
1271 /* REACTION-FIELD ELECTROSTATICS */
1272 felec = _mm_mul_pd(qq01,_mm_msub_pd(rinv01,rinvsq01,krf2));
1276 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1278 /* Update vectorial force */
1279 fix0 = _mm_macc_pd(dx01,fscal,fix0);
1280 fiy0 = _mm_macc_pd(dy01,fscal,fiy0);
1281 fiz0 = _mm_macc_pd(dz01,fscal,fiz0);
1283 fjx1 = _mm_macc_pd(dx01,fscal,fjx1);
1284 fjy1 = _mm_macc_pd(dy01,fscal,fjy1);
1285 fjz1 = _mm_macc_pd(dz01,fscal,fjz1);
1287 /**************************
1288 * CALCULATE INTERACTIONS *
1289 **************************/
1291 /* REACTION-FIELD ELECTROSTATICS */
1292 felec = _mm_mul_pd(qq02,_mm_msub_pd(rinv02,rinvsq02,krf2));
1296 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1298 /* Update vectorial force */
1299 fix0 = _mm_macc_pd(dx02,fscal,fix0);
1300 fiy0 = _mm_macc_pd(dy02,fscal,fiy0);
1301 fiz0 = _mm_macc_pd(dz02,fscal,fiz0);
1303 fjx2 = _mm_macc_pd(dx02,fscal,fjx2);
1304 fjy2 = _mm_macc_pd(dy02,fscal,fjy2);
1305 fjz2 = _mm_macc_pd(dz02,fscal,fjz2);
1307 /**************************
1308 * CALCULATE INTERACTIONS *
1309 **************************/
1311 /* REACTION-FIELD ELECTROSTATICS */
1312 felec = _mm_mul_pd(qq10,_mm_msub_pd(rinv10,rinvsq10,krf2));
1316 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1318 /* Update vectorial force */
1319 fix1 = _mm_macc_pd(dx10,fscal,fix1);
1320 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
1321 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
1323 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
1324 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
1325 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
1327 /**************************
1328 * CALCULATE INTERACTIONS *
1329 **************************/
1331 /* REACTION-FIELD ELECTROSTATICS */
1332 felec = _mm_mul_pd(qq11,_mm_msub_pd(rinv11,rinvsq11,krf2));
1336 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1338 /* Update vectorial force */
1339 fix1 = _mm_macc_pd(dx11,fscal,fix1);
1340 fiy1 = _mm_macc_pd(dy11,fscal,fiy1);
1341 fiz1 = _mm_macc_pd(dz11,fscal,fiz1);
1343 fjx1 = _mm_macc_pd(dx11,fscal,fjx1);
1344 fjy1 = _mm_macc_pd(dy11,fscal,fjy1);
1345 fjz1 = _mm_macc_pd(dz11,fscal,fjz1);
1347 /**************************
1348 * CALCULATE INTERACTIONS *
1349 **************************/
1351 /* REACTION-FIELD ELECTROSTATICS */
1352 felec = _mm_mul_pd(qq12,_mm_msub_pd(rinv12,rinvsq12,krf2));
1356 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1358 /* Update vectorial force */
1359 fix1 = _mm_macc_pd(dx12,fscal,fix1);
1360 fiy1 = _mm_macc_pd(dy12,fscal,fiy1);
1361 fiz1 = _mm_macc_pd(dz12,fscal,fiz1);
1363 fjx2 = _mm_macc_pd(dx12,fscal,fjx2);
1364 fjy2 = _mm_macc_pd(dy12,fscal,fjy2);
1365 fjz2 = _mm_macc_pd(dz12,fscal,fjz2);
1367 /**************************
1368 * CALCULATE INTERACTIONS *
1369 **************************/
1371 /* REACTION-FIELD ELECTROSTATICS */
1372 felec = _mm_mul_pd(qq20,_mm_msub_pd(rinv20,rinvsq20,krf2));
1376 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1378 /* Update vectorial force */
1379 fix2 = _mm_macc_pd(dx20,fscal,fix2);
1380 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
1381 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
1383 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
1384 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
1385 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
1387 /**************************
1388 * CALCULATE INTERACTIONS *
1389 **************************/
1391 /* REACTION-FIELD ELECTROSTATICS */
1392 felec = _mm_mul_pd(qq21,_mm_msub_pd(rinv21,rinvsq21,krf2));
1396 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1398 /* Update vectorial force */
1399 fix2 = _mm_macc_pd(dx21,fscal,fix2);
1400 fiy2 = _mm_macc_pd(dy21,fscal,fiy2);
1401 fiz2 = _mm_macc_pd(dz21,fscal,fiz2);
1403 fjx1 = _mm_macc_pd(dx21,fscal,fjx1);
1404 fjy1 = _mm_macc_pd(dy21,fscal,fjy1);
1405 fjz1 = _mm_macc_pd(dz21,fscal,fjz1);
1407 /**************************
1408 * CALCULATE INTERACTIONS *
1409 **************************/
1411 /* REACTION-FIELD ELECTROSTATICS */
1412 felec = _mm_mul_pd(qq22,_mm_msub_pd(rinv22,rinvsq22,krf2));
1416 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1418 /* Update vectorial force */
1419 fix2 = _mm_macc_pd(dx22,fscal,fix2);
1420 fiy2 = _mm_macc_pd(dy22,fscal,fiy2);
1421 fiz2 = _mm_macc_pd(dz22,fscal,fiz2);
1423 fjx2 = _mm_macc_pd(dx22,fscal,fjx2);
1424 fjy2 = _mm_macc_pd(dy22,fscal,fjy2);
1425 fjz2 = _mm_macc_pd(dz22,fscal,fjz2);
1427 gmx_mm_decrement_3rvec_1ptr_swizzle_pd(f+j_coord_offsetA,fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
1429 /* Inner loop uses 270 flops */
1432 /* End of innermost loop */
1434 gmx_mm_update_iforce_3atom_swizzle_pd(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
1435 f+i_coord_offset,fshift+i_shift_offset);
1437 /* Increment number of inner iterations */
1438 inneriter += j_index_end - j_index_start;
1440 /* Outer loop uses 18 flops */
1443 /* Increment number of outer iterations */
1446 /* Update outer/inner flops */
1448 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3W3_F,outeriter*18 + inneriter*270);