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_VdwLJ_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_VdwLJ_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 /* Avoid stupid compiler warnings */
113 jnrA
= jnrB
= jnrC
= jnrD
= 0;
122 for(iidx
=0;iidx
<4*DIM
;iidx
++)
127 /* Start outer loop over neighborlists */
128 for(iidx
=0; iidx
<nri
; iidx
++)
130 /* Load shift vector for this list */
131 i_shift_offset
= DIM
*shiftidx
[iidx
];
133 /* Load limits for loop over neighbors */
134 j_index_start
= jindex
[iidx
];
135 j_index_end
= jindex
[iidx
+1];
137 /* Get outer coordinate index */
139 i_coord_offset
= DIM
*inr
;
141 /* Load i particle coords and add shift vector */
142 gmx_mm_load_shift_and_1rvec_broadcast_ps(shiftvec
+i_shift_offset
,x
+i_coord_offset
,&ix0
,&iy0
,&iz0
);
144 fix0
= _mm_setzero_ps();
145 fiy0
= _mm_setzero_ps();
146 fiz0
= _mm_setzero_ps();
148 /* Load parameters for i particles */
149 vdwioffset0
= 2*nvdwtype
*vdwtype
[inr
+0];
151 /* Reset potential sums */
152 vvdwsum
= _mm_setzero_ps();
154 /* Start inner kernel loop */
155 for(jidx
=j_index_start
; jidx
<j_index_end
&& jjnr
[jidx
+3]>=0; jidx
+=4)
158 /* Get j neighbor index, and coordinate index */
163 j_coord_offsetA
= DIM
*jnrA
;
164 j_coord_offsetB
= DIM
*jnrB
;
165 j_coord_offsetC
= DIM
*jnrC
;
166 j_coord_offsetD
= DIM
*jnrD
;
168 /* load j atom coordinates */
169 gmx_mm_load_1rvec_4ptr_swizzle_ps(x
+j_coord_offsetA
,x
+j_coord_offsetB
,
170 x
+j_coord_offsetC
,x
+j_coord_offsetD
,
173 /* Calculate displacement vector */
174 dx00
= _mm_sub_ps(ix0
,jx0
);
175 dy00
= _mm_sub_ps(iy0
,jy0
);
176 dz00
= _mm_sub_ps(iz0
,jz0
);
178 /* Calculate squared distance and things based on it */
179 rsq00
= gmx_mm_calc_rsq_ps(dx00
,dy00
,dz00
);
181 rinvsq00
= sse41_inv_f(rsq00
);
183 /* Load parameters for j particles */
184 vdwjidx0A
= 2*vdwtype
[jnrA
+0];
185 vdwjidx0B
= 2*vdwtype
[jnrB
+0];
186 vdwjidx0C
= 2*vdwtype
[jnrC
+0];
187 vdwjidx0D
= 2*vdwtype
[jnrD
+0];
189 /**************************
190 * CALCULATE INTERACTIONS *
191 **************************/
193 /* Compute parameters for interactions between i and j atoms */
194 gmx_mm_load_4pair_swizzle_ps(vdwparam
+vdwioffset0
+vdwjidx0A
,
195 vdwparam
+vdwioffset0
+vdwjidx0B
,
196 vdwparam
+vdwioffset0
+vdwjidx0C
,
197 vdwparam
+vdwioffset0
+vdwjidx0D
,
200 /* LENNARD-JONES DISPERSION/REPULSION */
202 rinvsix
= _mm_mul_ps(_mm_mul_ps(rinvsq00
,rinvsq00
),rinvsq00
);
203 vvdw6
= _mm_mul_ps(c6_00
,rinvsix
);
204 vvdw12
= _mm_mul_ps(c12_00
,_mm_mul_ps(rinvsix
,rinvsix
));
205 vvdw
= _mm_sub_ps( _mm_mul_ps(vvdw12
,one_twelfth
) , _mm_mul_ps(vvdw6
,one_sixth
) );
206 fvdw
= _mm_mul_ps(_mm_sub_ps(vvdw12
,vvdw6
),rinvsq00
);
208 /* Update potential sum for this i atom from the interaction with this j atom. */
209 vvdwsum
= _mm_add_ps(vvdwsum
,vvdw
);
213 /* Calculate temporary vectorial force */
214 tx
= _mm_mul_ps(fscal
,dx00
);
215 ty
= _mm_mul_ps(fscal
,dy00
);
216 tz
= _mm_mul_ps(fscal
,dz00
);
218 /* Update vectorial force */
219 fix0
= _mm_add_ps(fix0
,tx
);
220 fiy0
= _mm_add_ps(fiy0
,ty
);
221 fiz0
= _mm_add_ps(fiz0
,tz
);
223 fjptrA
= f
+j_coord_offsetA
;
224 fjptrB
= f
+j_coord_offsetB
;
225 fjptrC
= f
+j_coord_offsetC
;
226 fjptrD
= f
+j_coord_offsetD
;
227 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA
,fjptrB
,fjptrC
,fjptrD
,tx
,ty
,tz
);
229 /* Inner loop uses 32 flops */
235 /* Get j neighbor index, and coordinate index */
236 jnrlistA
= jjnr
[jidx
];
237 jnrlistB
= jjnr
[jidx
+1];
238 jnrlistC
= jjnr
[jidx
+2];
239 jnrlistD
= jjnr
[jidx
+3];
240 /* Sign of each element will be negative for non-real atoms.
241 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
242 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
244 dummy_mask
= gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i
*)(jjnr
+jidx
)),_mm_setzero_si128()));
245 jnrA
= (jnrlistA
>=0) ? jnrlistA
: 0;
246 jnrB
= (jnrlistB
>=0) ? jnrlistB
: 0;
247 jnrC
= (jnrlistC
>=0) ? jnrlistC
: 0;
248 jnrD
= (jnrlistD
>=0) ? jnrlistD
: 0;
249 j_coord_offsetA
= DIM
*jnrA
;
250 j_coord_offsetB
= DIM
*jnrB
;
251 j_coord_offsetC
= DIM
*jnrC
;
252 j_coord_offsetD
= DIM
*jnrD
;
254 /* load j atom coordinates */
255 gmx_mm_load_1rvec_4ptr_swizzle_ps(x
+j_coord_offsetA
,x
+j_coord_offsetB
,
256 x
+j_coord_offsetC
,x
+j_coord_offsetD
,
259 /* Calculate displacement vector */
260 dx00
= _mm_sub_ps(ix0
,jx0
);
261 dy00
= _mm_sub_ps(iy0
,jy0
);
262 dz00
= _mm_sub_ps(iz0
,jz0
);
264 /* Calculate squared distance and things based on it */
265 rsq00
= gmx_mm_calc_rsq_ps(dx00
,dy00
,dz00
);
267 rinvsq00
= sse41_inv_f(rsq00
);
269 /* Load parameters for j particles */
270 vdwjidx0A
= 2*vdwtype
[jnrA
+0];
271 vdwjidx0B
= 2*vdwtype
[jnrB
+0];
272 vdwjidx0C
= 2*vdwtype
[jnrC
+0];
273 vdwjidx0D
= 2*vdwtype
[jnrD
+0];
275 /**************************
276 * CALCULATE INTERACTIONS *
277 **************************/
279 /* Compute parameters for interactions between i and j atoms */
280 gmx_mm_load_4pair_swizzle_ps(vdwparam
+vdwioffset0
+vdwjidx0A
,
281 vdwparam
+vdwioffset0
+vdwjidx0B
,
282 vdwparam
+vdwioffset0
+vdwjidx0C
,
283 vdwparam
+vdwioffset0
+vdwjidx0D
,
286 /* LENNARD-JONES DISPERSION/REPULSION */
288 rinvsix
= _mm_mul_ps(_mm_mul_ps(rinvsq00
,rinvsq00
),rinvsq00
);
289 vvdw6
= _mm_mul_ps(c6_00
,rinvsix
);
290 vvdw12
= _mm_mul_ps(c12_00
,_mm_mul_ps(rinvsix
,rinvsix
));
291 vvdw
= _mm_sub_ps( _mm_mul_ps(vvdw12
,one_twelfth
) , _mm_mul_ps(vvdw6
,one_sixth
) );
292 fvdw
= _mm_mul_ps(_mm_sub_ps(vvdw12
,vvdw6
),rinvsq00
);
294 /* Update potential sum for this i atom from the interaction with this j atom. */
295 vvdw
= _mm_andnot_ps(dummy_mask
,vvdw
);
296 vvdwsum
= _mm_add_ps(vvdwsum
,vvdw
);
300 fscal
= _mm_andnot_ps(dummy_mask
,fscal
);
302 /* Calculate temporary vectorial force */
303 tx
= _mm_mul_ps(fscal
,dx00
);
304 ty
= _mm_mul_ps(fscal
,dy00
);
305 tz
= _mm_mul_ps(fscal
,dz00
);
307 /* Update vectorial force */
308 fix0
= _mm_add_ps(fix0
,tx
);
309 fiy0
= _mm_add_ps(fiy0
,ty
);
310 fiz0
= _mm_add_ps(fiz0
,tz
);
312 fjptrA
= (jnrlistA
>=0) ? f
+j_coord_offsetA
: scratch
;
313 fjptrB
= (jnrlistB
>=0) ? f
+j_coord_offsetB
: scratch
;
314 fjptrC
= (jnrlistC
>=0) ? f
+j_coord_offsetC
: scratch
;
315 fjptrD
= (jnrlistD
>=0) ? f
+j_coord_offsetD
: scratch
;
316 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA
,fjptrB
,fjptrC
,fjptrD
,tx
,ty
,tz
);
318 /* Inner loop uses 32 flops */
321 /* End of innermost loop */
323 gmx_mm_update_iforce_1atom_swizzle_ps(fix0
,fiy0
,fiz0
,
324 f
+i_coord_offset
,fshift
+i_shift_offset
);
327 /* Update potential energies */
328 gmx_mm_update_1pot_ps(vvdwsum
,kernel_data
->energygrp_vdw
+ggid
);
330 /* Increment number of inner iterations */
331 inneriter
+= j_index_end
- j_index_start
;
333 /* Outer loop uses 7 flops */
336 /* Increment number of outer iterations */
339 /* Update outer/inner flops */
341 inc_nrnb(nrnb
,eNR_NBKERNEL_VDW_VF
,outeriter
*7 + inneriter
*32);
344 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwLJ_GeomP1P1_F_sse4_1_single
345 * Electrostatics interaction: None
346 * VdW interaction: LennardJones
347 * Geometry: Particle-Particle
348 * Calculate force/pot: Force
351 nb_kernel_ElecNone_VdwLJ_GeomP1P1_F_sse4_1_single
352 (t_nblist
* gmx_restrict nlist
,
353 rvec
* gmx_restrict xx
,
354 rvec
* gmx_restrict ff
,
355 struct t_forcerec
* gmx_restrict fr
,
356 t_mdatoms
* gmx_restrict mdatoms
,
357 nb_kernel_data_t gmx_unused
* gmx_restrict kernel_data
,
358 t_nrnb
* gmx_restrict nrnb
)
360 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
361 * just 0 for non-waters.
362 * Suffixes A,B,C,D refer to j loop unrolling done with SSE, e.g. for the four different
363 * jnr indices corresponding to data put in the four positions in the SIMD register.
365 int i_shift_offset
,i_coord_offset
,outeriter
,inneriter
;
366 int j_index_start
,j_index_end
,jidx
,nri
,inr
,ggid
,iidx
;
367 int jnrA
,jnrB
,jnrC
,jnrD
;
368 int jnrlistA
,jnrlistB
,jnrlistC
,jnrlistD
;
369 int j_coord_offsetA
,j_coord_offsetB
,j_coord_offsetC
,j_coord_offsetD
;
370 int *iinr
,*jindex
,*jjnr
,*shiftidx
,*gid
;
372 real
*shiftvec
,*fshift
,*x
,*f
;
373 real
*fjptrA
,*fjptrB
,*fjptrC
,*fjptrD
;
375 __m128 tx
,ty
,tz
,fscal
,rcutoff
,rcutoff2
,jidxall
;
377 __m128 ix0
,iy0
,iz0
,fix0
,fiy0
,fiz0
,iq0
,isai0
;
378 int vdwjidx0A
,vdwjidx0B
,vdwjidx0C
,vdwjidx0D
;
379 __m128 jx0
,jy0
,jz0
,fjx0
,fjy0
,fjz0
,jq0
,isaj0
;
380 __m128 dx00
,dy00
,dz00
,rsq00
,rinv00
,rinvsq00
,r00
,qq00
,c6_00
,c12_00
;
382 __m128 rinvsix
,rvdw
,vvdw
,vvdw6
,vvdw12
,fvdw
,fvdw6
,fvdw12
,vvdwsum
,sh_vdw_invrcut6
;
385 __m128 one_sixth
= _mm_set1_ps(1.0/6.0);
386 __m128 one_twelfth
= _mm_set1_ps(1.0/12.0);
387 __m128 dummy_mask
,cutoff_mask
;
388 __m128 signbit
= _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
389 __m128 one
= _mm_set1_ps(1.0);
390 __m128 two
= _mm_set1_ps(2.0);
396 jindex
= nlist
->jindex
;
398 shiftidx
= nlist
->shift
;
400 shiftvec
= fr
->shift_vec
[0];
401 fshift
= fr
->fshift
[0];
402 nvdwtype
= fr
->ntype
;
404 vdwtype
= mdatoms
->typeA
;
406 /* Avoid stupid compiler warnings */
407 jnrA
= jnrB
= jnrC
= jnrD
= 0;
416 for(iidx
=0;iidx
<4*DIM
;iidx
++)
421 /* Start outer loop over neighborlists */
422 for(iidx
=0; iidx
<nri
; iidx
++)
424 /* Load shift vector for this list */
425 i_shift_offset
= DIM
*shiftidx
[iidx
];
427 /* Load limits for loop over neighbors */
428 j_index_start
= jindex
[iidx
];
429 j_index_end
= jindex
[iidx
+1];
431 /* Get outer coordinate index */
433 i_coord_offset
= DIM
*inr
;
435 /* Load i particle coords and add shift vector */
436 gmx_mm_load_shift_and_1rvec_broadcast_ps(shiftvec
+i_shift_offset
,x
+i_coord_offset
,&ix0
,&iy0
,&iz0
);
438 fix0
= _mm_setzero_ps();
439 fiy0
= _mm_setzero_ps();
440 fiz0
= _mm_setzero_ps();
442 /* Load parameters for i particles */
443 vdwioffset0
= 2*nvdwtype
*vdwtype
[inr
+0];
445 /* Start inner kernel loop */
446 for(jidx
=j_index_start
; jidx
<j_index_end
&& jjnr
[jidx
+3]>=0; jidx
+=4)
449 /* Get j neighbor index, and coordinate index */
454 j_coord_offsetA
= DIM
*jnrA
;
455 j_coord_offsetB
= DIM
*jnrB
;
456 j_coord_offsetC
= DIM
*jnrC
;
457 j_coord_offsetD
= DIM
*jnrD
;
459 /* load j atom coordinates */
460 gmx_mm_load_1rvec_4ptr_swizzle_ps(x
+j_coord_offsetA
,x
+j_coord_offsetB
,
461 x
+j_coord_offsetC
,x
+j_coord_offsetD
,
464 /* Calculate displacement vector */
465 dx00
= _mm_sub_ps(ix0
,jx0
);
466 dy00
= _mm_sub_ps(iy0
,jy0
);
467 dz00
= _mm_sub_ps(iz0
,jz0
);
469 /* Calculate squared distance and things based on it */
470 rsq00
= gmx_mm_calc_rsq_ps(dx00
,dy00
,dz00
);
472 rinvsq00
= sse41_inv_f(rsq00
);
474 /* Load parameters for j particles */
475 vdwjidx0A
= 2*vdwtype
[jnrA
+0];
476 vdwjidx0B
= 2*vdwtype
[jnrB
+0];
477 vdwjidx0C
= 2*vdwtype
[jnrC
+0];
478 vdwjidx0D
= 2*vdwtype
[jnrD
+0];
480 /**************************
481 * CALCULATE INTERACTIONS *
482 **************************/
484 /* Compute parameters for interactions between i and j atoms */
485 gmx_mm_load_4pair_swizzle_ps(vdwparam
+vdwioffset0
+vdwjidx0A
,
486 vdwparam
+vdwioffset0
+vdwjidx0B
,
487 vdwparam
+vdwioffset0
+vdwjidx0C
,
488 vdwparam
+vdwioffset0
+vdwjidx0D
,
491 /* LENNARD-JONES DISPERSION/REPULSION */
493 rinvsix
= _mm_mul_ps(_mm_mul_ps(rinvsq00
,rinvsq00
),rinvsq00
);
494 fvdw
= _mm_mul_ps(_mm_sub_ps(_mm_mul_ps(c12_00
,rinvsix
),c6_00
),_mm_mul_ps(rinvsix
,rinvsq00
));
498 /* Calculate temporary vectorial force */
499 tx
= _mm_mul_ps(fscal
,dx00
);
500 ty
= _mm_mul_ps(fscal
,dy00
);
501 tz
= _mm_mul_ps(fscal
,dz00
);
503 /* Update vectorial force */
504 fix0
= _mm_add_ps(fix0
,tx
);
505 fiy0
= _mm_add_ps(fiy0
,ty
);
506 fiz0
= _mm_add_ps(fiz0
,tz
);
508 fjptrA
= f
+j_coord_offsetA
;
509 fjptrB
= f
+j_coord_offsetB
;
510 fjptrC
= f
+j_coord_offsetC
;
511 fjptrD
= f
+j_coord_offsetD
;
512 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA
,fjptrB
,fjptrC
,fjptrD
,tx
,ty
,tz
);
514 /* Inner loop uses 27 flops */
520 /* Get j neighbor index, and coordinate index */
521 jnrlistA
= jjnr
[jidx
];
522 jnrlistB
= jjnr
[jidx
+1];
523 jnrlistC
= jjnr
[jidx
+2];
524 jnrlistD
= jjnr
[jidx
+3];
525 /* Sign of each element will be negative for non-real atoms.
526 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
527 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
529 dummy_mask
= gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i
*)(jjnr
+jidx
)),_mm_setzero_si128()));
530 jnrA
= (jnrlistA
>=0) ? jnrlistA
: 0;
531 jnrB
= (jnrlistB
>=0) ? jnrlistB
: 0;
532 jnrC
= (jnrlistC
>=0) ? jnrlistC
: 0;
533 jnrD
= (jnrlistD
>=0) ? jnrlistD
: 0;
534 j_coord_offsetA
= DIM
*jnrA
;
535 j_coord_offsetB
= DIM
*jnrB
;
536 j_coord_offsetC
= DIM
*jnrC
;
537 j_coord_offsetD
= DIM
*jnrD
;
539 /* load j atom coordinates */
540 gmx_mm_load_1rvec_4ptr_swizzle_ps(x
+j_coord_offsetA
,x
+j_coord_offsetB
,
541 x
+j_coord_offsetC
,x
+j_coord_offsetD
,
544 /* Calculate displacement vector */
545 dx00
= _mm_sub_ps(ix0
,jx0
);
546 dy00
= _mm_sub_ps(iy0
,jy0
);
547 dz00
= _mm_sub_ps(iz0
,jz0
);
549 /* Calculate squared distance and things based on it */
550 rsq00
= gmx_mm_calc_rsq_ps(dx00
,dy00
,dz00
);
552 rinvsq00
= sse41_inv_f(rsq00
);
554 /* Load parameters for j particles */
555 vdwjidx0A
= 2*vdwtype
[jnrA
+0];
556 vdwjidx0B
= 2*vdwtype
[jnrB
+0];
557 vdwjidx0C
= 2*vdwtype
[jnrC
+0];
558 vdwjidx0D
= 2*vdwtype
[jnrD
+0];
560 /**************************
561 * CALCULATE INTERACTIONS *
562 **************************/
564 /* Compute parameters for interactions between i and j atoms */
565 gmx_mm_load_4pair_swizzle_ps(vdwparam
+vdwioffset0
+vdwjidx0A
,
566 vdwparam
+vdwioffset0
+vdwjidx0B
,
567 vdwparam
+vdwioffset0
+vdwjidx0C
,
568 vdwparam
+vdwioffset0
+vdwjidx0D
,
571 /* LENNARD-JONES DISPERSION/REPULSION */
573 rinvsix
= _mm_mul_ps(_mm_mul_ps(rinvsq00
,rinvsq00
),rinvsq00
);
574 fvdw
= _mm_mul_ps(_mm_sub_ps(_mm_mul_ps(c12_00
,rinvsix
),c6_00
),_mm_mul_ps(rinvsix
,rinvsq00
));
578 fscal
= _mm_andnot_ps(dummy_mask
,fscal
);
580 /* Calculate temporary vectorial force */
581 tx
= _mm_mul_ps(fscal
,dx00
);
582 ty
= _mm_mul_ps(fscal
,dy00
);
583 tz
= _mm_mul_ps(fscal
,dz00
);
585 /* Update vectorial force */
586 fix0
= _mm_add_ps(fix0
,tx
);
587 fiy0
= _mm_add_ps(fiy0
,ty
);
588 fiz0
= _mm_add_ps(fiz0
,tz
);
590 fjptrA
= (jnrlistA
>=0) ? f
+j_coord_offsetA
: scratch
;
591 fjptrB
= (jnrlistB
>=0) ? f
+j_coord_offsetB
: scratch
;
592 fjptrC
= (jnrlistC
>=0) ? f
+j_coord_offsetC
: scratch
;
593 fjptrD
= (jnrlistD
>=0) ? f
+j_coord_offsetD
: scratch
;
594 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA
,fjptrB
,fjptrC
,fjptrD
,tx
,ty
,tz
);
596 /* Inner loop uses 27 flops */
599 /* End of innermost loop */
601 gmx_mm_update_iforce_1atom_swizzle_ps(fix0
,fiy0
,fiz0
,
602 f
+i_coord_offset
,fshift
+i_shift_offset
);
604 /* Increment number of inner iterations */
605 inneriter
+= j_index_end
- j_index_start
;
607 /* Outer loop uses 6 flops */
610 /* Increment number of outer iterations */
613 /* Update outer/inner flops */
615 inc_nrnb(nrnb
,eNR_NBKERNEL_VDW_F
,outeriter
*6 + inneriter
*27);