2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
36 * Note: this file was generated by the GROMACS avx_128_fma_double kernel generator.
42 #include "../nb_kernel.h"
43 #include "types/simple.h"
44 #include "gromacs/math/vec.h"
47 #include "gromacs/simd/math_x86_avx_128_fma_double.h"
48 #include "kernelutil_x86_avx_128_fma_double.h"
51 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwNone_GeomW4W4_VF_avx_128_fma_double
52 * Electrostatics interaction: ReactionField
53 * VdW interaction: None
54 * Geometry: Water4-Water4
55 * Calculate force/pot: PotentialAndForce
58 nb_kernel_ElecRF_VdwNone_GeomW4W4_VF_avx_128_fma_double
59 (t_nblist * gmx_restrict nlist,
60 rvec * gmx_restrict xx,
61 rvec * gmx_restrict ff,
62 t_forcerec * gmx_restrict fr,
63 t_mdatoms * gmx_restrict mdatoms,
64 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
65 t_nrnb * gmx_restrict nrnb)
67 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
68 * just 0 for non-waters.
69 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
70 * jnr indices corresponding to data put in the four positions in the SIMD register.
72 int i_shift_offset,i_coord_offset,outeriter,inneriter;
73 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
75 int j_coord_offsetA,j_coord_offsetB;
76 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
78 real *shiftvec,*fshift,*x,*f;
79 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
81 __m128d ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
83 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
85 __m128d ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
86 int vdwjidx1A,vdwjidx1B;
87 __m128d jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
88 int vdwjidx2A,vdwjidx2B;
89 __m128d jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
90 int vdwjidx3A,vdwjidx3B;
91 __m128d jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
92 __m128d dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
93 __m128d dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
94 __m128d dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13;
95 __m128d dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
96 __m128d dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
97 __m128d dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23;
98 __m128d dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31;
99 __m128d dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32;
100 __m128d dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33;
101 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
103 __m128d dummy_mask,cutoff_mask;
104 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
105 __m128d one = _mm_set1_pd(1.0);
106 __m128d two = _mm_set1_pd(2.0);
112 jindex = nlist->jindex;
114 shiftidx = nlist->shift;
116 shiftvec = fr->shift_vec[0];
117 fshift = fr->fshift[0];
118 facel = _mm_set1_pd(fr->epsfac);
119 charge = mdatoms->chargeA;
120 krf = _mm_set1_pd(fr->ic->k_rf);
121 krf2 = _mm_set1_pd(fr->ic->k_rf*2.0);
122 crf = _mm_set1_pd(fr->ic->c_rf);
124 /* Setup water-specific parameters */
125 inr = nlist->iinr[0];
126 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
127 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
128 iq3 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+3]));
130 jq1 = _mm_set1_pd(charge[inr+1]);
131 jq2 = _mm_set1_pd(charge[inr+2]);
132 jq3 = _mm_set1_pd(charge[inr+3]);
133 qq11 = _mm_mul_pd(iq1,jq1);
134 qq12 = _mm_mul_pd(iq1,jq2);
135 qq13 = _mm_mul_pd(iq1,jq3);
136 qq21 = _mm_mul_pd(iq2,jq1);
137 qq22 = _mm_mul_pd(iq2,jq2);
138 qq23 = _mm_mul_pd(iq2,jq3);
139 qq31 = _mm_mul_pd(iq3,jq1);
140 qq32 = _mm_mul_pd(iq3,jq2);
141 qq33 = _mm_mul_pd(iq3,jq3);
143 /* Avoid stupid compiler warnings */
151 /* Start outer loop over neighborlists */
152 for(iidx=0; iidx<nri; iidx++)
154 /* Load shift vector for this list */
155 i_shift_offset = DIM*shiftidx[iidx];
157 /* Load limits for loop over neighbors */
158 j_index_start = jindex[iidx];
159 j_index_end = jindex[iidx+1];
161 /* Get outer coordinate index */
163 i_coord_offset = DIM*inr;
165 /* Load i particle coords and add shift vector */
166 gmx_mm_load_shift_and_3rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset+DIM,
167 &ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
169 fix1 = _mm_setzero_pd();
170 fiy1 = _mm_setzero_pd();
171 fiz1 = _mm_setzero_pd();
172 fix2 = _mm_setzero_pd();
173 fiy2 = _mm_setzero_pd();
174 fiz2 = _mm_setzero_pd();
175 fix3 = _mm_setzero_pd();
176 fiy3 = _mm_setzero_pd();
177 fiz3 = _mm_setzero_pd();
179 /* Reset potential sums */
180 velecsum = _mm_setzero_pd();
182 /* Start inner kernel loop */
183 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
186 /* Get j neighbor index, and coordinate index */
189 j_coord_offsetA = DIM*jnrA;
190 j_coord_offsetB = DIM*jnrB;
192 /* load j atom coordinates */
193 gmx_mm_load_3rvec_2ptr_swizzle_pd(x+j_coord_offsetA+DIM,x+j_coord_offsetB+DIM,
194 &jx1,&jy1,&jz1,&jx2,&jy2,&jz2,&jx3,&jy3,&jz3);
196 /* Calculate displacement vector */
197 dx11 = _mm_sub_pd(ix1,jx1);
198 dy11 = _mm_sub_pd(iy1,jy1);
199 dz11 = _mm_sub_pd(iz1,jz1);
200 dx12 = _mm_sub_pd(ix1,jx2);
201 dy12 = _mm_sub_pd(iy1,jy2);
202 dz12 = _mm_sub_pd(iz1,jz2);
203 dx13 = _mm_sub_pd(ix1,jx3);
204 dy13 = _mm_sub_pd(iy1,jy3);
205 dz13 = _mm_sub_pd(iz1,jz3);
206 dx21 = _mm_sub_pd(ix2,jx1);
207 dy21 = _mm_sub_pd(iy2,jy1);
208 dz21 = _mm_sub_pd(iz2,jz1);
209 dx22 = _mm_sub_pd(ix2,jx2);
210 dy22 = _mm_sub_pd(iy2,jy2);
211 dz22 = _mm_sub_pd(iz2,jz2);
212 dx23 = _mm_sub_pd(ix2,jx3);
213 dy23 = _mm_sub_pd(iy2,jy3);
214 dz23 = _mm_sub_pd(iz2,jz3);
215 dx31 = _mm_sub_pd(ix3,jx1);
216 dy31 = _mm_sub_pd(iy3,jy1);
217 dz31 = _mm_sub_pd(iz3,jz1);
218 dx32 = _mm_sub_pd(ix3,jx2);
219 dy32 = _mm_sub_pd(iy3,jy2);
220 dz32 = _mm_sub_pd(iz3,jz2);
221 dx33 = _mm_sub_pd(ix3,jx3);
222 dy33 = _mm_sub_pd(iy3,jy3);
223 dz33 = _mm_sub_pd(iz3,jz3);
225 /* Calculate squared distance and things based on it */
226 rsq11 = gmx_mm_calc_rsq_pd(dx11,dy11,dz11);
227 rsq12 = gmx_mm_calc_rsq_pd(dx12,dy12,dz12);
228 rsq13 = gmx_mm_calc_rsq_pd(dx13,dy13,dz13);
229 rsq21 = gmx_mm_calc_rsq_pd(dx21,dy21,dz21);
230 rsq22 = gmx_mm_calc_rsq_pd(dx22,dy22,dz22);
231 rsq23 = gmx_mm_calc_rsq_pd(dx23,dy23,dz23);
232 rsq31 = gmx_mm_calc_rsq_pd(dx31,dy31,dz31);
233 rsq32 = gmx_mm_calc_rsq_pd(dx32,dy32,dz32);
234 rsq33 = gmx_mm_calc_rsq_pd(dx33,dy33,dz33);
236 rinv11 = gmx_mm_invsqrt_pd(rsq11);
237 rinv12 = gmx_mm_invsqrt_pd(rsq12);
238 rinv13 = gmx_mm_invsqrt_pd(rsq13);
239 rinv21 = gmx_mm_invsqrt_pd(rsq21);
240 rinv22 = gmx_mm_invsqrt_pd(rsq22);
241 rinv23 = gmx_mm_invsqrt_pd(rsq23);
242 rinv31 = gmx_mm_invsqrt_pd(rsq31);
243 rinv32 = gmx_mm_invsqrt_pd(rsq32);
244 rinv33 = gmx_mm_invsqrt_pd(rsq33);
246 rinvsq11 = _mm_mul_pd(rinv11,rinv11);
247 rinvsq12 = _mm_mul_pd(rinv12,rinv12);
248 rinvsq13 = _mm_mul_pd(rinv13,rinv13);
249 rinvsq21 = _mm_mul_pd(rinv21,rinv21);
250 rinvsq22 = _mm_mul_pd(rinv22,rinv22);
251 rinvsq23 = _mm_mul_pd(rinv23,rinv23);
252 rinvsq31 = _mm_mul_pd(rinv31,rinv31);
253 rinvsq32 = _mm_mul_pd(rinv32,rinv32);
254 rinvsq33 = _mm_mul_pd(rinv33,rinv33);
256 fjx1 = _mm_setzero_pd();
257 fjy1 = _mm_setzero_pd();
258 fjz1 = _mm_setzero_pd();
259 fjx2 = _mm_setzero_pd();
260 fjy2 = _mm_setzero_pd();
261 fjz2 = _mm_setzero_pd();
262 fjx3 = _mm_setzero_pd();
263 fjy3 = _mm_setzero_pd();
264 fjz3 = _mm_setzero_pd();
266 /**************************
267 * CALCULATE INTERACTIONS *
268 **************************/
270 /* REACTION-FIELD ELECTROSTATICS */
271 velec = _mm_mul_pd(qq11,_mm_sub_pd(_mm_macc_pd(krf,rsq11,rinv11),crf));
272 felec = _mm_mul_pd(qq11,_mm_msub_pd(rinv11,rinvsq11,krf2));
274 /* Update potential sum for this i atom from the interaction with this j atom. */
275 velecsum = _mm_add_pd(velecsum,velec);
279 /* Update vectorial force */
280 fix1 = _mm_macc_pd(dx11,fscal,fix1);
281 fiy1 = _mm_macc_pd(dy11,fscal,fiy1);
282 fiz1 = _mm_macc_pd(dz11,fscal,fiz1);
284 fjx1 = _mm_macc_pd(dx11,fscal,fjx1);
285 fjy1 = _mm_macc_pd(dy11,fscal,fjy1);
286 fjz1 = _mm_macc_pd(dz11,fscal,fjz1);
288 /**************************
289 * CALCULATE INTERACTIONS *
290 **************************/
292 /* REACTION-FIELD ELECTROSTATICS */
293 velec = _mm_mul_pd(qq12,_mm_sub_pd(_mm_macc_pd(krf,rsq12,rinv12),crf));
294 felec = _mm_mul_pd(qq12,_mm_msub_pd(rinv12,rinvsq12,krf2));
296 /* Update potential sum for this i atom from the interaction with this j atom. */
297 velecsum = _mm_add_pd(velecsum,velec);
301 /* Update vectorial force */
302 fix1 = _mm_macc_pd(dx12,fscal,fix1);
303 fiy1 = _mm_macc_pd(dy12,fscal,fiy1);
304 fiz1 = _mm_macc_pd(dz12,fscal,fiz1);
306 fjx2 = _mm_macc_pd(dx12,fscal,fjx2);
307 fjy2 = _mm_macc_pd(dy12,fscal,fjy2);
308 fjz2 = _mm_macc_pd(dz12,fscal,fjz2);
310 /**************************
311 * CALCULATE INTERACTIONS *
312 **************************/
314 /* REACTION-FIELD ELECTROSTATICS */
315 velec = _mm_mul_pd(qq13,_mm_sub_pd(_mm_macc_pd(krf,rsq13,rinv13),crf));
316 felec = _mm_mul_pd(qq13,_mm_msub_pd(rinv13,rinvsq13,krf2));
318 /* Update potential sum for this i atom from the interaction with this j atom. */
319 velecsum = _mm_add_pd(velecsum,velec);
323 /* Update vectorial force */
324 fix1 = _mm_macc_pd(dx13,fscal,fix1);
325 fiy1 = _mm_macc_pd(dy13,fscal,fiy1);
326 fiz1 = _mm_macc_pd(dz13,fscal,fiz1);
328 fjx3 = _mm_macc_pd(dx13,fscal,fjx3);
329 fjy3 = _mm_macc_pd(dy13,fscal,fjy3);
330 fjz3 = _mm_macc_pd(dz13,fscal,fjz3);
332 /**************************
333 * CALCULATE INTERACTIONS *
334 **************************/
336 /* REACTION-FIELD ELECTROSTATICS */
337 velec = _mm_mul_pd(qq21,_mm_sub_pd(_mm_macc_pd(krf,rsq21,rinv21),crf));
338 felec = _mm_mul_pd(qq21,_mm_msub_pd(rinv21,rinvsq21,krf2));
340 /* Update potential sum for this i atom from the interaction with this j atom. */
341 velecsum = _mm_add_pd(velecsum,velec);
345 /* Update vectorial force */
346 fix2 = _mm_macc_pd(dx21,fscal,fix2);
347 fiy2 = _mm_macc_pd(dy21,fscal,fiy2);
348 fiz2 = _mm_macc_pd(dz21,fscal,fiz2);
350 fjx1 = _mm_macc_pd(dx21,fscal,fjx1);
351 fjy1 = _mm_macc_pd(dy21,fscal,fjy1);
352 fjz1 = _mm_macc_pd(dz21,fscal,fjz1);
354 /**************************
355 * CALCULATE INTERACTIONS *
356 **************************/
358 /* REACTION-FIELD ELECTROSTATICS */
359 velec = _mm_mul_pd(qq22,_mm_sub_pd(_mm_macc_pd(krf,rsq22,rinv22),crf));
360 felec = _mm_mul_pd(qq22,_mm_msub_pd(rinv22,rinvsq22,krf2));
362 /* Update potential sum for this i atom from the interaction with this j atom. */
363 velecsum = _mm_add_pd(velecsum,velec);
367 /* Update vectorial force */
368 fix2 = _mm_macc_pd(dx22,fscal,fix2);
369 fiy2 = _mm_macc_pd(dy22,fscal,fiy2);
370 fiz2 = _mm_macc_pd(dz22,fscal,fiz2);
372 fjx2 = _mm_macc_pd(dx22,fscal,fjx2);
373 fjy2 = _mm_macc_pd(dy22,fscal,fjy2);
374 fjz2 = _mm_macc_pd(dz22,fscal,fjz2);
376 /**************************
377 * CALCULATE INTERACTIONS *
378 **************************/
380 /* REACTION-FIELD ELECTROSTATICS */
381 velec = _mm_mul_pd(qq23,_mm_sub_pd(_mm_macc_pd(krf,rsq23,rinv23),crf));
382 felec = _mm_mul_pd(qq23,_mm_msub_pd(rinv23,rinvsq23,krf2));
384 /* Update potential sum for this i atom from the interaction with this j atom. */
385 velecsum = _mm_add_pd(velecsum,velec);
389 /* Update vectorial force */
390 fix2 = _mm_macc_pd(dx23,fscal,fix2);
391 fiy2 = _mm_macc_pd(dy23,fscal,fiy2);
392 fiz2 = _mm_macc_pd(dz23,fscal,fiz2);
394 fjx3 = _mm_macc_pd(dx23,fscal,fjx3);
395 fjy3 = _mm_macc_pd(dy23,fscal,fjy3);
396 fjz3 = _mm_macc_pd(dz23,fscal,fjz3);
398 /**************************
399 * CALCULATE INTERACTIONS *
400 **************************/
402 /* REACTION-FIELD ELECTROSTATICS */
403 velec = _mm_mul_pd(qq31,_mm_sub_pd(_mm_macc_pd(krf,rsq31,rinv31),crf));
404 felec = _mm_mul_pd(qq31,_mm_msub_pd(rinv31,rinvsq31,krf2));
406 /* Update potential sum for this i atom from the interaction with this j atom. */
407 velecsum = _mm_add_pd(velecsum,velec);
411 /* Update vectorial force */
412 fix3 = _mm_macc_pd(dx31,fscal,fix3);
413 fiy3 = _mm_macc_pd(dy31,fscal,fiy3);
414 fiz3 = _mm_macc_pd(dz31,fscal,fiz3);
416 fjx1 = _mm_macc_pd(dx31,fscal,fjx1);
417 fjy1 = _mm_macc_pd(dy31,fscal,fjy1);
418 fjz1 = _mm_macc_pd(dz31,fscal,fjz1);
420 /**************************
421 * CALCULATE INTERACTIONS *
422 **************************/
424 /* REACTION-FIELD ELECTROSTATICS */
425 velec = _mm_mul_pd(qq32,_mm_sub_pd(_mm_macc_pd(krf,rsq32,rinv32),crf));
426 felec = _mm_mul_pd(qq32,_mm_msub_pd(rinv32,rinvsq32,krf2));
428 /* Update potential sum for this i atom from the interaction with this j atom. */
429 velecsum = _mm_add_pd(velecsum,velec);
433 /* Update vectorial force */
434 fix3 = _mm_macc_pd(dx32,fscal,fix3);
435 fiy3 = _mm_macc_pd(dy32,fscal,fiy3);
436 fiz3 = _mm_macc_pd(dz32,fscal,fiz3);
438 fjx2 = _mm_macc_pd(dx32,fscal,fjx2);
439 fjy2 = _mm_macc_pd(dy32,fscal,fjy2);
440 fjz2 = _mm_macc_pd(dz32,fscal,fjz2);
442 /**************************
443 * CALCULATE INTERACTIONS *
444 **************************/
446 /* REACTION-FIELD ELECTROSTATICS */
447 velec = _mm_mul_pd(qq33,_mm_sub_pd(_mm_macc_pd(krf,rsq33,rinv33),crf));
448 felec = _mm_mul_pd(qq33,_mm_msub_pd(rinv33,rinvsq33,krf2));
450 /* Update potential sum for this i atom from the interaction with this j atom. */
451 velecsum = _mm_add_pd(velecsum,velec);
455 /* Update vectorial force */
456 fix3 = _mm_macc_pd(dx33,fscal,fix3);
457 fiy3 = _mm_macc_pd(dy33,fscal,fiy3);
458 fiz3 = _mm_macc_pd(dz33,fscal,fiz3);
460 fjx3 = _mm_macc_pd(dx33,fscal,fjx3);
461 fjy3 = _mm_macc_pd(dy33,fscal,fjy3);
462 fjz3 = _mm_macc_pd(dz33,fscal,fjz3);
464 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);
466 /* Inner loop uses 315 flops */
473 j_coord_offsetA = DIM*jnrA;
475 /* load j atom coordinates */
476 gmx_mm_load_3rvec_1ptr_swizzle_pd(x+j_coord_offsetA+DIM,
477 &jx1,&jy1,&jz1,&jx2,&jy2,&jz2,&jx3,&jy3,&jz3);
479 /* Calculate displacement vector */
480 dx11 = _mm_sub_pd(ix1,jx1);
481 dy11 = _mm_sub_pd(iy1,jy1);
482 dz11 = _mm_sub_pd(iz1,jz1);
483 dx12 = _mm_sub_pd(ix1,jx2);
484 dy12 = _mm_sub_pd(iy1,jy2);
485 dz12 = _mm_sub_pd(iz1,jz2);
486 dx13 = _mm_sub_pd(ix1,jx3);
487 dy13 = _mm_sub_pd(iy1,jy3);
488 dz13 = _mm_sub_pd(iz1,jz3);
489 dx21 = _mm_sub_pd(ix2,jx1);
490 dy21 = _mm_sub_pd(iy2,jy1);
491 dz21 = _mm_sub_pd(iz2,jz1);
492 dx22 = _mm_sub_pd(ix2,jx2);
493 dy22 = _mm_sub_pd(iy2,jy2);
494 dz22 = _mm_sub_pd(iz2,jz2);
495 dx23 = _mm_sub_pd(ix2,jx3);
496 dy23 = _mm_sub_pd(iy2,jy3);
497 dz23 = _mm_sub_pd(iz2,jz3);
498 dx31 = _mm_sub_pd(ix3,jx1);
499 dy31 = _mm_sub_pd(iy3,jy1);
500 dz31 = _mm_sub_pd(iz3,jz1);
501 dx32 = _mm_sub_pd(ix3,jx2);
502 dy32 = _mm_sub_pd(iy3,jy2);
503 dz32 = _mm_sub_pd(iz3,jz2);
504 dx33 = _mm_sub_pd(ix3,jx3);
505 dy33 = _mm_sub_pd(iy3,jy3);
506 dz33 = _mm_sub_pd(iz3,jz3);
508 /* Calculate squared distance and things based on it */
509 rsq11 = gmx_mm_calc_rsq_pd(dx11,dy11,dz11);
510 rsq12 = gmx_mm_calc_rsq_pd(dx12,dy12,dz12);
511 rsq13 = gmx_mm_calc_rsq_pd(dx13,dy13,dz13);
512 rsq21 = gmx_mm_calc_rsq_pd(dx21,dy21,dz21);
513 rsq22 = gmx_mm_calc_rsq_pd(dx22,dy22,dz22);
514 rsq23 = gmx_mm_calc_rsq_pd(dx23,dy23,dz23);
515 rsq31 = gmx_mm_calc_rsq_pd(dx31,dy31,dz31);
516 rsq32 = gmx_mm_calc_rsq_pd(dx32,dy32,dz32);
517 rsq33 = gmx_mm_calc_rsq_pd(dx33,dy33,dz33);
519 rinv11 = gmx_mm_invsqrt_pd(rsq11);
520 rinv12 = gmx_mm_invsqrt_pd(rsq12);
521 rinv13 = gmx_mm_invsqrt_pd(rsq13);
522 rinv21 = gmx_mm_invsqrt_pd(rsq21);
523 rinv22 = gmx_mm_invsqrt_pd(rsq22);
524 rinv23 = gmx_mm_invsqrt_pd(rsq23);
525 rinv31 = gmx_mm_invsqrt_pd(rsq31);
526 rinv32 = gmx_mm_invsqrt_pd(rsq32);
527 rinv33 = gmx_mm_invsqrt_pd(rsq33);
529 rinvsq11 = _mm_mul_pd(rinv11,rinv11);
530 rinvsq12 = _mm_mul_pd(rinv12,rinv12);
531 rinvsq13 = _mm_mul_pd(rinv13,rinv13);
532 rinvsq21 = _mm_mul_pd(rinv21,rinv21);
533 rinvsq22 = _mm_mul_pd(rinv22,rinv22);
534 rinvsq23 = _mm_mul_pd(rinv23,rinv23);
535 rinvsq31 = _mm_mul_pd(rinv31,rinv31);
536 rinvsq32 = _mm_mul_pd(rinv32,rinv32);
537 rinvsq33 = _mm_mul_pd(rinv33,rinv33);
539 fjx1 = _mm_setzero_pd();
540 fjy1 = _mm_setzero_pd();
541 fjz1 = _mm_setzero_pd();
542 fjx2 = _mm_setzero_pd();
543 fjy2 = _mm_setzero_pd();
544 fjz2 = _mm_setzero_pd();
545 fjx3 = _mm_setzero_pd();
546 fjy3 = _mm_setzero_pd();
547 fjz3 = _mm_setzero_pd();
549 /**************************
550 * CALCULATE INTERACTIONS *
551 **************************/
553 /* REACTION-FIELD ELECTROSTATICS */
554 velec = _mm_mul_pd(qq11,_mm_sub_pd(_mm_macc_pd(krf,rsq11,rinv11),crf));
555 felec = _mm_mul_pd(qq11,_mm_msub_pd(rinv11,rinvsq11,krf2));
557 /* Update potential sum for this i atom from the interaction with this j atom. */
558 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
559 velecsum = _mm_add_pd(velecsum,velec);
563 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
565 /* Update vectorial force */
566 fix1 = _mm_macc_pd(dx11,fscal,fix1);
567 fiy1 = _mm_macc_pd(dy11,fscal,fiy1);
568 fiz1 = _mm_macc_pd(dz11,fscal,fiz1);
570 fjx1 = _mm_macc_pd(dx11,fscal,fjx1);
571 fjy1 = _mm_macc_pd(dy11,fscal,fjy1);
572 fjz1 = _mm_macc_pd(dz11,fscal,fjz1);
574 /**************************
575 * CALCULATE INTERACTIONS *
576 **************************/
578 /* REACTION-FIELD ELECTROSTATICS */
579 velec = _mm_mul_pd(qq12,_mm_sub_pd(_mm_macc_pd(krf,rsq12,rinv12),crf));
580 felec = _mm_mul_pd(qq12,_mm_msub_pd(rinv12,rinvsq12,krf2));
582 /* Update potential sum for this i atom from the interaction with this j atom. */
583 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
584 velecsum = _mm_add_pd(velecsum,velec);
588 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
590 /* Update vectorial force */
591 fix1 = _mm_macc_pd(dx12,fscal,fix1);
592 fiy1 = _mm_macc_pd(dy12,fscal,fiy1);
593 fiz1 = _mm_macc_pd(dz12,fscal,fiz1);
595 fjx2 = _mm_macc_pd(dx12,fscal,fjx2);
596 fjy2 = _mm_macc_pd(dy12,fscal,fjy2);
597 fjz2 = _mm_macc_pd(dz12,fscal,fjz2);
599 /**************************
600 * CALCULATE INTERACTIONS *
601 **************************/
603 /* REACTION-FIELD ELECTROSTATICS */
604 velec = _mm_mul_pd(qq13,_mm_sub_pd(_mm_macc_pd(krf,rsq13,rinv13),crf));
605 felec = _mm_mul_pd(qq13,_mm_msub_pd(rinv13,rinvsq13,krf2));
607 /* Update potential sum for this i atom from the interaction with this j atom. */
608 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
609 velecsum = _mm_add_pd(velecsum,velec);
613 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
615 /* Update vectorial force */
616 fix1 = _mm_macc_pd(dx13,fscal,fix1);
617 fiy1 = _mm_macc_pd(dy13,fscal,fiy1);
618 fiz1 = _mm_macc_pd(dz13,fscal,fiz1);
620 fjx3 = _mm_macc_pd(dx13,fscal,fjx3);
621 fjy3 = _mm_macc_pd(dy13,fscal,fjy3);
622 fjz3 = _mm_macc_pd(dz13,fscal,fjz3);
624 /**************************
625 * CALCULATE INTERACTIONS *
626 **************************/
628 /* REACTION-FIELD ELECTROSTATICS */
629 velec = _mm_mul_pd(qq21,_mm_sub_pd(_mm_macc_pd(krf,rsq21,rinv21),crf));
630 felec = _mm_mul_pd(qq21,_mm_msub_pd(rinv21,rinvsq21,krf2));
632 /* Update potential sum for this i atom from the interaction with this j atom. */
633 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
634 velecsum = _mm_add_pd(velecsum,velec);
638 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
640 /* Update vectorial force */
641 fix2 = _mm_macc_pd(dx21,fscal,fix2);
642 fiy2 = _mm_macc_pd(dy21,fscal,fiy2);
643 fiz2 = _mm_macc_pd(dz21,fscal,fiz2);
645 fjx1 = _mm_macc_pd(dx21,fscal,fjx1);
646 fjy1 = _mm_macc_pd(dy21,fscal,fjy1);
647 fjz1 = _mm_macc_pd(dz21,fscal,fjz1);
649 /**************************
650 * CALCULATE INTERACTIONS *
651 **************************/
653 /* REACTION-FIELD ELECTROSTATICS */
654 velec = _mm_mul_pd(qq22,_mm_sub_pd(_mm_macc_pd(krf,rsq22,rinv22),crf));
655 felec = _mm_mul_pd(qq22,_mm_msub_pd(rinv22,rinvsq22,krf2));
657 /* Update potential sum for this i atom from the interaction with this j atom. */
658 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
659 velecsum = _mm_add_pd(velecsum,velec);
663 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
665 /* Update vectorial force */
666 fix2 = _mm_macc_pd(dx22,fscal,fix2);
667 fiy2 = _mm_macc_pd(dy22,fscal,fiy2);
668 fiz2 = _mm_macc_pd(dz22,fscal,fiz2);
670 fjx2 = _mm_macc_pd(dx22,fscal,fjx2);
671 fjy2 = _mm_macc_pd(dy22,fscal,fjy2);
672 fjz2 = _mm_macc_pd(dz22,fscal,fjz2);
674 /**************************
675 * CALCULATE INTERACTIONS *
676 **************************/
678 /* REACTION-FIELD ELECTROSTATICS */
679 velec = _mm_mul_pd(qq23,_mm_sub_pd(_mm_macc_pd(krf,rsq23,rinv23),crf));
680 felec = _mm_mul_pd(qq23,_mm_msub_pd(rinv23,rinvsq23,krf2));
682 /* Update potential sum for this i atom from the interaction with this j atom. */
683 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
684 velecsum = _mm_add_pd(velecsum,velec);
688 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
690 /* Update vectorial force */
691 fix2 = _mm_macc_pd(dx23,fscal,fix2);
692 fiy2 = _mm_macc_pd(dy23,fscal,fiy2);
693 fiz2 = _mm_macc_pd(dz23,fscal,fiz2);
695 fjx3 = _mm_macc_pd(dx23,fscal,fjx3);
696 fjy3 = _mm_macc_pd(dy23,fscal,fjy3);
697 fjz3 = _mm_macc_pd(dz23,fscal,fjz3);
699 /**************************
700 * CALCULATE INTERACTIONS *
701 **************************/
703 /* REACTION-FIELD ELECTROSTATICS */
704 velec = _mm_mul_pd(qq31,_mm_sub_pd(_mm_macc_pd(krf,rsq31,rinv31),crf));
705 felec = _mm_mul_pd(qq31,_mm_msub_pd(rinv31,rinvsq31,krf2));
707 /* Update potential sum for this i atom from the interaction with this j atom. */
708 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
709 velecsum = _mm_add_pd(velecsum,velec);
713 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
715 /* Update vectorial force */
716 fix3 = _mm_macc_pd(dx31,fscal,fix3);
717 fiy3 = _mm_macc_pd(dy31,fscal,fiy3);
718 fiz3 = _mm_macc_pd(dz31,fscal,fiz3);
720 fjx1 = _mm_macc_pd(dx31,fscal,fjx1);
721 fjy1 = _mm_macc_pd(dy31,fscal,fjy1);
722 fjz1 = _mm_macc_pd(dz31,fscal,fjz1);
724 /**************************
725 * CALCULATE INTERACTIONS *
726 **************************/
728 /* REACTION-FIELD ELECTROSTATICS */
729 velec = _mm_mul_pd(qq32,_mm_sub_pd(_mm_macc_pd(krf,rsq32,rinv32),crf));
730 felec = _mm_mul_pd(qq32,_mm_msub_pd(rinv32,rinvsq32,krf2));
732 /* Update potential sum for this i atom from the interaction with this j atom. */
733 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
734 velecsum = _mm_add_pd(velecsum,velec);
738 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
740 /* Update vectorial force */
741 fix3 = _mm_macc_pd(dx32,fscal,fix3);
742 fiy3 = _mm_macc_pd(dy32,fscal,fiy3);
743 fiz3 = _mm_macc_pd(dz32,fscal,fiz3);
745 fjx2 = _mm_macc_pd(dx32,fscal,fjx2);
746 fjy2 = _mm_macc_pd(dy32,fscal,fjy2);
747 fjz2 = _mm_macc_pd(dz32,fscal,fjz2);
749 /**************************
750 * CALCULATE INTERACTIONS *
751 **************************/
753 /* REACTION-FIELD ELECTROSTATICS */
754 velec = _mm_mul_pd(qq33,_mm_sub_pd(_mm_macc_pd(krf,rsq33,rinv33),crf));
755 felec = _mm_mul_pd(qq33,_mm_msub_pd(rinv33,rinvsq33,krf2));
757 /* Update potential sum for this i atom from the interaction with this j atom. */
758 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
759 velecsum = _mm_add_pd(velecsum,velec);
763 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
765 /* Update vectorial force */
766 fix3 = _mm_macc_pd(dx33,fscal,fix3);
767 fiy3 = _mm_macc_pd(dy33,fscal,fiy3);
768 fiz3 = _mm_macc_pd(dz33,fscal,fiz3);
770 fjx3 = _mm_macc_pd(dx33,fscal,fjx3);
771 fjy3 = _mm_macc_pd(dy33,fscal,fjy3);
772 fjz3 = _mm_macc_pd(dz33,fscal,fjz3);
774 gmx_mm_decrement_3rvec_1ptr_swizzle_pd(f+j_coord_offsetA+DIM,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
776 /* Inner loop uses 315 flops */
779 /* End of innermost loop */
781 gmx_mm_update_iforce_3atom_swizzle_pd(fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
782 f+i_coord_offset+DIM,fshift+i_shift_offset);
785 /* Update potential energies */
786 gmx_mm_update_1pot_pd(velecsum,kernel_data->energygrp_elec+ggid);
788 /* Increment number of inner iterations */
789 inneriter += j_index_end - j_index_start;
791 /* Outer loop uses 19 flops */
794 /* Increment number of outer iterations */
797 /* Update outer/inner flops */
799 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4W4_VF,outeriter*19 + inneriter*315);
802 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwNone_GeomW4W4_F_avx_128_fma_double
803 * Electrostatics interaction: ReactionField
804 * VdW interaction: None
805 * Geometry: Water4-Water4
806 * Calculate force/pot: Force
809 nb_kernel_ElecRF_VdwNone_GeomW4W4_F_avx_128_fma_double
810 (t_nblist * gmx_restrict nlist,
811 rvec * gmx_restrict xx,
812 rvec * gmx_restrict ff,
813 t_forcerec * gmx_restrict fr,
814 t_mdatoms * gmx_restrict mdatoms,
815 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
816 t_nrnb * gmx_restrict nrnb)
818 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
819 * just 0 for non-waters.
820 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
821 * jnr indices corresponding to data put in the four positions in the SIMD register.
823 int i_shift_offset,i_coord_offset,outeriter,inneriter;
824 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
826 int j_coord_offsetA,j_coord_offsetB;
827 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
829 real *shiftvec,*fshift,*x,*f;
830 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
832 __m128d ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
834 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
836 __m128d ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
837 int vdwjidx1A,vdwjidx1B;
838 __m128d jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
839 int vdwjidx2A,vdwjidx2B;
840 __m128d jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
841 int vdwjidx3A,vdwjidx3B;
842 __m128d jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
843 __m128d dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
844 __m128d dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
845 __m128d dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13;
846 __m128d dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
847 __m128d dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
848 __m128d dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23;
849 __m128d dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31;
850 __m128d dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32;
851 __m128d dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33;
852 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
854 __m128d dummy_mask,cutoff_mask;
855 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
856 __m128d one = _mm_set1_pd(1.0);
857 __m128d two = _mm_set1_pd(2.0);
863 jindex = nlist->jindex;
865 shiftidx = nlist->shift;
867 shiftvec = fr->shift_vec[0];
868 fshift = fr->fshift[0];
869 facel = _mm_set1_pd(fr->epsfac);
870 charge = mdatoms->chargeA;
871 krf = _mm_set1_pd(fr->ic->k_rf);
872 krf2 = _mm_set1_pd(fr->ic->k_rf*2.0);
873 crf = _mm_set1_pd(fr->ic->c_rf);
875 /* Setup water-specific parameters */
876 inr = nlist->iinr[0];
877 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
878 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
879 iq3 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+3]));
881 jq1 = _mm_set1_pd(charge[inr+1]);
882 jq2 = _mm_set1_pd(charge[inr+2]);
883 jq3 = _mm_set1_pd(charge[inr+3]);
884 qq11 = _mm_mul_pd(iq1,jq1);
885 qq12 = _mm_mul_pd(iq1,jq2);
886 qq13 = _mm_mul_pd(iq1,jq3);
887 qq21 = _mm_mul_pd(iq2,jq1);
888 qq22 = _mm_mul_pd(iq2,jq2);
889 qq23 = _mm_mul_pd(iq2,jq3);
890 qq31 = _mm_mul_pd(iq3,jq1);
891 qq32 = _mm_mul_pd(iq3,jq2);
892 qq33 = _mm_mul_pd(iq3,jq3);
894 /* Avoid stupid compiler warnings */
902 /* Start outer loop over neighborlists */
903 for(iidx=0; iidx<nri; iidx++)
905 /* Load shift vector for this list */
906 i_shift_offset = DIM*shiftidx[iidx];
908 /* Load limits for loop over neighbors */
909 j_index_start = jindex[iidx];
910 j_index_end = jindex[iidx+1];
912 /* Get outer coordinate index */
914 i_coord_offset = DIM*inr;
916 /* Load i particle coords and add shift vector */
917 gmx_mm_load_shift_and_3rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset+DIM,
918 &ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
920 fix1 = _mm_setzero_pd();
921 fiy1 = _mm_setzero_pd();
922 fiz1 = _mm_setzero_pd();
923 fix2 = _mm_setzero_pd();
924 fiy2 = _mm_setzero_pd();
925 fiz2 = _mm_setzero_pd();
926 fix3 = _mm_setzero_pd();
927 fiy3 = _mm_setzero_pd();
928 fiz3 = _mm_setzero_pd();
930 /* Start inner kernel loop */
931 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
934 /* Get j neighbor index, and coordinate index */
937 j_coord_offsetA = DIM*jnrA;
938 j_coord_offsetB = DIM*jnrB;
940 /* load j atom coordinates */
941 gmx_mm_load_3rvec_2ptr_swizzle_pd(x+j_coord_offsetA+DIM,x+j_coord_offsetB+DIM,
942 &jx1,&jy1,&jz1,&jx2,&jy2,&jz2,&jx3,&jy3,&jz3);
944 /* Calculate displacement vector */
945 dx11 = _mm_sub_pd(ix1,jx1);
946 dy11 = _mm_sub_pd(iy1,jy1);
947 dz11 = _mm_sub_pd(iz1,jz1);
948 dx12 = _mm_sub_pd(ix1,jx2);
949 dy12 = _mm_sub_pd(iy1,jy2);
950 dz12 = _mm_sub_pd(iz1,jz2);
951 dx13 = _mm_sub_pd(ix1,jx3);
952 dy13 = _mm_sub_pd(iy1,jy3);
953 dz13 = _mm_sub_pd(iz1,jz3);
954 dx21 = _mm_sub_pd(ix2,jx1);
955 dy21 = _mm_sub_pd(iy2,jy1);
956 dz21 = _mm_sub_pd(iz2,jz1);
957 dx22 = _mm_sub_pd(ix2,jx2);
958 dy22 = _mm_sub_pd(iy2,jy2);
959 dz22 = _mm_sub_pd(iz2,jz2);
960 dx23 = _mm_sub_pd(ix2,jx3);
961 dy23 = _mm_sub_pd(iy2,jy3);
962 dz23 = _mm_sub_pd(iz2,jz3);
963 dx31 = _mm_sub_pd(ix3,jx1);
964 dy31 = _mm_sub_pd(iy3,jy1);
965 dz31 = _mm_sub_pd(iz3,jz1);
966 dx32 = _mm_sub_pd(ix3,jx2);
967 dy32 = _mm_sub_pd(iy3,jy2);
968 dz32 = _mm_sub_pd(iz3,jz2);
969 dx33 = _mm_sub_pd(ix3,jx3);
970 dy33 = _mm_sub_pd(iy3,jy3);
971 dz33 = _mm_sub_pd(iz3,jz3);
973 /* Calculate squared distance and things based on it */
974 rsq11 = gmx_mm_calc_rsq_pd(dx11,dy11,dz11);
975 rsq12 = gmx_mm_calc_rsq_pd(dx12,dy12,dz12);
976 rsq13 = gmx_mm_calc_rsq_pd(dx13,dy13,dz13);
977 rsq21 = gmx_mm_calc_rsq_pd(dx21,dy21,dz21);
978 rsq22 = gmx_mm_calc_rsq_pd(dx22,dy22,dz22);
979 rsq23 = gmx_mm_calc_rsq_pd(dx23,dy23,dz23);
980 rsq31 = gmx_mm_calc_rsq_pd(dx31,dy31,dz31);
981 rsq32 = gmx_mm_calc_rsq_pd(dx32,dy32,dz32);
982 rsq33 = gmx_mm_calc_rsq_pd(dx33,dy33,dz33);
984 rinv11 = gmx_mm_invsqrt_pd(rsq11);
985 rinv12 = gmx_mm_invsqrt_pd(rsq12);
986 rinv13 = gmx_mm_invsqrt_pd(rsq13);
987 rinv21 = gmx_mm_invsqrt_pd(rsq21);
988 rinv22 = gmx_mm_invsqrt_pd(rsq22);
989 rinv23 = gmx_mm_invsqrt_pd(rsq23);
990 rinv31 = gmx_mm_invsqrt_pd(rsq31);
991 rinv32 = gmx_mm_invsqrt_pd(rsq32);
992 rinv33 = gmx_mm_invsqrt_pd(rsq33);
994 rinvsq11 = _mm_mul_pd(rinv11,rinv11);
995 rinvsq12 = _mm_mul_pd(rinv12,rinv12);
996 rinvsq13 = _mm_mul_pd(rinv13,rinv13);
997 rinvsq21 = _mm_mul_pd(rinv21,rinv21);
998 rinvsq22 = _mm_mul_pd(rinv22,rinv22);
999 rinvsq23 = _mm_mul_pd(rinv23,rinv23);
1000 rinvsq31 = _mm_mul_pd(rinv31,rinv31);
1001 rinvsq32 = _mm_mul_pd(rinv32,rinv32);
1002 rinvsq33 = _mm_mul_pd(rinv33,rinv33);
1004 fjx1 = _mm_setzero_pd();
1005 fjy1 = _mm_setzero_pd();
1006 fjz1 = _mm_setzero_pd();
1007 fjx2 = _mm_setzero_pd();
1008 fjy2 = _mm_setzero_pd();
1009 fjz2 = _mm_setzero_pd();
1010 fjx3 = _mm_setzero_pd();
1011 fjy3 = _mm_setzero_pd();
1012 fjz3 = _mm_setzero_pd();
1014 /**************************
1015 * CALCULATE INTERACTIONS *
1016 **************************/
1018 /* REACTION-FIELD ELECTROSTATICS */
1019 felec = _mm_mul_pd(qq11,_mm_msub_pd(rinv11,rinvsq11,krf2));
1023 /* Update vectorial force */
1024 fix1 = _mm_macc_pd(dx11,fscal,fix1);
1025 fiy1 = _mm_macc_pd(dy11,fscal,fiy1);
1026 fiz1 = _mm_macc_pd(dz11,fscal,fiz1);
1028 fjx1 = _mm_macc_pd(dx11,fscal,fjx1);
1029 fjy1 = _mm_macc_pd(dy11,fscal,fjy1);
1030 fjz1 = _mm_macc_pd(dz11,fscal,fjz1);
1032 /**************************
1033 * CALCULATE INTERACTIONS *
1034 **************************/
1036 /* REACTION-FIELD ELECTROSTATICS */
1037 felec = _mm_mul_pd(qq12,_mm_msub_pd(rinv12,rinvsq12,krf2));
1041 /* Update vectorial force */
1042 fix1 = _mm_macc_pd(dx12,fscal,fix1);
1043 fiy1 = _mm_macc_pd(dy12,fscal,fiy1);
1044 fiz1 = _mm_macc_pd(dz12,fscal,fiz1);
1046 fjx2 = _mm_macc_pd(dx12,fscal,fjx2);
1047 fjy2 = _mm_macc_pd(dy12,fscal,fjy2);
1048 fjz2 = _mm_macc_pd(dz12,fscal,fjz2);
1050 /**************************
1051 * CALCULATE INTERACTIONS *
1052 **************************/
1054 /* REACTION-FIELD ELECTROSTATICS */
1055 felec = _mm_mul_pd(qq13,_mm_msub_pd(rinv13,rinvsq13,krf2));
1059 /* Update vectorial force */
1060 fix1 = _mm_macc_pd(dx13,fscal,fix1);
1061 fiy1 = _mm_macc_pd(dy13,fscal,fiy1);
1062 fiz1 = _mm_macc_pd(dz13,fscal,fiz1);
1064 fjx3 = _mm_macc_pd(dx13,fscal,fjx3);
1065 fjy3 = _mm_macc_pd(dy13,fscal,fjy3);
1066 fjz3 = _mm_macc_pd(dz13,fscal,fjz3);
1068 /**************************
1069 * CALCULATE INTERACTIONS *
1070 **************************/
1072 /* REACTION-FIELD ELECTROSTATICS */
1073 felec = _mm_mul_pd(qq21,_mm_msub_pd(rinv21,rinvsq21,krf2));
1077 /* Update vectorial force */
1078 fix2 = _mm_macc_pd(dx21,fscal,fix2);
1079 fiy2 = _mm_macc_pd(dy21,fscal,fiy2);
1080 fiz2 = _mm_macc_pd(dz21,fscal,fiz2);
1082 fjx1 = _mm_macc_pd(dx21,fscal,fjx1);
1083 fjy1 = _mm_macc_pd(dy21,fscal,fjy1);
1084 fjz1 = _mm_macc_pd(dz21,fscal,fjz1);
1086 /**************************
1087 * CALCULATE INTERACTIONS *
1088 **************************/
1090 /* REACTION-FIELD ELECTROSTATICS */
1091 felec = _mm_mul_pd(qq22,_mm_msub_pd(rinv22,rinvsq22,krf2));
1095 /* Update vectorial force */
1096 fix2 = _mm_macc_pd(dx22,fscal,fix2);
1097 fiy2 = _mm_macc_pd(dy22,fscal,fiy2);
1098 fiz2 = _mm_macc_pd(dz22,fscal,fiz2);
1100 fjx2 = _mm_macc_pd(dx22,fscal,fjx2);
1101 fjy2 = _mm_macc_pd(dy22,fscal,fjy2);
1102 fjz2 = _mm_macc_pd(dz22,fscal,fjz2);
1104 /**************************
1105 * CALCULATE INTERACTIONS *
1106 **************************/
1108 /* REACTION-FIELD ELECTROSTATICS */
1109 felec = _mm_mul_pd(qq23,_mm_msub_pd(rinv23,rinvsq23,krf2));
1113 /* Update vectorial force */
1114 fix2 = _mm_macc_pd(dx23,fscal,fix2);
1115 fiy2 = _mm_macc_pd(dy23,fscal,fiy2);
1116 fiz2 = _mm_macc_pd(dz23,fscal,fiz2);
1118 fjx3 = _mm_macc_pd(dx23,fscal,fjx3);
1119 fjy3 = _mm_macc_pd(dy23,fscal,fjy3);
1120 fjz3 = _mm_macc_pd(dz23,fscal,fjz3);
1122 /**************************
1123 * CALCULATE INTERACTIONS *
1124 **************************/
1126 /* REACTION-FIELD ELECTROSTATICS */
1127 felec = _mm_mul_pd(qq31,_mm_msub_pd(rinv31,rinvsq31,krf2));
1131 /* Update vectorial force */
1132 fix3 = _mm_macc_pd(dx31,fscal,fix3);
1133 fiy3 = _mm_macc_pd(dy31,fscal,fiy3);
1134 fiz3 = _mm_macc_pd(dz31,fscal,fiz3);
1136 fjx1 = _mm_macc_pd(dx31,fscal,fjx1);
1137 fjy1 = _mm_macc_pd(dy31,fscal,fjy1);
1138 fjz1 = _mm_macc_pd(dz31,fscal,fjz1);
1140 /**************************
1141 * CALCULATE INTERACTIONS *
1142 **************************/
1144 /* REACTION-FIELD ELECTROSTATICS */
1145 felec = _mm_mul_pd(qq32,_mm_msub_pd(rinv32,rinvsq32,krf2));
1149 /* Update vectorial force */
1150 fix3 = _mm_macc_pd(dx32,fscal,fix3);
1151 fiy3 = _mm_macc_pd(dy32,fscal,fiy3);
1152 fiz3 = _mm_macc_pd(dz32,fscal,fiz3);
1154 fjx2 = _mm_macc_pd(dx32,fscal,fjx2);
1155 fjy2 = _mm_macc_pd(dy32,fscal,fjy2);
1156 fjz2 = _mm_macc_pd(dz32,fscal,fjz2);
1158 /**************************
1159 * CALCULATE INTERACTIONS *
1160 **************************/
1162 /* REACTION-FIELD ELECTROSTATICS */
1163 felec = _mm_mul_pd(qq33,_mm_msub_pd(rinv33,rinvsq33,krf2));
1167 /* Update vectorial force */
1168 fix3 = _mm_macc_pd(dx33,fscal,fix3);
1169 fiy3 = _mm_macc_pd(dy33,fscal,fiy3);
1170 fiz3 = _mm_macc_pd(dz33,fscal,fiz3);
1172 fjx3 = _mm_macc_pd(dx33,fscal,fjx3);
1173 fjy3 = _mm_macc_pd(dy33,fscal,fjy3);
1174 fjz3 = _mm_macc_pd(dz33,fscal,fjz3);
1176 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);
1178 /* Inner loop uses 270 flops */
1181 if(jidx<j_index_end)
1185 j_coord_offsetA = DIM*jnrA;
1187 /* load j atom coordinates */
1188 gmx_mm_load_3rvec_1ptr_swizzle_pd(x+j_coord_offsetA+DIM,
1189 &jx1,&jy1,&jz1,&jx2,&jy2,&jz2,&jx3,&jy3,&jz3);
1191 /* Calculate displacement vector */
1192 dx11 = _mm_sub_pd(ix1,jx1);
1193 dy11 = _mm_sub_pd(iy1,jy1);
1194 dz11 = _mm_sub_pd(iz1,jz1);
1195 dx12 = _mm_sub_pd(ix1,jx2);
1196 dy12 = _mm_sub_pd(iy1,jy2);
1197 dz12 = _mm_sub_pd(iz1,jz2);
1198 dx13 = _mm_sub_pd(ix1,jx3);
1199 dy13 = _mm_sub_pd(iy1,jy3);
1200 dz13 = _mm_sub_pd(iz1,jz3);
1201 dx21 = _mm_sub_pd(ix2,jx1);
1202 dy21 = _mm_sub_pd(iy2,jy1);
1203 dz21 = _mm_sub_pd(iz2,jz1);
1204 dx22 = _mm_sub_pd(ix2,jx2);
1205 dy22 = _mm_sub_pd(iy2,jy2);
1206 dz22 = _mm_sub_pd(iz2,jz2);
1207 dx23 = _mm_sub_pd(ix2,jx3);
1208 dy23 = _mm_sub_pd(iy2,jy3);
1209 dz23 = _mm_sub_pd(iz2,jz3);
1210 dx31 = _mm_sub_pd(ix3,jx1);
1211 dy31 = _mm_sub_pd(iy3,jy1);
1212 dz31 = _mm_sub_pd(iz3,jz1);
1213 dx32 = _mm_sub_pd(ix3,jx2);
1214 dy32 = _mm_sub_pd(iy3,jy2);
1215 dz32 = _mm_sub_pd(iz3,jz2);
1216 dx33 = _mm_sub_pd(ix3,jx3);
1217 dy33 = _mm_sub_pd(iy3,jy3);
1218 dz33 = _mm_sub_pd(iz3,jz3);
1220 /* Calculate squared distance and things based on it */
1221 rsq11 = gmx_mm_calc_rsq_pd(dx11,dy11,dz11);
1222 rsq12 = gmx_mm_calc_rsq_pd(dx12,dy12,dz12);
1223 rsq13 = gmx_mm_calc_rsq_pd(dx13,dy13,dz13);
1224 rsq21 = gmx_mm_calc_rsq_pd(dx21,dy21,dz21);
1225 rsq22 = gmx_mm_calc_rsq_pd(dx22,dy22,dz22);
1226 rsq23 = gmx_mm_calc_rsq_pd(dx23,dy23,dz23);
1227 rsq31 = gmx_mm_calc_rsq_pd(dx31,dy31,dz31);
1228 rsq32 = gmx_mm_calc_rsq_pd(dx32,dy32,dz32);
1229 rsq33 = gmx_mm_calc_rsq_pd(dx33,dy33,dz33);
1231 rinv11 = gmx_mm_invsqrt_pd(rsq11);
1232 rinv12 = gmx_mm_invsqrt_pd(rsq12);
1233 rinv13 = gmx_mm_invsqrt_pd(rsq13);
1234 rinv21 = gmx_mm_invsqrt_pd(rsq21);
1235 rinv22 = gmx_mm_invsqrt_pd(rsq22);
1236 rinv23 = gmx_mm_invsqrt_pd(rsq23);
1237 rinv31 = gmx_mm_invsqrt_pd(rsq31);
1238 rinv32 = gmx_mm_invsqrt_pd(rsq32);
1239 rinv33 = gmx_mm_invsqrt_pd(rsq33);
1241 rinvsq11 = _mm_mul_pd(rinv11,rinv11);
1242 rinvsq12 = _mm_mul_pd(rinv12,rinv12);
1243 rinvsq13 = _mm_mul_pd(rinv13,rinv13);
1244 rinvsq21 = _mm_mul_pd(rinv21,rinv21);
1245 rinvsq22 = _mm_mul_pd(rinv22,rinv22);
1246 rinvsq23 = _mm_mul_pd(rinv23,rinv23);
1247 rinvsq31 = _mm_mul_pd(rinv31,rinv31);
1248 rinvsq32 = _mm_mul_pd(rinv32,rinv32);
1249 rinvsq33 = _mm_mul_pd(rinv33,rinv33);
1251 fjx1 = _mm_setzero_pd();
1252 fjy1 = _mm_setzero_pd();
1253 fjz1 = _mm_setzero_pd();
1254 fjx2 = _mm_setzero_pd();
1255 fjy2 = _mm_setzero_pd();
1256 fjz2 = _mm_setzero_pd();
1257 fjx3 = _mm_setzero_pd();
1258 fjy3 = _mm_setzero_pd();
1259 fjz3 = _mm_setzero_pd();
1261 /**************************
1262 * CALCULATE INTERACTIONS *
1263 **************************/
1265 /* REACTION-FIELD ELECTROSTATICS */
1266 felec = _mm_mul_pd(qq11,_mm_msub_pd(rinv11,rinvsq11,krf2));
1270 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1272 /* Update vectorial force */
1273 fix1 = _mm_macc_pd(dx11,fscal,fix1);
1274 fiy1 = _mm_macc_pd(dy11,fscal,fiy1);
1275 fiz1 = _mm_macc_pd(dz11,fscal,fiz1);
1277 fjx1 = _mm_macc_pd(dx11,fscal,fjx1);
1278 fjy1 = _mm_macc_pd(dy11,fscal,fjy1);
1279 fjz1 = _mm_macc_pd(dz11,fscal,fjz1);
1281 /**************************
1282 * CALCULATE INTERACTIONS *
1283 **************************/
1285 /* REACTION-FIELD ELECTROSTATICS */
1286 felec = _mm_mul_pd(qq12,_mm_msub_pd(rinv12,rinvsq12,krf2));
1290 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1292 /* Update vectorial force */
1293 fix1 = _mm_macc_pd(dx12,fscal,fix1);
1294 fiy1 = _mm_macc_pd(dy12,fscal,fiy1);
1295 fiz1 = _mm_macc_pd(dz12,fscal,fiz1);
1297 fjx2 = _mm_macc_pd(dx12,fscal,fjx2);
1298 fjy2 = _mm_macc_pd(dy12,fscal,fjy2);
1299 fjz2 = _mm_macc_pd(dz12,fscal,fjz2);
1301 /**************************
1302 * CALCULATE INTERACTIONS *
1303 **************************/
1305 /* REACTION-FIELD ELECTROSTATICS */
1306 felec = _mm_mul_pd(qq13,_mm_msub_pd(rinv13,rinvsq13,krf2));
1310 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1312 /* Update vectorial force */
1313 fix1 = _mm_macc_pd(dx13,fscal,fix1);
1314 fiy1 = _mm_macc_pd(dy13,fscal,fiy1);
1315 fiz1 = _mm_macc_pd(dz13,fscal,fiz1);
1317 fjx3 = _mm_macc_pd(dx13,fscal,fjx3);
1318 fjy3 = _mm_macc_pd(dy13,fscal,fjy3);
1319 fjz3 = _mm_macc_pd(dz13,fscal,fjz3);
1321 /**************************
1322 * CALCULATE INTERACTIONS *
1323 **************************/
1325 /* REACTION-FIELD ELECTROSTATICS */
1326 felec = _mm_mul_pd(qq21,_mm_msub_pd(rinv21,rinvsq21,krf2));
1330 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1332 /* Update vectorial force */
1333 fix2 = _mm_macc_pd(dx21,fscal,fix2);
1334 fiy2 = _mm_macc_pd(dy21,fscal,fiy2);
1335 fiz2 = _mm_macc_pd(dz21,fscal,fiz2);
1337 fjx1 = _mm_macc_pd(dx21,fscal,fjx1);
1338 fjy1 = _mm_macc_pd(dy21,fscal,fjy1);
1339 fjz1 = _mm_macc_pd(dz21,fscal,fjz1);
1341 /**************************
1342 * CALCULATE INTERACTIONS *
1343 **************************/
1345 /* REACTION-FIELD ELECTROSTATICS */
1346 felec = _mm_mul_pd(qq22,_mm_msub_pd(rinv22,rinvsq22,krf2));
1350 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1352 /* Update vectorial force */
1353 fix2 = _mm_macc_pd(dx22,fscal,fix2);
1354 fiy2 = _mm_macc_pd(dy22,fscal,fiy2);
1355 fiz2 = _mm_macc_pd(dz22,fscal,fiz2);
1357 fjx2 = _mm_macc_pd(dx22,fscal,fjx2);
1358 fjy2 = _mm_macc_pd(dy22,fscal,fjy2);
1359 fjz2 = _mm_macc_pd(dz22,fscal,fjz2);
1361 /**************************
1362 * CALCULATE INTERACTIONS *
1363 **************************/
1365 /* REACTION-FIELD ELECTROSTATICS */
1366 felec = _mm_mul_pd(qq23,_mm_msub_pd(rinv23,rinvsq23,krf2));
1370 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1372 /* Update vectorial force */
1373 fix2 = _mm_macc_pd(dx23,fscal,fix2);
1374 fiy2 = _mm_macc_pd(dy23,fscal,fiy2);
1375 fiz2 = _mm_macc_pd(dz23,fscal,fiz2);
1377 fjx3 = _mm_macc_pd(dx23,fscal,fjx3);
1378 fjy3 = _mm_macc_pd(dy23,fscal,fjy3);
1379 fjz3 = _mm_macc_pd(dz23,fscal,fjz3);
1381 /**************************
1382 * CALCULATE INTERACTIONS *
1383 **************************/
1385 /* REACTION-FIELD ELECTROSTATICS */
1386 felec = _mm_mul_pd(qq31,_mm_msub_pd(rinv31,rinvsq31,krf2));
1390 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1392 /* Update vectorial force */
1393 fix3 = _mm_macc_pd(dx31,fscal,fix3);
1394 fiy3 = _mm_macc_pd(dy31,fscal,fiy3);
1395 fiz3 = _mm_macc_pd(dz31,fscal,fiz3);
1397 fjx1 = _mm_macc_pd(dx31,fscal,fjx1);
1398 fjy1 = _mm_macc_pd(dy31,fscal,fjy1);
1399 fjz1 = _mm_macc_pd(dz31,fscal,fjz1);
1401 /**************************
1402 * CALCULATE INTERACTIONS *
1403 **************************/
1405 /* REACTION-FIELD ELECTROSTATICS */
1406 felec = _mm_mul_pd(qq32,_mm_msub_pd(rinv32,rinvsq32,krf2));
1410 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1412 /* Update vectorial force */
1413 fix3 = _mm_macc_pd(dx32,fscal,fix3);
1414 fiy3 = _mm_macc_pd(dy32,fscal,fiy3);
1415 fiz3 = _mm_macc_pd(dz32,fscal,fiz3);
1417 fjx2 = _mm_macc_pd(dx32,fscal,fjx2);
1418 fjy2 = _mm_macc_pd(dy32,fscal,fjy2);
1419 fjz2 = _mm_macc_pd(dz32,fscal,fjz2);
1421 /**************************
1422 * CALCULATE INTERACTIONS *
1423 **************************/
1425 /* REACTION-FIELD ELECTROSTATICS */
1426 felec = _mm_mul_pd(qq33,_mm_msub_pd(rinv33,rinvsq33,krf2));
1430 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1432 /* Update vectorial force */
1433 fix3 = _mm_macc_pd(dx33,fscal,fix3);
1434 fiy3 = _mm_macc_pd(dy33,fscal,fiy3);
1435 fiz3 = _mm_macc_pd(dz33,fscal,fiz3);
1437 fjx3 = _mm_macc_pd(dx33,fscal,fjx3);
1438 fjy3 = _mm_macc_pd(dy33,fscal,fjy3);
1439 fjz3 = _mm_macc_pd(dz33,fscal,fjz3);
1441 gmx_mm_decrement_3rvec_1ptr_swizzle_pd(f+j_coord_offsetA+DIM,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
1443 /* Inner loop uses 270 flops */
1446 /* End of innermost loop */
1448 gmx_mm_update_iforce_3atom_swizzle_pd(fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
1449 f+i_coord_offset+DIM,fshift+i_shift_offset);
1451 /* Increment number of inner iterations */
1452 inneriter += j_index_end - j_index_start;
1454 /* Outer loop uses 18 flops */
1457 /* Increment number of outer iterations */
1460 /* Update outer/inner flops */
1462 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4W4_F,outeriter*18 + inneriter*270);