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 sse4_1_single kernel generator.
42 #include "../nb_kernel.h"
43 #include "types/simple.h"
44 #include "gromacs/math/vec.h"
47 #include "gromacs/simd/math_x86_sse4_1_single.h"
48 #include "kernelutil_x86_sse4_1_single.h"
51 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwLJSh_GeomP1P1_VF_sse4_1_single
52 * Electrostatics interaction: None
53 * VdW interaction: LennardJones
54 * Geometry: Particle-Particle
55 * Calculate force/pot: PotentialAndForce
58 nb_kernel_ElecNone_VdwLJSh_GeomP1P1_VF_sse4_1_single
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 SSE, 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 j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
77 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
79 real *shiftvec,*fshift,*x,*f;
80 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
82 __m128 tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
84 __m128 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
85 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
86 __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
87 __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
89 __m128 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
92 __m128 one_sixth = _mm_set1_ps(1.0/6.0);
93 __m128 one_twelfth = _mm_set1_ps(1.0/12.0);
94 __m128 dummy_mask,cutoff_mask;
95 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
96 __m128 one = _mm_set1_ps(1.0);
97 __m128 two = _mm_set1_ps(2.0);
103 jindex = nlist->jindex;
105 shiftidx = nlist->shift;
107 shiftvec = fr->shift_vec[0];
108 fshift = fr->fshift[0];
109 nvdwtype = fr->ntype;
111 vdwtype = mdatoms->typeA;
113 rcutoff_scalar = fr->rvdw;
114 rcutoff = _mm_set1_ps(rcutoff_scalar);
115 rcutoff2 = _mm_mul_ps(rcutoff,rcutoff);
117 sh_vdw_invrcut6 = _mm_set1_ps(fr->ic->sh_invrc6);
118 rvdw = _mm_set1_ps(fr->rvdw);
120 /* Avoid stupid compiler warnings */
121 jnrA = jnrB = jnrC = jnrD = 0;
130 for(iidx=0;iidx<4*DIM;iidx++)
135 /* Start outer loop over neighborlists */
136 for(iidx=0; iidx<nri; iidx++)
138 /* Load shift vector for this list */
139 i_shift_offset = DIM*shiftidx[iidx];
141 /* Load limits for loop over neighbors */
142 j_index_start = jindex[iidx];
143 j_index_end = jindex[iidx+1];
145 /* Get outer coordinate index */
147 i_coord_offset = DIM*inr;
149 /* Load i particle coords and add shift vector */
150 gmx_mm_load_shift_and_1rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
152 fix0 = _mm_setzero_ps();
153 fiy0 = _mm_setzero_ps();
154 fiz0 = _mm_setzero_ps();
156 /* Load parameters for i particles */
157 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
159 /* Reset potential sums */
160 vvdwsum = _mm_setzero_ps();
162 /* Start inner kernel loop */
163 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
166 /* Get j neighbor index, and coordinate index */
171 j_coord_offsetA = DIM*jnrA;
172 j_coord_offsetB = DIM*jnrB;
173 j_coord_offsetC = DIM*jnrC;
174 j_coord_offsetD = DIM*jnrD;
176 /* load j atom coordinates */
177 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
178 x+j_coord_offsetC,x+j_coord_offsetD,
181 /* Calculate displacement vector */
182 dx00 = _mm_sub_ps(ix0,jx0);
183 dy00 = _mm_sub_ps(iy0,jy0);
184 dz00 = _mm_sub_ps(iz0,jz0);
186 /* Calculate squared distance and things based on it */
187 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
189 rinvsq00 = gmx_mm_inv_ps(rsq00);
191 /* Load parameters for j particles */
192 vdwjidx0A = 2*vdwtype[jnrA+0];
193 vdwjidx0B = 2*vdwtype[jnrB+0];
194 vdwjidx0C = 2*vdwtype[jnrC+0];
195 vdwjidx0D = 2*vdwtype[jnrD+0];
197 /**************************
198 * CALCULATE INTERACTIONS *
199 **************************/
201 if (gmx_mm_any_lt(rsq00,rcutoff2))
204 /* Compute parameters for interactions between i and j atoms */
205 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
206 vdwparam+vdwioffset0+vdwjidx0B,
207 vdwparam+vdwioffset0+vdwjidx0C,
208 vdwparam+vdwioffset0+vdwjidx0D,
211 /* LENNARD-JONES DISPERSION/REPULSION */
213 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
214 vvdw6 = _mm_mul_ps(c6_00,rinvsix);
215 vvdw12 = _mm_mul_ps(c12_00,_mm_mul_ps(rinvsix,rinvsix));
216 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) ,
217 _mm_mul_ps( _mm_sub_ps(vvdw6,_mm_mul_ps(c6_00,sh_vdw_invrcut6)),one_sixth));
218 fvdw = _mm_mul_ps(_mm_sub_ps(vvdw12,vvdw6),rinvsq00);
220 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
222 /* Update potential sum for this i atom from the interaction with this j atom. */
223 vvdw = _mm_and_ps(vvdw,cutoff_mask);
224 vvdwsum = _mm_add_ps(vvdwsum,vvdw);
228 fscal = _mm_and_ps(fscal,cutoff_mask);
230 /* Calculate temporary vectorial force */
231 tx = _mm_mul_ps(fscal,dx00);
232 ty = _mm_mul_ps(fscal,dy00);
233 tz = _mm_mul_ps(fscal,dz00);
235 /* Update vectorial force */
236 fix0 = _mm_add_ps(fix0,tx);
237 fiy0 = _mm_add_ps(fiy0,ty);
238 fiz0 = _mm_add_ps(fiz0,tz);
240 fjptrA = f+j_coord_offsetA;
241 fjptrB = f+j_coord_offsetB;
242 fjptrC = f+j_coord_offsetC;
243 fjptrD = f+j_coord_offsetD;
244 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,tx,ty,tz);
248 /* Inner loop uses 41 flops */
254 /* Get j neighbor index, and coordinate index */
255 jnrlistA = jjnr[jidx];
256 jnrlistB = jjnr[jidx+1];
257 jnrlistC = jjnr[jidx+2];
258 jnrlistD = jjnr[jidx+3];
259 /* Sign of each element will be negative for non-real atoms.
260 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
261 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
263 dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
264 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
265 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
266 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
267 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
268 j_coord_offsetA = DIM*jnrA;
269 j_coord_offsetB = DIM*jnrB;
270 j_coord_offsetC = DIM*jnrC;
271 j_coord_offsetD = DIM*jnrD;
273 /* load j atom coordinates */
274 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
275 x+j_coord_offsetC,x+j_coord_offsetD,
278 /* Calculate displacement vector */
279 dx00 = _mm_sub_ps(ix0,jx0);
280 dy00 = _mm_sub_ps(iy0,jy0);
281 dz00 = _mm_sub_ps(iz0,jz0);
283 /* Calculate squared distance and things based on it */
284 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
286 rinvsq00 = gmx_mm_inv_ps(rsq00);
288 /* Load parameters for j particles */
289 vdwjidx0A = 2*vdwtype[jnrA+0];
290 vdwjidx0B = 2*vdwtype[jnrB+0];
291 vdwjidx0C = 2*vdwtype[jnrC+0];
292 vdwjidx0D = 2*vdwtype[jnrD+0];
294 /**************************
295 * CALCULATE INTERACTIONS *
296 **************************/
298 if (gmx_mm_any_lt(rsq00,rcutoff2))
301 /* Compute parameters for interactions between i and j atoms */
302 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
303 vdwparam+vdwioffset0+vdwjidx0B,
304 vdwparam+vdwioffset0+vdwjidx0C,
305 vdwparam+vdwioffset0+vdwjidx0D,
308 /* LENNARD-JONES DISPERSION/REPULSION */
310 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
311 vvdw6 = _mm_mul_ps(c6_00,rinvsix);
312 vvdw12 = _mm_mul_ps(c12_00,_mm_mul_ps(rinvsix,rinvsix));
313 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) ,
314 _mm_mul_ps( _mm_sub_ps(vvdw6,_mm_mul_ps(c6_00,sh_vdw_invrcut6)),one_sixth));
315 fvdw = _mm_mul_ps(_mm_sub_ps(vvdw12,vvdw6),rinvsq00);
317 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
319 /* Update potential sum for this i atom from the interaction with this j atom. */
320 vvdw = _mm_and_ps(vvdw,cutoff_mask);
321 vvdw = _mm_andnot_ps(dummy_mask,vvdw);
322 vvdwsum = _mm_add_ps(vvdwsum,vvdw);
326 fscal = _mm_and_ps(fscal,cutoff_mask);
328 fscal = _mm_andnot_ps(dummy_mask,fscal);
330 /* Calculate temporary vectorial force */
331 tx = _mm_mul_ps(fscal,dx00);
332 ty = _mm_mul_ps(fscal,dy00);
333 tz = _mm_mul_ps(fscal,dz00);
335 /* Update vectorial force */
336 fix0 = _mm_add_ps(fix0,tx);
337 fiy0 = _mm_add_ps(fiy0,ty);
338 fiz0 = _mm_add_ps(fiz0,tz);
340 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
341 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
342 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
343 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
344 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,tx,ty,tz);
348 /* Inner loop uses 41 flops */
351 /* End of innermost loop */
353 gmx_mm_update_iforce_1atom_swizzle_ps(fix0,fiy0,fiz0,
354 f+i_coord_offset,fshift+i_shift_offset);
357 /* Update potential energies */
358 gmx_mm_update_1pot_ps(vvdwsum,kernel_data->energygrp_vdw+ggid);
360 /* Increment number of inner iterations */
361 inneriter += j_index_end - j_index_start;
363 /* Outer loop uses 7 flops */
366 /* Increment number of outer iterations */
369 /* Update outer/inner flops */
371 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_VF,outeriter*7 + inneriter*41);
374 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwLJSh_GeomP1P1_F_sse4_1_single
375 * Electrostatics interaction: None
376 * VdW interaction: LennardJones
377 * Geometry: Particle-Particle
378 * Calculate force/pot: Force
381 nb_kernel_ElecNone_VdwLJSh_GeomP1P1_F_sse4_1_single
382 (t_nblist * gmx_restrict nlist,
383 rvec * gmx_restrict xx,
384 rvec * gmx_restrict ff,
385 t_forcerec * gmx_restrict fr,
386 t_mdatoms * gmx_restrict mdatoms,
387 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
388 t_nrnb * gmx_restrict nrnb)
390 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
391 * just 0 for non-waters.
392 * Suffixes A,B,C,D refer to j loop unrolling done with SSE, e.g. for the four different
393 * jnr indices corresponding to data put in the four positions in the SIMD register.
395 int i_shift_offset,i_coord_offset,outeriter,inneriter;
396 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
397 int jnrA,jnrB,jnrC,jnrD;
398 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
399 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
400 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
402 real *shiftvec,*fshift,*x,*f;
403 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
405 __m128 tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
407 __m128 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
408 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
409 __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
410 __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
412 __m128 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
415 __m128 one_sixth = _mm_set1_ps(1.0/6.0);
416 __m128 one_twelfth = _mm_set1_ps(1.0/12.0);
417 __m128 dummy_mask,cutoff_mask;
418 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
419 __m128 one = _mm_set1_ps(1.0);
420 __m128 two = _mm_set1_ps(2.0);
426 jindex = nlist->jindex;
428 shiftidx = nlist->shift;
430 shiftvec = fr->shift_vec[0];
431 fshift = fr->fshift[0];
432 nvdwtype = fr->ntype;
434 vdwtype = mdatoms->typeA;
436 rcutoff_scalar = fr->rvdw;
437 rcutoff = _mm_set1_ps(rcutoff_scalar);
438 rcutoff2 = _mm_mul_ps(rcutoff,rcutoff);
440 sh_vdw_invrcut6 = _mm_set1_ps(fr->ic->sh_invrc6);
441 rvdw = _mm_set1_ps(fr->rvdw);
443 /* Avoid stupid compiler warnings */
444 jnrA = jnrB = jnrC = jnrD = 0;
453 for(iidx=0;iidx<4*DIM;iidx++)
458 /* Start outer loop over neighborlists */
459 for(iidx=0; iidx<nri; iidx++)
461 /* Load shift vector for this list */
462 i_shift_offset = DIM*shiftidx[iidx];
464 /* Load limits for loop over neighbors */
465 j_index_start = jindex[iidx];
466 j_index_end = jindex[iidx+1];
468 /* Get outer coordinate index */
470 i_coord_offset = DIM*inr;
472 /* Load i particle coords and add shift vector */
473 gmx_mm_load_shift_and_1rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
475 fix0 = _mm_setzero_ps();
476 fiy0 = _mm_setzero_ps();
477 fiz0 = _mm_setzero_ps();
479 /* Load parameters for i particles */
480 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
482 /* Start inner kernel loop */
483 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
486 /* Get j neighbor index, and coordinate index */
491 j_coord_offsetA = DIM*jnrA;
492 j_coord_offsetB = DIM*jnrB;
493 j_coord_offsetC = DIM*jnrC;
494 j_coord_offsetD = DIM*jnrD;
496 /* load j atom coordinates */
497 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
498 x+j_coord_offsetC,x+j_coord_offsetD,
501 /* Calculate displacement vector */
502 dx00 = _mm_sub_ps(ix0,jx0);
503 dy00 = _mm_sub_ps(iy0,jy0);
504 dz00 = _mm_sub_ps(iz0,jz0);
506 /* Calculate squared distance and things based on it */
507 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
509 rinvsq00 = gmx_mm_inv_ps(rsq00);
511 /* Load parameters for j particles */
512 vdwjidx0A = 2*vdwtype[jnrA+0];
513 vdwjidx0B = 2*vdwtype[jnrB+0];
514 vdwjidx0C = 2*vdwtype[jnrC+0];
515 vdwjidx0D = 2*vdwtype[jnrD+0];
517 /**************************
518 * CALCULATE INTERACTIONS *
519 **************************/
521 if (gmx_mm_any_lt(rsq00,rcutoff2))
524 /* Compute parameters for interactions between i and j atoms */
525 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
526 vdwparam+vdwioffset0+vdwjidx0B,
527 vdwparam+vdwioffset0+vdwjidx0C,
528 vdwparam+vdwioffset0+vdwjidx0D,
531 /* LENNARD-JONES DISPERSION/REPULSION */
533 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
534 fvdw = _mm_mul_ps(_mm_sub_ps(_mm_mul_ps(c12_00,rinvsix),c6_00),_mm_mul_ps(rinvsix,rinvsq00));
536 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
540 fscal = _mm_and_ps(fscal,cutoff_mask);
542 /* Calculate temporary vectorial force */
543 tx = _mm_mul_ps(fscal,dx00);
544 ty = _mm_mul_ps(fscal,dy00);
545 tz = _mm_mul_ps(fscal,dz00);
547 /* Update vectorial force */
548 fix0 = _mm_add_ps(fix0,tx);
549 fiy0 = _mm_add_ps(fiy0,ty);
550 fiz0 = _mm_add_ps(fiz0,tz);
552 fjptrA = f+j_coord_offsetA;
553 fjptrB = f+j_coord_offsetB;
554 fjptrC = f+j_coord_offsetC;
555 fjptrD = f+j_coord_offsetD;
556 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,tx,ty,tz);
560 /* Inner loop uses 30 flops */
566 /* Get j neighbor index, and coordinate index */
567 jnrlistA = jjnr[jidx];
568 jnrlistB = jjnr[jidx+1];
569 jnrlistC = jjnr[jidx+2];
570 jnrlistD = jjnr[jidx+3];
571 /* Sign of each element will be negative for non-real atoms.
572 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
573 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
575 dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
576 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
577 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
578 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
579 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
580 j_coord_offsetA = DIM*jnrA;
581 j_coord_offsetB = DIM*jnrB;
582 j_coord_offsetC = DIM*jnrC;
583 j_coord_offsetD = DIM*jnrD;
585 /* load j atom coordinates */
586 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
587 x+j_coord_offsetC,x+j_coord_offsetD,
590 /* Calculate displacement vector */
591 dx00 = _mm_sub_ps(ix0,jx0);
592 dy00 = _mm_sub_ps(iy0,jy0);
593 dz00 = _mm_sub_ps(iz0,jz0);
595 /* Calculate squared distance and things based on it */
596 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
598 rinvsq00 = gmx_mm_inv_ps(rsq00);
600 /* Load parameters for j particles */
601 vdwjidx0A = 2*vdwtype[jnrA+0];
602 vdwjidx0B = 2*vdwtype[jnrB+0];
603 vdwjidx0C = 2*vdwtype[jnrC+0];
604 vdwjidx0D = 2*vdwtype[jnrD+0];
606 /**************************
607 * CALCULATE INTERACTIONS *
608 **************************/
610 if (gmx_mm_any_lt(rsq00,rcutoff2))
613 /* Compute parameters for interactions between i and j atoms */
614 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
615 vdwparam+vdwioffset0+vdwjidx0B,
616 vdwparam+vdwioffset0+vdwjidx0C,
617 vdwparam+vdwioffset0+vdwjidx0D,
620 /* LENNARD-JONES DISPERSION/REPULSION */
622 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
623 fvdw = _mm_mul_ps(_mm_sub_ps(_mm_mul_ps(c12_00,rinvsix),c6_00),_mm_mul_ps(rinvsix,rinvsq00));
625 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
629 fscal = _mm_and_ps(fscal,cutoff_mask);
631 fscal = _mm_andnot_ps(dummy_mask,fscal);
633 /* Calculate temporary vectorial force */
634 tx = _mm_mul_ps(fscal,dx00);
635 ty = _mm_mul_ps(fscal,dy00);
636 tz = _mm_mul_ps(fscal,dz00);
638 /* Update vectorial force */
639 fix0 = _mm_add_ps(fix0,tx);
640 fiy0 = _mm_add_ps(fiy0,ty);
641 fiz0 = _mm_add_ps(fiz0,tz);
643 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
644 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
645 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
646 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
647 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,tx,ty,tz);
651 /* Inner loop uses 30 flops */
654 /* End of innermost loop */
656 gmx_mm_update_iforce_1atom_swizzle_ps(fix0,fiy0,fiz0,
657 f+i_coord_offset,fshift+i_shift_offset);
659 /* Increment number of inner iterations */
660 inneriter += j_index_end - j_index_start;
662 /* Outer loop uses 6 flops */
665 /* Increment number of outer iterations */
668 /* Update outer/inner flops */
670 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_F,outeriter*6 + inneriter*30);