2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014,2015,2017,2018, 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_single kernel generator.
44 #include "../nb_kernel.h"
45 #include "gromacs/gmxlib/nrnb.h"
47 #include "kernelutil_x86_avx_256_single.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwLJ_GeomP1P1_VF_avx_256_single
51 * Electrostatics interaction: ReactionField
52 * VdW interaction: LennardJones
53 * Geometry: Particle-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecRF_VdwLJ_GeomP1P1_VF_avx_256_single
58 (t_nblist * gmx_restrict nlist,
59 rvec * gmx_restrict xx,
60 rvec * gmx_restrict ff,
61 struct t_forcerec * gmx_restrict fr,
62 t_mdatoms * gmx_restrict mdatoms,
63 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
64 t_nrnb * gmx_restrict nrnb)
66 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
67 * just 0 for non-waters.
68 * Suffixes A,B,C,D,E,F,G,H refer to j loop unrolling done with AVX, e.g. for the eight different
69 * jnr indices corresponding to data put in the four positions in the SIMD register.
71 int i_shift_offset,i_coord_offset,outeriter,inneriter;
72 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
73 int jnrA,jnrB,jnrC,jnrD;
74 int jnrE,jnrF,jnrG,jnrH;
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 j_coord_offsetE,j_coord_offsetF,j_coord_offsetG,j_coord_offsetH;
79 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
81 real *shiftvec,*fshift,*x,*f;
82 real *fjptrA,*fjptrB,*fjptrC,*fjptrD,*fjptrE,*fjptrF,*fjptrG,*fjptrH;
84 __m256 tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
85 real * vdwioffsetptr0;
86 __m256 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
87 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D,vdwjidx0E,vdwjidx0F,vdwjidx0G,vdwjidx0H;
88 __m256 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
89 __m256 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
90 __m256 velec,felec,velecsum,facel,crf,krf,krf2;
93 __m256 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
96 __m256 one_sixth = _mm256_set1_ps(1.0/6.0);
97 __m256 one_twelfth = _mm256_set1_ps(1.0/12.0);
98 __m256 dummy_mask,cutoff_mask;
99 __m256 signbit = _mm256_castsi256_ps( _mm256_set1_epi32(0x80000000) );
100 __m256 one = _mm256_set1_ps(1.0);
101 __m256 two = _mm256_set1_ps(2.0);
107 jindex = nlist->jindex;
109 shiftidx = nlist->shift;
111 shiftvec = fr->shift_vec[0];
112 fshift = fr->fshift[0];
113 facel = _mm256_set1_ps(fr->ic->epsfac);
114 charge = mdatoms->chargeA;
115 krf = _mm256_set1_ps(fr->ic->k_rf);
116 krf2 = _mm256_set1_ps(fr->ic->k_rf*2.0);
117 crf = _mm256_set1_ps(fr->ic->c_rf);
118 nvdwtype = fr->ntype;
120 vdwtype = mdatoms->typeA;
122 /* Avoid stupid compiler warnings */
123 jnrA = jnrB = jnrC = jnrD = jnrE = jnrF = jnrG = jnrH = 0;
136 for(iidx=0;iidx<4*DIM;iidx++)
141 /* Start outer loop over neighborlists */
142 for(iidx=0; iidx<nri; iidx++)
144 /* Load shift vector for this list */
145 i_shift_offset = DIM*shiftidx[iidx];
147 /* Load limits for loop over neighbors */
148 j_index_start = jindex[iidx];
149 j_index_end = jindex[iidx+1];
151 /* Get outer coordinate index */
153 i_coord_offset = DIM*inr;
155 /* Load i particle coords and add shift vector */
156 gmx_mm256_load_shift_and_1rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
158 fix0 = _mm256_setzero_ps();
159 fiy0 = _mm256_setzero_ps();
160 fiz0 = _mm256_setzero_ps();
162 /* Load parameters for i particles */
163 iq0 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+0]));
164 vdwioffsetptr0 = vdwparam+2*nvdwtype*vdwtype[inr+0];
166 /* Reset potential sums */
167 velecsum = _mm256_setzero_ps();
168 vvdwsum = _mm256_setzero_ps();
170 /* Start inner kernel loop */
171 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+7]>=0; jidx+=8)
174 /* Get j neighbor index, and coordinate index */
183 j_coord_offsetA = DIM*jnrA;
184 j_coord_offsetB = DIM*jnrB;
185 j_coord_offsetC = DIM*jnrC;
186 j_coord_offsetD = DIM*jnrD;
187 j_coord_offsetE = DIM*jnrE;
188 j_coord_offsetF = DIM*jnrF;
189 j_coord_offsetG = DIM*jnrG;
190 j_coord_offsetH = DIM*jnrH;
192 /* load j atom coordinates */
193 gmx_mm256_load_1rvec_8ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
194 x+j_coord_offsetC,x+j_coord_offsetD,
195 x+j_coord_offsetE,x+j_coord_offsetF,
196 x+j_coord_offsetG,x+j_coord_offsetH,
199 /* Calculate displacement vector */
200 dx00 = _mm256_sub_ps(ix0,jx0);
201 dy00 = _mm256_sub_ps(iy0,jy0);
202 dz00 = _mm256_sub_ps(iz0,jz0);
204 /* Calculate squared distance and things based on it */
205 rsq00 = gmx_mm256_calc_rsq_ps(dx00,dy00,dz00);
207 rinv00 = avx256_invsqrt_f(rsq00);
209 rinvsq00 = _mm256_mul_ps(rinv00,rinv00);
211 /* Load parameters for j particles */
212 jq0 = gmx_mm256_load_8real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
213 charge+jnrC+0,charge+jnrD+0,
214 charge+jnrE+0,charge+jnrF+0,
215 charge+jnrG+0,charge+jnrH+0);
216 vdwjidx0A = 2*vdwtype[jnrA+0];
217 vdwjidx0B = 2*vdwtype[jnrB+0];
218 vdwjidx0C = 2*vdwtype[jnrC+0];
219 vdwjidx0D = 2*vdwtype[jnrD+0];
220 vdwjidx0E = 2*vdwtype[jnrE+0];
221 vdwjidx0F = 2*vdwtype[jnrF+0];
222 vdwjidx0G = 2*vdwtype[jnrG+0];
223 vdwjidx0H = 2*vdwtype[jnrH+0];
225 /**************************
226 * CALCULATE INTERACTIONS *
227 **************************/
229 /* Compute parameters for interactions between i and j atoms */
230 qq00 = _mm256_mul_ps(iq0,jq0);
231 gmx_mm256_load_8pair_swizzle_ps(vdwioffsetptr0+vdwjidx0A,
232 vdwioffsetptr0+vdwjidx0B,
233 vdwioffsetptr0+vdwjidx0C,
234 vdwioffsetptr0+vdwjidx0D,
235 vdwioffsetptr0+vdwjidx0E,
236 vdwioffsetptr0+vdwjidx0F,
237 vdwioffsetptr0+vdwjidx0G,
238 vdwioffsetptr0+vdwjidx0H,
241 /* REACTION-FIELD ELECTROSTATICS */
242 velec = _mm256_mul_ps(qq00,_mm256_sub_ps(_mm256_add_ps(rinv00,_mm256_mul_ps(krf,rsq00)),crf));
243 felec = _mm256_mul_ps(qq00,_mm256_sub_ps(_mm256_mul_ps(rinv00,rinvsq00),krf2));
245 /* LENNARD-JONES DISPERSION/REPULSION */
247 rinvsix = _mm256_mul_ps(_mm256_mul_ps(rinvsq00,rinvsq00),rinvsq00);
248 vvdw6 = _mm256_mul_ps(c6_00,rinvsix);
249 vvdw12 = _mm256_mul_ps(c12_00,_mm256_mul_ps(rinvsix,rinvsix));
250 vvdw = _mm256_sub_ps( _mm256_mul_ps(vvdw12,one_twelfth) , _mm256_mul_ps(vvdw6,one_sixth) );
251 fvdw = _mm256_mul_ps(_mm256_sub_ps(vvdw12,vvdw6),rinvsq00);
253 /* Update potential sum for this i atom from the interaction with this j atom. */
254 velecsum = _mm256_add_ps(velecsum,velec);
255 vvdwsum = _mm256_add_ps(vvdwsum,vvdw);
257 fscal = _mm256_add_ps(felec,fvdw);
259 /* Calculate temporary vectorial force */
260 tx = _mm256_mul_ps(fscal,dx00);
261 ty = _mm256_mul_ps(fscal,dy00);
262 tz = _mm256_mul_ps(fscal,dz00);
264 /* Update vectorial force */
265 fix0 = _mm256_add_ps(fix0,tx);
266 fiy0 = _mm256_add_ps(fiy0,ty);
267 fiz0 = _mm256_add_ps(fiz0,tz);
269 fjptrA = f+j_coord_offsetA;
270 fjptrB = f+j_coord_offsetB;
271 fjptrC = f+j_coord_offsetC;
272 fjptrD = f+j_coord_offsetD;
273 fjptrE = f+j_coord_offsetE;
274 fjptrF = f+j_coord_offsetF;
275 fjptrG = f+j_coord_offsetG;
276 fjptrH = f+j_coord_offsetH;
277 gmx_mm256_decrement_1rvec_8ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjptrE,fjptrF,fjptrG,fjptrH,tx,ty,tz);
279 /* Inner loop uses 44 flops */
285 /* Get j neighbor index, and coordinate index */
286 jnrlistA = jjnr[jidx];
287 jnrlistB = jjnr[jidx+1];
288 jnrlistC = jjnr[jidx+2];
289 jnrlistD = jjnr[jidx+3];
290 jnrlistE = jjnr[jidx+4];
291 jnrlistF = jjnr[jidx+5];
292 jnrlistG = jjnr[jidx+6];
293 jnrlistH = jjnr[jidx+7];
294 /* Sign of each element will be negative for non-real atoms.
295 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
296 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
298 dummy_mask = gmx_mm256_set_m128(gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx+4)),_mm_setzero_si128())),
299 gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128())));
301 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
302 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
303 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
304 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
305 jnrE = (jnrlistE>=0) ? jnrlistE : 0;
306 jnrF = (jnrlistF>=0) ? jnrlistF : 0;
307 jnrG = (jnrlistG>=0) ? jnrlistG : 0;
308 jnrH = (jnrlistH>=0) ? jnrlistH : 0;
309 j_coord_offsetA = DIM*jnrA;
310 j_coord_offsetB = DIM*jnrB;
311 j_coord_offsetC = DIM*jnrC;
312 j_coord_offsetD = DIM*jnrD;
313 j_coord_offsetE = DIM*jnrE;
314 j_coord_offsetF = DIM*jnrF;
315 j_coord_offsetG = DIM*jnrG;
316 j_coord_offsetH = DIM*jnrH;
318 /* load j atom coordinates */
319 gmx_mm256_load_1rvec_8ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
320 x+j_coord_offsetC,x+j_coord_offsetD,
321 x+j_coord_offsetE,x+j_coord_offsetF,
322 x+j_coord_offsetG,x+j_coord_offsetH,
325 /* Calculate displacement vector */
326 dx00 = _mm256_sub_ps(ix0,jx0);
327 dy00 = _mm256_sub_ps(iy0,jy0);
328 dz00 = _mm256_sub_ps(iz0,jz0);
330 /* Calculate squared distance and things based on it */
331 rsq00 = gmx_mm256_calc_rsq_ps(dx00,dy00,dz00);
333 rinv00 = avx256_invsqrt_f(rsq00);
335 rinvsq00 = _mm256_mul_ps(rinv00,rinv00);
337 /* Load parameters for j particles */
338 jq0 = gmx_mm256_load_8real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
339 charge+jnrC+0,charge+jnrD+0,
340 charge+jnrE+0,charge+jnrF+0,
341 charge+jnrG+0,charge+jnrH+0);
342 vdwjidx0A = 2*vdwtype[jnrA+0];
343 vdwjidx0B = 2*vdwtype[jnrB+0];
344 vdwjidx0C = 2*vdwtype[jnrC+0];
345 vdwjidx0D = 2*vdwtype[jnrD+0];
346 vdwjidx0E = 2*vdwtype[jnrE+0];
347 vdwjidx0F = 2*vdwtype[jnrF+0];
348 vdwjidx0G = 2*vdwtype[jnrG+0];
349 vdwjidx0H = 2*vdwtype[jnrH+0];
351 /**************************
352 * CALCULATE INTERACTIONS *
353 **************************/
355 /* Compute parameters for interactions between i and j atoms */
356 qq00 = _mm256_mul_ps(iq0,jq0);
357 gmx_mm256_load_8pair_swizzle_ps(vdwioffsetptr0+vdwjidx0A,
358 vdwioffsetptr0+vdwjidx0B,
359 vdwioffsetptr0+vdwjidx0C,
360 vdwioffsetptr0+vdwjidx0D,
361 vdwioffsetptr0+vdwjidx0E,
362 vdwioffsetptr0+vdwjidx0F,
363 vdwioffsetptr0+vdwjidx0G,
364 vdwioffsetptr0+vdwjidx0H,
367 /* REACTION-FIELD ELECTROSTATICS */
368 velec = _mm256_mul_ps(qq00,_mm256_sub_ps(_mm256_add_ps(rinv00,_mm256_mul_ps(krf,rsq00)),crf));
369 felec = _mm256_mul_ps(qq00,_mm256_sub_ps(_mm256_mul_ps(rinv00,rinvsq00),krf2));
371 /* LENNARD-JONES DISPERSION/REPULSION */
373 rinvsix = _mm256_mul_ps(_mm256_mul_ps(rinvsq00,rinvsq00),rinvsq00);
374 vvdw6 = _mm256_mul_ps(c6_00,rinvsix);
375 vvdw12 = _mm256_mul_ps(c12_00,_mm256_mul_ps(rinvsix,rinvsix));
376 vvdw = _mm256_sub_ps( _mm256_mul_ps(vvdw12,one_twelfth) , _mm256_mul_ps(vvdw6,one_sixth) );
377 fvdw = _mm256_mul_ps(_mm256_sub_ps(vvdw12,vvdw6),rinvsq00);
379 /* Update potential sum for this i atom from the interaction with this j atom. */
380 velec = _mm256_andnot_ps(dummy_mask,velec);
381 velecsum = _mm256_add_ps(velecsum,velec);
382 vvdw = _mm256_andnot_ps(dummy_mask,vvdw);
383 vvdwsum = _mm256_add_ps(vvdwsum,vvdw);
385 fscal = _mm256_add_ps(felec,fvdw);
387 fscal = _mm256_andnot_ps(dummy_mask,fscal);
389 /* Calculate temporary vectorial force */
390 tx = _mm256_mul_ps(fscal,dx00);
391 ty = _mm256_mul_ps(fscal,dy00);
392 tz = _mm256_mul_ps(fscal,dz00);
394 /* Update vectorial force */
395 fix0 = _mm256_add_ps(fix0,tx);
396 fiy0 = _mm256_add_ps(fiy0,ty);
397 fiz0 = _mm256_add_ps(fiz0,tz);
399 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
400 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
401 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
402 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
403 fjptrE = (jnrlistE>=0) ? f+j_coord_offsetE : scratch;
404 fjptrF = (jnrlistF>=0) ? f+j_coord_offsetF : scratch;
405 fjptrG = (jnrlistG>=0) ? f+j_coord_offsetG : scratch;
406 fjptrH = (jnrlistH>=0) ? f+j_coord_offsetH : scratch;
407 gmx_mm256_decrement_1rvec_8ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjptrE,fjptrF,fjptrG,fjptrH,tx,ty,tz);
409 /* Inner loop uses 44 flops */
412 /* End of innermost loop */
414 gmx_mm256_update_iforce_1atom_swizzle_ps(fix0,fiy0,fiz0,
415 f+i_coord_offset,fshift+i_shift_offset);
418 /* Update potential energies */
419 gmx_mm256_update_1pot_ps(velecsum,kernel_data->energygrp_elec+ggid);
420 gmx_mm256_update_1pot_ps(vvdwsum,kernel_data->energygrp_vdw+ggid);
422 /* Increment number of inner iterations */
423 inneriter += j_index_end - j_index_start;
425 /* Outer loop uses 9 flops */
428 /* Increment number of outer iterations */
431 /* Update outer/inner flops */
433 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_VF,outeriter*9 + inneriter*44);
436 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwLJ_GeomP1P1_F_avx_256_single
437 * Electrostatics interaction: ReactionField
438 * VdW interaction: LennardJones
439 * Geometry: Particle-Particle
440 * Calculate force/pot: Force
443 nb_kernel_ElecRF_VdwLJ_GeomP1P1_F_avx_256_single
444 (t_nblist * gmx_restrict nlist,
445 rvec * gmx_restrict xx,
446 rvec * gmx_restrict ff,
447 struct t_forcerec * gmx_restrict fr,
448 t_mdatoms * gmx_restrict mdatoms,
449 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
450 t_nrnb * gmx_restrict nrnb)
452 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
453 * just 0 for non-waters.
454 * Suffixes A,B,C,D,E,F,G,H refer to j loop unrolling done with AVX, e.g. for the eight different
455 * jnr indices corresponding to data put in the four positions in the SIMD register.
457 int i_shift_offset,i_coord_offset,outeriter,inneriter;
458 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
459 int jnrA,jnrB,jnrC,jnrD;
460 int jnrE,jnrF,jnrG,jnrH;
461 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
462 int jnrlistE,jnrlistF,jnrlistG,jnrlistH;
463 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
464 int j_coord_offsetE,j_coord_offsetF,j_coord_offsetG,j_coord_offsetH;
465 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
467 real *shiftvec,*fshift,*x,*f;
468 real *fjptrA,*fjptrB,*fjptrC,*fjptrD,*fjptrE,*fjptrF,*fjptrG,*fjptrH;
470 __m256 tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
471 real * vdwioffsetptr0;
472 __m256 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
473 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D,vdwjidx0E,vdwjidx0F,vdwjidx0G,vdwjidx0H;
474 __m256 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
475 __m256 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
476 __m256 velec,felec,velecsum,facel,crf,krf,krf2;
479 __m256 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
482 __m256 one_sixth = _mm256_set1_ps(1.0/6.0);
483 __m256 one_twelfth = _mm256_set1_ps(1.0/12.0);
484 __m256 dummy_mask,cutoff_mask;
485 __m256 signbit = _mm256_castsi256_ps( _mm256_set1_epi32(0x80000000) );
486 __m256 one = _mm256_set1_ps(1.0);
487 __m256 two = _mm256_set1_ps(2.0);
493 jindex = nlist->jindex;
495 shiftidx = nlist->shift;
497 shiftvec = fr->shift_vec[0];
498 fshift = fr->fshift[0];
499 facel = _mm256_set1_ps(fr->ic->epsfac);
500 charge = mdatoms->chargeA;
501 krf = _mm256_set1_ps(fr->ic->k_rf);
502 krf2 = _mm256_set1_ps(fr->ic->k_rf*2.0);
503 crf = _mm256_set1_ps(fr->ic->c_rf);
504 nvdwtype = fr->ntype;
506 vdwtype = mdatoms->typeA;
508 /* Avoid stupid compiler warnings */
509 jnrA = jnrB = jnrC = jnrD = jnrE = jnrF = jnrG = jnrH = 0;
522 for(iidx=0;iidx<4*DIM;iidx++)
527 /* Start outer loop over neighborlists */
528 for(iidx=0; iidx<nri; iidx++)
530 /* Load shift vector for this list */
531 i_shift_offset = DIM*shiftidx[iidx];
533 /* Load limits for loop over neighbors */
534 j_index_start = jindex[iidx];
535 j_index_end = jindex[iidx+1];
537 /* Get outer coordinate index */
539 i_coord_offset = DIM*inr;
541 /* Load i particle coords and add shift vector */
542 gmx_mm256_load_shift_and_1rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
544 fix0 = _mm256_setzero_ps();
545 fiy0 = _mm256_setzero_ps();
546 fiz0 = _mm256_setzero_ps();
548 /* Load parameters for i particles */
549 iq0 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+0]));
550 vdwioffsetptr0 = vdwparam+2*nvdwtype*vdwtype[inr+0];
552 /* Start inner kernel loop */
553 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+7]>=0; jidx+=8)
556 /* Get j neighbor index, and coordinate index */
565 j_coord_offsetA = DIM*jnrA;
566 j_coord_offsetB = DIM*jnrB;
567 j_coord_offsetC = DIM*jnrC;
568 j_coord_offsetD = DIM*jnrD;
569 j_coord_offsetE = DIM*jnrE;
570 j_coord_offsetF = DIM*jnrF;
571 j_coord_offsetG = DIM*jnrG;
572 j_coord_offsetH = DIM*jnrH;
574 /* load j atom coordinates */
575 gmx_mm256_load_1rvec_8ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
576 x+j_coord_offsetC,x+j_coord_offsetD,
577 x+j_coord_offsetE,x+j_coord_offsetF,
578 x+j_coord_offsetG,x+j_coord_offsetH,
581 /* Calculate displacement vector */
582 dx00 = _mm256_sub_ps(ix0,jx0);
583 dy00 = _mm256_sub_ps(iy0,jy0);
584 dz00 = _mm256_sub_ps(iz0,jz0);
586 /* Calculate squared distance and things based on it */
587 rsq00 = gmx_mm256_calc_rsq_ps(dx00,dy00,dz00);
589 rinv00 = avx256_invsqrt_f(rsq00);
591 rinvsq00 = _mm256_mul_ps(rinv00,rinv00);
593 /* Load parameters for j particles */
594 jq0 = gmx_mm256_load_8real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
595 charge+jnrC+0,charge+jnrD+0,
596 charge+jnrE+0,charge+jnrF+0,
597 charge+jnrG+0,charge+jnrH+0);
598 vdwjidx0A = 2*vdwtype[jnrA+0];
599 vdwjidx0B = 2*vdwtype[jnrB+0];
600 vdwjidx0C = 2*vdwtype[jnrC+0];
601 vdwjidx0D = 2*vdwtype[jnrD+0];
602 vdwjidx0E = 2*vdwtype[jnrE+0];
603 vdwjidx0F = 2*vdwtype[jnrF+0];
604 vdwjidx0G = 2*vdwtype[jnrG+0];
605 vdwjidx0H = 2*vdwtype[jnrH+0];
607 /**************************
608 * CALCULATE INTERACTIONS *
609 **************************/
611 /* Compute parameters for interactions between i and j atoms */
612 qq00 = _mm256_mul_ps(iq0,jq0);
613 gmx_mm256_load_8pair_swizzle_ps(vdwioffsetptr0+vdwjidx0A,
614 vdwioffsetptr0+vdwjidx0B,
615 vdwioffsetptr0+vdwjidx0C,
616 vdwioffsetptr0+vdwjidx0D,
617 vdwioffsetptr0+vdwjidx0E,
618 vdwioffsetptr0+vdwjidx0F,
619 vdwioffsetptr0+vdwjidx0G,
620 vdwioffsetptr0+vdwjidx0H,
623 /* REACTION-FIELD ELECTROSTATICS */
624 felec = _mm256_mul_ps(qq00,_mm256_sub_ps(_mm256_mul_ps(rinv00,rinvsq00),krf2));
626 /* LENNARD-JONES DISPERSION/REPULSION */
628 rinvsix = _mm256_mul_ps(_mm256_mul_ps(rinvsq00,rinvsq00),rinvsq00);
629 fvdw = _mm256_mul_ps(_mm256_sub_ps(_mm256_mul_ps(c12_00,rinvsix),c6_00),_mm256_mul_ps(rinvsix,rinvsq00));
631 fscal = _mm256_add_ps(felec,fvdw);
633 /* Calculate temporary vectorial force */
634 tx = _mm256_mul_ps(fscal,dx00);
635 ty = _mm256_mul_ps(fscal,dy00);
636 tz = _mm256_mul_ps(fscal,dz00);
638 /* Update vectorial force */
639 fix0 = _mm256_add_ps(fix0,tx);
640 fiy0 = _mm256_add_ps(fiy0,ty);
641 fiz0 = _mm256_add_ps(fiz0,tz);
643 fjptrA = f+j_coord_offsetA;
644 fjptrB = f+j_coord_offsetB;
645 fjptrC = f+j_coord_offsetC;
646 fjptrD = f+j_coord_offsetD;
647 fjptrE = f+j_coord_offsetE;
648 fjptrF = f+j_coord_offsetF;
649 fjptrG = f+j_coord_offsetG;
650 fjptrH = f+j_coord_offsetH;
651 gmx_mm256_decrement_1rvec_8ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjptrE,fjptrF,fjptrG,fjptrH,tx,ty,tz);
653 /* Inner loop uses 34 flops */
659 /* Get j neighbor index, and coordinate index */
660 jnrlistA = jjnr[jidx];
661 jnrlistB = jjnr[jidx+1];
662 jnrlistC = jjnr[jidx+2];
663 jnrlistD = jjnr[jidx+3];
664 jnrlistE = jjnr[jidx+4];
665 jnrlistF = jjnr[jidx+5];
666 jnrlistG = jjnr[jidx+6];
667 jnrlistH = jjnr[jidx+7];
668 /* Sign of each element will be negative for non-real atoms.
669 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
670 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
672 dummy_mask = gmx_mm256_set_m128(gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx+4)),_mm_setzero_si128())),
673 gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128())));
675 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
676 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
677 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
678 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
679 jnrE = (jnrlistE>=0) ? jnrlistE : 0;
680 jnrF = (jnrlistF>=0) ? jnrlistF : 0;
681 jnrG = (jnrlistG>=0) ? jnrlistG : 0;
682 jnrH = (jnrlistH>=0) ? jnrlistH : 0;
683 j_coord_offsetA = DIM*jnrA;
684 j_coord_offsetB = DIM*jnrB;
685 j_coord_offsetC = DIM*jnrC;
686 j_coord_offsetD = DIM*jnrD;
687 j_coord_offsetE = DIM*jnrE;
688 j_coord_offsetF = DIM*jnrF;
689 j_coord_offsetG = DIM*jnrG;
690 j_coord_offsetH = DIM*jnrH;
692 /* load j atom coordinates */
693 gmx_mm256_load_1rvec_8ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
694 x+j_coord_offsetC,x+j_coord_offsetD,
695 x+j_coord_offsetE,x+j_coord_offsetF,
696 x+j_coord_offsetG,x+j_coord_offsetH,
699 /* Calculate displacement vector */
700 dx00 = _mm256_sub_ps(ix0,jx0);
701 dy00 = _mm256_sub_ps(iy0,jy0);
702 dz00 = _mm256_sub_ps(iz0,jz0);
704 /* Calculate squared distance and things based on it */
705 rsq00 = gmx_mm256_calc_rsq_ps(dx00,dy00,dz00);
707 rinv00 = avx256_invsqrt_f(rsq00);
709 rinvsq00 = _mm256_mul_ps(rinv00,rinv00);
711 /* Load parameters for j particles */
712 jq0 = gmx_mm256_load_8real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
713 charge+jnrC+0,charge+jnrD+0,
714 charge+jnrE+0,charge+jnrF+0,
715 charge+jnrG+0,charge+jnrH+0);
716 vdwjidx0A = 2*vdwtype[jnrA+0];
717 vdwjidx0B = 2*vdwtype[jnrB+0];
718 vdwjidx0C = 2*vdwtype[jnrC+0];
719 vdwjidx0D = 2*vdwtype[jnrD+0];
720 vdwjidx0E = 2*vdwtype[jnrE+0];
721 vdwjidx0F = 2*vdwtype[jnrF+0];
722 vdwjidx0G = 2*vdwtype[jnrG+0];
723 vdwjidx0H = 2*vdwtype[jnrH+0];
725 /**************************
726 * CALCULATE INTERACTIONS *
727 **************************/
729 /* Compute parameters for interactions between i and j atoms */
730 qq00 = _mm256_mul_ps(iq0,jq0);
731 gmx_mm256_load_8pair_swizzle_ps(vdwioffsetptr0+vdwjidx0A,
732 vdwioffsetptr0+vdwjidx0B,
733 vdwioffsetptr0+vdwjidx0C,
734 vdwioffsetptr0+vdwjidx0D,
735 vdwioffsetptr0+vdwjidx0E,
736 vdwioffsetptr0+vdwjidx0F,
737 vdwioffsetptr0+vdwjidx0G,
738 vdwioffsetptr0+vdwjidx0H,
741 /* REACTION-FIELD ELECTROSTATICS */
742 felec = _mm256_mul_ps(qq00,_mm256_sub_ps(_mm256_mul_ps(rinv00,rinvsq00),krf2));
744 /* LENNARD-JONES DISPERSION/REPULSION */
746 rinvsix = _mm256_mul_ps(_mm256_mul_ps(rinvsq00,rinvsq00),rinvsq00);
747 fvdw = _mm256_mul_ps(_mm256_sub_ps(_mm256_mul_ps(c12_00,rinvsix),c6_00),_mm256_mul_ps(rinvsix,rinvsq00));
749 fscal = _mm256_add_ps(felec,fvdw);
751 fscal = _mm256_andnot_ps(dummy_mask,fscal);
753 /* Calculate temporary vectorial force */
754 tx = _mm256_mul_ps(fscal,dx00);
755 ty = _mm256_mul_ps(fscal,dy00);
756 tz = _mm256_mul_ps(fscal,dz00);
758 /* Update vectorial force */
759 fix0 = _mm256_add_ps(fix0,tx);
760 fiy0 = _mm256_add_ps(fiy0,ty);
761 fiz0 = _mm256_add_ps(fiz0,tz);
763 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
764 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
765 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
766 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
767 fjptrE = (jnrlistE>=0) ? f+j_coord_offsetE : scratch;
768 fjptrF = (jnrlistF>=0) ? f+j_coord_offsetF : scratch;
769 fjptrG = (jnrlistG>=0) ? f+j_coord_offsetG : scratch;
770 fjptrH = (jnrlistH>=0) ? f+j_coord_offsetH : scratch;
771 gmx_mm256_decrement_1rvec_8ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjptrE,fjptrF,fjptrG,fjptrH,tx,ty,tz);
773 /* Inner loop uses 34 flops */
776 /* End of innermost loop */
778 gmx_mm256_update_iforce_1atom_swizzle_ps(fix0,fiy0,fiz0,
779 f+i_coord_offset,fshift+i_shift_offset);
781 /* Increment number of inner iterations */
782 inneriter += j_index_end - j_index_start;
784 /* Outer loop uses 7 flops */
787 /* Increment number of outer iterations */
790 /* Update outer/inner flops */
792 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_F,outeriter*7 + inneriter*34);