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_single kernel generator.
44 #include "../nb_kernel.h"
45 #include "types/simple.h"
49 #include "gromacs/simd/math_x86_avx_128_fma_single.h"
50 #include "kernelutil_x86_avx_128_fma_single.h"
53 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwLJ_GeomW3W3_VF_avx_128_fma_single
54 * Electrostatics interaction: Coulomb
55 * VdW interaction: LennardJones
56 * Geometry: Water3-Water3
57 * Calculate force/pot: PotentialAndForce
60 nb_kernel_ElecCoul_VdwLJ_GeomW3W3_VF_avx_128_fma_single
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,C,D refer to j loop unrolling done with AVX_128, e.g. for the four 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;
76 int jnrA,jnrB,jnrC,jnrD;
77 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
78 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
79 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
81 real *shiftvec,*fshift,*x,*f;
82 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
84 __m128 fscal,rcutoff,rcutoff2,jidxall;
86 __m128 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
88 __m128 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
90 __m128 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
91 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
92 __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
93 int vdwjidx1A,vdwjidx1B,vdwjidx1C,vdwjidx1D;
94 __m128 jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
95 int vdwjidx2A,vdwjidx2B,vdwjidx2C,vdwjidx2D;
96 __m128 jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
97 __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
98 __m128 dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01;
99 __m128 dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02;
100 __m128 dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
101 __m128 dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
102 __m128 dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
103 __m128 dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
104 __m128 dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
105 __m128 dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
106 __m128 velec,felec,velecsum,facel,crf,krf,krf2;
109 __m128 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
112 __m128 one_sixth = _mm_set1_ps(1.0/6.0);
113 __m128 one_twelfth = _mm_set1_ps(1.0/12.0);
114 __m128 dummy_mask,cutoff_mask;
115 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
116 __m128 one = _mm_set1_ps(1.0);
117 __m128 two = _mm_set1_ps(2.0);
123 jindex = nlist->jindex;
125 shiftidx = nlist->shift;
127 shiftvec = fr->shift_vec[0];
128 fshift = fr->fshift[0];
129 facel = _mm_set1_ps(fr->epsfac);
130 charge = mdatoms->chargeA;
131 nvdwtype = fr->ntype;
133 vdwtype = mdatoms->typeA;
135 /* Setup water-specific parameters */
136 inr = nlist->iinr[0];
137 iq0 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+0]));
138 iq1 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+1]));
139 iq2 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+2]));
140 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
142 jq0 = _mm_set1_ps(charge[inr+0]);
143 jq1 = _mm_set1_ps(charge[inr+1]);
144 jq2 = _mm_set1_ps(charge[inr+2]);
145 vdwjidx0A = 2*vdwtype[inr+0];
146 qq00 = _mm_mul_ps(iq0,jq0);
147 c6_00 = _mm_set1_ps(vdwparam[vdwioffset0+vdwjidx0A]);
148 c12_00 = _mm_set1_ps(vdwparam[vdwioffset0+vdwjidx0A+1]);
149 qq01 = _mm_mul_ps(iq0,jq1);
150 qq02 = _mm_mul_ps(iq0,jq2);
151 qq10 = _mm_mul_ps(iq1,jq0);
152 qq11 = _mm_mul_ps(iq1,jq1);
153 qq12 = _mm_mul_ps(iq1,jq2);
154 qq20 = _mm_mul_ps(iq2,jq0);
155 qq21 = _mm_mul_ps(iq2,jq1);
156 qq22 = _mm_mul_ps(iq2,jq2);
158 /* Avoid stupid compiler warnings */
159 jnrA = jnrB = jnrC = jnrD = 0;
168 for(iidx=0;iidx<4*DIM;iidx++)
173 /* Start outer loop over neighborlists */
174 for(iidx=0; iidx<nri; iidx++)
176 /* Load shift vector for this list */
177 i_shift_offset = DIM*shiftidx[iidx];
179 /* Load limits for loop over neighbors */
180 j_index_start = jindex[iidx];
181 j_index_end = jindex[iidx+1];
183 /* Get outer coordinate index */
185 i_coord_offset = DIM*inr;
187 /* Load i particle coords and add shift vector */
188 gmx_mm_load_shift_and_3rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
189 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
191 fix0 = _mm_setzero_ps();
192 fiy0 = _mm_setzero_ps();
193 fiz0 = _mm_setzero_ps();
194 fix1 = _mm_setzero_ps();
195 fiy1 = _mm_setzero_ps();
196 fiz1 = _mm_setzero_ps();
197 fix2 = _mm_setzero_ps();
198 fiy2 = _mm_setzero_ps();
199 fiz2 = _mm_setzero_ps();
201 /* Reset potential sums */
202 velecsum = _mm_setzero_ps();
203 vvdwsum = _mm_setzero_ps();
205 /* Start inner kernel loop */
206 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
209 /* Get j neighbor index, and coordinate index */
214 j_coord_offsetA = DIM*jnrA;
215 j_coord_offsetB = DIM*jnrB;
216 j_coord_offsetC = DIM*jnrC;
217 j_coord_offsetD = DIM*jnrD;
219 /* load j atom coordinates */
220 gmx_mm_load_3rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
221 x+j_coord_offsetC,x+j_coord_offsetD,
222 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
224 /* Calculate displacement vector */
225 dx00 = _mm_sub_ps(ix0,jx0);
226 dy00 = _mm_sub_ps(iy0,jy0);
227 dz00 = _mm_sub_ps(iz0,jz0);
228 dx01 = _mm_sub_ps(ix0,jx1);
229 dy01 = _mm_sub_ps(iy0,jy1);
230 dz01 = _mm_sub_ps(iz0,jz1);
231 dx02 = _mm_sub_ps(ix0,jx2);
232 dy02 = _mm_sub_ps(iy0,jy2);
233 dz02 = _mm_sub_ps(iz0,jz2);
234 dx10 = _mm_sub_ps(ix1,jx0);
235 dy10 = _mm_sub_ps(iy1,jy0);
236 dz10 = _mm_sub_ps(iz1,jz0);
237 dx11 = _mm_sub_ps(ix1,jx1);
238 dy11 = _mm_sub_ps(iy1,jy1);
239 dz11 = _mm_sub_ps(iz1,jz1);
240 dx12 = _mm_sub_ps(ix1,jx2);
241 dy12 = _mm_sub_ps(iy1,jy2);
242 dz12 = _mm_sub_ps(iz1,jz2);
243 dx20 = _mm_sub_ps(ix2,jx0);
244 dy20 = _mm_sub_ps(iy2,jy0);
245 dz20 = _mm_sub_ps(iz2,jz0);
246 dx21 = _mm_sub_ps(ix2,jx1);
247 dy21 = _mm_sub_ps(iy2,jy1);
248 dz21 = _mm_sub_ps(iz2,jz1);
249 dx22 = _mm_sub_ps(ix2,jx2);
250 dy22 = _mm_sub_ps(iy2,jy2);
251 dz22 = _mm_sub_ps(iz2,jz2);
253 /* Calculate squared distance and things based on it */
254 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
255 rsq01 = gmx_mm_calc_rsq_ps(dx01,dy01,dz01);
256 rsq02 = gmx_mm_calc_rsq_ps(dx02,dy02,dz02);
257 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
258 rsq11 = gmx_mm_calc_rsq_ps(dx11,dy11,dz11);
259 rsq12 = gmx_mm_calc_rsq_ps(dx12,dy12,dz12);
260 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
261 rsq21 = gmx_mm_calc_rsq_ps(dx21,dy21,dz21);
262 rsq22 = gmx_mm_calc_rsq_ps(dx22,dy22,dz22);
264 rinv00 = gmx_mm_invsqrt_ps(rsq00);
265 rinv01 = gmx_mm_invsqrt_ps(rsq01);
266 rinv02 = gmx_mm_invsqrt_ps(rsq02);
267 rinv10 = gmx_mm_invsqrt_ps(rsq10);
268 rinv11 = gmx_mm_invsqrt_ps(rsq11);
269 rinv12 = gmx_mm_invsqrt_ps(rsq12);
270 rinv20 = gmx_mm_invsqrt_ps(rsq20);
271 rinv21 = gmx_mm_invsqrt_ps(rsq21);
272 rinv22 = gmx_mm_invsqrt_ps(rsq22);
274 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
275 rinvsq01 = _mm_mul_ps(rinv01,rinv01);
276 rinvsq02 = _mm_mul_ps(rinv02,rinv02);
277 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
278 rinvsq11 = _mm_mul_ps(rinv11,rinv11);
279 rinvsq12 = _mm_mul_ps(rinv12,rinv12);
280 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
281 rinvsq21 = _mm_mul_ps(rinv21,rinv21);
282 rinvsq22 = _mm_mul_ps(rinv22,rinv22);
284 fjx0 = _mm_setzero_ps();
285 fjy0 = _mm_setzero_ps();
286 fjz0 = _mm_setzero_ps();
287 fjx1 = _mm_setzero_ps();
288 fjy1 = _mm_setzero_ps();
289 fjz1 = _mm_setzero_ps();
290 fjx2 = _mm_setzero_ps();
291 fjy2 = _mm_setzero_ps();
292 fjz2 = _mm_setzero_ps();
294 /**************************
295 * CALCULATE INTERACTIONS *
296 **************************/
298 /* COULOMB ELECTROSTATICS */
299 velec = _mm_mul_ps(qq00,rinv00);
300 felec = _mm_mul_ps(velec,rinvsq00);
302 /* LENNARD-JONES DISPERSION/REPULSION */
304 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
305 vvdw6 = _mm_mul_ps(c6_00,rinvsix);
306 vvdw12 = _mm_mul_ps(c12_00,_mm_mul_ps(rinvsix,rinvsix));
307 vvdw = _mm_msub_ps(vvdw12,one_twelfth,_mm_mul_ps(vvdw6,one_sixth));
308 fvdw = _mm_mul_ps(_mm_sub_ps(vvdw12,vvdw6),rinvsq00);
310 /* Update potential sum for this i atom from the interaction with this j atom. */
311 velecsum = _mm_add_ps(velecsum,velec);
312 vvdwsum = _mm_add_ps(vvdwsum,vvdw);
314 fscal = _mm_add_ps(felec,fvdw);
316 /* Update vectorial force */
317 fix0 = _mm_macc_ps(dx00,fscal,fix0);
318 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
319 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
321 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
322 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
323 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
325 /**************************
326 * CALCULATE INTERACTIONS *
327 **************************/
329 /* COULOMB ELECTROSTATICS */
330 velec = _mm_mul_ps(qq01,rinv01);
331 felec = _mm_mul_ps(velec,rinvsq01);
333 /* Update potential sum for this i atom from the interaction with this j atom. */
334 velecsum = _mm_add_ps(velecsum,velec);
338 /* Update vectorial force */
339 fix0 = _mm_macc_ps(dx01,fscal,fix0);
340 fiy0 = _mm_macc_ps(dy01,fscal,fiy0);
341 fiz0 = _mm_macc_ps(dz01,fscal,fiz0);
343 fjx1 = _mm_macc_ps(dx01,fscal,fjx1);
344 fjy1 = _mm_macc_ps(dy01,fscal,fjy1);
345 fjz1 = _mm_macc_ps(dz01,fscal,fjz1);
347 /**************************
348 * CALCULATE INTERACTIONS *
349 **************************/
351 /* COULOMB ELECTROSTATICS */
352 velec = _mm_mul_ps(qq02,rinv02);
353 felec = _mm_mul_ps(velec,rinvsq02);
355 /* Update potential sum for this i atom from the interaction with this j atom. */
356 velecsum = _mm_add_ps(velecsum,velec);
360 /* Update vectorial force */
361 fix0 = _mm_macc_ps(dx02,fscal,fix0);
362 fiy0 = _mm_macc_ps(dy02,fscal,fiy0);
363 fiz0 = _mm_macc_ps(dz02,fscal,fiz0);
365 fjx2 = _mm_macc_ps(dx02,fscal,fjx2);
366 fjy2 = _mm_macc_ps(dy02,fscal,fjy2);
367 fjz2 = _mm_macc_ps(dz02,fscal,fjz2);
369 /**************************
370 * CALCULATE INTERACTIONS *
371 **************************/
373 /* COULOMB ELECTROSTATICS */
374 velec = _mm_mul_ps(qq10,rinv10);
375 felec = _mm_mul_ps(velec,rinvsq10);
377 /* Update potential sum for this i atom from the interaction with this j atom. */
378 velecsum = _mm_add_ps(velecsum,velec);
382 /* Update vectorial force */
383 fix1 = _mm_macc_ps(dx10,fscal,fix1);
384 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
385 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
387 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
388 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
389 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
391 /**************************
392 * CALCULATE INTERACTIONS *
393 **************************/
395 /* COULOMB ELECTROSTATICS */
396 velec = _mm_mul_ps(qq11,rinv11);
397 felec = _mm_mul_ps(velec,rinvsq11);
399 /* Update potential sum for this i atom from the interaction with this j atom. */
400 velecsum = _mm_add_ps(velecsum,velec);
404 /* Update vectorial force */
405 fix1 = _mm_macc_ps(dx11,fscal,fix1);
406 fiy1 = _mm_macc_ps(dy11,fscal,fiy1);
407 fiz1 = _mm_macc_ps(dz11,fscal,fiz1);
409 fjx1 = _mm_macc_ps(dx11,fscal,fjx1);
410 fjy1 = _mm_macc_ps(dy11,fscal,fjy1);
411 fjz1 = _mm_macc_ps(dz11,fscal,fjz1);
413 /**************************
414 * CALCULATE INTERACTIONS *
415 **************************/
417 /* COULOMB ELECTROSTATICS */
418 velec = _mm_mul_ps(qq12,rinv12);
419 felec = _mm_mul_ps(velec,rinvsq12);
421 /* Update potential sum for this i atom from the interaction with this j atom. */
422 velecsum = _mm_add_ps(velecsum,velec);
426 /* Update vectorial force */
427 fix1 = _mm_macc_ps(dx12,fscal,fix1);
428 fiy1 = _mm_macc_ps(dy12,fscal,fiy1);
429 fiz1 = _mm_macc_ps(dz12,fscal,fiz1);
431 fjx2 = _mm_macc_ps(dx12,fscal,fjx2);
432 fjy2 = _mm_macc_ps(dy12,fscal,fjy2);
433 fjz2 = _mm_macc_ps(dz12,fscal,fjz2);
435 /**************************
436 * CALCULATE INTERACTIONS *
437 **************************/
439 /* COULOMB ELECTROSTATICS */
440 velec = _mm_mul_ps(qq20,rinv20);
441 felec = _mm_mul_ps(velec,rinvsq20);
443 /* Update potential sum for this i atom from the interaction with this j atom. */
444 velecsum = _mm_add_ps(velecsum,velec);
448 /* Update vectorial force */
449 fix2 = _mm_macc_ps(dx20,fscal,fix2);
450 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
451 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
453 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
454 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
455 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
457 /**************************
458 * CALCULATE INTERACTIONS *
459 **************************/
461 /* COULOMB ELECTROSTATICS */
462 velec = _mm_mul_ps(qq21,rinv21);
463 felec = _mm_mul_ps(velec,rinvsq21);
465 /* Update potential sum for this i atom from the interaction with this j atom. */
466 velecsum = _mm_add_ps(velecsum,velec);
470 /* Update vectorial force */
471 fix2 = _mm_macc_ps(dx21,fscal,fix2);
472 fiy2 = _mm_macc_ps(dy21,fscal,fiy2);
473 fiz2 = _mm_macc_ps(dz21,fscal,fiz2);
475 fjx1 = _mm_macc_ps(dx21,fscal,fjx1);
476 fjy1 = _mm_macc_ps(dy21,fscal,fjy1);
477 fjz1 = _mm_macc_ps(dz21,fscal,fjz1);
479 /**************************
480 * CALCULATE INTERACTIONS *
481 **************************/
483 /* COULOMB ELECTROSTATICS */
484 velec = _mm_mul_ps(qq22,rinv22);
485 felec = _mm_mul_ps(velec,rinvsq22);
487 /* Update potential sum for this i atom from the interaction with this j atom. */
488 velecsum = _mm_add_ps(velecsum,velec);
492 /* Update vectorial force */
493 fix2 = _mm_macc_ps(dx22,fscal,fix2);
494 fiy2 = _mm_macc_ps(dy22,fscal,fiy2);
495 fiz2 = _mm_macc_ps(dz22,fscal,fiz2);
497 fjx2 = _mm_macc_ps(dx22,fscal,fjx2);
498 fjy2 = _mm_macc_ps(dy22,fscal,fjy2);
499 fjz2 = _mm_macc_ps(dz22,fscal,fjz2);
501 fjptrA = f+j_coord_offsetA;
502 fjptrB = f+j_coord_offsetB;
503 fjptrC = f+j_coord_offsetC;
504 fjptrD = f+j_coord_offsetD;
506 gmx_mm_decrement_3rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
507 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
509 /* Inner loop uses 291 flops */
515 /* Get j neighbor index, and coordinate index */
516 jnrlistA = jjnr[jidx];
517 jnrlistB = jjnr[jidx+1];
518 jnrlistC = jjnr[jidx+2];
519 jnrlistD = jjnr[jidx+3];
520 /* Sign of each element will be negative for non-real atoms.
521 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
522 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
524 dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
525 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
526 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
527 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
528 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
529 j_coord_offsetA = DIM*jnrA;
530 j_coord_offsetB = DIM*jnrB;
531 j_coord_offsetC = DIM*jnrC;
532 j_coord_offsetD = DIM*jnrD;
534 /* load j atom coordinates */
535 gmx_mm_load_3rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
536 x+j_coord_offsetC,x+j_coord_offsetD,
537 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
539 /* Calculate displacement vector */
540 dx00 = _mm_sub_ps(ix0,jx0);
541 dy00 = _mm_sub_ps(iy0,jy0);
542 dz00 = _mm_sub_ps(iz0,jz0);
543 dx01 = _mm_sub_ps(ix0,jx1);
544 dy01 = _mm_sub_ps(iy0,jy1);
545 dz01 = _mm_sub_ps(iz0,jz1);
546 dx02 = _mm_sub_ps(ix0,jx2);
547 dy02 = _mm_sub_ps(iy0,jy2);
548 dz02 = _mm_sub_ps(iz0,jz2);
549 dx10 = _mm_sub_ps(ix1,jx0);
550 dy10 = _mm_sub_ps(iy1,jy0);
551 dz10 = _mm_sub_ps(iz1,jz0);
552 dx11 = _mm_sub_ps(ix1,jx1);
553 dy11 = _mm_sub_ps(iy1,jy1);
554 dz11 = _mm_sub_ps(iz1,jz1);
555 dx12 = _mm_sub_ps(ix1,jx2);
556 dy12 = _mm_sub_ps(iy1,jy2);
557 dz12 = _mm_sub_ps(iz1,jz2);
558 dx20 = _mm_sub_ps(ix2,jx0);
559 dy20 = _mm_sub_ps(iy2,jy0);
560 dz20 = _mm_sub_ps(iz2,jz0);
561 dx21 = _mm_sub_ps(ix2,jx1);
562 dy21 = _mm_sub_ps(iy2,jy1);
563 dz21 = _mm_sub_ps(iz2,jz1);
564 dx22 = _mm_sub_ps(ix2,jx2);
565 dy22 = _mm_sub_ps(iy2,jy2);
566 dz22 = _mm_sub_ps(iz2,jz2);
568 /* Calculate squared distance and things based on it */
569 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
570 rsq01 = gmx_mm_calc_rsq_ps(dx01,dy01,dz01);
571 rsq02 = gmx_mm_calc_rsq_ps(dx02,dy02,dz02);
572 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
573 rsq11 = gmx_mm_calc_rsq_ps(dx11,dy11,dz11);
574 rsq12 = gmx_mm_calc_rsq_ps(dx12,dy12,dz12);
575 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
576 rsq21 = gmx_mm_calc_rsq_ps(dx21,dy21,dz21);
577 rsq22 = gmx_mm_calc_rsq_ps(dx22,dy22,dz22);
579 rinv00 = gmx_mm_invsqrt_ps(rsq00);
580 rinv01 = gmx_mm_invsqrt_ps(rsq01);
581 rinv02 = gmx_mm_invsqrt_ps(rsq02);
582 rinv10 = gmx_mm_invsqrt_ps(rsq10);
583 rinv11 = gmx_mm_invsqrt_ps(rsq11);
584 rinv12 = gmx_mm_invsqrt_ps(rsq12);
585 rinv20 = gmx_mm_invsqrt_ps(rsq20);
586 rinv21 = gmx_mm_invsqrt_ps(rsq21);
587 rinv22 = gmx_mm_invsqrt_ps(rsq22);
589 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
590 rinvsq01 = _mm_mul_ps(rinv01,rinv01);
591 rinvsq02 = _mm_mul_ps(rinv02,rinv02);
592 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
593 rinvsq11 = _mm_mul_ps(rinv11,rinv11);
594 rinvsq12 = _mm_mul_ps(rinv12,rinv12);
595 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
596 rinvsq21 = _mm_mul_ps(rinv21,rinv21);
597 rinvsq22 = _mm_mul_ps(rinv22,rinv22);
599 fjx0 = _mm_setzero_ps();
600 fjy0 = _mm_setzero_ps();
601 fjz0 = _mm_setzero_ps();
602 fjx1 = _mm_setzero_ps();
603 fjy1 = _mm_setzero_ps();
604 fjz1 = _mm_setzero_ps();
605 fjx2 = _mm_setzero_ps();
606 fjy2 = _mm_setzero_ps();
607 fjz2 = _mm_setzero_ps();
609 /**************************
610 * CALCULATE INTERACTIONS *
611 **************************/
613 /* COULOMB ELECTROSTATICS */
614 velec = _mm_mul_ps(qq00,rinv00);
615 felec = _mm_mul_ps(velec,rinvsq00);
617 /* LENNARD-JONES DISPERSION/REPULSION */
619 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
620 vvdw6 = _mm_mul_ps(c6_00,rinvsix);
621 vvdw12 = _mm_mul_ps(c12_00,_mm_mul_ps(rinvsix,rinvsix));
622 vvdw = _mm_msub_ps(vvdw12,one_twelfth,_mm_mul_ps(vvdw6,one_sixth));
623 fvdw = _mm_mul_ps(_mm_sub_ps(vvdw12,vvdw6),rinvsq00);
625 /* Update potential sum for this i atom from the interaction with this j atom. */
626 velec = _mm_andnot_ps(dummy_mask,velec);
627 velecsum = _mm_add_ps(velecsum,velec);
628 vvdw = _mm_andnot_ps(dummy_mask,vvdw);
629 vvdwsum = _mm_add_ps(vvdwsum,vvdw);
631 fscal = _mm_add_ps(felec,fvdw);
633 fscal = _mm_andnot_ps(dummy_mask,fscal);
635 /* Update vectorial force */
636 fix0 = _mm_macc_ps(dx00,fscal,fix0);
637 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
638 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
640 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
641 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
642 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
644 /**************************
645 * CALCULATE INTERACTIONS *
646 **************************/
648 /* COULOMB ELECTROSTATICS */
649 velec = _mm_mul_ps(qq01,rinv01);
650 felec = _mm_mul_ps(velec,rinvsq01);
652 /* Update potential sum for this i atom from the interaction with this j atom. */
653 velec = _mm_andnot_ps(dummy_mask,velec);
654 velecsum = _mm_add_ps(velecsum,velec);
658 fscal = _mm_andnot_ps(dummy_mask,fscal);
660 /* Update vectorial force */
661 fix0 = _mm_macc_ps(dx01,fscal,fix0);
662 fiy0 = _mm_macc_ps(dy01,fscal,fiy0);
663 fiz0 = _mm_macc_ps(dz01,fscal,fiz0);
665 fjx1 = _mm_macc_ps(dx01,fscal,fjx1);
666 fjy1 = _mm_macc_ps(dy01,fscal,fjy1);
667 fjz1 = _mm_macc_ps(dz01,fscal,fjz1);
669 /**************************
670 * CALCULATE INTERACTIONS *
671 **************************/
673 /* COULOMB ELECTROSTATICS */
674 velec = _mm_mul_ps(qq02,rinv02);
675 felec = _mm_mul_ps(velec,rinvsq02);
677 /* Update potential sum for this i atom from the interaction with this j atom. */
678 velec = _mm_andnot_ps(dummy_mask,velec);
679 velecsum = _mm_add_ps(velecsum,velec);
683 fscal = _mm_andnot_ps(dummy_mask,fscal);
685 /* Update vectorial force */
686 fix0 = _mm_macc_ps(dx02,fscal,fix0);
687 fiy0 = _mm_macc_ps(dy02,fscal,fiy0);
688 fiz0 = _mm_macc_ps(dz02,fscal,fiz0);
690 fjx2 = _mm_macc_ps(dx02,fscal,fjx2);
691 fjy2 = _mm_macc_ps(dy02,fscal,fjy2);
692 fjz2 = _mm_macc_ps(dz02,fscal,fjz2);
694 /**************************
695 * CALCULATE INTERACTIONS *
696 **************************/
698 /* COULOMB ELECTROSTATICS */
699 velec = _mm_mul_ps(qq10,rinv10);
700 felec = _mm_mul_ps(velec,rinvsq10);
702 /* Update potential sum for this i atom from the interaction with this j atom. */
703 velec = _mm_andnot_ps(dummy_mask,velec);
704 velecsum = _mm_add_ps(velecsum,velec);
708 fscal = _mm_andnot_ps(dummy_mask,fscal);
710 /* Update vectorial force */
711 fix1 = _mm_macc_ps(dx10,fscal,fix1);
712 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
713 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
715 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
716 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
717 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
719 /**************************
720 * CALCULATE INTERACTIONS *
721 **************************/
723 /* COULOMB ELECTROSTATICS */
724 velec = _mm_mul_ps(qq11,rinv11);
725 felec = _mm_mul_ps(velec,rinvsq11);
727 /* Update potential sum for this i atom from the interaction with this j atom. */
728 velec = _mm_andnot_ps(dummy_mask,velec);
729 velecsum = _mm_add_ps(velecsum,velec);
733 fscal = _mm_andnot_ps(dummy_mask,fscal);
735 /* Update vectorial force */
736 fix1 = _mm_macc_ps(dx11,fscal,fix1);
737 fiy1 = _mm_macc_ps(dy11,fscal,fiy1);
738 fiz1 = _mm_macc_ps(dz11,fscal,fiz1);
740 fjx1 = _mm_macc_ps(dx11,fscal,fjx1);
741 fjy1 = _mm_macc_ps(dy11,fscal,fjy1);
742 fjz1 = _mm_macc_ps(dz11,fscal,fjz1);
744 /**************************
745 * CALCULATE INTERACTIONS *
746 **************************/
748 /* COULOMB ELECTROSTATICS */
749 velec = _mm_mul_ps(qq12,rinv12);
750 felec = _mm_mul_ps(velec,rinvsq12);
752 /* Update potential sum for this i atom from the interaction with this j atom. */
753 velec = _mm_andnot_ps(dummy_mask,velec);
754 velecsum = _mm_add_ps(velecsum,velec);
758 fscal = _mm_andnot_ps(dummy_mask,fscal);
760 /* Update vectorial force */
761 fix1 = _mm_macc_ps(dx12,fscal,fix1);
762 fiy1 = _mm_macc_ps(dy12,fscal,fiy1);
763 fiz1 = _mm_macc_ps(dz12,fscal,fiz1);
765 fjx2 = _mm_macc_ps(dx12,fscal,fjx2);
766 fjy2 = _mm_macc_ps(dy12,fscal,fjy2);
767 fjz2 = _mm_macc_ps(dz12,fscal,fjz2);
769 /**************************
770 * CALCULATE INTERACTIONS *
771 **************************/
773 /* COULOMB ELECTROSTATICS */
774 velec = _mm_mul_ps(qq20,rinv20);
775 felec = _mm_mul_ps(velec,rinvsq20);
777 /* Update potential sum for this i atom from the interaction with this j atom. */
778 velec = _mm_andnot_ps(dummy_mask,velec);
779 velecsum = _mm_add_ps(velecsum,velec);
783 fscal = _mm_andnot_ps(dummy_mask,fscal);
785 /* Update vectorial force */
786 fix2 = _mm_macc_ps(dx20,fscal,fix2);
787 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
788 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
790 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
791 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
792 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
794 /**************************
795 * CALCULATE INTERACTIONS *
796 **************************/
798 /* COULOMB ELECTROSTATICS */
799 velec = _mm_mul_ps(qq21,rinv21);
800 felec = _mm_mul_ps(velec,rinvsq21);
802 /* Update potential sum for this i atom from the interaction with this j atom. */
803 velec = _mm_andnot_ps(dummy_mask,velec);
804 velecsum = _mm_add_ps(velecsum,velec);
808 fscal = _mm_andnot_ps(dummy_mask,fscal);
810 /* Update vectorial force */
811 fix2 = _mm_macc_ps(dx21,fscal,fix2);
812 fiy2 = _mm_macc_ps(dy21,fscal,fiy2);
813 fiz2 = _mm_macc_ps(dz21,fscal,fiz2);
815 fjx1 = _mm_macc_ps(dx21,fscal,fjx1);
816 fjy1 = _mm_macc_ps(dy21,fscal,fjy1);
817 fjz1 = _mm_macc_ps(dz21,fscal,fjz1);
819 /**************************
820 * CALCULATE INTERACTIONS *
821 **************************/
823 /* COULOMB ELECTROSTATICS */
824 velec = _mm_mul_ps(qq22,rinv22);
825 felec = _mm_mul_ps(velec,rinvsq22);
827 /* Update potential sum for this i atom from the interaction with this j atom. */
828 velec = _mm_andnot_ps(dummy_mask,velec);
829 velecsum = _mm_add_ps(velecsum,velec);
833 fscal = _mm_andnot_ps(dummy_mask,fscal);
835 /* Update vectorial force */
836 fix2 = _mm_macc_ps(dx22,fscal,fix2);
837 fiy2 = _mm_macc_ps(dy22,fscal,fiy2);
838 fiz2 = _mm_macc_ps(dz22,fscal,fiz2);
840 fjx2 = _mm_macc_ps(dx22,fscal,fjx2);
841 fjy2 = _mm_macc_ps(dy22,fscal,fjy2);
842 fjz2 = _mm_macc_ps(dz22,fscal,fjz2);
844 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
845 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
846 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
847 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
849 gmx_mm_decrement_3rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
850 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
852 /* Inner loop uses 291 flops */
855 /* End of innermost loop */
857 gmx_mm_update_iforce_3atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
858 f+i_coord_offset,fshift+i_shift_offset);
861 /* Update potential energies */
862 gmx_mm_update_1pot_ps(velecsum,kernel_data->energygrp_elec+ggid);
863 gmx_mm_update_1pot_ps(vvdwsum,kernel_data->energygrp_vdw+ggid);
865 /* Increment number of inner iterations */
866 inneriter += j_index_end - j_index_start;
868 /* Outer loop uses 20 flops */
871 /* Increment number of outer iterations */
874 /* Update outer/inner flops */
876 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*20 + inneriter*291);
879 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwLJ_GeomW3W3_F_avx_128_fma_single
880 * Electrostatics interaction: Coulomb
881 * VdW interaction: LennardJones
882 * Geometry: Water3-Water3
883 * Calculate force/pot: Force
886 nb_kernel_ElecCoul_VdwLJ_GeomW3W3_F_avx_128_fma_single
887 (t_nblist * gmx_restrict nlist,
888 rvec * gmx_restrict xx,
889 rvec * gmx_restrict ff,
890 t_forcerec * gmx_restrict fr,
891 t_mdatoms * gmx_restrict mdatoms,
892 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
893 t_nrnb * gmx_restrict nrnb)
895 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
896 * just 0 for non-waters.
897 * Suffixes A,B,C,D refer to j loop unrolling done with AVX_128, e.g. for the four different
898 * jnr indices corresponding to data put in the four positions in the SIMD register.
900 int i_shift_offset,i_coord_offset,outeriter,inneriter;
901 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
902 int jnrA,jnrB,jnrC,jnrD;
903 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
904 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
905 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
907 real *shiftvec,*fshift,*x,*f;
908 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
910 __m128 fscal,rcutoff,rcutoff2,jidxall;
912 __m128 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
914 __m128 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
916 __m128 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
917 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
918 __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
919 int vdwjidx1A,vdwjidx1B,vdwjidx1C,vdwjidx1D;
920 __m128 jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
921 int vdwjidx2A,vdwjidx2B,vdwjidx2C,vdwjidx2D;
922 __m128 jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
923 __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
924 __m128 dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01;
925 __m128 dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02;
926 __m128 dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
927 __m128 dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
928 __m128 dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
929 __m128 dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
930 __m128 dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
931 __m128 dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
932 __m128 velec,felec,velecsum,facel,crf,krf,krf2;
935 __m128 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
938 __m128 one_sixth = _mm_set1_ps(1.0/6.0);
939 __m128 one_twelfth = _mm_set1_ps(1.0/12.0);
940 __m128 dummy_mask,cutoff_mask;
941 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
942 __m128 one = _mm_set1_ps(1.0);
943 __m128 two = _mm_set1_ps(2.0);
949 jindex = nlist->jindex;
951 shiftidx = nlist->shift;
953 shiftvec = fr->shift_vec[0];
954 fshift = fr->fshift[0];
955 facel = _mm_set1_ps(fr->epsfac);
956 charge = mdatoms->chargeA;
957 nvdwtype = fr->ntype;
959 vdwtype = mdatoms->typeA;
961 /* Setup water-specific parameters */
962 inr = nlist->iinr[0];
963 iq0 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+0]));
964 iq1 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+1]));
965 iq2 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+2]));
966 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
968 jq0 = _mm_set1_ps(charge[inr+0]);
969 jq1 = _mm_set1_ps(charge[inr+1]);
970 jq2 = _mm_set1_ps(charge[inr+2]);
971 vdwjidx0A = 2*vdwtype[inr+0];
972 qq00 = _mm_mul_ps(iq0,jq0);
973 c6_00 = _mm_set1_ps(vdwparam[vdwioffset0+vdwjidx0A]);
974 c12_00 = _mm_set1_ps(vdwparam[vdwioffset0+vdwjidx0A+1]);
975 qq01 = _mm_mul_ps(iq0,jq1);
976 qq02 = _mm_mul_ps(iq0,jq2);
977 qq10 = _mm_mul_ps(iq1,jq0);
978 qq11 = _mm_mul_ps(iq1,jq1);
979 qq12 = _mm_mul_ps(iq1,jq2);
980 qq20 = _mm_mul_ps(iq2,jq0);
981 qq21 = _mm_mul_ps(iq2,jq1);
982 qq22 = _mm_mul_ps(iq2,jq2);
984 /* Avoid stupid compiler warnings */
985 jnrA = jnrB = jnrC = jnrD = 0;
994 for(iidx=0;iidx<4*DIM;iidx++)
999 /* Start outer loop over neighborlists */
1000 for(iidx=0; iidx<nri; iidx++)
1002 /* Load shift vector for this list */
1003 i_shift_offset = DIM*shiftidx[iidx];
1005 /* Load limits for loop over neighbors */
1006 j_index_start = jindex[iidx];
1007 j_index_end = jindex[iidx+1];
1009 /* Get outer coordinate index */
1011 i_coord_offset = DIM*inr;
1013 /* Load i particle coords and add shift vector */
1014 gmx_mm_load_shift_and_3rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
1015 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
1017 fix0 = _mm_setzero_ps();
1018 fiy0 = _mm_setzero_ps();
1019 fiz0 = _mm_setzero_ps();
1020 fix1 = _mm_setzero_ps();
1021 fiy1 = _mm_setzero_ps();
1022 fiz1 = _mm_setzero_ps();
1023 fix2 = _mm_setzero_ps();
1024 fiy2 = _mm_setzero_ps();
1025 fiz2 = _mm_setzero_ps();
1027 /* Start inner kernel loop */
1028 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
1031 /* Get j neighbor index, and coordinate index */
1033 jnrB = jjnr[jidx+1];
1034 jnrC = jjnr[jidx+2];
1035 jnrD = jjnr[jidx+3];
1036 j_coord_offsetA = DIM*jnrA;
1037 j_coord_offsetB = DIM*jnrB;
1038 j_coord_offsetC = DIM*jnrC;
1039 j_coord_offsetD = DIM*jnrD;
1041 /* load j atom coordinates */
1042 gmx_mm_load_3rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
1043 x+j_coord_offsetC,x+j_coord_offsetD,
1044 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
1046 /* Calculate displacement vector */
1047 dx00 = _mm_sub_ps(ix0,jx0);
1048 dy00 = _mm_sub_ps(iy0,jy0);
1049 dz00 = _mm_sub_ps(iz0,jz0);
1050 dx01 = _mm_sub_ps(ix0,jx1);
1051 dy01 = _mm_sub_ps(iy0,jy1);
1052 dz01 = _mm_sub_ps(iz0,jz1);
1053 dx02 = _mm_sub_ps(ix0,jx2);
1054 dy02 = _mm_sub_ps(iy0,jy2);
1055 dz02 = _mm_sub_ps(iz0,jz2);
1056 dx10 = _mm_sub_ps(ix1,jx0);
1057 dy10 = _mm_sub_ps(iy1,jy0);
1058 dz10 = _mm_sub_ps(iz1,jz0);
1059 dx11 = _mm_sub_ps(ix1,jx1);
1060 dy11 = _mm_sub_ps(iy1,jy1);
1061 dz11 = _mm_sub_ps(iz1,jz1);
1062 dx12 = _mm_sub_ps(ix1,jx2);
1063 dy12 = _mm_sub_ps(iy1,jy2);
1064 dz12 = _mm_sub_ps(iz1,jz2);
1065 dx20 = _mm_sub_ps(ix2,jx0);
1066 dy20 = _mm_sub_ps(iy2,jy0);
1067 dz20 = _mm_sub_ps(iz2,jz0);
1068 dx21 = _mm_sub_ps(ix2,jx1);
1069 dy21 = _mm_sub_ps(iy2,jy1);
1070 dz21 = _mm_sub_ps(iz2,jz1);
1071 dx22 = _mm_sub_ps(ix2,jx2);
1072 dy22 = _mm_sub_ps(iy2,jy2);
1073 dz22 = _mm_sub_ps(iz2,jz2);
1075 /* Calculate squared distance and things based on it */
1076 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
1077 rsq01 = gmx_mm_calc_rsq_ps(dx01,dy01,dz01);
1078 rsq02 = gmx_mm_calc_rsq_ps(dx02,dy02,dz02);
1079 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
1080 rsq11 = gmx_mm_calc_rsq_ps(dx11,dy11,dz11);
1081 rsq12 = gmx_mm_calc_rsq_ps(dx12,dy12,dz12);
1082 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
1083 rsq21 = gmx_mm_calc_rsq_ps(dx21,dy21,dz21);
1084 rsq22 = gmx_mm_calc_rsq_ps(dx22,dy22,dz22);
1086 rinv00 = gmx_mm_invsqrt_ps(rsq00);
1087 rinv01 = gmx_mm_invsqrt_ps(rsq01);
1088 rinv02 = gmx_mm_invsqrt_ps(rsq02);
1089 rinv10 = gmx_mm_invsqrt_ps(rsq10);
1090 rinv11 = gmx_mm_invsqrt_ps(rsq11);
1091 rinv12 = gmx_mm_invsqrt_ps(rsq12);
1092 rinv20 = gmx_mm_invsqrt_ps(rsq20);
1093 rinv21 = gmx_mm_invsqrt_ps(rsq21);
1094 rinv22 = gmx_mm_invsqrt_ps(rsq22);
1096 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
1097 rinvsq01 = _mm_mul_ps(rinv01,rinv01);
1098 rinvsq02 = _mm_mul_ps(rinv02,rinv02);
1099 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
1100 rinvsq11 = _mm_mul_ps(rinv11,rinv11);
1101 rinvsq12 = _mm_mul_ps(rinv12,rinv12);
1102 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
1103 rinvsq21 = _mm_mul_ps(rinv21,rinv21);
1104 rinvsq22 = _mm_mul_ps(rinv22,rinv22);
1106 fjx0 = _mm_setzero_ps();
1107 fjy0 = _mm_setzero_ps();
1108 fjz0 = _mm_setzero_ps();
1109 fjx1 = _mm_setzero_ps();
1110 fjy1 = _mm_setzero_ps();
1111 fjz1 = _mm_setzero_ps();
1112 fjx2 = _mm_setzero_ps();
1113 fjy2 = _mm_setzero_ps();
1114 fjz2 = _mm_setzero_ps();
1116 /**************************
1117 * CALCULATE INTERACTIONS *
1118 **************************/
1120 /* COULOMB ELECTROSTATICS */
1121 velec = _mm_mul_ps(qq00,rinv00);
1122 felec = _mm_mul_ps(velec,rinvsq00);
1124 /* LENNARD-JONES DISPERSION/REPULSION */
1126 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
1127 fvdw = _mm_mul_ps(_mm_msub_ps(c12_00,rinvsix,c6_00),_mm_mul_ps(rinvsix,rinvsq00));
1129 fscal = _mm_add_ps(felec,fvdw);
1131 /* Update vectorial force */
1132 fix0 = _mm_macc_ps(dx00,fscal,fix0);
1133 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
1134 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
1136 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
1137 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
1138 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
1140 /**************************
1141 * CALCULATE INTERACTIONS *
1142 **************************/
1144 /* COULOMB ELECTROSTATICS */
1145 velec = _mm_mul_ps(qq01,rinv01);
1146 felec = _mm_mul_ps(velec,rinvsq01);
1150 /* Update vectorial force */
1151 fix0 = _mm_macc_ps(dx01,fscal,fix0);
1152 fiy0 = _mm_macc_ps(dy01,fscal,fiy0);
1153 fiz0 = _mm_macc_ps(dz01,fscal,fiz0);
1155 fjx1 = _mm_macc_ps(dx01,fscal,fjx1);
1156 fjy1 = _mm_macc_ps(dy01,fscal,fjy1);
1157 fjz1 = _mm_macc_ps(dz01,fscal,fjz1);
1159 /**************************
1160 * CALCULATE INTERACTIONS *
1161 **************************/
1163 /* COULOMB ELECTROSTATICS */
1164 velec = _mm_mul_ps(qq02,rinv02);
1165 felec = _mm_mul_ps(velec,rinvsq02);
1169 /* Update vectorial force */
1170 fix0 = _mm_macc_ps(dx02,fscal,fix0);
1171 fiy0 = _mm_macc_ps(dy02,fscal,fiy0);
1172 fiz0 = _mm_macc_ps(dz02,fscal,fiz0);
1174 fjx2 = _mm_macc_ps(dx02,fscal,fjx2);
1175 fjy2 = _mm_macc_ps(dy02,fscal,fjy2);
1176 fjz2 = _mm_macc_ps(dz02,fscal,fjz2);
1178 /**************************
1179 * CALCULATE INTERACTIONS *
1180 **************************/
1182 /* COULOMB ELECTROSTATICS */
1183 velec = _mm_mul_ps(qq10,rinv10);
1184 felec = _mm_mul_ps(velec,rinvsq10);
1188 /* Update vectorial force */
1189 fix1 = _mm_macc_ps(dx10,fscal,fix1);
1190 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
1191 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
1193 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
1194 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
1195 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
1197 /**************************
1198 * CALCULATE INTERACTIONS *
1199 **************************/
1201 /* COULOMB ELECTROSTATICS */
1202 velec = _mm_mul_ps(qq11,rinv11);
1203 felec = _mm_mul_ps(velec,rinvsq11);
1207 /* Update vectorial force */
1208 fix1 = _mm_macc_ps(dx11,fscal,fix1);
1209 fiy1 = _mm_macc_ps(dy11,fscal,fiy1);
1210 fiz1 = _mm_macc_ps(dz11,fscal,fiz1);
1212 fjx1 = _mm_macc_ps(dx11,fscal,fjx1);
1213 fjy1 = _mm_macc_ps(dy11,fscal,fjy1);
1214 fjz1 = _mm_macc_ps(dz11,fscal,fjz1);
1216 /**************************
1217 * CALCULATE INTERACTIONS *
1218 **************************/
1220 /* COULOMB ELECTROSTATICS */
1221 velec = _mm_mul_ps(qq12,rinv12);
1222 felec = _mm_mul_ps(velec,rinvsq12);
1226 /* Update vectorial force */
1227 fix1 = _mm_macc_ps(dx12,fscal,fix1);
1228 fiy1 = _mm_macc_ps(dy12,fscal,fiy1);
1229 fiz1 = _mm_macc_ps(dz12,fscal,fiz1);
1231 fjx2 = _mm_macc_ps(dx12,fscal,fjx2);
1232 fjy2 = _mm_macc_ps(dy12,fscal,fjy2);
1233 fjz2 = _mm_macc_ps(dz12,fscal,fjz2);
1235 /**************************
1236 * CALCULATE INTERACTIONS *
1237 **************************/
1239 /* COULOMB ELECTROSTATICS */
1240 velec = _mm_mul_ps(qq20,rinv20);
1241 felec = _mm_mul_ps(velec,rinvsq20);
1245 /* Update vectorial force */
1246 fix2 = _mm_macc_ps(dx20,fscal,fix2);
1247 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
1248 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
1250 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
1251 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
1252 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
1254 /**************************
1255 * CALCULATE INTERACTIONS *
1256 **************************/
1258 /* COULOMB ELECTROSTATICS */
1259 velec = _mm_mul_ps(qq21,rinv21);
1260 felec = _mm_mul_ps(velec,rinvsq21);
1264 /* Update vectorial force */
1265 fix2 = _mm_macc_ps(dx21,fscal,fix2);
1266 fiy2 = _mm_macc_ps(dy21,fscal,fiy2);
1267 fiz2 = _mm_macc_ps(dz21,fscal,fiz2);
1269 fjx1 = _mm_macc_ps(dx21,fscal,fjx1);
1270 fjy1 = _mm_macc_ps(dy21,fscal,fjy1);
1271 fjz1 = _mm_macc_ps(dz21,fscal,fjz1);
1273 /**************************
1274 * CALCULATE INTERACTIONS *
1275 **************************/
1277 /* COULOMB ELECTROSTATICS */
1278 velec = _mm_mul_ps(qq22,rinv22);
1279 felec = _mm_mul_ps(velec,rinvsq22);
1283 /* Update vectorial force */
1284 fix2 = _mm_macc_ps(dx22,fscal,fix2);
1285 fiy2 = _mm_macc_ps(dy22,fscal,fiy2);
1286 fiz2 = _mm_macc_ps(dz22,fscal,fiz2);
1288 fjx2 = _mm_macc_ps(dx22,fscal,fjx2);
1289 fjy2 = _mm_macc_ps(dy22,fscal,fjy2);
1290 fjz2 = _mm_macc_ps(dz22,fscal,fjz2);
1292 fjptrA = f+j_coord_offsetA;
1293 fjptrB = f+j_coord_offsetB;
1294 fjptrC = f+j_coord_offsetC;
1295 fjptrD = f+j_coord_offsetD;
1297 gmx_mm_decrement_3rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
1298 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
1300 /* Inner loop uses 277 flops */
1303 if(jidx<j_index_end)
1306 /* Get j neighbor index, and coordinate index */
1307 jnrlistA = jjnr[jidx];
1308 jnrlistB = jjnr[jidx+1];
1309 jnrlistC = jjnr[jidx+2];
1310 jnrlistD = jjnr[jidx+3];
1311 /* Sign of each element will be negative for non-real atoms.
1312 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
1313 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
1315 dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
1316 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
1317 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
1318 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
1319 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
1320 j_coord_offsetA = DIM*jnrA;
1321 j_coord_offsetB = DIM*jnrB;
1322 j_coord_offsetC = DIM*jnrC;
1323 j_coord_offsetD = DIM*jnrD;
1325 /* load j atom coordinates */
1326 gmx_mm_load_3rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
1327 x+j_coord_offsetC,x+j_coord_offsetD,
1328 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
1330 /* Calculate displacement vector */
1331 dx00 = _mm_sub_ps(ix0,jx0);
1332 dy00 = _mm_sub_ps(iy0,jy0);
1333 dz00 = _mm_sub_ps(iz0,jz0);
1334 dx01 = _mm_sub_ps(ix0,jx1);
1335 dy01 = _mm_sub_ps(iy0,jy1);
1336 dz01 = _mm_sub_ps(iz0,jz1);
1337 dx02 = _mm_sub_ps(ix0,jx2);
1338 dy02 = _mm_sub_ps(iy0,jy2);
1339 dz02 = _mm_sub_ps(iz0,jz2);
1340 dx10 = _mm_sub_ps(ix1,jx0);
1341 dy10 = _mm_sub_ps(iy1,jy0);
1342 dz10 = _mm_sub_ps(iz1,jz0);
1343 dx11 = _mm_sub_ps(ix1,jx1);
1344 dy11 = _mm_sub_ps(iy1,jy1);
1345 dz11 = _mm_sub_ps(iz1,jz1);
1346 dx12 = _mm_sub_ps(ix1,jx2);
1347 dy12 = _mm_sub_ps(iy1,jy2);
1348 dz12 = _mm_sub_ps(iz1,jz2);
1349 dx20 = _mm_sub_ps(ix2,jx0);
1350 dy20 = _mm_sub_ps(iy2,jy0);
1351 dz20 = _mm_sub_ps(iz2,jz0);
1352 dx21 = _mm_sub_ps(ix2,jx1);
1353 dy21 = _mm_sub_ps(iy2,jy1);
1354 dz21 = _mm_sub_ps(iz2,jz1);
1355 dx22 = _mm_sub_ps(ix2,jx2);
1356 dy22 = _mm_sub_ps(iy2,jy2);
1357 dz22 = _mm_sub_ps(iz2,jz2);
1359 /* Calculate squared distance and things based on it */
1360 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
1361 rsq01 = gmx_mm_calc_rsq_ps(dx01,dy01,dz01);
1362 rsq02 = gmx_mm_calc_rsq_ps(dx02,dy02,dz02);
1363 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
1364 rsq11 = gmx_mm_calc_rsq_ps(dx11,dy11,dz11);
1365 rsq12 = gmx_mm_calc_rsq_ps(dx12,dy12,dz12);
1366 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
1367 rsq21 = gmx_mm_calc_rsq_ps(dx21,dy21,dz21);
1368 rsq22 = gmx_mm_calc_rsq_ps(dx22,dy22,dz22);
1370 rinv00 = gmx_mm_invsqrt_ps(rsq00);
1371 rinv01 = gmx_mm_invsqrt_ps(rsq01);
1372 rinv02 = gmx_mm_invsqrt_ps(rsq02);
1373 rinv10 = gmx_mm_invsqrt_ps(rsq10);
1374 rinv11 = gmx_mm_invsqrt_ps(rsq11);
1375 rinv12 = gmx_mm_invsqrt_ps(rsq12);
1376 rinv20 = gmx_mm_invsqrt_ps(rsq20);
1377 rinv21 = gmx_mm_invsqrt_ps(rsq21);
1378 rinv22 = gmx_mm_invsqrt_ps(rsq22);
1380 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
1381 rinvsq01 = _mm_mul_ps(rinv01,rinv01);
1382 rinvsq02 = _mm_mul_ps(rinv02,rinv02);
1383 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
1384 rinvsq11 = _mm_mul_ps(rinv11,rinv11);
1385 rinvsq12 = _mm_mul_ps(rinv12,rinv12);
1386 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
1387 rinvsq21 = _mm_mul_ps(rinv21,rinv21);
1388 rinvsq22 = _mm_mul_ps(rinv22,rinv22);
1390 fjx0 = _mm_setzero_ps();
1391 fjy0 = _mm_setzero_ps();
1392 fjz0 = _mm_setzero_ps();
1393 fjx1 = _mm_setzero_ps();
1394 fjy1 = _mm_setzero_ps();
1395 fjz1 = _mm_setzero_ps();
1396 fjx2 = _mm_setzero_ps();
1397 fjy2 = _mm_setzero_ps();
1398 fjz2 = _mm_setzero_ps();
1400 /**************************
1401 * CALCULATE INTERACTIONS *
1402 **************************/
1404 /* COULOMB ELECTROSTATICS */
1405 velec = _mm_mul_ps(qq00,rinv00);
1406 felec = _mm_mul_ps(velec,rinvsq00);
1408 /* LENNARD-JONES DISPERSION/REPULSION */
1410 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
1411 fvdw = _mm_mul_ps(_mm_msub_ps(c12_00,rinvsix,c6_00),_mm_mul_ps(rinvsix,rinvsq00));
1413 fscal = _mm_add_ps(felec,fvdw);
1415 fscal = _mm_andnot_ps(dummy_mask,fscal);
1417 /* Update vectorial force */
1418 fix0 = _mm_macc_ps(dx00,fscal,fix0);
1419 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
1420 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
1422 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
1423 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
1424 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
1426 /**************************
1427 * CALCULATE INTERACTIONS *
1428 **************************/
1430 /* COULOMB ELECTROSTATICS */
1431 velec = _mm_mul_ps(qq01,rinv01);
1432 felec = _mm_mul_ps(velec,rinvsq01);
1436 fscal = _mm_andnot_ps(dummy_mask,fscal);
1438 /* Update vectorial force */
1439 fix0 = _mm_macc_ps(dx01,fscal,fix0);
1440 fiy0 = _mm_macc_ps(dy01,fscal,fiy0);
1441 fiz0 = _mm_macc_ps(dz01,fscal,fiz0);
1443 fjx1 = _mm_macc_ps(dx01,fscal,fjx1);
1444 fjy1 = _mm_macc_ps(dy01,fscal,fjy1);
1445 fjz1 = _mm_macc_ps(dz01,fscal,fjz1);
1447 /**************************
1448 * CALCULATE INTERACTIONS *
1449 **************************/
1451 /* COULOMB ELECTROSTATICS */
1452 velec = _mm_mul_ps(qq02,rinv02);
1453 felec = _mm_mul_ps(velec,rinvsq02);
1457 fscal = _mm_andnot_ps(dummy_mask,fscal);
1459 /* Update vectorial force */
1460 fix0 = _mm_macc_ps(dx02,fscal,fix0);
1461 fiy0 = _mm_macc_ps(dy02,fscal,fiy0);
1462 fiz0 = _mm_macc_ps(dz02,fscal,fiz0);
1464 fjx2 = _mm_macc_ps(dx02,fscal,fjx2);
1465 fjy2 = _mm_macc_ps(dy02,fscal,fjy2);
1466 fjz2 = _mm_macc_ps(dz02,fscal,fjz2);
1468 /**************************
1469 * CALCULATE INTERACTIONS *
1470 **************************/
1472 /* COULOMB ELECTROSTATICS */
1473 velec = _mm_mul_ps(qq10,rinv10);
1474 felec = _mm_mul_ps(velec,rinvsq10);
1478 fscal = _mm_andnot_ps(dummy_mask,fscal);
1480 /* Update vectorial force */
1481 fix1 = _mm_macc_ps(dx10,fscal,fix1);
1482 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
1483 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
1485 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
1486 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
1487 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
1489 /**************************
1490 * CALCULATE INTERACTIONS *
1491 **************************/
1493 /* COULOMB ELECTROSTATICS */
1494 velec = _mm_mul_ps(qq11,rinv11);
1495 felec = _mm_mul_ps(velec,rinvsq11);
1499 fscal = _mm_andnot_ps(dummy_mask,fscal);
1501 /* Update vectorial force */
1502 fix1 = _mm_macc_ps(dx11,fscal,fix1);
1503 fiy1 = _mm_macc_ps(dy11,fscal,fiy1);
1504 fiz1 = _mm_macc_ps(dz11,fscal,fiz1);
1506 fjx1 = _mm_macc_ps(dx11,fscal,fjx1);
1507 fjy1 = _mm_macc_ps(dy11,fscal,fjy1);
1508 fjz1 = _mm_macc_ps(dz11,fscal,fjz1);
1510 /**************************
1511 * CALCULATE INTERACTIONS *
1512 **************************/
1514 /* COULOMB ELECTROSTATICS */
1515 velec = _mm_mul_ps(qq12,rinv12);
1516 felec = _mm_mul_ps(velec,rinvsq12);
1520 fscal = _mm_andnot_ps(dummy_mask,fscal);
1522 /* Update vectorial force */
1523 fix1 = _mm_macc_ps(dx12,fscal,fix1);
1524 fiy1 = _mm_macc_ps(dy12,fscal,fiy1);
1525 fiz1 = _mm_macc_ps(dz12,fscal,fiz1);
1527 fjx2 = _mm_macc_ps(dx12,fscal,fjx2);
1528 fjy2 = _mm_macc_ps(dy12,fscal,fjy2);
1529 fjz2 = _mm_macc_ps(dz12,fscal,fjz2);
1531 /**************************
1532 * CALCULATE INTERACTIONS *
1533 **************************/
1535 /* COULOMB ELECTROSTATICS */
1536 velec = _mm_mul_ps(qq20,rinv20);
1537 felec = _mm_mul_ps(velec,rinvsq20);
1541 fscal = _mm_andnot_ps(dummy_mask,fscal);
1543 /* Update vectorial force */
1544 fix2 = _mm_macc_ps(dx20,fscal,fix2);
1545 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
1546 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
1548 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
1549 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
1550 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
1552 /**************************
1553 * CALCULATE INTERACTIONS *
1554 **************************/
1556 /* COULOMB ELECTROSTATICS */
1557 velec = _mm_mul_ps(qq21,rinv21);
1558 felec = _mm_mul_ps(velec,rinvsq21);
1562 fscal = _mm_andnot_ps(dummy_mask,fscal);
1564 /* Update vectorial force */
1565 fix2 = _mm_macc_ps(dx21,fscal,fix2);
1566 fiy2 = _mm_macc_ps(dy21,fscal,fiy2);
1567 fiz2 = _mm_macc_ps(dz21,fscal,fiz2);
1569 fjx1 = _mm_macc_ps(dx21,fscal,fjx1);
1570 fjy1 = _mm_macc_ps(dy21,fscal,fjy1);
1571 fjz1 = _mm_macc_ps(dz21,fscal,fjz1);
1573 /**************************
1574 * CALCULATE INTERACTIONS *
1575 **************************/
1577 /* COULOMB ELECTROSTATICS */
1578 velec = _mm_mul_ps(qq22,rinv22);
1579 felec = _mm_mul_ps(velec,rinvsq22);
1583 fscal = _mm_andnot_ps(dummy_mask,fscal);
1585 /* Update vectorial force */
1586 fix2 = _mm_macc_ps(dx22,fscal,fix2);
1587 fiy2 = _mm_macc_ps(dy22,fscal,fiy2);
1588 fiz2 = _mm_macc_ps(dz22,fscal,fiz2);
1590 fjx2 = _mm_macc_ps(dx22,fscal,fjx2);
1591 fjy2 = _mm_macc_ps(dy22,fscal,fjy2);
1592 fjz2 = _mm_macc_ps(dz22,fscal,fjz2);
1594 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
1595 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
1596 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
1597 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
1599 gmx_mm_decrement_3rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
1600 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
1602 /* Inner loop uses 277 flops */
1605 /* End of innermost loop */
1607 gmx_mm_update_iforce_3atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
1608 f+i_coord_offset,fshift+i_shift_offset);
1610 /* Increment number of inner iterations */
1611 inneriter += j_index_end - j_index_start;
1613 /* Outer loop uses 18 flops */
1616 /* Increment number of outer iterations */
1619 /* Update outer/inner flops */
1621 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*18 + inneriter*277);