2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014,2015,2017, 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 sse2_single kernel generator.
44 #include "../nb_kernel.h"
45 #include "gromacs/gmxlib/nrnb.h"
47 #include "kernelutil_x86_sse2_single.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwCSTab_GeomW4P1_VF_sse2_single
51 * Electrostatics interaction: CubicSplineTable
52 * VdW interaction: CubicSplineTable
53 * Geometry: Water4-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecCSTab_VdwCSTab_GeomW4P1_VF_sse2_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
;
85 __m128 ix1
,iy1
,iz1
,fix1
,fiy1
,fiz1
,iq1
,isai1
;
87 __m128 ix2
,iy2
,iz2
,fix2
,fiy2
,fiz2
,iq2
,isai2
;
89 __m128 ix3
,iy3
,iz3
,fix3
,fiy3
,fiz3
,iq3
,isai3
;
90 int vdwjidx0A
,vdwjidx0B
,vdwjidx0C
,vdwjidx0D
;
91 __m128 jx0
,jy0
,jz0
,fjx0
,fjy0
,fjz0
,jq0
,isaj0
;
92 __m128 dx00
,dy00
,dz00
,rsq00
,rinv00
,rinvsq00
,r00
,qq00
,c6_00
,c12_00
;
93 __m128 dx10
,dy10
,dz10
,rsq10
,rinv10
,rinvsq10
,r10
,qq10
,c6_10
,c12_10
;
94 __m128 dx20
,dy20
,dz20
,rsq20
,rinv20
,rinvsq20
,r20
,qq20
,c6_20
,c12_20
;
95 __m128 dx30
,dy30
,dz30
,rsq30
,rinv30
,rinvsq30
,r30
,qq30
,c6_30
,c12_30
;
96 __m128 velec
,felec
,velecsum
,facel
,crf
,krf
,krf2
;
99 __m128 rinvsix
,rvdw
,vvdw
,vvdw6
,vvdw12
,fvdw
,fvdw6
,fvdw12
,vvdwsum
,sh_vdw_invrcut6
;
102 __m128 one_sixth
= _mm_set1_ps(1.0/6.0);
103 __m128 one_twelfth
= _mm_set1_ps(1.0/12.0);
105 __m128i ifour
= _mm_set1_epi32(4);
106 __m128 rt
,vfeps
,vftabscale
,Y
,F
,G
,H
,Heps
,Fp
,VV
,FF
;
108 __m128 dummy_mask
,cutoff_mask
;
109 __m128 signbit
= _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
110 __m128 one
= _mm_set1_ps(1.0);
111 __m128 two
= _mm_set1_ps(2.0);
117 jindex
= nlist
->jindex
;
119 shiftidx
= nlist
->shift
;
121 shiftvec
= fr
->shift_vec
[0];
122 fshift
= fr
->fshift
[0];
123 facel
= _mm_set1_ps(fr
->ic
->epsfac
);
124 charge
= mdatoms
->chargeA
;
125 nvdwtype
= fr
->ntype
;
127 vdwtype
= mdatoms
->typeA
;
129 vftab
= kernel_data
->table_elec_vdw
->data
;
130 vftabscale
= _mm_set1_ps(kernel_data
->table_elec_vdw
->scale
);
132 /* Setup water-specific parameters */
133 inr
= nlist
->iinr
[0];
134 iq1
= _mm_mul_ps(facel
,_mm_set1_ps(charge
[inr
+1]));
135 iq2
= _mm_mul_ps(facel
,_mm_set1_ps(charge
[inr
+2]));
136 iq3
= _mm_mul_ps(facel
,_mm_set1_ps(charge
[inr
+3]));
137 vdwioffset0
= 2*nvdwtype
*vdwtype
[inr
+0];
139 /* Avoid stupid compiler warnings */
140 jnrA
= jnrB
= jnrC
= jnrD
= 0;
149 for(iidx
=0;iidx
<4*DIM
;iidx
++)
154 /* Start outer loop over neighborlists */
155 for(iidx
=0; iidx
<nri
; iidx
++)
157 /* Load shift vector for this list */
158 i_shift_offset
= DIM
*shiftidx
[iidx
];
160 /* Load limits for loop over neighbors */
161 j_index_start
= jindex
[iidx
];
162 j_index_end
= jindex
[iidx
+1];
164 /* Get outer coordinate index */
166 i_coord_offset
= DIM
*inr
;
168 /* Load i particle coords and add shift vector */
169 gmx_mm_load_shift_and_4rvec_broadcast_ps(shiftvec
+i_shift_offset
,x
+i_coord_offset
,
170 &ix0
,&iy0
,&iz0
,&ix1
,&iy1
,&iz1
,&ix2
,&iy2
,&iz2
,&ix3
,&iy3
,&iz3
);
172 fix0
= _mm_setzero_ps();
173 fiy0
= _mm_setzero_ps();
174 fiz0
= _mm_setzero_ps();
175 fix1
= _mm_setzero_ps();
176 fiy1
= _mm_setzero_ps();
177 fiz1
= _mm_setzero_ps();
178 fix2
= _mm_setzero_ps();
179 fiy2
= _mm_setzero_ps();
180 fiz2
= _mm_setzero_ps();
181 fix3
= _mm_setzero_ps();
182 fiy3
= _mm_setzero_ps();
183 fiz3
= _mm_setzero_ps();
185 /* Reset potential sums */
186 velecsum
= _mm_setzero_ps();
187 vvdwsum
= _mm_setzero_ps();
189 /* Start inner kernel loop */
190 for(jidx
=j_index_start
; jidx
<j_index_end
&& jjnr
[jidx
+3]>=0; jidx
+=4)
193 /* Get j neighbor index, and coordinate index */
198 j_coord_offsetA
= DIM
*jnrA
;
199 j_coord_offsetB
= DIM
*jnrB
;
200 j_coord_offsetC
= DIM
*jnrC
;
201 j_coord_offsetD
= DIM
*jnrD
;
203 /* load j atom coordinates */
204 gmx_mm_load_1rvec_4ptr_swizzle_ps(x
+j_coord_offsetA
,x
+j_coord_offsetB
,
205 x
+j_coord_offsetC
,x
+j_coord_offsetD
,
208 /* Calculate displacement vector */
209 dx00
= _mm_sub_ps(ix0
,jx0
);
210 dy00
= _mm_sub_ps(iy0
,jy0
);
211 dz00
= _mm_sub_ps(iz0
,jz0
);
212 dx10
= _mm_sub_ps(ix1
,jx0
);
213 dy10
= _mm_sub_ps(iy1
,jy0
);
214 dz10
= _mm_sub_ps(iz1
,jz0
);
215 dx20
= _mm_sub_ps(ix2
,jx0
);
216 dy20
= _mm_sub_ps(iy2
,jy0
);
217 dz20
= _mm_sub_ps(iz2
,jz0
);
218 dx30
= _mm_sub_ps(ix3
,jx0
);
219 dy30
= _mm_sub_ps(iy3
,jy0
);
220 dz30
= _mm_sub_ps(iz3
,jz0
);
222 /* Calculate squared distance and things based on it */
223 rsq00
= gmx_mm_calc_rsq_ps(dx00
,dy00
,dz00
);
224 rsq10
= gmx_mm_calc_rsq_ps(dx10
,dy10
,dz10
);
225 rsq20
= gmx_mm_calc_rsq_ps(dx20
,dy20
,dz20
);
226 rsq30
= gmx_mm_calc_rsq_ps(dx30
,dy30
,dz30
);
228 rinv00
= sse2_invsqrt_f(rsq00
);
229 rinv10
= sse2_invsqrt_f(rsq10
);
230 rinv20
= sse2_invsqrt_f(rsq20
);
231 rinv30
= sse2_invsqrt_f(rsq30
);
233 /* Load parameters for j particles */
234 jq0
= gmx_mm_load_4real_swizzle_ps(charge
+jnrA
+0,charge
+jnrB
+0,
235 charge
+jnrC
+0,charge
+jnrD
+0);
236 vdwjidx0A
= 2*vdwtype
[jnrA
+0];
237 vdwjidx0B
= 2*vdwtype
[jnrB
+0];
238 vdwjidx0C
= 2*vdwtype
[jnrC
+0];
239 vdwjidx0D
= 2*vdwtype
[jnrD
+0];
241 fjx0
= _mm_setzero_ps();
242 fjy0
= _mm_setzero_ps();
243 fjz0
= _mm_setzero_ps();
245 /**************************
246 * CALCULATE INTERACTIONS *
247 **************************/
249 r00
= _mm_mul_ps(rsq00
,rinv00
);
251 /* Compute parameters for interactions between i and j atoms */
252 gmx_mm_load_4pair_swizzle_ps(vdwparam
+vdwioffset0
+vdwjidx0A
,
253 vdwparam
+vdwioffset0
+vdwjidx0B
,
254 vdwparam
+vdwioffset0
+vdwjidx0C
,
255 vdwparam
+vdwioffset0
+vdwjidx0D
,
258 /* Calculate table index by multiplying r with table scale and truncate to integer */
259 rt
= _mm_mul_ps(r00
,vftabscale
);
260 vfitab
= _mm_cvttps_epi32(rt
);
261 vfeps
= _mm_sub_ps(rt
,_mm_cvtepi32_ps(vfitab
));
262 vfitab
= _mm_slli_epi32(_mm_add_epi32(vfitab
,_mm_slli_epi32(vfitab
,1)),2);
264 /* CUBIC SPLINE TABLE DISPERSION */
265 vfitab
= _mm_add_epi32(vfitab
,ifour
);
266 Y
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,0) );
267 F
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,1) );
268 G
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,2) );
269 H
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,3) );
270 _MM_TRANSPOSE4_PS(Y
,F
,G
,H
);
271 Heps
= _mm_mul_ps(vfeps
,H
);
272 Fp
= _mm_add_ps(F
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,Heps
)));
273 VV
= _mm_add_ps(Y
,_mm_mul_ps(vfeps
,Fp
));
274 vvdw6
= _mm_mul_ps(c6_00
,VV
);
275 FF
= _mm_add_ps(Fp
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,_mm_add_ps(Heps
,Heps
))));
276 fvdw6
= _mm_mul_ps(c6_00
,FF
);
278 /* CUBIC SPLINE TABLE REPULSION */
279 vfitab
= _mm_add_epi32(vfitab
,ifour
);
280 Y
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,0) );
281 F
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,1) );
282 G
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,2) );
283 H
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,3) );
284 _MM_TRANSPOSE4_PS(Y
,F
,G
,H
);
285 Heps
= _mm_mul_ps(vfeps
,H
);
286 Fp
= _mm_add_ps(F
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,Heps
)));
287 VV
= _mm_add_ps(Y
,_mm_mul_ps(vfeps
,Fp
));
288 vvdw12
= _mm_mul_ps(c12_00
,VV
);
289 FF
= _mm_add_ps(Fp
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,_mm_add_ps(Heps
,Heps
))));
290 fvdw12
= _mm_mul_ps(c12_00
,FF
);
291 vvdw
= _mm_add_ps(vvdw12
,vvdw6
);
292 fvdw
= _mm_xor_ps(signbit
,_mm_mul_ps(_mm_add_ps(fvdw6
,fvdw12
),_mm_mul_ps(vftabscale
,rinv00
)));
294 /* Update potential sum for this i atom from the interaction with this j atom. */
295 vvdwsum
= _mm_add_ps(vvdwsum
,vvdw
);
299 /* Calculate temporary vectorial force */
300 tx
= _mm_mul_ps(fscal
,dx00
);
301 ty
= _mm_mul_ps(fscal
,dy00
);
302 tz
= _mm_mul_ps(fscal
,dz00
);
304 /* Update vectorial force */
305 fix0
= _mm_add_ps(fix0
,tx
);
306 fiy0
= _mm_add_ps(fiy0
,ty
);
307 fiz0
= _mm_add_ps(fiz0
,tz
);
309 fjx0
= _mm_add_ps(fjx0
,tx
);
310 fjy0
= _mm_add_ps(fjy0
,ty
);
311 fjz0
= _mm_add_ps(fjz0
,tz
);
313 /**************************
314 * CALCULATE INTERACTIONS *
315 **************************/
317 r10
= _mm_mul_ps(rsq10
,rinv10
);
319 /* Compute parameters for interactions between i and j atoms */
320 qq10
= _mm_mul_ps(iq1
,jq0
);
322 /* Calculate table index by multiplying r with table scale and truncate to integer */
323 rt
= _mm_mul_ps(r10
,vftabscale
);
324 vfitab
= _mm_cvttps_epi32(rt
);
325 vfeps
= _mm_sub_ps(rt
,_mm_cvtepi32_ps(vfitab
));
326 vfitab
= _mm_slli_epi32(_mm_add_epi32(vfitab
,_mm_slli_epi32(vfitab
,1)),2);
328 /* CUBIC SPLINE TABLE ELECTROSTATICS */
329 Y
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,0) );
330 F
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,1) );
331 G
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,2) );
332 H
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,3) );
333 _MM_TRANSPOSE4_PS(Y
,F
,G
,H
);
334 Heps
= _mm_mul_ps(vfeps
,H
);
335 Fp
= _mm_add_ps(F
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,Heps
)));
336 VV
= _mm_add_ps(Y
,_mm_mul_ps(vfeps
,Fp
));
337 velec
= _mm_mul_ps(qq10
,VV
);
338 FF
= _mm_add_ps(Fp
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,_mm_add_ps(Heps
,Heps
))));
339 felec
= _mm_xor_ps(signbit
,_mm_mul_ps(_mm_mul_ps(qq10
,FF
),_mm_mul_ps(vftabscale
,rinv10
)));
341 /* Update potential sum for this i atom from the interaction with this j atom. */
342 velecsum
= _mm_add_ps(velecsum
,velec
);
346 /* Calculate temporary vectorial force */
347 tx
= _mm_mul_ps(fscal
,dx10
);
348 ty
= _mm_mul_ps(fscal
,dy10
);
349 tz
= _mm_mul_ps(fscal
,dz10
);
351 /* Update vectorial force */
352 fix1
= _mm_add_ps(fix1
,tx
);
353 fiy1
= _mm_add_ps(fiy1
,ty
);
354 fiz1
= _mm_add_ps(fiz1
,tz
);
356 fjx0
= _mm_add_ps(fjx0
,tx
);
357 fjy0
= _mm_add_ps(fjy0
,ty
);
358 fjz0
= _mm_add_ps(fjz0
,tz
);
360 /**************************
361 * CALCULATE INTERACTIONS *
362 **************************/
364 r20
= _mm_mul_ps(rsq20
,rinv20
);
366 /* Compute parameters for interactions between i and j atoms */
367 qq20
= _mm_mul_ps(iq2
,jq0
);
369 /* Calculate table index by multiplying r with table scale and truncate to integer */
370 rt
= _mm_mul_ps(r20
,vftabscale
);
371 vfitab
= _mm_cvttps_epi32(rt
);
372 vfeps
= _mm_sub_ps(rt
,_mm_cvtepi32_ps(vfitab
));
373 vfitab
= _mm_slli_epi32(_mm_add_epi32(vfitab
,_mm_slli_epi32(vfitab
,1)),2);
375 /* CUBIC SPLINE TABLE ELECTROSTATICS */
376 Y
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,0) );
377 F
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,1) );
378 G
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,2) );
379 H
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,3) );
380 _MM_TRANSPOSE4_PS(Y
,F
,G
,H
);
381 Heps
= _mm_mul_ps(vfeps
,H
);
382 Fp
= _mm_add_ps(F
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,Heps
)));
383 VV
= _mm_add_ps(Y
,_mm_mul_ps(vfeps
,Fp
));
384 velec
= _mm_mul_ps(qq20
,VV
);
385 FF
= _mm_add_ps(Fp
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,_mm_add_ps(Heps
,Heps
))));
386 felec
= _mm_xor_ps(signbit
,_mm_mul_ps(_mm_mul_ps(qq20
,FF
),_mm_mul_ps(vftabscale
,rinv20
)));
388 /* Update potential sum for this i atom from the interaction with this j atom. */
389 velecsum
= _mm_add_ps(velecsum
,velec
);
393 /* Calculate temporary vectorial force */
394 tx
= _mm_mul_ps(fscal
,dx20
);
395 ty
= _mm_mul_ps(fscal
,dy20
);
396 tz
= _mm_mul_ps(fscal
,dz20
);
398 /* Update vectorial force */
399 fix2
= _mm_add_ps(fix2
,tx
);
400 fiy2
= _mm_add_ps(fiy2
,ty
);
401 fiz2
= _mm_add_ps(fiz2
,tz
);
403 fjx0
= _mm_add_ps(fjx0
,tx
);
404 fjy0
= _mm_add_ps(fjy0
,ty
);
405 fjz0
= _mm_add_ps(fjz0
,tz
);
407 /**************************
408 * CALCULATE INTERACTIONS *
409 **************************/
411 r30
= _mm_mul_ps(rsq30
,rinv30
);
413 /* Compute parameters for interactions between i and j atoms */
414 qq30
= _mm_mul_ps(iq3
,jq0
);
416 /* Calculate table index by multiplying r with table scale and truncate to integer */
417 rt
= _mm_mul_ps(r30
,vftabscale
);
418 vfitab
= _mm_cvttps_epi32(rt
);
419 vfeps
= _mm_sub_ps(rt
,_mm_cvtepi32_ps(vfitab
));
420 vfitab
= _mm_slli_epi32(_mm_add_epi32(vfitab
,_mm_slli_epi32(vfitab
,1)),2);
422 /* CUBIC SPLINE TABLE ELECTROSTATICS */
423 Y
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,0) );
424 F
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,1) );
425 G
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,2) );
426 H
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,3) );
427 _MM_TRANSPOSE4_PS(Y
,F
,G
,H
);
428 Heps
= _mm_mul_ps(vfeps
,H
);
429 Fp
= _mm_add_ps(F
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,Heps
)));
430 VV
= _mm_add_ps(Y
,_mm_mul_ps(vfeps
,Fp
));
431 velec
= _mm_mul_ps(qq30
,VV
);
432 FF
= _mm_add_ps(Fp
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,_mm_add_ps(Heps
,Heps
))));
433 felec
= _mm_xor_ps(signbit
,_mm_mul_ps(_mm_mul_ps(qq30
,FF
),_mm_mul_ps(vftabscale
,rinv30
)));
435 /* Update potential sum for this i atom from the interaction with this j atom. */
436 velecsum
= _mm_add_ps(velecsum
,velec
);
440 /* Calculate temporary vectorial force */
441 tx
= _mm_mul_ps(fscal
,dx30
);
442 ty
= _mm_mul_ps(fscal
,dy30
);
443 tz
= _mm_mul_ps(fscal
,dz30
);
445 /* Update vectorial force */
446 fix3
= _mm_add_ps(fix3
,tx
);
447 fiy3
= _mm_add_ps(fiy3
,ty
);
448 fiz3
= _mm_add_ps(fiz3
,tz
);
450 fjx0
= _mm_add_ps(fjx0
,tx
);
451 fjy0
= _mm_add_ps(fjy0
,ty
);
452 fjz0
= _mm_add_ps(fjz0
,tz
);
454 fjptrA
= f
+j_coord_offsetA
;
455 fjptrB
= f
+j_coord_offsetB
;
456 fjptrC
= f
+j_coord_offsetC
;
457 fjptrD
= f
+j_coord_offsetD
;
459 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA
,fjptrB
,fjptrC
,fjptrD
,fjx0
,fjy0
,fjz0
);
461 /* Inner loop uses 185 flops */
467 /* Get j neighbor index, and coordinate index */
468 jnrlistA
= jjnr
[jidx
];
469 jnrlistB
= jjnr
[jidx
+1];
470 jnrlistC
= jjnr
[jidx
+2];
471 jnrlistD
= jjnr
[jidx
+3];
472 /* Sign of each element will be negative for non-real atoms.
473 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
474 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
476 dummy_mask
= gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i
*)(jjnr
+jidx
)),_mm_setzero_si128()));
477 jnrA
= (jnrlistA
>=0) ? jnrlistA
: 0;
478 jnrB
= (jnrlistB
>=0) ? jnrlistB
: 0;
479 jnrC
= (jnrlistC
>=0) ? jnrlistC
: 0;
480 jnrD
= (jnrlistD
>=0) ? jnrlistD
: 0;
481 j_coord_offsetA
= DIM
*jnrA
;
482 j_coord_offsetB
= DIM
*jnrB
;
483 j_coord_offsetC
= DIM
*jnrC
;
484 j_coord_offsetD
= DIM
*jnrD
;
486 /* load j atom coordinates */
487 gmx_mm_load_1rvec_4ptr_swizzle_ps(x
+j_coord_offsetA
,x
+j_coord_offsetB
,
488 x
+j_coord_offsetC
,x
+j_coord_offsetD
,
491 /* Calculate displacement vector */
492 dx00
= _mm_sub_ps(ix0
,jx0
);
493 dy00
= _mm_sub_ps(iy0
,jy0
);
494 dz00
= _mm_sub_ps(iz0
,jz0
);
495 dx10
= _mm_sub_ps(ix1
,jx0
);
496 dy10
= _mm_sub_ps(iy1
,jy0
);
497 dz10
= _mm_sub_ps(iz1
,jz0
);
498 dx20
= _mm_sub_ps(ix2
,jx0
);
499 dy20
= _mm_sub_ps(iy2
,jy0
);
500 dz20
= _mm_sub_ps(iz2
,jz0
);
501 dx30
= _mm_sub_ps(ix3
,jx0
);
502 dy30
= _mm_sub_ps(iy3
,jy0
);
503 dz30
= _mm_sub_ps(iz3
,jz0
);
505 /* Calculate squared distance and things based on it */
506 rsq00
= gmx_mm_calc_rsq_ps(dx00
,dy00
,dz00
);
507 rsq10
= gmx_mm_calc_rsq_ps(dx10
,dy10
,dz10
);
508 rsq20
= gmx_mm_calc_rsq_ps(dx20
,dy20
,dz20
);
509 rsq30
= gmx_mm_calc_rsq_ps(dx30
,dy30
,dz30
);
511 rinv00
= sse2_invsqrt_f(rsq00
);
512 rinv10
= sse2_invsqrt_f(rsq10
);
513 rinv20
= sse2_invsqrt_f(rsq20
);
514 rinv30
= sse2_invsqrt_f(rsq30
);
516 /* Load parameters for j particles */
517 jq0
= gmx_mm_load_4real_swizzle_ps(charge
+jnrA
+0,charge
+jnrB
+0,
518 charge
+jnrC
+0,charge
+jnrD
+0);
519 vdwjidx0A
= 2*vdwtype
[jnrA
+0];
520 vdwjidx0B
= 2*vdwtype
[jnrB
+0];
521 vdwjidx0C
= 2*vdwtype
[jnrC
+0];
522 vdwjidx0D
= 2*vdwtype
[jnrD
+0];
524 fjx0
= _mm_setzero_ps();
525 fjy0
= _mm_setzero_ps();
526 fjz0
= _mm_setzero_ps();
528 /**************************
529 * CALCULATE INTERACTIONS *
530 **************************/
532 r00
= _mm_mul_ps(rsq00
,rinv00
);
533 r00
= _mm_andnot_ps(dummy_mask
,r00
);
535 /* Compute parameters for interactions between i and j atoms */
536 gmx_mm_load_4pair_swizzle_ps(vdwparam
+vdwioffset0
+vdwjidx0A
,
537 vdwparam
+vdwioffset0
+vdwjidx0B
,
538 vdwparam
+vdwioffset0
+vdwjidx0C
,
539 vdwparam
+vdwioffset0
+vdwjidx0D
,
542 /* Calculate table index by multiplying r with table scale and truncate to integer */
543 rt
= _mm_mul_ps(r00
,vftabscale
);
544 vfitab
= _mm_cvttps_epi32(rt
);
545 vfeps
= _mm_sub_ps(rt
,_mm_cvtepi32_ps(vfitab
));
546 vfitab
= _mm_slli_epi32(_mm_add_epi32(vfitab
,_mm_slli_epi32(vfitab
,1)),2);
548 /* CUBIC SPLINE TABLE DISPERSION */
549 vfitab
= _mm_add_epi32(vfitab
,ifour
);
550 Y
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,0) );
551 F
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,1) );
552 G
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,2) );
553 H
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,3) );
554 _MM_TRANSPOSE4_PS(Y
,F
,G
,H
);
555 Heps
= _mm_mul_ps(vfeps
,H
);
556 Fp
= _mm_add_ps(F
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,Heps
)));
557 VV
= _mm_add_ps(Y
,_mm_mul_ps(vfeps
,Fp
));
558 vvdw6
= _mm_mul_ps(c6_00
,VV
);
559 FF
= _mm_add_ps(Fp
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,_mm_add_ps(Heps
,Heps
))));
560 fvdw6
= _mm_mul_ps(c6_00
,FF
);
562 /* CUBIC SPLINE TABLE REPULSION */
563 vfitab
= _mm_add_epi32(vfitab
,ifour
);
564 Y
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,0) );
565 F
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,1) );
566 G
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,2) );
567 H
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,3) );
568 _MM_TRANSPOSE4_PS(Y
,F
,G
,H
);
569 Heps
= _mm_mul_ps(vfeps
,H
);
570 Fp
= _mm_add_ps(F
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,Heps
)));
571 VV
= _mm_add_ps(Y
,_mm_mul_ps(vfeps
,Fp
));
572 vvdw12
= _mm_mul_ps(c12_00
,VV
);
573 FF
= _mm_add_ps(Fp
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,_mm_add_ps(Heps
,Heps
))));
574 fvdw12
= _mm_mul_ps(c12_00
,FF
);
575 vvdw
= _mm_add_ps(vvdw12
,vvdw6
);
576 fvdw
= _mm_xor_ps(signbit
,_mm_mul_ps(_mm_add_ps(fvdw6
,fvdw12
),_mm_mul_ps(vftabscale
,rinv00
)));
578 /* Update potential sum for this i atom from the interaction with this j atom. */
579 vvdw
= _mm_andnot_ps(dummy_mask
,vvdw
);
580 vvdwsum
= _mm_add_ps(vvdwsum
,vvdw
);
584 fscal
= _mm_andnot_ps(dummy_mask
,fscal
);
586 /* Calculate temporary vectorial force */
587 tx
= _mm_mul_ps(fscal
,dx00
);
588 ty
= _mm_mul_ps(fscal
,dy00
);
589 tz
= _mm_mul_ps(fscal
,dz00
);
591 /* Update vectorial force */
592 fix0
= _mm_add_ps(fix0
,tx
);
593 fiy0
= _mm_add_ps(fiy0
,ty
);
594 fiz0
= _mm_add_ps(fiz0
,tz
);
596 fjx0
= _mm_add_ps(fjx0
,tx
);
597 fjy0
= _mm_add_ps(fjy0
,ty
);
598 fjz0
= _mm_add_ps(fjz0
,tz
);
600 /**************************
601 * CALCULATE INTERACTIONS *
602 **************************/
604 r10
= _mm_mul_ps(rsq10
,rinv10
);
605 r10
= _mm_andnot_ps(dummy_mask
,r10
);
607 /* Compute parameters for interactions between i and j atoms */
608 qq10
= _mm_mul_ps(iq1
,jq0
);
610 /* Calculate table index by multiplying r with table scale and truncate to integer */
611 rt
= _mm_mul_ps(r10
,vftabscale
);
612 vfitab
= _mm_cvttps_epi32(rt
);
613 vfeps
= _mm_sub_ps(rt
,_mm_cvtepi32_ps(vfitab
));
614 vfitab
= _mm_slli_epi32(_mm_add_epi32(vfitab
,_mm_slli_epi32(vfitab
,1)),2);
616 /* CUBIC SPLINE TABLE ELECTROSTATICS */
617 Y
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,0) );
618 F
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,1) );
619 G
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,2) );
620 H
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,3) );
621 _MM_TRANSPOSE4_PS(Y
,F
,G
,H
);
622 Heps
= _mm_mul_ps(vfeps
,H
);
623 Fp
= _mm_add_ps(F
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,Heps
)));
624 VV
= _mm_add_ps(Y
,_mm_mul_ps(vfeps
,Fp
));
625 velec
= _mm_mul_ps(qq10
,VV
);
626 FF
= _mm_add_ps(Fp
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,_mm_add_ps(Heps
,Heps
))));
627 felec
= _mm_xor_ps(signbit
,_mm_mul_ps(_mm_mul_ps(qq10
,FF
),_mm_mul_ps(vftabscale
,rinv10
)));
629 /* Update potential sum for this i atom from the interaction with this j atom. */
630 velec
= _mm_andnot_ps(dummy_mask
,velec
);
631 velecsum
= _mm_add_ps(velecsum
,velec
);
635 fscal
= _mm_andnot_ps(dummy_mask
,fscal
);
637 /* Calculate temporary vectorial force */
638 tx
= _mm_mul_ps(fscal
,dx10
);
639 ty
= _mm_mul_ps(fscal
,dy10
);
640 tz
= _mm_mul_ps(fscal
,dz10
);
642 /* Update vectorial force */
643 fix1
= _mm_add_ps(fix1
,tx
);
644 fiy1
= _mm_add_ps(fiy1
,ty
);
645 fiz1
= _mm_add_ps(fiz1
,tz
);
647 fjx0
= _mm_add_ps(fjx0
,tx
);
648 fjy0
= _mm_add_ps(fjy0
,ty
);
649 fjz0
= _mm_add_ps(fjz0
,tz
);
651 /**************************
652 * CALCULATE INTERACTIONS *
653 **************************/
655 r20
= _mm_mul_ps(rsq20
,rinv20
);
656 r20
= _mm_andnot_ps(dummy_mask
,r20
);
658 /* Compute parameters for interactions between i and j atoms */
659 qq20
= _mm_mul_ps(iq2
,jq0
);
661 /* Calculate table index by multiplying r with table scale and truncate to integer */
662 rt
= _mm_mul_ps(r20
,vftabscale
);
663 vfitab
= _mm_cvttps_epi32(rt
);
664 vfeps
= _mm_sub_ps(rt
,_mm_cvtepi32_ps(vfitab
));
665 vfitab
= _mm_slli_epi32(_mm_add_epi32(vfitab
,_mm_slli_epi32(vfitab
,1)),2);
667 /* CUBIC SPLINE TABLE ELECTROSTATICS */
668 Y
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,0) );
669 F
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,1) );
670 G
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,2) );
671 H
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,3) );
672 _MM_TRANSPOSE4_PS(Y
,F
,G
,H
);
673 Heps
= _mm_mul_ps(vfeps
,H
);
674 Fp
= _mm_add_ps(F
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,Heps
)));
675 VV
= _mm_add_ps(Y
,_mm_mul_ps(vfeps
,Fp
));
676 velec
= _mm_mul_ps(qq20
,VV
);
677 FF
= _mm_add_ps(Fp
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,_mm_add_ps(Heps
,Heps
))));
678 felec
= _mm_xor_ps(signbit
,_mm_mul_ps(_mm_mul_ps(qq20
,FF
),_mm_mul_ps(vftabscale
,rinv20
)));
680 /* Update potential sum for this i atom from the interaction with this j atom. */
681 velec
= _mm_andnot_ps(dummy_mask
,velec
);
682 velecsum
= _mm_add_ps(velecsum
,velec
);
686 fscal
= _mm_andnot_ps(dummy_mask
,fscal
);
688 /* Calculate temporary vectorial force */
689 tx
= _mm_mul_ps(fscal
,dx20
);
690 ty
= _mm_mul_ps(fscal
,dy20
);
691 tz
= _mm_mul_ps(fscal
,dz20
);
693 /* Update vectorial force */
694 fix2
= _mm_add_ps(fix2
,tx
);
695 fiy2
= _mm_add_ps(fiy2
,ty
);
696 fiz2
= _mm_add_ps(fiz2
,tz
);
698 fjx0
= _mm_add_ps(fjx0
,tx
);
699 fjy0
= _mm_add_ps(fjy0
,ty
);
700 fjz0
= _mm_add_ps(fjz0
,tz
);
702 /**************************
703 * CALCULATE INTERACTIONS *
704 **************************/
706 r30
= _mm_mul_ps(rsq30
,rinv30
);
707 r30
= _mm_andnot_ps(dummy_mask
,r30
);
709 /* Compute parameters for interactions between i and j atoms */
710 qq30
= _mm_mul_ps(iq3
,jq0
);
712 /* Calculate table index by multiplying r with table scale and truncate to integer */
713 rt
= _mm_mul_ps(r30
,vftabscale
);
714 vfitab
= _mm_cvttps_epi32(rt
);
715 vfeps
= _mm_sub_ps(rt
,_mm_cvtepi32_ps(vfitab
));
716 vfitab
= _mm_slli_epi32(_mm_add_epi32(vfitab
,_mm_slli_epi32(vfitab
,1)),2);
718 /* CUBIC SPLINE TABLE ELECTROSTATICS */
719 Y
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,0) );
720 F
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,1) );
721 G
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,2) );
722 H
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,3) );
723 _MM_TRANSPOSE4_PS(Y
,F
,G
,H
);
724 Heps
= _mm_mul_ps(vfeps
,H
);
725 Fp
= _mm_add_ps(F
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,Heps
)));
726 VV
= _mm_add_ps(Y
,_mm_mul_ps(vfeps
,Fp
));
727 velec
= _mm_mul_ps(qq30
,VV
);
728 FF
= _mm_add_ps(Fp
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,_mm_add_ps(Heps
,Heps
))));
729 felec
= _mm_xor_ps(signbit
,_mm_mul_ps(_mm_mul_ps(qq30
,FF
),_mm_mul_ps(vftabscale
,rinv30
)));
731 /* Update potential sum for this i atom from the interaction with this j atom. */
732 velec
= _mm_andnot_ps(dummy_mask
,velec
);
733 velecsum
= _mm_add_ps(velecsum
,velec
);
737 fscal
= _mm_andnot_ps(dummy_mask
,fscal
);
739 /* Calculate temporary vectorial force */
740 tx
= _mm_mul_ps(fscal
,dx30
);
741 ty
= _mm_mul_ps(fscal
,dy30
);
742 tz
= _mm_mul_ps(fscal
,dz30
);
744 /* Update vectorial force */
745 fix3
= _mm_add_ps(fix3
,tx
);
746 fiy3
= _mm_add_ps(fiy3
,ty
);
747 fiz3
= _mm_add_ps(fiz3
,tz
);
749 fjx0
= _mm_add_ps(fjx0
,tx
);
750 fjy0
= _mm_add_ps(fjy0
,ty
);
751 fjz0
= _mm_add_ps(fjz0
,tz
);
753 fjptrA
= (jnrlistA
>=0) ? f
+j_coord_offsetA
: scratch
;
754 fjptrB
= (jnrlistB
>=0) ? f
+j_coord_offsetB
: scratch
;
755 fjptrC
= (jnrlistC
>=0) ? f
+j_coord_offsetC
: scratch
;
756 fjptrD
= (jnrlistD
>=0) ? f
+j_coord_offsetD
: scratch
;
758 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA
,fjptrB
,fjptrC
,fjptrD
,fjx0
,fjy0
,fjz0
);
760 /* Inner loop uses 189 flops */
763 /* End of innermost loop */
765 gmx_mm_update_iforce_4atom_swizzle_ps(fix0
,fiy0
,fiz0
,fix1
,fiy1
,fiz1
,fix2
,fiy2
,fiz2
,fix3
,fiy3
,fiz3
,
766 f
+i_coord_offset
,fshift
+i_shift_offset
);
769 /* Update potential energies */
770 gmx_mm_update_1pot_ps(velecsum
,kernel_data
->energygrp_elec
+ggid
);
771 gmx_mm_update_1pot_ps(vvdwsum
,kernel_data
->energygrp_vdw
+ggid
);
773 /* Increment number of inner iterations */
774 inneriter
+= j_index_end
- j_index_start
;
776 /* Outer loop uses 26 flops */
779 /* Increment number of outer iterations */
782 /* Update outer/inner flops */
784 inc_nrnb(nrnb
,eNR_NBKERNEL_ELEC_VDW_W4_VF
,outeriter
*26 + inneriter
*189);
787 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwCSTab_GeomW4P1_F_sse2_single
788 * Electrostatics interaction: CubicSplineTable
789 * VdW interaction: CubicSplineTable
790 * Geometry: Water4-Particle
791 * Calculate force/pot: Force
794 nb_kernel_ElecCSTab_VdwCSTab_GeomW4P1_F_sse2_single
795 (t_nblist
* gmx_restrict nlist
,
796 rvec
* gmx_restrict xx
,
797 rvec
* gmx_restrict ff
,
798 struct t_forcerec
* gmx_restrict fr
,
799 t_mdatoms
* gmx_restrict mdatoms
,
800 nb_kernel_data_t gmx_unused
* gmx_restrict kernel_data
,
801 t_nrnb
* gmx_restrict nrnb
)
803 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
804 * just 0 for non-waters.
805 * Suffixes A,B,C,D refer to j loop unrolling done with SSE, e.g. for the four different
806 * jnr indices corresponding to data put in the four positions in the SIMD register.
808 int i_shift_offset
,i_coord_offset
,outeriter
,inneriter
;
809 int j_index_start
,j_index_end
,jidx
,nri
,inr
,ggid
,iidx
;
810 int jnrA
,jnrB
,jnrC
,jnrD
;
811 int jnrlistA
,jnrlistB
,jnrlistC
,jnrlistD
;
812 int j_coord_offsetA
,j_coord_offsetB
,j_coord_offsetC
,j_coord_offsetD
;
813 int *iinr
,*jindex
,*jjnr
,*shiftidx
,*gid
;
815 real
*shiftvec
,*fshift
,*x
,*f
;
816 real
*fjptrA
,*fjptrB
,*fjptrC
,*fjptrD
;
818 __m128 tx
,ty
,tz
,fscal
,rcutoff
,rcutoff2
,jidxall
;
820 __m128 ix0
,iy0
,iz0
,fix0
,fiy0
,fiz0
,iq0
,isai0
;
822 __m128 ix1
,iy1
,iz1
,fix1
,fiy1
,fiz1
,iq1
,isai1
;
824 __m128 ix2
,iy2
,iz2
,fix2
,fiy2
,fiz2
,iq2
,isai2
;
826 __m128 ix3
,iy3
,iz3
,fix3
,fiy3
,fiz3
,iq3
,isai3
;
827 int vdwjidx0A
,vdwjidx0B
,vdwjidx0C
,vdwjidx0D
;
828 __m128 jx0
,jy0
,jz0
,fjx0
,fjy0
,fjz0
,jq0
,isaj0
;
829 __m128 dx00
,dy00
,dz00
,rsq00
,rinv00
,rinvsq00
,r00
,qq00
,c6_00
,c12_00
;
830 __m128 dx10
,dy10
,dz10
,rsq10
,rinv10
,rinvsq10
,r10
,qq10
,c6_10
,c12_10
;
831 __m128 dx20
,dy20
,dz20
,rsq20
,rinv20
,rinvsq20
,r20
,qq20
,c6_20
,c12_20
;
832 __m128 dx30
,dy30
,dz30
,rsq30
,rinv30
,rinvsq30
,r30
,qq30
,c6_30
,c12_30
;
833 __m128 velec
,felec
,velecsum
,facel
,crf
,krf
,krf2
;
836 __m128 rinvsix
,rvdw
,vvdw
,vvdw6
,vvdw12
,fvdw
,fvdw6
,fvdw12
,vvdwsum
,sh_vdw_invrcut6
;
839 __m128 one_sixth
= _mm_set1_ps(1.0/6.0);
840 __m128 one_twelfth
= _mm_set1_ps(1.0/12.0);
842 __m128i ifour
= _mm_set1_epi32(4);
843 __m128 rt
,vfeps
,vftabscale
,Y
,F
,G
,H
,Heps
,Fp
,VV
,FF
;
845 __m128 dummy_mask
,cutoff_mask
;
846 __m128 signbit
= _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
847 __m128 one
= _mm_set1_ps(1.0);
848 __m128 two
= _mm_set1_ps(2.0);
854 jindex
= nlist
->jindex
;
856 shiftidx
= nlist
->shift
;
858 shiftvec
= fr
->shift_vec
[0];
859 fshift
= fr
->fshift
[0];
860 facel
= _mm_set1_ps(fr
->ic
->epsfac
);
861 charge
= mdatoms
->chargeA
;
862 nvdwtype
= fr
->ntype
;
864 vdwtype
= mdatoms
->typeA
;
866 vftab
= kernel_data
->table_elec_vdw
->data
;
867 vftabscale
= _mm_set1_ps(kernel_data
->table_elec_vdw
->scale
);
869 /* Setup water-specific parameters */
870 inr
= nlist
->iinr
[0];
871 iq1
= _mm_mul_ps(facel
,_mm_set1_ps(charge
[inr
+1]));
872 iq2
= _mm_mul_ps(facel
,_mm_set1_ps(charge
[inr
+2]));
873 iq3
= _mm_mul_ps(facel
,_mm_set1_ps(charge
[inr
+3]));
874 vdwioffset0
= 2*nvdwtype
*vdwtype
[inr
+0];
876 /* Avoid stupid compiler warnings */
877 jnrA
= jnrB
= jnrC
= jnrD
= 0;
886 for(iidx
=0;iidx
<4*DIM
;iidx
++)
891 /* Start outer loop over neighborlists */
892 for(iidx
=0; iidx
<nri
; iidx
++)
894 /* Load shift vector for this list */
895 i_shift_offset
= DIM
*shiftidx
[iidx
];
897 /* Load limits for loop over neighbors */
898 j_index_start
= jindex
[iidx
];
899 j_index_end
= jindex
[iidx
+1];
901 /* Get outer coordinate index */
903 i_coord_offset
= DIM
*inr
;
905 /* Load i particle coords and add shift vector */
906 gmx_mm_load_shift_and_4rvec_broadcast_ps(shiftvec
+i_shift_offset
,x
+i_coord_offset
,
907 &ix0
,&iy0
,&iz0
,&ix1
,&iy1
,&iz1
,&ix2
,&iy2
,&iz2
,&ix3
,&iy3
,&iz3
);
909 fix0
= _mm_setzero_ps();
910 fiy0
= _mm_setzero_ps();
911 fiz0
= _mm_setzero_ps();
912 fix1
= _mm_setzero_ps();
913 fiy1
= _mm_setzero_ps();
914 fiz1
= _mm_setzero_ps();
915 fix2
= _mm_setzero_ps();
916 fiy2
= _mm_setzero_ps();
917 fiz2
= _mm_setzero_ps();
918 fix3
= _mm_setzero_ps();
919 fiy3
= _mm_setzero_ps();
920 fiz3
= _mm_setzero_ps();
922 /* Start inner kernel loop */
923 for(jidx
=j_index_start
; jidx
<j_index_end
&& jjnr
[jidx
+3]>=0; jidx
+=4)
926 /* Get j neighbor index, and coordinate index */
931 j_coord_offsetA
= DIM
*jnrA
;
932 j_coord_offsetB
= DIM
*jnrB
;
933 j_coord_offsetC
= DIM
*jnrC
;
934 j_coord_offsetD
= DIM
*jnrD
;
936 /* load j atom coordinates */
937 gmx_mm_load_1rvec_4ptr_swizzle_ps(x
+j_coord_offsetA
,x
+j_coord_offsetB
,
938 x
+j_coord_offsetC
,x
+j_coord_offsetD
,
941 /* Calculate displacement vector */
942 dx00
= _mm_sub_ps(ix0
,jx0
);
943 dy00
= _mm_sub_ps(iy0
,jy0
);
944 dz00
= _mm_sub_ps(iz0
,jz0
);
945 dx10
= _mm_sub_ps(ix1
,jx0
);
946 dy10
= _mm_sub_ps(iy1
,jy0
);
947 dz10
= _mm_sub_ps(iz1
,jz0
);
948 dx20
= _mm_sub_ps(ix2
,jx0
);
949 dy20
= _mm_sub_ps(iy2
,jy0
);
950 dz20
= _mm_sub_ps(iz2
,jz0
);
951 dx30
= _mm_sub_ps(ix3
,jx0
);
952 dy30
= _mm_sub_ps(iy3
,jy0
);
953 dz30
= _mm_sub_ps(iz3
,jz0
);
955 /* Calculate squared distance and things based on it */
956 rsq00
= gmx_mm_calc_rsq_ps(dx00
,dy00
,dz00
);
957 rsq10
= gmx_mm_calc_rsq_ps(dx10
,dy10
,dz10
);
958 rsq20
= gmx_mm_calc_rsq_ps(dx20
,dy20
,dz20
);
959 rsq30
= gmx_mm_calc_rsq_ps(dx30
,dy30
,dz30
);
961 rinv00
= sse2_invsqrt_f(rsq00
);
962 rinv10
= sse2_invsqrt_f(rsq10
);
963 rinv20
= sse2_invsqrt_f(rsq20
);
964 rinv30
= sse2_invsqrt_f(rsq30
);
966 /* Load parameters for j particles */
967 jq0
= gmx_mm_load_4real_swizzle_ps(charge
+jnrA
+0,charge
+jnrB
+0,
968 charge
+jnrC
+0,charge
+jnrD
+0);
969 vdwjidx0A
= 2*vdwtype
[jnrA
+0];
970 vdwjidx0B
= 2*vdwtype
[jnrB
+0];
971 vdwjidx0C
= 2*vdwtype
[jnrC
+0];
972 vdwjidx0D
= 2*vdwtype
[jnrD
+0];
974 fjx0
= _mm_setzero_ps();
975 fjy0
= _mm_setzero_ps();
976 fjz0
= _mm_setzero_ps();
978 /**************************
979 * CALCULATE INTERACTIONS *
980 **************************/
982 r00
= _mm_mul_ps(rsq00
,rinv00
);
984 /* Compute parameters for interactions between i and j atoms */
985 gmx_mm_load_4pair_swizzle_ps(vdwparam
+vdwioffset0
+vdwjidx0A
,
986 vdwparam
+vdwioffset0
+vdwjidx0B
,
987 vdwparam
+vdwioffset0
+vdwjidx0C
,
988 vdwparam
+vdwioffset0
+vdwjidx0D
,
991 /* Calculate table index by multiplying r with table scale and truncate to integer */
992 rt
= _mm_mul_ps(r00
,vftabscale
);
993 vfitab
= _mm_cvttps_epi32(rt
);
994 vfeps
= _mm_sub_ps(rt
,_mm_cvtepi32_ps(vfitab
));
995 vfitab
= _mm_slli_epi32(_mm_add_epi32(vfitab
,_mm_slli_epi32(vfitab
,1)),2);
997 /* CUBIC SPLINE TABLE DISPERSION */
998 vfitab
= _mm_add_epi32(vfitab
,ifour
);
999 Y
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,0) );
1000 F
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,1) );
1001 G
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,2) );
1002 H
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,3) );
1003 _MM_TRANSPOSE4_PS(Y
,F
,G
,H
);
1004 Heps
= _mm_mul_ps(vfeps
,H
);
1005 Fp
= _mm_add_ps(F
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,Heps
)));
1006 FF
= _mm_add_ps(Fp
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,_mm_add_ps(Heps
,Heps
))));
1007 fvdw6
= _mm_mul_ps(c6_00
,FF
);
1009 /* CUBIC SPLINE TABLE REPULSION */
1010 vfitab
= _mm_add_epi32(vfitab
,ifour
);
1011 Y
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,0) );
1012 F
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,1) );
1013 G
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,2) );
1014 H
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,3) );
1015 _MM_TRANSPOSE4_PS(Y
,F
,G
,H
);
1016 Heps
= _mm_mul_ps(vfeps
,H
);
1017 Fp
= _mm_add_ps(F
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,Heps
)));
1018 FF
= _mm_add_ps(Fp
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,_mm_add_ps(Heps
,Heps
))));
1019 fvdw12
= _mm_mul_ps(c12_00
,FF
);
1020 fvdw
= _mm_xor_ps(signbit
,_mm_mul_ps(_mm_add_ps(fvdw6
,fvdw12
),_mm_mul_ps(vftabscale
,rinv00
)));
1024 /* Calculate temporary vectorial force */
1025 tx
= _mm_mul_ps(fscal
,dx00
);
1026 ty
= _mm_mul_ps(fscal
,dy00
);
1027 tz
= _mm_mul_ps(fscal
,dz00
);
1029 /* Update vectorial force */
1030 fix0
= _mm_add_ps(fix0
,tx
);
1031 fiy0
= _mm_add_ps(fiy0
,ty
);
1032 fiz0
= _mm_add_ps(fiz0
,tz
);
1034 fjx0
= _mm_add_ps(fjx0
,tx
);
1035 fjy0
= _mm_add_ps(fjy0
,ty
);
1036 fjz0
= _mm_add_ps(fjz0
,tz
);
1038 /**************************
1039 * CALCULATE INTERACTIONS *
1040 **************************/
1042 r10
= _mm_mul_ps(rsq10
,rinv10
);
1044 /* Compute parameters for interactions between i and j atoms */
1045 qq10
= _mm_mul_ps(iq1
,jq0
);
1047 /* Calculate table index by multiplying r with table scale and truncate to integer */
1048 rt
= _mm_mul_ps(r10
,vftabscale
);
1049 vfitab
= _mm_cvttps_epi32(rt
);
1050 vfeps
= _mm_sub_ps(rt
,_mm_cvtepi32_ps(vfitab
));
1051 vfitab
= _mm_slli_epi32(_mm_add_epi32(vfitab
,_mm_slli_epi32(vfitab
,1)),2);
1053 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1054 Y
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,0) );
1055 F
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,1) );
1056 G
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,2) );
1057 H
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,3) );
1058 _MM_TRANSPOSE4_PS(Y
,F
,G
,H
);
1059 Heps
= _mm_mul_ps(vfeps
,H
);
1060 Fp
= _mm_add_ps(F
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,Heps
)));
1061 FF
= _mm_add_ps(Fp
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,_mm_add_ps(Heps
,Heps
))));
1062 felec
= _mm_xor_ps(signbit
,_mm_mul_ps(_mm_mul_ps(qq10
,FF
),_mm_mul_ps(vftabscale
,rinv10
)));
1066 /* Calculate temporary vectorial force */
1067 tx
= _mm_mul_ps(fscal
,dx10
);
1068 ty
= _mm_mul_ps(fscal
,dy10
);
1069 tz
= _mm_mul_ps(fscal
,dz10
);
1071 /* Update vectorial force */
1072 fix1
= _mm_add_ps(fix1
,tx
);
1073 fiy1
= _mm_add_ps(fiy1
,ty
);
1074 fiz1
= _mm_add_ps(fiz1
,tz
);
1076 fjx0
= _mm_add_ps(fjx0
,tx
);
1077 fjy0
= _mm_add_ps(fjy0
,ty
);
1078 fjz0
= _mm_add_ps(fjz0
,tz
);
1080 /**************************
1081 * CALCULATE INTERACTIONS *
1082 **************************/
1084 r20
= _mm_mul_ps(rsq20
,rinv20
);
1086 /* Compute parameters for interactions between i and j atoms */
1087 qq20
= _mm_mul_ps(iq2
,jq0
);
1089 /* Calculate table index by multiplying r with table scale and truncate to integer */
1090 rt
= _mm_mul_ps(r20
,vftabscale
);
1091 vfitab
= _mm_cvttps_epi32(rt
);
1092 vfeps
= _mm_sub_ps(rt
,_mm_cvtepi32_ps(vfitab
));
1093 vfitab
= _mm_slli_epi32(_mm_add_epi32(vfitab
,_mm_slli_epi32(vfitab
,1)),2);
1095 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1096 Y
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,0) );
1097 F
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,1) );
1098 G
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,2) );
1099 H
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,3) );
1100 _MM_TRANSPOSE4_PS(Y
,F
,G
,H
);
1101 Heps
= _mm_mul_ps(vfeps
,H
);
1102 Fp
= _mm_add_ps(F
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,Heps
)));
1103 FF
= _mm_add_ps(Fp
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,_mm_add_ps(Heps
,Heps
))));
1104 felec
= _mm_xor_ps(signbit
,_mm_mul_ps(_mm_mul_ps(qq20
,FF
),_mm_mul_ps(vftabscale
,rinv20
)));
1108 /* Calculate temporary vectorial force */
1109 tx
= _mm_mul_ps(fscal
,dx20
);
1110 ty
= _mm_mul_ps(fscal
,dy20
);
1111 tz
= _mm_mul_ps(fscal
,dz20
);
1113 /* Update vectorial force */
1114 fix2
= _mm_add_ps(fix2
,tx
);
1115 fiy2
= _mm_add_ps(fiy2
,ty
);
1116 fiz2
= _mm_add_ps(fiz2
,tz
);
1118 fjx0
= _mm_add_ps(fjx0
,tx
);
1119 fjy0
= _mm_add_ps(fjy0
,ty
);
1120 fjz0
= _mm_add_ps(fjz0
,tz
);
1122 /**************************
1123 * CALCULATE INTERACTIONS *
1124 **************************/
1126 r30
= _mm_mul_ps(rsq30
,rinv30
);
1128 /* Compute parameters for interactions between i and j atoms */
1129 qq30
= _mm_mul_ps(iq3
,jq0
);
1131 /* Calculate table index by multiplying r with table scale and truncate to integer */
1132 rt
= _mm_mul_ps(r30
,vftabscale
);
1133 vfitab
= _mm_cvttps_epi32(rt
);
1134 vfeps
= _mm_sub_ps(rt
,_mm_cvtepi32_ps(vfitab
));
1135 vfitab
= _mm_slli_epi32(_mm_add_epi32(vfitab
,_mm_slli_epi32(vfitab
,1)),2);
1137 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1138 Y
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,0) );
1139 F
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,1) );
1140 G
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,2) );
1141 H
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,3) );
1142 _MM_TRANSPOSE4_PS(Y
,F
,G
,H
);
1143 Heps
= _mm_mul_ps(vfeps
,H
);
1144 Fp
= _mm_add_ps(F
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,Heps
)));
1145 FF
= _mm_add_ps(Fp
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,_mm_add_ps(Heps
,Heps
))));
1146 felec
= _mm_xor_ps(signbit
,_mm_mul_ps(_mm_mul_ps(qq30
,FF
),_mm_mul_ps(vftabscale
,rinv30
)));
1150 /* Calculate temporary vectorial force */
1151 tx
= _mm_mul_ps(fscal
,dx30
);
1152 ty
= _mm_mul_ps(fscal
,dy30
);
1153 tz
= _mm_mul_ps(fscal
,dz30
);
1155 /* Update vectorial force */
1156 fix3
= _mm_add_ps(fix3
,tx
);
1157 fiy3
= _mm_add_ps(fiy3
,ty
);
1158 fiz3
= _mm_add_ps(fiz3
,tz
);
1160 fjx0
= _mm_add_ps(fjx0
,tx
);
1161 fjy0
= _mm_add_ps(fjy0
,ty
);
1162 fjz0
= _mm_add_ps(fjz0
,tz
);
1164 fjptrA
= f
+j_coord_offsetA
;
1165 fjptrB
= f
+j_coord_offsetB
;
1166 fjptrC
= f
+j_coord_offsetC
;
1167 fjptrD
= f
+j_coord_offsetD
;
1169 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA
,fjptrB
,fjptrC
,fjptrD
,fjx0
,fjy0
,fjz0
);
1171 /* Inner loop uses 165 flops */
1174 if(jidx
<j_index_end
)
1177 /* Get j neighbor index, and coordinate index */
1178 jnrlistA
= jjnr
[jidx
];
1179 jnrlistB
= jjnr
[jidx
+1];
1180 jnrlistC
= jjnr
[jidx
+2];
1181 jnrlistD
= jjnr
[jidx
+3];
1182 /* Sign of each element will be negative for non-real atoms.
1183 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
1184 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
1186 dummy_mask
= gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i
*)(jjnr
+jidx
)),_mm_setzero_si128()));
1187 jnrA
= (jnrlistA
>=0) ? jnrlistA
: 0;
1188 jnrB
= (jnrlistB
>=0) ? jnrlistB
: 0;
1189 jnrC
= (jnrlistC
>=0) ? jnrlistC
: 0;
1190 jnrD
= (jnrlistD
>=0) ? jnrlistD
: 0;
1191 j_coord_offsetA
= DIM
*jnrA
;
1192 j_coord_offsetB
= DIM
*jnrB
;
1193 j_coord_offsetC
= DIM
*jnrC
;
1194 j_coord_offsetD
= DIM
*jnrD
;
1196 /* load j atom coordinates */
1197 gmx_mm_load_1rvec_4ptr_swizzle_ps(x
+j_coord_offsetA
,x
+j_coord_offsetB
,
1198 x
+j_coord_offsetC
,x
+j_coord_offsetD
,
1201 /* Calculate displacement vector */
1202 dx00
= _mm_sub_ps(ix0
,jx0
);
1203 dy00
= _mm_sub_ps(iy0
,jy0
);
1204 dz00
= _mm_sub_ps(iz0
,jz0
);
1205 dx10
= _mm_sub_ps(ix1
,jx0
);
1206 dy10
= _mm_sub_ps(iy1
,jy0
);
1207 dz10
= _mm_sub_ps(iz1
,jz0
);
1208 dx20
= _mm_sub_ps(ix2
,jx0
);
1209 dy20
= _mm_sub_ps(iy2
,jy0
);
1210 dz20
= _mm_sub_ps(iz2
,jz0
);
1211 dx30
= _mm_sub_ps(ix3
,jx0
);
1212 dy30
= _mm_sub_ps(iy3
,jy0
);
1213 dz30
= _mm_sub_ps(iz3
,jz0
);
1215 /* Calculate squared distance and things based on it */
1216 rsq00
= gmx_mm_calc_rsq_ps(dx00
,dy00
,dz00
);
1217 rsq10
= gmx_mm_calc_rsq_ps(dx10
,dy10
,dz10
);
1218 rsq20
= gmx_mm_calc_rsq_ps(dx20
,dy20
,dz20
);
1219 rsq30
= gmx_mm_calc_rsq_ps(dx30
,dy30
,dz30
);
1221 rinv00
= sse2_invsqrt_f(rsq00
);
1222 rinv10
= sse2_invsqrt_f(rsq10
);
1223 rinv20
= sse2_invsqrt_f(rsq20
);
1224 rinv30
= sse2_invsqrt_f(rsq30
);
1226 /* Load parameters for j particles */
1227 jq0
= gmx_mm_load_4real_swizzle_ps(charge
+jnrA
+0,charge
+jnrB
+0,
1228 charge
+jnrC
+0,charge
+jnrD
+0);
1229 vdwjidx0A
= 2*vdwtype
[jnrA
+0];
1230 vdwjidx0B
= 2*vdwtype
[jnrB
+0];
1231 vdwjidx0C
= 2*vdwtype
[jnrC
+0];
1232 vdwjidx0D
= 2*vdwtype
[jnrD
+0];
1234 fjx0
= _mm_setzero_ps();
1235 fjy0
= _mm_setzero_ps();
1236 fjz0
= _mm_setzero_ps();
1238 /**************************
1239 * CALCULATE INTERACTIONS *
1240 **************************/
1242 r00
= _mm_mul_ps(rsq00
,rinv00
);
1243 r00
= _mm_andnot_ps(dummy_mask
,r00
);
1245 /* Compute parameters for interactions between i and j atoms */
1246 gmx_mm_load_4pair_swizzle_ps(vdwparam
+vdwioffset0
+vdwjidx0A
,
1247 vdwparam
+vdwioffset0
+vdwjidx0B
,
1248 vdwparam
+vdwioffset0
+vdwjidx0C
,
1249 vdwparam
+vdwioffset0
+vdwjidx0D
,
1252 /* Calculate table index by multiplying r with table scale and truncate to integer */
1253 rt
= _mm_mul_ps(r00
,vftabscale
);
1254 vfitab
= _mm_cvttps_epi32(rt
);
1255 vfeps
= _mm_sub_ps(rt
,_mm_cvtepi32_ps(vfitab
));
1256 vfitab
= _mm_slli_epi32(_mm_add_epi32(vfitab
,_mm_slli_epi32(vfitab
,1)),2);
1258 /* CUBIC SPLINE TABLE DISPERSION */
1259 vfitab
= _mm_add_epi32(vfitab
,ifour
);
1260 Y
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,0) );
1261 F
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,1) );
1262 G
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,2) );
1263 H
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,3) );
1264 _MM_TRANSPOSE4_PS(Y
,F
,G
,H
);
1265 Heps
= _mm_mul_ps(vfeps
,H
);
1266 Fp
= _mm_add_ps(F
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,Heps
)));
1267 FF
= _mm_add_ps(Fp
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,_mm_add_ps(Heps
,Heps
))));
1268 fvdw6
= _mm_mul_ps(c6_00
,FF
);
1270 /* CUBIC SPLINE TABLE REPULSION */
1271 vfitab
= _mm_add_epi32(vfitab
,ifour
);
1272 Y
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,0) );
1273 F
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,1) );
1274 G
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,2) );
1275 H
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,3) );
1276 _MM_TRANSPOSE4_PS(Y
,F
,G
,H
);
1277 Heps
= _mm_mul_ps(vfeps
,H
);
1278 Fp
= _mm_add_ps(F
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,Heps
)));
1279 FF
= _mm_add_ps(Fp
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,_mm_add_ps(Heps
,Heps
))));
1280 fvdw12
= _mm_mul_ps(c12_00
,FF
);
1281 fvdw
= _mm_xor_ps(signbit
,_mm_mul_ps(_mm_add_ps(fvdw6
,fvdw12
),_mm_mul_ps(vftabscale
,rinv00
)));
1285 fscal
= _mm_andnot_ps(dummy_mask
,fscal
);
1287 /* Calculate temporary vectorial force */
1288 tx
= _mm_mul_ps(fscal
,dx00
);
1289 ty
= _mm_mul_ps(fscal
,dy00
);
1290 tz
= _mm_mul_ps(fscal
,dz00
);
1292 /* Update vectorial force */
1293 fix0
= _mm_add_ps(fix0
,tx
);
1294 fiy0
= _mm_add_ps(fiy0
,ty
);
1295 fiz0
= _mm_add_ps(fiz0
,tz
);
1297 fjx0
= _mm_add_ps(fjx0
,tx
);
1298 fjy0
= _mm_add_ps(fjy0
,ty
);
1299 fjz0
= _mm_add_ps(fjz0
,tz
);
1301 /**************************
1302 * CALCULATE INTERACTIONS *
1303 **************************/
1305 r10
= _mm_mul_ps(rsq10
,rinv10
);
1306 r10
= _mm_andnot_ps(dummy_mask
,r10
);
1308 /* Compute parameters for interactions between i and j atoms */
1309 qq10
= _mm_mul_ps(iq1
,jq0
);
1311 /* Calculate table index by multiplying r with table scale and truncate to integer */
1312 rt
= _mm_mul_ps(r10
,vftabscale
);
1313 vfitab
= _mm_cvttps_epi32(rt
);
1314 vfeps
= _mm_sub_ps(rt
,_mm_cvtepi32_ps(vfitab
));
1315 vfitab
= _mm_slli_epi32(_mm_add_epi32(vfitab
,_mm_slli_epi32(vfitab
,1)),2);
1317 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1318 Y
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,0) );
1319 F
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,1) );
1320 G
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,2) );
1321 H
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,3) );
1322 _MM_TRANSPOSE4_PS(Y
,F
,G
,H
);
1323 Heps
= _mm_mul_ps(vfeps
,H
);
1324 Fp
= _mm_add_ps(F
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,Heps
)));
1325 FF
= _mm_add_ps(Fp
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,_mm_add_ps(Heps
,Heps
))));
1326 felec
= _mm_xor_ps(signbit
,_mm_mul_ps(_mm_mul_ps(qq10
,FF
),_mm_mul_ps(vftabscale
,rinv10
)));
1330 fscal
= _mm_andnot_ps(dummy_mask
,fscal
);
1332 /* Calculate temporary vectorial force */
1333 tx
= _mm_mul_ps(fscal
,dx10
);
1334 ty
= _mm_mul_ps(fscal
,dy10
);
1335 tz
= _mm_mul_ps(fscal
,dz10
);
1337 /* Update vectorial force */
1338 fix1
= _mm_add_ps(fix1
,tx
);
1339 fiy1
= _mm_add_ps(fiy1
,ty
);
1340 fiz1
= _mm_add_ps(fiz1
,tz
);
1342 fjx0
= _mm_add_ps(fjx0
,tx
);
1343 fjy0
= _mm_add_ps(fjy0
,ty
);
1344 fjz0
= _mm_add_ps(fjz0
,tz
);
1346 /**************************
1347 * CALCULATE INTERACTIONS *
1348 **************************/
1350 r20
= _mm_mul_ps(rsq20
,rinv20
);
1351 r20
= _mm_andnot_ps(dummy_mask
,r20
);
1353 /* Compute parameters for interactions between i and j atoms */
1354 qq20
= _mm_mul_ps(iq2
,jq0
);
1356 /* Calculate table index by multiplying r with table scale and truncate to integer */
1357 rt
= _mm_mul_ps(r20
,vftabscale
);
1358 vfitab
= _mm_cvttps_epi32(rt
);
1359 vfeps
= _mm_sub_ps(rt
,_mm_cvtepi32_ps(vfitab
));
1360 vfitab
= _mm_slli_epi32(_mm_add_epi32(vfitab
,_mm_slli_epi32(vfitab
,1)),2);
1362 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1363 Y
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,0) );
1364 F
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,1) );
1365 G
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,2) );
1366 H
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,3) );
1367 _MM_TRANSPOSE4_PS(Y
,F
,G
,H
);
1368 Heps
= _mm_mul_ps(vfeps
,H
);
1369 Fp
= _mm_add_ps(F
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,Heps
)));
1370 FF
= _mm_add_ps(Fp
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,_mm_add_ps(Heps
,Heps
))));
1371 felec
= _mm_xor_ps(signbit
,_mm_mul_ps(_mm_mul_ps(qq20
,FF
),_mm_mul_ps(vftabscale
,rinv20
)));
1375 fscal
= _mm_andnot_ps(dummy_mask
,fscal
);
1377 /* Calculate temporary vectorial force */
1378 tx
= _mm_mul_ps(fscal
,dx20
);
1379 ty
= _mm_mul_ps(fscal
,dy20
);
1380 tz
= _mm_mul_ps(fscal
,dz20
);
1382 /* Update vectorial force */
1383 fix2
= _mm_add_ps(fix2
,tx
);
1384 fiy2
= _mm_add_ps(fiy2
,ty
);
1385 fiz2
= _mm_add_ps(fiz2
,tz
);
1387 fjx0
= _mm_add_ps(fjx0
,tx
);
1388 fjy0
= _mm_add_ps(fjy0
,ty
);
1389 fjz0
= _mm_add_ps(fjz0
,tz
);
1391 /**************************
1392 * CALCULATE INTERACTIONS *
1393 **************************/
1395 r30
= _mm_mul_ps(rsq30
,rinv30
);
1396 r30
= _mm_andnot_ps(dummy_mask
,r30
);
1398 /* Compute parameters for interactions between i and j atoms */
1399 qq30
= _mm_mul_ps(iq3
,jq0
);
1401 /* Calculate table index by multiplying r with table scale and truncate to integer */
1402 rt
= _mm_mul_ps(r30
,vftabscale
);
1403 vfitab
= _mm_cvttps_epi32(rt
);
1404 vfeps
= _mm_sub_ps(rt
,_mm_cvtepi32_ps(vfitab
));
1405 vfitab
= _mm_slli_epi32(_mm_add_epi32(vfitab
,_mm_slli_epi32(vfitab
,1)),2);
1407 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1408 Y
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,0) );
1409 F
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,1) );
1410 G
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,2) );
1411 H
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,3) );
1412 _MM_TRANSPOSE4_PS(Y
,F
,G
,H
);
1413 Heps
= _mm_mul_ps(vfeps
,H
);
1414 Fp
= _mm_add_ps(F
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,Heps
)));
1415 FF
= _mm_add_ps(Fp
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,_mm_add_ps(Heps
,Heps
))));
1416 felec
= _mm_xor_ps(signbit
,_mm_mul_ps(_mm_mul_ps(qq30
,FF
),_mm_mul_ps(vftabscale
,rinv30
)));
1420 fscal
= _mm_andnot_ps(dummy_mask
,fscal
);
1422 /* Calculate temporary vectorial force */
1423 tx
= _mm_mul_ps(fscal
,dx30
);
1424 ty
= _mm_mul_ps(fscal
,dy30
);
1425 tz
= _mm_mul_ps(fscal
,dz30
);
1427 /* Update vectorial force */
1428 fix3
= _mm_add_ps(fix3
,tx
);
1429 fiy3
= _mm_add_ps(fiy3
,ty
);
1430 fiz3
= _mm_add_ps(fiz3
,tz
);
1432 fjx0
= _mm_add_ps(fjx0
,tx
);
1433 fjy0
= _mm_add_ps(fjy0
,ty
);
1434 fjz0
= _mm_add_ps(fjz0
,tz
);
1436 fjptrA
= (jnrlistA
>=0) ? f
+j_coord_offsetA
: scratch
;
1437 fjptrB
= (jnrlistB
>=0) ? f
+j_coord_offsetB
: scratch
;
1438 fjptrC
= (jnrlistC
>=0) ? f
+j_coord_offsetC
: scratch
;
1439 fjptrD
= (jnrlistD
>=0) ? f
+j_coord_offsetD
: scratch
;
1441 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA
,fjptrB
,fjptrC
,fjptrD
,fjx0
,fjy0
,fjz0
);
1443 /* Inner loop uses 169 flops */
1446 /* End of innermost loop */
1448 gmx_mm_update_iforce_4atom_swizzle_ps(fix0
,fiy0
,fiz0
,fix1
,fiy1
,fiz1
,fix2
,fiy2
,fiz2
,fix3
,fiy3
,fiz3
,
1449 f
+i_coord_offset
,fshift
+i_shift_offset
);
1451 /* Increment number of inner iterations */
1452 inneriter
+= j_index_end
- j_index_start
;
1454 /* Outer loop uses 24 flops */
1457 /* Increment number of outer iterations */
1460 /* Update outer/inner flops */
1462 inc_nrnb(nrnb
,eNR_NBKERNEL_ELEC_VDW_W4_F
,outeriter
*24 + inneriter
*169);