2 * Note: this file was generated by the Gromacs sse2_double 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_sse2_double.h"
34 #include "kernelutil_x86_sse2_double.h"
37 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwLJ_GeomP1P1_VF_sse2_double
38 * Electrostatics interaction: None
39 * VdW interaction: LennardJones
40 * Geometry: Particle-Particle
41 * Calculate force/pot: PotentialAndForce
44 nb_kernel_ElecNone_VdwLJ_GeomP1P1_VF_sse2_double
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 refer to j loop unrolling done with SSE double precision, e.g. for the two 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;
61 int j_coord_offsetA,j_coord_offsetB;
62 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
64 real *shiftvec,*fshift,*x,*f;
65 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
67 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
68 int vdwjidx0A,vdwjidx0B;
69 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
70 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
72 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
75 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
76 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
77 __m128d dummy_mask,cutoff_mask;
78 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
79 __m128d one = _mm_set1_pd(1.0);
80 __m128d two = _mm_set1_pd(2.0);
86 jindex = nlist->jindex;
88 shiftidx = nlist->shift;
90 shiftvec = fr->shift_vec[0];
91 fshift = fr->fshift[0];
94 vdwtype = mdatoms->typeA;
96 /* Avoid stupid compiler warnings */
104 /* Start outer loop over neighborlists */
105 for(iidx=0; iidx<nri; iidx++)
107 /* Load shift vector for this list */
108 i_shift_offset = DIM*shiftidx[iidx];
110 /* Load limits for loop over neighbors */
111 j_index_start = jindex[iidx];
112 j_index_end = jindex[iidx+1];
114 /* Get outer coordinate index */
116 i_coord_offset = DIM*inr;
118 /* Load i particle coords and add shift vector */
119 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
121 fix0 = _mm_setzero_pd();
122 fiy0 = _mm_setzero_pd();
123 fiz0 = _mm_setzero_pd();
125 /* Load parameters for i particles */
126 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
128 /* Reset potential sums */
129 vvdwsum = _mm_setzero_pd();
131 /* Start inner kernel loop */
132 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
135 /* Get j neighbor index, and coordinate index */
138 j_coord_offsetA = DIM*jnrA;
139 j_coord_offsetB = DIM*jnrB;
141 /* load j atom coordinates */
142 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
145 /* Calculate displacement vector */
146 dx00 = _mm_sub_pd(ix0,jx0);
147 dy00 = _mm_sub_pd(iy0,jy0);
148 dz00 = _mm_sub_pd(iz0,jz0);
150 /* Calculate squared distance and things based on it */
151 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
153 rinvsq00 = gmx_mm_inv_pd(rsq00);
155 /* Load parameters for j particles */
156 vdwjidx0A = 2*vdwtype[jnrA+0];
157 vdwjidx0B = 2*vdwtype[jnrB+0];
159 /**************************
160 * CALCULATE INTERACTIONS *
161 **************************/
163 /* Compute parameters for interactions between i and j atoms */
164 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
165 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
167 /* LENNARD-JONES DISPERSION/REPULSION */
169 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
170 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
171 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
172 vvdw = _mm_sub_pd( _mm_mul_pd(vvdw12,one_twelfth) , _mm_mul_pd(vvdw6,one_sixth) );
173 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
175 /* Update potential sum for this i atom from the interaction with this j atom. */
176 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
180 /* Calculate temporary vectorial force */
181 tx = _mm_mul_pd(fscal,dx00);
182 ty = _mm_mul_pd(fscal,dy00);
183 tz = _mm_mul_pd(fscal,dz00);
185 /* Update vectorial force */
186 fix0 = _mm_add_pd(fix0,tx);
187 fiy0 = _mm_add_pd(fiy0,ty);
188 fiz0 = _mm_add_pd(fiz0,tz);
190 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,tx,ty,tz);
192 /* Inner loop uses 32 flops */
199 j_coord_offsetA = DIM*jnrA;
201 /* load j atom coordinates */
202 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
205 /* Calculate displacement vector */
206 dx00 = _mm_sub_pd(ix0,jx0);
207 dy00 = _mm_sub_pd(iy0,jy0);
208 dz00 = _mm_sub_pd(iz0,jz0);
210 /* Calculate squared distance and things based on it */
211 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
213 rinvsq00 = gmx_mm_inv_pd(rsq00);
215 /* Load parameters for j particles */
216 vdwjidx0A = 2*vdwtype[jnrA+0];
218 /**************************
219 * CALCULATE INTERACTIONS *
220 **************************/
222 /* Compute parameters for interactions between i and j atoms */
223 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
225 /* LENNARD-JONES DISPERSION/REPULSION */
227 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
228 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
229 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
230 vvdw = _mm_sub_pd( _mm_mul_pd(vvdw12,one_twelfth) , _mm_mul_pd(vvdw6,one_sixth) );
231 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
233 /* Update potential sum for this i atom from the interaction with this j atom. */
234 vvdw = _mm_unpacklo_pd(vvdw,_mm_setzero_pd());
235 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
239 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
241 /* Calculate temporary vectorial force */
242 tx = _mm_mul_pd(fscal,dx00);
243 ty = _mm_mul_pd(fscal,dy00);
244 tz = _mm_mul_pd(fscal,dz00);
246 /* Update vectorial force */
247 fix0 = _mm_add_pd(fix0,tx);
248 fiy0 = _mm_add_pd(fiy0,ty);
249 fiz0 = _mm_add_pd(fiz0,tz);
251 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,tx,ty,tz);
253 /* Inner loop uses 32 flops */
256 /* End of innermost loop */
258 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
259 f+i_coord_offset,fshift+i_shift_offset);
262 /* Update potential energies */
263 gmx_mm_update_1pot_pd(vvdwsum,kernel_data->energygrp_vdw+ggid);
265 /* Increment number of inner iterations */
266 inneriter += j_index_end - j_index_start;
268 /* Outer loop uses 7 flops */
271 /* Increment number of outer iterations */
274 /* Update outer/inner flops */
276 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_VF,outeriter*7 + inneriter*32);
279 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwLJ_GeomP1P1_F_sse2_double
280 * Electrostatics interaction: None
281 * VdW interaction: LennardJones
282 * Geometry: Particle-Particle
283 * Calculate force/pot: Force
286 nb_kernel_ElecNone_VdwLJ_GeomP1P1_F_sse2_double
287 (t_nblist * gmx_restrict nlist,
288 rvec * gmx_restrict xx,
289 rvec * gmx_restrict ff,
290 t_forcerec * gmx_restrict fr,
291 t_mdatoms * gmx_restrict mdatoms,
292 nb_kernel_data_t * gmx_restrict kernel_data,
293 t_nrnb * gmx_restrict nrnb)
295 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
296 * just 0 for non-waters.
297 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
298 * jnr indices corresponding to data put in the four positions in the SIMD register.
300 int i_shift_offset,i_coord_offset,outeriter,inneriter;
301 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
303 int j_coord_offsetA,j_coord_offsetB;
304 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
306 real *shiftvec,*fshift,*x,*f;
307 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
309 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
310 int vdwjidx0A,vdwjidx0B;
311 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
312 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
314 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
317 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
318 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
319 __m128d dummy_mask,cutoff_mask;
320 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
321 __m128d one = _mm_set1_pd(1.0);
322 __m128d two = _mm_set1_pd(2.0);
328 jindex = nlist->jindex;
330 shiftidx = nlist->shift;
332 shiftvec = fr->shift_vec[0];
333 fshift = fr->fshift[0];
334 nvdwtype = fr->ntype;
336 vdwtype = mdatoms->typeA;
338 /* Avoid stupid compiler warnings */
346 /* Start outer loop over neighborlists */
347 for(iidx=0; iidx<nri; iidx++)
349 /* Load shift vector for this list */
350 i_shift_offset = DIM*shiftidx[iidx];
352 /* Load limits for loop over neighbors */
353 j_index_start = jindex[iidx];
354 j_index_end = jindex[iidx+1];
356 /* Get outer coordinate index */
358 i_coord_offset = DIM*inr;
360 /* Load i particle coords and add shift vector */
361 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
363 fix0 = _mm_setzero_pd();
364 fiy0 = _mm_setzero_pd();
365 fiz0 = _mm_setzero_pd();
367 /* Load parameters for i particles */
368 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
370 /* Start inner kernel loop */
371 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
374 /* Get j neighbor index, and coordinate index */
377 j_coord_offsetA = DIM*jnrA;
378 j_coord_offsetB = DIM*jnrB;
380 /* load j atom coordinates */
381 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
384 /* Calculate displacement vector */
385 dx00 = _mm_sub_pd(ix0,jx0);
386 dy00 = _mm_sub_pd(iy0,jy0);
387 dz00 = _mm_sub_pd(iz0,jz0);
389 /* Calculate squared distance and things based on it */
390 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
392 rinvsq00 = gmx_mm_inv_pd(rsq00);
394 /* Load parameters for j particles */
395 vdwjidx0A = 2*vdwtype[jnrA+0];
396 vdwjidx0B = 2*vdwtype[jnrB+0];
398 /**************************
399 * CALCULATE INTERACTIONS *
400 **************************/
402 /* Compute parameters for interactions between i and j atoms */
403 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
404 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
406 /* LENNARD-JONES DISPERSION/REPULSION */
408 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
409 fvdw = _mm_mul_pd(_mm_sub_pd(_mm_mul_pd(c12_00,rinvsix),c6_00),_mm_mul_pd(rinvsix,rinvsq00));
413 /* Calculate temporary vectorial force */
414 tx = _mm_mul_pd(fscal,dx00);
415 ty = _mm_mul_pd(fscal,dy00);
416 tz = _mm_mul_pd(fscal,dz00);
418 /* Update vectorial force */
419 fix0 = _mm_add_pd(fix0,tx);
420 fiy0 = _mm_add_pd(fiy0,ty);
421 fiz0 = _mm_add_pd(fiz0,tz);
423 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,tx,ty,tz);
425 /* Inner loop uses 27 flops */
432 j_coord_offsetA = DIM*jnrA;
434 /* load j atom coordinates */
435 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
438 /* Calculate displacement vector */
439 dx00 = _mm_sub_pd(ix0,jx0);
440 dy00 = _mm_sub_pd(iy0,jy0);
441 dz00 = _mm_sub_pd(iz0,jz0);
443 /* Calculate squared distance and things based on it */
444 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
446 rinvsq00 = gmx_mm_inv_pd(rsq00);
448 /* Load parameters for j particles */
449 vdwjidx0A = 2*vdwtype[jnrA+0];
451 /**************************
452 * CALCULATE INTERACTIONS *
453 **************************/
455 /* Compute parameters for interactions between i and j atoms */
456 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
458 /* LENNARD-JONES DISPERSION/REPULSION */
460 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
461 fvdw = _mm_mul_pd(_mm_sub_pd(_mm_mul_pd(c12_00,rinvsix),c6_00),_mm_mul_pd(rinvsix,rinvsq00));
465 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
467 /* Calculate temporary vectorial force */
468 tx = _mm_mul_pd(fscal,dx00);
469 ty = _mm_mul_pd(fscal,dy00);
470 tz = _mm_mul_pd(fscal,dz00);
472 /* Update vectorial force */
473 fix0 = _mm_add_pd(fix0,tx);
474 fiy0 = _mm_add_pd(fiy0,ty);
475 fiz0 = _mm_add_pd(fiz0,tz);
477 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,tx,ty,tz);
479 /* Inner loop uses 27 flops */
482 /* End of innermost loop */
484 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
485 f+i_coord_offset,fshift+i_shift_offset);
487 /* Increment number of inner iterations */
488 inneriter += j_index_end - j_index_start;
490 /* Outer loop uses 6 flops */
493 /* Increment number of outer iterations */
496 /* Update outer/inner flops */
498 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_F,outeriter*6 + inneriter*27);