2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014,2015, 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/math/vec.h"
46 #include "gromacs/legacyheaders/nrnb.h"
48 #include "gromacs/simd/math_x86_sse2_single.h"
49 #include "kernelutil_x86_sse2_single.h"
52 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwCSTab_GeomW3W3_VF_sse2_single
53 * Electrostatics interaction: Ewald
54 * VdW interaction: CubicSplineTable
55 * Geometry: Water3-Water3
56 * Calculate force/pot: PotentialAndForce
59 nb_kernel_ElecEw_VdwCSTab_GeomW3W3_VF_sse2_single
60 (t_nblist
* gmx_restrict nlist
,
61 rvec
* gmx_restrict xx
,
62 rvec
* gmx_restrict ff
,
63 t_forcerec
* gmx_restrict fr
,
64 t_mdatoms
* gmx_restrict mdatoms
,
65 nb_kernel_data_t gmx_unused
* gmx_restrict kernel_data
,
66 t_nrnb
* gmx_restrict nrnb
)
68 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
69 * just 0 for non-waters.
70 * Suffixes A,B,C,D refer to j loop unrolling done with SSE, e.g. for the four different
71 * jnr indices corresponding to data put in the four positions in the SIMD register.
73 int i_shift_offset
,i_coord_offset
,outeriter
,inneriter
;
74 int j_index_start
,j_index_end
,jidx
,nri
,inr
,ggid
,iidx
;
75 int jnrA
,jnrB
,jnrC
,jnrD
;
76 int jnrlistA
,jnrlistB
,jnrlistC
,jnrlistD
;
77 int j_coord_offsetA
,j_coord_offsetB
,j_coord_offsetC
,j_coord_offsetD
;
78 int *iinr
,*jindex
,*jjnr
,*shiftidx
,*gid
;
80 real
*shiftvec
,*fshift
,*x
,*f
;
81 real
*fjptrA
,*fjptrB
,*fjptrC
,*fjptrD
;
83 __m128 tx
,ty
,tz
,fscal
,rcutoff
,rcutoff2
,jidxall
;
85 __m128 ix0
,iy0
,iz0
,fix0
,fiy0
,fiz0
,iq0
,isai0
;
87 __m128 ix1
,iy1
,iz1
,fix1
,fiy1
,fiz1
,iq1
,isai1
;
89 __m128 ix2
,iy2
,iz2
,fix2
,fiy2
,fiz2
,iq2
,isai2
;
90 int vdwjidx0A
,vdwjidx0B
,vdwjidx0C
,vdwjidx0D
;
91 __m128 jx0
,jy0
,jz0
,fjx0
,fjy0
,fjz0
,jq0
,isaj0
;
92 int vdwjidx1A
,vdwjidx1B
,vdwjidx1C
,vdwjidx1D
;
93 __m128 jx1
,jy1
,jz1
,fjx1
,fjy1
,fjz1
,jq1
,isaj1
;
94 int vdwjidx2A
,vdwjidx2B
,vdwjidx2C
,vdwjidx2D
;
95 __m128 jx2
,jy2
,jz2
,fjx2
,fjy2
,fjz2
,jq2
,isaj2
;
96 __m128 dx00
,dy00
,dz00
,rsq00
,rinv00
,rinvsq00
,r00
,qq00
,c6_00
,c12_00
;
97 __m128 dx01
,dy01
,dz01
,rsq01
,rinv01
,rinvsq01
,r01
,qq01
,c6_01
,c12_01
;
98 __m128 dx02
,dy02
,dz02
,rsq02
,rinv02
,rinvsq02
,r02
,qq02
,c6_02
,c12_02
;
99 __m128 dx10
,dy10
,dz10
,rsq10
,rinv10
,rinvsq10
,r10
,qq10
,c6_10
,c12_10
;
100 __m128 dx11
,dy11
,dz11
,rsq11
,rinv11
,rinvsq11
,r11
,qq11
,c6_11
,c12_11
;
101 __m128 dx12
,dy12
,dz12
,rsq12
,rinv12
,rinvsq12
,r12
,qq12
,c6_12
,c12_12
;
102 __m128 dx20
,dy20
,dz20
,rsq20
,rinv20
,rinvsq20
,r20
,qq20
,c6_20
,c12_20
;
103 __m128 dx21
,dy21
,dz21
,rsq21
,rinv21
,rinvsq21
,r21
,qq21
,c6_21
,c12_21
;
104 __m128 dx22
,dy22
,dz22
,rsq22
,rinv22
,rinvsq22
,r22
,qq22
,c6_22
,c12_22
;
105 __m128 velec
,felec
,velecsum
,facel
,crf
,krf
,krf2
;
108 __m128 rinvsix
,rvdw
,vvdw
,vvdw6
,vvdw12
,fvdw
,fvdw6
,fvdw12
,vvdwsum
,sh_vdw_invrcut6
;
111 __m128 one_sixth
= _mm_set1_ps(1.0/6.0);
112 __m128 one_twelfth
= _mm_set1_ps(1.0/12.0);
114 __m128i ifour
= _mm_set1_epi32(4);
115 __m128 rt
,vfeps
,vftabscale
,Y
,F
,G
,H
,Heps
,Fp
,VV
,FF
;
118 __m128 ewtabscale
,eweps
,sh_ewald
,ewrt
,ewtabhalfspace
,ewtabF
,ewtabFn
,ewtabD
,ewtabV
;
120 __m128 dummy_mask
,cutoff_mask
;
121 __m128 signbit
= _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
122 __m128 one
= _mm_set1_ps(1.0);
123 __m128 two
= _mm_set1_ps(2.0);
129 jindex
= nlist
->jindex
;
131 shiftidx
= nlist
->shift
;
133 shiftvec
= fr
->shift_vec
[0];
134 fshift
= fr
->fshift
[0];
135 facel
= _mm_set1_ps(fr
->epsfac
);
136 charge
= mdatoms
->chargeA
;
137 nvdwtype
= fr
->ntype
;
139 vdwtype
= mdatoms
->typeA
;
141 vftab
= kernel_data
->table_vdw
->data
;
142 vftabscale
= _mm_set1_ps(kernel_data
->table_vdw
->scale
);
144 sh_ewald
= _mm_set1_ps(fr
->ic
->sh_ewald
);
145 ewtab
= fr
->ic
->tabq_coul_FDV0
;
146 ewtabscale
= _mm_set1_ps(fr
->ic
->tabq_scale
);
147 ewtabhalfspace
= _mm_set1_ps(0.5/fr
->ic
->tabq_scale
);
149 /* Setup water-specific parameters */
150 inr
= nlist
->iinr
[0];
151 iq0
= _mm_mul_ps(facel
,_mm_set1_ps(charge
[inr
+0]));
152 iq1
= _mm_mul_ps(facel
,_mm_set1_ps(charge
[inr
+1]));
153 iq2
= _mm_mul_ps(facel
,_mm_set1_ps(charge
[inr
+2]));
154 vdwioffset0
= 2*nvdwtype
*vdwtype
[inr
+0];
156 jq0
= _mm_set1_ps(charge
[inr
+0]);
157 jq1
= _mm_set1_ps(charge
[inr
+1]);
158 jq2
= _mm_set1_ps(charge
[inr
+2]);
159 vdwjidx0A
= 2*vdwtype
[inr
+0];
160 qq00
= _mm_mul_ps(iq0
,jq0
);
161 c6_00
= _mm_set1_ps(vdwparam
[vdwioffset0
+vdwjidx0A
]);
162 c12_00
= _mm_set1_ps(vdwparam
[vdwioffset0
+vdwjidx0A
+1]);
163 qq01
= _mm_mul_ps(iq0
,jq1
);
164 qq02
= _mm_mul_ps(iq0
,jq2
);
165 qq10
= _mm_mul_ps(iq1
,jq0
);
166 qq11
= _mm_mul_ps(iq1
,jq1
);
167 qq12
= _mm_mul_ps(iq1
,jq2
);
168 qq20
= _mm_mul_ps(iq2
,jq0
);
169 qq21
= _mm_mul_ps(iq2
,jq1
);
170 qq22
= _mm_mul_ps(iq2
,jq2
);
172 /* Avoid stupid compiler warnings */
173 jnrA
= jnrB
= jnrC
= jnrD
= 0;
182 for(iidx
=0;iidx
<4*DIM
;iidx
++)
187 /* Start outer loop over neighborlists */
188 for(iidx
=0; iidx
<nri
; iidx
++)
190 /* Load shift vector for this list */
191 i_shift_offset
= DIM
*shiftidx
[iidx
];
193 /* Load limits for loop over neighbors */
194 j_index_start
= jindex
[iidx
];
195 j_index_end
= jindex
[iidx
+1];
197 /* Get outer coordinate index */
199 i_coord_offset
= DIM
*inr
;
201 /* Load i particle coords and add shift vector */
202 gmx_mm_load_shift_and_3rvec_broadcast_ps(shiftvec
+i_shift_offset
,x
+i_coord_offset
,
203 &ix0
,&iy0
,&iz0
,&ix1
,&iy1
,&iz1
,&ix2
,&iy2
,&iz2
);
205 fix0
= _mm_setzero_ps();
206 fiy0
= _mm_setzero_ps();
207 fiz0
= _mm_setzero_ps();
208 fix1
= _mm_setzero_ps();
209 fiy1
= _mm_setzero_ps();
210 fiz1
= _mm_setzero_ps();
211 fix2
= _mm_setzero_ps();
212 fiy2
= _mm_setzero_ps();
213 fiz2
= _mm_setzero_ps();
215 /* Reset potential sums */
216 velecsum
= _mm_setzero_ps();
217 vvdwsum
= _mm_setzero_ps();
219 /* Start inner kernel loop */
220 for(jidx
=j_index_start
; jidx
<j_index_end
&& jjnr
[jidx
+3]>=0; jidx
+=4)
223 /* Get j neighbor index, and coordinate index */
228 j_coord_offsetA
= DIM
*jnrA
;
229 j_coord_offsetB
= DIM
*jnrB
;
230 j_coord_offsetC
= DIM
*jnrC
;
231 j_coord_offsetD
= DIM
*jnrD
;
233 /* load j atom coordinates */
234 gmx_mm_load_3rvec_4ptr_swizzle_ps(x
+j_coord_offsetA
,x
+j_coord_offsetB
,
235 x
+j_coord_offsetC
,x
+j_coord_offsetD
,
236 &jx0
,&jy0
,&jz0
,&jx1
,&jy1
,&jz1
,&jx2
,&jy2
,&jz2
);
238 /* Calculate displacement vector */
239 dx00
= _mm_sub_ps(ix0
,jx0
);
240 dy00
= _mm_sub_ps(iy0
,jy0
);
241 dz00
= _mm_sub_ps(iz0
,jz0
);
242 dx01
= _mm_sub_ps(ix0
,jx1
);
243 dy01
= _mm_sub_ps(iy0
,jy1
);
244 dz01
= _mm_sub_ps(iz0
,jz1
);
245 dx02
= _mm_sub_ps(ix0
,jx2
);
246 dy02
= _mm_sub_ps(iy0
,jy2
);
247 dz02
= _mm_sub_ps(iz0
,jz2
);
248 dx10
= _mm_sub_ps(ix1
,jx0
);
249 dy10
= _mm_sub_ps(iy1
,jy0
);
250 dz10
= _mm_sub_ps(iz1
,jz0
);
251 dx11
= _mm_sub_ps(ix1
,jx1
);
252 dy11
= _mm_sub_ps(iy1
,jy1
);
253 dz11
= _mm_sub_ps(iz1
,jz1
);
254 dx12
= _mm_sub_ps(ix1
,jx2
);
255 dy12
= _mm_sub_ps(iy1
,jy2
);
256 dz12
= _mm_sub_ps(iz1
,jz2
);
257 dx20
= _mm_sub_ps(ix2
,jx0
);
258 dy20
= _mm_sub_ps(iy2
,jy0
);
259 dz20
= _mm_sub_ps(iz2
,jz0
);
260 dx21
= _mm_sub_ps(ix2
,jx1
);
261 dy21
= _mm_sub_ps(iy2
,jy1
);
262 dz21
= _mm_sub_ps(iz2
,jz1
);
263 dx22
= _mm_sub_ps(ix2
,jx2
);
264 dy22
= _mm_sub_ps(iy2
,jy2
);
265 dz22
= _mm_sub_ps(iz2
,jz2
);
267 /* Calculate squared distance and things based on it */
268 rsq00
= gmx_mm_calc_rsq_ps(dx00
,dy00
,dz00
);
269 rsq01
= gmx_mm_calc_rsq_ps(dx01
,dy01
,dz01
);
270 rsq02
= gmx_mm_calc_rsq_ps(dx02
,dy02
,dz02
);
271 rsq10
= gmx_mm_calc_rsq_ps(dx10
,dy10
,dz10
);
272 rsq11
= gmx_mm_calc_rsq_ps(dx11
,dy11
,dz11
);
273 rsq12
= gmx_mm_calc_rsq_ps(dx12
,dy12
,dz12
);
274 rsq20
= gmx_mm_calc_rsq_ps(dx20
,dy20
,dz20
);
275 rsq21
= gmx_mm_calc_rsq_ps(dx21
,dy21
,dz21
);
276 rsq22
= gmx_mm_calc_rsq_ps(dx22
,dy22
,dz22
);
278 rinv00
= gmx_mm_invsqrt_ps(rsq00
);
279 rinv01
= gmx_mm_invsqrt_ps(rsq01
);
280 rinv02
= gmx_mm_invsqrt_ps(rsq02
);
281 rinv10
= gmx_mm_invsqrt_ps(rsq10
);
282 rinv11
= gmx_mm_invsqrt_ps(rsq11
);
283 rinv12
= gmx_mm_invsqrt_ps(rsq12
);
284 rinv20
= gmx_mm_invsqrt_ps(rsq20
);
285 rinv21
= gmx_mm_invsqrt_ps(rsq21
);
286 rinv22
= gmx_mm_invsqrt_ps(rsq22
);
288 rinvsq00
= _mm_mul_ps(rinv00
,rinv00
);
289 rinvsq01
= _mm_mul_ps(rinv01
,rinv01
);
290 rinvsq02
= _mm_mul_ps(rinv02
,rinv02
);
291 rinvsq10
= _mm_mul_ps(rinv10
,rinv10
);
292 rinvsq11
= _mm_mul_ps(rinv11
,rinv11
);
293 rinvsq12
= _mm_mul_ps(rinv12
,rinv12
);
294 rinvsq20
= _mm_mul_ps(rinv20
,rinv20
);
295 rinvsq21
= _mm_mul_ps(rinv21
,rinv21
);
296 rinvsq22
= _mm_mul_ps(rinv22
,rinv22
);
298 fjx0
= _mm_setzero_ps();
299 fjy0
= _mm_setzero_ps();
300 fjz0
= _mm_setzero_ps();
301 fjx1
= _mm_setzero_ps();
302 fjy1
= _mm_setzero_ps();
303 fjz1
= _mm_setzero_ps();
304 fjx2
= _mm_setzero_ps();
305 fjy2
= _mm_setzero_ps();
306 fjz2
= _mm_setzero_ps();
308 /**************************
309 * CALCULATE INTERACTIONS *
310 **************************/
312 r00
= _mm_mul_ps(rsq00
,rinv00
);
314 /* Calculate table index by multiplying r with table scale and truncate to integer */
315 rt
= _mm_mul_ps(r00
,vftabscale
);
316 vfitab
= _mm_cvttps_epi32(rt
);
317 vfeps
= _mm_sub_ps(rt
,_mm_cvtepi32_ps(vfitab
));
318 vfitab
= _mm_slli_epi32(vfitab
,3);
320 /* EWALD ELECTROSTATICS */
322 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
323 ewrt
= _mm_mul_ps(r00
,ewtabscale
);
324 ewitab
= _mm_cvttps_epi32(ewrt
);
325 eweps
= _mm_sub_ps(ewrt
,_mm_cvtepi32_ps(ewitab
));
326 ewitab
= _mm_slli_epi32(ewitab
,2);
327 ewtabF
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,0) );
328 ewtabD
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,1) );
329 ewtabV
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,2) );
330 ewtabFn
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,3) );
331 _MM_TRANSPOSE4_PS(ewtabF
,ewtabD
,ewtabV
,ewtabFn
);
332 felec
= _mm_add_ps(ewtabF
,_mm_mul_ps(eweps
,ewtabD
));
333 velec
= _mm_sub_ps(ewtabV
,_mm_mul_ps(_mm_mul_ps(ewtabhalfspace
,eweps
),_mm_add_ps(ewtabF
,felec
)));
334 velec
= _mm_mul_ps(qq00
,_mm_sub_ps(rinv00
,velec
));
335 felec
= _mm_mul_ps(_mm_mul_ps(qq00
,rinv00
),_mm_sub_ps(rinvsq00
,felec
));
337 /* CUBIC SPLINE TABLE DISPERSION */
338 Y
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,0) );
339 F
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,1) );
340 G
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,2) );
341 H
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,3) );
342 _MM_TRANSPOSE4_PS(Y
,F
,G
,H
);
343 Heps
= _mm_mul_ps(vfeps
,H
);
344 Fp
= _mm_add_ps(F
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,Heps
)));
345 VV
= _mm_add_ps(Y
,_mm_mul_ps(vfeps
,Fp
));
346 vvdw6
= _mm_mul_ps(c6_00
,VV
);
347 FF
= _mm_add_ps(Fp
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,_mm_add_ps(Heps
,Heps
))));
348 fvdw6
= _mm_mul_ps(c6_00
,FF
);
350 /* CUBIC SPLINE TABLE REPULSION */
351 vfitab
= _mm_add_epi32(vfitab
,ifour
);
352 Y
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,0) );
353 F
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,1) );
354 G
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,2) );
355 H
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,3) );
356 _MM_TRANSPOSE4_PS(Y
,F
,G
,H
);
357 Heps
= _mm_mul_ps(vfeps
,H
);
358 Fp
= _mm_add_ps(F
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,Heps
)));
359 VV
= _mm_add_ps(Y
,_mm_mul_ps(vfeps
,Fp
));
360 vvdw12
= _mm_mul_ps(c12_00
,VV
);
361 FF
= _mm_add_ps(Fp
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,_mm_add_ps(Heps
,Heps
))));
362 fvdw12
= _mm_mul_ps(c12_00
,FF
);
363 vvdw
= _mm_add_ps(vvdw12
,vvdw6
);
364 fvdw
= _mm_xor_ps(signbit
,_mm_mul_ps(_mm_add_ps(fvdw6
,fvdw12
),_mm_mul_ps(vftabscale
,rinv00
)));
366 /* Update potential sum for this i atom from the interaction with this j atom. */
367 velecsum
= _mm_add_ps(velecsum
,velec
);
368 vvdwsum
= _mm_add_ps(vvdwsum
,vvdw
);
370 fscal
= _mm_add_ps(felec
,fvdw
);
372 /* Calculate temporary vectorial force */
373 tx
= _mm_mul_ps(fscal
,dx00
);
374 ty
= _mm_mul_ps(fscal
,dy00
);
375 tz
= _mm_mul_ps(fscal
,dz00
);
377 /* Update vectorial force */
378 fix0
= _mm_add_ps(fix0
,tx
);
379 fiy0
= _mm_add_ps(fiy0
,ty
);
380 fiz0
= _mm_add_ps(fiz0
,tz
);
382 fjx0
= _mm_add_ps(fjx0
,tx
);
383 fjy0
= _mm_add_ps(fjy0
,ty
);
384 fjz0
= _mm_add_ps(fjz0
,tz
);
386 /**************************
387 * CALCULATE INTERACTIONS *
388 **************************/
390 r01
= _mm_mul_ps(rsq01
,rinv01
);
392 /* EWALD ELECTROSTATICS */
394 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
395 ewrt
= _mm_mul_ps(r01
,ewtabscale
);
396 ewitab
= _mm_cvttps_epi32(ewrt
);
397 eweps
= _mm_sub_ps(ewrt
,_mm_cvtepi32_ps(ewitab
));
398 ewitab
= _mm_slli_epi32(ewitab
,2);
399 ewtabF
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,0) );
400 ewtabD
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,1) );
401 ewtabV
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,2) );
402 ewtabFn
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,3) );
403 _MM_TRANSPOSE4_PS(ewtabF
,ewtabD
,ewtabV
,ewtabFn
);
404 felec
= _mm_add_ps(ewtabF
,_mm_mul_ps(eweps
,ewtabD
));
405 velec
= _mm_sub_ps(ewtabV
,_mm_mul_ps(_mm_mul_ps(ewtabhalfspace
,eweps
),_mm_add_ps(ewtabF
,felec
)));
406 velec
= _mm_mul_ps(qq01
,_mm_sub_ps(rinv01
,velec
));
407 felec
= _mm_mul_ps(_mm_mul_ps(qq01
,rinv01
),_mm_sub_ps(rinvsq01
,felec
));
409 /* Update potential sum for this i atom from the interaction with this j atom. */
410 velecsum
= _mm_add_ps(velecsum
,velec
);
414 /* Calculate temporary vectorial force */
415 tx
= _mm_mul_ps(fscal
,dx01
);
416 ty
= _mm_mul_ps(fscal
,dy01
);
417 tz
= _mm_mul_ps(fscal
,dz01
);
419 /* Update vectorial force */
420 fix0
= _mm_add_ps(fix0
,tx
);
421 fiy0
= _mm_add_ps(fiy0
,ty
);
422 fiz0
= _mm_add_ps(fiz0
,tz
);
424 fjx1
= _mm_add_ps(fjx1
,tx
);
425 fjy1
= _mm_add_ps(fjy1
,ty
);
426 fjz1
= _mm_add_ps(fjz1
,tz
);
428 /**************************
429 * CALCULATE INTERACTIONS *
430 **************************/
432 r02
= _mm_mul_ps(rsq02
,rinv02
);
434 /* EWALD ELECTROSTATICS */
436 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
437 ewrt
= _mm_mul_ps(r02
,ewtabscale
);
438 ewitab
= _mm_cvttps_epi32(ewrt
);
439 eweps
= _mm_sub_ps(ewrt
,_mm_cvtepi32_ps(ewitab
));
440 ewitab
= _mm_slli_epi32(ewitab
,2);
441 ewtabF
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,0) );
442 ewtabD
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,1) );
443 ewtabV
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,2) );
444 ewtabFn
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,3) );
445 _MM_TRANSPOSE4_PS(ewtabF
,ewtabD
,ewtabV
,ewtabFn
);
446 felec
= _mm_add_ps(ewtabF
,_mm_mul_ps(eweps
,ewtabD
));
447 velec
= _mm_sub_ps(ewtabV
,_mm_mul_ps(_mm_mul_ps(ewtabhalfspace
,eweps
),_mm_add_ps(ewtabF
,felec
)));
448 velec
= _mm_mul_ps(qq02
,_mm_sub_ps(rinv02
,velec
));
449 felec
= _mm_mul_ps(_mm_mul_ps(qq02
,rinv02
),_mm_sub_ps(rinvsq02
,felec
));
451 /* Update potential sum for this i atom from the interaction with this j atom. */
452 velecsum
= _mm_add_ps(velecsum
,velec
);
456 /* Calculate temporary vectorial force */
457 tx
= _mm_mul_ps(fscal
,dx02
);
458 ty
= _mm_mul_ps(fscal
,dy02
);
459 tz
= _mm_mul_ps(fscal
,dz02
);
461 /* Update vectorial force */
462 fix0
= _mm_add_ps(fix0
,tx
);
463 fiy0
= _mm_add_ps(fiy0
,ty
);
464 fiz0
= _mm_add_ps(fiz0
,tz
);
466 fjx2
= _mm_add_ps(fjx2
,tx
);
467 fjy2
= _mm_add_ps(fjy2
,ty
);
468 fjz2
= _mm_add_ps(fjz2
,tz
);
470 /**************************
471 * CALCULATE INTERACTIONS *
472 **************************/
474 r10
= _mm_mul_ps(rsq10
,rinv10
);
476 /* EWALD ELECTROSTATICS */
478 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
479 ewrt
= _mm_mul_ps(r10
,ewtabscale
);
480 ewitab
= _mm_cvttps_epi32(ewrt
);
481 eweps
= _mm_sub_ps(ewrt
,_mm_cvtepi32_ps(ewitab
));
482 ewitab
= _mm_slli_epi32(ewitab
,2);
483 ewtabF
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,0) );
484 ewtabD
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,1) );
485 ewtabV
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,2) );
486 ewtabFn
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,3) );
487 _MM_TRANSPOSE4_PS(ewtabF
,ewtabD
,ewtabV
,ewtabFn
);
488 felec
= _mm_add_ps(ewtabF
,_mm_mul_ps(eweps
,ewtabD
));
489 velec
= _mm_sub_ps(ewtabV
,_mm_mul_ps(_mm_mul_ps(ewtabhalfspace
,eweps
),_mm_add_ps(ewtabF
,felec
)));
490 velec
= _mm_mul_ps(qq10
,_mm_sub_ps(rinv10
,velec
));
491 felec
= _mm_mul_ps(_mm_mul_ps(qq10
,rinv10
),_mm_sub_ps(rinvsq10
,felec
));
493 /* Update potential sum for this i atom from the interaction with this j atom. */
494 velecsum
= _mm_add_ps(velecsum
,velec
);
498 /* Calculate temporary vectorial force */
499 tx
= _mm_mul_ps(fscal
,dx10
);
500 ty
= _mm_mul_ps(fscal
,dy10
);
501 tz
= _mm_mul_ps(fscal
,dz10
);
503 /* Update vectorial force */
504 fix1
= _mm_add_ps(fix1
,tx
);
505 fiy1
= _mm_add_ps(fiy1
,ty
);
506 fiz1
= _mm_add_ps(fiz1
,tz
);
508 fjx0
= _mm_add_ps(fjx0
,tx
);
509 fjy0
= _mm_add_ps(fjy0
,ty
);
510 fjz0
= _mm_add_ps(fjz0
,tz
);
512 /**************************
513 * CALCULATE INTERACTIONS *
514 **************************/
516 r11
= _mm_mul_ps(rsq11
,rinv11
);
518 /* EWALD ELECTROSTATICS */
520 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
521 ewrt
= _mm_mul_ps(r11
,ewtabscale
);
522 ewitab
= _mm_cvttps_epi32(ewrt
);
523 eweps
= _mm_sub_ps(ewrt
,_mm_cvtepi32_ps(ewitab
));
524 ewitab
= _mm_slli_epi32(ewitab
,2);
525 ewtabF
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,0) );
526 ewtabD
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,1) );
527 ewtabV
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,2) );
528 ewtabFn
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,3) );
529 _MM_TRANSPOSE4_PS(ewtabF
,ewtabD
,ewtabV
,ewtabFn
);
530 felec
= _mm_add_ps(ewtabF
,_mm_mul_ps(eweps
,ewtabD
));
531 velec
= _mm_sub_ps(ewtabV
,_mm_mul_ps(_mm_mul_ps(ewtabhalfspace
,eweps
),_mm_add_ps(ewtabF
,felec
)));
532 velec
= _mm_mul_ps(qq11
,_mm_sub_ps(rinv11
,velec
));
533 felec
= _mm_mul_ps(_mm_mul_ps(qq11
,rinv11
),_mm_sub_ps(rinvsq11
,felec
));
535 /* Update potential sum for this i atom from the interaction with this j atom. */
536 velecsum
= _mm_add_ps(velecsum
,velec
);
540 /* Calculate temporary vectorial force */
541 tx
= _mm_mul_ps(fscal
,dx11
);
542 ty
= _mm_mul_ps(fscal
,dy11
);
543 tz
= _mm_mul_ps(fscal
,dz11
);
545 /* Update vectorial force */
546 fix1
= _mm_add_ps(fix1
,tx
);
547 fiy1
= _mm_add_ps(fiy1
,ty
);
548 fiz1
= _mm_add_ps(fiz1
,tz
);
550 fjx1
= _mm_add_ps(fjx1
,tx
);
551 fjy1
= _mm_add_ps(fjy1
,ty
);
552 fjz1
= _mm_add_ps(fjz1
,tz
);
554 /**************************
555 * CALCULATE INTERACTIONS *
556 **************************/
558 r12
= _mm_mul_ps(rsq12
,rinv12
);
560 /* EWALD ELECTROSTATICS */
562 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
563 ewrt
= _mm_mul_ps(r12
,ewtabscale
);
564 ewitab
= _mm_cvttps_epi32(ewrt
);
565 eweps
= _mm_sub_ps(ewrt
,_mm_cvtepi32_ps(ewitab
));
566 ewitab
= _mm_slli_epi32(ewitab
,2);
567 ewtabF
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,0) );
568 ewtabD
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,1) );
569 ewtabV
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,2) );
570 ewtabFn
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,3) );
571 _MM_TRANSPOSE4_PS(ewtabF
,ewtabD
,ewtabV
,ewtabFn
);
572 felec
= _mm_add_ps(ewtabF
,_mm_mul_ps(eweps
,ewtabD
));
573 velec
= _mm_sub_ps(ewtabV
,_mm_mul_ps(_mm_mul_ps(ewtabhalfspace
,eweps
),_mm_add_ps(ewtabF
,felec
)));
574 velec
= _mm_mul_ps(qq12
,_mm_sub_ps(rinv12
,velec
));
575 felec
= _mm_mul_ps(_mm_mul_ps(qq12
,rinv12
),_mm_sub_ps(rinvsq12
,felec
));
577 /* Update potential sum for this i atom from the interaction with this j atom. */
578 velecsum
= _mm_add_ps(velecsum
,velec
);
582 /* Calculate temporary vectorial force */
583 tx
= _mm_mul_ps(fscal
,dx12
);
584 ty
= _mm_mul_ps(fscal
,dy12
);
585 tz
= _mm_mul_ps(fscal
,dz12
);
587 /* Update vectorial force */
588 fix1
= _mm_add_ps(fix1
,tx
);
589 fiy1
= _mm_add_ps(fiy1
,ty
);
590 fiz1
= _mm_add_ps(fiz1
,tz
);
592 fjx2
= _mm_add_ps(fjx2
,tx
);
593 fjy2
= _mm_add_ps(fjy2
,ty
);
594 fjz2
= _mm_add_ps(fjz2
,tz
);
596 /**************************
597 * CALCULATE INTERACTIONS *
598 **************************/
600 r20
= _mm_mul_ps(rsq20
,rinv20
);
602 /* EWALD ELECTROSTATICS */
604 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
605 ewrt
= _mm_mul_ps(r20
,ewtabscale
);
606 ewitab
= _mm_cvttps_epi32(ewrt
);
607 eweps
= _mm_sub_ps(ewrt
,_mm_cvtepi32_ps(ewitab
));
608 ewitab
= _mm_slli_epi32(ewitab
,2);
609 ewtabF
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,0) );
610 ewtabD
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,1) );
611 ewtabV
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,2) );
612 ewtabFn
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,3) );
613 _MM_TRANSPOSE4_PS(ewtabF
,ewtabD
,ewtabV
,ewtabFn
);
614 felec
= _mm_add_ps(ewtabF
,_mm_mul_ps(eweps
,ewtabD
));
615 velec
= _mm_sub_ps(ewtabV
,_mm_mul_ps(_mm_mul_ps(ewtabhalfspace
,eweps
),_mm_add_ps(ewtabF
,felec
)));
616 velec
= _mm_mul_ps(qq20
,_mm_sub_ps(rinv20
,velec
));
617 felec
= _mm_mul_ps(_mm_mul_ps(qq20
,rinv20
),_mm_sub_ps(rinvsq20
,felec
));
619 /* Update potential sum for this i atom from the interaction with this j atom. */
620 velecsum
= _mm_add_ps(velecsum
,velec
);
624 /* Calculate temporary vectorial force */
625 tx
= _mm_mul_ps(fscal
,dx20
);
626 ty
= _mm_mul_ps(fscal
,dy20
);
627 tz
= _mm_mul_ps(fscal
,dz20
);
629 /* Update vectorial force */
630 fix2
= _mm_add_ps(fix2
,tx
);
631 fiy2
= _mm_add_ps(fiy2
,ty
);
632 fiz2
= _mm_add_ps(fiz2
,tz
);
634 fjx0
= _mm_add_ps(fjx0
,tx
);
635 fjy0
= _mm_add_ps(fjy0
,ty
);
636 fjz0
= _mm_add_ps(fjz0
,tz
);
638 /**************************
639 * CALCULATE INTERACTIONS *
640 **************************/
642 r21
= _mm_mul_ps(rsq21
,rinv21
);
644 /* EWALD ELECTROSTATICS */
646 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
647 ewrt
= _mm_mul_ps(r21
,ewtabscale
);
648 ewitab
= _mm_cvttps_epi32(ewrt
);
649 eweps
= _mm_sub_ps(ewrt
,_mm_cvtepi32_ps(ewitab
));
650 ewitab
= _mm_slli_epi32(ewitab
,2);
651 ewtabF
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,0) );
652 ewtabD
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,1) );
653 ewtabV
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,2) );
654 ewtabFn
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,3) );
655 _MM_TRANSPOSE4_PS(ewtabF
,ewtabD
,ewtabV
,ewtabFn
);
656 felec
= _mm_add_ps(ewtabF
,_mm_mul_ps(eweps
,ewtabD
));
657 velec
= _mm_sub_ps(ewtabV
,_mm_mul_ps(_mm_mul_ps(ewtabhalfspace
,eweps
),_mm_add_ps(ewtabF
,felec
)));
658 velec
= _mm_mul_ps(qq21
,_mm_sub_ps(rinv21
,velec
));
659 felec
= _mm_mul_ps(_mm_mul_ps(qq21
,rinv21
),_mm_sub_ps(rinvsq21
,felec
));
661 /* Update potential sum for this i atom from the interaction with this j atom. */
662 velecsum
= _mm_add_ps(velecsum
,velec
);
666 /* Calculate temporary vectorial force */
667 tx
= _mm_mul_ps(fscal
,dx21
);
668 ty
= _mm_mul_ps(fscal
,dy21
);
669 tz
= _mm_mul_ps(fscal
,dz21
);
671 /* Update vectorial force */
672 fix2
= _mm_add_ps(fix2
,tx
);
673 fiy2
= _mm_add_ps(fiy2
,ty
);
674 fiz2
= _mm_add_ps(fiz2
,tz
);
676 fjx1
= _mm_add_ps(fjx1
,tx
);
677 fjy1
= _mm_add_ps(fjy1
,ty
);
678 fjz1
= _mm_add_ps(fjz1
,tz
);
680 /**************************
681 * CALCULATE INTERACTIONS *
682 **************************/
684 r22
= _mm_mul_ps(rsq22
,rinv22
);
686 /* EWALD ELECTROSTATICS */
688 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
689 ewrt
= _mm_mul_ps(r22
,ewtabscale
);
690 ewitab
= _mm_cvttps_epi32(ewrt
);
691 eweps
= _mm_sub_ps(ewrt
,_mm_cvtepi32_ps(ewitab
));
692 ewitab
= _mm_slli_epi32(ewitab
,2);
693 ewtabF
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,0) );
694 ewtabD
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,1) );
695 ewtabV
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,2) );
696 ewtabFn
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,3) );
697 _MM_TRANSPOSE4_PS(ewtabF
,ewtabD
,ewtabV
,ewtabFn
);
698 felec
= _mm_add_ps(ewtabF
,_mm_mul_ps(eweps
,ewtabD
));
699 velec
= _mm_sub_ps(ewtabV
,_mm_mul_ps(_mm_mul_ps(ewtabhalfspace
,eweps
),_mm_add_ps(ewtabF
,felec
)));
700 velec
= _mm_mul_ps(qq22
,_mm_sub_ps(rinv22
,velec
));
701 felec
= _mm_mul_ps(_mm_mul_ps(qq22
,rinv22
),_mm_sub_ps(rinvsq22
,felec
));
703 /* Update potential sum for this i atom from the interaction with this j atom. */
704 velecsum
= _mm_add_ps(velecsum
,velec
);
708 /* Calculate temporary vectorial force */
709 tx
= _mm_mul_ps(fscal
,dx22
);
710 ty
= _mm_mul_ps(fscal
,dy22
);
711 tz
= _mm_mul_ps(fscal
,dz22
);
713 /* Update vectorial force */
714 fix2
= _mm_add_ps(fix2
,tx
);
715 fiy2
= _mm_add_ps(fiy2
,ty
);
716 fiz2
= _mm_add_ps(fiz2
,tz
);
718 fjx2
= _mm_add_ps(fjx2
,tx
);
719 fjy2
= _mm_add_ps(fjy2
,ty
);
720 fjz2
= _mm_add_ps(fjz2
,tz
);
722 fjptrA
= f
+j_coord_offsetA
;
723 fjptrB
= f
+j_coord_offsetB
;
724 fjptrC
= f
+j_coord_offsetC
;
725 fjptrD
= f
+j_coord_offsetD
;
727 gmx_mm_decrement_3rvec_4ptr_swizzle_ps(fjptrA
,fjptrB
,fjptrC
,fjptrD
,
728 fjx0
,fjy0
,fjz0
,fjx1
,fjy1
,fjz1
,fjx2
,fjy2
,fjz2
);
730 /* Inner loop uses 403 flops */
736 /* Get j neighbor index, and coordinate index */
737 jnrlistA
= jjnr
[jidx
];
738 jnrlistB
= jjnr
[jidx
+1];
739 jnrlistC
= jjnr
[jidx
+2];
740 jnrlistD
= jjnr
[jidx
+3];
741 /* Sign of each element will be negative for non-real atoms.
742 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
743 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
745 dummy_mask
= gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i
*)(jjnr
+jidx
)),_mm_setzero_si128()));
746 jnrA
= (jnrlistA
>=0) ? jnrlistA
: 0;
747 jnrB
= (jnrlistB
>=0) ? jnrlistB
: 0;
748 jnrC
= (jnrlistC
>=0) ? jnrlistC
: 0;
749 jnrD
= (jnrlistD
>=0) ? jnrlistD
: 0;
750 j_coord_offsetA
= DIM
*jnrA
;
751 j_coord_offsetB
= DIM
*jnrB
;
752 j_coord_offsetC
= DIM
*jnrC
;
753 j_coord_offsetD
= DIM
*jnrD
;
755 /* load j atom coordinates */
756 gmx_mm_load_3rvec_4ptr_swizzle_ps(x
+j_coord_offsetA
,x
+j_coord_offsetB
,
757 x
+j_coord_offsetC
,x
+j_coord_offsetD
,
758 &jx0
,&jy0
,&jz0
,&jx1
,&jy1
,&jz1
,&jx2
,&jy2
,&jz2
);
760 /* Calculate displacement vector */
761 dx00
= _mm_sub_ps(ix0
,jx0
);
762 dy00
= _mm_sub_ps(iy0
,jy0
);
763 dz00
= _mm_sub_ps(iz0
,jz0
);
764 dx01
= _mm_sub_ps(ix0
,jx1
);
765 dy01
= _mm_sub_ps(iy0
,jy1
);
766 dz01
= _mm_sub_ps(iz0
,jz1
);
767 dx02
= _mm_sub_ps(ix0
,jx2
);
768 dy02
= _mm_sub_ps(iy0
,jy2
);
769 dz02
= _mm_sub_ps(iz0
,jz2
);
770 dx10
= _mm_sub_ps(ix1
,jx0
);
771 dy10
= _mm_sub_ps(iy1
,jy0
);
772 dz10
= _mm_sub_ps(iz1
,jz0
);
773 dx11
= _mm_sub_ps(ix1
,jx1
);
774 dy11
= _mm_sub_ps(iy1
,jy1
);
775 dz11
= _mm_sub_ps(iz1
,jz1
);
776 dx12
= _mm_sub_ps(ix1
,jx2
);
777 dy12
= _mm_sub_ps(iy1
,jy2
);
778 dz12
= _mm_sub_ps(iz1
,jz2
);
779 dx20
= _mm_sub_ps(ix2
,jx0
);
780 dy20
= _mm_sub_ps(iy2
,jy0
);
781 dz20
= _mm_sub_ps(iz2
,jz0
);
782 dx21
= _mm_sub_ps(ix2
,jx1
);
783 dy21
= _mm_sub_ps(iy2
,jy1
);
784 dz21
= _mm_sub_ps(iz2
,jz1
);
785 dx22
= _mm_sub_ps(ix2
,jx2
);
786 dy22
= _mm_sub_ps(iy2
,jy2
);
787 dz22
= _mm_sub_ps(iz2
,jz2
);
789 /* Calculate squared distance and things based on it */
790 rsq00
= gmx_mm_calc_rsq_ps(dx00
,dy00
,dz00
);
791 rsq01
= gmx_mm_calc_rsq_ps(dx01
,dy01
,dz01
);
792 rsq02
= gmx_mm_calc_rsq_ps(dx02
,dy02
,dz02
);
793 rsq10
= gmx_mm_calc_rsq_ps(dx10
,dy10
,dz10
);
794 rsq11
= gmx_mm_calc_rsq_ps(dx11
,dy11
,dz11
);
795 rsq12
= gmx_mm_calc_rsq_ps(dx12
,dy12
,dz12
);
796 rsq20
= gmx_mm_calc_rsq_ps(dx20
,dy20
,dz20
);
797 rsq21
= gmx_mm_calc_rsq_ps(dx21
,dy21
,dz21
);
798 rsq22
= gmx_mm_calc_rsq_ps(dx22
,dy22
,dz22
);
800 rinv00
= gmx_mm_invsqrt_ps(rsq00
);
801 rinv01
= gmx_mm_invsqrt_ps(rsq01
);
802 rinv02
= gmx_mm_invsqrt_ps(rsq02
);
803 rinv10
= gmx_mm_invsqrt_ps(rsq10
);
804 rinv11
= gmx_mm_invsqrt_ps(rsq11
);
805 rinv12
= gmx_mm_invsqrt_ps(rsq12
);
806 rinv20
= gmx_mm_invsqrt_ps(rsq20
);
807 rinv21
= gmx_mm_invsqrt_ps(rsq21
);
808 rinv22
= gmx_mm_invsqrt_ps(rsq22
);
810 rinvsq00
= _mm_mul_ps(rinv00
,rinv00
);
811 rinvsq01
= _mm_mul_ps(rinv01
,rinv01
);
812 rinvsq02
= _mm_mul_ps(rinv02
,rinv02
);
813 rinvsq10
= _mm_mul_ps(rinv10
,rinv10
);
814 rinvsq11
= _mm_mul_ps(rinv11
,rinv11
);
815 rinvsq12
= _mm_mul_ps(rinv12
,rinv12
);
816 rinvsq20
= _mm_mul_ps(rinv20
,rinv20
);
817 rinvsq21
= _mm_mul_ps(rinv21
,rinv21
);
818 rinvsq22
= _mm_mul_ps(rinv22
,rinv22
);
820 fjx0
= _mm_setzero_ps();
821 fjy0
= _mm_setzero_ps();
822 fjz0
= _mm_setzero_ps();
823 fjx1
= _mm_setzero_ps();
824 fjy1
= _mm_setzero_ps();
825 fjz1
= _mm_setzero_ps();
826 fjx2
= _mm_setzero_ps();
827 fjy2
= _mm_setzero_ps();
828 fjz2
= _mm_setzero_ps();
830 /**************************
831 * CALCULATE INTERACTIONS *
832 **************************/
834 r00
= _mm_mul_ps(rsq00
,rinv00
);
835 r00
= _mm_andnot_ps(dummy_mask
,r00
);
837 /* Calculate table index by multiplying r with table scale and truncate to integer */
838 rt
= _mm_mul_ps(r00
,vftabscale
);
839 vfitab
= _mm_cvttps_epi32(rt
);
840 vfeps
= _mm_sub_ps(rt
,_mm_cvtepi32_ps(vfitab
));
841 vfitab
= _mm_slli_epi32(vfitab
,3);
843 /* EWALD ELECTROSTATICS */
845 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
846 ewrt
= _mm_mul_ps(r00
,ewtabscale
);
847 ewitab
= _mm_cvttps_epi32(ewrt
);
848 eweps
= _mm_sub_ps(ewrt
,_mm_cvtepi32_ps(ewitab
));
849 ewitab
= _mm_slli_epi32(ewitab
,2);
850 ewtabF
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,0) );
851 ewtabD
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,1) );
852 ewtabV
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,2) );
853 ewtabFn
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,3) );
854 _MM_TRANSPOSE4_PS(ewtabF
,ewtabD
,ewtabV
,ewtabFn
);
855 felec
= _mm_add_ps(ewtabF
,_mm_mul_ps(eweps
,ewtabD
));
856 velec
= _mm_sub_ps(ewtabV
,_mm_mul_ps(_mm_mul_ps(ewtabhalfspace
,eweps
),_mm_add_ps(ewtabF
,felec
)));
857 velec
= _mm_mul_ps(qq00
,_mm_sub_ps(rinv00
,velec
));
858 felec
= _mm_mul_ps(_mm_mul_ps(qq00
,rinv00
),_mm_sub_ps(rinvsq00
,felec
));
860 /* CUBIC SPLINE TABLE DISPERSION */
861 Y
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,0) );
862 F
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,1) );
863 G
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,2) );
864 H
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,3) );
865 _MM_TRANSPOSE4_PS(Y
,F
,G
,H
);
866 Heps
= _mm_mul_ps(vfeps
,H
);
867 Fp
= _mm_add_ps(F
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,Heps
)));
868 VV
= _mm_add_ps(Y
,_mm_mul_ps(vfeps
,Fp
));
869 vvdw6
= _mm_mul_ps(c6_00
,VV
);
870 FF
= _mm_add_ps(Fp
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,_mm_add_ps(Heps
,Heps
))));
871 fvdw6
= _mm_mul_ps(c6_00
,FF
);
873 /* CUBIC SPLINE TABLE REPULSION */
874 vfitab
= _mm_add_epi32(vfitab
,ifour
);
875 Y
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,0) );
876 F
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,1) );
877 G
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,2) );
878 H
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,3) );
879 _MM_TRANSPOSE4_PS(Y
,F
,G
,H
);
880 Heps
= _mm_mul_ps(vfeps
,H
);
881 Fp
= _mm_add_ps(F
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,Heps
)));
882 VV
= _mm_add_ps(Y
,_mm_mul_ps(vfeps
,Fp
));
883 vvdw12
= _mm_mul_ps(c12_00
,VV
);
884 FF
= _mm_add_ps(Fp
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,_mm_add_ps(Heps
,Heps
))));
885 fvdw12
= _mm_mul_ps(c12_00
,FF
);
886 vvdw
= _mm_add_ps(vvdw12
,vvdw6
);
887 fvdw
= _mm_xor_ps(signbit
,_mm_mul_ps(_mm_add_ps(fvdw6
,fvdw12
),_mm_mul_ps(vftabscale
,rinv00
)));
889 /* Update potential sum for this i atom from the interaction with this j atom. */
890 velec
= _mm_andnot_ps(dummy_mask
,velec
);
891 velecsum
= _mm_add_ps(velecsum
,velec
);
892 vvdw
= _mm_andnot_ps(dummy_mask
,vvdw
);
893 vvdwsum
= _mm_add_ps(vvdwsum
,vvdw
);
895 fscal
= _mm_add_ps(felec
,fvdw
);
897 fscal
= _mm_andnot_ps(dummy_mask
,fscal
);
899 /* Calculate temporary vectorial force */
900 tx
= _mm_mul_ps(fscal
,dx00
);
901 ty
= _mm_mul_ps(fscal
,dy00
);
902 tz
= _mm_mul_ps(fscal
,dz00
);
904 /* Update vectorial force */
905 fix0
= _mm_add_ps(fix0
,tx
);
906 fiy0
= _mm_add_ps(fiy0
,ty
);
907 fiz0
= _mm_add_ps(fiz0
,tz
);
909 fjx0
= _mm_add_ps(fjx0
,tx
);
910 fjy0
= _mm_add_ps(fjy0
,ty
);
911 fjz0
= _mm_add_ps(fjz0
,tz
);
913 /**************************
914 * CALCULATE INTERACTIONS *
915 **************************/
917 r01
= _mm_mul_ps(rsq01
,rinv01
);
918 r01
= _mm_andnot_ps(dummy_mask
,r01
);
920 /* EWALD ELECTROSTATICS */
922 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
923 ewrt
= _mm_mul_ps(r01
,ewtabscale
);
924 ewitab
= _mm_cvttps_epi32(ewrt
);
925 eweps
= _mm_sub_ps(ewrt
,_mm_cvtepi32_ps(ewitab
));
926 ewitab
= _mm_slli_epi32(ewitab
,2);
927 ewtabF
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,0) );
928 ewtabD
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,1) );
929 ewtabV
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,2) );
930 ewtabFn
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,3) );
931 _MM_TRANSPOSE4_PS(ewtabF
,ewtabD
,ewtabV
,ewtabFn
);
932 felec
= _mm_add_ps(ewtabF
,_mm_mul_ps(eweps
,ewtabD
));
933 velec
= _mm_sub_ps(ewtabV
,_mm_mul_ps(_mm_mul_ps(ewtabhalfspace
,eweps
),_mm_add_ps(ewtabF
,felec
)));
934 velec
= _mm_mul_ps(qq01
,_mm_sub_ps(rinv01
,velec
));
935 felec
= _mm_mul_ps(_mm_mul_ps(qq01
,rinv01
),_mm_sub_ps(rinvsq01
,felec
));
937 /* Update potential sum for this i atom from the interaction with this j atom. */
938 velec
= _mm_andnot_ps(dummy_mask
,velec
);
939 velecsum
= _mm_add_ps(velecsum
,velec
);
943 fscal
= _mm_andnot_ps(dummy_mask
,fscal
);
945 /* Calculate temporary vectorial force */
946 tx
= _mm_mul_ps(fscal
,dx01
);
947 ty
= _mm_mul_ps(fscal
,dy01
);
948 tz
= _mm_mul_ps(fscal
,dz01
);
950 /* Update vectorial force */
951 fix0
= _mm_add_ps(fix0
,tx
);
952 fiy0
= _mm_add_ps(fiy0
,ty
);
953 fiz0
= _mm_add_ps(fiz0
,tz
);
955 fjx1
= _mm_add_ps(fjx1
,tx
);
956 fjy1
= _mm_add_ps(fjy1
,ty
);
957 fjz1
= _mm_add_ps(fjz1
,tz
);
959 /**************************
960 * CALCULATE INTERACTIONS *
961 **************************/
963 r02
= _mm_mul_ps(rsq02
,rinv02
);
964 r02
= _mm_andnot_ps(dummy_mask
,r02
);
966 /* EWALD ELECTROSTATICS */
968 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
969 ewrt
= _mm_mul_ps(r02
,ewtabscale
);
970 ewitab
= _mm_cvttps_epi32(ewrt
);
971 eweps
= _mm_sub_ps(ewrt
,_mm_cvtepi32_ps(ewitab
));
972 ewitab
= _mm_slli_epi32(ewitab
,2);
973 ewtabF
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,0) );
974 ewtabD
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,1) );
975 ewtabV
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,2) );
976 ewtabFn
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,3) );
977 _MM_TRANSPOSE4_PS(ewtabF
,ewtabD
,ewtabV
,ewtabFn
);
978 felec
= _mm_add_ps(ewtabF
,_mm_mul_ps(eweps
,ewtabD
));
979 velec
= _mm_sub_ps(ewtabV
,_mm_mul_ps(_mm_mul_ps(ewtabhalfspace
,eweps
),_mm_add_ps(ewtabF
,felec
)));
980 velec
= _mm_mul_ps(qq02
,_mm_sub_ps(rinv02
,velec
));
981 felec
= _mm_mul_ps(_mm_mul_ps(qq02
,rinv02
),_mm_sub_ps(rinvsq02
,felec
));
983 /* Update potential sum for this i atom from the interaction with this j atom. */
984 velec
= _mm_andnot_ps(dummy_mask
,velec
);
985 velecsum
= _mm_add_ps(velecsum
,velec
);
989 fscal
= _mm_andnot_ps(dummy_mask
,fscal
);
991 /* Calculate temporary vectorial force */
992 tx
= _mm_mul_ps(fscal
,dx02
);
993 ty
= _mm_mul_ps(fscal
,dy02
);
994 tz
= _mm_mul_ps(fscal
,dz02
);
996 /* Update vectorial force */
997 fix0
= _mm_add_ps(fix0
,tx
);
998 fiy0
= _mm_add_ps(fiy0
,ty
);
999 fiz0
= _mm_add_ps(fiz0
,tz
);
1001 fjx2
= _mm_add_ps(fjx2
,tx
);
1002 fjy2
= _mm_add_ps(fjy2
,ty
);
1003 fjz2
= _mm_add_ps(fjz2
,tz
);
1005 /**************************
1006 * CALCULATE INTERACTIONS *
1007 **************************/
1009 r10
= _mm_mul_ps(rsq10
,rinv10
);
1010 r10
= _mm_andnot_ps(dummy_mask
,r10
);
1012 /* EWALD ELECTROSTATICS */
1014 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1015 ewrt
= _mm_mul_ps(r10
,ewtabscale
);
1016 ewitab
= _mm_cvttps_epi32(ewrt
);
1017 eweps
= _mm_sub_ps(ewrt
,_mm_cvtepi32_ps(ewitab
));
1018 ewitab
= _mm_slli_epi32(ewitab
,2);
1019 ewtabF
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,0) );
1020 ewtabD
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,1) );
1021 ewtabV
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,2) );
1022 ewtabFn
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,3) );
1023 _MM_TRANSPOSE4_PS(ewtabF
,ewtabD
,ewtabV
,ewtabFn
);
1024 felec
= _mm_add_ps(ewtabF
,_mm_mul_ps(eweps
,ewtabD
));
1025 velec
= _mm_sub_ps(ewtabV
,_mm_mul_ps(_mm_mul_ps(ewtabhalfspace
,eweps
),_mm_add_ps(ewtabF
,felec
)));
1026 velec
= _mm_mul_ps(qq10
,_mm_sub_ps(rinv10
,velec
));
1027 felec
= _mm_mul_ps(_mm_mul_ps(qq10
,rinv10
),_mm_sub_ps(rinvsq10
,felec
));
1029 /* Update potential sum for this i atom from the interaction with this j atom. */
1030 velec
= _mm_andnot_ps(dummy_mask
,velec
);
1031 velecsum
= _mm_add_ps(velecsum
,velec
);
1035 fscal
= _mm_andnot_ps(dummy_mask
,fscal
);
1037 /* Calculate temporary vectorial force */
1038 tx
= _mm_mul_ps(fscal
,dx10
);
1039 ty
= _mm_mul_ps(fscal
,dy10
);
1040 tz
= _mm_mul_ps(fscal
,dz10
);
1042 /* Update vectorial force */
1043 fix1
= _mm_add_ps(fix1
,tx
);
1044 fiy1
= _mm_add_ps(fiy1
,ty
);
1045 fiz1
= _mm_add_ps(fiz1
,tz
);
1047 fjx0
= _mm_add_ps(fjx0
,tx
);
1048 fjy0
= _mm_add_ps(fjy0
,ty
);
1049 fjz0
= _mm_add_ps(fjz0
,tz
);
1051 /**************************
1052 * CALCULATE INTERACTIONS *
1053 **************************/
1055 r11
= _mm_mul_ps(rsq11
,rinv11
);
1056 r11
= _mm_andnot_ps(dummy_mask
,r11
);
1058 /* EWALD ELECTROSTATICS */
1060 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1061 ewrt
= _mm_mul_ps(r11
,ewtabscale
);
1062 ewitab
= _mm_cvttps_epi32(ewrt
);
1063 eweps
= _mm_sub_ps(ewrt
,_mm_cvtepi32_ps(ewitab
));
1064 ewitab
= _mm_slli_epi32(ewitab
,2);
1065 ewtabF
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,0) );
1066 ewtabD
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,1) );
1067 ewtabV
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,2) );
1068 ewtabFn
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,3) );
1069 _MM_TRANSPOSE4_PS(ewtabF
,ewtabD
,ewtabV
,ewtabFn
);
1070 felec
= _mm_add_ps(ewtabF
,_mm_mul_ps(eweps
,ewtabD
));
1071 velec
= _mm_sub_ps(ewtabV
,_mm_mul_ps(_mm_mul_ps(ewtabhalfspace
,eweps
),_mm_add_ps(ewtabF
,felec
)));
1072 velec
= _mm_mul_ps(qq11
,_mm_sub_ps(rinv11
,velec
));
1073 felec
= _mm_mul_ps(_mm_mul_ps(qq11
,rinv11
),_mm_sub_ps(rinvsq11
,felec
));
1075 /* Update potential sum for this i atom from the interaction with this j atom. */
1076 velec
= _mm_andnot_ps(dummy_mask
,velec
);
1077 velecsum
= _mm_add_ps(velecsum
,velec
);
1081 fscal
= _mm_andnot_ps(dummy_mask
,fscal
);
1083 /* Calculate temporary vectorial force */
1084 tx
= _mm_mul_ps(fscal
,dx11
);
1085 ty
= _mm_mul_ps(fscal
,dy11
);
1086 tz
= _mm_mul_ps(fscal
,dz11
);
1088 /* Update vectorial force */
1089 fix1
= _mm_add_ps(fix1
,tx
);
1090 fiy1
= _mm_add_ps(fiy1
,ty
);
1091 fiz1
= _mm_add_ps(fiz1
,tz
);
1093 fjx1
= _mm_add_ps(fjx1
,tx
);
1094 fjy1
= _mm_add_ps(fjy1
,ty
);
1095 fjz1
= _mm_add_ps(fjz1
,tz
);
1097 /**************************
1098 * CALCULATE INTERACTIONS *
1099 **************************/
1101 r12
= _mm_mul_ps(rsq12
,rinv12
);
1102 r12
= _mm_andnot_ps(dummy_mask
,r12
);
1104 /* EWALD ELECTROSTATICS */
1106 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1107 ewrt
= _mm_mul_ps(r12
,ewtabscale
);
1108 ewitab
= _mm_cvttps_epi32(ewrt
);
1109 eweps
= _mm_sub_ps(ewrt
,_mm_cvtepi32_ps(ewitab
));
1110 ewitab
= _mm_slli_epi32(ewitab
,2);
1111 ewtabF
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,0) );
1112 ewtabD
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,1) );
1113 ewtabV
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,2) );
1114 ewtabFn
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,3) );
1115 _MM_TRANSPOSE4_PS(ewtabF
,ewtabD
,ewtabV
,ewtabFn
);
1116 felec
= _mm_add_ps(ewtabF
,_mm_mul_ps(eweps
,ewtabD
));
1117 velec
= _mm_sub_ps(ewtabV
,_mm_mul_ps(_mm_mul_ps(ewtabhalfspace
,eweps
),_mm_add_ps(ewtabF
,felec
)));
1118 velec
= _mm_mul_ps(qq12
,_mm_sub_ps(rinv12
,velec
));
1119 felec
= _mm_mul_ps(_mm_mul_ps(qq12
,rinv12
),_mm_sub_ps(rinvsq12
,felec
));
1121 /* Update potential sum for this i atom from the interaction with this j atom. */
1122 velec
= _mm_andnot_ps(dummy_mask
,velec
);
1123 velecsum
= _mm_add_ps(velecsum
,velec
);
1127 fscal
= _mm_andnot_ps(dummy_mask
,fscal
);
1129 /* Calculate temporary vectorial force */
1130 tx
= _mm_mul_ps(fscal
,dx12
);
1131 ty
= _mm_mul_ps(fscal
,dy12
);
1132 tz
= _mm_mul_ps(fscal
,dz12
);
1134 /* Update vectorial force */
1135 fix1
= _mm_add_ps(fix1
,tx
);
1136 fiy1
= _mm_add_ps(fiy1
,ty
);
1137 fiz1
= _mm_add_ps(fiz1
,tz
);
1139 fjx2
= _mm_add_ps(fjx2
,tx
);
1140 fjy2
= _mm_add_ps(fjy2
,ty
);
1141 fjz2
= _mm_add_ps(fjz2
,tz
);
1143 /**************************
1144 * CALCULATE INTERACTIONS *
1145 **************************/
1147 r20
= _mm_mul_ps(rsq20
,rinv20
);
1148 r20
= _mm_andnot_ps(dummy_mask
,r20
);
1150 /* EWALD ELECTROSTATICS */
1152 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1153 ewrt
= _mm_mul_ps(r20
,ewtabscale
);
1154 ewitab
= _mm_cvttps_epi32(ewrt
);
1155 eweps
= _mm_sub_ps(ewrt
,_mm_cvtepi32_ps(ewitab
));
1156 ewitab
= _mm_slli_epi32(ewitab
,2);
1157 ewtabF
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,0) );
1158 ewtabD
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,1) );
1159 ewtabV
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,2) );
1160 ewtabFn
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,3) );
1161 _MM_TRANSPOSE4_PS(ewtabF
,ewtabD
,ewtabV
,ewtabFn
);
1162 felec
= _mm_add_ps(ewtabF
,_mm_mul_ps(eweps
,ewtabD
));
1163 velec
= _mm_sub_ps(ewtabV
,_mm_mul_ps(_mm_mul_ps(ewtabhalfspace
,eweps
),_mm_add_ps(ewtabF
,felec
)));
1164 velec
= _mm_mul_ps(qq20
,_mm_sub_ps(rinv20
,velec
));
1165 felec
= _mm_mul_ps(_mm_mul_ps(qq20
,rinv20
),_mm_sub_ps(rinvsq20
,felec
));
1167 /* Update potential sum for this i atom from the interaction with this j atom. */
1168 velec
= _mm_andnot_ps(dummy_mask
,velec
);
1169 velecsum
= _mm_add_ps(velecsum
,velec
);
1173 fscal
= _mm_andnot_ps(dummy_mask
,fscal
);
1175 /* Calculate temporary vectorial force */
1176 tx
= _mm_mul_ps(fscal
,dx20
);
1177 ty
= _mm_mul_ps(fscal
,dy20
);
1178 tz
= _mm_mul_ps(fscal
,dz20
);
1180 /* Update vectorial force */
1181 fix2
= _mm_add_ps(fix2
,tx
);
1182 fiy2
= _mm_add_ps(fiy2
,ty
);
1183 fiz2
= _mm_add_ps(fiz2
,tz
);
1185 fjx0
= _mm_add_ps(fjx0
,tx
);
1186 fjy0
= _mm_add_ps(fjy0
,ty
);
1187 fjz0
= _mm_add_ps(fjz0
,tz
);
1189 /**************************
1190 * CALCULATE INTERACTIONS *
1191 **************************/
1193 r21
= _mm_mul_ps(rsq21
,rinv21
);
1194 r21
= _mm_andnot_ps(dummy_mask
,r21
);
1196 /* EWALD ELECTROSTATICS */
1198 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1199 ewrt
= _mm_mul_ps(r21
,ewtabscale
);
1200 ewitab
= _mm_cvttps_epi32(ewrt
);
1201 eweps
= _mm_sub_ps(ewrt
,_mm_cvtepi32_ps(ewitab
));
1202 ewitab
= _mm_slli_epi32(ewitab
,2);
1203 ewtabF
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,0) );
1204 ewtabD
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,1) );
1205 ewtabV
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,2) );
1206 ewtabFn
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,3) );
1207 _MM_TRANSPOSE4_PS(ewtabF
,ewtabD
,ewtabV
,ewtabFn
);
1208 felec
= _mm_add_ps(ewtabF
,_mm_mul_ps(eweps
,ewtabD
));
1209 velec
= _mm_sub_ps(ewtabV
,_mm_mul_ps(_mm_mul_ps(ewtabhalfspace
,eweps
),_mm_add_ps(ewtabF
,felec
)));
1210 velec
= _mm_mul_ps(qq21
,_mm_sub_ps(rinv21
,velec
));
1211 felec
= _mm_mul_ps(_mm_mul_ps(qq21
,rinv21
),_mm_sub_ps(rinvsq21
,felec
));
1213 /* Update potential sum for this i atom from the interaction with this j atom. */
1214 velec
= _mm_andnot_ps(dummy_mask
,velec
);
1215 velecsum
= _mm_add_ps(velecsum
,velec
);
1219 fscal
= _mm_andnot_ps(dummy_mask
,fscal
);
1221 /* Calculate temporary vectorial force */
1222 tx
= _mm_mul_ps(fscal
,dx21
);
1223 ty
= _mm_mul_ps(fscal
,dy21
);
1224 tz
= _mm_mul_ps(fscal
,dz21
);
1226 /* Update vectorial force */
1227 fix2
= _mm_add_ps(fix2
,tx
);
1228 fiy2
= _mm_add_ps(fiy2
,ty
);
1229 fiz2
= _mm_add_ps(fiz2
,tz
);
1231 fjx1
= _mm_add_ps(fjx1
,tx
);
1232 fjy1
= _mm_add_ps(fjy1
,ty
);
1233 fjz1
= _mm_add_ps(fjz1
,tz
);
1235 /**************************
1236 * CALCULATE INTERACTIONS *
1237 **************************/
1239 r22
= _mm_mul_ps(rsq22
,rinv22
);
1240 r22
= _mm_andnot_ps(dummy_mask
,r22
);
1242 /* EWALD ELECTROSTATICS */
1244 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1245 ewrt
= _mm_mul_ps(r22
,ewtabscale
);
1246 ewitab
= _mm_cvttps_epi32(ewrt
);
1247 eweps
= _mm_sub_ps(ewrt
,_mm_cvtepi32_ps(ewitab
));
1248 ewitab
= _mm_slli_epi32(ewitab
,2);
1249 ewtabF
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,0) );
1250 ewtabD
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,1) );
1251 ewtabV
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,2) );
1252 ewtabFn
= _mm_load_ps( ewtab
+ gmx_mm_extract_epi32(ewitab
,3) );
1253 _MM_TRANSPOSE4_PS(ewtabF
,ewtabD
,ewtabV
,ewtabFn
);
1254 felec
= _mm_add_ps(ewtabF
,_mm_mul_ps(eweps
,ewtabD
));
1255 velec
= _mm_sub_ps(ewtabV
,_mm_mul_ps(_mm_mul_ps(ewtabhalfspace
,eweps
),_mm_add_ps(ewtabF
,felec
)));
1256 velec
= _mm_mul_ps(qq22
,_mm_sub_ps(rinv22
,velec
));
1257 felec
= _mm_mul_ps(_mm_mul_ps(qq22
,rinv22
),_mm_sub_ps(rinvsq22
,felec
));
1259 /* Update potential sum for this i atom from the interaction with this j atom. */
1260 velec
= _mm_andnot_ps(dummy_mask
,velec
);
1261 velecsum
= _mm_add_ps(velecsum
,velec
);
1265 fscal
= _mm_andnot_ps(dummy_mask
,fscal
);
1267 /* Calculate temporary vectorial force */
1268 tx
= _mm_mul_ps(fscal
,dx22
);
1269 ty
= _mm_mul_ps(fscal
,dy22
);
1270 tz
= _mm_mul_ps(fscal
,dz22
);
1272 /* Update vectorial force */
1273 fix2
= _mm_add_ps(fix2
,tx
);
1274 fiy2
= _mm_add_ps(fiy2
,ty
);
1275 fiz2
= _mm_add_ps(fiz2
,tz
);
1277 fjx2
= _mm_add_ps(fjx2
,tx
);
1278 fjy2
= _mm_add_ps(fjy2
,ty
);
1279 fjz2
= _mm_add_ps(fjz2
,tz
);
1281 fjptrA
= (jnrlistA
>=0) ? f
+j_coord_offsetA
: scratch
;
1282 fjptrB
= (jnrlistB
>=0) ? f
+j_coord_offsetB
: scratch
;
1283 fjptrC
= (jnrlistC
>=0) ? f
+j_coord_offsetC
: scratch
;
1284 fjptrD
= (jnrlistD
>=0) ? f
+j_coord_offsetD
: scratch
;
1286 gmx_mm_decrement_3rvec_4ptr_swizzle_ps(fjptrA
,fjptrB
,fjptrC
,fjptrD
,
1287 fjx0
,fjy0
,fjz0
,fjx1
,fjy1
,fjz1
,fjx2
,fjy2
,fjz2
);
1289 /* Inner loop uses 412 flops */
1292 /* End of innermost loop */
1294 gmx_mm_update_iforce_3atom_swizzle_ps(fix0
,fiy0
,fiz0
,fix1
,fiy1
,fiz1
,fix2
,fiy2
,fiz2
,
1295 f
+i_coord_offset
,fshift
+i_shift_offset
);
1298 /* Update potential energies */
1299 gmx_mm_update_1pot_ps(velecsum
,kernel_data
->energygrp_elec
+ggid
);
1300 gmx_mm_update_1pot_ps(vvdwsum
,kernel_data
->energygrp_vdw
+ggid
);
1302 /* Increment number of inner iterations */
1303 inneriter
+= j_index_end
- j_index_start
;
1305 /* Outer loop uses 20 flops */
1308 /* Increment number of outer iterations */
1311 /* Update outer/inner flops */
1313 inc_nrnb(nrnb
,eNR_NBKERNEL_ELEC_VDW_W3W3_VF
,outeriter
*20 + inneriter
*412);
1316 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwCSTab_GeomW3W3_F_sse2_single
1317 * Electrostatics interaction: Ewald
1318 * VdW interaction: CubicSplineTable
1319 * Geometry: Water3-Water3
1320 * Calculate force/pot: Force
1323 nb_kernel_ElecEw_VdwCSTab_GeomW3W3_F_sse2_single
1324 (t_nblist
* gmx_restrict nlist
,
1325 rvec
* gmx_restrict xx
,
1326 rvec
* gmx_restrict ff
,
1327 t_forcerec
* gmx_restrict fr
,
1328 t_mdatoms
* gmx_restrict mdatoms
,
1329 nb_kernel_data_t gmx_unused
* gmx_restrict kernel_data
,
1330 t_nrnb
* gmx_restrict nrnb
)
1332 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
1333 * just 0 for non-waters.
1334 * Suffixes A,B,C,D refer to j loop unrolling done with SSE, e.g. for the four different
1335 * jnr indices corresponding to data put in the four positions in the SIMD register.
1337 int i_shift_offset
,i_coord_offset
,outeriter
,inneriter
;
1338 int j_index_start
,j_index_end
,jidx
,nri
,inr
,ggid
,iidx
;
1339 int jnrA
,jnrB
,jnrC
,jnrD
;
1340 int jnrlistA
,jnrlistB
,jnrlistC
,jnrlistD
;
1341 int j_coord_offsetA
,j_coord_offsetB
,j_coord_offsetC
,j_coord_offsetD
;
1342 int *iinr
,*jindex
,*jjnr
,*shiftidx
,*gid
;
1343 real rcutoff_scalar
;
1344 real
*shiftvec
,*fshift
,*x
,*f
;
1345 real
*fjptrA
,*fjptrB
,*fjptrC
,*fjptrD
;
1346 real scratch
[4*DIM
];
1347 __m128 tx
,ty
,tz
,fscal
,rcutoff
,rcutoff2
,jidxall
;
1349 __m128 ix0
,iy0
,iz0
,fix0
,fiy0
,fiz0
,iq0
,isai0
;
1351 __m128 ix1
,iy1
,iz1
,fix1
,fiy1
,fiz1
,iq1
,isai1
;
1353 __m128 ix2
,iy2
,iz2
,fix2
,fiy2
,fiz2
,iq2
,isai2
;
1354 int vdwjidx0A
,vdwjidx0B
,vdwjidx0C
,vdwjidx0D
;
1355 __m128 jx0
,jy0
,jz0
,fjx0
,fjy0
,fjz0
,jq0
,isaj0
;
1356 int vdwjidx1A
,vdwjidx1B
,vdwjidx1C
,vdwjidx1D
;
1357 __m128 jx1
,jy1
,jz1
,fjx1
,fjy1
,fjz1
,jq1
,isaj1
;
1358 int vdwjidx2A
,vdwjidx2B
,vdwjidx2C
,vdwjidx2D
;
1359 __m128 jx2
,jy2
,jz2
,fjx2
,fjy2
,fjz2
,jq2
,isaj2
;
1360 __m128 dx00
,dy00
,dz00
,rsq00
,rinv00
,rinvsq00
,r00
,qq00
,c6_00
,c12_00
;
1361 __m128 dx01
,dy01
,dz01
,rsq01
,rinv01
,rinvsq01
,r01
,qq01
,c6_01
,c12_01
;
1362 __m128 dx02
,dy02
,dz02
,rsq02
,rinv02
,rinvsq02
,r02
,qq02
,c6_02
,c12_02
;
1363 __m128 dx10
,dy10
,dz10
,rsq10
,rinv10
,rinvsq10
,r10
,qq10
,c6_10
,c12_10
;
1364 __m128 dx11
,dy11
,dz11
,rsq11
,rinv11
,rinvsq11
,r11
,qq11
,c6_11
,c12_11
;
1365 __m128 dx12
,dy12
,dz12
,rsq12
,rinv12
,rinvsq12
,r12
,qq12
,c6_12
,c12_12
;
1366 __m128 dx20
,dy20
,dz20
,rsq20
,rinv20
,rinvsq20
,r20
,qq20
,c6_20
,c12_20
;
1367 __m128 dx21
,dy21
,dz21
,rsq21
,rinv21
,rinvsq21
,r21
,qq21
,c6_21
,c12_21
;
1368 __m128 dx22
,dy22
,dz22
,rsq22
,rinv22
,rinvsq22
,r22
,qq22
,c6_22
,c12_22
;
1369 __m128 velec
,felec
,velecsum
,facel
,crf
,krf
,krf2
;
1372 __m128 rinvsix
,rvdw
,vvdw
,vvdw6
,vvdw12
,fvdw
,fvdw6
,fvdw12
,vvdwsum
,sh_vdw_invrcut6
;
1375 __m128 one_sixth
= _mm_set1_ps(1.0/6.0);
1376 __m128 one_twelfth
= _mm_set1_ps(1.0/12.0);
1378 __m128i ifour
= _mm_set1_epi32(4);
1379 __m128 rt
,vfeps
,vftabscale
,Y
,F
,G
,H
,Heps
,Fp
,VV
,FF
;
1382 __m128 ewtabscale
,eweps
,sh_ewald
,ewrt
,ewtabhalfspace
,ewtabF
,ewtabFn
,ewtabD
,ewtabV
;
1384 __m128 dummy_mask
,cutoff_mask
;
1385 __m128 signbit
= _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
1386 __m128 one
= _mm_set1_ps(1.0);
1387 __m128 two
= _mm_set1_ps(2.0);
1393 jindex
= nlist
->jindex
;
1395 shiftidx
= nlist
->shift
;
1397 shiftvec
= fr
->shift_vec
[0];
1398 fshift
= fr
->fshift
[0];
1399 facel
= _mm_set1_ps(fr
->epsfac
);
1400 charge
= mdatoms
->chargeA
;
1401 nvdwtype
= fr
->ntype
;
1402 vdwparam
= fr
->nbfp
;
1403 vdwtype
= mdatoms
->typeA
;
1405 vftab
= kernel_data
->table_vdw
->data
;
1406 vftabscale
= _mm_set1_ps(kernel_data
->table_vdw
->scale
);
1408 sh_ewald
= _mm_set1_ps(fr
->ic
->sh_ewald
);
1409 ewtab
= fr
->ic
->tabq_coul_F
;
1410 ewtabscale
= _mm_set1_ps(fr
->ic
->tabq_scale
);
1411 ewtabhalfspace
= _mm_set1_ps(0.5/fr
->ic
->tabq_scale
);
1413 /* Setup water-specific parameters */
1414 inr
= nlist
->iinr
[0];
1415 iq0
= _mm_mul_ps(facel
,_mm_set1_ps(charge
[inr
+0]));
1416 iq1
= _mm_mul_ps(facel
,_mm_set1_ps(charge
[inr
+1]));
1417 iq2
= _mm_mul_ps(facel
,_mm_set1_ps(charge
[inr
+2]));
1418 vdwioffset0
= 2*nvdwtype
*vdwtype
[inr
+0];
1420 jq0
= _mm_set1_ps(charge
[inr
+0]);
1421 jq1
= _mm_set1_ps(charge
[inr
+1]);
1422 jq2
= _mm_set1_ps(charge
[inr
+2]);
1423 vdwjidx0A
= 2*vdwtype
[inr
+0];
1424 qq00
= _mm_mul_ps(iq0
,jq0
);
1425 c6_00
= _mm_set1_ps(vdwparam
[vdwioffset0
+vdwjidx0A
]);
1426 c12_00
= _mm_set1_ps(vdwparam
[vdwioffset0
+vdwjidx0A
+1]);
1427 qq01
= _mm_mul_ps(iq0
,jq1
);
1428 qq02
= _mm_mul_ps(iq0
,jq2
);
1429 qq10
= _mm_mul_ps(iq1
,jq0
);
1430 qq11
= _mm_mul_ps(iq1
,jq1
);
1431 qq12
= _mm_mul_ps(iq1
,jq2
);
1432 qq20
= _mm_mul_ps(iq2
,jq0
);
1433 qq21
= _mm_mul_ps(iq2
,jq1
);
1434 qq22
= _mm_mul_ps(iq2
,jq2
);
1436 /* Avoid stupid compiler warnings */
1437 jnrA
= jnrB
= jnrC
= jnrD
= 0;
1438 j_coord_offsetA
= 0;
1439 j_coord_offsetB
= 0;
1440 j_coord_offsetC
= 0;
1441 j_coord_offsetD
= 0;
1446 for(iidx
=0;iidx
<4*DIM
;iidx
++)
1448 scratch
[iidx
] = 0.0;
1451 /* Start outer loop over neighborlists */
1452 for(iidx
=0; iidx
<nri
; iidx
++)
1454 /* Load shift vector for this list */
1455 i_shift_offset
= DIM
*shiftidx
[iidx
];
1457 /* Load limits for loop over neighbors */
1458 j_index_start
= jindex
[iidx
];
1459 j_index_end
= jindex
[iidx
+1];
1461 /* Get outer coordinate index */
1463 i_coord_offset
= DIM
*inr
;
1465 /* Load i particle coords and add shift vector */
1466 gmx_mm_load_shift_and_3rvec_broadcast_ps(shiftvec
+i_shift_offset
,x
+i_coord_offset
,
1467 &ix0
,&iy0
,&iz0
,&ix1
,&iy1
,&iz1
,&ix2
,&iy2
,&iz2
);
1469 fix0
= _mm_setzero_ps();
1470 fiy0
= _mm_setzero_ps();
1471 fiz0
= _mm_setzero_ps();
1472 fix1
= _mm_setzero_ps();
1473 fiy1
= _mm_setzero_ps();
1474 fiz1
= _mm_setzero_ps();
1475 fix2
= _mm_setzero_ps();
1476 fiy2
= _mm_setzero_ps();
1477 fiz2
= _mm_setzero_ps();
1479 /* Start inner kernel loop */
1480 for(jidx
=j_index_start
; jidx
<j_index_end
&& jjnr
[jidx
+3]>=0; jidx
+=4)
1483 /* Get j neighbor index, and coordinate index */
1485 jnrB
= jjnr
[jidx
+1];
1486 jnrC
= jjnr
[jidx
+2];
1487 jnrD
= jjnr
[jidx
+3];
1488 j_coord_offsetA
= DIM
*jnrA
;
1489 j_coord_offsetB
= DIM
*jnrB
;
1490 j_coord_offsetC
= DIM
*jnrC
;
1491 j_coord_offsetD
= DIM
*jnrD
;
1493 /* load j atom coordinates */
1494 gmx_mm_load_3rvec_4ptr_swizzle_ps(x
+j_coord_offsetA
,x
+j_coord_offsetB
,
1495 x
+j_coord_offsetC
,x
+j_coord_offsetD
,
1496 &jx0
,&jy0
,&jz0
,&jx1
,&jy1
,&jz1
,&jx2
,&jy2
,&jz2
);
1498 /* Calculate displacement vector */
1499 dx00
= _mm_sub_ps(ix0
,jx0
);
1500 dy00
= _mm_sub_ps(iy0
,jy0
);
1501 dz00
= _mm_sub_ps(iz0
,jz0
);
1502 dx01
= _mm_sub_ps(ix0
,jx1
);
1503 dy01
= _mm_sub_ps(iy0
,jy1
);
1504 dz01
= _mm_sub_ps(iz0
,jz1
);
1505 dx02
= _mm_sub_ps(ix0
,jx2
);
1506 dy02
= _mm_sub_ps(iy0
,jy2
);
1507 dz02
= _mm_sub_ps(iz0
,jz2
);
1508 dx10
= _mm_sub_ps(ix1
,jx0
);
1509 dy10
= _mm_sub_ps(iy1
,jy0
);
1510 dz10
= _mm_sub_ps(iz1
,jz0
);
1511 dx11
= _mm_sub_ps(ix1
,jx1
);
1512 dy11
= _mm_sub_ps(iy1
,jy1
);
1513 dz11
= _mm_sub_ps(iz1
,jz1
);
1514 dx12
= _mm_sub_ps(ix1
,jx2
);
1515 dy12
= _mm_sub_ps(iy1
,jy2
);
1516 dz12
= _mm_sub_ps(iz1
,jz2
);
1517 dx20
= _mm_sub_ps(ix2
,jx0
);
1518 dy20
= _mm_sub_ps(iy2
,jy0
);
1519 dz20
= _mm_sub_ps(iz2
,jz0
);
1520 dx21
= _mm_sub_ps(ix2
,jx1
);
1521 dy21
= _mm_sub_ps(iy2
,jy1
);
1522 dz21
= _mm_sub_ps(iz2
,jz1
);
1523 dx22
= _mm_sub_ps(ix2
,jx2
);
1524 dy22
= _mm_sub_ps(iy2
,jy2
);
1525 dz22
= _mm_sub_ps(iz2
,jz2
);
1527 /* Calculate squared distance and things based on it */
1528 rsq00
= gmx_mm_calc_rsq_ps(dx00
,dy00
,dz00
);
1529 rsq01
= gmx_mm_calc_rsq_ps(dx01
,dy01
,dz01
);
1530 rsq02
= gmx_mm_calc_rsq_ps(dx02
,dy02
,dz02
);
1531 rsq10
= gmx_mm_calc_rsq_ps(dx10
,dy10
,dz10
);
1532 rsq11
= gmx_mm_calc_rsq_ps(dx11
,dy11
,dz11
);
1533 rsq12
= gmx_mm_calc_rsq_ps(dx12
,dy12
,dz12
);
1534 rsq20
= gmx_mm_calc_rsq_ps(dx20
,dy20
,dz20
);
1535 rsq21
= gmx_mm_calc_rsq_ps(dx21
,dy21
,dz21
);
1536 rsq22
= gmx_mm_calc_rsq_ps(dx22
,dy22
,dz22
);
1538 rinv00
= gmx_mm_invsqrt_ps(rsq00
);
1539 rinv01
= gmx_mm_invsqrt_ps(rsq01
);
1540 rinv02
= gmx_mm_invsqrt_ps(rsq02
);
1541 rinv10
= gmx_mm_invsqrt_ps(rsq10
);
1542 rinv11
= gmx_mm_invsqrt_ps(rsq11
);
1543 rinv12
= gmx_mm_invsqrt_ps(rsq12
);
1544 rinv20
= gmx_mm_invsqrt_ps(rsq20
);
1545 rinv21
= gmx_mm_invsqrt_ps(rsq21
);
1546 rinv22
= gmx_mm_invsqrt_ps(rsq22
);
1548 rinvsq00
= _mm_mul_ps(rinv00
,rinv00
);
1549 rinvsq01
= _mm_mul_ps(rinv01
,rinv01
);
1550 rinvsq02
= _mm_mul_ps(rinv02
,rinv02
);
1551 rinvsq10
= _mm_mul_ps(rinv10
,rinv10
);
1552 rinvsq11
= _mm_mul_ps(rinv11
,rinv11
);
1553 rinvsq12
= _mm_mul_ps(rinv12
,rinv12
);
1554 rinvsq20
= _mm_mul_ps(rinv20
,rinv20
);
1555 rinvsq21
= _mm_mul_ps(rinv21
,rinv21
);
1556 rinvsq22
= _mm_mul_ps(rinv22
,rinv22
);
1558 fjx0
= _mm_setzero_ps();
1559 fjy0
= _mm_setzero_ps();
1560 fjz0
= _mm_setzero_ps();
1561 fjx1
= _mm_setzero_ps();
1562 fjy1
= _mm_setzero_ps();
1563 fjz1
= _mm_setzero_ps();
1564 fjx2
= _mm_setzero_ps();
1565 fjy2
= _mm_setzero_ps();
1566 fjz2
= _mm_setzero_ps();
1568 /**************************
1569 * CALCULATE INTERACTIONS *
1570 **************************/
1572 r00
= _mm_mul_ps(rsq00
,rinv00
);
1574 /* Calculate table index by multiplying r with table scale and truncate to integer */
1575 rt
= _mm_mul_ps(r00
,vftabscale
);
1576 vfitab
= _mm_cvttps_epi32(rt
);
1577 vfeps
= _mm_sub_ps(rt
,_mm_cvtepi32_ps(vfitab
));
1578 vfitab
= _mm_slli_epi32(vfitab
,3);
1580 /* EWALD ELECTROSTATICS */
1582 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1583 ewrt
= _mm_mul_ps(r00
,ewtabscale
);
1584 ewitab
= _mm_cvttps_epi32(ewrt
);
1585 eweps
= _mm_sub_ps(ewrt
,_mm_cvtepi32_ps(ewitab
));
1586 gmx_mm_load_4pair_swizzle_ps(ewtab
+gmx_mm_extract_epi32(ewitab
,0),ewtab
+gmx_mm_extract_epi32(ewitab
,1),
1587 ewtab
+gmx_mm_extract_epi32(ewitab
,2),ewtab
+gmx_mm_extract_epi32(ewitab
,3),
1589 felec
= _mm_add_ps(_mm_mul_ps( _mm_sub_ps(one
,eweps
),ewtabF
),_mm_mul_ps(eweps
,ewtabFn
));
1590 felec
= _mm_mul_ps(_mm_mul_ps(qq00
,rinv00
),_mm_sub_ps(rinvsq00
,felec
));
1592 /* CUBIC SPLINE TABLE DISPERSION */
1593 Y
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,0) );
1594 F
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,1) );
1595 G
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,2) );
1596 H
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,3) );
1597 _MM_TRANSPOSE4_PS(Y
,F
,G
,H
);
1598 Heps
= _mm_mul_ps(vfeps
,H
);
1599 Fp
= _mm_add_ps(F
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,Heps
)));
1600 FF
= _mm_add_ps(Fp
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,_mm_add_ps(Heps
,Heps
))));
1601 fvdw6
= _mm_mul_ps(c6_00
,FF
);
1603 /* CUBIC SPLINE TABLE REPULSION */
1604 vfitab
= _mm_add_epi32(vfitab
,ifour
);
1605 Y
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,0) );
1606 F
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,1) );
1607 G
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,2) );
1608 H
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,3) );
1609 _MM_TRANSPOSE4_PS(Y
,F
,G
,H
);
1610 Heps
= _mm_mul_ps(vfeps
,H
);
1611 Fp
= _mm_add_ps(F
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,Heps
)));
1612 FF
= _mm_add_ps(Fp
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,_mm_add_ps(Heps
,Heps
))));
1613 fvdw12
= _mm_mul_ps(c12_00
,FF
);
1614 fvdw
= _mm_xor_ps(signbit
,_mm_mul_ps(_mm_add_ps(fvdw6
,fvdw12
),_mm_mul_ps(vftabscale
,rinv00
)));
1616 fscal
= _mm_add_ps(felec
,fvdw
);
1618 /* Calculate temporary vectorial force */
1619 tx
= _mm_mul_ps(fscal
,dx00
);
1620 ty
= _mm_mul_ps(fscal
,dy00
);
1621 tz
= _mm_mul_ps(fscal
,dz00
);
1623 /* Update vectorial force */
1624 fix0
= _mm_add_ps(fix0
,tx
);
1625 fiy0
= _mm_add_ps(fiy0
,ty
);
1626 fiz0
= _mm_add_ps(fiz0
,tz
);
1628 fjx0
= _mm_add_ps(fjx0
,tx
);
1629 fjy0
= _mm_add_ps(fjy0
,ty
);
1630 fjz0
= _mm_add_ps(fjz0
,tz
);
1632 /**************************
1633 * CALCULATE INTERACTIONS *
1634 **************************/
1636 r01
= _mm_mul_ps(rsq01
,rinv01
);
1638 /* EWALD ELECTROSTATICS */
1640 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1641 ewrt
= _mm_mul_ps(r01
,ewtabscale
);
1642 ewitab
= _mm_cvttps_epi32(ewrt
);
1643 eweps
= _mm_sub_ps(ewrt
,_mm_cvtepi32_ps(ewitab
));
1644 gmx_mm_load_4pair_swizzle_ps(ewtab
+gmx_mm_extract_epi32(ewitab
,0),ewtab
+gmx_mm_extract_epi32(ewitab
,1),
1645 ewtab
+gmx_mm_extract_epi32(ewitab
,2),ewtab
+gmx_mm_extract_epi32(ewitab
,3),
1647 felec
= _mm_add_ps(_mm_mul_ps( _mm_sub_ps(one
,eweps
),ewtabF
),_mm_mul_ps(eweps
,ewtabFn
));
1648 felec
= _mm_mul_ps(_mm_mul_ps(qq01
,rinv01
),_mm_sub_ps(rinvsq01
,felec
));
1652 /* Calculate temporary vectorial force */
1653 tx
= _mm_mul_ps(fscal
,dx01
);
1654 ty
= _mm_mul_ps(fscal
,dy01
);
1655 tz
= _mm_mul_ps(fscal
,dz01
);
1657 /* Update vectorial force */
1658 fix0
= _mm_add_ps(fix0
,tx
);
1659 fiy0
= _mm_add_ps(fiy0
,ty
);
1660 fiz0
= _mm_add_ps(fiz0
,tz
);
1662 fjx1
= _mm_add_ps(fjx1
,tx
);
1663 fjy1
= _mm_add_ps(fjy1
,ty
);
1664 fjz1
= _mm_add_ps(fjz1
,tz
);
1666 /**************************
1667 * CALCULATE INTERACTIONS *
1668 **************************/
1670 r02
= _mm_mul_ps(rsq02
,rinv02
);
1672 /* EWALD ELECTROSTATICS */
1674 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1675 ewrt
= _mm_mul_ps(r02
,ewtabscale
);
1676 ewitab
= _mm_cvttps_epi32(ewrt
);
1677 eweps
= _mm_sub_ps(ewrt
,_mm_cvtepi32_ps(ewitab
));
1678 gmx_mm_load_4pair_swizzle_ps(ewtab
+gmx_mm_extract_epi32(ewitab
,0),ewtab
+gmx_mm_extract_epi32(ewitab
,1),
1679 ewtab
+gmx_mm_extract_epi32(ewitab
,2),ewtab
+gmx_mm_extract_epi32(ewitab
,3),
1681 felec
= _mm_add_ps(_mm_mul_ps( _mm_sub_ps(one
,eweps
),ewtabF
),_mm_mul_ps(eweps
,ewtabFn
));
1682 felec
= _mm_mul_ps(_mm_mul_ps(qq02
,rinv02
),_mm_sub_ps(rinvsq02
,felec
));
1686 /* Calculate temporary vectorial force */
1687 tx
= _mm_mul_ps(fscal
,dx02
);
1688 ty
= _mm_mul_ps(fscal
,dy02
);
1689 tz
= _mm_mul_ps(fscal
,dz02
);
1691 /* Update vectorial force */
1692 fix0
= _mm_add_ps(fix0
,tx
);
1693 fiy0
= _mm_add_ps(fiy0
,ty
);
1694 fiz0
= _mm_add_ps(fiz0
,tz
);
1696 fjx2
= _mm_add_ps(fjx2
,tx
);
1697 fjy2
= _mm_add_ps(fjy2
,ty
);
1698 fjz2
= _mm_add_ps(fjz2
,tz
);
1700 /**************************
1701 * CALCULATE INTERACTIONS *
1702 **************************/
1704 r10
= _mm_mul_ps(rsq10
,rinv10
);
1706 /* EWALD ELECTROSTATICS */
1708 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1709 ewrt
= _mm_mul_ps(r10
,ewtabscale
);
1710 ewitab
= _mm_cvttps_epi32(ewrt
);
1711 eweps
= _mm_sub_ps(ewrt
,_mm_cvtepi32_ps(ewitab
));
1712 gmx_mm_load_4pair_swizzle_ps(ewtab
+gmx_mm_extract_epi32(ewitab
,0),ewtab
+gmx_mm_extract_epi32(ewitab
,1),
1713 ewtab
+gmx_mm_extract_epi32(ewitab
,2),ewtab
+gmx_mm_extract_epi32(ewitab
,3),
1715 felec
= _mm_add_ps(_mm_mul_ps( _mm_sub_ps(one
,eweps
),ewtabF
),_mm_mul_ps(eweps
,ewtabFn
));
1716 felec
= _mm_mul_ps(_mm_mul_ps(qq10
,rinv10
),_mm_sub_ps(rinvsq10
,felec
));
1720 /* Calculate temporary vectorial force */
1721 tx
= _mm_mul_ps(fscal
,dx10
);
1722 ty
= _mm_mul_ps(fscal
,dy10
);
1723 tz
= _mm_mul_ps(fscal
,dz10
);
1725 /* Update vectorial force */
1726 fix1
= _mm_add_ps(fix1
,tx
);
1727 fiy1
= _mm_add_ps(fiy1
,ty
);
1728 fiz1
= _mm_add_ps(fiz1
,tz
);
1730 fjx0
= _mm_add_ps(fjx0
,tx
);
1731 fjy0
= _mm_add_ps(fjy0
,ty
);
1732 fjz0
= _mm_add_ps(fjz0
,tz
);
1734 /**************************
1735 * CALCULATE INTERACTIONS *
1736 **************************/
1738 r11
= _mm_mul_ps(rsq11
,rinv11
);
1740 /* EWALD ELECTROSTATICS */
1742 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1743 ewrt
= _mm_mul_ps(r11
,ewtabscale
);
1744 ewitab
= _mm_cvttps_epi32(ewrt
);
1745 eweps
= _mm_sub_ps(ewrt
,_mm_cvtepi32_ps(ewitab
));
1746 gmx_mm_load_4pair_swizzle_ps(ewtab
+gmx_mm_extract_epi32(ewitab
,0),ewtab
+gmx_mm_extract_epi32(ewitab
,1),
1747 ewtab
+gmx_mm_extract_epi32(ewitab
,2),ewtab
+gmx_mm_extract_epi32(ewitab
,3),
1749 felec
= _mm_add_ps(_mm_mul_ps( _mm_sub_ps(one
,eweps
),ewtabF
),_mm_mul_ps(eweps
,ewtabFn
));
1750 felec
= _mm_mul_ps(_mm_mul_ps(qq11
,rinv11
),_mm_sub_ps(rinvsq11
,felec
));
1754 /* Calculate temporary vectorial force */
1755 tx
= _mm_mul_ps(fscal
,dx11
);
1756 ty
= _mm_mul_ps(fscal
,dy11
);
1757 tz
= _mm_mul_ps(fscal
,dz11
);
1759 /* Update vectorial force */
1760 fix1
= _mm_add_ps(fix1
,tx
);
1761 fiy1
= _mm_add_ps(fiy1
,ty
);
1762 fiz1
= _mm_add_ps(fiz1
,tz
);
1764 fjx1
= _mm_add_ps(fjx1
,tx
);
1765 fjy1
= _mm_add_ps(fjy1
,ty
);
1766 fjz1
= _mm_add_ps(fjz1
,tz
);
1768 /**************************
1769 * CALCULATE INTERACTIONS *
1770 **************************/
1772 r12
= _mm_mul_ps(rsq12
,rinv12
);
1774 /* EWALD ELECTROSTATICS */
1776 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1777 ewrt
= _mm_mul_ps(r12
,ewtabscale
);
1778 ewitab
= _mm_cvttps_epi32(ewrt
);
1779 eweps
= _mm_sub_ps(ewrt
,_mm_cvtepi32_ps(ewitab
));
1780 gmx_mm_load_4pair_swizzle_ps(ewtab
+gmx_mm_extract_epi32(ewitab
,0),ewtab
+gmx_mm_extract_epi32(ewitab
,1),
1781 ewtab
+gmx_mm_extract_epi32(ewitab
,2),ewtab
+gmx_mm_extract_epi32(ewitab
,3),
1783 felec
= _mm_add_ps(_mm_mul_ps( _mm_sub_ps(one
,eweps
),ewtabF
),_mm_mul_ps(eweps
,ewtabFn
));
1784 felec
= _mm_mul_ps(_mm_mul_ps(qq12
,rinv12
),_mm_sub_ps(rinvsq12
,felec
));
1788 /* Calculate temporary vectorial force */
1789 tx
= _mm_mul_ps(fscal
,dx12
);
1790 ty
= _mm_mul_ps(fscal
,dy12
);
1791 tz
= _mm_mul_ps(fscal
,dz12
);
1793 /* Update vectorial force */
1794 fix1
= _mm_add_ps(fix1
,tx
);
1795 fiy1
= _mm_add_ps(fiy1
,ty
);
1796 fiz1
= _mm_add_ps(fiz1
,tz
);
1798 fjx2
= _mm_add_ps(fjx2
,tx
);
1799 fjy2
= _mm_add_ps(fjy2
,ty
);
1800 fjz2
= _mm_add_ps(fjz2
,tz
);
1802 /**************************
1803 * CALCULATE INTERACTIONS *
1804 **************************/
1806 r20
= _mm_mul_ps(rsq20
,rinv20
);
1808 /* EWALD ELECTROSTATICS */
1810 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1811 ewrt
= _mm_mul_ps(r20
,ewtabscale
);
1812 ewitab
= _mm_cvttps_epi32(ewrt
);
1813 eweps
= _mm_sub_ps(ewrt
,_mm_cvtepi32_ps(ewitab
));
1814 gmx_mm_load_4pair_swizzle_ps(ewtab
+gmx_mm_extract_epi32(ewitab
,0),ewtab
+gmx_mm_extract_epi32(ewitab
,1),
1815 ewtab
+gmx_mm_extract_epi32(ewitab
,2),ewtab
+gmx_mm_extract_epi32(ewitab
,3),
1817 felec
= _mm_add_ps(_mm_mul_ps( _mm_sub_ps(one
,eweps
),ewtabF
),_mm_mul_ps(eweps
,ewtabFn
));
1818 felec
= _mm_mul_ps(_mm_mul_ps(qq20
,rinv20
),_mm_sub_ps(rinvsq20
,felec
));
1822 /* Calculate temporary vectorial force */
1823 tx
= _mm_mul_ps(fscal
,dx20
);
1824 ty
= _mm_mul_ps(fscal
,dy20
);
1825 tz
= _mm_mul_ps(fscal
,dz20
);
1827 /* Update vectorial force */
1828 fix2
= _mm_add_ps(fix2
,tx
);
1829 fiy2
= _mm_add_ps(fiy2
,ty
);
1830 fiz2
= _mm_add_ps(fiz2
,tz
);
1832 fjx0
= _mm_add_ps(fjx0
,tx
);
1833 fjy0
= _mm_add_ps(fjy0
,ty
);
1834 fjz0
= _mm_add_ps(fjz0
,tz
);
1836 /**************************
1837 * CALCULATE INTERACTIONS *
1838 **************************/
1840 r21
= _mm_mul_ps(rsq21
,rinv21
);
1842 /* EWALD ELECTROSTATICS */
1844 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1845 ewrt
= _mm_mul_ps(r21
,ewtabscale
);
1846 ewitab
= _mm_cvttps_epi32(ewrt
);
1847 eweps
= _mm_sub_ps(ewrt
,_mm_cvtepi32_ps(ewitab
));
1848 gmx_mm_load_4pair_swizzle_ps(ewtab
+gmx_mm_extract_epi32(ewitab
,0),ewtab
+gmx_mm_extract_epi32(ewitab
,1),
1849 ewtab
+gmx_mm_extract_epi32(ewitab
,2),ewtab
+gmx_mm_extract_epi32(ewitab
,3),
1851 felec
= _mm_add_ps(_mm_mul_ps( _mm_sub_ps(one
,eweps
),ewtabF
),_mm_mul_ps(eweps
,ewtabFn
));
1852 felec
= _mm_mul_ps(_mm_mul_ps(qq21
,rinv21
),_mm_sub_ps(rinvsq21
,felec
));
1856 /* Calculate temporary vectorial force */
1857 tx
= _mm_mul_ps(fscal
,dx21
);
1858 ty
= _mm_mul_ps(fscal
,dy21
);
1859 tz
= _mm_mul_ps(fscal
,dz21
);
1861 /* Update vectorial force */
1862 fix2
= _mm_add_ps(fix2
,tx
);
1863 fiy2
= _mm_add_ps(fiy2
,ty
);
1864 fiz2
= _mm_add_ps(fiz2
,tz
);
1866 fjx1
= _mm_add_ps(fjx1
,tx
);
1867 fjy1
= _mm_add_ps(fjy1
,ty
);
1868 fjz1
= _mm_add_ps(fjz1
,tz
);
1870 /**************************
1871 * CALCULATE INTERACTIONS *
1872 **************************/
1874 r22
= _mm_mul_ps(rsq22
,rinv22
);
1876 /* EWALD ELECTROSTATICS */
1878 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1879 ewrt
= _mm_mul_ps(r22
,ewtabscale
);
1880 ewitab
= _mm_cvttps_epi32(ewrt
);
1881 eweps
= _mm_sub_ps(ewrt
,_mm_cvtepi32_ps(ewitab
));
1882 gmx_mm_load_4pair_swizzle_ps(ewtab
+gmx_mm_extract_epi32(ewitab
,0),ewtab
+gmx_mm_extract_epi32(ewitab
,1),
1883 ewtab
+gmx_mm_extract_epi32(ewitab
,2),ewtab
+gmx_mm_extract_epi32(ewitab
,3),
1885 felec
= _mm_add_ps(_mm_mul_ps( _mm_sub_ps(one
,eweps
),ewtabF
),_mm_mul_ps(eweps
,ewtabFn
));
1886 felec
= _mm_mul_ps(_mm_mul_ps(qq22
,rinv22
),_mm_sub_ps(rinvsq22
,felec
));
1890 /* Calculate temporary vectorial force */
1891 tx
= _mm_mul_ps(fscal
,dx22
);
1892 ty
= _mm_mul_ps(fscal
,dy22
);
1893 tz
= _mm_mul_ps(fscal
,dz22
);
1895 /* Update vectorial force */
1896 fix2
= _mm_add_ps(fix2
,tx
);
1897 fiy2
= _mm_add_ps(fiy2
,ty
);
1898 fiz2
= _mm_add_ps(fiz2
,tz
);
1900 fjx2
= _mm_add_ps(fjx2
,tx
);
1901 fjy2
= _mm_add_ps(fjy2
,ty
);
1902 fjz2
= _mm_add_ps(fjz2
,tz
);
1904 fjptrA
= f
+j_coord_offsetA
;
1905 fjptrB
= f
+j_coord_offsetB
;
1906 fjptrC
= f
+j_coord_offsetC
;
1907 fjptrD
= f
+j_coord_offsetD
;
1909 gmx_mm_decrement_3rvec_4ptr_swizzle_ps(fjptrA
,fjptrB
,fjptrC
,fjptrD
,
1910 fjx0
,fjy0
,fjz0
,fjx1
,fjy1
,fjz1
,fjx2
,fjy2
,fjz2
);
1912 /* Inner loop uses 350 flops */
1915 if(jidx
<j_index_end
)
1918 /* Get j neighbor index, and coordinate index */
1919 jnrlistA
= jjnr
[jidx
];
1920 jnrlistB
= jjnr
[jidx
+1];
1921 jnrlistC
= jjnr
[jidx
+2];
1922 jnrlistD
= jjnr
[jidx
+3];
1923 /* Sign of each element will be negative for non-real atoms.
1924 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
1925 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
1927 dummy_mask
= gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i
*)(jjnr
+jidx
)),_mm_setzero_si128()));
1928 jnrA
= (jnrlistA
>=0) ? jnrlistA
: 0;
1929 jnrB
= (jnrlistB
>=0) ? jnrlistB
: 0;
1930 jnrC
= (jnrlistC
>=0) ? jnrlistC
: 0;
1931 jnrD
= (jnrlistD
>=0) ? jnrlistD
: 0;
1932 j_coord_offsetA
= DIM
*jnrA
;
1933 j_coord_offsetB
= DIM
*jnrB
;
1934 j_coord_offsetC
= DIM
*jnrC
;
1935 j_coord_offsetD
= DIM
*jnrD
;
1937 /* load j atom coordinates */
1938 gmx_mm_load_3rvec_4ptr_swizzle_ps(x
+j_coord_offsetA
,x
+j_coord_offsetB
,
1939 x
+j_coord_offsetC
,x
+j_coord_offsetD
,
1940 &jx0
,&jy0
,&jz0
,&jx1
,&jy1
,&jz1
,&jx2
,&jy2
,&jz2
);
1942 /* Calculate displacement vector */
1943 dx00
= _mm_sub_ps(ix0
,jx0
);
1944 dy00
= _mm_sub_ps(iy0
,jy0
);
1945 dz00
= _mm_sub_ps(iz0
,jz0
);
1946 dx01
= _mm_sub_ps(ix0
,jx1
);
1947 dy01
= _mm_sub_ps(iy0
,jy1
);
1948 dz01
= _mm_sub_ps(iz0
,jz1
);
1949 dx02
= _mm_sub_ps(ix0
,jx2
);
1950 dy02
= _mm_sub_ps(iy0
,jy2
);
1951 dz02
= _mm_sub_ps(iz0
,jz2
);
1952 dx10
= _mm_sub_ps(ix1
,jx0
);
1953 dy10
= _mm_sub_ps(iy1
,jy0
);
1954 dz10
= _mm_sub_ps(iz1
,jz0
);
1955 dx11
= _mm_sub_ps(ix1
,jx1
);
1956 dy11
= _mm_sub_ps(iy1
,jy1
);
1957 dz11
= _mm_sub_ps(iz1
,jz1
);
1958 dx12
= _mm_sub_ps(ix1
,jx2
);
1959 dy12
= _mm_sub_ps(iy1
,jy2
);
1960 dz12
= _mm_sub_ps(iz1
,jz2
);
1961 dx20
= _mm_sub_ps(ix2
,jx0
);
1962 dy20
= _mm_sub_ps(iy2
,jy0
);
1963 dz20
= _mm_sub_ps(iz2
,jz0
);
1964 dx21
= _mm_sub_ps(ix2
,jx1
);
1965 dy21
= _mm_sub_ps(iy2
,jy1
);
1966 dz21
= _mm_sub_ps(iz2
,jz1
);
1967 dx22
= _mm_sub_ps(ix2
,jx2
);
1968 dy22
= _mm_sub_ps(iy2
,jy2
);
1969 dz22
= _mm_sub_ps(iz2
,jz2
);
1971 /* Calculate squared distance and things based on it */
1972 rsq00
= gmx_mm_calc_rsq_ps(dx00
,dy00
,dz00
);
1973 rsq01
= gmx_mm_calc_rsq_ps(dx01
,dy01
,dz01
);
1974 rsq02
= gmx_mm_calc_rsq_ps(dx02
,dy02
,dz02
);
1975 rsq10
= gmx_mm_calc_rsq_ps(dx10
,dy10
,dz10
);
1976 rsq11
= gmx_mm_calc_rsq_ps(dx11
,dy11
,dz11
);
1977 rsq12
= gmx_mm_calc_rsq_ps(dx12
,dy12
,dz12
);
1978 rsq20
= gmx_mm_calc_rsq_ps(dx20
,dy20
,dz20
);
1979 rsq21
= gmx_mm_calc_rsq_ps(dx21
,dy21
,dz21
);
1980 rsq22
= gmx_mm_calc_rsq_ps(dx22
,dy22
,dz22
);
1982 rinv00
= gmx_mm_invsqrt_ps(rsq00
);
1983 rinv01
= gmx_mm_invsqrt_ps(rsq01
);
1984 rinv02
= gmx_mm_invsqrt_ps(rsq02
);
1985 rinv10
= gmx_mm_invsqrt_ps(rsq10
);
1986 rinv11
= gmx_mm_invsqrt_ps(rsq11
);
1987 rinv12
= gmx_mm_invsqrt_ps(rsq12
);
1988 rinv20
= gmx_mm_invsqrt_ps(rsq20
);
1989 rinv21
= gmx_mm_invsqrt_ps(rsq21
);
1990 rinv22
= gmx_mm_invsqrt_ps(rsq22
);
1992 rinvsq00
= _mm_mul_ps(rinv00
,rinv00
);
1993 rinvsq01
= _mm_mul_ps(rinv01
,rinv01
);
1994 rinvsq02
= _mm_mul_ps(rinv02
,rinv02
);
1995 rinvsq10
= _mm_mul_ps(rinv10
,rinv10
);
1996 rinvsq11
= _mm_mul_ps(rinv11
,rinv11
);
1997 rinvsq12
= _mm_mul_ps(rinv12
,rinv12
);
1998 rinvsq20
= _mm_mul_ps(rinv20
,rinv20
);
1999 rinvsq21
= _mm_mul_ps(rinv21
,rinv21
);
2000 rinvsq22
= _mm_mul_ps(rinv22
,rinv22
);
2002 fjx0
= _mm_setzero_ps();
2003 fjy0
= _mm_setzero_ps();
2004 fjz0
= _mm_setzero_ps();
2005 fjx1
= _mm_setzero_ps();
2006 fjy1
= _mm_setzero_ps();
2007 fjz1
= _mm_setzero_ps();
2008 fjx2
= _mm_setzero_ps();
2009 fjy2
= _mm_setzero_ps();
2010 fjz2
= _mm_setzero_ps();
2012 /**************************
2013 * CALCULATE INTERACTIONS *
2014 **************************/
2016 r00
= _mm_mul_ps(rsq00
,rinv00
);
2017 r00
= _mm_andnot_ps(dummy_mask
,r00
);
2019 /* Calculate table index by multiplying r with table scale and truncate to integer */
2020 rt
= _mm_mul_ps(r00
,vftabscale
);
2021 vfitab
= _mm_cvttps_epi32(rt
);
2022 vfeps
= _mm_sub_ps(rt
,_mm_cvtepi32_ps(vfitab
));
2023 vfitab
= _mm_slli_epi32(vfitab
,3);
2025 /* EWALD ELECTROSTATICS */
2027 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
2028 ewrt
= _mm_mul_ps(r00
,ewtabscale
);
2029 ewitab
= _mm_cvttps_epi32(ewrt
);
2030 eweps
= _mm_sub_ps(ewrt
,_mm_cvtepi32_ps(ewitab
));
2031 gmx_mm_load_4pair_swizzle_ps(ewtab
+gmx_mm_extract_epi32(ewitab
,0),ewtab
+gmx_mm_extract_epi32(ewitab
,1),
2032 ewtab
+gmx_mm_extract_epi32(ewitab
,2),ewtab
+gmx_mm_extract_epi32(ewitab
,3),
2034 felec
= _mm_add_ps(_mm_mul_ps( _mm_sub_ps(one
,eweps
),ewtabF
),_mm_mul_ps(eweps
,ewtabFn
));
2035 felec
= _mm_mul_ps(_mm_mul_ps(qq00
,rinv00
),_mm_sub_ps(rinvsq00
,felec
));
2037 /* CUBIC SPLINE TABLE DISPERSION */
2038 Y
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,0) );
2039 F
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,1) );
2040 G
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,2) );
2041 H
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,3) );
2042 _MM_TRANSPOSE4_PS(Y
,F
,G
,H
);
2043 Heps
= _mm_mul_ps(vfeps
,H
);
2044 Fp
= _mm_add_ps(F
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,Heps
)));
2045 FF
= _mm_add_ps(Fp
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,_mm_add_ps(Heps
,Heps
))));
2046 fvdw6
= _mm_mul_ps(c6_00
,FF
);
2048 /* CUBIC SPLINE TABLE REPULSION */
2049 vfitab
= _mm_add_epi32(vfitab
,ifour
);
2050 Y
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,0) );
2051 F
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,1) );
2052 G
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,2) );
2053 H
= _mm_load_ps( vftab
+ gmx_mm_extract_epi32(vfitab
,3) );
2054 _MM_TRANSPOSE4_PS(Y
,F
,G
,H
);
2055 Heps
= _mm_mul_ps(vfeps
,H
);
2056 Fp
= _mm_add_ps(F
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,Heps
)));
2057 FF
= _mm_add_ps(Fp
,_mm_mul_ps(vfeps
,_mm_add_ps(G
,_mm_add_ps(Heps
,Heps
))));
2058 fvdw12
= _mm_mul_ps(c12_00
,FF
);
2059 fvdw
= _mm_xor_ps(signbit
,_mm_mul_ps(_mm_add_ps(fvdw6
,fvdw12
),_mm_mul_ps(vftabscale
,rinv00
)));
2061 fscal
= _mm_add_ps(felec
,fvdw
);
2063 fscal
= _mm_andnot_ps(dummy_mask
,fscal
);
2065 /* Calculate temporary vectorial force */
2066 tx
= _mm_mul_ps(fscal
,dx00
);
2067 ty
= _mm_mul_ps(fscal
,dy00
);
2068 tz
= _mm_mul_ps(fscal
,dz00
);
2070 /* Update vectorial force */
2071 fix0
= _mm_add_ps(fix0
,tx
);
2072 fiy0
= _mm_add_ps(fiy0
,ty
);
2073 fiz0
= _mm_add_ps(fiz0
,tz
);
2075 fjx0
= _mm_add_ps(fjx0
,tx
);
2076 fjy0
= _mm_add_ps(fjy0
,ty
);
2077 fjz0
= _mm_add_ps(fjz0
,tz
);
2079 /**************************
2080 * CALCULATE INTERACTIONS *
2081 **************************/
2083 r01
= _mm_mul_ps(rsq01
,rinv01
);
2084 r01
= _mm_andnot_ps(dummy_mask
,r01
);
2086 /* EWALD ELECTROSTATICS */
2088 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
2089 ewrt
= _mm_mul_ps(r01
,ewtabscale
);
2090 ewitab
= _mm_cvttps_epi32(ewrt
);
2091 eweps
= _mm_sub_ps(ewrt
,_mm_cvtepi32_ps(ewitab
));
2092 gmx_mm_load_4pair_swizzle_ps(ewtab
+gmx_mm_extract_epi32(ewitab
,0),ewtab
+gmx_mm_extract_epi32(ewitab
,1),
2093 ewtab
+gmx_mm_extract_epi32(ewitab
,2),ewtab
+gmx_mm_extract_epi32(ewitab
,3),
2095 felec
= _mm_add_ps(_mm_mul_ps( _mm_sub_ps(one
,eweps
),ewtabF
),_mm_mul_ps(eweps
,ewtabFn
));
2096 felec
= _mm_mul_ps(_mm_mul_ps(qq01
,rinv01
),_mm_sub_ps(rinvsq01
,felec
));
2100 fscal
= _mm_andnot_ps(dummy_mask
,fscal
);
2102 /* Calculate temporary vectorial force */
2103 tx
= _mm_mul_ps(fscal
,dx01
);
2104 ty
= _mm_mul_ps(fscal
,dy01
);
2105 tz
= _mm_mul_ps(fscal
,dz01
);
2107 /* Update vectorial force */
2108 fix0
= _mm_add_ps(fix0
,tx
);
2109 fiy0
= _mm_add_ps(fiy0
,ty
);
2110 fiz0
= _mm_add_ps(fiz0
,tz
);
2112 fjx1
= _mm_add_ps(fjx1
,tx
);
2113 fjy1
= _mm_add_ps(fjy1
,ty
);
2114 fjz1
= _mm_add_ps(fjz1
,tz
);
2116 /**************************
2117 * CALCULATE INTERACTIONS *
2118 **************************/
2120 r02
= _mm_mul_ps(rsq02
,rinv02
);
2121 r02
= _mm_andnot_ps(dummy_mask
,r02
);
2123 /* EWALD ELECTROSTATICS */
2125 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
2126 ewrt
= _mm_mul_ps(r02
,ewtabscale
);
2127 ewitab
= _mm_cvttps_epi32(ewrt
);
2128 eweps
= _mm_sub_ps(ewrt
,_mm_cvtepi32_ps(ewitab
));
2129 gmx_mm_load_4pair_swizzle_ps(ewtab
+gmx_mm_extract_epi32(ewitab
,0),ewtab
+gmx_mm_extract_epi32(ewitab
,1),
2130 ewtab
+gmx_mm_extract_epi32(ewitab
,2),ewtab
+gmx_mm_extract_epi32(ewitab
,3),
2132 felec
= _mm_add_ps(_mm_mul_ps( _mm_sub_ps(one
,eweps
),ewtabF
),_mm_mul_ps(eweps
,ewtabFn
));
2133 felec
= _mm_mul_ps(_mm_mul_ps(qq02
,rinv02
),_mm_sub_ps(rinvsq02
,felec
));
2137 fscal
= _mm_andnot_ps(dummy_mask
,fscal
);
2139 /* Calculate temporary vectorial force */
2140 tx
= _mm_mul_ps(fscal
,dx02
);
2141 ty
= _mm_mul_ps(fscal
,dy02
);
2142 tz
= _mm_mul_ps(fscal
,dz02
);
2144 /* Update vectorial force */
2145 fix0
= _mm_add_ps(fix0
,tx
);
2146 fiy0
= _mm_add_ps(fiy0
,ty
);
2147 fiz0
= _mm_add_ps(fiz0
,tz
);
2149 fjx2
= _mm_add_ps(fjx2
,tx
);
2150 fjy2
= _mm_add_ps(fjy2
,ty
);
2151 fjz2
= _mm_add_ps(fjz2
,tz
);
2153 /**************************
2154 * CALCULATE INTERACTIONS *
2155 **************************/
2157 r10
= _mm_mul_ps(rsq10
,rinv10
);
2158 r10
= _mm_andnot_ps(dummy_mask
,r10
);
2160 /* EWALD ELECTROSTATICS */
2162 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
2163 ewrt
= _mm_mul_ps(r10
,ewtabscale
);
2164 ewitab
= _mm_cvttps_epi32(ewrt
);
2165 eweps
= _mm_sub_ps(ewrt
,_mm_cvtepi32_ps(ewitab
));
2166 gmx_mm_load_4pair_swizzle_ps(ewtab
+gmx_mm_extract_epi32(ewitab
,0),ewtab
+gmx_mm_extract_epi32(ewitab
,1),
2167 ewtab
+gmx_mm_extract_epi32(ewitab
,2),ewtab
+gmx_mm_extract_epi32(ewitab
,3),
2169 felec
= _mm_add_ps(_mm_mul_ps( _mm_sub_ps(one
,eweps
),ewtabF
),_mm_mul_ps(eweps
,ewtabFn
));
2170 felec
= _mm_mul_ps(_mm_mul_ps(qq10
,rinv10
),_mm_sub_ps(rinvsq10
,felec
));
2174 fscal
= _mm_andnot_ps(dummy_mask
,fscal
);
2176 /* Calculate temporary vectorial force */
2177 tx
= _mm_mul_ps(fscal
,dx10
);
2178 ty
= _mm_mul_ps(fscal
,dy10
);
2179 tz
= _mm_mul_ps(fscal
,dz10
);
2181 /* Update vectorial force */
2182 fix1
= _mm_add_ps(fix1
,tx
);
2183 fiy1
= _mm_add_ps(fiy1
,ty
);
2184 fiz1
= _mm_add_ps(fiz1
,tz
);
2186 fjx0
= _mm_add_ps(fjx0
,tx
);
2187 fjy0
= _mm_add_ps(fjy0
,ty
);
2188 fjz0
= _mm_add_ps(fjz0
,tz
);
2190 /**************************
2191 * CALCULATE INTERACTIONS *
2192 **************************/
2194 r11
= _mm_mul_ps(rsq11
,rinv11
);
2195 r11
= _mm_andnot_ps(dummy_mask
,r11
);
2197 /* EWALD ELECTROSTATICS */
2199 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
2200 ewrt
= _mm_mul_ps(r11
,ewtabscale
);
2201 ewitab
= _mm_cvttps_epi32(ewrt
);
2202 eweps
= _mm_sub_ps(ewrt
,_mm_cvtepi32_ps(ewitab
));
2203 gmx_mm_load_4pair_swizzle_ps(ewtab
+gmx_mm_extract_epi32(ewitab
,0),ewtab
+gmx_mm_extract_epi32(ewitab
,1),
2204 ewtab
+gmx_mm_extract_epi32(ewitab
,2),ewtab
+gmx_mm_extract_epi32(ewitab
,3),
2206 felec
= _mm_add_ps(_mm_mul_ps( _mm_sub_ps(one
,eweps
),ewtabF
),_mm_mul_ps(eweps
,ewtabFn
));
2207 felec
= _mm_mul_ps(_mm_mul_ps(qq11
,rinv11
),_mm_sub_ps(rinvsq11
,felec
));
2211 fscal
= _mm_andnot_ps(dummy_mask
,fscal
);
2213 /* Calculate temporary vectorial force */
2214 tx
= _mm_mul_ps(fscal
,dx11
);
2215 ty
= _mm_mul_ps(fscal
,dy11
);
2216 tz
= _mm_mul_ps(fscal
,dz11
);
2218 /* Update vectorial force */
2219 fix1
= _mm_add_ps(fix1
,tx
);
2220 fiy1
= _mm_add_ps(fiy1
,ty
);
2221 fiz1
= _mm_add_ps(fiz1
,tz
);
2223 fjx1
= _mm_add_ps(fjx1
,tx
);
2224 fjy1
= _mm_add_ps(fjy1
,ty
);
2225 fjz1
= _mm_add_ps(fjz1
,tz
);
2227 /**************************
2228 * CALCULATE INTERACTIONS *
2229 **************************/
2231 r12
= _mm_mul_ps(rsq12
,rinv12
);
2232 r12
= _mm_andnot_ps(dummy_mask
,r12
);
2234 /* EWALD ELECTROSTATICS */
2236 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
2237 ewrt
= _mm_mul_ps(r12
,ewtabscale
);
2238 ewitab
= _mm_cvttps_epi32(ewrt
);
2239 eweps
= _mm_sub_ps(ewrt
,_mm_cvtepi32_ps(ewitab
));
2240 gmx_mm_load_4pair_swizzle_ps(ewtab
+gmx_mm_extract_epi32(ewitab
,0),ewtab
+gmx_mm_extract_epi32(ewitab
,1),
2241 ewtab
+gmx_mm_extract_epi32(ewitab
,2),ewtab
+gmx_mm_extract_epi32(ewitab
,3),
2243 felec
= _mm_add_ps(_mm_mul_ps( _mm_sub_ps(one
,eweps
),ewtabF
),_mm_mul_ps(eweps
,ewtabFn
));
2244 felec
= _mm_mul_ps(_mm_mul_ps(qq12
,rinv12
),_mm_sub_ps(rinvsq12
,felec
));
2248 fscal
= _mm_andnot_ps(dummy_mask
,fscal
);
2250 /* Calculate temporary vectorial force */
2251 tx
= _mm_mul_ps(fscal
,dx12
);
2252 ty
= _mm_mul_ps(fscal
,dy12
);
2253 tz
= _mm_mul_ps(fscal
,dz12
);
2255 /* Update vectorial force */
2256 fix1
= _mm_add_ps(fix1
,tx
);
2257 fiy1
= _mm_add_ps(fiy1
,ty
);
2258 fiz1
= _mm_add_ps(fiz1
,tz
);
2260 fjx2
= _mm_add_ps(fjx2
,tx
);
2261 fjy2
= _mm_add_ps(fjy2
,ty
);
2262 fjz2
= _mm_add_ps(fjz2
,tz
);
2264 /**************************
2265 * CALCULATE INTERACTIONS *
2266 **************************/
2268 r20
= _mm_mul_ps(rsq20
,rinv20
);
2269 r20
= _mm_andnot_ps(dummy_mask
,r20
);
2271 /* EWALD ELECTROSTATICS */
2273 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
2274 ewrt
= _mm_mul_ps(r20
,ewtabscale
);
2275 ewitab
= _mm_cvttps_epi32(ewrt
);
2276 eweps
= _mm_sub_ps(ewrt
,_mm_cvtepi32_ps(ewitab
));
2277 gmx_mm_load_4pair_swizzle_ps(ewtab
+gmx_mm_extract_epi32(ewitab
,0),ewtab
+gmx_mm_extract_epi32(ewitab
,1),
2278 ewtab
+gmx_mm_extract_epi32(ewitab
,2),ewtab
+gmx_mm_extract_epi32(ewitab
,3),
2280 felec
= _mm_add_ps(_mm_mul_ps( _mm_sub_ps(one
,eweps
),ewtabF
),_mm_mul_ps(eweps
,ewtabFn
));
2281 felec
= _mm_mul_ps(_mm_mul_ps(qq20
,rinv20
),_mm_sub_ps(rinvsq20
,felec
));
2285 fscal
= _mm_andnot_ps(dummy_mask
,fscal
);
2287 /* Calculate temporary vectorial force */
2288 tx
= _mm_mul_ps(fscal
,dx20
);
2289 ty
= _mm_mul_ps(fscal
,dy20
);
2290 tz
= _mm_mul_ps(fscal
,dz20
);
2292 /* Update vectorial force */
2293 fix2
= _mm_add_ps(fix2
,tx
);
2294 fiy2
= _mm_add_ps(fiy2
,ty
);
2295 fiz2
= _mm_add_ps(fiz2
,tz
);
2297 fjx0
= _mm_add_ps(fjx0
,tx
);
2298 fjy0
= _mm_add_ps(fjy0
,ty
);
2299 fjz0
= _mm_add_ps(fjz0
,tz
);
2301 /**************************
2302 * CALCULATE INTERACTIONS *
2303 **************************/
2305 r21
= _mm_mul_ps(rsq21
,rinv21
);
2306 r21
= _mm_andnot_ps(dummy_mask
,r21
);
2308 /* EWALD ELECTROSTATICS */
2310 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
2311 ewrt
= _mm_mul_ps(r21
,ewtabscale
);
2312 ewitab
= _mm_cvttps_epi32(ewrt
);
2313 eweps
= _mm_sub_ps(ewrt
,_mm_cvtepi32_ps(ewitab
));
2314 gmx_mm_load_4pair_swizzle_ps(ewtab
+gmx_mm_extract_epi32(ewitab
,0),ewtab
+gmx_mm_extract_epi32(ewitab
,1),
2315 ewtab
+gmx_mm_extract_epi32(ewitab
,2),ewtab
+gmx_mm_extract_epi32(ewitab
,3),
2317 felec
= _mm_add_ps(_mm_mul_ps( _mm_sub_ps(one
,eweps
),ewtabF
),_mm_mul_ps(eweps
,ewtabFn
));
2318 felec
= _mm_mul_ps(_mm_mul_ps(qq21
,rinv21
),_mm_sub_ps(rinvsq21
,felec
));
2322 fscal
= _mm_andnot_ps(dummy_mask
,fscal
);
2324 /* Calculate temporary vectorial force */
2325 tx
= _mm_mul_ps(fscal
,dx21
);
2326 ty
= _mm_mul_ps(fscal
,dy21
);
2327 tz
= _mm_mul_ps(fscal
,dz21
);
2329 /* Update vectorial force */
2330 fix2
= _mm_add_ps(fix2
,tx
);
2331 fiy2
= _mm_add_ps(fiy2
,ty
);
2332 fiz2
= _mm_add_ps(fiz2
,tz
);
2334 fjx1
= _mm_add_ps(fjx1
,tx
);
2335 fjy1
= _mm_add_ps(fjy1
,ty
);
2336 fjz1
= _mm_add_ps(fjz1
,tz
);
2338 /**************************
2339 * CALCULATE INTERACTIONS *
2340 **************************/
2342 r22
= _mm_mul_ps(rsq22
,rinv22
);
2343 r22
= _mm_andnot_ps(dummy_mask
,r22
);
2345 /* EWALD ELECTROSTATICS */
2347 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
2348 ewrt
= _mm_mul_ps(r22
,ewtabscale
);
2349 ewitab
= _mm_cvttps_epi32(ewrt
);
2350 eweps
= _mm_sub_ps(ewrt
,_mm_cvtepi32_ps(ewitab
));
2351 gmx_mm_load_4pair_swizzle_ps(ewtab
+gmx_mm_extract_epi32(ewitab
,0),ewtab
+gmx_mm_extract_epi32(ewitab
,1),
2352 ewtab
+gmx_mm_extract_epi32(ewitab
,2),ewtab
+gmx_mm_extract_epi32(ewitab
,3),
2354 felec
= _mm_add_ps(_mm_mul_ps( _mm_sub_ps(one
,eweps
),ewtabF
),_mm_mul_ps(eweps
,ewtabFn
));
2355 felec
= _mm_mul_ps(_mm_mul_ps(qq22
,rinv22
),_mm_sub_ps(rinvsq22
,felec
));
2359 fscal
= _mm_andnot_ps(dummy_mask
,fscal
);
2361 /* Calculate temporary vectorial force */
2362 tx
= _mm_mul_ps(fscal
,dx22
);
2363 ty
= _mm_mul_ps(fscal
,dy22
);
2364 tz
= _mm_mul_ps(fscal
,dz22
);
2366 /* Update vectorial force */
2367 fix2
= _mm_add_ps(fix2
,tx
);
2368 fiy2
= _mm_add_ps(fiy2
,ty
);
2369 fiz2
= _mm_add_ps(fiz2
,tz
);
2371 fjx2
= _mm_add_ps(fjx2
,tx
);
2372 fjy2
= _mm_add_ps(fjy2
,ty
);
2373 fjz2
= _mm_add_ps(fjz2
,tz
);
2375 fjptrA
= (jnrlistA
>=0) ? f
+j_coord_offsetA
: scratch
;
2376 fjptrB
= (jnrlistB
>=0) ? f
+j_coord_offsetB
: scratch
;
2377 fjptrC
= (jnrlistC
>=0) ? f
+j_coord_offsetC
: scratch
;
2378 fjptrD
= (jnrlistD
>=0) ? f
+j_coord_offsetD
: scratch
;
2380 gmx_mm_decrement_3rvec_4ptr_swizzle_ps(fjptrA
,fjptrB
,fjptrC
,fjptrD
,
2381 fjx0
,fjy0
,fjz0
,fjx1
,fjy1
,fjz1
,fjx2
,fjy2
,fjz2
);
2383 /* Inner loop uses 359 flops */
2386 /* End of innermost loop */
2388 gmx_mm_update_iforce_3atom_swizzle_ps(fix0
,fiy0
,fiz0
,fix1
,fiy1
,fiz1
,fix2
,fiy2
,fiz2
,
2389 f
+i_coord_offset
,fshift
+i_shift_offset
);
2391 /* Increment number of inner iterations */
2392 inneriter
+= j_index_end
- j_index_start
;
2394 /* Outer loop uses 18 flops */
2397 /* Increment number of outer iterations */
2400 /* Update outer/inner flops */
2402 inc_nrnb(nrnb
,eNR_NBKERNEL_ELEC_VDW_W3W3_F
,outeriter
*18 + inneriter
*359);