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_256_double 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_256_double.h"
48 #include "kernelutil_x86_avx_256_double.h"
51 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwLJSh_GeomP1P1_VF_avx_256_double
52 * Electrostatics interaction: None
53 * VdW interaction: LennardJones
54 * Geometry: Particle-Particle
55 * Calculate force/pot: PotentialAndForce
58 nb_kernel_ElecNone_VdwLJSh_GeomP1P1_VF_avx_256_double
59 (t_nblist * gmx_restrict nlist,
60 rvec * gmx_restrict xx,
61 rvec * gmx_restrict ff,
62 t_forcerec * gmx_restrict fr,
63 t_mdatoms * gmx_restrict mdatoms,
64 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
65 t_nrnb * gmx_restrict nrnb)
67 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
68 * just 0 for non-waters.
69 * Suffixes A,B,C,D refer to j loop unrolling done with AVX, 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 jnrlistE,jnrlistF,jnrlistG,jnrlistH;
77 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
78 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
80 real *shiftvec,*fshift,*x,*f;
81 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
83 __m256d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
84 real * vdwioffsetptr0;
85 __m256d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
86 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
87 __m256d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
88 __m256d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
90 __m256d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
93 __m256d one_sixth = _mm256_set1_pd(1.0/6.0);
94 __m256d one_twelfth = _mm256_set1_pd(1.0/12.0);
95 __m256d dummy_mask,cutoff_mask;
96 __m128 tmpmask0,tmpmask1;
97 __m256d signbit = _mm256_castsi256_pd( _mm256_set1_epi32(0x80000000) );
98 __m256d one = _mm256_set1_pd(1.0);
99 __m256d two = _mm256_set1_pd(2.0);
105 jindex = nlist->jindex;
107 shiftidx = nlist->shift;
109 shiftvec = fr->shift_vec[0];
110 fshift = fr->fshift[0];
111 nvdwtype = fr->ntype;
113 vdwtype = mdatoms->typeA;
115 rcutoff_scalar = fr->rvdw;
116 rcutoff = _mm256_set1_pd(rcutoff_scalar);
117 rcutoff2 = _mm256_mul_pd(rcutoff,rcutoff);
119 sh_vdw_invrcut6 = _mm256_set1_pd(fr->ic->sh_invrc6);
120 rvdw = _mm256_set1_pd(fr->rvdw);
122 /* Avoid stupid compiler warnings */
123 jnrA = jnrB = jnrC = jnrD = 0;
132 for(iidx=0;iidx<4*DIM;iidx++)
137 /* Start outer loop over neighborlists */
138 for(iidx=0; iidx<nri; iidx++)
140 /* Load shift vector for this list */
141 i_shift_offset = DIM*shiftidx[iidx];
143 /* Load limits for loop over neighbors */
144 j_index_start = jindex[iidx];
145 j_index_end = jindex[iidx+1];
147 /* Get outer coordinate index */
149 i_coord_offset = DIM*inr;
151 /* Load i particle coords and add shift vector */
152 gmx_mm256_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
154 fix0 = _mm256_setzero_pd();
155 fiy0 = _mm256_setzero_pd();
156 fiz0 = _mm256_setzero_pd();
158 /* Load parameters for i particles */
159 vdwioffsetptr0 = vdwparam+2*nvdwtype*vdwtype[inr+0];
161 /* Reset potential sums */
162 vvdwsum = _mm256_setzero_pd();
164 /* Start inner kernel loop */
165 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
168 /* Get j neighbor index, and coordinate index */
173 j_coord_offsetA = DIM*jnrA;
174 j_coord_offsetB = DIM*jnrB;
175 j_coord_offsetC = DIM*jnrC;
176 j_coord_offsetD = DIM*jnrD;
178 /* load j atom coordinates */
179 gmx_mm256_load_1rvec_4ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
180 x+j_coord_offsetC,x+j_coord_offsetD,
183 /* Calculate displacement vector */
184 dx00 = _mm256_sub_pd(ix0,jx0);
185 dy00 = _mm256_sub_pd(iy0,jy0);
186 dz00 = _mm256_sub_pd(iz0,jz0);
188 /* Calculate squared distance and things based on it */
189 rsq00 = gmx_mm256_calc_rsq_pd(dx00,dy00,dz00);
191 rinvsq00 = gmx_mm256_inv_pd(rsq00);
193 /* Load parameters for j particles */
194 vdwjidx0A = 2*vdwtype[jnrA+0];
195 vdwjidx0B = 2*vdwtype[jnrB+0];
196 vdwjidx0C = 2*vdwtype[jnrC+0];
197 vdwjidx0D = 2*vdwtype[jnrD+0];
199 /**************************
200 * CALCULATE INTERACTIONS *
201 **************************/
203 if (gmx_mm256_any_lt(rsq00,rcutoff2))
206 /* Compute parameters for interactions between i and j atoms */
207 gmx_mm256_load_4pair_swizzle_pd(vdwioffsetptr0+vdwjidx0A,
208 vdwioffsetptr0+vdwjidx0B,
209 vdwioffsetptr0+vdwjidx0C,
210 vdwioffsetptr0+vdwjidx0D,
213 /* LENNARD-JONES DISPERSION/REPULSION */
215 rinvsix = _mm256_mul_pd(_mm256_mul_pd(rinvsq00,rinvsq00),rinvsq00);
216 vvdw6 = _mm256_mul_pd(c6_00,rinvsix);
217 vvdw12 = _mm256_mul_pd(c12_00,_mm256_mul_pd(rinvsix,rinvsix));
218 vvdw = _mm256_sub_pd(_mm256_mul_pd( _mm256_sub_pd(vvdw12 , _mm256_mul_pd(c12_00,_mm256_mul_pd(sh_vdw_invrcut6,sh_vdw_invrcut6))), one_twelfth) ,
219 _mm256_mul_pd( _mm256_sub_pd(vvdw6,_mm256_mul_pd(c6_00,sh_vdw_invrcut6)),one_sixth));
220 fvdw = _mm256_mul_pd(_mm256_sub_pd(vvdw12,vvdw6),rinvsq00);
222 cutoff_mask = _mm256_cmp_pd(rsq00,rcutoff2,_CMP_LT_OQ);
224 /* Update potential sum for this i atom from the interaction with this j atom. */
225 vvdw = _mm256_and_pd(vvdw,cutoff_mask);
226 vvdwsum = _mm256_add_pd(vvdwsum,vvdw);
230 fscal = _mm256_and_pd(fscal,cutoff_mask);
232 /* Calculate temporary vectorial force */
233 tx = _mm256_mul_pd(fscal,dx00);
234 ty = _mm256_mul_pd(fscal,dy00);
235 tz = _mm256_mul_pd(fscal,dz00);
237 /* Update vectorial force */
238 fix0 = _mm256_add_pd(fix0,tx);
239 fiy0 = _mm256_add_pd(fiy0,ty);
240 fiz0 = _mm256_add_pd(fiz0,tz);
242 fjptrA = f+j_coord_offsetA;
243 fjptrB = f+j_coord_offsetB;
244 fjptrC = f+j_coord_offsetC;
245 fjptrD = f+j_coord_offsetD;
246 gmx_mm256_decrement_1rvec_4ptr_swizzle_pd(fjptrA,fjptrB,fjptrC,fjptrD,tx,ty,tz);
250 /* Inner loop uses 41 flops */
256 /* Get j neighbor index, and coordinate index */
257 jnrlistA = jjnr[jidx];
258 jnrlistB = jjnr[jidx+1];
259 jnrlistC = jjnr[jidx+2];
260 jnrlistD = jjnr[jidx+3];
261 /* Sign of each element will be negative for non-real atoms.
262 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
263 * so use it as val = _mm_andnot_pd(mask,val) to clear dummy entries.
265 tmpmask0 = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
267 tmpmask1 = _mm_permute_ps(tmpmask0,_GMX_MM_PERMUTE(3,3,2,2));
268 tmpmask0 = _mm_permute_ps(tmpmask0,_GMX_MM_PERMUTE(1,1,0,0));
269 dummy_mask = _mm256_castps_pd(gmx_mm256_set_m128(tmpmask1,tmpmask0));
271 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
272 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
273 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
274 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
275 j_coord_offsetA = DIM*jnrA;
276 j_coord_offsetB = DIM*jnrB;
277 j_coord_offsetC = DIM*jnrC;
278 j_coord_offsetD = DIM*jnrD;
280 /* load j atom coordinates */
281 gmx_mm256_load_1rvec_4ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
282 x+j_coord_offsetC,x+j_coord_offsetD,
285 /* Calculate displacement vector */
286 dx00 = _mm256_sub_pd(ix0,jx0);
287 dy00 = _mm256_sub_pd(iy0,jy0);
288 dz00 = _mm256_sub_pd(iz0,jz0);
290 /* Calculate squared distance and things based on it */
291 rsq00 = gmx_mm256_calc_rsq_pd(dx00,dy00,dz00);
293 rinvsq00 = gmx_mm256_inv_pd(rsq00);
295 /* Load parameters for j particles */
296 vdwjidx0A = 2*vdwtype[jnrA+0];
297 vdwjidx0B = 2*vdwtype[jnrB+0];
298 vdwjidx0C = 2*vdwtype[jnrC+0];
299 vdwjidx0D = 2*vdwtype[jnrD+0];
301 /**************************
302 * CALCULATE INTERACTIONS *
303 **************************/
305 if (gmx_mm256_any_lt(rsq00,rcutoff2))
308 /* Compute parameters for interactions between i and j atoms */
309 gmx_mm256_load_4pair_swizzle_pd(vdwioffsetptr0+vdwjidx0A,
310 vdwioffsetptr0+vdwjidx0B,
311 vdwioffsetptr0+vdwjidx0C,
312 vdwioffsetptr0+vdwjidx0D,
315 /* LENNARD-JONES DISPERSION/REPULSION */
317 rinvsix = _mm256_mul_pd(_mm256_mul_pd(rinvsq00,rinvsq00),rinvsq00);
318 vvdw6 = _mm256_mul_pd(c6_00,rinvsix);
319 vvdw12 = _mm256_mul_pd(c12_00,_mm256_mul_pd(rinvsix,rinvsix));
320 vvdw = _mm256_sub_pd(_mm256_mul_pd( _mm256_sub_pd(vvdw12 , _mm256_mul_pd(c12_00,_mm256_mul_pd(sh_vdw_invrcut6,sh_vdw_invrcut6))), one_twelfth) ,
321 _mm256_mul_pd( _mm256_sub_pd(vvdw6,_mm256_mul_pd(c6_00,sh_vdw_invrcut6)),one_sixth));
322 fvdw = _mm256_mul_pd(_mm256_sub_pd(vvdw12,vvdw6),rinvsq00);
324 cutoff_mask = _mm256_cmp_pd(rsq00,rcutoff2,_CMP_LT_OQ);
326 /* Update potential sum for this i atom from the interaction with this j atom. */
327 vvdw = _mm256_and_pd(vvdw,cutoff_mask);
328 vvdw = _mm256_andnot_pd(dummy_mask,vvdw);
329 vvdwsum = _mm256_add_pd(vvdwsum,vvdw);
333 fscal = _mm256_and_pd(fscal,cutoff_mask);
335 fscal = _mm256_andnot_pd(dummy_mask,fscal);
337 /* Calculate temporary vectorial force */
338 tx = _mm256_mul_pd(fscal,dx00);
339 ty = _mm256_mul_pd(fscal,dy00);
340 tz = _mm256_mul_pd(fscal,dz00);
342 /* Update vectorial force */
343 fix0 = _mm256_add_pd(fix0,tx);
344 fiy0 = _mm256_add_pd(fiy0,ty);
345 fiz0 = _mm256_add_pd(fiz0,tz);
347 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
348 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
349 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
350 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
351 gmx_mm256_decrement_1rvec_4ptr_swizzle_pd(fjptrA,fjptrB,fjptrC,fjptrD,tx,ty,tz);
355 /* Inner loop uses 41 flops */
358 /* End of innermost loop */
360 gmx_mm256_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
361 f+i_coord_offset,fshift+i_shift_offset);
364 /* Update potential energies */
365 gmx_mm256_update_1pot_pd(vvdwsum,kernel_data->energygrp_vdw+ggid);
367 /* Increment number of inner iterations */
368 inneriter += j_index_end - j_index_start;
370 /* Outer loop uses 7 flops */
373 /* Increment number of outer iterations */
376 /* Update outer/inner flops */
378 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_VF,outeriter*7 + inneriter*41);
381 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwLJSh_GeomP1P1_F_avx_256_double
382 * Electrostatics interaction: None
383 * VdW interaction: LennardJones
384 * Geometry: Particle-Particle
385 * Calculate force/pot: Force
388 nb_kernel_ElecNone_VdwLJSh_GeomP1P1_F_avx_256_double
389 (t_nblist * gmx_restrict nlist,
390 rvec * gmx_restrict xx,
391 rvec * gmx_restrict ff,
392 t_forcerec * gmx_restrict fr,
393 t_mdatoms * gmx_restrict mdatoms,
394 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
395 t_nrnb * gmx_restrict nrnb)
397 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
398 * just 0 for non-waters.
399 * Suffixes A,B,C,D refer to j loop unrolling done with AVX, e.g. for the four different
400 * jnr indices corresponding to data put in the four positions in the SIMD register.
402 int i_shift_offset,i_coord_offset,outeriter,inneriter;
403 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
404 int jnrA,jnrB,jnrC,jnrD;
405 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
406 int jnrlistE,jnrlistF,jnrlistG,jnrlistH;
407 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
408 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
410 real *shiftvec,*fshift,*x,*f;
411 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
413 __m256d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
414 real * vdwioffsetptr0;
415 __m256d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
416 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
417 __m256d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
418 __m256d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
420 __m256d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
423 __m256d one_sixth = _mm256_set1_pd(1.0/6.0);
424 __m256d one_twelfth = _mm256_set1_pd(1.0/12.0);
425 __m256d dummy_mask,cutoff_mask;
426 __m128 tmpmask0,tmpmask1;
427 __m256d signbit = _mm256_castsi256_pd( _mm256_set1_epi32(0x80000000) );
428 __m256d one = _mm256_set1_pd(1.0);
429 __m256d two = _mm256_set1_pd(2.0);
435 jindex = nlist->jindex;
437 shiftidx = nlist->shift;
439 shiftvec = fr->shift_vec[0];
440 fshift = fr->fshift[0];
441 nvdwtype = fr->ntype;
443 vdwtype = mdatoms->typeA;
445 rcutoff_scalar = fr->rvdw;
446 rcutoff = _mm256_set1_pd(rcutoff_scalar);
447 rcutoff2 = _mm256_mul_pd(rcutoff,rcutoff);
449 sh_vdw_invrcut6 = _mm256_set1_pd(fr->ic->sh_invrc6);
450 rvdw = _mm256_set1_pd(fr->rvdw);
452 /* Avoid stupid compiler warnings */
453 jnrA = jnrB = jnrC = jnrD = 0;
462 for(iidx=0;iidx<4*DIM;iidx++)
467 /* Start outer loop over neighborlists */
468 for(iidx=0; iidx<nri; iidx++)
470 /* Load shift vector for this list */
471 i_shift_offset = DIM*shiftidx[iidx];
473 /* Load limits for loop over neighbors */
474 j_index_start = jindex[iidx];
475 j_index_end = jindex[iidx+1];
477 /* Get outer coordinate index */
479 i_coord_offset = DIM*inr;
481 /* Load i particle coords and add shift vector */
482 gmx_mm256_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
484 fix0 = _mm256_setzero_pd();
485 fiy0 = _mm256_setzero_pd();
486 fiz0 = _mm256_setzero_pd();
488 /* Load parameters for i particles */
489 vdwioffsetptr0 = vdwparam+2*nvdwtype*vdwtype[inr+0];
491 /* Start inner kernel loop */
492 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
495 /* Get j neighbor index, and coordinate index */
500 j_coord_offsetA = DIM*jnrA;
501 j_coord_offsetB = DIM*jnrB;
502 j_coord_offsetC = DIM*jnrC;
503 j_coord_offsetD = DIM*jnrD;
505 /* load j atom coordinates */
506 gmx_mm256_load_1rvec_4ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
507 x+j_coord_offsetC,x+j_coord_offsetD,
510 /* Calculate displacement vector */
511 dx00 = _mm256_sub_pd(ix0,jx0);
512 dy00 = _mm256_sub_pd(iy0,jy0);
513 dz00 = _mm256_sub_pd(iz0,jz0);
515 /* Calculate squared distance and things based on it */
516 rsq00 = gmx_mm256_calc_rsq_pd(dx00,dy00,dz00);
518 rinvsq00 = gmx_mm256_inv_pd(rsq00);
520 /* Load parameters for j particles */
521 vdwjidx0A = 2*vdwtype[jnrA+0];
522 vdwjidx0B = 2*vdwtype[jnrB+0];
523 vdwjidx0C = 2*vdwtype[jnrC+0];
524 vdwjidx0D = 2*vdwtype[jnrD+0];
526 /**************************
527 * CALCULATE INTERACTIONS *
528 **************************/
530 if (gmx_mm256_any_lt(rsq00,rcutoff2))
533 /* Compute parameters for interactions between i and j atoms */
534 gmx_mm256_load_4pair_swizzle_pd(vdwioffsetptr0+vdwjidx0A,
535 vdwioffsetptr0+vdwjidx0B,
536 vdwioffsetptr0+vdwjidx0C,
537 vdwioffsetptr0+vdwjidx0D,
540 /* LENNARD-JONES DISPERSION/REPULSION */
542 rinvsix = _mm256_mul_pd(_mm256_mul_pd(rinvsq00,rinvsq00),rinvsq00);
543 fvdw = _mm256_mul_pd(_mm256_sub_pd(_mm256_mul_pd(c12_00,rinvsix),c6_00),_mm256_mul_pd(rinvsix,rinvsq00));
545 cutoff_mask = _mm256_cmp_pd(rsq00,rcutoff2,_CMP_LT_OQ);
549 fscal = _mm256_and_pd(fscal,cutoff_mask);
551 /* Calculate temporary vectorial force */
552 tx = _mm256_mul_pd(fscal,dx00);
553 ty = _mm256_mul_pd(fscal,dy00);
554 tz = _mm256_mul_pd(fscal,dz00);
556 /* Update vectorial force */
557 fix0 = _mm256_add_pd(fix0,tx);
558 fiy0 = _mm256_add_pd(fiy0,ty);
559 fiz0 = _mm256_add_pd(fiz0,tz);
561 fjptrA = f+j_coord_offsetA;
562 fjptrB = f+j_coord_offsetB;
563 fjptrC = f+j_coord_offsetC;
564 fjptrD = f+j_coord_offsetD;
565 gmx_mm256_decrement_1rvec_4ptr_swizzle_pd(fjptrA,fjptrB,fjptrC,fjptrD,tx,ty,tz);
569 /* Inner loop uses 30 flops */
575 /* Get j neighbor index, and coordinate index */
576 jnrlistA = jjnr[jidx];
577 jnrlistB = jjnr[jidx+1];
578 jnrlistC = jjnr[jidx+2];
579 jnrlistD = jjnr[jidx+3];
580 /* Sign of each element will be negative for non-real atoms.
581 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
582 * so use it as val = _mm_andnot_pd(mask,val) to clear dummy entries.
584 tmpmask0 = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
586 tmpmask1 = _mm_permute_ps(tmpmask0,_GMX_MM_PERMUTE(3,3,2,2));
587 tmpmask0 = _mm_permute_ps(tmpmask0,_GMX_MM_PERMUTE(1,1,0,0));
588 dummy_mask = _mm256_castps_pd(gmx_mm256_set_m128(tmpmask1,tmpmask0));
590 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
591 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
592 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
593 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
594 j_coord_offsetA = DIM*jnrA;
595 j_coord_offsetB = DIM*jnrB;
596 j_coord_offsetC = DIM*jnrC;
597 j_coord_offsetD = DIM*jnrD;
599 /* load j atom coordinates */
600 gmx_mm256_load_1rvec_4ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
601 x+j_coord_offsetC,x+j_coord_offsetD,
604 /* Calculate displacement vector */
605 dx00 = _mm256_sub_pd(ix0,jx0);
606 dy00 = _mm256_sub_pd(iy0,jy0);
607 dz00 = _mm256_sub_pd(iz0,jz0);
609 /* Calculate squared distance and things based on it */
610 rsq00 = gmx_mm256_calc_rsq_pd(dx00,dy00,dz00);
612 rinvsq00 = gmx_mm256_inv_pd(rsq00);
614 /* Load parameters for j particles */
615 vdwjidx0A = 2*vdwtype[jnrA+0];
616 vdwjidx0B = 2*vdwtype[jnrB+0];
617 vdwjidx0C = 2*vdwtype[jnrC+0];
618 vdwjidx0D = 2*vdwtype[jnrD+0];
620 /**************************
621 * CALCULATE INTERACTIONS *
622 **************************/
624 if (gmx_mm256_any_lt(rsq00,rcutoff2))
627 /* Compute parameters for interactions between i and j atoms */
628 gmx_mm256_load_4pair_swizzle_pd(vdwioffsetptr0+vdwjidx0A,
629 vdwioffsetptr0+vdwjidx0B,
630 vdwioffsetptr0+vdwjidx0C,
631 vdwioffsetptr0+vdwjidx0D,
634 /* LENNARD-JONES DISPERSION/REPULSION */
636 rinvsix = _mm256_mul_pd(_mm256_mul_pd(rinvsq00,rinvsq00),rinvsq00);
637 fvdw = _mm256_mul_pd(_mm256_sub_pd(_mm256_mul_pd(c12_00,rinvsix),c6_00),_mm256_mul_pd(rinvsix,rinvsq00));
639 cutoff_mask = _mm256_cmp_pd(rsq00,rcutoff2,_CMP_LT_OQ);
643 fscal = _mm256_and_pd(fscal,cutoff_mask);
645 fscal = _mm256_andnot_pd(dummy_mask,fscal);
647 /* Calculate temporary vectorial force */
648 tx = _mm256_mul_pd(fscal,dx00);
649 ty = _mm256_mul_pd(fscal,dy00);
650 tz = _mm256_mul_pd(fscal,dz00);
652 /* Update vectorial force */
653 fix0 = _mm256_add_pd(fix0,tx);
654 fiy0 = _mm256_add_pd(fiy0,ty);
655 fiz0 = _mm256_add_pd(fiz0,tz);
657 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
658 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
659 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
660 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
661 gmx_mm256_decrement_1rvec_4ptr_swizzle_pd(fjptrA,fjptrB,fjptrC,fjptrD,tx,ty,tz);
665 /* Inner loop uses 30 flops */
668 /* End of innermost loop */
670 gmx_mm256_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
671 f+i_coord_offset,fshift+i_shift_offset);
673 /* Increment number of inner iterations */
674 inneriter += j_index_end - j_index_start;
676 /* Outer loop uses 6 flops */
679 /* Increment number of outer iterations */
682 /* Update outer/inner flops */
684 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_F,outeriter*6 + inneriter*30);