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 sse4_1_single kernel generator.
44 #include "../nb_kernel.h"
45 #include "gromacs/gmxlib/nrnb.h"
47 #include "kernelutil_x86_sse4_1_single.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwLJSh_GeomP1P1_VF_sse4_1_single
51 * Electrostatics interaction: None
52 * VdW interaction: LennardJones
53 * Geometry: Particle-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecNone_VdwLJSh_GeomP1P1_VF_sse4_1_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 refer to j loop unrolling done with SSE, e.g. for the four 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 jnrlistA,jnrlistB,jnrlistC,jnrlistD;
75 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
76 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
78 real *shiftvec,*fshift,*x,*f;
79 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
81 __m128 tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
83 __m128 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
84 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
85 __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
86 __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
88 __m128 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
91 __m128 one_sixth = _mm_set1_ps(1.0/6.0);
92 __m128 one_twelfth = _mm_set1_ps(1.0/12.0);
93 __m128 dummy_mask,cutoff_mask;
94 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
95 __m128 one = _mm_set1_ps(1.0);
96 __m128 two = _mm_set1_ps(2.0);
102 jindex = nlist->jindex;
104 shiftidx = nlist->shift;
106 shiftvec = fr->shift_vec[0];
107 fshift = fr->fshift[0];
108 nvdwtype = fr->ntype;
110 vdwtype = mdatoms->typeA;
112 rcutoff_scalar = fr->ic->rvdw;
113 rcutoff = _mm_set1_ps(rcutoff_scalar);
114 rcutoff2 = _mm_mul_ps(rcutoff,rcutoff);
116 sh_vdw_invrcut6 = _mm_set1_ps(fr->ic->sh_invrc6);
117 rvdw = _mm_set1_ps(fr->ic->rvdw);
119 /* Avoid stupid compiler warnings */
120 jnrA = jnrB = jnrC = jnrD = 0;
129 for(iidx=0;iidx<4*DIM;iidx++)
134 /* Start outer loop over neighborlists */
135 for(iidx=0; iidx<nri; iidx++)
137 /* Load shift vector for this list */
138 i_shift_offset = DIM*shiftidx[iidx];
140 /* Load limits for loop over neighbors */
141 j_index_start = jindex[iidx];
142 j_index_end = jindex[iidx+1];
144 /* Get outer coordinate index */
146 i_coord_offset = DIM*inr;
148 /* Load i particle coords and add shift vector */
149 gmx_mm_load_shift_and_1rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
151 fix0 = _mm_setzero_ps();
152 fiy0 = _mm_setzero_ps();
153 fiz0 = _mm_setzero_ps();
155 /* Load parameters for i particles */
156 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
158 /* Reset potential sums */
159 vvdwsum = _mm_setzero_ps();
161 /* Start inner kernel loop */
162 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
165 /* Get j neighbor index, and coordinate index */
170 j_coord_offsetA = DIM*jnrA;
171 j_coord_offsetB = DIM*jnrB;
172 j_coord_offsetC = DIM*jnrC;
173 j_coord_offsetD = DIM*jnrD;
175 /* load j atom coordinates */
176 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
177 x+j_coord_offsetC,x+j_coord_offsetD,
180 /* Calculate displacement vector */
181 dx00 = _mm_sub_ps(ix0,jx0);
182 dy00 = _mm_sub_ps(iy0,jy0);
183 dz00 = _mm_sub_ps(iz0,jz0);
185 /* Calculate squared distance and things based on it */
186 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
188 rinvsq00 = sse41_inv_f(rsq00);
190 /* Load parameters for j particles */
191 vdwjidx0A = 2*vdwtype[jnrA+0];
192 vdwjidx0B = 2*vdwtype[jnrB+0];
193 vdwjidx0C = 2*vdwtype[jnrC+0];
194 vdwjidx0D = 2*vdwtype[jnrD+0];
196 /**************************
197 * CALCULATE INTERACTIONS *
198 **************************/
200 if (gmx_mm_any_lt(rsq00,rcutoff2))
203 /* Compute parameters for interactions between i and j atoms */
204 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
205 vdwparam+vdwioffset0+vdwjidx0B,
206 vdwparam+vdwioffset0+vdwjidx0C,
207 vdwparam+vdwioffset0+vdwjidx0D,
210 /* LENNARD-JONES DISPERSION/REPULSION */
212 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
213 vvdw6 = _mm_mul_ps(c6_00,rinvsix);
214 vvdw12 = _mm_mul_ps(c12_00,_mm_mul_ps(rinvsix,rinvsix));
215 vvdw = _mm_sub_ps(_mm_mul_ps( _mm_sub_ps(vvdw12 , _mm_mul_ps(c12_00,_mm_mul_ps(sh_vdw_invrcut6,sh_vdw_invrcut6))), one_twelfth) ,
216 _mm_mul_ps( _mm_sub_ps(vvdw6,_mm_mul_ps(c6_00,sh_vdw_invrcut6)),one_sixth));
217 fvdw = _mm_mul_ps(_mm_sub_ps(vvdw12,vvdw6),rinvsq00);
219 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
221 /* Update potential sum for this i atom from the interaction with this j atom. */
222 vvdw = _mm_and_ps(vvdw,cutoff_mask);
223 vvdwsum = _mm_add_ps(vvdwsum,vvdw);
227 fscal = _mm_and_ps(fscal,cutoff_mask);
229 /* Calculate temporary vectorial force */
230 tx = _mm_mul_ps(fscal,dx00);
231 ty = _mm_mul_ps(fscal,dy00);
232 tz = _mm_mul_ps(fscal,dz00);
234 /* Update vectorial force */
235 fix0 = _mm_add_ps(fix0,tx);
236 fiy0 = _mm_add_ps(fiy0,ty);
237 fiz0 = _mm_add_ps(fiz0,tz);
239 fjptrA = f+j_coord_offsetA;
240 fjptrB = f+j_coord_offsetB;
241 fjptrC = f+j_coord_offsetC;
242 fjptrD = f+j_coord_offsetD;
243 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,tx,ty,tz);
247 /* Inner loop uses 41 flops */
253 /* Get j neighbor index, and coordinate index */
254 jnrlistA = jjnr[jidx];
255 jnrlistB = jjnr[jidx+1];
256 jnrlistC = jjnr[jidx+2];
257 jnrlistD = jjnr[jidx+3];
258 /* Sign of each element will be negative for non-real atoms.
259 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
260 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
262 dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
263 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
264 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
265 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
266 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
267 j_coord_offsetA = DIM*jnrA;
268 j_coord_offsetB = DIM*jnrB;
269 j_coord_offsetC = DIM*jnrC;
270 j_coord_offsetD = DIM*jnrD;
272 /* load j atom coordinates */
273 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
274 x+j_coord_offsetC,x+j_coord_offsetD,
277 /* Calculate displacement vector */
278 dx00 = _mm_sub_ps(ix0,jx0);
279 dy00 = _mm_sub_ps(iy0,jy0);
280 dz00 = _mm_sub_ps(iz0,jz0);
282 /* Calculate squared distance and things based on it */
283 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
285 rinvsq00 = sse41_inv_f(rsq00);
287 /* Load parameters for j particles */
288 vdwjidx0A = 2*vdwtype[jnrA+0];
289 vdwjidx0B = 2*vdwtype[jnrB+0];
290 vdwjidx0C = 2*vdwtype[jnrC+0];
291 vdwjidx0D = 2*vdwtype[jnrD+0];
293 /**************************
294 * CALCULATE INTERACTIONS *
295 **************************/
297 if (gmx_mm_any_lt(rsq00,rcutoff2))
300 /* Compute parameters for interactions between i and j atoms */
301 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
302 vdwparam+vdwioffset0+vdwjidx0B,
303 vdwparam+vdwioffset0+vdwjidx0C,
304 vdwparam+vdwioffset0+vdwjidx0D,
307 /* LENNARD-JONES DISPERSION/REPULSION */
309 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
310 vvdw6 = _mm_mul_ps(c6_00,rinvsix);
311 vvdw12 = _mm_mul_ps(c12_00,_mm_mul_ps(rinvsix,rinvsix));
312 vvdw = _mm_sub_ps(_mm_mul_ps( _mm_sub_ps(vvdw12 , _mm_mul_ps(c12_00,_mm_mul_ps(sh_vdw_invrcut6,sh_vdw_invrcut6))), one_twelfth) ,
313 _mm_mul_ps( _mm_sub_ps(vvdw6,_mm_mul_ps(c6_00,sh_vdw_invrcut6)),one_sixth));
314 fvdw = _mm_mul_ps(_mm_sub_ps(vvdw12,vvdw6),rinvsq00);
316 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
318 /* Update potential sum for this i atom from the interaction with this j atom. */
319 vvdw = _mm_and_ps(vvdw,cutoff_mask);
320 vvdw = _mm_andnot_ps(dummy_mask,vvdw);
321 vvdwsum = _mm_add_ps(vvdwsum,vvdw);
325 fscal = _mm_and_ps(fscal,cutoff_mask);
327 fscal = _mm_andnot_ps(dummy_mask,fscal);
329 /* Calculate temporary vectorial force */
330 tx = _mm_mul_ps(fscal,dx00);
331 ty = _mm_mul_ps(fscal,dy00);
332 tz = _mm_mul_ps(fscal,dz00);
334 /* Update vectorial force */
335 fix0 = _mm_add_ps(fix0,tx);
336 fiy0 = _mm_add_ps(fiy0,ty);
337 fiz0 = _mm_add_ps(fiz0,tz);
339 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
340 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
341 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
342 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
343 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,tx,ty,tz);
347 /* Inner loop uses 41 flops */
350 /* End of innermost loop */
352 gmx_mm_update_iforce_1atom_swizzle_ps(fix0,fiy0,fiz0,
353 f+i_coord_offset,fshift+i_shift_offset);
356 /* Update potential energies */
357 gmx_mm_update_1pot_ps(vvdwsum,kernel_data->energygrp_vdw+ggid);
359 /* Increment number of inner iterations */
360 inneriter += j_index_end - j_index_start;
362 /* Outer loop uses 7 flops */
365 /* Increment number of outer iterations */
368 /* Update outer/inner flops */
370 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_VF,outeriter*7 + inneriter*41);
373 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwLJSh_GeomP1P1_F_sse4_1_single
374 * Electrostatics interaction: None
375 * VdW interaction: LennardJones
376 * Geometry: Particle-Particle
377 * Calculate force/pot: Force
380 nb_kernel_ElecNone_VdwLJSh_GeomP1P1_F_sse4_1_single
381 (t_nblist * gmx_restrict nlist,
382 rvec * gmx_restrict xx,
383 rvec * gmx_restrict ff,
384 struct t_forcerec * gmx_restrict fr,
385 t_mdatoms * gmx_restrict mdatoms,
386 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
387 t_nrnb * gmx_restrict nrnb)
389 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
390 * just 0 for non-waters.
391 * Suffixes A,B,C,D refer to j loop unrolling done with SSE, e.g. for the four different
392 * jnr indices corresponding to data put in the four positions in the SIMD register.
394 int i_shift_offset,i_coord_offset,outeriter,inneriter;
395 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
396 int jnrA,jnrB,jnrC,jnrD;
397 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
398 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
399 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
401 real *shiftvec,*fshift,*x,*f;
402 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
404 __m128 tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
406 __m128 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
407 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
408 __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
409 __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
411 __m128 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
414 __m128 one_sixth = _mm_set1_ps(1.0/6.0);
415 __m128 one_twelfth = _mm_set1_ps(1.0/12.0);
416 __m128 dummy_mask,cutoff_mask;
417 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
418 __m128 one = _mm_set1_ps(1.0);
419 __m128 two = _mm_set1_ps(2.0);
425 jindex = nlist->jindex;
427 shiftidx = nlist->shift;
429 shiftvec = fr->shift_vec[0];
430 fshift = fr->fshift[0];
431 nvdwtype = fr->ntype;
433 vdwtype = mdatoms->typeA;
435 rcutoff_scalar = fr->ic->rvdw;
436 rcutoff = _mm_set1_ps(rcutoff_scalar);
437 rcutoff2 = _mm_mul_ps(rcutoff,rcutoff);
439 sh_vdw_invrcut6 = _mm_set1_ps(fr->ic->sh_invrc6);
440 rvdw = _mm_set1_ps(fr->ic->rvdw);
442 /* Avoid stupid compiler warnings */
443 jnrA = jnrB = jnrC = jnrD = 0;
452 for(iidx=0;iidx<4*DIM;iidx++)
457 /* Start outer loop over neighborlists */
458 for(iidx=0; iidx<nri; iidx++)
460 /* Load shift vector for this list */
461 i_shift_offset = DIM*shiftidx[iidx];
463 /* Load limits for loop over neighbors */
464 j_index_start = jindex[iidx];
465 j_index_end = jindex[iidx+1];
467 /* Get outer coordinate index */
469 i_coord_offset = DIM*inr;
471 /* Load i particle coords and add shift vector */
472 gmx_mm_load_shift_and_1rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
474 fix0 = _mm_setzero_ps();
475 fiy0 = _mm_setzero_ps();
476 fiz0 = _mm_setzero_ps();
478 /* Load parameters for i particles */
479 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
481 /* Start inner kernel loop */
482 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
485 /* Get j neighbor index, and coordinate index */
490 j_coord_offsetA = DIM*jnrA;
491 j_coord_offsetB = DIM*jnrB;
492 j_coord_offsetC = DIM*jnrC;
493 j_coord_offsetD = DIM*jnrD;
495 /* load j atom coordinates */
496 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
497 x+j_coord_offsetC,x+j_coord_offsetD,
500 /* Calculate displacement vector */
501 dx00 = _mm_sub_ps(ix0,jx0);
502 dy00 = _mm_sub_ps(iy0,jy0);
503 dz00 = _mm_sub_ps(iz0,jz0);
505 /* Calculate squared distance and things based on it */
506 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
508 rinvsq00 = sse41_inv_f(rsq00);
510 /* Load parameters for j particles */
511 vdwjidx0A = 2*vdwtype[jnrA+0];
512 vdwjidx0B = 2*vdwtype[jnrB+0];
513 vdwjidx0C = 2*vdwtype[jnrC+0];
514 vdwjidx0D = 2*vdwtype[jnrD+0];
516 /**************************
517 * CALCULATE INTERACTIONS *
518 **************************/
520 if (gmx_mm_any_lt(rsq00,rcutoff2))
523 /* Compute parameters for interactions between i and j atoms */
524 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
525 vdwparam+vdwioffset0+vdwjidx0B,
526 vdwparam+vdwioffset0+vdwjidx0C,
527 vdwparam+vdwioffset0+vdwjidx0D,
530 /* LENNARD-JONES DISPERSION/REPULSION */
532 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
533 fvdw = _mm_mul_ps(_mm_sub_ps(_mm_mul_ps(c12_00,rinvsix),c6_00),_mm_mul_ps(rinvsix,rinvsq00));
535 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
539 fscal = _mm_and_ps(fscal,cutoff_mask);
541 /* Calculate temporary vectorial force */
542 tx = _mm_mul_ps(fscal,dx00);
543 ty = _mm_mul_ps(fscal,dy00);
544 tz = _mm_mul_ps(fscal,dz00);
546 /* Update vectorial force */
547 fix0 = _mm_add_ps(fix0,tx);
548 fiy0 = _mm_add_ps(fiy0,ty);
549 fiz0 = _mm_add_ps(fiz0,tz);
551 fjptrA = f+j_coord_offsetA;
552 fjptrB = f+j_coord_offsetB;
553 fjptrC = f+j_coord_offsetC;
554 fjptrD = f+j_coord_offsetD;
555 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,tx,ty,tz);
559 /* Inner loop uses 30 flops */
565 /* Get j neighbor index, and coordinate index */
566 jnrlistA = jjnr[jidx];
567 jnrlistB = jjnr[jidx+1];
568 jnrlistC = jjnr[jidx+2];
569 jnrlistD = jjnr[jidx+3];
570 /* Sign of each element will be negative for non-real atoms.
571 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
572 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
574 dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
575 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
576 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
577 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
578 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
579 j_coord_offsetA = DIM*jnrA;
580 j_coord_offsetB = DIM*jnrB;
581 j_coord_offsetC = DIM*jnrC;
582 j_coord_offsetD = DIM*jnrD;
584 /* load j atom coordinates */
585 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
586 x+j_coord_offsetC,x+j_coord_offsetD,
589 /* Calculate displacement vector */
590 dx00 = _mm_sub_ps(ix0,jx0);
591 dy00 = _mm_sub_ps(iy0,jy0);
592 dz00 = _mm_sub_ps(iz0,jz0);
594 /* Calculate squared distance and things based on it */
595 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
597 rinvsq00 = sse41_inv_f(rsq00);
599 /* Load parameters for j particles */
600 vdwjidx0A = 2*vdwtype[jnrA+0];
601 vdwjidx0B = 2*vdwtype[jnrB+0];
602 vdwjidx0C = 2*vdwtype[jnrC+0];
603 vdwjidx0D = 2*vdwtype[jnrD+0];
605 /**************************
606 * CALCULATE INTERACTIONS *
607 **************************/
609 if (gmx_mm_any_lt(rsq00,rcutoff2))
612 /* Compute parameters for interactions between i and j atoms */
613 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
614 vdwparam+vdwioffset0+vdwjidx0B,
615 vdwparam+vdwioffset0+vdwjidx0C,
616 vdwparam+vdwioffset0+vdwjidx0D,
619 /* LENNARD-JONES DISPERSION/REPULSION */
621 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
622 fvdw = _mm_mul_ps(_mm_sub_ps(_mm_mul_ps(c12_00,rinvsix),c6_00),_mm_mul_ps(rinvsix,rinvsq00));
624 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
628 fscal = _mm_and_ps(fscal,cutoff_mask);
630 fscal = _mm_andnot_ps(dummy_mask,fscal);
632 /* Calculate temporary vectorial force */
633 tx = _mm_mul_ps(fscal,dx00);
634 ty = _mm_mul_ps(fscal,dy00);
635 tz = _mm_mul_ps(fscal,dz00);
637 /* Update vectorial force */
638 fix0 = _mm_add_ps(fix0,tx);
639 fiy0 = _mm_add_ps(fiy0,ty);
640 fiz0 = _mm_add_ps(fiz0,tz);
642 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
643 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
644 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
645 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
646 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,tx,ty,tz);
650 /* Inner loop uses 30 flops */
653 /* End of innermost loop */
655 gmx_mm_update_iforce_1atom_swizzle_ps(fix0,fiy0,fiz0,
656 f+i_coord_offset,fshift+i_shift_offset);
658 /* Increment number of inner iterations */
659 inneriter += j_index_end - j_index_start;
661 /* Outer loop uses 6 flops */
664 /* Increment number of outer iterations */
667 /* Update outer/inner flops */
669 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_F,outeriter*6 + inneriter*30);