2 * Note: this file was generated by the Gromacs avx_256_single kernel generator.
4 * This source code is part of
8 * Copyright (c) 2001-2012, The GROMACS Development Team
10 * Gromacs is a library for molecular simulation and trajectory analysis,
11 * written by Erik Lindahl, David van der Spoel, Berk Hess, and others - for
12 * a full list of developers and information, check out http://www.gromacs.org
14 * This program is free software; you can redistribute it and/or modify it under
15 * the terms of the GNU Lesser General Public License as published by the Free
16 * Software Foundation; either version 2 of the License, or (at your option) any
19 * To help fund GROMACS development, we humbly ask that you cite
20 * the papers people have written on it - you can find them on the website.
28 #include "../nb_kernel.h"
29 #include "types/simple.h"
33 #include "gmx_math_x86_avx_256_single.h"
34 #include "kernelutil_x86_avx_256_single.h"
37 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwLJ_GeomP1P1_VF_avx_256_single
38 * Electrostatics interaction: None
39 * VdW interaction: LennardJones
40 * Geometry: Particle-Particle
41 * Calculate force/pot: PotentialAndForce
44 nb_kernel_ElecNone_VdwLJ_GeomP1P1_VF_avx_256_single
45 (t_nblist * gmx_restrict nlist,
46 rvec * gmx_restrict xx,
47 rvec * gmx_restrict ff,
48 t_forcerec * gmx_restrict fr,
49 t_mdatoms * gmx_restrict mdatoms,
50 nb_kernel_data_t * gmx_restrict kernel_data,
51 t_nrnb * gmx_restrict nrnb)
53 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
54 * just 0 for non-waters.
55 * Suffixes A,B,C,D,E,F,G,H refer to j loop unrolling done with AVX, e.g. for the eight different
56 * jnr indices corresponding to data put in the four positions in the SIMD register.
58 int i_shift_offset,i_coord_offset,outeriter,inneriter;
59 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
60 int jnrA,jnrB,jnrC,jnrD;
61 int jnrE,jnrF,jnrG,jnrH;
62 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
63 int jnrlistE,jnrlistF,jnrlistG,jnrlistH;
64 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
65 int j_coord_offsetE,j_coord_offsetF,j_coord_offsetG,j_coord_offsetH;
66 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
68 real *shiftvec,*fshift,*x,*f;
69 real *fjptrA,*fjptrB,*fjptrC,*fjptrD,*fjptrE,*fjptrF,*fjptrG,*fjptrH;
71 __m256 tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
72 real * vdwioffsetptr0;
73 __m256 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
74 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D,vdwjidx0E,vdwjidx0F,vdwjidx0G,vdwjidx0H;
75 __m256 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
76 __m256 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
78 __m256 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
81 __m256 one_sixth = _mm256_set1_ps(1.0/6.0);
82 __m256 one_twelfth = _mm256_set1_ps(1.0/12.0);
83 __m256 dummy_mask,cutoff_mask;
84 __m256 signbit = _mm256_castsi256_ps( _mm256_set1_epi32(0x80000000) );
85 __m256 one = _mm256_set1_ps(1.0);
86 __m256 two = _mm256_set1_ps(2.0);
92 jindex = nlist->jindex;
94 shiftidx = nlist->shift;
96 shiftvec = fr->shift_vec[0];
97 fshift = fr->fshift[0];
100 vdwtype = mdatoms->typeA;
102 /* Avoid stupid compiler warnings */
103 jnrA = jnrB = jnrC = jnrD = jnrE = jnrF = jnrG = jnrH = 0;
116 for(iidx=0;iidx<4*DIM;iidx++)
121 /* Start outer loop over neighborlists */
122 for(iidx=0; iidx<nri; iidx++)
124 /* Load shift vector for this list */
125 i_shift_offset = DIM*shiftidx[iidx];
127 /* Load limits for loop over neighbors */
128 j_index_start = jindex[iidx];
129 j_index_end = jindex[iidx+1];
131 /* Get outer coordinate index */
133 i_coord_offset = DIM*inr;
135 /* Load i particle coords and add shift vector */
136 gmx_mm256_load_shift_and_1rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
138 fix0 = _mm256_setzero_ps();
139 fiy0 = _mm256_setzero_ps();
140 fiz0 = _mm256_setzero_ps();
142 /* Load parameters for i particles */
143 vdwioffsetptr0 = vdwparam+2*nvdwtype*vdwtype[inr+0];
145 /* Reset potential sums */
146 vvdwsum = _mm256_setzero_ps();
148 /* Start inner kernel loop */
149 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+7]>=0; jidx+=8)
152 /* Get j neighbor index, and coordinate index */
161 j_coord_offsetA = DIM*jnrA;
162 j_coord_offsetB = DIM*jnrB;
163 j_coord_offsetC = DIM*jnrC;
164 j_coord_offsetD = DIM*jnrD;
165 j_coord_offsetE = DIM*jnrE;
166 j_coord_offsetF = DIM*jnrF;
167 j_coord_offsetG = DIM*jnrG;
168 j_coord_offsetH = DIM*jnrH;
170 /* load j atom coordinates */
171 gmx_mm256_load_1rvec_8ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
172 x+j_coord_offsetC,x+j_coord_offsetD,
173 x+j_coord_offsetE,x+j_coord_offsetF,
174 x+j_coord_offsetG,x+j_coord_offsetH,
177 /* Calculate displacement vector */
178 dx00 = _mm256_sub_ps(ix0,jx0);
179 dy00 = _mm256_sub_ps(iy0,jy0);
180 dz00 = _mm256_sub_ps(iz0,jz0);
182 /* Calculate squared distance and things based on it */
183 rsq00 = gmx_mm256_calc_rsq_ps(dx00,dy00,dz00);
185 rinvsq00 = gmx_mm256_inv_ps(rsq00);
187 /* Load parameters for j particles */
188 vdwjidx0A = 2*vdwtype[jnrA+0];
189 vdwjidx0B = 2*vdwtype[jnrB+0];
190 vdwjidx0C = 2*vdwtype[jnrC+0];
191 vdwjidx0D = 2*vdwtype[jnrD+0];
192 vdwjidx0E = 2*vdwtype[jnrE+0];
193 vdwjidx0F = 2*vdwtype[jnrF+0];
194 vdwjidx0G = 2*vdwtype[jnrG+0];
195 vdwjidx0H = 2*vdwtype[jnrH+0];
197 /**************************
198 * CALCULATE INTERACTIONS *
199 **************************/
201 /* Compute parameters for interactions between i and j atoms */
202 gmx_mm256_load_8pair_swizzle_ps(vdwioffsetptr0+vdwjidx0A,
203 vdwioffsetptr0+vdwjidx0B,
204 vdwioffsetptr0+vdwjidx0C,
205 vdwioffsetptr0+vdwjidx0D,
206 vdwioffsetptr0+vdwjidx0E,
207 vdwioffsetptr0+vdwjidx0F,
208 vdwioffsetptr0+vdwjidx0G,
209 vdwioffsetptr0+vdwjidx0H,
212 /* LENNARD-JONES DISPERSION/REPULSION */
214 rinvsix = _mm256_mul_ps(_mm256_mul_ps(rinvsq00,rinvsq00),rinvsq00);
215 vvdw6 = _mm256_mul_ps(c6_00,rinvsix);
216 vvdw12 = _mm256_mul_ps(c12_00,_mm256_mul_ps(rinvsix,rinvsix));
217 vvdw = _mm256_sub_ps( _mm256_mul_ps(vvdw12,one_twelfth) , _mm256_mul_ps(vvdw6,one_sixth) );
218 fvdw = _mm256_mul_ps(_mm256_sub_ps(vvdw12,vvdw6),rinvsq00);
220 /* Update potential sum for this i atom from the interaction with this j atom. */
221 vvdwsum = _mm256_add_ps(vvdwsum,vvdw);
225 /* Calculate temporary vectorial force */
226 tx = _mm256_mul_ps(fscal,dx00);
227 ty = _mm256_mul_ps(fscal,dy00);
228 tz = _mm256_mul_ps(fscal,dz00);
230 /* Update vectorial force */
231 fix0 = _mm256_add_ps(fix0,tx);
232 fiy0 = _mm256_add_ps(fiy0,ty);
233 fiz0 = _mm256_add_ps(fiz0,tz);
235 fjptrA = f+j_coord_offsetA;
236 fjptrB = f+j_coord_offsetB;
237 fjptrC = f+j_coord_offsetC;
238 fjptrD = f+j_coord_offsetD;
239 fjptrE = f+j_coord_offsetE;
240 fjptrF = f+j_coord_offsetF;
241 fjptrG = f+j_coord_offsetG;
242 fjptrH = f+j_coord_offsetH;
243 gmx_mm256_decrement_1rvec_8ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjptrE,fjptrF,fjptrG,fjptrH,tx,ty,tz);
245 /* Inner loop uses 32 flops */
251 /* Get j neighbor index, and coordinate index */
252 jnrlistA = jjnr[jidx];
253 jnrlistB = jjnr[jidx+1];
254 jnrlistC = jjnr[jidx+2];
255 jnrlistD = jjnr[jidx+3];
256 jnrlistE = jjnr[jidx+4];
257 jnrlistF = jjnr[jidx+5];
258 jnrlistG = jjnr[jidx+6];
259 jnrlistH = jjnr[jidx+7];
260 /* Sign of each element will be negative for non-real atoms.
261 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
262 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
264 dummy_mask = gmx_mm256_set_m128(gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx+4)),_mm_setzero_si128())),
265 gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128())));
267 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
268 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
269 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
270 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
271 jnrE = (jnrlistE>=0) ? jnrlistE : 0;
272 jnrF = (jnrlistF>=0) ? jnrlistF : 0;
273 jnrG = (jnrlistG>=0) ? jnrlistG : 0;
274 jnrH = (jnrlistH>=0) ? jnrlistH : 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;
279 j_coord_offsetE = DIM*jnrE;
280 j_coord_offsetF = DIM*jnrF;
281 j_coord_offsetG = DIM*jnrG;
282 j_coord_offsetH = DIM*jnrH;
284 /* load j atom coordinates */
285 gmx_mm256_load_1rvec_8ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
286 x+j_coord_offsetC,x+j_coord_offsetD,
287 x+j_coord_offsetE,x+j_coord_offsetF,
288 x+j_coord_offsetG,x+j_coord_offsetH,
291 /* Calculate displacement vector */
292 dx00 = _mm256_sub_ps(ix0,jx0);
293 dy00 = _mm256_sub_ps(iy0,jy0);
294 dz00 = _mm256_sub_ps(iz0,jz0);
296 /* Calculate squared distance and things based on it */
297 rsq00 = gmx_mm256_calc_rsq_ps(dx00,dy00,dz00);
299 rinvsq00 = gmx_mm256_inv_ps(rsq00);
301 /* Load parameters for j particles */
302 vdwjidx0A = 2*vdwtype[jnrA+0];
303 vdwjidx0B = 2*vdwtype[jnrB+0];
304 vdwjidx0C = 2*vdwtype[jnrC+0];
305 vdwjidx0D = 2*vdwtype[jnrD+0];
306 vdwjidx0E = 2*vdwtype[jnrE+0];
307 vdwjidx0F = 2*vdwtype[jnrF+0];
308 vdwjidx0G = 2*vdwtype[jnrG+0];
309 vdwjidx0H = 2*vdwtype[jnrH+0];
311 /**************************
312 * CALCULATE INTERACTIONS *
313 **************************/
315 /* Compute parameters for interactions between i and j atoms */
316 gmx_mm256_load_8pair_swizzle_ps(vdwioffsetptr0+vdwjidx0A,
317 vdwioffsetptr0+vdwjidx0B,
318 vdwioffsetptr0+vdwjidx0C,
319 vdwioffsetptr0+vdwjidx0D,
320 vdwioffsetptr0+vdwjidx0E,
321 vdwioffsetptr0+vdwjidx0F,
322 vdwioffsetptr0+vdwjidx0G,
323 vdwioffsetptr0+vdwjidx0H,
326 /* LENNARD-JONES DISPERSION/REPULSION */
328 rinvsix = _mm256_mul_ps(_mm256_mul_ps(rinvsq00,rinvsq00),rinvsq00);
329 vvdw6 = _mm256_mul_ps(c6_00,rinvsix);
330 vvdw12 = _mm256_mul_ps(c12_00,_mm256_mul_ps(rinvsix,rinvsix));
331 vvdw = _mm256_sub_ps( _mm256_mul_ps(vvdw12,one_twelfth) , _mm256_mul_ps(vvdw6,one_sixth) );
332 fvdw = _mm256_mul_ps(_mm256_sub_ps(vvdw12,vvdw6),rinvsq00);
334 /* Update potential sum for this i atom from the interaction with this j atom. */
335 vvdw = _mm256_andnot_ps(dummy_mask,vvdw);
336 vvdwsum = _mm256_add_ps(vvdwsum,vvdw);
340 fscal = _mm256_andnot_ps(dummy_mask,fscal);
342 /* Calculate temporary vectorial force */
343 tx = _mm256_mul_ps(fscal,dx00);
344 ty = _mm256_mul_ps(fscal,dy00);
345 tz = _mm256_mul_ps(fscal,dz00);
347 /* Update vectorial force */
348 fix0 = _mm256_add_ps(fix0,tx);
349 fiy0 = _mm256_add_ps(fiy0,ty);
350 fiz0 = _mm256_add_ps(fiz0,tz);
352 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
353 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
354 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
355 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
356 fjptrE = (jnrlistE>=0) ? f+j_coord_offsetE : scratch;
357 fjptrF = (jnrlistF>=0) ? f+j_coord_offsetF : scratch;
358 fjptrG = (jnrlistG>=0) ? f+j_coord_offsetG : scratch;
359 fjptrH = (jnrlistH>=0) ? f+j_coord_offsetH : scratch;
360 gmx_mm256_decrement_1rvec_8ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjptrE,fjptrF,fjptrG,fjptrH,tx,ty,tz);
362 /* Inner loop uses 32 flops */
365 /* End of innermost loop */
367 gmx_mm256_update_iforce_1atom_swizzle_ps(fix0,fiy0,fiz0,
368 f+i_coord_offset,fshift+i_shift_offset);
371 /* Update potential energies */
372 gmx_mm256_update_1pot_ps(vvdwsum,kernel_data->energygrp_vdw+ggid);
374 /* Increment number of inner iterations */
375 inneriter += j_index_end - j_index_start;
377 /* Outer loop uses 7 flops */
380 /* Increment number of outer iterations */
383 /* Update outer/inner flops */
385 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_VF,outeriter*7 + inneriter*32);
388 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwLJ_GeomP1P1_F_avx_256_single
389 * Electrostatics interaction: None
390 * VdW interaction: LennardJones
391 * Geometry: Particle-Particle
392 * Calculate force/pot: Force
395 nb_kernel_ElecNone_VdwLJ_GeomP1P1_F_avx_256_single
396 (t_nblist * gmx_restrict nlist,
397 rvec * gmx_restrict xx,
398 rvec * gmx_restrict ff,
399 t_forcerec * gmx_restrict fr,
400 t_mdatoms * gmx_restrict mdatoms,
401 nb_kernel_data_t * gmx_restrict kernel_data,
402 t_nrnb * gmx_restrict nrnb)
404 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
405 * just 0 for non-waters.
406 * Suffixes A,B,C,D,E,F,G,H refer to j loop unrolling done with AVX, e.g. for the eight different
407 * jnr indices corresponding to data put in the four positions in the SIMD register.
409 int i_shift_offset,i_coord_offset,outeriter,inneriter;
410 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
411 int jnrA,jnrB,jnrC,jnrD;
412 int jnrE,jnrF,jnrG,jnrH;
413 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
414 int jnrlistE,jnrlistF,jnrlistG,jnrlistH;
415 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
416 int j_coord_offsetE,j_coord_offsetF,j_coord_offsetG,j_coord_offsetH;
417 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
419 real *shiftvec,*fshift,*x,*f;
420 real *fjptrA,*fjptrB,*fjptrC,*fjptrD,*fjptrE,*fjptrF,*fjptrG,*fjptrH;
422 __m256 tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
423 real * vdwioffsetptr0;
424 __m256 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
425 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D,vdwjidx0E,vdwjidx0F,vdwjidx0G,vdwjidx0H;
426 __m256 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
427 __m256 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
429 __m256 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
432 __m256 one_sixth = _mm256_set1_ps(1.0/6.0);
433 __m256 one_twelfth = _mm256_set1_ps(1.0/12.0);
434 __m256 dummy_mask,cutoff_mask;
435 __m256 signbit = _mm256_castsi256_ps( _mm256_set1_epi32(0x80000000) );
436 __m256 one = _mm256_set1_ps(1.0);
437 __m256 two = _mm256_set1_ps(2.0);
443 jindex = nlist->jindex;
445 shiftidx = nlist->shift;
447 shiftvec = fr->shift_vec[0];
448 fshift = fr->fshift[0];
449 nvdwtype = fr->ntype;
451 vdwtype = mdatoms->typeA;
453 /* Avoid stupid compiler warnings */
454 jnrA = jnrB = jnrC = jnrD = jnrE = jnrF = jnrG = jnrH = 0;
467 for(iidx=0;iidx<4*DIM;iidx++)
472 /* Start outer loop over neighborlists */
473 for(iidx=0; iidx<nri; iidx++)
475 /* Load shift vector for this list */
476 i_shift_offset = DIM*shiftidx[iidx];
478 /* Load limits for loop over neighbors */
479 j_index_start = jindex[iidx];
480 j_index_end = jindex[iidx+1];
482 /* Get outer coordinate index */
484 i_coord_offset = DIM*inr;
486 /* Load i particle coords and add shift vector */
487 gmx_mm256_load_shift_and_1rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
489 fix0 = _mm256_setzero_ps();
490 fiy0 = _mm256_setzero_ps();
491 fiz0 = _mm256_setzero_ps();
493 /* Load parameters for i particles */
494 vdwioffsetptr0 = vdwparam+2*nvdwtype*vdwtype[inr+0];
496 /* Start inner kernel loop */
497 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+7]>=0; jidx+=8)
500 /* Get j neighbor index, and coordinate index */
509 j_coord_offsetA = DIM*jnrA;
510 j_coord_offsetB = DIM*jnrB;
511 j_coord_offsetC = DIM*jnrC;
512 j_coord_offsetD = DIM*jnrD;
513 j_coord_offsetE = DIM*jnrE;
514 j_coord_offsetF = DIM*jnrF;
515 j_coord_offsetG = DIM*jnrG;
516 j_coord_offsetH = DIM*jnrH;
518 /* load j atom coordinates */
519 gmx_mm256_load_1rvec_8ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
520 x+j_coord_offsetC,x+j_coord_offsetD,
521 x+j_coord_offsetE,x+j_coord_offsetF,
522 x+j_coord_offsetG,x+j_coord_offsetH,
525 /* Calculate displacement vector */
526 dx00 = _mm256_sub_ps(ix0,jx0);
527 dy00 = _mm256_sub_ps(iy0,jy0);
528 dz00 = _mm256_sub_ps(iz0,jz0);
530 /* Calculate squared distance and things based on it */
531 rsq00 = gmx_mm256_calc_rsq_ps(dx00,dy00,dz00);
533 rinvsq00 = gmx_mm256_inv_ps(rsq00);
535 /* Load parameters for j particles */
536 vdwjidx0A = 2*vdwtype[jnrA+0];
537 vdwjidx0B = 2*vdwtype[jnrB+0];
538 vdwjidx0C = 2*vdwtype[jnrC+0];
539 vdwjidx0D = 2*vdwtype[jnrD+0];
540 vdwjidx0E = 2*vdwtype[jnrE+0];
541 vdwjidx0F = 2*vdwtype[jnrF+0];
542 vdwjidx0G = 2*vdwtype[jnrG+0];
543 vdwjidx0H = 2*vdwtype[jnrH+0];
545 /**************************
546 * CALCULATE INTERACTIONS *
547 **************************/
549 /* Compute parameters for interactions between i and j atoms */
550 gmx_mm256_load_8pair_swizzle_ps(vdwioffsetptr0+vdwjidx0A,
551 vdwioffsetptr0+vdwjidx0B,
552 vdwioffsetptr0+vdwjidx0C,
553 vdwioffsetptr0+vdwjidx0D,
554 vdwioffsetptr0+vdwjidx0E,
555 vdwioffsetptr0+vdwjidx0F,
556 vdwioffsetptr0+vdwjidx0G,
557 vdwioffsetptr0+vdwjidx0H,
560 /* LENNARD-JONES DISPERSION/REPULSION */
562 rinvsix = _mm256_mul_ps(_mm256_mul_ps(rinvsq00,rinvsq00),rinvsq00);
563 fvdw = _mm256_mul_ps(_mm256_sub_ps(_mm256_mul_ps(c12_00,rinvsix),c6_00),_mm256_mul_ps(rinvsix,rinvsq00));
567 /* Calculate temporary vectorial force */
568 tx = _mm256_mul_ps(fscal,dx00);
569 ty = _mm256_mul_ps(fscal,dy00);
570 tz = _mm256_mul_ps(fscal,dz00);
572 /* Update vectorial force */
573 fix0 = _mm256_add_ps(fix0,tx);
574 fiy0 = _mm256_add_ps(fiy0,ty);
575 fiz0 = _mm256_add_ps(fiz0,tz);
577 fjptrA = f+j_coord_offsetA;
578 fjptrB = f+j_coord_offsetB;
579 fjptrC = f+j_coord_offsetC;
580 fjptrD = f+j_coord_offsetD;
581 fjptrE = f+j_coord_offsetE;
582 fjptrF = f+j_coord_offsetF;
583 fjptrG = f+j_coord_offsetG;
584 fjptrH = f+j_coord_offsetH;
585 gmx_mm256_decrement_1rvec_8ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjptrE,fjptrF,fjptrG,fjptrH,tx,ty,tz);
587 /* Inner loop uses 27 flops */
593 /* Get j neighbor index, and coordinate index */
594 jnrlistA = jjnr[jidx];
595 jnrlistB = jjnr[jidx+1];
596 jnrlistC = jjnr[jidx+2];
597 jnrlistD = jjnr[jidx+3];
598 jnrlistE = jjnr[jidx+4];
599 jnrlistF = jjnr[jidx+5];
600 jnrlistG = jjnr[jidx+6];
601 jnrlistH = jjnr[jidx+7];
602 /* Sign of each element will be negative for non-real atoms.
603 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
604 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
606 dummy_mask = gmx_mm256_set_m128(gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx+4)),_mm_setzero_si128())),
607 gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128())));
609 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
610 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
611 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
612 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
613 jnrE = (jnrlistE>=0) ? jnrlistE : 0;
614 jnrF = (jnrlistF>=0) ? jnrlistF : 0;
615 jnrG = (jnrlistG>=0) ? jnrlistG : 0;
616 jnrH = (jnrlistH>=0) ? jnrlistH : 0;
617 j_coord_offsetA = DIM*jnrA;
618 j_coord_offsetB = DIM*jnrB;
619 j_coord_offsetC = DIM*jnrC;
620 j_coord_offsetD = DIM*jnrD;
621 j_coord_offsetE = DIM*jnrE;
622 j_coord_offsetF = DIM*jnrF;
623 j_coord_offsetG = DIM*jnrG;
624 j_coord_offsetH = DIM*jnrH;
626 /* load j atom coordinates */
627 gmx_mm256_load_1rvec_8ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
628 x+j_coord_offsetC,x+j_coord_offsetD,
629 x+j_coord_offsetE,x+j_coord_offsetF,
630 x+j_coord_offsetG,x+j_coord_offsetH,
633 /* Calculate displacement vector */
634 dx00 = _mm256_sub_ps(ix0,jx0);
635 dy00 = _mm256_sub_ps(iy0,jy0);
636 dz00 = _mm256_sub_ps(iz0,jz0);
638 /* Calculate squared distance and things based on it */
639 rsq00 = gmx_mm256_calc_rsq_ps(dx00,dy00,dz00);
641 rinvsq00 = gmx_mm256_inv_ps(rsq00);
643 /* Load parameters for j particles */
644 vdwjidx0A = 2*vdwtype[jnrA+0];
645 vdwjidx0B = 2*vdwtype[jnrB+0];
646 vdwjidx0C = 2*vdwtype[jnrC+0];
647 vdwjidx0D = 2*vdwtype[jnrD+0];
648 vdwjidx0E = 2*vdwtype[jnrE+0];
649 vdwjidx0F = 2*vdwtype[jnrF+0];
650 vdwjidx0G = 2*vdwtype[jnrG+0];
651 vdwjidx0H = 2*vdwtype[jnrH+0];
653 /**************************
654 * CALCULATE INTERACTIONS *
655 **************************/
657 /* Compute parameters for interactions between i and j atoms */
658 gmx_mm256_load_8pair_swizzle_ps(vdwioffsetptr0+vdwjidx0A,
659 vdwioffsetptr0+vdwjidx0B,
660 vdwioffsetptr0+vdwjidx0C,
661 vdwioffsetptr0+vdwjidx0D,
662 vdwioffsetptr0+vdwjidx0E,
663 vdwioffsetptr0+vdwjidx0F,
664 vdwioffsetptr0+vdwjidx0G,
665 vdwioffsetptr0+vdwjidx0H,
668 /* LENNARD-JONES DISPERSION/REPULSION */
670 rinvsix = _mm256_mul_ps(_mm256_mul_ps(rinvsq00,rinvsq00),rinvsq00);
671 fvdw = _mm256_mul_ps(_mm256_sub_ps(_mm256_mul_ps(c12_00,rinvsix),c6_00),_mm256_mul_ps(rinvsix,rinvsq00));
675 fscal = _mm256_andnot_ps(dummy_mask,fscal);
677 /* Calculate temporary vectorial force */
678 tx = _mm256_mul_ps(fscal,dx00);
679 ty = _mm256_mul_ps(fscal,dy00);
680 tz = _mm256_mul_ps(fscal,dz00);
682 /* Update vectorial force */
683 fix0 = _mm256_add_ps(fix0,tx);
684 fiy0 = _mm256_add_ps(fiy0,ty);
685 fiz0 = _mm256_add_ps(fiz0,tz);
687 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
688 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
689 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
690 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
691 fjptrE = (jnrlistE>=0) ? f+j_coord_offsetE : scratch;
692 fjptrF = (jnrlistF>=0) ? f+j_coord_offsetF : scratch;
693 fjptrG = (jnrlistG>=0) ? f+j_coord_offsetG : scratch;
694 fjptrH = (jnrlistH>=0) ? f+j_coord_offsetH : scratch;
695 gmx_mm256_decrement_1rvec_8ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjptrE,fjptrF,fjptrG,fjptrH,tx,ty,tz);
697 /* Inner loop uses 27 flops */
700 /* End of innermost loop */
702 gmx_mm256_update_iforce_1atom_swizzle_ps(fix0,fiy0,fiz0,
703 f+i_coord_offset,fshift+i_shift_offset);
705 /* Increment number of inner iterations */
706 inneriter += j_index_end - j_index_start;
708 /* Outer loop uses 6 flops */
711 /* Increment number of outer iterations */
714 /* Update outer/inner flops */
716 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_F,outeriter*6 + inneriter*27);