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_GeomW4W4_VF_avx_128_fma_double
38 * Electrostatics interaction: ReactionField
39 * VdW interaction: None
40 * Geometry: Water4-Water4
41 * Calculate force/pot: PotentialAndForce
44 nb_kernel_ElecRF_VdwNone_GeomW4W4_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 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
69 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
71 __m128d ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
72 int vdwjidx1A,vdwjidx1B;
73 __m128d jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
74 int vdwjidx2A,vdwjidx2B;
75 __m128d jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
76 int vdwjidx3A,vdwjidx3B;
77 __m128d jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
78 __m128d dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
79 __m128d dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
80 __m128d dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13;
81 __m128d dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
82 __m128d dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
83 __m128d dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23;
84 __m128d dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31;
85 __m128d dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32;
86 __m128d dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33;
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 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
113 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
114 iq3 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+3]));
116 jq1 = _mm_set1_pd(charge[inr+1]);
117 jq2 = _mm_set1_pd(charge[inr+2]);
118 jq3 = _mm_set1_pd(charge[inr+3]);
119 qq11 = _mm_mul_pd(iq1,jq1);
120 qq12 = _mm_mul_pd(iq1,jq2);
121 qq13 = _mm_mul_pd(iq1,jq3);
122 qq21 = _mm_mul_pd(iq2,jq1);
123 qq22 = _mm_mul_pd(iq2,jq2);
124 qq23 = _mm_mul_pd(iq2,jq3);
125 qq31 = _mm_mul_pd(iq3,jq1);
126 qq32 = _mm_mul_pd(iq3,jq2);
127 qq33 = _mm_mul_pd(iq3,jq3);
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+DIM,
153 &ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
155 fix1 = _mm_setzero_pd();
156 fiy1 = _mm_setzero_pd();
157 fiz1 = _mm_setzero_pd();
158 fix2 = _mm_setzero_pd();
159 fiy2 = _mm_setzero_pd();
160 fiz2 = _mm_setzero_pd();
161 fix3 = _mm_setzero_pd();
162 fiy3 = _mm_setzero_pd();
163 fiz3 = _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+DIM,x+j_coord_offsetB+DIM,
180 &jx1,&jy1,&jz1,&jx2,&jy2,&jz2,&jx3,&jy3,&jz3);
182 /* Calculate displacement vector */
183 dx11 = _mm_sub_pd(ix1,jx1);
184 dy11 = _mm_sub_pd(iy1,jy1);
185 dz11 = _mm_sub_pd(iz1,jz1);
186 dx12 = _mm_sub_pd(ix1,jx2);
187 dy12 = _mm_sub_pd(iy1,jy2);
188 dz12 = _mm_sub_pd(iz1,jz2);
189 dx13 = _mm_sub_pd(ix1,jx3);
190 dy13 = _mm_sub_pd(iy1,jy3);
191 dz13 = _mm_sub_pd(iz1,jz3);
192 dx21 = _mm_sub_pd(ix2,jx1);
193 dy21 = _mm_sub_pd(iy2,jy1);
194 dz21 = _mm_sub_pd(iz2,jz1);
195 dx22 = _mm_sub_pd(ix2,jx2);
196 dy22 = _mm_sub_pd(iy2,jy2);
197 dz22 = _mm_sub_pd(iz2,jz2);
198 dx23 = _mm_sub_pd(ix2,jx3);
199 dy23 = _mm_sub_pd(iy2,jy3);
200 dz23 = _mm_sub_pd(iz2,jz3);
201 dx31 = _mm_sub_pd(ix3,jx1);
202 dy31 = _mm_sub_pd(iy3,jy1);
203 dz31 = _mm_sub_pd(iz3,jz1);
204 dx32 = _mm_sub_pd(ix3,jx2);
205 dy32 = _mm_sub_pd(iy3,jy2);
206 dz32 = _mm_sub_pd(iz3,jz2);
207 dx33 = _mm_sub_pd(ix3,jx3);
208 dy33 = _mm_sub_pd(iy3,jy3);
209 dz33 = _mm_sub_pd(iz3,jz3);
211 /* Calculate squared distance and things based on it */
212 rsq11 = gmx_mm_calc_rsq_pd(dx11,dy11,dz11);
213 rsq12 = gmx_mm_calc_rsq_pd(dx12,dy12,dz12);
214 rsq13 = gmx_mm_calc_rsq_pd(dx13,dy13,dz13);
215 rsq21 = gmx_mm_calc_rsq_pd(dx21,dy21,dz21);
216 rsq22 = gmx_mm_calc_rsq_pd(dx22,dy22,dz22);
217 rsq23 = gmx_mm_calc_rsq_pd(dx23,dy23,dz23);
218 rsq31 = gmx_mm_calc_rsq_pd(dx31,dy31,dz31);
219 rsq32 = gmx_mm_calc_rsq_pd(dx32,dy32,dz32);
220 rsq33 = gmx_mm_calc_rsq_pd(dx33,dy33,dz33);
222 rinv11 = gmx_mm_invsqrt_pd(rsq11);
223 rinv12 = gmx_mm_invsqrt_pd(rsq12);
224 rinv13 = gmx_mm_invsqrt_pd(rsq13);
225 rinv21 = gmx_mm_invsqrt_pd(rsq21);
226 rinv22 = gmx_mm_invsqrt_pd(rsq22);
227 rinv23 = gmx_mm_invsqrt_pd(rsq23);
228 rinv31 = gmx_mm_invsqrt_pd(rsq31);
229 rinv32 = gmx_mm_invsqrt_pd(rsq32);
230 rinv33 = gmx_mm_invsqrt_pd(rsq33);
232 rinvsq11 = _mm_mul_pd(rinv11,rinv11);
233 rinvsq12 = _mm_mul_pd(rinv12,rinv12);
234 rinvsq13 = _mm_mul_pd(rinv13,rinv13);
235 rinvsq21 = _mm_mul_pd(rinv21,rinv21);
236 rinvsq22 = _mm_mul_pd(rinv22,rinv22);
237 rinvsq23 = _mm_mul_pd(rinv23,rinv23);
238 rinvsq31 = _mm_mul_pd(rinv31,rinv31);
239 rinvsq32 = _mm_mul_pd(rinv32,rinv32);
240 rinvsq33 = _mm_mul_pd(rinv33,rinv33);
242 fjx1 = _mm_setzero_pd();
243 fjy1 = _mm_setzero_pd();
244 fjz1 = _mm_setzero_pd();
245 fjx2 = _mm_setzero_pd();
246 fjy2 = _mm_setzero_pd();
247 fjz2 = _mm_setzero_pd();
248 fjx3 = _mm_setzero_pd();
249 fjy3 = _mm_setzero_pd();
250 fjz3 = _mm_setzero_pd();
252 /**************************
253 * CALCULATE INTERACTIONS *
254 **************************/
256 /* REACTION-FIELD ELECTROSTATICS */
257 velec = _mm_mul_pd(qq11,_mm_sub_pd(_mm_macc_pd(krf,rsq11,rinv11),crf));
258 felec = _mm_mul_pd(qq11,_mm_msub_pd(rinv11,rinvsq11,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 fix1 = _mm_macc_pd(dx11,fscal,fix1);
267 fiy1 = _mm_macc_pd(dy11,fscal,fiy1);
268 fiz1 = _mm_macc_pd(dz11,fscal,fiz1);
270 fjx1 = _mm_macc_pd(dx11,fscal,fjx1);
271 fjy1 = _mm_macc_pd(dy11,fscal,fjy1);
272 fjz1 = _mm_macc_pd(dz11,fscal,fjz1);
274 /**************************
275 * CALCULATE INTERACTIONS *
276 **************************/
278 /* REACTION-FIELD ELECTROSTATICS */
279 velec = _mm_mul_pd(qq12,_mm_sub_pd(_mm_macc_pd(krf,rsq12,rinv12),crf));
280 felec = _mm_mul_pd(qq12,_mm_msub_pd(rinv12,rinvsq12,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 fix1 = _mm_macc_pd(dx12,fscal,fix1);
289 fiy1 = _mm_macc_pd(dy12,fscal,fiy1);
290 fiz1 = _mm_macc_pd(dz12,fscal,fiz1);
292 fjx2 = _mm_macc_pd(dx12,fscal,fjx2);
293 fjy2 = _mm_macc_pd(dy12,fscal,fjy2);
294 fjz2 = _mm_macc_pd(dz12,fscal,fjz2);
296 /**************************
297 * CALCULATE INTERACTIONS *
298 **************************/
300 /* REACTION-FIELD ELECTROSTATICS */
301 velec = _mm_mul_pd(qq13,_mm_sub_pd(_mm_macc_pd(krf,rsq13,rinv13),crf));
302 felec = _mm_mul_pd(qq13,_mm_msub_pd(rinv13,rinvsq13,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 fix1 = _mm_macc_pd(dx13,fscal,fix1);
311 fiy1 = _mm_macc_pd(dy13,fscal,fiy1);
312 fiz1 = _mm_macc_pd(dz13,fscal,fiz1);
314 fjx3 = _mm_macc_pd(dx13,fscal,fjx3);
315 fjy3 = _mm_macc_pd(dy13,fscal,fjy3);
316 fjz3 = _mm_macc_pd(dz13,fscal,fjz3);
318 /**************************
319 * CALCULATE INTERACTIONS *
320 **************************/
322 /* REACTION-FIELD ELECTROSTATICS */
323 velec = _mm_mul_pd(qq21,_mm_sub_pd(_mm_macc_pd(krf,rsq21,rinv21),crf));
324 felec = _mm_mul_pd(qq21,_mm_msub_pd(rinv21,rinvsq21,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 fix2 = _mm_macc_pd(dx21,fscal,fix2);
333 fiy2 = _mm_macc_pd(dy21,fscal,fiy2);
334 fiz2 = _mm_macc_pd(dz21,fscal,fiz2);
336 fjx1 = _mm_macc_pd(dx21,fscal,fjx1);
337 fjy1 = _mm_macc_pd(dy21,fscal,fjy1);
338 fjz1 = _mm_macc_pd(dz21,fscal,fjz1);
340 /**************************
341 * CALCULATE INTERACTIONS *
342 **************************/
344 /* REACTION-FIELD ELECTROSTATICS */
345 velec = _mm_mul_pd(qq22,_mm_sub_pd(_mm_macc_pd(krf,rsq22,rinv22),crf));
346 felec = _mm_mul_pd(qq22,_mm_msub_pd(rinv22,rinvsq22,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 fix2 = _mm_macc_pd(dx22,fscal,fix2);
355 fiy2 = _mm_macc_pd(dy22,fscal,fiy2);
356 fiz2 = _mm_macc_pd(dz22,fscal,fiz2);
358 fjx2 = _mm_macc_pd(dx22,fscal,fjx2);
359 fjy2 = _mm_macc_pd(dy22,fscal,fjy2);
360 fjz2 = _mm_macc_pd(dz22,fscal,fjz2);
362 /**************************
363 * CALCULATE INTERACTIONS *
364 **************************/
366 /* REACTION-FIELD ELECTROSTATICS */
367 velec = _mm_mul_pd(qq23,_mm_sub_pd(_mm_macc_pd(krf,rsq23,rinv23),crf));
368 felec = _mm_mul_pd(qq23,_mm_msub_pd(rinv23,rinvsq23,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 fix2 = _mm_macc_pd(dx23,fscal,fix2);
377 fiy2 = _mm_macc_pd(dy23,fscal,fiy2);
378 fiz2 = _mm_macc_pd(dz23,fscal,fiz2);
380 fjx3 = _mm_macc_pd(dx23,fscal,fjx3);
381 fjy3 = _mm_macc_pd(dy23,fscal,fjy3);
382 fjz3 = _mm_macc_pd(dz23,fscal,fjz3);
384 /**************************
385 * CALCULATE INTERACTIONS *
386 **************************/
388 /* REACTION-FIELD ELECTROSTATICS */
389 velec = _mm_mul_pd(qq31,_mm_sub_pd(_mm_macc_pd(krf,rsq31,rinv31),crf));
390 felec = _mm_mul_pd(qq31,_mm_msub_pd(rinv31,rinvsq31,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 fix3 = _mm_macc_pd(dx31,fscal,fix3);
399 fiy3 = _mm_macc_pd(dy31,fscal,fiy3);
400 fiz3 = _mm_macc_pd(dz31,fscal,fiz3);
402 fjx1 = _mm_macc_pd(dx31,fscal,fjx1);
403 fjy1 = _mm_macc_pd(dy31,fscal,fjy1);
404 fjz1 = _mm_macc_pd(dz31,fscal,fjz1);
406 /**************************
407 * CALCULATE INTERACTIONS *
408 **************************/
410 /* REACTION-FIELD ELECTROSTATICS */
411 velec = _mm_mul_pd(qq32,_mm_sub_pd(_mm_macc_pd(krf,rsq32,rinv32),crf));
412 felec = _mm_mul_pd(qq32,_mm_msub_pd(rinv32,rinvsq32,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 fix3 = _mm_macc_pd(dx32,fscal,fix3);
421 fiy3 = _mm_macc_pd(dy32,fscal,fiy3);
422 fiz3 = _mm_macc_pd(dz32,fscal,fiz3);
424 fjx2 = _mm_macc_pd(dx32,fscal,fjx2);
425 fjy2 = _mm_macc_pd(dy32,fscal,fjy2);
426 fjz2 = _mm_macc_pd(dz32,fscal,fjz2);
428 /**************************
429 * CALCULATE INTERACTIONS *
430 **************************/
432 /* REACTION-FIELD ELECTROSTATICS */
433 velec = _mm_mul_pd(qq33,_mm_sub_pd(_mm_macc_pd(krf,rsq33,rinv33),crf));
434 felec = _mm_mul_pd(qq33,_mm_msub_pd(rinv33,rinvsq33,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 fix3 = _mm_macc_pd(dx33,fscal,fix3);
443 fiy3 = _mm_macc_pd(dy33,fscal,fiy3);
444 fiz3 = _mm_macc_pd(dz33,fscal,fiz3);
446 fjx3 = _mm_macc_pd(dx33,fscal,fjx3);
447 fjy3 = _mm_macc_pd(dy33,fscal,fjy3);
448 fjz3 = _mm_macc_pd(dz33,fscal,fjz3);
450 gmx_mm_decrement_3rvec_2ptr_swizzle_pd(f+j_coord_offsetA+DIM,f+j_coord_offsetB+DIM,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
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+DIM,
463 &jx1,&jy1,&jz1,&jx2,&jy2,&jz2,&jx3,&jy3,&jz3);
465 /* Calculate displacement vector */
466 dx11 = _mm_sub_pd(ix1,jx1);
467 dy11 = _mm_sub_pd(iy1,jy1);
468 dz11 = _mm_sub_pd(iz1,jz1);
469 dx12 = _mm_sub_pd(ix1,jx2);
470 dy12 = _mm_sub_pd(iy1,jy2);
471 dz12 = _mm_sub_pd(iz1,jz2);
472 dx13 = _mm_sub_pd(ix1,jx3);
473 dy13 = _mm_sub_pd(iy1,jy3);
474 dz13 = _mm_sub_pd(iz1,jz3);
475 dx21 = _mm_sub_pd(ix2,jx1);
476 dy21 = _mm_sub_pd(iy2,jy1);
477 dz21 = _mm_sub_pd(iz2,jz1);
478 dx22 = _mm_sub_pd(ix2,jx2);
479 dy22 = _mm_sub_pd(iy2,jy2);
480 dz22 = _mm_sub_pd(iz2,jz2);
481 dx23 = _mm_sub_pd(ix2,jx3);
482 dy23 = _mm_sub_pd(iy2,jy3);
483 dz23 = _mm_sub_pd(iz2,jz3);
484 dx31 = _mm_sub_pd(ix3,jx1);
485 dy31 = _mm_sub_pd(iy3,jy1);
486 dz31 = _mm_sub_pd(iz3,jz1);
487 dx32 = _mm_sub_pd(ix3,jx2);
488 dy32 = _mm_sub_pd(iy3,jy2);
489 dz32 = _mm_sub_pd(iz3,jz2);
490 dx33 = _mm_sub_pd(ix3,jx3);
491 dy33 = _mm_sub_pd(iy3,jy3);
492 dz33 = _mm_sub_pd(iz3,jz3);
494 /* Calculate squared distance and things based on it */
495 rsq11 = gmx_mm_calc_rsq_pd(dx11,dy11,dz11);
496 rsq12 = gmx_mm_calc_rsq_pd(dx12,dy12,dz12);
497 rsq13 = gmx_mm_calc_rsq_pd(dx13,dy13,dz13);
498 rsq21 = gmx_mm_calc_rsq_pd(dx21,dy21,dz21);
499 rsq22 = gmx_mm_calc_rsq_pd(dx22,dy22,dz22);
500 rsq23 = gmx_mm_calc_rsq_pd(dx23,dy23,dz23);
501 rsq31 = gmx_mm_calc_rsq_pd(dx31,dy31,dz31);
502 rsq32 = gmx_mm_calc_rsq_pd(dx32,dy32,dz32);
503 rsq33 = gmx_mm_calc_rsq_pd(dx33,dy33,dz33);
505 rinv11 = gmx_mm_invsqrt_pd(rsq11);
506 rinv12 = gmx_mm_invsqrt_pd(rsq12);
507 rinv13 = gmx_mm_invsqrt_pd(rsq13);
508 rinv21 = gmx_mm_invsqrt_pd(rsq21);
509 rinv22 = gmx_mm_invsqrt_pd(rsq22);
510 rinv23 = gmx_mm_invsqrt_pd(rsq23);
511 rinv31 = gmx_mm_invsqrt_pd(rsq31);
512 rinv32 = gmx_mm_invsqrt_pd(rsq32);
513 rinv33 = gmx_mm_invsqrt_pd(rsq33);
515 rinvsq11 = _mm_mul_pd(rinv11,rinv11);
516 rinvsq12 = _mm_mul_pd(rinv12,rinv12);
517 rinvsq13 = _mm_mul_pd(rinv13,rinv13);
518 rinvsq21 = _mm_mul_pd(rinv21,rinv21);
519 rinvsq22 = _mm_mul_pd(rinv22,rinv22);
520 rinvsq23 = _mm_mul_pd(rinv23,rinv23);
521 rinvsq31 = _mm_mul_pd(rinv31,rinv31);
522 rinvsq32 = _mm_mul_pd(rinv32,rinv32);
523 rinvsq33 = _mm_mul_pd(rinv33,rinv33);
525 fjx1 = _mm_setzero_pd();
526 fjy1 = _mm_setzero_pd();
527 fjz1 = _mm_setzero_pd();
528 fjx2 = _mm_setzero_pd();
529 fjy2 = _mm_setzero_pd();
530 fjz2 = _mm_setzero_pd();
531 fjx3 = _mm_setzero_pd();
532 fjy3 = _mm_setzero_pd();
533 fjz3 = _mm_setzero_pd();
535 /**************************
536 * CALCULATE INTERACTIONS *
537 **************************/
539 /* REACTION-FIELD ELECTROSTATICS */
540 velec = _mm_mul_pd(qq11,_mm_sub_pd(_mm_macc_pd(krf,rsq11,rinv11),crf));
541 felec = _mm_mul_pd(qq11,_mm_msub_pd(rinv11,rinvsq11,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 fix1 = _mm_macc_pd(dx11,fscal,fix1);
553 fiy1 = _mm_macc_pd(dy11,fscal,fiy1);
554 fiz1 = _mm_macc_pd(dz11,fscal,fiz1);
556 fjx1 = _mm_macc_pd(dx11,fscal,fjx1);
557 fjy1 = _mm_macc_pd(dy11,fscal,fjy1);
558 fjz1 = _mm_macc_pd(dz11,fscal,fjz1);
560 /**************************
561 * CALCULATE INTERACTIONS *
562 **************************/
564 /* REACTION-FIELD ELECTROSTATICS */
565 velec = _mm_mul_pd(qq12,_mm_sub_pd(_mm_macc_pd(krf,rsq12,rinv12),crf));
566 felec = _mm_mul_pd(qq12,_mm_msub_pd(rinv12,rinvsq12,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 fix1 = _mm_macc_pd(dx12,fscal,fix1);
578 fiy1 = _mm_macc_pd(dy12,fscal,fiy1);
579 fiz1 = _mm_macc_pd(dz12,fscal,fiz1);
581 fjx2 = _mm_macc_pd(dx12,fscal,fjx2);
582 fjy2 = _mm_macc_pd(dy12,fscal,fjy2);
583 fjz2 = _mm_macc_pd(dz12,fscal,fjz2);
585 /**************************
586 * CALCULATE INTERACTIONS *
587 **************************/
589 /* REACTION-FIELD ELECTROSTATICS */
590 velec = _mm_mul_pd(qq13,_mm_sub_pd(_mm_macc_pd(krf,rsq13,rinv13),crf));
591 felec = _mm_mul_pd(qq13,_mm_msub_pd(rinv13,rinvsq13,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 fix1 = _mm_macc_pd(dx13,fscal,fix1);
603 fiy1 = _mm_macc_pd(dy13,fscal,fiy1);
604 fiz1 = _mm_macc_pd(dz13,fscal,fiz1);
606 fjx3 = _mm_macc_pd(dx13,fscal,fjx3);
607 fjy3 = _mm_macc_pd(dy13,fscal,fjy3);
608 fjz3 = _mm_macc_pd(dz13,fscal,fjz3);
610 /**************************
611 * CALCULATE INTERACTIONS *
612 **************************/
614 /* REACTION-FIELD ELECTROSTATICS */
615 velec = _mm_mul_pd(qq21,_mm_sub_pd(_mm_macc_pd(krf,rsq21,rinv21),crf));
616 felec = _mm_mul_pd(qq21,_mm_msub_pd(rinv21,rinvsq21,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 fix2 = _mm_macc_pd(dx21,fscal,fix2);
628 fiy2 = _mm_macc_pd(dy21,fscal,fiy2);
629 fiz2 = _mm_macc_pd(dz21,fscal,fiz2);
631 fjx1 = _mm_macc_pd(dx21,fscal,fjx1);
632 fjy1 = _mm_macc_pd(dy21,fscal,fjy1);
633 fjz1 = _mm_macc_pd(dz21,fscal,fjz1);
635 /**************************
636 * CALCULATE INTERACTIONS *
637 **************************/
639 /* REACTION-FIELD ELECTROSTATICS */
640 velec = _mm_mul_pd(qq22,_mm_sub_pd(_mm_macc_pd(krf,rsq22,rinv22),crf));
641 felec = _mm_mul_pd(qq22,_mm_msub_pd(rinv22,rinvsq22,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 fix2 = _mm_macc_pd(dx22,fscal,fix2);
653 fiy2 = _mm_macc_pd(dy22,fscal,fiy2);
654 fiz2 = _mm_macc_pd(dz22,fscal,fiz2);
656 fjx2 = _mm_macc_pd(dx22,fscal,fjx2);
657 fjy2 = _mm_macc_pd(dy22,fscal,fjy2);
658 fjz2 = _mm_macc_pd(dz22,fscal,fjz2);
660 /**************************
661 * CALCULATE INTERACTIONS *
662 **************************/
664 /* REACTION-FIELD ELECTROSTATICS */
665 velec = _mm_mul_pd(qq23,_mm_sub_pd(_mm_macc_pd(krf,rsq23,rinv23),crf));
666 felec = _mm_mul_pd(qq23,_mm_msub_pd(rinv23,rinvsq23,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 fix2 = _mm_macc_pd(dx23,fscal,fix2);
678 fiy2 = _mm_macc_pd(dy23,fscal,fiy2);
679 fiz2 = _mm_macc_pd(dz23,fscal,fiz2);
681 fjx3 = _mm_macc_pd(dx23,fscal,fjx3);
682 fjy3 = _mm_macc_pd(dy23,fscal,fjy3);
683 fjz3 = _mm_macc_pd(dz23,fscal,fjz3);
685 /**************************
686 * CALCULATE INTERACTIONS *
687 **************************/
689 /* REACTION-FIELD ELECTROSTATICS */
690 velec = _mm_mul_pd(qq31,_mm_sub_pd(_mm_macc_pd(krf,rsq31,rinv31),crf));
691 felec = _mm_mul_pd(qq31,_mm_msub_pd(rinv31,rinvsq31,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 fix3 = _mm_macc_pd(dx31,fscal,fix3);
703 fiy3 = _mm_macc_pd(dy31,fscal,fiy3);
704 fiz3 = _mm_macc_pd(dz31,fscal,fiz3);
706 fjx1 = _mm_macc_pd(dx31,fscal,fjx1);
707 fjy1 = _mm_macc_pd(dy31,fscal,fjy1);
708 fjz1 = _mm_macc_pd(dz31,fscal,fjz1);
710 /**************************
711 * CALCULATE INTERACTIONS *
712 **************************/
714 /* REACTION-FIELD ELECTROSTATICS */
715 velec = _mm_mul_pd(qq32,_mm_sub_pd(_mm_macc_pd(krf,rsq32,rinv32),crf));
716 felec = _mm_mul_pd(qq32,_mm_msub_pd(rinv32,rinvsq32,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 fix3 = _mm_macc_pd(dx32,fscal,fix3);
728 fiy3 = _mm_macc_pd(dy32,fscal,fiy3);
729 fiz3 = _mm_macc_pd(dz32,fscal,fiz3);
731 fjx2 = _mm_macc_pd(dx32,fscal,fjx2);
732 fjy2 = _mm_macc_pd(dy32,fscal,fjy2);
733 fjz2 = _mm_macc_pd(dz32,fscal,fjz2);
735 /**************************
736 * CALCULATE INTERACTIONS *
737 **************************/
739 /* REACTION-FIELD ELECTROSTATICS */
740 velec = _mm_mul_pd(qq33,_mm_sub_pd(_mm_macc_pd(krf,rsq33,rinv33),crf));
741 felec = _mm_mul_pd(qq33,_mm_msub_pd(rinv33,rinvsq33,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 fix3 = _mm_macc_pd(dx33,fscal,fix3);
753 fiy3 = _mm_macc_pd(dy33,fscal,fiy3);
754 fiz3 = _mm_macc_pd(dz33,fscal,fiz3);
756 fjx3 = _mm_macc_pd(dx33,fscal,fjx3);
757 fjy3 = _mm_macc_pd(dy33,fscal,fjy3);
758 fjz3 = _mm_macc_pd(dz33,fscal,fjz3);
760 gmx_mm_decrement_3rvec_1ptr_swizzle_pd(f+j_coord_offsetA+DIM,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
762 /* Inner loop uses 315 flops */
765 /* End of innermost loop */
767 gmx_mm_update_iforce_3atom_swizzle_pd(fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
768 f+i_coord_offset+DIM,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_W4W4_VF,outeriter*19 + inneriter*315);
788 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwNone_GeomW4W4_F_avx_128_fma_double
789 * Electrostatics interaction: ReactionField
790 * VdW interaction: None
791 * Geometry: Water4-Water4
792 * Calculate force/pot: Force
795 nb_kernel_ElecRF_VdwNone_GeomW4W4_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 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
820 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
822 __m128d ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
823 int vdwjidx1A,vdwjidx1B;
824 __m128d jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
825 int vdwjidx2A,vdwjidx2B;
826 __m128d jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
827 int vdwjidx3A,vdwjidx3B;
828 __m128d jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
829 __m128d dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
830 __m128d dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
831 __m128d dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13;
832 __m128d dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
833 __m128d dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
834 __m128d dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23;
835 __m128d dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31;
836 __m128d dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32;
837 __m128d dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33;
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 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
864 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
865 iq3 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+3]));
867 jq1 = _mm_set1_pd(charge[inr+1]);
868 jq2 = _mm_set1_pd(charge[inr+2]);
869 jq3 = _mm_set1_pd(charge[inr+3]);
870 qq11 = _mm_mul_pd(iq1,jq1);
871 qq12 = _mm_mul_pd(iq1,jq2);
872 qq13 = _mm_mul_pd(iq1,jq3);
873 qq21 = _mm_mul_pd(iq2,jq1);
874 qq22 = _mm_mul_pd(iq2,jq2);
875 qq23 = _mm_mul_pd(iq2,jq3);
876 qq31 = _mm_mul_pd(iq3,jq1);
877 qq32 = _mm_mul_pd(iq3,jq2);
878 qq33 = _mm_mul_pd(iq3,jq3);
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+DIM,
904 &ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
906 fix1 = _mm_setzero_pd();
907 fiy1 = _mm_setzero_pd();
908 fiz1 = _mm_setzero_pd();
909 fix2 = _mm_setzero_pd();
910 fiy2 = _mm_setzero_pd();
911 fiz2 = _mm_setzero_pd();
912 fix3 = _mm_setzero_pd();
913 fiy3 = _mm_setzero_pd();
914 fiz3 = _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+DIM,x+j_coord_offsetB+DIM,
928 &jx1,&jy1,&jz1,&jx2,&jy2,&jz2,&jx3,&jy3,&jz3);
930 /* Calculate displacement vector */
931 dx11 = _mm_sub_pd(ix1,jx1);
932 dy11 = _mm_sub_pd(iy1,jy1);
933 dz11 = _mm_sub_pd(iz1,jz1);
934 dx12 = _mm_sub_pd(ix1,jx2);
935 dy12 = _mm_sub_pd(iy1,jy2);
936 dz12 = _mm_sub_pd(iz1,jz2);
937 dx13 = _mm_sub_pd(ix1,jx3);
938 dy13 = _mm_sub_pd(iy1,jy3);
939 dz13 = _mm_sub_pd(iz1,jz3);
940 dx21 = _mm_sub_pd(ix2,jx1);
941 dy21 = _mm_sub_pd(iy2,jy1);
942 dz21 = _mm_sub_pd(iz2,jz1);
943 dx22 = _mm_sub_pd(ix2,jx2);
944 dy22 = _mm_sub_pd(iy2,jy2);
945 dz22 = _mm_sub_pd(iz2,jz2);
946 dx23 = _mm_sub_pd(ix2,jx3);
947 dy23 = _mm_sub_pd(iy2,jy3);
948 dz23 = _mm_sub_pd(iz2,jz3);
949 dx31 = _mm_sub_pd(ix3,jx1);
950 dy31 = _mm_sub_pd(iy3,jy1);
951 dz31 = _mm_sub_pd(iz3,jz1);
952 dx32 = _mm_sub_pd(ix3,jx2);
953 dy32 = _mm_sub_pd(iy3,jy2);
954 dz32 = _mm_sub_pd(iz3,jz2);
955 dx33 = _mm_sub_pd(ix3,jx3);
956 dy33 = _mm_sub_pd(iy3,jy3);
957 dz33 = _mm_sub_pd(iz3,jz3);
959 /* Calculate squared distance and things based on it */
960 rsq11 = gmx_mm_calc_rsq_pd(dx11,dy11,dz11);
961 rsq12 = gmx_mm_calc_rsq_pd(dx12,dy12,dz12);
962 rsq13 = gmx_mm_calc_rsq_pd(dx13,dy13,dz13);
963 rsq21 = gmx_mm_calc_rsq_pd(dx21,dy21,dz21);
964 rsq22 = gmx_mm_calc_rsq_pd(dx22,dy22,dz22);
965 rsq23 = gmx_mm_calc_rsq_pd(dx23,dy23,dz23);
966 rsq31 = gmx_mm_calc_rsq_pd(dx31,dy31,dz31);
967 rsq32 = gmx_mm_calc_rsq_pd(dx32,dy32,dz32);
968 rsq33 = gmx_mm_calc_rsq_pd(dx33,dy33,dz33);
970 rinv11 = gmx_mm_invsqrt_pd(rsq11);
971 rinv12 = gmx_mm_invsqrt_pd(rsq12);
972 rinv13 = gmx_mm_invsqrt_pd(rsq13);
973 rinv21 = gmx_mm_invsqrt_pd(rsq21);
974 rinv22 = gmx_mm_invsqrt_pd(rsq22);
975 rinv23 = gmx_mm_invsqrt_pd(rsq23);
976 rinv31 = gmx_mm_invsqrt_pd(rsq31);
977 rinv32 = gmx_mm_invsqrt_pd(rsq32);
978 rinv33 = gmx_mm_invsqrt_pd(rsq33);
980 rinvsq11 = _mm_mul_pd(rinv11,rinv11);
981 rinvsq12 = _mm_mul_pd(rinv12,rinv12);
982 rinvsq13 = _mm_mul_pd(rinv13,rinv13);
983 rinvsq21 = _mm_mul_pd(rinv21,rinv21);
984 rinvsq22 = _mm_mul_pd(rinv22,rinv22);
985 rinvsq23 = _mm_mul_pd(rinv23,rinv23);
986 rinvsq31 = _mm_mul_pd(rinv31,rinv31);
987 rinvsq32 = _mm_mul_pd(rinv32,rinv32);
988 rinvsq33 = _mm_mul_pd(rinv33,rinv33);
990 fjx1 = _mm_setzero_pd();
991 fjy1 = _mm_setzero_pd();
992 fjz1 = _mm_setzero_pd();
993 fjx2 = _mm_setzero_pd();
994 fjy2 = _mm_setzero_pd();
995 fjz2 = _mm_setzero_pd();
996 fjx3 = _mm_setzero_pd();
997 fjy3 = _mm_setzero_pd();
998 fjz3 = _mm_setzero_pd();
1000 /**************************
1001 * CALCULATE INTERACTIONS *
1002 **************************/
1004 /* REACTION-FIELD ELECTROSTATICS */
1005 felec = _mm_mul_pd(qq11,_mm_msub_pd(rinv11,rinvsq11,krf2));
1009 /* Update vectorial force */
1010 fix1 = _mm_macc_pd(dx11,fscal,fix1);
1011 fiy1 = _mm_macc_pd(dy11,fscal,fiy1);
1012 fiz1 = _mm_macc_pd(dz11,fscal,fiz1);
1014 fjx1 = _mm_macc_pd(dx11,fscal,fjx1);
1015 fjy1 = _mm_macc_pd(dy11,fscal,fjy1);
1016 fjz1 = _mm_macc_pd(dz11,fscal,fjz1);
1018 /**************************
1019 * CALCULATE INTERACTIONS *
1020 **************************/
1022 /* REACTION-FIELD ELECTROSTATICS */
1023 felec = _mm_mul_pd(qq12,_mm_msub_pd(rinv12,rinvsq12,krf2));
1027 /* Update vectorial force */
1028 fix1 = _mm_macc_pd(dx12,fscal,fix1);
1029 fiy1 = _mm_macc_pd(dy12,fscal,fiy1);
1030 fiz1 = _mm_macc_pd(dz12,fscal,fiz1);
1032 fjx2 = _mm_macc_pd(dx12,fscal,fjx2);
1033 fjy2 = _mm_macc_pd(dy12,fscal,fjy2);
1034 fjz2 = _mm_macc_pd(dz12,fscal,fjz2);
1036 /**************************
1037 * CALCULATE INTERACTIONS *
1038 **************************/
1040 /* REACTION-FIELD ELECTROSTATICS */
1041 felec = _mm_mul_pd(qq13,_mm_msub_pd(rinv13,rinvsq13,krf2));
1045 /* Update vectorial force */
1046 fix1 = _mm_macc_pd(dx13,fscal,fix1);
1047 fiy1 = _mm_macc_pd(dy13,fscal,fiy1);
1048 fiz1 = _mm_macc_pd(dz13,fscal,fiz1);
1050 fjx3 = _mm_macc_pd(dx13,fscal,fjx3);
1051 fjy3 = _mm_macc_pd(dy13,fscal,fjy3);
1052 fjz3 = _mm_macc_pd(dz13,fscal,fjz3);
1054 /**************************
1055 * CALCULATE INTERACTIONS *
1056 **************************/
1058 /* REACTION-FIELD ELECTROSTATICS */
1059 felec = _mm_mul_pd(qq21,_mm_msub_pd(rinv21,rinvsq21,krf2));
1063 /* Update vectorial force */
1064 fix2 = _mm_macc_pd(dx21,fscal,fix2);
1065 fiy2 = _mm_macc_pd(dy21,fscal,fiy2);
1066 fiz2 = _mm_macc_pd(dz21,fscal,fiz2);
1068 fjx1 = _mm_macc_pd(dx21,fscal,fjx1);
1069 fjy1 = _mm_macc_pd(dy21,fscal,fjy1);
1070 fjz1 = _mm_macc_pd(dz21,fscal,fjz1);
1072 /**************************
1073 * CALCULATE INTERACTIONS *
1074 **************************/
1076 /* REACTION-FIELD ELECTROSTATICS */
1077 felec = _mm_mul_pd(qq22,_mm_msub_pd(rinv22,rinvsq22,krf2));
1081 /* Update vectorial force */
1082 fix2 = _mm_macc_pd(dx22,fscal,fix2);
1083 fiy2 = _mm_macc_pd(dy22,fscal,fiy2);
1084 fiz2 = _mm_macc_pd(dz22,fscal,fiz2);
1086 fjx2 = _mm_macc_pd(dx22,fscal,fjx2);
1087 fjy2 = _mm_macc_pd(dy22,fscal,fjy2);
1088 fjz2 = _mm_macc_pd(dz22,fscal,fjz2);
1090 /**************************
1091 * CALCULATE INTERACTIONS *
1092 **************************/
1094 /* REACTION-FIELD ELECTROSTATICS */
1095 felec = _mm_mul_pd(qq23,_mm_msub_pd(rinv23,rinvsq23,krf2));
1099 /* Update vectorial force */
1100 fix2 = _mm_macc_pd(dx23,fscal,fix2);
1101 fiy2 = _mm_macc_pd(dy23,fscal,fiy2);
1102 fiz2 = _mm_macc_pd(dz23,fscal,fiz2);
1104 fjx3 = _mm_macc_pd(dx23,fscal,fjx3);
1105 fjy3 = _mm_macc_pd(dy23,fscal,fjy3);
1106 fjz3 = _mm_macc_pd(dz23,fscal,fjz3);
1108 /**************************
1109 * CALCULATE INTERACTIONS *
1110 **************************/
1112 /* REACTION-FIELD ELECTROSTATICS */
1113 felec = _mm_mul_pd(qq31,_mm_msub_pd(rinv31,rinvsq31,krf2));
1117 /* Update vectorial force */
1118 fix3 = _mm_macc_pd(dx31,fscal,fix3);
1119 fiy3 = _mm_macc_pd(dy31,fscal,fiy3);
1120 fiz3 = _mm_macc_pd(dz31,fscal,fiz3);
1122 fjx1 = _mm_macc_pd(dx31,fscal,fjx1);
1123 fjy1 = _mm_macc_pd(dy31,fscal,fjy1);
1124 fjz1 = _mm_macc_pd(dz31,fscal,fjz1);
1126 /**************************
1127 * CALCULATE INTERACTIONS *
1128 **************************/
1130 /* REACTION-FIELD ELECTROSTATICS */
1131 felec = _mm_mul_pd(qq32,_mm_msub_pd(rinv32,rinvsq32,krf2));
1135 /* Update vectorial force */
1136 fix3 = _mm_macc_pd(dx32,fscal,fix3);
1137 fiy3 = _mm_macc_pd(dy32,fscal,fiy3);
1138 fiz3 = _mm_macc_pd(dz32,fscal,fiz3);
1140 fjx2 = _mm_macc_pd(dx32,fscal,fjx2);
1141 fjy2 = _mm_macc_pd(dy32,fscal,fjy2);
1142 fjz2 = _mm_macc_pd(dz32,fscal,fjz2);
1144 /**************************
1145 * CALCULATE INTERACTIONS *
1146 **************************/
1148 /* REACTION-FIELD ELECTROSTATICS */
1149 felec = _mm_mul_pd(qq33,_mm_msub_pd(rinv33,rinvsq33,krf2));
1153 /* Update vectorial force */
1154 fix3 = _mm_macc_pd(dx33,fscal,fix3);
1155 fiy3 = _mm_macc_pd(dy33,fscal,fiy3);
1156 fiz3 = _mm_macc_pd(dz33,fscal,fiz3);
1158 fjx3 = _mm_macc_pd(dx33,fscal,fjx3);
1159 fjy3 = _mm_macc_pd(dy33,fscal,fjy3);
1160 fjz3 = _mm_macc_pd(dz33,fscal,fjz3);
1162 gmx_mm_decrement_3rvec_2ptr_swizzle_pd(f+j_coord_offsetA+DIM,f+j_coord_offsetB+DIM,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
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+DIM,
1175 &jx1,&jy1,&jz1,&jx2,&jy2,&jz2,&jx3,&jy3,&jz3);
1177 /* Calculate displacement vector */
1178 dx11 = _mm_sub_pd(ix1,jx1);
1179 dy11 = _mm_sub_pd(iy1,jy1);
1180 dz11 = _mm_sub_pd(iz1,jz1);
1181 dx12 = _mm_sub_pd(ix1,jx2);
1182 dy12 = _mm_sub_pd(iy1,jy2);
1183 dz12 = _mm_sub_pd(iz1,jz2);
1184 dx13 = _mm_sub_pd(ix1,jx3);
1185 dy13 = _mm_sub_pd(iy1,jy3);
1186 dz13 = _mm_sub_pd(iz1,jz3);
1187 dx21 = _mm_sub_pd(ix2,jx1);
1188 dy21 = _mm_sub_pd(iy2,jy1);
1189 dz21 = _mm_sub_pd(iz2,jz1);
1190 dx22 = _mm_sub_pd(ix2,jx2);
1191 dy22 = _mm_sub_pd(iy2,jy2);
1192 dz22 = _mm_sub_pd(iz2,jz2);
1193 dx23 = _mm_sub_pd(ix2,jx3);
1194 dy23 = _mm_sub_pd(iy2,jy3);
1195 dz23 = _mm_sub_pd(iz2,jz3);
1196 dx31 = _mm_sub_pd(ix3,jx1);
1197 dy31 = _mm_sub_pd(iy3,jy1);
1198 dz31 = _mm_sub_pd(iz3,jz1);
1199 dx32 = _mm_sub_pd(ix3,jx2);
1200 dy32 = _mm_sub_pd(iy3,jy2);
1201 dz32 = _mm_sub_pd(iz3,jz2);
1202 dx33 = _mm_sub_pd(ix3,jx3);
1203 dy33 = _mm_sub_pd(iy3,jy3);
1204 dz33 = _mm_sub_pd(iz3,jz3);
1206 /* Calculate squared distance and things based on it */
1207 rsq11 = gmx_mm_calc_rsq_pd(dx11,dy11,dz11);
1208 rsq12 = gmx_mm_calc_rsq_pd(dx12,dy12,dz12);
1209 rsq13 = gmx_mm_calc_rsq_pd(dx13,dy13,dz13);
1210 rsq21 = gmx_mm_calc_rsq_pd(dx21,dy21,dz21);
1211 rsq22 = gmx_mm_calc_rsq_pd(dx22,dy22,dz22);
1212 rsq23 = gmx_mm_calc_rsq_pd(dx23,dy23,dz23);
1213 rsq31 = gmx_mm_calc_rsq_pd(dx31,dy31,dz31);
1214 rsq32 = gmx_mm_calc_rsq_pd(dx32,dy32,dz32);
1215 rsq33 = gmx_mm_calc_rsq_pd(dx33,dy33,dz33);
1217 rinv11 = gmx_mm_invsqrt_pd(rsq11);
1218 rinv12 = gmx_mm_invsqrt_pd(rsq12);
1219 rinv13 = gmx_mm_invsqrt_pd(rsq13);
1220 rinv21 = gmx_mm_invsqrt_pd(rsq21);
1221 rinv22 = gmx_mm_invsqrt_pd(rsq22);
1222 rinv23 = gmx_mm_invsqrt_pd(rsq23);
1223 rinv31 = gmx_mm_invsqrt_pd(rsq31);
1224 rinv32 = gmx_mm_invsqrt_pd(rsq32);
1225 rinv33 = gmx_mm_invsqrt_pd(rsq33);
1227 rinvsq11 = _mm_mul_pd(rinv11,rinv11);
1228 rinvsq12 = _mm_mul_pd(rinv12,rinv12);
1229 rinvsq13 = _mm_mul_pd(rinv13,rinv13);
1230 rinvsq21 = _mm_mul_pd(rinv21,rinv21);
1231 rinvsq22 = _mm_mul_pd(rinv22,rinv22);
1232 rinvsq23 = _mm_mul_pd(rinv23,rinv23);
1233 rinvsq31 = _mm_mul_pd(rinv31,rinv31);
1234 rinvsq32 = _mm_mul_pd(rinv32,rinv32);
1235 rinvsq33 = _mm_mul_pd(rinv33,rinv33);
1237 fjx1 = _mm_setzero_pd();
1238 fjy1 = _mm_setzero_pd();
1239 fjz1 = _mm_setzero_pd();
1240 fjx2 = _mm_setzero_pd();
1241 fjy2 = _mm_setzero_pd();
1242 fjz2 = _mm_setzero_pd();
1243 fjx3 = _mm_setzero_pd();
1244 fjy3 = _mm_setzero_pd();
1245 fjz3 = _mm_setzero_pd();
1247 /**************************
1248 * CALCULATE INTERACTIONS *
1249 **************************/
1251 /* REACTION-FIELD ELECTROSTATICS */
1252 felec = _mm_mul_pd(qq11,_mm_msub_pd(rinv11,rinvsq11,krf2));
1256 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1258 /* Update vectorial force */
1259 fix1 = _mm_macc_pd(dx11,fscal,fix1);
1260 fiy1 = _mm_macc_pd(dy11,fscal,fiy1);
1261 fiz1 = _mm_macc_pd(dz11,fscal,fiz1);
1263 fjx1 = _mm_macc_pd(dx11,fscal,fjx1);
1264 fjy1 = _mm_macc_pd(dy11,fscal,fjy1);
1265 fjz1 = _mm_macc_pd(dz11,fscal,fjz1);
1267 /**************************
1268 * CALCULATE INTERACTIONS *
1269 **************************/
1271 /* REACTION-FIELD ELECTROSTATICS */
1272 felec = _mm_mul_pd(qq12,_mm_msub_pd(rinv12,rinvsq12,krf2));
1276 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1278 /* Update vectorial force */
1279 fix1 = _mm_macc_pd(dx12,fscal,fix1);
1280 fiy1 = _mm_macc_pd(dy12,fscal,fiy1);
1281 fiz1 = _mm_macc_pd(dz12,fscal,fiz1);
1283 fjx2 = _mm_macc_pd(dx12,fscal,fjx2);
1284 fjy2 = _mm_macc_pd(dy12,fscal,fjy2);
1285 fjz2 = _mm_macc_pd(dz12,fscal,fjz2);
1287 /**************************
1288 * CALCULATE INTERACTIONS *
1289 **************************/
1291 /* REACTION-FIELD ELECTROSTATICS */
1292 felec = _mm_mul_pd(qq13,_mm_msub_pd(rinv13,rinvsq13,krf2));
1296 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1298 /* Update vectorial force */
1299 fix1 = _mm_macc_pd(dx13,fscal,fix1);
1300 fiy1 = _mm_macc_pd(dy13,fscal,fiy1);
1301 fiz1 = _mm_macc_pd(dz13,fscal,fiz1);
1303 fjx3 = _mm_macc_pd(dx13,fscal,fjx3);
1304 fjy3 = _mm_macc_pd(dy13,fscal,fjy3);
1305 fjz3 = _mm_macc_pd(dz13,fscal,fjz3);
1307 /**************************
1308 * CALCULATE INTERACTIONS *
1309 **************************/
1311 /* REACTION-FIELD ELECTROSTATICS */
1312 felec = _mm_mul_pd(qq21,_mm_msub_pd(rinv21,rinvsq21,krf2));
1316 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1318 /* Update vectorial force */
1319 fix2 = _mm_macc_pd(dx21,fscal,fix2);
1320 fiy2 = _mm_macc_pd(dy21,fscal,fiy2);
1321 fiz2 = _mm_macc_pd(dz21,fscal,fiz2);
1323 fjx1 = _mm_macc_pd(dx21,fscal,fjx1);
1324 fjy1 = _mm_macc_pd(dy21,fscal,fjy1);
1325 fjz1 = _mm_macc_pd(dz21,fscal,fjz1);
1327 /**************************
1328 * CALCULATE INTERACTIONS *
1329 **************************/
1331 /* REACTION-FIELD ELECTROSTATICS */
1332 felec = _mm_mul_pd(qq22,_mm_msub_pd(rinv22,rinvsq22,krf2));
1336 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1338 /* Update vectorial force */
1339 fix2 = _mm_macc_pd(dx22,fscal,fix2);
1340 fiy2 = _mm_macc_pd(dy22,fscal,fiy2);
1341 fiz2 = _mm_macc_pd(dz22,fscal,fiz2);
1343 fjx2 = _mm_macc_pd(dx22,fscal,fjx2);
1344 fjy2 = _mm_macc_pd(dy22,fscal,fjy2);
1345 fjz2 = _mm_macc_pd(dz22,fscal,fjz2);
1347 /**************************
1348 * CALCULATE INTERACTIONS *
1349 **************************/
1351 /* REACTION-FIELD ELECTROSTATICS */
1352 felec = _mm_mul_pd(qq23,_mm_msub_pd(rinv23,rinvsq23,krf2));
1356 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1358 /* Update vectorial force */
1359 fix2 = _mm_macc_pd(dx23,fscal,fix2);
1360 fiy2 = _mm_macc_pd(dy23,fscal,fiy2);
1361 fiz2 = _mm_macc_pd(dz23,fscal,fiz2);
1363 fjx3 = _mm_macc_pd(dx23,fscal,fjx3);
1364 fjy3 = _mm_macc_pd(dy23,fscal,fjy3);
1365 fjz3 = _mm_macc_pd(dz23,fscal,fjz3);
1367 /**************************
1368 * CALCULATE INTERACTIONS *
1369 **************************/
1371 /* REACTION-FIELD ELECTROSTATICS */
1372 felec = _mm_mul_pd(qq31,_mm_msub_pd(rinv31,rinvsq31,krf2));
1376 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1378 /* Update vectorial force */
1379 fix3 = _mm_macc_pd(dx31,fscal,fix3);
1380 fiy3 = _mm_macc_pd(dy31,fscal,fiy3);
1381 fiz3 = _mm_macc_pd(dz31,fscal,fiz3);
1383 fjx1 = _mm_macc_pd(dx31,fscal,fjx1);
1384 fjy1 = _mm_macc_pd(dy31,fscal,fjy1);
1385 fjz1 = _mm_macc_pd(dz31,fscal,fjz1);
1387 /**************************
1388 * CALCULATE INTERACTIONS *
1389 **************************/
1391 /* REACTION-FIELD ELECTROSTATICS */
1392 felec = _mm_mul_pd(qq32,_mm_msub_pd(rinv32,rinvsq32,krf2));
1396 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1398 /* Update vectorial force */
1399 fix3 = _mm_macc_pd(dx32,fscal,fix3);
1400 fiy3 = _mm_macc_pd(dy32,fscal,fiy3);
1401 fiz3 = _mm_macc_pd(dz32,fscal,fiz3);
1403 fjx2 = _mm_macc_pd(dx32,fscal,fjx2);
1404 fjy2 = _mm_macc_pd(dy32,fscal,fjy2);
1405 fjz2 = _mm_macc_pd(dz32,fscal,fjz2);
1407 /**************************
1408 * CALCULATE INTERACTIONS *
1409 **************************/
1411 /* REACTION-FIELD ELECTROSTATICS */
1412 felec = _mm_mul_pd(qq33,_mm_msub_pd(rinv33,rinvsq33,krf2));
1416 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1418 /* Update vectorial force */
1419 fix3 = _mm_macc_pd(dx33,fscal,fix3);
1420 fiy3 = _mm_macc_pd(dy33,fscal,fiy3);
1421 fiz3 = _mm_macc_pd(dz33,fscal,fiz3);
1423 fjx3 = _mm_macc_pd(dx33,fscal,fjx3);
1424 fjy3 = _mm_macc_pd(dy33,fscal,fjy3);
1425 fjz3 = _mm_macc_pd(dz33,fscal,fjz3);
1427 gmx_mm_decrement_3rvec_1ptr_swizzle_pd(f+j_coord_offsetA+DIM,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
1429 /* Inner loop uses 270 flops */
1432 /* End of innermost loop */
1434 gmx_mm_update_iforce_3atom_swizzle_pd(fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
1435 f+i_coord_offset+DIM,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_W4W4_F,outeriter*18 + inneriter*270);