2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
36 * Note: this file was generated by the GROMACS avx_128_fma_double kernel generator.
44 #include "../nb_kernel.h"
45 #include "types/simple.h"
49 #include "gmx_math_x86_avx_128_fma_double.h"
50 #include "kernelutil_x86_avx_128_fma_double.h"
53 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwNone_GeomW3W3_VF_avx_128_fma_double
54 * Electrostatics interaction: ReactionField
55 * VdW interaction: None
56 * Geometry: Water3-Water3
57 * Calculate force/pot: PotentialAndForce
60 nb_kernel_ElecRF_VdwNone_GeomW3W3_VF_avx_128_fma_double
61 (t_nblist * gmx_restrict nlist,
62 rvec * gmx_restrict xx,
63 rvec * gmx_restrict ff,
64 t_forcerec * gmx_restrict fr,
65 t_mdatoms * gmx_restrict mdatoms,
66 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
67 t_nrnb * gmx_restrict nrnb)
69 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
70 * just 0 for non-waters.
71 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
72 * jnr indices corresponding to data put in the four positions in the SIMD register.
74 int i_shift_offset,i_coord_offset,outeriter,inneriter;
75 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
77 int j_coord_offsetA,j_coord_offsetB;
78 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
80 real *shiftvec,*fshift,*x,*f;
81 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
83 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
85 __m128d ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
87 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
88 int vdwjidx0A,vdwjidx0B;
89 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
90 int vdwjidx1A,vdwjidx1B;
91 __m128d jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
92 int vdwjidx2A,vdwjidx2B;
93 __m128d jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
94 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
95 __m128d dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01;
96 __m128d dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02;
97 __m128d dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
98 __m128d dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
99 __m128d dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
100 __m128d dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
101 __m128d dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
102 __m128d dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
103 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
105 __m128d dummy_mask,cutoff_mask;
106 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
107 __m128d one = _mm_set1_pd(1.0);
108 __m128d two = _mm_set1_pd(2.0);
114 jindex = nlist->jindex;
116 shiftidx = nlist->shift;
118 shiftvec = fr->shift_vec[0];
119 fshift = fr->fshift[0];
120 facel = _mm_set1_pd(fr->epsfac);
121 charge = mdatoms->chargeA;
122 krf = _mm_set1_pd(fr->ic->k_rf);
123 krf2 = _mm_set1_pd(fr->ic->k_rf*2.0);
124 crf = _mm_set1_pd(fr->ic->c_rf);
126 /* Setup water-specific parameters */
127 inr = nlist->iinr[0];
128 iq0 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+0]));
129 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
130 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
132 jq0 = _mm_set1_pd(charge[inr+0]);
133 jq1 = _mm_set1_pd(charge[inr+1]);
134 jq2 = _mm_set1_pd(charge[inr+2]);
135 qq00 = _mm_mul_pd(iq0,jq0);
136 qq01 = _mm_mul_pd(iq0,jq1);
137 qq02 = _mm_mul_pd(iq0,jq2);
138 qq10 = _mm_mul_pd(iq1,jq0);
139 qq11 = _mm_mul_pd(iq1,jq1);
140 qq12 = _mm_mul_pd(iq1,jq2);
141 qq20 = _mm_mul_pd(iq2,jq0);
142 qq21 = _mm_mul_pd(iq2,jq1);
143 qq22 = _mm_mul_pd(iq2,jq2);
145 /* Avoid stupid compiler warnings */
153 /* Start outer loop over neighborlists */
154 for(iidx=0; iidx<nri; iidx++)
156 /* Load shift vector for this list */
157 i_shift_offset = DIM*shiftidx[iidx];
159 /* Load limits for loop over neighbors */
160 j_index_start = jindex[iidx];
161 j_index_end = jindex[iidx+1];
163 /* Get outer coordinate index */
165 i_coord_offset = DIM*inr;
167 /* Load i particle coords and add shift vector */
168 gmx_mm_load_shift_and_3rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,
169 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
171 fix0 = _mm_setzero_pd();
172 fiy0 = _mm_setzero_pd();
173 fiz0 = _mm_setzero_pd();
174 fix1 = _mm_setzero_pd();
175 fiy1 = _mm_setzero_pd();
176 fiz1 = _mm_setzero_pd();
177 fix2 = _mm_setzero_pd();
178 fiy2 = _mm_setzero_pd();
179 fiz2 = _mm_setzero_pd();
181 /* Reset potential sums */
182 velecsum = _mm_setzero_pd();
184 /* Start inner kernel loop */
185 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
188 /* Get j neighbor index, and coordinate index */
191 j_coord_offsetA = DIM*jnrA;
192 j_coord_offsetB = DIM*jnrB;
194 /* load j atom coordinates */
195 gmx_mm_load_3rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
196 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
198 /* Calculate displacement vector */
199 dx00 = _mm_sub_pd(ix0,jx0);
200 dy00 = _mm_sub_pd(iy0,jy0);
201 dz00 = _mm_sub_pd(iz0,jz0);
202 dx01 = _mm_sub_pd(ix0,jx1);
203 dy01 = _mm_sub_pd(iy0,jy1);
204 dz01 = _mm_sub_pd(iz0,jz1);
205 dx02 = _mm_sub_pd(ix0,jx2);
206 dy02 = _mm_sub_pd(iy0,jy2);
207 dz02 = _mm_sub_pd(iz0,jz2);
208 dx10 = _mm_sub_pd(ix1,jx0);
209 dy10 = _mm_sub_pd(iy1,jy0);
210 dz10 = _mm_sub_pd(iz1,jz0);
211 dx11 = _mm_sub_pd(ix1,jx1);
212 dy11 = _mm_sub_pd(iy1,jy1);
213 dz11 = _mm_sub_pd(iz1,jz1);
214 dx12 = _mm_sub_pd(ix1,jx2);
215 dy12 = _mm_sub_pd(iy1,jy2);
216 dz12 = _mm_sub_pd(iz1,jz2);
217 dx20 = _mm_sub_pd(ix2,jx0);
218 dy20 = _mm_sub_pd(iy2,jy0);
219 dz20 = _mm_sub_pd(iz2,jz0);
220 dx21 = _mm_sub_pd(ix2,jx1);
221 dy21 = _mm_sub_pd(iy2,jy1);
222 dz21 = _mm_sub_pd(iz2,jz1);
223 dx22 = _mm_sub_pd(ix2,jx2);
224 dy22 = _mm_sub_pd(iy2,jy2);
225 dz22 = _mm_sub_pd(iz2,jz2);
227 /* Calculate squared distance and things based on it */
228 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
229 rsq01 = gmx_mm_calc_rsq_pd(dx01,dy01,dz01);
230 rsq02 = gmx_mm_calc_rsq_pd(dx02,dy02,dz02);
231 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
232 rsq11 = gmx_mm_calc_rsq_pd(dx11,dy11,dz11);
233 rsq12 = gmx_mm_calc_rsq_pd(dx12,dy12,dz12);
234 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
235 rsq21 = gmx_mm_calc_rsq_pd(dx21,dy21,dz21);
236 rsq22 = gmx_mm_calc_rsq_pd(dx22,dy22,dz22);
238 rinv00 = gmx_mm_invsqrt_pd(rsq00);
239 rinv01 = gmx_mm_invsqrt_pd(rsq01);
240 rinv02 = gmx_mm_invsqrt_pd(rsq02);
241 rinv10 = gmx_mm_invsqrt_pd(rsq10);
242 rinv11 = gmx_mm_invsqrt_pd(rsq11);
243 rinv12 = gmx_mm_invsqrt_pd(rsq12);
244 rinv20 = gmx_mm_invsqrt_pd(rsq20);
245 rinv21 = gmx_mm_invsqrt_pd(rsq21);
246 rinv22 = gmx_mm_invsqrt_pd(rsq22);
248 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
249 rinvsq01 = _mm_mul_pd(rinv01,rinv01);
250 rinvsq02 = _mm_mul_pd(rinv02,rinv02);
251 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
252 rinvsq11 = _mm_mul_pd(rinv11,rinv11);
253 rinvsq12 = _mm_mul_pd(rinv12,rinv12);
254 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
255 rinvsq21 = _mm_mul_pd(rinv21,rinv21);
256 rinvsq22 = _mm_mul_pd(rinv22,rinv22);
258 fjx0 = _mm_setzero_pd();
259 fjy0 = _mm_setzero_pd();
260 fjz0 = _mm_setzero_pd();
261 fjx1 = _mm_setzero_pd();
262 fjy1 = _mm_setzero_pd();
263 fjz1 = _mm_setzero_pd();
264 fjx2 = _mm_setzero_pd();
265 fjy2 = _mm_setzero_pd();
266 fjz2 = _mm_setzero_pd();
268 /**************************
269 * CALCULATE INTERACTIONS *
270 **************************/
272 /* REACTION-FIELD ELECTROSTATICS */
273 velec = _mm_mul_pd(qq00,_mm_sub_pd(_mm_macc_pd(krf,rsq00,rinv00),crf));
274 felec = _mm_mul_pd(qq00,_mm_msub_pd(rinv00,rinvsq00,krf2));
276 /* Update potential sum for this i atom from the interaction with this j atom. */
277 velecsum = _mm_add_pd(velecsum,velec);
281 /* Update vectorial force */
282 fix0 = _mm_macc_pd(dx00,fscal,fix0);
283 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
284 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
286 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
287 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
288 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
290 /**************************
291 * CALCULATE INTERACTIONS *
292 **************************/
294 /* REACTION-FIELD ELECTROSTATICS */
295 velec = _mm_mul_pd(qq01,_mm_sub_pd(_mm_macc_pd(krf,rsq01,rinv01),crf));
296 felec = _mm_mul_pd(qq01,_mm_msub_pd(rinv01,rinvsq01,krf2));
298 /* Update potential sum for this i atom from the interaction with this j atom. */
299 velecsum = _mm_add_pd(velecsum,velec);
303 /* Update vectorial force */
304 fix0 = _mm_macc_pd(dx01,fscal,fix0);
305 fiy0 = _mm_macc_pd(dy01,fscal,fiy0);
306 fiz0 = _mm_macc_pd(dz01,fscal,fiz0);
308 fjx1 = _mm_macc_pd(dx01,fscal,fjx1);
309 fjy1 = _mm_macc_pd(dy01,fscal,fjy1);
310 fjz1 = _mm_macc_pd(dz01,fscal,fjz1);
312 /**************************
313 * CALCULATE INTERACTIONS *
314 **************************/
316 /* REACTION-FIELD ELECTROSTATICS */
317 velec = _mm_mul_pd(qq02,_mm_sub_pd(_mm_macc_pd(krf,rsq02,rinv02),crf));
318 felec = _mm_mul_pd(qq02,_mm_msub_pd(rinv02,rinvsq02,krf2));
320 /* Update potential sum for this i atom from the interaction with this j atom. */
321 velecsum = _mm_add_pd(velecsum,velec);
325 /* Update vectorial force */
326 fix0 = _mm_macc_pd(dx02,fscal,fix0);
327 fiy0 = _mm_macc_pd(dy02,fscal,fiy0);
328 fiz0 = _mm_macc_pd(dz02,fscal,fiz0);
330 fjx2 = _mm_macc_pd(dx02,fscal,fjx2);
331 fjy2 = _mm_macc_pd(dy02,fscal,fjy2);
332 fjz2 = _mm_macc_pd(dz02,fscal,fjz2);
334 /**************************
335 * CALCULATE INTERACTIONS *
336 **************************/
338 /* REACTION-FIELD ELECTROSTATICS */
339 velec = _mm_mul_pd(qq10,_mm_sub_pd(_mm_macc_pd(krf,rsq10,rinv10),crf));
340 felec = _mm_mul_pd(qq10,_mm_msub_pd(rinv10,rinvsq10,krf2));
342 /* Update potential sum for this i atom from the interaction with this j atom. */
343 velecsum = _mm_add_pd(velecsum,velec);
347 /* Update vectorial force */
348 fix1 = _mm_macc_pd(dx10,fscal,fix1);
349 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
350 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
352 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
353 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
354 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
356 /**************************
357 * CALCULATE INTERACTIONS *
358 **************************/
360 /* REACTION-FIELD ELECTROSTATICS */
361 velec = _mm_mul_pd(qq11,_mm_sub_pd(_mm_macc_pd(krf,rsq11,rinv11),crf));
362 felec = _mm_mul_pd(qq11,_mm_msub_pd(rinv11,rinvsq11,krf2));
364 /* Update potential sum for this i atom from the interaction with this j atom. */
365 velecsum = _mm_add_pd(velecsum,velec);
369 /* Update vectorial force */
370 fix1 = _mm_macc_pd(dx11,fscal,fix1);
371 fiy1 = _mm_macc_pd(dy11,fscal,fiy1);
372 fiz1 = _mm_macc_pd(dz11,fscal,fiz1);
374 fjx1 = _mm_macc_pd(dx11,fscal,fjx1);
375 fjy1 = _mm_macc_pd(dy11,fscal,fjy1);
376 fjz1 = _mm_macc_pd(dz11,fscal,fjz1);
378 /**************************
379 * CALCULATE INTERACTIONS *
380 **************************/
382 /* REACTION-FIELD ELECTROSTATICS */
383 velec = _mm_mul_pd(qq12,_mm_sub_pd(_mm_macc_pd(krf,rsq12,rinv12),crf));
384 felec = _mm_mul_pd(qq12,_mm_msub_pd(rinv12,rinvsq12,krf2));
386 /* Update potential sum for this i atom from the interaction with this j atom. */
387 velecsum = _mm_add_pd(velecsum,velec);
391 /* Update vectorial force */
392 fix1 = _mm_macc_pd(dx12,fscal,fix1);
393 fiy1 = _mm_macc_pd(dy12,fscal,fiy1);
394 fiz1 = _mm_macc_pd(dz12,fscal,fiz1);
396 fjx2 = _mm_macc_pd(dx12,fscal,fjx2);
397 fjy2 = _mm_macc_pd(dy12,fscal,fjy2);
398 fjz2 = _mm_macc_pd(dz12,fscal,fjz2);
400 /**************************
401 * CALCULATE INTERACTIONS *
402 **************************/
404 /* REACTION-FIELD ELECTROSTATICS */
405 velec = _mm_mul_pd(qq20,_mm_sub_pd(_mm_macc_pd(krf,rsq20,rinv20),crf));
406 felec = _mm_mul_pd(qq20,_mm_msub_pd(rinv20,rinvsq20,krf2));
408 /* Update potential sum for this i atom from the interaction with this j atom. */
409 velecsum = _mm_add_pd(velecsum,velec);
413 /* Update vectorial force */
414 fix2 = _mm_macc_pd(dx20,fscal,fix2);
415 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
416 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
418 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
419 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
420 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
422 /**************************
423 * CALCULATE INTERACTIONS *
424 **************************/
426 /* REACTION-FIELD ELECTROSTATICS */
427 velec = _mm_mul_pd(qq21,_mm_sub_pd(_mm_macc_pd(krf,rsq21,rinv21),crf));
428 felec = _mm_mul_pd(qq21,_mm_msub_pd(rinv21,rinvsq21,krf2));
430 /* Update potential sum for this i atom from the interaction with this j atom. */
431 velecsum = _mm_add_pd(velecsum,velec);
435 /* Update vectorial force */
436 fix2 = _mm_macc_pd(dx21,fscal,fix2);
437 fiy2 = _mm_macc_pd(dy21,fscal,fiy2);
438 fiz2 = _mm_macc_pd(dz21,fscal,fiz2);
440 fjx1 = _mm_macc_pd(dx21,fscal,fjx1);
441 fjy1 = _mm_macc_pd(dy21,fscal,fjy1);
442 fjz1 = _mm_macc_pd(dz21,fscal,fjz1);
444 /**************************
445 * CALCULATE INTERACTIONS *
446 **************************/
448 /* REACTION-FIELD ELECTROSTATICS */
449 velec = _mm_mul_pd(qq22,_mm_sub_pd(_mm_macc_pd(krf,rsq22,rinv22),crf));
450 felec = _mm_mul_pd(qq22,_mm_msub_pd(rinv22,rinvsq22,krf2));
452 /* Update potential sum for this i atom from the interaction with this j atom. */
453 velecsum = _mm_add_pd(velecsum,velec);
457 /* Update vectorial force */
458 fix2 = _mm_macc_pd(dx22,fscal,fix2);
459 fiy2 = _mm_macc_pd(dy22,fscal,fiy2);
460 fiz2 = _mm_macc_pd(dz22,fscal,fiz2);
462 fjx2 = _mm_macc_pd(dx22,fscal,fjx2);
463 fjy2 = _mm_macc_pd(dy22,fscal,fjy2);
464 fjz2 = _mm_macc_pd(dz22,fscal,fjz2);
466 gmx_mm_decrement_3rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
468 /* Inner loop uses 315 flops */
475 j_coord_offsetA = DIM*jnrA;
477 /* load j atom coordinates */
478 gmx_mm_load_3rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
479 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
481 /* Calculate displacement vector */
482 dx00 = _mm_sub_pd(ix0,jx0);
483 dy00 = _mm_sub_pd(iy0,jy0);
484 dz00 = _mm_sub_pd(iz0,jz0);
485 dx01 = _mm_sub_pd(ix0,jx1);
486 dy01 = _mm_sub_pd(iy0,jy1);
487 dz01 = _mm_sub_pd(iz0,jz1);
488 dx02 = _mm_sub_pd(ix0,jx2);
489 dy02 = _mm_sub_pd(iy0,jy2);
490 dz02 = _mm_sub_pd(iz0,jz2);
491 dx10 = _mm_sub_pd(ix1,jx0);
492 dy10 = _mm_sub_pd(iy1,jy0);
493 dz10 = _mm_sub_pd(iz1,jz0);
494 dx11 = _mm_sub_pd(ix1,jx1);
495 dy11 = _mm_sub_pd(iy1,jy1);
496 dz11 = _mm_sub_pd(iz1,jz1);
497 dx12 = _mm_sub_pd(ix1,jx2);
498 dy12 = _mm_sub_pd(iy1,jy2);
499 dz12 = _mm_sub_pd(iz1,jz2);
500 dx20 = _mm_sub_pd(ix2,jx0);
501 dy20 = _mm_sub_pd(iy2,jy0);
502 dz20 = _mm_sub_pd(iz2,jz0);
503 dx21 = _mm_sub_pd(ix2,jx1);
504 dy21 = _mm_sub_pd(iy2,jy1);
505 dz21 = _mm_sub_pd(iz2,jz1);
506 dx22 = _mm_sub_pd(ix2,jx2);
507 dy22 = _mm_sub_pd(iy2,jy2);
508 dz22 = _mm_sub_pd(iz2,jz2);
510 /* Calculate squared distance and things based on it */
511 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
512 rsq01 = gmx_mm_calc_rsq_pd(dx01,dy01,dz01);
513 rsq02 = gmx_mm_calc_rsq_pd(dx02,dy02,dz02);
514 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
515 rsq11 = gmx_mm_calc_rsq_pd(dx11,dy11,dz11);
516 rsq12 = gmx_mm_calc_rsq_pd(dx12,dy12,dz12);
517 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
518 rsq21 = gmx_mm_calc_rsq_pd(dx21,dy21,dz21);
519 rsq22 = gmx_mm_calc_rsq_pd(dx22,dy22,dz22);
521 rinv00 = gmx_mm_invsqrt_pd(rsq00);
522 rinv01 = gmx_mm_invsqrt_pd(rsq01);
523 rinv02 = gmx_mm_invsqrt_pd(rsq02);
524 rinv10 = gmx_mm_invsqrt_pd(rsq10);
525 rinv11 = gmx_mm_invsqrt_pd(rsq11);
526 rinv12 = gmx_mm_invsqrt_pd(rsq12);
527 rinv20 = gmx_mm_invsqrt_pd(rsq20);
528 rinv21 = gmx_mm_invsqrt_pd(rsq21);
529 rinv22 = gmx_mm_invsqrt_pd(rsq22);
531 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
532 rinvsq01 = _mm_mul_pd(rinv01,rinv01);
533 rinvsq02 = _mm_mul_pd(rinv02,rinv02);
534 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
535 rinvsq11 = _mm_mul_pd(rinv11,rinv11);
536 rinvsq12 = _mm_mul_pd(rinv12,rinv12);
537 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
538 rinvsq21 = _mm_mul_pd(rinv21,rinv21);
539 rinvsq22 = _mm_mul_pd(rinv22,rinv22);
541 fjx0 = _mm_setzero_pd();
542 fjy0 = _mm_setzero_pd();
543 fjz0 = _mm_setzero_pd();
544 fjx1 = _mm_setzero_pd();
545 fjy1 = _mm_setzero_pd();
546 fjz1 = _mm_setzero_pd();
547 fjx2 = _mm_setzero_pd();
548 fjy2 = _mm_setzero_pd();
549 fjz2 = _mm_setzero_pd();
551 /**************************
552 * CALCULATE INTERACTIONS *
553 **************************/
555 /* REACTION-FIELD ELECTROSTATICS */
556 velec = _mm_mul_pd(qq00,_mm_sub_pd(_mm_macc_pd(krf,rsq00,rinv00),crf));
557 felec = _mm_mul_pd(qq00,_mm_msub_pd(rinv00,rinvsq00,krf2));
559 /* Update potential sum for this i atom from the interaction with this j atom. */
560 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
561 velecsum = _mm_add_pd(velecsum,velec);
565 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
567 /* Update vectorial force */
568 fix0 = _mm_macc_pd(dx00,fscal,fix0);
569 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
570 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
572 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
573 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
574 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
576 /**************************
577 * CALCULATE INTERACTIONS *
578 **************************/
580 /* REACTION-FIELD ELECTROSTATICS */
581 velec = _mm_mul_pd(qq01,_mm_sub_pd(_mm_macc_pd(krf,rsq01,rinv01),crf));
582 felec = _mm_mul_pd(qq01,_mm_msub_pd(rinv01,rinvsq01,krf2));
584 /* Update potential sum for this i atom from the interaction with this j atom. */
585 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
586 velecsum = _mm_add_pd(velecsum,velec);
590 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
592 /* Update vectorial force */
593 fix0 = _mm_macc_pd(dx01,fscal,fix0);
594 fiy0 = _mm_macc_pd(dy01,fscal,fiy0);
595 fiz0 = _mm_macc_pd(dz01,fscal,fiz0);
597 fjx1 = _mm_macc_pd(dx01,fscal,fjx1);
598 fjy1 = _mm_macc_pd(dy01,fscal,fjy1);
599 fjz1 = _mm_macc_pd(dz01,fscal,fjz1);
601 /**************************
602 * CALCULATE INTERACTIONS *
603 **************************/
605 /* REACTION-FIELD ELECTROSTATICS */
606 velec = _mm_mul_pd(qq02,_mm_sub_pd(_mm_macc_pd(krf,rsq02,rinv02),crf));
607 felec = _mm_mul_pd(qq02,_mm_msub_pd(rinv02,rinvsq02,krf2));
609 /* Update potential sum for this i atom from the interaction with this j atom. */
610 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
611 velecsum = _mm_add_pd(velecsum,velec);
615 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
617 /* Update vectorial force */
618 fix0 = _mm_macc_pd(dx02,fscal,fix0);
619 fiy0 = _mm_macc_pd(dy02,fscal,fiy0);
620 fiz0 = _mm_macc_pd(dz02,fscal,fiz0);
622 fjx2 = _mm_macc_pd(dx02,fscal,fjx2);
623 fjy2 = _mm_macc_pd(dy02,fscal,fjy2);
624 fjz2 = _mm_macc_pd(dz02,fscal,fjz2);
626 /**************************
627 * CALCULATE INTERACTIONS *
628 **************************/
630 /* REACTION-FIELD ELECTROSTATICS */
631 velec = _mm_mul_pd(qq10,_mm_sub_pd(_mm_macc_pd(krf,rsq10,rinv10),crf));
632 felec = _mm_mul_pd(qq10,_mm_msub_pd(rinv10,rinvsq10,krf2));
634 /* Update potential sum for this i atom from the interaction with this j atom. */
635 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
636 velecsum = _mm_add_pd(velecsum,velec);
640 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
642 /* Update vectorial force */
643 fix1 = _mm_macc_pd(dx10,fscal,fix1);
644 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
645 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
647 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
648 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
649 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
651 /**************************
652 * CALCULATE INTERACTIONS *
653 **************************/
655 /* REACTION-FIELD ELECTROSTATICS */
656 velec = _mm_mul_pd(qq11,_mm_sub_pd(_mm_macc_pd(krf,rsq11,rinv11),crf));
657 felec = _mm_mul_pd(qq11,_mm_msub_pd(rinv11,rinvsq11,krf2));
659 /* Update potential sum for this i atom from the interaction with this j atom. */
660 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
661 velecsum = _mm_add_pd(velecsum,velec);
665 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
667 /* Update vectorial force */
668 fix1 = _mm_macc_pd(dx11,fscal,fix1);
669 fiy1 = _mm_macc_pd(dy11,fscal,fiy1);
670 fiz1 = _mm_macc_pd(dz11,fscal,fiz1);
672 fjx1 = _mm_macc_pd(dx11,fscal,fjx1);
673 fjy1 = _mm_macc_pd(dy11,fscal,fjy1);
674 fjz1 = _mm_macc_pd(dz11,fscal,fjz1);
676 /**************************
677 * CALCULATE INTERACTIONS *
678 **************************/
680 /* REACTION-FIELD ELECTROSTATICS */
681 velec = _mm_mul_pd(qq12,_mm_sub_pd(_mm_macc_pd(krf,rsq12,rinv12),crf));
682 felec = _mm_mul_pd(qq12,_mm_msub_pd(rinv12,rinvsq12,krf2));
684 /* Update potential sum for this i atom from the interaction with this j atom. */
685 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
686 velecsum = _mm_add_pd(velecsum,velec);
690 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
692 /* Update vectorial force */
693 fix1 = _mm_macc_pd(dx12,fscal,fix1);
694 fiy1 = _mm_macc_pd(dy12,fscal,fiy1);
695 fiz1 = _mm_macc_pd(dz12,fscal,fiz1);
697 fjx2 = _mm_macc_pd(dx12,fscal,fjx2);
698 fjy2 = _mm_macc_pd(dy12,fscal,fjy2);
699 fjz2 = _mm_macc_pd(dz12,fscal,fjz2);
701 /**************************
702 * CALCULATE INTERACTIONS *
703 **************************/
705 /* REACTION-FIELD ELECTROSTATICS */
706 velec = _mm_mul_pd(qq20,_mm_sub_pd(_mm_macc_pd(krf,rsq20,rinv20),crf));
707 felec = _mm_mul_pd(qq20,_mm_msub_pd(rinv20,rinvsq20,krf2));
709 /* Update potential sum for this i atom from the interaction with this j atom. */
710 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
711 velecsum = _mm_add_pd(velecsum,velec);
715 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
717 /* Update vectorial force */
718 fix2 = _mm_macc_pd(dx20,fscal,fix2);
719 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
720 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
722 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
723 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
724 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
726 /**************************
727 * CALCULATE INTERACTIONS *
728 **************************/
730 /* REACTION-FIELD ELECTROSTATICS */
731 velec = _mm_mul_pd(qq21,_mm_sub_pd(_mm_macc_pd(krf,rsq21,rinv21),crf));
732 felec = _mm_mul_pd(qq21,_mm_msub_pd(rinv21,rinvsq21,krf2));
734 /* Update potential sum for this i atom from the interaction with this j atom. */
735 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
736 velecsum = _mm_add_pd(velecsum,velec);
740 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
742 /* Update vectorial force */
743 fix2 = _mm_macc_pd(dx21,fscal,fix2);
744 fiy2 = _mm_macc_pd(dy21,fscal,fiy2);
745 fiz2 = _mm_macc_pd(dz21,fscal,fiz2);
747 fjx1 = _mm_macc_pd(dx21,fscal,fjx1);
748 fjy1 = _mm_macc_pd(dy21,fscal,fjy1);
749 fjz1 = _mm_macc_pd(dz21,fscal,fjz1);
751 /**************************
752 * CALCULATE INTERACTIONS *
753 **************************/
755 /* REACTION-FIELD ELECTROSTATICS */
756 velec = _mm_mul_pd(qq22,_mm_sub_pd(_mm_macc_pd(krf,rsq22,rinv22),crf));
757 felec = _mm_mul_pd(qq22,_mm_msub_pd(rinv22,rinvsq22,krf2));
759 /* Update potential sum for this i atom from the interaction with this j atom. */
760 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
761 velecsum = _mm_add_pd(velecsum,velec);
765 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
767 /* Update vectorial force */
768 fix2 = _mm_macc_pd(dx22,fscal,fix2);
769 fiy2 = _mm_macc_pd(dy22,fscal,fiy2);
770 fiz2 = _mm_macc_pd(dz22,fscal,fiz2);
772 fjx2 = _mm_macc_pd(dx22,fscal,fjx2);
773 fjy2 = _mm_macc_pd(dy22,fscal,fjy2);
774 fjz2 = _mm_macc_pd(dz22,fscal,fjz2);
776 gmx_mm_decrement_3rvec_1ptr_swizzle_pd(f+j_coord_offsetA,fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
778 /* Inner loop uses 315 flops */
781 /* End of innermost loop */
783 gmx_mm_update_iforce_3atom_swizzle_pd(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
784 f+i_coord_offset,fshift+i_shift_offset);
787 /* Update potential energies */
788 gmx_mm_update_1pot_pd(velecsum,kernel_data->energygrp_elec+ggid);
790 /* Increment number of inner iterations */
791 inneriter += j_index_end - j_index_start;
793 /* Outer loop uses 19 flops */
796 /* Increment number of outer iterations */
799 /* Update outer/inner flops */
801 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3W3_VF,outeriter*19 + inneriter*315);
804 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwNone_GeomW3W3_F_avx_128_fma_double
805 * Electrostatics interaction: ReactionField
806 * VdW interaction: None
807 * Geometry: Water3-Water3
808 * Calculate force/pot: Force
811 nb_kernel_ElecRF_VdwNone_GeomW3W3_F_avx_128_fma_double
812 (t_nblist * gmx_restrict nlist,
813 rvec * gmx_restrict xx,
814 rvec * gmx_restrict ff,
815 t_forcerec * gmx_restrict fr,
816 t_mdatoms * gmx_restrict mdatoms,
817 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
818 t_nrnb * gmx_restrict nrnb)
820 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
821 * just 0 for non-waters.
822 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
823 * jnr indices corresponding to data put in the four positions in the SIMD register.
825 int i_shift_offset,i_coord_offset,outeriter,inneriter;
826 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
828 int j_coord_offsetA,j_coord_offsetB;
829 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
831 real *shiftvec,*fshift,*x,*f;
832 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
834 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
836 __m128d ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
838 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
839 int vdwjidx0A,vdwjidx0B;
840 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
841 int vdwjidx1A,vdwjidx1B;
842 __m128d jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
843 int vdwjidx2A,vdwjidx2B;
844 __m128d jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
845 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
846 __m128d dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01;
847 __m128d dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02;
848 __m128d dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
849 __m128d dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
850 __m128d dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
851 __m128d dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
852 __m128d dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
853 __m128d dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
854 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
856 __m128d dummy_mask,cutoff_mask;
857 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
858 __m128d one = _mm_set1_pd(1.0);
859 __m128d two = _mm_set1_pd(2.0);
865 jindex = nlist->jindex;
867 shiftidx = nlist->shift;
869 shiftvec = fr->shift_vec[0];
870 fshift = fr->fshift[0];
871 facel = _mm_set1_pd(fr->epsfac);
872 charge = mdatoms->chargeA;
873 krf = _mm_set1_pd(fr->ic->k_rf);
874 krf2 = _mm_set1_pd(fr->ic->k_rf*2.0);
875 crf = _mm_set1_pd(fr->ic->c_rf);
877 /* Setup water-specific parameters */
878 inr = nlist->iinr[0];
879 iq0 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+0]));
880 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
881 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
883 jq0 = _mm_set1_pd(charge[inr+0]);
884 jq1 = _mm_set1_pd(charge[inr+1]);
885 jq2 = _mm_set1_pd(charge[inr+2]);
886 qq00 = _mm_mul_pd(iq0,jq0);
887 qq01 = _mm_mul_pd(iq0,jq1);
888 qq02 = _mm_mul_pd(iq0,jq2);
889 qq10 = _mm_mul_pd(iq1,jq0);
890 qq11 = _mm_mul_pd(iq1,jq1);
891 qq12 = _mm_mul_pd(iq1,jq2);
892 qq20 = _mm_mul_pd(iq2,jq0);
893 qq21 = _mm_mul_pd(iq2,jq1);
894 qq22 = _mm_mul_pd(iq2,jq2);
896 /* Avoid stupid compiler warnings */
904 /* Start outer loop over neighborlists */
905 for(iidx=0; iidx<nri; iidx++)
907 /* Load shift vector for this list */
908 i_shift_offset = DIM*shiftidx[iidx];
910 /* Load limits for loop over neighbors */
911 j_index_start = jindex[iidx];
912 j_index_end = jindex[iidx+1];
914 /* Get outer coordinate index */
916 i_coord_offset = DIM*inr;
918 /* Load i particle coords and add shift vector */
919 gmx_mm_load_shift_and_3rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,
920 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
922 fix0 = _mm_setzero_pd();
923 fiy0 = _mm_setzero_pd();
924 fiz0 = _mm_setzero_pd();
925 fix1 = _mm_setzero_pd();
926 fiy1 = _mm_setzero_pd();
927 fiz1 = _mm_setzero_pd();
928 fix2 = _mm_setzero_pd();
929 fiy2 = _mm_setzero_pd();
930 fiz2 = _mm_setzero_pd();
932 /* Start inner kernel loop */
933 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
936 /* Get j neighbor index, and coordinate index */
939 j_coord_offsetA = DIM*jnrA;
940 j_coord_offsetB = DIM*jnrB;
942 /* load j atom coordinates */
943 gmx_mm_load_3rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
944 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
946 /* Calculate displacement vector */
947 dx00 = _mm_sub_pd(ix0,jx0);
948 dy00 = _mm_sub_pd(iy0,jy0);
949 dz00 = _mm_sub_pd(iz0,jz0);
950 dx01 = _mm_sub_pd(ix0,jx1);
951 dy01 = _mm_sub_pd(iy0,jy1);
952 dz01 = _mm_sub_pd(iz0,jz1);
953 dx02 = _mm_sub_pd(ix0,jx2);
954 dy02 = _mm_sub_pd(iy0,jy2);
955 dz02 = _mm_sub_pd(iz0,jz2);
956 dx10 = _mm_sub_pd(ix1,jx0);
957 dy10 = _mm_sub_pd(iy1,jy0);
958 dz10 = _mm_sub_pd(iz1,jz0);
959 dx11 = _mm_sub_pd(ix1,jx1);
960 dy11 = _mm_sub_pd(iy1,jy1);
961 dz11 = _mm_sub_pd(iz1,jz1);
962 dx12 = _mm_sub_pd(ix1,jx2);
963 dy12 = _mm_sub_pd(iy1,jy2);
964 dz12 = _mm_sub_pd(iz1,jz2);
965 dx20 = _mm_sub_pd(ix2,jx0);
966 dy20 = _mm_sub_pd(iy2,jy0);
967 dz20 = _mm_sub_pd(iz2,jz0);
968 dx21 = _mm_sub_pd(ix2,jx1);
969 dy21 = _mm_sub_pd(iy2,jy1);
970 dz21 = _mm_sub_pd(iz2,jz1);
971 dx22 = _mm_sub_pd(ix2,jx2);
972 dy22 = _mm_sub_pd(iy2,jy2);
973 dz22 = _mm_sub_pd(iz2,jz2);
975 /* Calculate squared distance and things based on it */
976 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
977 rsq01 = gmx_mm_calc_rsq_pd(dx01,dy01,dz01);
978 rsq02 = gmx_mm_calc_rsq_pd(dx02,dy02,dz02);
979 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
980 rsq11 = gmx_mm_calc_rsq_pd(dx11,dy11,dz11);
981 rsq12 = gmx_mm_calc_rsq_pd(dx12,dy12,dz12);
982 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
983 rsq21 = gmx_mm_calc_rsq_pd(dx21,dy21,dz21);
984 rsq22 = gmx_mm_calc_rsq_pd(dx22,dy22,dz22);
986 rinv00 = gmx_mm_invsqrt_pd(rsq00);
987 rinv01 = gmx_mm_invsqrt_pd(rsq01);
988 rinv02 = gmx_mm_invsqrt_pd(rsq02);
989 rinv10 = gmx_mm_invsqrt_pd(rsq10);
990 rinv11 = gmx_mm_invsqrt_pd(rsq11);
991 rinv12 = gmx_mm_invsqrt_pd(rsq12);
992 rinv20 = gmx_mm_invsqrt_pd(rsq20);
993 rinv21 = gmx_mm_invsqrt_pd(rsq21);
994 rinv22 = gmx_mm_invsqrt_pd(rsq22);
996 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
997 rinvsq01 = _mm_mul_pd(rinv01,rinv01);
998 rinvsq02 = _mm_mul_pd(rinv02,rinv02);
999 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
1000 rinvsq11 = _mm_mul_pd(rinv11,rinv11);
1001 rinvsq12 = _mm_mul_pd(rinv12,rinv12);
1002 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
1003 rinvsq21 = _mm_mul_pd(rinv21,rinv21);
1004 rinvsq22 = _mm_mul_pd(rinv22,rinv22);
1006 fjx0 = _mm_setzero_pd();
1007 fjy0 = _mm_setzero_pd();
1008 fjz0 = _mm_setzero_pd();
1009 fjx1 = _mm_setzero_pd();
1010 fjy1 = _mm_setzero_pd();
1011 fjz1 = _mm_setzero_pd();
1012 fjx2 = _mm_setzero_pd();
1013 fjy2 = _mm_setzero_pd();
1014 fjz2 = _mm_setzero_pd();
1016 /**************************
1017 * CALCULATE INTERACTIONS *
1018 **************************/
1020 /* REACTION-FIELD ELECTROSTATICS */
1021 felec = _mm_mul_pd(qq00,_mm_msub_pd(rinv00,rinvsq00,krf2));
1025 /* Update vectorial force */
1026 fix0 = _mm_macc_pd(dx00,fscal,fix0);
1027 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
1028 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
1030 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
1031 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
1032 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
1034 /**************************
1035 * CALCULATE INTERACTIONS *
1036 **************************/
1038 /* REACTION-FIELD ELECTROSTATICS */
1039 felec = _mm_mul_pd(qq01,_mm_msub_pd(rinv01,rinvsq01,krf2));
1043 /* Update vectorial force */
1044 fix0 = _mm_macc_pd(dx01,fscal,fix0);
1045 fiy0 = _mm_macc_pd(dy01,fscal,fiy0);
1046 fiz0 = _mm_macc_pd(dz01,fscal,fiz0);
1048 fjx1 = _mm_macc_pd(dx01,fscal,fjx1);
1049 fjy1 = _mm_macc_pd(dy01,fscal,fjy1);
1050 fjz1 = _mm_macc_pd(dz01,fscal,fjz1);
1052 /**************************
1053 * CALCULATE INTERACTIONS *
1054 **************************/
1056 /* REACTION-FIELD ELECTROSTATICS */
1057 felec = _mm_mul_pd(qq02,_mm_msub_pd(rinv02,rinvsq02,krf2));
1061 /* Update vectorial force */
1062 fix0 = _mm_macc_pd(dx02,fscal,fix0);
1063 fiy0 = _mm_macc_pd(dy02,fscal,fiy0);
1064 fiz0 = _mm_macc_pd(dz02,fscal,fiz0);
1066 fjx2 = _mm_macc_pd(dx02,fscal,fjx2);
1067 fjy2 = _mm_macc_pd(dy02,fscal,fjy2);
1068 fjz2 = _mm_macc_pd(dz02,fscal,fjz2);
1070 /**************************
1071 * CALCULATE INTERACTIONS *
1072 **************************/
1074 /* REACTION-FIELD ELECTROSTATICS */
1075 felec = _mm_mul_pd(qq10,_mm_msub_pd(rinv10,rinvsq10,krf2));
1079 /* Update vectorial force */
1080 fix1 = _mm_macc_pd(dx10,fscal,fix1);
1081 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
1082 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
1084 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
1085 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
1086 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
1088 /**************************
1089 * CALCULATE INTERACTIONS *
1090 **************************/
1092 /* REACTION-FIELD ELECTROSTATICS */
1093 felec = _mm_mul_pd(qq11,_mm_msub_pd(rinv11,rinvsq11,krf2));
1097 /* Update vectorial force */
1098 fix1 = _mm_macc_pd(dx11,fscal,fix1);
1099 fiy1 = _mm_macc_pd(dy11,fscal,fiy1);
1100 fiz1 = _mm_macc_pd(dz11,fscal,fiz1);
1102 fjx1 = _mm_macc_pd(dx11,fscal,fjx1);
1103 fjy1 = _mm_macc_pd(dy11,fscal,fjy1);
1104 fjz1 = _mm_macc_pd(dz11,fscal,fjz1);
1106 /**************************
1107 * CALCULATE INTERACTIONS *
1108 **************************/
1110 /* REACTION-FIELD ELECTROSTATICS */
1111 felec = _mm_mul_pd(qq12,_mm_msub_pd(rinv12,rinvsq12,krf2));
1115 /* Update vectorial force */
1116 fix1 = _mm_macc_pd(dx12,fscal,fix1);
1117 fiy1 = _mm_macc_pd(dy12,fscal,fiy1);
1118 fiz1 = _mm_macc_pd(dz12,fscal,fiz1);
1120 fjx2 = _mm_macc_pd(dx12,fscal,fjx2);
1121 fjy2 = _mm_macc_pd(dy12,fscal,fjy2);
1122 fjz2 = _mm_macc_pd(dz12,fscal,fjz2);
1124 /**************************
1125 * CALCULATE INTERACTIONS *
1126 **************************/
1128 /* REACTION-FIELD ELECTROSTATICS */
1129 felec = _mm_mul_pd(qq20,_mm_msub_pd(rinv20,rinvsq20,krf2));
1133 /* Update vectorial force */
1134 fix2 = _mm_macc_pd(dx20,fscal,fix2);
1135 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
1136 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
1138 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
1139 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
1140 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
1142 /**************************
1143 * CALCULATE INTERACTIONS *
1144 **************************/
1146 /* REACTION-FIELD ELECTROSTATICS */
1147 felec = _mm_mul_pd(qq21,_mm_msub_pd(rinv21,rinvsq21,krf2));
1151 /* Update vectorial force */
1152 fix2 = _mm_macc_pd(dx21,fscal,fix2);
1153 fiy2 = _mm_macc_pd(dy21,fscal,fiy2);
1154 fiz2 = _mm_macc_pd(dz21,fscal,fiz2);
1156 fjx1 = _mm_macc_pd(dx21,fscal,fjx1);
1157 fjy1 = _mm_macc_pd(dy21,fscal,fjy1);
1158 fjz1 = _mm_macc_pd(dz21,fscal,fjz1);
1160 /**************************
1161 * CALCULATE INTERACTIONS *
1162 **************************/
1164 /* REACTION-FIELD ELECTROSTATICS */
1165 felec = _mm_mul_pd(qq22,_mm_msub_pd(rinv22,rinvsq22,krf2));
1169 /* Update vectorial force */
1170 fix2 = _mm_macc_pd(dx22,fscal,fix2);
1171 fiy2 = _mm_macc_pd(dy22,fscal,fiy2);
1172 fiz2 = _mm_macc_pd(dz22,fscal,fiz2);
1174 fjx2 = _mm_macc_pd(dx22,fscal,fjx2);
1175 fjy2 = _mm_macc_pd(dy22,fscal,fjy2);
1176 fjz2 = _mm_macc_pd(dz22,fscal,fjz2);
1178 gmx_mm_decrement_3rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
1180 /* Inner loop uses 270 flops */
1183 if(jidx<j_index_end)
1187 j_coord_offsetA = DIM*jnrA;
1189 /* load j atom coordinates */
1190 gmx_mm_load_3rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
1191 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
1193 /* Calculate displacement vector */
1194 dx00 = _mm_sub_pd(ix0,jx0);
1195 dy00 = _mm_sub_pd(iy0,jy0);
1196 dz00 = _mm_sub_pd(iz0,jz0);
1197 dx01 = _mm_sub_pd(ix0,jx1);
1198 dy01 = _mm_sub_pd(iy0,jy1);
1199 dz01 = _mm_sub_pd(iz0,jz1);
1200 dx02 = _mm_sub_pd(ix0,jx2);
1201 dy02 = _mm_sub_pd(iy0,jy2);
1202 dz02 = _mm_sub_pd(iz0,jz2);
1203 dx10 = _mm_sub_pd(ix1,jx0);
1204 dy10 = _mm_sub_pd(iy1,jy0);
1205 dz10 = _mm_sub_pd(iz1,jz0);
1206 dx11 = _mm_sub_pd(ix1,jx1);
1207 dy11 = _mm_sub_pd(iy1,jy1);
1208 dz11 = _mm_sub_pd(iz1,jz1);
1209 dx12 = _mm_sub_pd(ix1,jx2);
1210 dy12 = _mm_sub_pd(iy1,jy2);
1211 dz12 = _mm_sub_pd(iz1,jz2);
1212 dx20 = _mm_sub_pd(ix2,jx0);
1213 dy20 = _mm_sub_pd(iy2,jy0);
1214 dz20 = _mm_sub_pd(iz2,jz0);
1215 dx21 = _mm_sub_pd(ix2,jx1);
1216 dy21 = _mm_sub_pd(iy2,jy1);
1217 dz21 = _mm_sub_pd(iz2,jz1);
1218 dx22 = _mm_sub_pd(ix2,jx2);
1219 dy22 = _mm_sub_pd(iy2,jy2);
1220 dz22 = _mm_sub_pd(iz2,jz2);
1222 /* Calculate squared distance and things based on it */
1223 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
1224 rsq01 = gmx_mm_calc_rsq_pd(dx01,dy01,dz01);
1225 rsq02 = gmx_mm_calc_rsq_pd(dx02,dy02,dz02);
1226 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
1227 rsq11 = gmx_mm_calc_rsq_pd(dx11,dy11,dz11);
1228 rsq12 = gmx_mm_calc_rsq_pd(dx12,dy12,dz12);
1229 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
1230 rsq21 = gmx_mm_calc_rsq_pd(dx21,dy21,dz21);
1231 rsq22 = gmx_mm_calc_rsq_pd(dx22,dy22,dz22);
1233 rinv00 = gmx_mm_invsqrt_pd(rsq00);
1234 rinv01 = gmx_mm_invsqrt_pd(rsq01);
1235 rinv02 = gmx_mm_invsqrt_pd(rsq02);
1236 rinv10 = gmx_mm_invsqrt_pd(rsq10);
1237 rinv11 = gmx_mm_invsqrt_pd(rsq11);
1238 rinv12 = gmx_mm_invsqrt_pd(rsq12);
1239 rinv20 = gmx_mm_invsqrt_pd(rsq20);
1240 rinv21 = gmx_mm_invsqrt_pd(rsq21);
1241 rinv22 = gmx_mm_invsqrt_pd(rsq22);
1243 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
1244 rinvsq01 = _mm_mul_pd(rinv01,rinv01);
1245 rinvsq02 = _mm_mul_pd(rinv02,rinv02);
1246 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
1247 rinvsq11 = _mm_mul_pd(rinv11,rinv11);
1248 rinvsq12 = _mm_mul_pd(rinv12,rinv12);
1249 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
1250 rinvsq21 = _mm_mul_pd(rinv21,rinv21);
1251 rinvsq22 = _mm_mul_pd(rinv22,rinv22);
1253 fjx0 = _mm_setzero_pd();
1254 fjy0 = _mm_setzero_pd();
1255 fjz0 = _mm_setzero_pd();
1256 fjx1 = _mm_setzero_pd();
1257 fjy1 = _mm_setzero_pd();
1258 fjz1 = _mm_setzero_pd();
1259 fjx2 = _mm_setzero_pd();
1260 fjy2 = _mm_setzero_pd();
1261 fjz2 = _mm_setzero_pd();
1263 /**************************
1264 * CALCULATE INTERACTIONS *
1265 **************************/
1267 /* REACTION-FIELD ELECTROSTATICS */
1268 felec = _mm_mul_pd(qq00,_mm_msub_pd(rinv00,rinvsq00,krf2));
1272 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1274 /* Update vectorial force */
1275 fix0 = _mm_macc_pd(dx00,fscal,fix0);
1276 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
1277 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
1279 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
1280 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
1281 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
1283 /**************************
1284 * CALCULATE INTERACTIONS *
1285 **************************/
1287 /* REACTION-FIELD ELECTROSTATICS */
1288 felec = _mm_mul_pd(qq01,_mm_msub_pd(rinv01,rinvsq01,krf2));
1292 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1294 /* Update vectorial force */
1295 fix0 = _mm_macc_pd(dx01,fscal,fix0);
1296 fiy0 = _mm_macc_pd(dy01,fscal,fiy0);
1297 fiz0 = _mm_macc_pd(dz01,fscal,fiz0);
1299 fjx1 = _mm_macc_pd(dx01,fscal,fjx1);
1300 fjy1 = _mm_macc_pd(dy01,fscal,fjy1);
1301 fjz1 = _mm_macc_pd(dz01,fscal,fjz1);
1303 /**************************
1304 * CALCULATE INTERACTIONS *
1305 **************************/
1307 /* REACTION-FIELD ELECTROSTATICS */
1308 felec = _mm_mul_pd(qq02,_mm_msub_pd(rinv02,rinvsq02,krf2));
1312 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1314 /* Update vectorial force */
1315 fix0 = _mm_macc_pd(dx02,fscal,fix0);
1316 fiy0 = _mm_macc_pd(dy02,fscal,fiy0);
1317 fiz0 = _mm_macc_pd(dz02,fscal,fiz0);
1319 fjx2 = _mm_macc_pd(dx02,fscal,fjx2);
1320 fjy2 = _mm_macc_pd(dy02,fscal,fjy2);
1321 fjz2 = _mm_macc_pd(dz02,fscal,fjz2);
1323 /**************************
1324 * CALCULATE INTERACTIONS *
1325 **************************/
1327 /* REACTION-FIELD ELECTROSTATICS */
1328 felec = _mm_mul_pd(qq10,_mm_msub_pd(rinv10,rinvsq10,krf2));
1332 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1334 /* Update vectorial force */
1335 fix1 = _mm_macc_pd(dx10,fscal,fix1);
1336 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
1337 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
1339 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
1340 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
1341 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
1343 /**************************
1344 * CALCULATE INTERACTIONS *
1345 **************************/
1347 /* REACTION-FIELD ELECTROSTATICS */
1348 felec = _mm_mul_pd(qq11,_mm_msub_pd(rinv11,rinvsq11,krf2));
1352 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1354 /* Update vectorial force */
1355 fix1 = _mm_macc_pd(dx11,fscal,fix1);
1356 fiy1 = _mm_macc_pd(dy11,fscal,fiy1);
1357 fiz1 = _mm_macc_pd(dz11,fscal,fiz1);
1359 fjx1 = _mm_macc_pd(dx11,fscal,fjx1);
1360 fjy1 = _mm_macc_pd(dy11,fscal,fjy1);
1361 fjz1 = _mm_macc_pd(dz11,fscal,fjz1);
1363 /**************************
1364 * CALCULATE INTERACTIONS *
1365 **************************/
1367 /* REACTION-FIELD ELECTROSTATICS */
1368 felec = _mm_mul_pd(qq12,_mm_msub_pd(rinv12,rinvsq12,krf2));
1372 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1374 /* Update vectorial force */
1375 fix1 = _mm_macc_pd(dx12,fscal,fix1);
1376 fiy1 = _mm_macc_pd(dy12,fscal,fiy1);
1377 fiz1 = _mm_macc_pd(dz12,fscal,fiz1);
1379 fjx2 = _mm_macc_pd(dx12,fscal,fjx2);
1380 fjy2 = _mm_macc_pd(dy12,fscal,fjy2);
1381 fjz2 = _mm_macc_pd(dz12,fscal,fjz2);
1383 /**************************
1384 * CALCULATE INTERACTIONS *
1385 **************************/
1387 /* REACTION-FIELD ELECTROSTATICS */
1388 felec = _mm_mul_pd(qq20,_mm_msub_pd(rinv20,rinvsq20,krf2));
1392 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1394 /* Update vectorial force */
1395 fix2 = _mm_macc_pd(dx20,fscal,fix2);
1396 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
1397 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
1399 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
1400 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
1401 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
1403 /**************************
1404 * CALCULATE INTERACTIONS *
1405 **************************/
1407 /* REACTION-FIELD ELECTROSTATICS */
1408 felec = _mm_mul_pd(qq21,_mm_msub_pd(rinv21,rinvsq21,krf2));
1412 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1414 /* Update vectorial force */
1415 fix2 = _mm_macc_pd(dx21,fscal,fix2);
1416 fiy2 = _mm_macc_pd(dy21,fscal,fiy2);
1417 fiz2 = _mm_macc_pd(dz21,fscal,fiz2);
1419 fjx1 = _mm_macc_pd(dx21,fscal,fjx1);
1420 fjy1 = _mm_macc_pd(dy21,fscal,fjy1);
1421 fjz1 = _mm_macc_pd(dz21,fscal,fjz1);
1423 /**************************
1424 * CALCULATE INTERACTIONS *
1425 **************************/
1427 /* REACTION-FIELD ELECTROSTATICS */
1428 felec = _mm_mul_pd(qq22,_mm_msub_pd(rinv22,rinvsq22,krf2));
1432 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1434 /* Update vectorial force */
1435 fix2 = _mm_macc_pd(dx22,fscal,fix2);
1436 fiy2 = _mm_macc_pd(dy22,fscal,fiy2);
1437 fiz2 = _mm_macc_pd(dz22,fscal,fiz2);
1439 fjx2 = _mm_macc_pd(dx22,fscal,fjx2);
1440 fjy2 = _mm_macc_pd(dy22,fscal,fjy2);
1441 fjz2 = _mm_macc_pd(dz22,fscal,fjz2);
1443 gmx_mm_decrement_3rvec_1ptr_swizzle_pd(f+j_coord_offsetA,fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
1445 /* Inner loop uses 270 flops */
1448 /* End of innermost loop */
1450 gmx_mm_update_iforce_3atom_swizzle_pd(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
1451 f+i_coord_offset,fshift+i_shift_offset);
1453 /* Increment number of inner iterations */
1454 inneriter += j_index_end - j_index_start;
1456 /* Outer loop uses 18 flops */
1459 /* Increment number of outer iterations */
1462 /* Update outer/inner flops */
1464 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3W3_F,outeriter*18 + inneriter*270);