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_single kernel generator.
42 #include "../nb_kernel.h"
43 #include "gromacs/legacyheaders/types/simple.h"
44 #include "gromacs/math/vec.h"
45 #include "gromacs/legacyheaders/nrnb.h"
47 #include "gromacs/simd/math_x86_avx_128_fma_single.h"
48 #include "kernelutil_x86_avx_128_fma_single.h"
51 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwLJ_GeomW4W4_VF_avx_128_fma_single
52 * Electrostatics interaction: Coulomb
53 * VdW interaction: LennardJones
54 * Geometry: Water4-Water4
55 * Calculate force/pot: PotentialAndForce
58 nb_kernel_ElecCoul_VdwLJ_GeomW4W4_VF_avx_128_fma_single
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,C,D refer to j loop unrolling done with AVX_128, e.g. for the four 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;
74 int jnrA,jnrB,jnrC,jnrD;
75 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
76 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
77 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
79 real *shiftvec,*fshift,*x,*f;
80 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
82 __m128 fscal,rcutoff,rcutoff2,jidxall;
84 __m128 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
86 __m128 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
88 __m128 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
90 __m128 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
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 int vdwjidx3A,vdwjidx3B,vdwjidx3C,vdwjidx3D;
98 __m128 jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
99 __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
100 __m128 dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
101 __m128 dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
102 __m128 dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13;
103 __m128 dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
104 __m128 dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
105 __m128 dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23;
106 __m128 dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31;
107 __m128 dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32;
108 __m128 dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33;
109 __m128 velec,felec,velecsum,facel,crf,krf,krf2;
112 __m128 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
115 __m128 one_sixth = _mm_set1_ps(1.0/6.0);
116 __m128 one_twelfth = _mm_set1_ps(1.0/12.0);
117 __m128 dummy_mask,cutoff_mask;
118 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
119 __m128 one = _mm_set1_ps(1.0);
120 __m128 two = _mm_set1_ps(2.0);
126 jindex = nlist->jindex;
128 shiftidx = nlist->shift;
130 shiftvec = fr->shift_vec[0];
131 fshift = fr->fshift[0];
132 facel = _mm_set1_ps(fr->epsfac);
133 charge = mdatoms->chargeA;
134 nvdwtype = fr->ntype;
136 vdwtype = mdatoms->typeA;
138 /* Setup water-specific parameters */
139 inr = nlist->iinr[0];
140 iq1 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+1]));
141 iq2 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+2]));
142 iq3 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+3]));
143 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
145 jq1 = _mm_set1_ps(charge[inr+1]);
146 jq2 = _mm_set1_ps(charge[inr+2]);
147 jq3 = _mm_set1_ps(charge[inr+3]);
148 vdwjidx0A = 2*vdwtype[inr+0];
149 c6_00 = _mm_set1_ps(vdwparam[vdwioffset0+vdwjidx0A]);
150 c12_00 = _mm_set1_ps(vdwparam[vdwioffset0+vdwjidx0A+1]);
151 qq11 = _mm_mul_ps(iq1,jq1);
152 qq12 = _mm_mul_ps(iq1,jq2);
153 qq13 = _mm_mul_ps(iq1,jq3);
154 qq21 = _mm_mul_ps(iq2,jq1);
155 qq22 = _mm_mul_ps(iq2,jq2);
156 qq23 = _mm_mul_ps(iq2,jq3);
157 qq31 = _mm_mul_ps(iq3,jq1);
158 qq32 = _mm_mul_ps(iq3,jq2);
159 qq33 = _mm_mul_ps(iq3,jq3);
161 /* Avoid stupid compiler warnings */
162 jnrA = jnrB = jnrC = jnrD = 0;
171 for(iidx=0;iidx<4*DIM;iidx++)
176 /* Start outer loop over neighborlists */
177 for(iidx=0; iidx<nri; iidx++)
179 /* Load shift vector for this list */
180 i_shift_offset = DIM*shiftidx[iidx];
182 /* Load limits for loop over neighbors */
183 j_index_start = jindex[iidx];
184 j_index_end = jindex[iidx+1];
186 /* Get outer coordinate index */
188 i_coord_offset = DIM*inr;
190 /* Load i particle coords and add shift vector */
191 gmx_mm_load_shift_and_4rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
192 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
194 fix0 = _mm_setzero_ps();
195 fiy0 = _mm_setzero_ps();
196 fiz0 = _mm_setzero_ps();
197 fix1 = _mm_setzero_ps();
198 fiy1 = _mm_setzero_ps();
199 fiz1 = _mm_setzero_ps();
200 fix2 = _mm_setzero_ps();
201 fiy2 = _mm_setzero_ps();
202 fiz2 = _mm_setzero_ps();
203 fix3 = _mm_setzero_ps();
204 fiy3 = _mm_setzero_ps();
205 fiz3 = _mm_setzero_ps();
207 /* Reset potential sums */
208 velecsum = _mm_setzero_ps();
209 vvdwsum = _mm_setzero_ps();
211 /* Start inner kernel loop */
212 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
215 /* Get j neighbor index, and coordinate index */
220 j_coord_offsetA = DIM*jnrA;
221 j_coord_offsetB = DIM*jnrB;
222 j_coord_offsetC = DIM*jnrC;
223 j_coord_offsetD = DIM*jnrD;
225 /* load j atom coordinates */
226 gmx_mm_load_4rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
227 x+j_coord_offsetC,x+j_coord_offsetD,
228 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,
229 &jy2,&jz2,&jx3,&jy3,&jz3);
231 /* Calculate displacement vector */
232 dx00 = _mm_sub_ps(ix0,jx0);
233 dy00 = _mm_sub_ps(iy0,jy0);
234 dz00 = _mm_sub_ps(iz0,jz0);
235 dx11 = _mm_sub_ps(ix1,jx1);
236 dy11 = _mm_sub_ps(iy1,jy1);
237 dz11 = _mm_sub_ps(iz1,jz1);
238 dx12 = _mm_sub_ps(ix1,jx2);
239 dy12 = _mm_sub_ps(iy1,jy2);
240 dz12 = _mm_sub_ps(iz1,jz2);
241 dx13 = _mm_sub_ps(ix1,jx3);
242 dy13 = _mm_sub_ps(iy1,jy3);
243 dz13 = _mm_sub_ps(iz1,jz3);
244 dx21 = _mm_sub_ps(ix2,jx1);
245 dy21 = _mm_sub_ps(iy2,jy1);
246 dz21 = _mm_sub_ps(iz2,jz1);
247 dx22 = _mm_sub_ps(ix2,jx2);
248 dy22 = _mm_sub_ps(iy2,jy2);
249 dz22 = _mm_sub_ps(iz2,jz2);
250 dx23 = _mm_sub_ps(ix2,jx3);
251 dy23 = _mm_sub_ps(iy2,jy3);
252 dz23 = _mm_sub_ps(iz2,jz3);
253 dx31 = _mm_sub_ps(ix3,jx1);
254 dy31 = _mm_sub_ps(iy3,jy1);
255 dz31 = _mm_sub_ps(iz3,jz1);
256 dx32 = _mm_sub_ps(ix3,jx2);
257 dy32 = _mm_sub_ps(iy3,jy2);
258 dz32 = _mm_sub_ps(iz3,jz2);
259 dx33 = _mm_sub_ps(ix3,jx3);
260 dy33 = _mm_sub_ps(iy3,jy3);
261 dz33 = _mm_sub_ps(iz3,jz3);
263 /* Calculate squared distance and things based on it */
264 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
265 rsq11 = gmx_mm_calc_rsq_ps(dx11,dy11,dz11);
266 rsq12 = gmx_mm_calc_rsq_ps(dx12,dy12,dz12);
267 rsq13 = gmx_mm_calc_rsq_ps(dx13,dy13,dz13);
268 rsq21 = gmx_mm_calc_rsq_ps(dx21,dy21,dz21);
269 rsq22 = gmx_mm_calc_rsq_ps(dx22,dy22,dz22);
270 rsq23 = gmx_mm_calc_rsq_ps(dx23,dy23,dz23);
271 rsq31 = gmx_mm_calc_rsq_ps(dx31,dy31,dz31);
272 rsq32 = gmx_mm_calc_rsq_ps(dx32,dy32,dz32);
273 rsq33 = gmx_mm_calc_rsq_ps(dx33,dy33,dz33);
275 rinv11 = gmx_mm_invsqrt_ps(rsq11);
276 rinv12 = gmx_mm_invsqrt_ps(rsq12);
277 rinv13 = gmx_mm_invsqrt_ps(rsq13);
278 rinv21 = gmx_mm_invsqrt_ps(rsq21);
279 rinv22 = gmx_mm_invsqrt_ps(rsq22);
280 rinv23 = gmx_mm_invsqrt_ps(rsq23);
281 rinv31 = gmx_mm_invsqrt_ps(rsq31);
282 rinv32 = gmx_mm_invsqrt_ps(rsq32);
283 rinv33 = gmx_mm_invsqrt_ps(rsq33);
285 rinvsq00 = gmx_mm_inv_ps(rsq00);
286 rinvsq11 = _mm_mul_ps(rinv11,rinv11);
287 rinvsq12 = _mm_mul_ps(rinv12,rinv12);
288 rinvsq13 = _mm_mul_ps(rinv13,rinv13);
289 rinvsq21 = _mm_mul_ps(rinv21,rinv21);
290 rinvsq22 = _mm_mul_ps(rinv22,rinv22);
291 rinvsq23 = _mm_mul_ps(rinv23,rinv23);
292 rinvsq31 = _mm_mul_ps(rinv31,rinv31);
293 rinvsq32 = _mm_mul_ps(rinv32,rinv32);
294 rinvsq33 = _mm_mul_ps(rinv33,rinv33);
296 fjx0 = _mm_setzero_ps();
297 fjy0 = _mm_setzero_ps();
298 fjz0 = _mm_setzero_ps();
299 fjx1 = _mm_setzero_ps();
300 fjy1 = _mm_setzero_ps();
301 fjz1 = _mm_setzero_ps();
302 fjx2 = _mm_setzero_ps();
303 fjy2 = _mm_setzero_ps();
304 fjz2 = _mm_setzero_ps();
305 fjx3 = _mm_setzero_ps();
306 fjy3 = _mm_setzero_ps();
307 fjz3 = _mm_setzero_ps();
309 /**************************
310 * CALCULATE INTERACTIONS *
311 **************************/
313 /* LENNARD-JONES DISPERSION/REPULSION */
315 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
316 vvdw6 = _mm_mul_ps(c6_00,rinvsix);
317 vvdw12 = _mm_mul_ps(c12_00,_mm_mul_ps(rinvsix,rinvsix));
318 vvdw = _mm_msub_ps(vvdw12,one_twelfth,_mm_mul_ps(vvdw6,one_sixth));
319 fvdw = _mm_mul_ps(_mm_sub_ps(vvdw12,vvdw6),rinvsq00);
321 /* Update potential sum for this i atom from the interaction with this j atom. */
322 vvdwsum = _mm_add_ps(vvdwsum,vvdw);
326 /* Update vectorial force */
327 fix0 = _mm_macc_ps(dx00,fscal,fix0);
328 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
329 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
331 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
332 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
333 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
335 /**************************
336 * CALCULATE INTERACTIONS *
337 **************************/
339 /* COULOMB ELECTROSTATICS */
340 velec = _mm_mul_ps(qq11,rinv11);
341 felec = _mm_mul_ps(velec,rinvsq11);
343 /* Update potential sum for this i atom from the interaction with this j atom. */
344 velecsum = _mm_add_ps(velecsum,velec);
348 /* Update vectorial force */
349 fix1 = _mm_macc_ps(dx11,fscal,fix1);
350 fiy1 = _mm_macc_ps(dy11,fscal,fiy1);
351 fiz1 = _mm_macc_ps(dz11,fscal,fiz1);
353 fjx1 = _mm_macc_ps(dx11,fscal,fjx1);
354 fjy1 = _mm_macc_ps(dy11,fscal,fjy1);
355 fjz1 = _mm_macc_ps(dz11,fscal,fjz1);
357 /**************************
358 * CALCULATE INTERACTIONS *
359 **************************/
361 /* COULOMB ELECTROSTATICS */
362 velec = _mm_mul_ps(qq12,rinv12);
363 felec = _mm_mul_ps(velec,rinvsq12);
365 /* Update potential sum for this i atom from the interaction with this j atom. */
366 velecsum = _mm_add_ps(velecsum,velec);
370 /* Update vectorial force */
371 fix1 = _mm_macc_ps(dx12,fscal,fix1);
372 fiy1 = _mm_macc_ps(dy12,fscal,fiy1);
373 fiz1 = _mm_macc_ps(dz12,fscal,fiz1);
375 fjx2 = _mm_macc_ps(dx12,fscal,fjx2);
376 fjy2 = _mm_macc_ps(dy12,fscal,fjy2);
377 fjz2 = _mm_macc_ps(dz12,fscal,fjz2);
379 /**************************
380 * CALCULATE INTERACTIONS *
381 **************************/
383 /* COULOMB ELECTROSTATICS */
384 velec = _mm_mul_ps(qq13,rinv13);
385 felec = _mm_mul_ps(velec,rinvsq13);
387 /* Update potential sum for this i atom from the interaction with this j atom. */
388 velecsum = _mm_add_ps(velecsum,velec);
392 /* Update vectorial force */
393 fix1 = _mm_macc_ps(dx13,fscal,fix1);
394 fiy1 = _mm_macc_ps(dy13,fscal,fiy1);
395 fiz1 = _mm_macc_ps(dz13,fscal,fiz1);
397 fjx3 = _mm_macc_ps(dx13,fscal,fjx3);
398 fjy3 = _mm_macc_ps(dy13,fscal,fjy3);
399 fjz3 = _mm_macc_ps(dz13,fscal,fjz3);
401 /**************************
402 * CALCULATE INTERACTIONS *
403 **************************/
405 /* COULOMB ELECTROSTATICS */
406 velec = _mm_mul_ps(qq21,rinv21);
407 felec = _mm_mul_ps(velec,rinvsq21);
409 /* Update potential sum for this i atom from the interaction with this j atom. */
410 velecsum = _mm_add_ps(velecsum,velec);
414 /* Update vectorial force */
415 fix2 = _mm_macc_ps(dx21,fscal,fix2);
416 fiy2 = _mm_macc_ps(dy21,fscal,fiy2);
417 fiz2 = _mm_macc_ps(dz21,fscal,fiz2);
419 fjx1 = _mm_macc_ps(dx21,fscal,fjx1);
420 fjy1 = _mm_macc_ps(dy21,fscal,fjy1);
421 fjz1 = _mm_macc_ps(dz21,fscal,fjz1);
423 /**************************
424 * CALCULATE INTERACTIONS *
425 **************************/
427 /* COULOMB ELECTROSTATICS */
428 velec = _mm_mul_ps(qq22,rinv22);
429 felec = _mm_mul_ps(velec,rinvsq22);
431 /* Update potential sum for this i atom from the interaction with this j atom. */
432 velecsum = _mm_add_ps(velecsum,velec);
436 /* Update vectorial force */
437 fix2 = _mm_macc_ps(dx22,fscal,fix2);
438 fiy2 = _mm_macc_ps(dy22,fscal,fiy2);
439 fiz2 = _mm_macc_ps(dz22,fscal,fiz2);
441 fjx2 = _mm_macc_ps(dx22,fscal,fjx2);
442 fjy2 = _mm_macc_ps(dy22,fscal,fjy2);
443 fjz2 = _mm_macc_ps(dz22,fscal,fjz2);
445 /**************************
446 * CALCULATE INTERACTIONS *
447 **************************/
449 /* COULOMB ELECTROSTATICS */
450 velec = _mm_mul_ps(qq23,rinv23);
451 felec = _mm_mul_ps(velec,rinvsq23);
453 /* Update potential sum for this i atom from the interaction with this j atom. */
454 velecsum = _mm_add_ps(velecsum,velec);
458 /* Update vectorial force */
459 fix2 = _mm_macc_ps(dx23,fscal,fix2);
460 fiy2 = _mm_macc_ps(dy23,fscal,fiy2);
461 fiz2 = _mm_macc_ps(dz23,fscal,fiz2);
463 fjx3 = _mm_macc_ps(dx23,fscal,fjx3);
464 fjy3 = _mm_macc_ps(dy23,fscal,fjy3);
465 fjz3 = _mm_macc_ps(dz23,fscal,fjz3);
467 /**************************
468 * CALCULATE INTERACTIONS *
469 **************************/
471 /* COULOMB ELECTROSTATICS */
472 velec = _mm_mul_ps(qq31,rinv31);
473 felec = _mm_mul_ps(velec,rinvsq31);
475 /* Update potential sum for this i atom from the interaction with this j atom. */
476 velecsum = _mm_add_ps(velecsum,velec);
480 /* Update vectorial force */
481 fix3 = _mm_macc_ps(dx31,fscal,fix3);
482 fiy3 = _mm_macc_ps(dy31,fscal,fiy3);
483 fiz3 = _mm_macc_ps(dz31,fscal,fiz3);
485 fjx1 = _mm_macc_ps(dx31,fscal,fjx1);
486 fjy1 = _mm_macc_ps(dy31,fscal,fjy1);
487 fjz1 = _mm_macc_ps(dz31,fscal,fjz1);
489 /**************************
490 * CALCULATE INTERACTIONS *
491 **************************/
493 /* COULOMB ELECTROSTATICS */
494 velec = _mm_mul_ps(qq32,rinv32);
495 felec = _mm_mul_ps(velec,rinvsq32);
497 /* Update potential sum for this i atom from the interaction with this j atom. */
498 velecsum = _mm_add_ps(velecsum,velec);
502 /* Update vectorial force */
503 fix3 = _mm_macc_ps(dx32,fscal,fix3);
504 fiy3 = _mm_macc_ps(dy32,fscal,fiy3);
505 fiz3 = _mm_macc_ps(dz32,fscal,fiz3);
507 fjx2 = _mm_macc_ps(dx32,fscal,fjx2);
508 fjy2 = _mm_macc_ps(dy32,fscal,fjy2);
509 fjz2 = _mm_macc_ps(dz32,fscal,fjz2);
511 /**************************
512 * CALCULATE INTERACTIONS *
513 **************************/
515 /* COULOMB ELECTROSTATICS */
516 velec = _mm_mul_ps(qq33,rinv33);
517 felec = _mm_mul_ps(velec,rinvsq33);
519 /* Update potential sum for this i atom from the interaction with this j atom. */
520 velecsum = _mm_add_ps(velecsum,velec);
524 /* Update vectorial force */
525 fix3 = _mm_macc_ps(dx33,fscal,fix3);
526 fiy3 = _mm_macc_ps(dy33,fscal,fiy3);
527 fiz3 = _mm_macc_ps(dz33,fscal,fiz3);
529 fjx3 = _mm_macc_ps(dx33,fscal,fjx3);
530 fjy3 = _mm_macc_ps(dy33,fscal,fjy3);
531 fjz3 = _mm_macc_ps(dz33,fscal,fjz3);
533 fjptrA = f+j_coord_offsetA;
534 fjptrB = f+j_coord_offsetB;
535 fjptrC = f+j_coord_offsetC;
536 fjptrD = f+j_coord_offsetD;
538 gmx_mm_decrement_4rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
539 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,
540 fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
542 /* Inner loop uses 317 flops */
548 /* Get j neighbor index, and coordinate index */
549 jnrlistA = jjnr[jidx];
550 jnrlistB = jjnr[jidx+1];
551 jnrlistC = jjnr[jidx+2];
552 jnrlistD = jjnr[jidx+3];
553 /* Sign of each element will be negative for non-real atoms.
554 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
555 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
557 dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
558 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
559 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
560 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
561 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
562 j_coord_offsetA = DIM*jnrA;
563 j_coord_offsetB = DIM*jnrB;
564 j_coord_offsetC = DIM*jnrC;
565 j_coord_offsetD = DIM*jnrD;
567 /* load j atom coordinates */
568 gmx_mm_load_4rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
569 x+j_coord_offsetC,x+j_coord_offsetD,
570 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,
571 &jy2,&jz2,&jx3,&jy3,&jz3);
573 /* Calculate displacement vector */
574 dx00 = _mm_sub_ps(ix0,jx0);
575 dy00 = _mm_sub_ps(iy0,jy0);
576 dz00 = _mm_sub_ps(iz0,jz0);
577 dx11 = _mm_sub_ps(ix1,jx1);
578 dy11 = _mm_sub_ps(iy1,jy1);
579 dz11 = _mm_sub_ps(iz1,jz1);
580 dx12 = _mm_sub_ps(ix1,jx2);
581 dy12 = _mm_sub_ps(iy1,jy2);
582 dz12 = _mm_sub_ps(iz1,jz2);
583 dx13 = _mm_sub_ps(ix1,jx3);
584 dy13 = _mm_sub_ps(iy1,jy3);
585 dz13 = _mm_sub_ps(iz1,jz3);
586 dx21 = _mm_sub_ps(ix2,jx1);
587 dy21 = _mm_sub_ps(iy2,jy1);
588 dz21 = _mm_sub_ps(iz2,jz1);
589 dx22 = _mm_sub_ps(ix2,jx2);
590 dy22 = _mm_sub_ps(iy2,jy2);
591 dz22 = _mm_sub_ps(iz2,jz2);
592 dx23 = _mm_sub_ps(ix2,jx3);
593 dy23 = _mm_sub_ps(iy2,jy3);
594 dz23 = _mm_sub_ps(iz2,jz3);
595 dx31 = _mm_sub_ps(ix3,jx1);
596 dy31 = _mm_sub_ps(iy3,jy1);
597 dz31 = _mm_sub_ps(iz3,jz1);
598 dx32 = _mm_sub_ps(ix3,jx2);
599 dy32 = _mm_sub_ps(iy3,jy2);
600 dz32 = _mm_sub_ps(iz3,jz2);
601 dx33 = _mm_sub_ps(ix3,jx3);
602 dy33 = _mm_sub_ps(iy3,jy3);
603 dz33 = _mm_sub_ps(iz3,jz3);
605 /* Calculate squared distance and things based on it */
606 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
607 rsq11 = gmx_mm_calc_rsq_ps(dx11,dy11,dz11);
608 rsq12 = gmx_mm_calc_rsq_ps(dx12,dy12,dz12);
609 rsq13 = gmx_mm_calc_rsq_ps(dx13,dy13,dz13);
610 rsq21 = gmx_mm_calc_rsq_ps(dx21,dy21,dz21);
611 rsq22 = gmx_mm_calc_rsq_ps(dx22,dy22,dz22);
612 rsq23 = gmx_mm_calc_rsq_ps(dx23,dy23,dz23);
613 rsq31 = gmx_mm_calc_rsq_ps(dx31,dy31,dz31);
614 rsq32 = gmx_mm_calc_rsq_ps(dx32,dy32,dz32);
615 rsq33 = gmx_mm_calc_rsq_ps(dx33,dy33,dz33);
617 rinv11 = gmx_mm_invsqrt_ps(rsq11);
618 rinv12 = gmx_mm_invsqrt_ps(rsq12);
619 rinv13 = gmx_mm_invsqrt_ps(rsq13);
620 rinv21 = gmx_mm_invsqrt_ps(rsq21);
621 rinv22 = gmx_mm_invsqrt_ps(rsq22);
622 rinv23 = gmx_mm_invsqrt_ps(rsq23);
623 rinv31 = gmx_mm_invsqrt_ps(rsq31);
624 rinv32 = gmx_mm_invsqrt_ps(rsq32);
625 rinv33 = gmx_mm_invsqrt_ps(rsq33);
627 rinvsq00 = gmx_mm_inv_ps(rsq00);
628 rinvsq11 = _mm_mul_ps(rinv11,rinv11);
629 rinvsq12 = _mm_mul_ps(rinv12,rinv12);
630 rinvsq13 = _mm_mul_ps(rinv13,rinv13);
631 rinvsq21 = _mm_mul_ps(rinv21,rinv21);
632 rinvsq22 = _mm_mul_ps(rinv22,rinv22);
633 rinvsq23 = _mm_mul_ps(rinv23,rinv23);
634 rinvsq31 = _mm_mul_ps(rinv31,rinv31);
635 rinvsq32 = _mm_mul_ps(rinv32,rinv32);
636 rinvsq33 = _mm_mul_ps(rinv33,rinv33);
638 fjx0 = _mm_setzero_ps();
639 fjy0 = _mm_setzero_ps();
640 fjz0 = _mm_setzero_ps();
641 fjx1 = _mm_setzero_ps();
642 fjy1 = _mm_setzero_ps();
643 fjz1 = _mm_setzero_ps();
644 fjx2 = _mm_setzero_ps();
645 fjy2 = _mm_setzero_ps();
646 fjz2 = _mm_setzero_ps();
647 fjx3 = _mm_setzero_ps();
648 fjy3 = _mm_setzero_ps();
649 fjz3 = _mm_setzero_ps();
651 /**************************
652 * CALCULATE INTERACTIONS *
653 **************************/
655 /* LENNARD-JONES DISPERSION/REPULSION */
657 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
658 vvdw6 = _mm_mul_ps(c6_00,rinvsix);
659 vvdw12 = _mm_mul_ps(c12_00,_mm_mul_ps(rinvsix,rinvsix));
660 vvdw = _mm_msub_ps(vvdw12,one_twelfth,_mm_mul_ps(vvdw6,one_sixth));
661 fvdw = _mm_mul_ps(_mm_sub_ps(vvdw12,vvdw6),rinvsq00);
663 /* Update potential sum for this i atom from the interaction with this j atom. */
664 vvdw = _mm_andnot_ps(dummy_mask,vvdw);
665 vvdwsum = _mm_add_ps(vvdwsum,vvdw);
669 fscal = _mm_andnot_ps(dummy_mask,fscal);
671 /* Update vectorial force */
672 fix0 = _mm_macc_ps(dx00,fscal,fix0);
673 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
674 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
676 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
677 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
678 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
680 /**************************
681 * CALCULATE INTERACTIONS *
682 **************************/
684 /* COULOMB ELECTROSTATICS */
685 velec = _mm_mul_ps(qq11,rinv11);
686 felec = _mm_mul_ps(velec,rinvsq11);
688 /* Update potential sum for this i atom from the interaction with this j atom. */
689 velec = _mm_andnot_ps(dummy_mask,velec);
690 velecsum = _mm_add_ps(velecsum,velec);
694 fscal = _mm_andnot_ps(dummy_mask,fscal);
696 /* Update vectorial force */
697 fix1 = _mm_macc_ps(dx11,fscal,fix1);
698 fiy1 = _mm_macc_ps(dy11,fscal,fiy1);
699 fiz1 = _mm_macc_ps(dz11,fscal,fiz1);
701 fjx1 = _mm_macc_ps(dx11,fscal,fjx1);
702 fjy1 = _mm_macc_ps(dy11,fscal,fjy1);
703 fjz1 = _mm_macc_ps(dz11,fscal,fjz1);
705 /**************************
706 * CALCULATE INTERACTIONS *
707 **************************/
709 /* COULOMB ELECTROSTATICS */
710 velec = _mm_mul_ps(qq12,rinv12);
711 felec = _mm_mul_ps(velec,rinvsq12);
713 /* Update potential sum for this i atom from the interaction with this j atom. */
714 velec = _mm_andnot_ps(dummy_mask,velec);
715 velecsum = _mm_add_ps(velecsum,velec);
719 fscal = _mm_andnot_ps(dummy_mask,fscal);
721 /* Update vectorial force */
722 fix1 = _mm_macc_ps(dx12,fscal,fix1);
723 fiy1 = _mm_macc_ps(dy12,fscal,fiy1);
724 fiz1 = _mm_macc_ps(dz12,fscal,fiz1);
726 fjx2 = _mm_macc_ps(dx12,fscal,fjx2);
727 fjy2 = _mm_macc_ps(dy12,fscal,fjy2);
728 fjz2 = _mm_macc_ps(dz12,fscal,fjz2);
730 /**************************
731 * CALCULATE INTERACTIONS *
732 **************************/
734 /* COULOMB ELECTROSTATICS */
735 velec = _mm_mul_ps(qq13,rinv13);
736 felec = _mm_mul_ps(velec,rinvsq13);
738 /* Update potential sum for this i atom from the interaction with this j atom. */
739 velec = _mm_andnot_ps(dummy_mask,velec);
740 velecsum = _mm_add_ps(velecsum,velec);
744 fscal = _mm_andnot_ps(dummy_mask,fscal);
746 /* Update vectorial force */
747 fix1 = _mm_macc_ps(dx13,fscal,fix1);
748 fiy1 = _mm_macc_ps(dy13,fscal,fiy1);
749 fiz1 = _mm_macc_ps(dz13,fscal,fiz1);
751 fjx3 = _mm_macc_ps(dx13,fscal,fjx3);
752 fjy3 = _mm_macc_ps(dy13,fscal,fjy3);
753 fjz3 = _mm_macc_ps(dz13,fscal,fjz3);
755 /**************************
756 * CALCULATE INTERACTIONS *
757 **************************/
759 /* COULOMB ELECTROSTATICS */
760 velec = _mm_mul_ps(qq21,rinv21);
761 felec = _mm_mul_ps(velec,rinvsq21);
763 /* Update potential sum for this i atom from the interaction with this j atom. */
764 velec = _mm_andnot_ps(dummy_mask,velec);
765 velecsum = _mm_add_ps(velecsum,velec);
769 fscal = _mm_andnot_ps(dummy_mask,fscal);
771 /* Update vectorial force */
772 fix2 = _mm_macc_ps(dx21,fscal,fix2);
773 fiy2 = _mm_macc_ps(dy21,fscal,fiy2);
774 fiz2 = _mm_macc_ps(dz21,fscal,fiz2);
776 fjx1 = _mm_macc_ps(dx21,fscal,fjx1);
777 fjy1 = _mm_macc_ps(dy21,fscal,fjy1);
778 fjz1 = _mm_macc_ps(dz21,fscal,fjz1);
780 /**************************
781 * CALCULATE INTERACTIONS *
782 **************************/
784 /* COULOMB ELECTROSTATICS */
785 velec = _mm_mul_ps(qq22,rinv22);
786 felec = _mm_mul_ps(velec,rinvsq22);
788 /* Update potential sum for this i atom from the interaction with this j atom. */
789 velec = _mm_andnot_ps(dummy_mask,velec);
790 velecsum = _mm_add_ps(velecsum,velec);
794 fscal = _mm_andnot_ps(dummy_mask,fscal);
796 /* Update vectorial force */
797 fix2 = _mm_macc_ps(dx22,fscal,fix2);
798 fiy2 = _mm_macc_ps(dy22,fscal,fiy2);
799 fiz2 = _mm_macc_ps(dz22,fscal,fiz2);
801 fjx2 = _mm_macc_ps(dx22,fscal,fjx2);
802 fjy2 = _mm_macc_ps(dy22,fscal,fjy2);
803 fjz2 = _mm_macc_ps(dz22,fscal,fjz2);
805 /**************************
806 * CALCULATE INTERACTIONS *
807 **************************/
809 /* COULOMB ELECTROSTATICS */
810 velec = _mm_mul_ps(qq23,rinv23);
811 felec = _mm_mul_ps(velec,rinvsq23);
813 /* Update potential sum for this i atom from the interaction with this j atom. */
814 velec = _mm_andnot_ps(dummy_mask,velec);
815 velecsum = _mm_add_ps(velecsum,velec);
819 fscal = _mm_andnot_ps(dummy_mask,fscal);
821 /* Update vectorial force */
822 fix2 = _mm_macc_ps(dx23,fscal,fix2);
823 fiy2 = _mm_macc_ps(dy23,fscal,fiy2);
824 fiz2 = _mm_macc_ps(dz23,fscal,fiz2);
826 fjx3 = _mm_macc_ps(dx23,fscal,fjx3);
827 fjy3 = _mm_macc_ps(dy23,fscal,fjy3);
828 fjz3 = _mm_macc_ps(dz23,fscal,fjz3);
830 /**************************
831 * CALCULATE INTERACTIONS *
832 **************************/
834 /* COULOMB ELECTROSTATICS */
835 velec = _mm_mul_ps(qq31,rinv31);
836 felec = _mm_mul_ps(velec,rinvsq31);
838 /* Update potential sum for this i atom from the interaction with this j atom. */
839 velec = _mm_andnot_ps(dummy_mask,velec);
840 velecsum = _mm_add_ps(velecsum,velec);
844 fscal = _mm_andnot_ps(dummy_mask,fscal);
846 /* Update vectorial force */
847 fix3 = _mm_macc_ps(dx31,fscal,fix3);
848 fiy3 = _mm_macc_ps(dy31,fscal,fiy3);
849 fiz3 = _mm_macc_ps(dz31,fscal,fiz3);
851 fjx1 = _mm_macc_ps(dx31,fscal,fjx1);
852 fjy1 = _mm_macc_ps(dy31,fscal,fjy1);
853 fjz1 = _mm_macc_ps(dz31,fscal,fjz1);
855 /**************************
856 * CALCULATE INTERACTIONS *
857 **************************/
859 /* COULOMB ELECTROSTATICS */
860 velec = _mm_mul_ps(qq32,rinv32);
861 felec = _mm_mul_ps(velec,rinvsq32);
863 /* Update potential sum for this i atom from the interaction with this j atom. */
864 velec = _mm_andnot_ps(dummy_mask,velec);
865 velecsum = _mm_add_ps(velecsum,velec);
869 fscal = _mm_andnot_ps(dummy_mask,fscal);
871 /* Update vectorial force */
872 fix3 = _mm_macc_ps(dx32,fscal,fix3);
873 fiy3 = _mm_macc_ps(dy32,fscal,fiy3);
874 fiz3 = _mm_macc_ps(dz32,fscal,fiz3);
876 fjx2 = _mm_macc_ps(dx32,fscal,fjx2);
877 fjy2 = _mm_macc_ps(dy32,fscal,fjy2);
878 fjz2 = _mm_macc_ps(dz32,fscal,fjz2);
880 /**************************
881 * CALCULATE INTERACTIONS *
882 **************************/
884 /* COULOMB ELECTROSTATICS */
885 velec = _mm_mul_ps(qq33,rinv33);
886 felec = _mm_mul_ps(velec,rinvsq33);
888 /* Update potential sum for this i atom from the interaction with this j atom. */
889 velec = _mm_andnot_ps(dummy_mask,velec);
890 velecsum = _mm_add_ps(velecsum,velec);
894 fscal = _mm_andnot_ps(dummy_mask,fscal);
896 /* Update vectorial force */
897 fix3 = _mm_macc_ps(dx33,fscal,fix3);
898 fiy3 = _mm_macc_ps(dy33,fscal,fiy3);
899 fiz3 = _mm_macc_ps(dz33,fscal,fiz3);
901 fjx3 = _mm_macc_ps(dx33,fscal,fjx3);
902 fjy3 = _mm_macc_ps(dy33,fscal,fjy3);
903 fjz3 = _mm_macc_ps(dz33,fscal,fjz3);
905 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
906 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
907 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
908 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
910 gmx_mm_decrement_4rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
911 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,
912 fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
914 /* Inner loop uses 317 flops */
917 /* End of innermost loop */
919 gmx_mm_update_iforce_4atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
920 f+i_coord_offset,fshift+i_shift_offset);
923 /* Update potential energies */
924 gmx_mm_update_1pot_ps(velecsum,kernel_data->energygrp_elec+ggid);
925 gmx_mm_update_1pot_ps(vvdwsum,kernel_data->energygrp_vdw+ggid);
927 /* Increment number of inner iterations */
928 inneriter += j_index_end - j_index_start;
930 /* Outer loop uses 26 flops */
933 /* Increment number of outer iterations */
936 /* Update outer/inner flops */
938 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*26 + inneriter*317);
941 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwLJ_GeomW4W4_F_avx_128_fma_single
942 * Electrostatics interaction: Coulomb
943 * VdW interaction: LennardJones
944 * Geometry: Water4-Water4
945 * Calculate force/pot: Force
948 nb_kernel_ElecCoul_VdwLJ_GeomW4W4_F_avx_128_fma_single
949 (t_nblist * gmx_restrict nlist,
950 rvec * gmx_restrict xx,
951 rvec * gmx_restrict ff,
952 t_forcerec * gmx_restrict fr,
953 t_mdatoms * gmx_restrict mdatoms,
954 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
955 t_nrnb * gmx_restrict nrnb)
957 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
958 * just 0 for non-waters.
959 * Suffixes A,B,C,D refer to j loop unrolling done with AVX_128, e.g. for the four different
960 * jnr indices corresponding to data put in the four positions in the SIMD register.
962 int i_shift_offset,i_coord_offset,outeriter,inneriter;
963 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
964 int jnrA,jnrB,jnrC,jnrD;
965 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
966 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
967 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
969 real *shiftvec,*fshift,*x,*f;
970 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
972 __m128 fscal,rcutoff,rcutoff2,jidxall;
974 __m128 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
976 __m128 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
978 __m128 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
980 __m128 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
981 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
982 __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
983 int vdwjidx1A,vdwjidx1B,vdwjidx1C,vdwjidx1D;
984 __m128 jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
985 int vdwjidx2A,vdwjidx2B,vdwjidx2C,vdwjidx2D;
986 __m128 jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
987 int vdwjidx3A,vdwjidx3B,vdwjidx3C,vdwjidx3D;
988 __m128 jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
989 __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
990 __m128 dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
991 __m128 dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
992 __m128 dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13;
993 __m128 dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
994 __m128 dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
995 __m128 dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23;
996 __m128 dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31;
997 __m128 dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32;
998 __m128 dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33;
999 __m128 velec,felec,velecsum,facel,crf,krf,krf2;
1002 __m128 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
1005 __m128 one_sixth = _mm_set1_ps(1.0/6.0);
1006 __m128 one_twelfth = _mm_set1_ps(1.0/12.0);
1007 __m128 dummy_mask,cutoff_mask;
1008 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
1009 __m128 one = _mm_set1_ps(1.0);
1010 __m128 two = _mm_set1_ps(2.0);
1016 jindex = nlist->jindex;
1018 shiftidx = nlist->shift;
1020 shiftvec = fr->shift_vec[0];
1021 fshift = fr->fshift[0];
1022 facel = _mm_set1_ps(fr->epsfac);
1023 charge = mdatoms->chargeA;
1024 nvdwtype = fr->ntype;
1025 vdwparam = fr->nbfp;
1026 vdwtype = mdatoms->typeA;
1028 /* Setup water-specific parameters */
1029 inr = nlist->iinr[0];
1030 iq1 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+1]));
1031 iq2 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+2]));
1032 iq3 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+3]));
1033 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
1035 jq1 = _mm_set1_ps(charge[inr+1]);
1036 jq2 = _mm_set1_ps(charge[inr+2]);
1037 jq3 = _mm_set1_ps(charge[inr+3]);
1038 vdwjidx0A = 2*vdwtype[inr+0];
1039 c6_00 = _mm_set1_ps(vdwparam[vdwioffset0+vdwjidx0A]);
1040 c12_00 = _mm_set1_ps(vdwparam[vdwioffset0+vdwjidx0A+1]);
1041 qq11 = _mm_mul_ps(iq1,jq1);
1042 qq12 = _mm_mul_ps(iq1,jq2);
1043 qq13 = _mm_mul_ps(iq1,jq3);
1044 qq21 = _mm_mul_ps(iq2,jq1);
1045 qq22 = _mm_mul_ps(iq2,jq2);
1046 qq23 = _mm_mul_ps(iq2,jq3);
1047 qq31 = _mm_mul_ps(iq3,jq1);
1048 qq32 = _mm_mul_ps(iq3,jq2);
1049 qq33 = _mm_mul_ps(iq3,jq3);
1051 /* Avoid stupid compiler warnings */
1052 jnrA = jnrB = jnrC = jnrD = 0;
1053 j_coord_offsetA = 0;
1054 j_coord_offsetB = 0;
1055 j_coord_offsetC = 0;
1056 j_coord_offsetD = 0;
1061 for(iidx=0;iidx<4*DIM;iidx++)
1063 scratch[iidx] = 0.0;
1066 /* Start outer loop over neighborlists */
1067 for(iidx=0; iidx<nri; iidx++)
1069 /* Load shift vector for this list */
1070 i_shift_offset = DIM*shiftidx[iidx];
1072 /* Load limits for loop over neighbors */
1073 j_index_start = jindex[iidx];
1074 j_index_end = jindex[iidx+1];
1076 /* Get outer coordinate index */
1078 i_coord_offset = DIM*inr;
1080 /* Load i particle coords and add shift vector */
1081 gmx_mm_load_shift_and_4rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
1082 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
1084 fix0 = _mm_setzero_ps();
1085 fiy0 = _mm_setzero_ps();
1086 fiz0 = _mm_setzero_ps();
1087 fix1 = _mm_setzero_ps();
1088 fiy1 = _mm_setzero_ps();
1089 fiz1 = _mm_setzero_ps();
1090 fix2 = _mm_setzero_ps();
1091 fiy2 = _mm_setzero_ps();
1092 fiz2 = _mm_setzero_ps();
1093 fix3 = _mm_setzero_ps();
1094 fiy3 = _mm_setzero_ps();
1095 fiz3 = _mm_setzero_ps();
1097 /* Start inner kernel loop */
1098 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
1101 /* Get j neighbor index, and coordinate index */
1103 jnrB = jjnr[jidx+1];
1104 jnrC = jjnr[jidx+2];
1105 jnrD = jjnr[jidx+3];
1106 j_coord_offsetA = DIM*jnrA;
1107 j_coord_offsetB = DIM*jnrB;
1108 j_coord_offsetC = DIM*jnrC;
1109 j_coord_offsetD = DIM*jnrD;
1111 /* load j atom coordinates */
1112 gmx_mm_load_4rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
1113 x+j_coord_offsetC,x+j_coord_offsetD,
1114 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,
1115 &jy2,&jz2,&jx3,&jy3,&jz3);
1117 /* Calculate displacement vector */
1118 dx00 = _mm_sub_ps(ix0,jx0);
1119 dy00 = _mm_sub_ps(iy0,jy0);
1120 dz00 = _mm_sub_ps(iz0,jz0);
1121 dx11 = _mm_sub_ps(ix1,jx1);
1122 dy11 = _mm_sub_ps(iy1,jy1);
1123 dz11 = _mm_sub_ps(iz1,jz1);
1124 dx12 = _mm_sub_ps(ix1,jx2);
1125 dy12 = _mm_sub_ps(iy1,jy2);
1126 dz12 = _mm_sub_ps(iz1,jz2);
1127 dx13 = _mm_sub_ps(ix1,jx3);
1128 dy13 = _mm_sub_ps(iy1,jy3);
1129 dz13 = _mm_sub_ps(iz1,jz3);
1130 dx21 = _mm_sub_ps(ix2,jx1);
1131 dy21 = _mm_sub_ps(iy2,jy1);
1132 dz21 = _mm_sub_ps(iz2,jz1);
1133 dx22 = _mm_sub_ps(ix2,jx2);
1134 dy22 = _mm_sub_ps(iy2,jy2);
1135 dz22 = _mm_sub_ps(iz2,jz2);
1136 dx23 = _mm_sub_ps(ix2,jx3);
1137 dy23 = _mm_sub_ps(iy2,jy3);
1138 dz23 = _mm_sub_ps(iz2,jz3);
1139 dx31 = _mm_sub_ps(ix3,jx1);
1140 dy31 = _mm_sub_ps(iy3,jy1);
1141 dz31 = _mm_sub_ps(iz3,jz1);
1142 dx32 = _mm_sub_ps(ix3,jx2);
1143 dy32 = _mm_sub_ps(iy3,jy2);
1144 dz32 = _mm_sub_ps(iz3,jz2);
1145 dx33 = _mm_sub_ps(ix3,jx3);
1146 dy33 = _mm_sub_ps(iy3,jy3);
1147 dz33 = _mm_sub_ps(iz3,jz3);
1149 /* Calculate squared distance and things based on it */
1150 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
1151 rsq11 = gmx_mm_calc_rsq_ps(dx11,dy11,dz11);
1152 rsq12 = gmx_mm_calc_rsq_ps(dx12,dy12,dz12);
1153 rsq13 = gmx_mm_calc_rsq_ps(dx13,dy13,dz13);
1154 rsq21 = gmx_mm_calc_rsq_ps(dx21,dy21,dz21);
1155 rsq22 = gmx_mm_calc_rsq_ps(dx22,dy22,dz22);
1156 rsq23 = gmx_mm_calc_rsq_ps(dx23,dy23,dz23);
1157 rsq31 = gmx_mm_calc_rsq_ps(dx31,dy31,dz31);
1158 rsq32 = gmx_mm_calc_rsq_ps(dx32,dy32,dz32);
1159 rsq33 = gmx_mm_calc_rsq_ps(dx33,dy33,dz33);
1161 rinv11 = gmx_mm_invsqrt_ps(rsq11);
1162 rinv12 = gmx_mm_invsqrt_ps(rsq12);
1163 rinv13 = gmx_mm_invsqrt_ps(rsq13);
1164 rinv21 = gmx_mm_invsqrt_ps(rsq21);
1165 rinv22 = gmx_mm_invsqrt_ps(rsq22);
1166 rinv23 = gmx_mm_invsqrt_ps(rsq23);
1167 rinv31 = gmx_mm_invsqrt_ps(rsq31);
1168 rinv32 = gmx_mm_invsqrt_ps(rsq32);
1169 rinv33 = gmx_mm_invsqrt_ps(rsq33);
1171 rinvsq00 = gmx_mm_inv_ps(rsq00);
1172 rinvsq11 = _mm_mul_ps(rinv11,rinv11);
1173 rinvsq12 = _mm_mul_ps(rinv12,rinv12);
1174 rinvsq13 = _mm_mul_ps(rinv13,rinv13);
1175 rinvsq21 = _mm_mul_ps(rinv21,rinv21);
1176 rinvsq22 = _mm_mul_ps(rinv22,rinv22);
1177 rinvsq23 = _mm_mul_ps(rinv23,rinv23);
1178 rinvsq31 = _mm_mul_ps(rinv31,rinv31);
1179 rinvsq32 = _mm_mul_ps(rinv32,rinv32);
1180 rinvsq33 = _mm_mul_ps(rinv33,rinv33);
1182 fjx0 = _mm_setzero_ps();
1183 fjy0 = _mm_setzero_ps();
1184 fjz0 = _mm_setzero_ps();
1185 fjx1 = _mm_setzero_ps();
1186 fjy1 = _mm_setzero_ps();
1187 fjz1 = _mm_setzero_ps();
1188 fjx2 = _mm_setzero_ps();
1189 fjy2 = _mm_setzero_ps();
1190 fjz2 = _mm_setzero_ps();
1191 fjx3 = _mm_setzero_ps();
1192 fjy3 = _mm_setzero_ps();
1193 fjz3 = _mm_setzero_ps();
1195 /**************************
1196 * CALCULATE INTERACTIONS *
1197 **************************/
1199 /* LENNARD-JONES DISPERSION/REPULSION */
1201 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
1202 fvdw = _mm_mul_ps(_mm_msub_ps(c12_00,rinvsix,c6_00),_mm_mul_ps(rinvsix,rinvsq00));
1206 /* Update vectorial force */
1207 fix0 = _mm_macc_ps(dx00,fscal,fix0);
1208 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
1209 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
1211 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
1212 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
1213 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
1215 /**************************
1216 * CALCULATE INTERACTIONS *
1217 **************************/
1219 /* COULOMB ELECTROSTATICS */
1220 velec = _mm_mul_ps(qq11,rinv11);
1221 felec = _mm_mul_ps(velec,rinvsq11);
1225 /* Update vectorial force */
1226 fix1 = _mm_macc_ps(dx11,fscal,fix1);
1227 fiy1 = _mm_macc_ps(dy11,fscal,fiy1);
1228 fiz1 = _mm_macc_ps(dz11,fscal,fiz1);
1230 fjx1 = _mm_macc_ps(dx11,fscal,fjx1);
1231 fjy1 = _mm_macc_ps(dy11,fscal,fjy1);
1232 fjz1 = _mm_macc_ps(dz11,fscal,fjz1);
1234 /**************************
1235 * CALCULATE INTERACTIONS *
1236 **************************/
1238 /* COULOMB ELECTROSTATICS */
1239 velec = _mm_mul_ps(qq12,rinv12);
1240 felec = _mm_mul_ps(velec,rinvsq12);
1244 /* Update vectorial force */
1245 fix1 = _mm_macc_ps(dx12,fscal,fix1);
1246 fiy1 = _mm_macc_ps(dy12,fscal,fiy1);
1247 fiz1 = _mm_macc_ps(dz12,fscal,fiz1);
1249 fjx2 = _mm_macc_ps(dx12,fscal,fjx2);
1250 fjy2 = _mm_macc_ps(dy12,fscal,fjy2);
1251 fjz2 = _mm_macc_ps(dz12,fscal,fjz2);
1253 /**************************
1254 * CALCULATE INTERACTIONS *
1255 **************************/
1257 /* COULOMB ELECTROSTATICS */
1258 velec = _mm_mul_ps(qq13,rinv13);
1259 felec = _mm_mul_ps(velec,rinvsq13);
1263 /* Update vectorial force */
1264 fix1 = _mm_macc_ps(dx13,fscal,fix1);
1265 fiy1 = _mm_macc_ps(dy13,fscal,fiy1);
1266 fiz1 = _mm_macc_ps(dz13,fscal,fiz1);
1268 fjx3 = _mm_macc_ps(dx13,fscal,fjx3);
1269 fjy3 = _mm_macc_ps(dy13,fscal,fjy3);
1270 fjz3 = _mm_macc_ps(dz13,fscal,fjz3);
1272 /**************************
1273 * CALCULATE INTERACTIONS *
1274 **************************/
1276 /* COULOMB ELECTROSTATICS */
1277 velec = _mm_mul_ps(qq21,rinv21);
1278 felec = _mm_mul_ps(velec,rinvsq21);
1282 /* Update vectorial force */
1283 fix2 = _mm_macc_ps(dx21,fscal,fix2);
1284 fiy2 = _mm_macc_ps(dy21,fscal,fiy2);
1285 fiz2 = _mm_macc_ps(dz21,fscal,fiz2);
1287 fjx1 = _mm_macc_ps(dx21,fscal,fjx1);
1288 fjy1 = _mm_macc_ps(dy21,fscal,fjy1);
1289 fjz1 = _mm_macc_ps(dz21,fscal,fjz1);
1291 /**************************
1292 * CALCULATE INTERACTIONS *
1293 **************************/
1295 /* COULOMB ELECTROSTATICS */
1296 velec = _mm_mul_ps(qq22,rinv22);
1297 felec = _mm_mul_ps(velec,rinvsq22);
1301 /* Update vectorial force */
1302 fix2 = _mm_macc_ps(dx22,fscal,fix2);
1303 fiy2 = _mm_macc_ps(dy22,fscal,fiy2);
1304 fiz2 = _mm_macc_ps(dz22,fscal,fiz2);
1306 fjx2 = _mm_macc_ps(dx22,fscal,fjx2);
1307 fjy2 = _mm_macc_ps(dy22,fscal,fjy2);
1308 fjz2 = _mm_macc_ps(dz22,fscal,fjz2);
1310 /**************************
1311 * CALCULATE INTERACTIONS *
1312 **************************/
1314 /* COULOMB ELECTROSTATICS */
1315 velec = _mm_mul_ps(qq23,rinv23);
1316 felec = _mm_mul_ps(velec,rinvsq23);
1320 /* Update vectorial force */
1321 fix2 = _mm_macc_ps(dx23,fscal,fix2);
1322 fiy2 = _mm_macc_ps(dy23,fscal,fiy2);
1323 fiz2 = _mm_macc_ps(dz23,fscal,fiz2);
1325 fjx3 = _mm_macc_ps(dx23,fscal,fjx3);
1326 fjy3 = _mm_macc_ps(dy23,fscal,fjy3);
1327 fjz3 = _mm_macc_ps(dz23,fscal,fjz3);
1329 /**************************
1330 * CALCULATE INTERACTIONS *
1331 **************************/
1333 /* COULOMB ELECTROSTATICS */
1334 velec = _mm_mul_ps(qq31,rinv31);
1335 felec = _mm_mul_ps(velec,rinvsq31);
1339 /* Update vectorial force */
1340 fix3 = _mm_macc_ps(dx31,fscal,fix3);
1341 fiy3 = _mm_macc_ps(dy31,fscal,fiy3);
1342 fiz3 = _mm_macc_ps(dz31,fscal,fiz3);
1344 fjx1 = _mm_macc_ps(dx31,fscal,fjx1);
1345 fjy1 = _mm_macc_ps(dy31,fscal,fjy1);
1346 fjz1 = _mm_macc_ps(dz31,fscal,fjz1);
1348 /**************************
1349 * CALCULATE INTERACTIONS *
1350 **************************/
1352 /* COULOMB ELECTROSTATICS */
1353 velec = _mm_mul_ps(qq32,rinv32);
1354 felec = _mm_mul_ps(velec,rinvsq32);
1358 /* Update vectorial force */
1359 fix3 = _mm_macc_ps(dx32,fscal,fix3);
1360 fiy3 = _mm_macc_ps(dy32,fscal,fiy3);
1361 fiz3 = _mm_macc_ps(dz32,fscal,fiz3);
1363 fjx2 = _mm_macc_ps(dx32,fscal,fjx2);
1364 fjy2 = _mm_macc_ps(dy32,fscal,fjy2);
1365 fjz2 = _mm_macc_ps(dz32,fscal,fjz2);
1367 /**************************
1368 * CALCULATE INTERACTIONS *
1369 **************************/
1371 /* COULOMB ELECTROSTATICS */
1372 velec = _mm_mul_ps(qq33,rinv33);
1373 felec = _mm_mul_ps(velec,rinvsq33);
1377 /* Update vectorial force */
1378 fix3 = _mm_macc_ps(dx33,fscal,fix3);
1379 fiy3 = _mm_macc_ps(dy33,fscal,fiy3);
1380 fiz3 = _mm_macc_ps(dz33,fscal,fiz3);
1382 fjx3 = _mm_macc_ps(dx33,fscal,fjx3);
1383 fjy3 = _mm_macc_ps(dy33,fscal,fjy3);
1384 fjz3 = _mm_macc_ps(dz33,fscal,fjz3);
1386 fjptrA = f+j_coord_offsetA;
1387 fjptrB = f+j_coord_offsetB;
1388 fjptrC = f+j_coord_offsetC;
1389 fjptrD = f+j_coord_offsetD;
1391 gmx_mm_decrement_4rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
1392 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,
1393 fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
1395 /* Inner loop uses 303 flops */
1398 if(jidx<j_index_end)
1401 /* Get j neighbor index, and coordinate index */
1402 jnrlistA = jjnr[jidx];
1403 jnrlistB = jjnr[jidx+1];
1404 jnrlistC = jjnr[jidx+2];
1405 jnrlistD = jjnr[jidx+3];
1406 /* Sign of each element will be negative for non-real atoms.
1407 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
1408 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
1410 dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
1411 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
1412 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
1413 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
1414 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
1415 j_coord_offsetA = DIM*jnrA;
1416 j_coord_offsetB = DIM*jnrB;
1417 j_coord_offsetC = DIM*jnrC;
1418 j_coord_offsetD = DIM*jnrD;
1420 /* load j atom coordinates */
1421 gmx_mm_load_4rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
1422 x+j_coord_offsetC,x+j_coord_offsetD,
1423 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,
1424 &jy2,&jz2,&jx3,&jy3,&jz3);
1426 /* Calculate displacement vector */
1427 dx00 = _mm_sub_ps(ix0,jx0);
1428 dy00 = _mm_sub_ps(iy0,jy0);
1429 dz00 = _mm_sub_ps(iz0,jz0);
1430 dx11 = _mm_sub_ps(ix1,jx1);
1431 dy11 = _mm_sub_ps(iy1,jy1);
1432 dz11 = _mm_sub_ps(iz1,jz1);
1433 dx12 = _mm_sub_ps(ix1,jx2);
1434 dy12 = _mm_sub_ps(iy1,jy2);
1435 dz12 = _mm_sub_ps(iz1,jz2);
1436 dx13 = _mm_sub_ps(ix1,jx3);
1437 dy13 = _mm_sub_ps(iy1,jy3);
1438 dz13 = _mm_sub_ps(iz1,jz3);
1439 dx21 = _mm_sub_ps(ix2,jx1);
1440 dy21 = _mm_sub_ps(iy2,jy1);
1441 dz21 = _mm_sub_ps(iz2,jz1);
1442 dx22 = _mm_sub_ps(ix2,jx2);
1443 dy22 = _mm_sub_ps(iy2,jy2);
1444 dz22 = _mm_sub_ps(iz2,jz2);
1445 dx23 = _mm_sub_ps(ix2,jx3);
1446 dy23 = _mm_sub_ps(iy2,jy3);
1447 dz23 = _mm_sub_ps(iz2,jz3);
1448 dx31 = _mm_sub_ps(ix3,jx1);
1449 dy31 = _mm_sub_ps(iy3,jy1);
1450 dz31 = _mm_sub_ps(iz3,jz1);
1451 dx32 = _mm_sub_ps(ix3,jx2);
1452 dy32 = _mm_sub_ps(iy3,jy2);
1453 dz32 = _mm_sub_ps(iz3,jz2);
1454 dx33 = _mm_sub_ps(ix3,jx3);
1455 dy33 = _mm_sub_ps(iy3,jy3);
1456 dz33 = _mm_sub_ps(iz3,jz3);
1458 /* Calculate squared distance and things based on it */
1459 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
1460 rsq11 = gmx_mm_calc_rsq_ps(dx11,dy11,dz11);
1461 rsq12 = gmx_mm_calc_rsq_ps(dx12,dy12,dz12);
1462 rsq13 = gmx_mm_calc_rsq_ps(dx13,dy13,dz13);
1463 rsq21 = gmx_mm_calc_rsq_ps(dx21,dy21,dz21);
1464 rsq22 = gmx_mm_calc_rsq_ps(dx22,dy22,dz22);
1465 rsq23 = gmx_mm_calc_rsq_ps(dx23,dy23,dz23);
1466 rsq31 = gmx_mm_calc_rsq_ps(dx31,dy31,dz31);
1467 rsq32 = gmx_mm_calc_rsq_ps(dx32,dy32,dz32);
1468 rsq33 = gmx_mm_calc_rsq_ps(dx33,dy33,dz33);
1470 rinv11 = gmx_mm_invsqrt_ps(rsq11);
1471 rinv12 = gmx_mm_invsqrt_ps(rsq12);
1472 rinv13 = gmx_mm_invsqrt_ps(rsq13);
1473 rinv21 = gmx_mm_invsqrt_ps(rsq21);
1474 rinv22 = gmx_mm_invsqrt_ps(rsq22);
1475 rinv23 = gmx_mm_invsqrt_ps(rsq23);
1476 rinv31 = gmx_mm_invsqrt_ps(rsq31);
1477 rinv32 = gmx_mm_invsqrt_ps(rsq32);
1478 rinv33 = gmx_mm_invsqrt_ps(rsq33);
1480 rinvsq00 = gmx_mm_inv_ps(rsq00);
1481 rinvsq11 = _mm_mul_ps(rinv11,rinv11);
1482 rinvsq12 = _mm_mul_ps(rinv12,rinv12);
1483 rinvsq13 = _mm_mul_ps(rinv13,rinv13);
1484 rinvsq21 = _mm_mul_ps(rinv21,rinv21);
1485 rinvsq22 = _mm_mul_ps(rinv22,rinv22);
1486 rinvsq23 = _mm_mul_ps(rinv23,rinv23);
1487 rinvsq31 = _mm_mul_ps(rinv31,rinv31);
1488 rinvsq32 = _mm_mul_ps(rinv32,rinv32);
1489 rinvsq33 = _mm_mul_ps(rinv33,rinv33);
1491 fjx0 = _mm_setzero_ps();
1492 fjy0 = _mm_setzero_ps();
1493 fjz0 = _mm_setzero_ps();
1494 fjx1 = _mm_setzero_ps();
1495 fjy1 = _mm_setzero_ps();
1496 fjz1 = _mm_setzero_ps();
1497 fjx2 = _mm_setzero_ps();
1498 fjy2 = _mm_setzero_ps();
1499 fjz2 = _mm_setzero_ps();
1500 fjx3 = _mm_setzero_ps();
1501 fjy3 = _mm_setzero_ps();
1502 fjz3 = _mm_setzero_ps();
1504 /**************************
1505 * CALCULATE INTERACTIONS *
1506 **************************/
1508 /* LENNARD-JONES DISPERSION/REPULSION */
1510 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
1511 fvdw = _mm_mul_ps(_mm_msub_ps(c12_00,rinvsix,c6_00),_mm_mul_ps(rinvsix,rinvsq00));
1515 fscal = _mm_andnot_ps(dummy_mask,fscal);
1517 /* Update vectorial force */
1518 fix0 = _mm_macc_ps(dx00,fscal,fix0);
1519 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
1520 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
1522 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
1523 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
1524 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
1526 /**************************
1527 * CALCULATE INTERACTIONS *
1528 **************************/
1530 /* COULOMB ELECTROSTATICS */
1531 velec = _mm_mul_ps(qq11,rinv11);
1532 felec = _mm_mul_ps(velec,rinvsq11);
1536 fscal = _mm_andnot_ps(dummy_mask,fscal);
1538 /* Update vectorial force */
1539 fix1 = _mm_macc_ps(dx11,fscal,fix1);
1540 fiy1 = _mm_macc_ps(dy11,fscal,fiy1);
1541 fiz1 = _mm_macc_ps(dz11,fscal,fiz1);
1543 fjx1 = _mm_macc_ps(dx11,fscal,fjx1);
1544 fjy1 = _mm_macc_ps(dy11,fscal,fjy1);
1545 fjz1 = _mm_macc_ps(dz11,fscal,fjz1);
1547 /**************************
1548 * CALCULATE INTERACTIONS *
1549 **************************/
1551 /* COULOMB ELECTROSTATICS */
1552 velec = _mm_mul_ps(qq12,rinv12);
1553 felec = _mm_mul_ps(velec,rinvsq12);
1557 fscal = _mm_andnot_ps(dummy_mask,fscal);
1559 /* Update vectorial force */
1560 fix1 = _mm_macc_ps(dx12,fscal,fix1);
1561 fiy1 = _mm_macc_ps(dy12,fscal,fiy1);
1562 fiz1 = _mm_macc_ps(dz12,fscal,fiz1);
1564 fjx2 = _mm_macc_ps(dx12,fscal,fjx2);
1565 fjy2 = _mm_macc_ps(dy12,fscal,fjy2);
1566 fjz2 = _mm_macc_ps(dz12,fscal,fjz2);
1568 /**************************
1569 * CALCULATE INTERACTIONS *
1570 **************************/
1572 /* COULOMB ELECTROSTATICS */
1573 velec = _mm_mul_ps(qq13,rinv13);
1574 felec = _mm_mul_ps(velec,rinvsq13);
1578 fscal = _mm_andnot_ps(dummy_mask,fscal);
1580 /* Update vectorial force */
1581 fix1 = _mm_macc_ps(dx13,fscal,fix1);
1582 fiy1 = _mm_macc_ps(dy13,fscal,fiy1);
1583 fiz1 = _mm_macc_ps(dz13,fscal,fiz1);
1585 fjx3 = _mm_macc_ps(dx13,fscal,fjx3);
1586 fjy3 = _mm_macc_ps(dy13,fscal,fjy3);
1587 fjz3 = _mm_macc_ps(dz13,fscal,fjz3);
1589 /**************************
1590 * CALCULATE INTERACTIONS *
1591 **************************/
1593 /* COULOMB ELECTROSTATICS */
1594 velec = _mm_mul_ps(qq21,rinv21);
1595 felec = _mm_mul_ps(velec,rinvsq21);
1599 fscal = _mm_andnot_ps(dummy_mask,fscal);
1601 /* Update vectorial force */
1602 fix2 = _mm_macc_ps(dx21,fscal,fix2);
1603 fiy2 = _mm_macc_ps(dy21,fscal,fiy2);
1604 fiz2 = _mm_macc_ps(dz21,fscal,fiz2);
1606 fjx1 = _mm_macc_ps(dx21,fscal,fjx1);
1607 fjy1 = _mm_macc_ps(dy21,fscal,fjy1);
1608 fjz1 = _mm_macc_ps(dz21,fscal,fjz1);
1610 /**************************
1611 * CALCULATE INTERACTIONS *
1612 **************************/
1614 /* COULOMB ELECTROSTATICS */
1615 velec = _mm_mul_ps(qq22,rinv22);
1616 felec = _mm_mul_ps(velec,rinvsq22);
1620 fscal = _mm_andnot_ps(dummy_mask,fscal);
1622 /* Update vectorial force */
1623 fix2 = _mm_macc_ps(dx22,fscal,fix2);
1624 fiy2 = _mm_macc_ps(dy22,fscal,fiy2);
1625 fiz2 = _mm_macc_ps(dz22,fscal,fiz2);
1627 fjx2 = _mm_macc_ps(dx22,fscal,fjx2);
1628 fjy2 = _mm_macc_ps(dy22,fscal,fjy2);
1629 fjz2 = _mm_macc_ps(dz22,fscal,fjz2);
1631 /**************************
1632 * CALCULATE INTERACTIONS *
1633 **************************/
1635 /* COULOMB ELECTROSTATICS */
1636 velec = _mm_mul_ps(qq23,rinv23);
1637 felec = _mm_mul_ps(velec,rinvsq23);
1641 fscal = _mm_andnot_ps(dummy_mask,fscal);
1643 /* Update vectorial force */
1644 fix2 = _mm_macc_ps(dx23,fscal,fix2);
1645 fiy2 = _mm_macc_ps(dy23,fscal,fiy2);
1646 fiz2 = _mm_macc_ps(dz23,fscal,fiz2);
1648 fjx3 = _mm_macc_ps(dx23,fscal,fjx3);
1649 fjy3 = _mm_macc_ps(dy23,fscal,fjy3);
1650 fjz3 = _mm_macc_ps(dz23,fscal,fjz3);
1652 /**************************
1653 * CALCULATE INTERACTIONS *
1654 **************************/
1656 /* COULOMB ELECTROSTATICS */
1657 velec = _mm_mul_ps(qq31,rinv31);
1658 felec = _mm_mul_ps(velec,rinvsq31);
1662 fscal = _mm_andnot_ps(dummy_mask,fscal);
1664 /* Update vectorial force */
1665 fix3 = _mm_macc_ps(dx31,fscal,fix3);
1666 fiy3 = _mm_macc_ps(dy31,fscal,fiy3);
1667 fiz3 = _mm_macc_ps(dz31,fscal,fiz3);
1669 fjx1 = _mm_macc_ps(dx31,fscal,fjx1);
1670 fjy1 = _mm_macc_ps(dy31,fscal,fjy1);
1671 fjz1 = _mm_macc_ps(dz31,fscal,fjz1);
1673 /**************************
1674 * CALCULATE INTERACTIONS *
1675 **************************/
1677 /* COULOMB ELECTROSTATICS */
1678 velec = _mm_mul_ps(qq32,rinv32);
1679 felec = _mm_mul_ps(velec,rinvsq32);
1683 fscal = _mm_andnot_ps(dummy_mask,fscal);
1685 /* Update vectorial force */
1686 fix3 = _mm_macc_ps(dx32,fscal,fix3);
1687 fiy3 = _mm_macc_ps(dy32,fscal,fiy3);
1688 fiz3 = _mm_macc_ps(dz32,fscal,fiz3);
1690 fjx2 = _mm_macc_ps(dx32,fscal,fjx2);
1691 fjy2 = _mm_macc_ps(dy32,fscal,fjy2);
1692 fjz2 = _mm_macc_ps(dz32,fscal,fjz2);
1694 /**************************
1695 * CALCULATE INTERACTIONS *
1696 **************************/
1698 /* COULOMB ELECTROSTATICS */
1699 velec = _mm_mul_ps(qq33,rinv33);
1700 felec = _mm_mul_ps(velec,rinvsq33);
1704 fscal = _mm_andnot_ps(dummy_mask,fscal);
1706 /* Update vectorial force */
1707 fix3 = _mm_macc_ps(dx33,fscal,fix3);
1708 fiy3 = _mm_macc_ps(dy33,fscal,fiy3);
1709 fiz3 = _mm_macc_ps(dz33,fscal,fiz3);
1711 fjx3 = _mm_macc_ps(dx33,fscal,fjx3);
1712 fjy3 = _mm_macc_ps(dy33,fscal,fjy3);
1713 fjz3 = _mm_macc_ps(dz33,fscal,fjz3);
1715 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
1716 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
1717 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
1718 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
1720 gmx_mm_decrement_4rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
1721 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,
1722 fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
1724 /* Inner loop uses 303 flops */
1727 /* End of innermost loop */
1729 gmx_mm_update_iforce_4atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
1730 f+i_coord_offset,fshift+i_shift_offset);
1732 /* Increment number of inner iterations */
1733 inneriter += j_index_end - j_index_start;
1735 /* Outer loop uses 24 flops */
1738 /* Increment number of outer iterations */
1741 /* Update outer/inner flops */
1743 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*24 + inneriter*303);