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.
44 #include "../nb_kernel.h"
45 #include "gromacs/legacyheaders/types/simple.h"
46 #include "gromacs/math/vec.h"
47 #include "gromacs/legacyheaders/nrnb.h"
49 #include "gromacs/simd/math_x86_avx_256_double.h"
50 #include "kernelutil_x86_avx_256_double.h"
53 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwLJSh_GeomP1P1_VF_avx_256_double
54 * Electrostatics interaction: None
55 * VdW interaction: LennardJones
56 * Geometry: Particle-Particle
57 * Calculate force/pot: PotentialAndForce
60 nb_kernel_ElecNone_VdwLJSh_GeomP1P1_VF_avx_256_double
61 (t_nblist * gmx_restrict nlist,
62 rvec * gmx_restrict xx,
63 rvec * gmx_restrict ff,
64 t_forcerec * gmx_restrict fr,
65 t_mdatoms * gmx_restrict mdatoms,
66 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
67 t_nrnb * gmx_restrict nrnb)
69 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
70 * just 0 for non-waters.
71 * Suffixes A,B,C,D refer to j loop unrolling done with AVX, 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 jnrlistE,jnrlistF,jnrlistG,jnrlistH;
79 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
80 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
82 real *shiftvec,*fshift,*x,*f;
83 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
85 __m256d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
86 real * vdwioffsetptr0;
87 __m256d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
88 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
89 __m256d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
90 __m256d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
92 __m256d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
95 __m256d one_sixth = _mm256_set1_pd(1.0/6.0);
96 __m256d one_twelfth = _mm256_set1_pd(1.0/12.0);
97 __m256d dummy_mask,cutoff_mask;
98 __m128 tmpmask0,tmpmask1;
99 __m256d signbit = _mm256_castsi256_pd( _mm256_set1_epi32(0x80000000) );
100 __m256d one = _mm256_set1_pd(1.0);
101 __m256d two = _mm256_set1_pd(2.0);
107 jindex = nlist->jindex;
109 shiftidx = nlist->shift;
111 shiftvec = fr->shift_vec[0];
112 fshift = fr->fshift[0];
113 nvdwtype = fr->ntype;
115 vdwtype = mdatoms->typeA;
117 rcutoff_scalar = fr->rvdw;
118 rcutoff = _mm256_set1_pd(rcutoff_scalar);
119 rcutoff2 = _mm256_mul_pd(rcutoff,rcutoff);
121 sh_vdw_invrcut6 = _mm256_set1_pd(fr->ic->sh_invrc6);
122 rvdw = _mm256_set1_pd(fr->rvdw);
124 /* Avoid stupid compiler warnings */
125 jnrA = jnrB = jnrC = jnrD = 0;
134 for(iidx=0;iidx<4*DIM;iidx++)
139 /* Start outer loop over neighborlists */
140 for(iidx=0; iidx<nri; iidx++)
142 /* Load shift vector for this list */
143 i_shift_offset = DIM*shiftidx[iidx];
145 /* Load limits for loop over neighbors */
146 j_index_start = jindex[iidx];
147 j_index_end = jindex[iidx+1];
149 /* Get outer coordinate index */
151 i_coord_offset = DIM*inr;
153 /* Load i particle coords and add shift vector */
154 gmx_mm256_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
156 fix0 = _mm256_setzero_pd();
157 fiy0 = _mm256_setzero_pd();
158 fiz0 = _mm256_setzero_pd();
160 /* Load parameters for i particles */
161 vdwioffsetptr0 = vdwparam+2*nvdwtype*vdwtype[inr+0];
163 /* Reset potential sums */
164 vvdwsum = _mm256_setzero_pd();
166 /* Start inner kernel loop */
167 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
170 /* Get j neighbor index, and coordinate index */
175 j_coord_offsetA = DIM*jnrA;
176 j_coord_offsetB = DIM*jnrB;
177 j_coord_offsetC = DIM*jnrC;
178 j_coord_offsetD = DIM*jnrD;
180 /* load j atom coordinates */
181 gmx_mm256_load_1rvec_4ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
182 x+j_coord_offsetC,x+j_coord_offsetD,
185 /* Calculate displacement vector */
186 dx00 = _mm256_sub_pd(ix0,jx0);
187 dy00 = _mm256_sub_pd(iy0,jy0);
188 dz00 = _mm256_sub_pd(iz0,jz0);
190 /* Calculate squared distance and things based on it */
191 rsq00 = gmx_mm256_calc_rsq_pd(dx00,dy00,dz00);
193 rinvsq00 = gmx_mm256_inv_pd(rsq00);
195 /* Load parameters for j particles */
196 vdwjidx0A = 2*vdwtype[jnrA+0];
197 vdwjidx0B = 2*vdwtype[jnrB+0];
198 vdwjidx0C = 2*vdwtype[jnrC+0];
199 vdwjidx0D = 2*vdwtype[jnrD+0];
201 /**************************
202 * CALCULATE INTERACTIONS *
203 **************************/
205 if (gmx_mm256_any_lt(rsq00,rcutoff2))
208 /* Compute parameters for interactions between i and j atoms */
209 gmx_mm256_load_4pair_swizzle_pd(vdwioffsetptr0+vdwjidx0A,
210 vdwioffsetptr0+vdwjidx0B,
211 vdwioffsetptr0+vdwjidx0C,
212 vdwioffsetptr0+vdwjidx0D,
215 /* LENNARD-JONES DISPERSION/REPULSION */
217 rinvsix = _mm256_mul_pd(_mm256_mul_pd(rinvsq00,rinvsq00),rinvsq00);
218 vvdw6 = _mm256_mul_pd(c6_00,rinvsix);
219 vvdw12 = _mm256_mul_pd(c12_00,_mm256_mul_pd(rinvsix,rinvsix));
220 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) ,
221 _mm256_mul_pd( _mm256_sub_pd(vvdw6,_mm256_mul_pd(c6_00,sh_vdw_invrcut6)),one_sixth));
222 fvdw = _mm256_mul_pd(_mm256_sub_pd(vvdw12,vvdw6),rinvsq00);
224 cutoff_mask = _mm256_cmp_pd(rsq00,rcutoff2,_CMP_LT_OQ);
226 /* Update potential sum for this i atom from the interaction with this j atom. */
227 vvdw = _mm256_and_pd(vvdw,cutoff_mask);
228 vvdwsum = _mm256_add_pd(vvdwsum,vvdw);
232 fscal = _mm256_and_pd(fscal,cutoff_mask);
234 /* Calculate temporary vectorial force */
235 tx = _mm256_mul_pd(fscal,dx00);
236 ty = _mm256_mul_pd(fscal,dy00);
237 tz = _mm256_mul_pd(fscal,dz00);
239 /* Update vectorial force */
240 fix0 = _mm256_add_pd(fix0,tx);
241 fiy0 = _mm256_add_pd(fiy0,ty);
242 fiz0 = _mm256_add_pd(fiz0,tz);
244 fjptrA = f+j_coord_offsetA;
245 fjptrB = f+j_coord_offsetB;
246 fjptrC = f+j_coord_offsetC;
247 fjptrD = f+j_coord_offsetD;
248 gmx_mm256_decrement_1rvec_4ptr_swizzle_pd(fjptrA,fjptrB,fjptrC,fjptrD,tx,ty,tz);
252 /* Inner loop uses 41 flops */
258 /* Get j neighbor index, and coordinate index */
259 jnrlistA = jjnr[jidx];
260 jnrlistB = jjnr[jidx+1];
261 jnrlistC = jjnr[jidx+2];
262 jnrlistD = jjnr[jidx+3];
263 /* Sign of each element will be negative for non-real atoms.
264 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
265 * so use it as val = _mm_andnot_pd(mask,val) to clear dummy entries.
267 tmpmask0 = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
269 tmpmask1 = _mm_permute_ps(tmpmask0,_GMX_MM_PERMUTE(3,3,2,2));
270 tmpmask0 = _mm_permute_ps(tmpmask0,_GMX_MM_PERMUTE(1,1,0,0));
271 dummy_mask = _mm256_castps_pd(gmx_mm256_set_m128(tmpmask1,tmpmask0));
273 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
274 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
275 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
276 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
277 j_coord_offsetA = DIM*jnrA;
278 j_coord_offsetB = DIM*jnrB;
279 j_coord_offsetC = DIM*jnrC;
280 j_coord_offsetD = DIM*jnrD;
282 /* load j atom coordinates */
283 gmx_mm256_load_1rvec_4ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
284 x+j_coord_offsetC,x+j_coord_offsetD,
287 /* Calculate displacement vector */
288 dx00 = _mm256_sub_pd(ix0,jx0);
289 dy00 = _mm256_sub_pd(iy0,jy0);
290 dz00 = _mm256_sub_pd(iz0,jz0);
292 /* Calculate squared distance and things based on it */
293 rsq00 = gmx_mm256_calc_rsq_pd(dx00,dy00,dz00);
295 rinvsq00 = gmx_mm256_inv_pd(rsq00);
297 /* Load parameters for j particles */
298 vdwjidx0A = 2*vdwtype[jnrA+0];
299 vdwjidx0B = 2*vdwtype[jnrB+0];
300 vdwjidx0C = 2*vdwtype[jnrC+0];
301 vdwjidx0D = 2*vdwtype[jnrD+0];
303 /**************************
304 * CALCULATE INTERACTIONS *
305 **************************/
307 if (gmx_mm256_any_lt(rsq00,rcutoff2))
310 /* Compute parameters for interactions between i and j atoms */
311 gmx_mm256_load_4pair_swizzle_pd(vdwioffsetptr0+vdwjidx0A,
312 vdwioffsetptr0+vdwjidx0B,
313 vdwioffsetptr0+vdwjidx0C,
314 vdwioffsetptr0+vdwjidx0D,
317 /* LENNARD-JONES DISPERSION/REPULSION */
319 rinvsix = _mm256_mul_pd(_mm256_mul_pd(rinvsq00,rinvsq00),rinvsq00);
320 vvdw6 = _mm256_mul_pd(c6_00,rinvsix);
321 vvdw12 = _mm256_mul_pd(c12_00,_mm256_mul_pd(rinvsix,rinvsix));
322 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) ,
323 _mm256_mul_pd( _mm256_sub_pd(vvdw6,_mm256_mul_pd(c6_00,sh_vdw_invrcut6)),one_sixth));
324 fvdw = _mm256_mul_pd(_mm256_sub_pd(vvdw12,vvdw6),rinvsq00);
326 cutoff_mask = _mm256_cmp_pd(rsq00,rcutoff2,_CMP_LT_OQ);
328 /* Update potential sum for this i atom from the interaction with this j atom. */
329 vvdw = _mm256_and_pd(vvdw,cutoff_mask);
330 vvdw = _mm256_andnot_pd(dummy_mask,vvdw);
331 vvdwsum = _mm256_add_pd(vvdwsum,vvdw);
335 fscal = _mm256_and_pd(fscal,cutoff_mask);
337 fscal = _mm256_andnot_pd(dummy_mask,fscal);
339 /* Calculate temporary vectorial force */
340 tx = _mm256_mul_pd(fscal,dx00);
341 ty = _mm256_mul_pd(fscal,dy00);
342 tz = _mm256_mul_pd(fscal,dz00);
344 /* Update vectorial force */
345 fix0 = _mm256_add_pd(fix0,tx);
346 fiy0 = _mm256_add_pd(fiy0,ty);
347 fiz0 = _mm256_add_pd(fiz0,tz);
349 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
350 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
351 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
352 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
353 gmx_mm256_decrement_1rvec_4ptr_swizzle_pd(fjptrA,fjptrB,fjptrC,fjptrD,tx,ty,tz);
357 /* Inner loop uses 41 flops */
360 /* End of innermost loop */
362 gmx_mm256_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
363 f+i_coord_offset,fshift+i_shift_offset);
366 /* Update potential energies */
367 gmx_mm256_update_1pot_pd(vvdwsum,kernel_data->energygrp_vdw+ggid);
369 /* Increment number of inner iterations */
370 inneriter += j_index_end - j_index_start;
372 /* Outer loop uses 7 flops */
375 /* Increment number of outer iterations */
378 /* Update outer/inner flops */
380 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_VF,outeriter*7 + inneriter*41);
383 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwLJSh_GeomP1P1_F_avx_256_double
384 * Electrostatics interaction: None
385 * VdW interaction: LennardJones
386 * Geometry: Particle-Particle
387 * Calculate force/pot: Force
390 nb_kernel_ElecNone_VdwLJSh_GeomP1P1_F_avx_256_double
391 (t_nblist * gmx_restrict nlist,
392 rvec * gmx_restrict xx,
393 rvec * gmx_restrict ff,
394 t_forcerec * gmx_restrict fr,
395 t_mdatoms * gmx_restrict mdatoms,
396 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
397 t_nrnb * gmx_restrict nrnb)
399 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
400 * just 0 for non-waters.
401 * Suffixes A,B,C,D refer to j loop unrolling done with AVX, e.g. for the four different
402 * jnr indices corresponding to data put in the four positions in the SIMD register.
404 int i_shift_offset,i_coord_offset,outeriter,inneriter;
405 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
406 int jnrA,jnrB,jnrC,jnrD;
407 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
408 int jnrlistE,jnrlistF,jnrlistG,jnrlistH;
409 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
410 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
412 real *shiftvec,*fshift,*x,*f;
413 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
415 __m256d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
416 real * vdwioffsetptr0;
417 __m256d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
418 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
419 __m256d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
420 __m256d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
422 __m256d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
425 __m256d one_sixth = _mm256_set1_pd(1.0/6.0);
426 __m256d one_twelfth = _mm256_set1_pd(1.0/12.0);
427 __m256d dummy_mask,cutoff_mask;
428 __m128 tmpmask0,tmpmask1;
429 __m256d signbit = _mm256_castsi256_pd( _mm256_set1_epi32(0x80000000) );
430 __m256d one = _mm256_set1_pd(1.0);
431 __m256d two = _mm256_set1_pd(2.0);
437 jindex = nlist->jindex;
439 shiftidx = nlist->shift;
441 shiftvec = fr->shift_vec[0];
442 fshift = fr->fshift[0];
443 nvdwtype = fr->ntype;
445 vdwtype = mdatoms->typeA;
447 rcutoff_scalar = fr->rvdw;
448 rcutoff = _mm256_set1_pd(rcutoff_scalar);
449 rcutoff2 = _mm256_mul_pd(rcutoff,rcutoff);
451 sh_vdw_invrcut6 = _mm256_set1_pd(fr->ic->sh_invrc6);
452 rvdw = _mm256_set1_pd(fr->rvdw);
454 /* Avoid stupid compiler warnings */
455 jnrA = jnrB = jnrC = jnrD = 0;
464 for(iidx=0;iidx<4*DIM;iidx++)
469 /* Start outer loop over neighborlists */
470 for(iidx=0; iidx<nri; iidx++)
472 /* Load shift vector for this list */
473 i_shift_offset = DIM*shiftidx[iidx];
475 /* Load limits for loop over neighbors */
476 j_index_start = jindex[iidx];
477 j_index_end = jindex[iidx+1];
479 /* Get outer coordinate index */
481 i_coord_offset = DIM*inr;
483 /* Load i particle coords and add shift vector */
484 gmx_mm256_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
486 fix0 = _mm256_setzero_pd();
487 fiy0 = _mm256_setzero_pd();
488 fiz0 = _mm256_setzero_pd();
490 /* Load parameters for i particles */
491 vdwioffsetptr0 = vdwparam+2*nvdwtype*vdwtype[inr+0];
493 /* Start inner kernel loop */
494 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
497 /* Get j neighbor index, and coordinate index */
502 j_coord_offsetA = DIM*jnrA;
503 j_coord_offsetB = DIM*jnrB;
504 j_coord_offsetC = DIM*jnrC;
505 j_coord_offsetD = DIM*jnrD;
507 /* load j atom coordinates */
508 gmx_mm256_load_1rvec_4ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
509 x+j_coord_offsetC,x+j_coord_offsetD,
512 /* Calculate displacement vector */
513 dx00 = _mm256_sub_pd(ix0,jx0);
514 dy00 = _mm256_sub_pd(iy0,jy0);
515 dz00 = _mm256_sub_pd(iz0,jz0);
517 /* Calculate squared distance and things based on it */
518 rsq00 = gmx_mm256_calc_rsq_pd(dx00,dy00,dz00);
520 rinvsq00 = gmx_mm256_inv_pd(rsq00);
522 /* Load parameters for j particles */
523 vdwjidx0A = 2*vdwtype[jnrA+0];
524 vdwjidx0B = 2*vdwtype[jnrB+0];
525 vdwjidx0C = 2*vdwtype[jnrC+0];
526 vdwjidx0D = 2*vdwtype[jnrD+0];
528 /**************************
529 * CALCULATE INTERACTIONS *
530 **************************/
532 if (gmx_mm256_any_lt(rsq00,rcutoff2))
535 /* Compute parameters for interactions between i and j atoms */
536 gmx_mm256_load_4pair_swizzle_pd(vdwioffsetptr0+vdwjidx0A,
537 vdwioffsetptr0+vdwjidx0B,
538 vdwioffsetptr0+vdwjidx0C,
539 vdwioffsetptr0+vdwjidx0D,
542 /* LENNARD-JONES DISPERSION/REPULSION */
544 rinvsix = _mm256_mul_pd(_mm256_mul_pd(rinvsq00,rinvsq00),rinvsq00);
545 fvdw = _mm256_mul_pd(_mm256_sub_pd(_mm256_mul_pd(c12_00,rinvsix),c6_00),_mm256_mul_pd(rinvsix,rinvsq00));
547 cutoff_mask = _mm256_cmp_pd(rsq00,rcutoff2,_CMP_LT_OQ);
551 fscal = _mm256_and_pd(fscal,cutoff_mask);
553 /* Calculate temporary vectorial force */
554 tx = _mm256_mul_pd(fscal,dx00);
555 ty = _mm256_mul_pd(fscal,dy00);
556 tz = _mm256_mul_pd(fscal,dz00);
558 /* Update vectorial force */
559 fix0 = _mm256_add_pd(fix0,tx);
560 fiy0 = _mm256_add_pd(fiy0,ty);
561 fiz0 = _mm256_add_pd(fiz0,tz);
563 fjptrA = f+j_coord_offsetA;
564 fjptrB = f+j_coord_offsetB;
565 fjptrC = f+j_coord_offsetC;
566 fjptrD = f+j_coord_offsetD;
567 gmx_mm256_decrement_1rvec_4ptr_swizzle_pd(fjptrA,fjptrB,fjptrC,fjptrD,tx,ty,tz);
571 /* Inner loop uses 30 flops */
577 /* Get j neighbor index, and coordinate index */
578 jnrlistA = jjnr[jidx];
579 jnrlistB = jjnr[jidx+1];
580 jnrlistC = jjnr[jidx+2];
581 jnrlistD = jjnr[jidx+3];
582 /* Sign of each element will be negative for non-real atoms.
583 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
584 * so use it as val = _mm_andnot_pd(mask,val) to clear dummy entries.
586 tmpmask0 = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
588 tmpmask1 = _mm_permute_ps(tmpmask0,_GMX_MM_PERMUTE(3,3,2,2));
589 tmpmask0 = _mm_permute_ps(tmpmask0,_GMX_MM_PERMUTE(1,1,0,0));
590 dummy_mask = _mm256_castps_pd(gmx_mm256_set_m128(tmpmask1,tmpmask0));
592 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
593 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
594 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
595 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
596 j_coord_offsetA = DIM*jnrA;
597 j_coord_offsetB = DIM*jnrB;
598 j_coord_offsetC = DIM*jnrC;
599 j_coord_offsetD = DIM*jnrD;
601 /* load j atom coordinates */
602 gmx_mm256_load_1rvec_4ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
603 x+j_coord_offsetC,x+j_coord_offsetD,
606 /* Calculate displacement vector */
607 dx00 = _mm256_sub_pd(ix0,jx0);
608 dy00 = _mm256_sub_pd(iy0,jy0);
609 dz00 = _mm256_sub_pd(iz0,jz0);
611 /* Calculate squared distance and things based on it */
612 rsq00 = gmx_mm256_calc_rsq_pd(dx00,dy00,dz00);
614 rinvsq00 = gmx_mm256_inv_pd(rsq00);
616 /* Load parameters for j particles */
617 vdwjidx0A = 2*vdwtype[jnrA+0];
618 vdwjidx0B = 2*vdwtype[jnrB+0];
619 vdwjidx0C = 2*vdwtype[jnrC+0];
620 vdwjidx0D = 2*vdwtype[jnrD+0];
622 /**************************
623 * CALCULATE INTERACTIONS *
624 **************************/
626 if (gmx_mm256_any_lt(rsq00,rcutoff2))
629 /* Compute parameters for interactions between i and j atoms */
630 gmx_mm256_load_4pair_swizzle_pd(vdwioffsetptr0+vdwjidx0A,
631 vdwioffsetptr0+vdwjidx0B,
632 vdwioffsetptr0+vdwjidx0C,
633 vdwioffsetptr0+vdwjidx0D,
636 /* LENNARD-JONES DISPERSION/REPULSION */
638 rinvsix = _mm256_mul_pd(_mm256_mul_pd(rinvsq00,rinvsq00),rinvsq00);
639 fvdw = _mm256_mul_pd(_mm256_sub_pd(_mm256_mul_pd(c12_00,rinvsix),c6_00),_mm256_mul_pd(rinvsix,rinvsq00));
641 cutoff_mask = _mm256_cmp_pd(rsq00,rcutoff2,_CMP_LT_OQ);
645 fscal = _mm256_and_pd(fscal,cutoff_mask);
647 fscal = _mm256_andnot_pd(dummy_mask,fscal);
649 /* Calculate temporary vectorial force */
650 tx = _mm256_mul_pd(fscal,dx00);
651 ty = _mm256_mul_pd(fscal,dy00);
652 tz = _mm256_mul_pd(fscal,dz00);
654 /* Update vectorial force */
655 fix0 = _mm256_add_pd(fix0,tx);
656 fiy0 = _mm256_add_pd(fiy0,ty);
657 fiz0 = _mm256_add_pd(fiz0,tz);
659 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
660 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
661 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
662 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
663 gmx_mm256_decrement_1rvec_4ptr_swizzle_pd(fjptrA,fjptrB,fjptrC,fjptrD,tx,ty,tz);
667 /* Inner loop uses 30 flops */
670 /* End of innermost loop */
672 gmx_mm256_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
673 f+i_coord_offset,fshift+i_shift_offset);
675 /* Increment number of inner iterations */
676 inneriter += j_index_end - j_index_start;
678 /* Outer loop uses 6 flops */
681 /* Increment number of outer iterations */
684 /* Update outer/inner flops */
686 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_F,outeriter*6 + inneriter*30);