nb_kernel301_x86_64_sse.intel_syntax.s
来自「最著名最快的分子模拟软件」· S 代码 · 共 1,950 行 · 第 1/4 页
S
1,950 行
cvttps2dq xmm1, xmm0 cvttps2dq xmm4, xmm3 cvttps2dq xmm7, xmm6 ;# convert back to float cvtdq2ps xmm2, xmm1 cvtdq2ps xmm5, xmm4 cvtdq2ps xmm8, xmm7 ;# multiply by 4 pslld xmm1, 2 pslld xmm4, 2 pslld xmm7, 2 ;# move to integer registers movhlps xmm13, xmm1 movhlps xmm14, xmm4 movhlps xmm15, xmm7 movd eax, xmm1 movd r8d, xmm4 movd r12d, xmm7 movd ecx, xmm13 movd r10d, xmm14 movd r14d, xmm15 pshufd xmm1, xmm1, 1 pshufd xmm4, xmm4, 1 pshufd xmm7, xmm7, 1 pshufd xmm13, xmm13, 1 pshufd xmm14, xmm14, 1 pshufd xmm15, xmm15, 1 movd ebx, xmm1 movd r9d, xmm4 movd r13d, xmm7 movd edx, xmm13 movd r11d, xmm14 movd r15d, xmm15 mov rsi, [rbp + nb301_VFtab] ;# calculate eps subps xmm0, xmm2 subps xmm3, xmm5 subps xmm6, xmm8 movaps [rsp + nb301_epsO], xmm0 movaps [rsp + nb301_epsH1], xmm3 movaps [rsp + nb301_epsH2], xmm6 ;# Load LOTS of table data movlps xmm1, [rsi + rax*4] movlps xmm5, [rsi + r8*4] movlps xmm9, [rsi + r12*4] movlps xmm3, [rsi + rcx*4] movlps xmm7, [rsi + r10*4] movlps xmm11, [rsi + r14*4] movhps xmm1, [rsi + rbx*4] movhps xmm5, [rsi + r9*4] movhps xmm9, [rsi + r13*4] movhps xmm3, [rsi + rdx*4] movhps xmm7, [rsi + r11*4] movhps xmm11, [rsi + r15*4] movaps xmm0, xmm1 movaps xmm4, xmm5 movaps xmm8, xmm9 shufps xmm0, xmm3, 136 ;# 10001000 shufps xmm4, xmm7, 136 ;# 10001000 shufps xmm8, xmm11, 136 ;# 10001000 shufps xmm1, xmm3, 221 ;# 11011101 shufps xmm5, xmm7, 221 ;# 11011101 shufps xmm9, xmm11, 221 ;# 11011101 movlps xmm3, [rsi + rax*4 + 8] movlps xmm7, [rsi + r8*4 + 8] movlps xmm11, [rsi + r12*4 + 8] movlps xmm12, [rsi + rcx*4 + 8] movlps xmm13, [rsi + r10*4 + 8] movlps xmm14, [rsi + r14*4 + 8] movhps xmm3, [rsi + rbx*4 + 8] movhps xmm7, [rsi + r9*4 + 8] movhps xmm11, [rsi + r13*4 + 8] movhps xmm12, [rsi + rdx*4 + 8] movhps xmm13, [rsi + r11*4 + 8] movhps xmm14, [rsi + r15*4 + 8] movaps xmm2, xmm3 movaps xmm6, xmm7 movaps xmm10, xmm11 shufps xmm2, xmm12, 136 ;# 10001000 shufps xmm6, xmm13, 136 ;# 10001000 shufps xmm10, xmm14, 136 ;# 10001000 shufps xmm3, xmm12, 221 ;# 11011101 shufps xmm7, xmm13, 221 ;# 11011101 shufps xmm11, xmm14, 221 ;# 11011101 ;# table data ready in xmm0-xmm3 , xmm4-xmm7 , and xmm8-xmm11 movaps xmm12, [rsp + nb301_epsO] movaps xmm13, [rsp + nb301_epsH1] movaps xmm14, [rsp + nb301_epsH2] mulps xmm3, xmm12 ;# Heps mulps xmm7, xmm13 mulps xmm11, xmm14 mulps xmm2, xmm12 ;# Geps mulps xmm6, xmm13 mulps xmm10, xmm14 mulps xmm3, xmm12 ;# Heps2 mulps xmm7, xmm13 mulps xmm11, xmm14 addps xmm1, xmm2 ;# F+Geps addps xmm5, xmm6 addps xmm9, xmm10 addps xmm1, xmm3 ;# F+Geps+Heps2 = Fp addps xmm5, xmm7 addps xmm9, xmm11 addps xmm3, xmm3 ;# 2*Heps2 addps xmm7, xmm7 addps xmm11, xmm11 addps xmm3, xmm2 ;# 2*Heps2+Geps addps xmm7, xmm6 addps xmm11, xmm10 addps xmm3, xmm1 ;# FF = Fp + 2*Heps2 + Geps addps xmm7, xmm5 addps xmm11, xmm9 mulps xmm1, xmm12 ;# eps*Fp mulps xmm5, xmm13 mulps xmm9, xmm14 movaps xmm12, [rsp + nb301_qqO] movaps xmm13, [rsp + nb301_qqH] addps xmm1, xmm0 ;# VV addps xmm5, xmm4 addps xmm9, xmm8 mulps xmm1, xmm12 ;# VV*qq = vcoul mulps xmm5, xmm13 mulps xmm9, xmm13 mulps xmm3, xmm12 ;# FF*qq = fij mulps xmm7, xmm13 mulps xmm11, xmm13 ;# accumulate vctot addps xmm1, [rsp + nb301_vctot] addps xmm5, xmm9 addps xmm1, xmm5 movaps [rsp + nb301_vctot], xmm1 movaps xmm10, [rsp + nb301_tsc] mulps xmm3, xmm10 ;# fscal mulps xmm7, xmm10 mulps xmm10, xmm11 movd eax, mm0 movd ebx, mm1 movd ecx, mm2 movd edx, mm3 ;# move j forces to local temp variables movlps xmm11, [rdi + rax*4] ;# jxa jya - - movlps xmm12, [rdi + rcx*4] ;# jxc jyc - - movhps xmm11, [rdi + rbx*4] ;# jxa jya jxb jyb movhps xmm12, [rdi + rdx*4] ;# jxc jyc jxd jyd movss xmm13, [rdi + rax*4 + 8] ;# jza - - - movss xmm14, [rdi + rcx*4 + 8] ;# jzc - - - movss xmm2, [rdi + rbx*4 + 8] ;# jzb movss xmm5, [rdi + rdx*4 + 8] ;# jzd movlhps xmm13, xmm2 ;# jza - jzb - movlhps xmm14, xmm5 ;# jzc - jzd - shufps xmm13, xmm14, 136 ;# 10001000 => jza jzb jzc jzd ;# xmm11: jxa jya jxb jyb ;# xmm12: jxc jyc jxd jyd ;# xmm13: jza jzb jzc jzd xorps xmm0, xmm0 xorps xmm4, xmm4 xorps xmm8, xmm8 mulps xmm3, [rsp + nb301_rinvO] mulps xmm7, [rsp + nb301_rinvH1] mulps xmm10, [rsp + nb301_rinvH2] subps xmm0, xmm3 subps xmm4, xmm7 subps xmm8, xmm10 movaps xmm1, xmm0 movaps xmm2, xmm0 movaps xmm3, xmm4 movaps xmm5, xmm4 movaps xmm6, xmm8 movaps xmm7, xmm8 mulps xmm0, [rsp + nb301_dxO] mulps xmm1, [rsp + nb301_dyO] mulps xmm2, [rsp + nb301_dzO] mulps xmm3, [rsp + nb301_dxH1] mulps xmm4, [rsp + nb301_dyH1] mulps xmm5, [rsp + nb301_dzH1] mulps xmm6, [rsp + nb301_dxH2] mulps xmm7, [rsp + nb301_dyH2] mulps xmm8, [rsp + nb301_dzH2] movaps xmm14, xmm0 movaps xmm15, xmm1 addps xmm13, xmm2 addps xmm0, [rsp + nb301_fixO] addps xmm1, [rsp + nb301_fiyO] addps xmm2, [rsp + nb301_fizO] addps xmm14, xmm3 addps xmm15, xmm4 addps xmm13, xmm5 addps xmm3, [rsp + nb301_fixH1] addps xmm4, [rsp + nb301_fiyH1] addps xmm5, [rsp + nb301_fizH1] addps xmm14, xmm6 addps xmm15, xmm7 addps xmm13, xmm8 addps xmm6, [rsp + nb301_fixH2] addps xmm7, [rsp + nb301_fiyH2] addps xmm8, [rsp + nb301_fizH2] movaps [rsp + nb301_fixO], xmm0 movaps [rsp + nb301_fiyO], xmm1 movaps [rsp + nb301_fizO], xmm2 movaps [rsp + nb301_fixH1], xmm3 movaps [rsp + nb301_fiyH1], xmm4 movaps [rsp + nb301_fizH1], xmm5 movaps [rsp + nb301_fixH2], xmm6 movaps [rsp + nb301_fiyH2], xmm7 movaps [rsp + nb301_fizH2], xmm8 ;# xmm14 = fjx ;# xmm15 = fjy ;# xmm13 = fjz movaps xmm0, xmm14 unpcklps xmm14, xmm15 unpckhps xmm0, xmm15 addps xmm11, xmm14 addps xmm12, xmm0 movhlps xmm14, xmm13 ;# fjzc fjzd movlps [rdi + rax*4], xmm11 movhps [rdi + rbx*4], xmm11 movlps [rdi + rcx*4], xmm12 movhps [rdi + rdx*4], xmm12 movss [rdi + rax*4 + 8], xmm13 movss [rdi + rcx*4 + 8], xmm14 shufps xmm13, xmm13, 1 shufps xmm14, xmm14, 1 movss [rdi + rbx*4 + 8], xmm13 movss [rdi + rdx*4 + 8], xmm14 ;# should we do one more iteration? sub dword ptr [rsp + nb301_innerk], 4 jl .nb301_odd_inner jmp .nb301_unroll_loop.nb301_odd_inner: add dword ptr [rsp + nb301_innerk], 4 jnz .nb301_odd_loop jmp .nb301_updateouterdata.nb301_odd_loop: mov rdx, [rsp + nb301_innerjjnr] ;# pointer to jjnr[k] mov eax, [rdx] add qword ptr [rsp + nb301_innerjjnr], 4 xorps xmm4, xmm4 movss xmm4, [rsp + nb301_iqO] mov rsi, [rbp + nb301_charge] movhps xmm4, [rsp + nb301_iqH] movss xmm3, [rsi + rax*4] ;# charge in xmm3 shufps xmm3, xmm3, 0 mulps xmm3, xmm4 movaps [rsp + nb301_qqO], xmm3 ;# use oxygen qq for storage mov rsi, [rbp + nb301_pos] lea rax, [rax + rax*2] ;# move j coords to xmm0-xmm2 movss xmm3, [rsi + rax*4] movss xmm4, [rsi + rax*4 + 4] movss xmm5, [rsi + rax*4 + 8] shufps xmm3, xmm3, 0 shufps xmm4, xmm4, 0 shufps xmm5, xmm5, 0 movss xmm0, [rsp + nb301_ixO] movss xmm1, [rsp + nb301_iyO] movss xmm2, [rsp + nb301_izO] movlps xmm6, [rsp + nb301_ixH1] movlps xmm7, [rsp + nb301_ixH2] unpcklps xmm6, xmm7 movlhps xmm0, xmm6 movlps xmm6, [rsp + nb301_iyH1] movlps xmm7, [rsp + nb301_iyH2] unpcklps xmm6, xmm7 movlhps xmm1, xmm6 movlps xmm6, [rsp + nb301_izH1] movlps xmm7, [rsp + nb301_izH2] unpcklps xmm6, xmm7 movlhps xmm2, xmm6 subps xmm3, xmm0 subps xmm4, xmm1 subps xmm5, xmm2 movaps [rsp + nb301_dxO], xmm3 movaps [rsp + nb301_dyO], xmm4 movaps [rsp + nb301_dzO], xmm5 mulps xmm3, xmm3 mulps xmm4, xmm4 mulps xmm5, xmm5 addps xmm4, xmm3 addps xmm4, xmm5 ;# rsq in xmm4 rsqrtps xmm5, xmm4 ;# lookup seed in xmm5 movaps xmm2, xmm5 mulps xmm5, xmm5 movaps xmm1, [rsp + nb301_three] mulps xmm5, xmm4 ;# rsq*lu*lu movaps xmm0, [rsp + nb301_half] subps xmm1, xmm5 ;# 30-rsq*lu*lu mulps xmm1, xmm2 mulps xmm0, xmm1 ;# xmm0=rinv ;# a little trick to avoid NaNs: ;# positions 0,2,and 3 are valid, but not 1. ;# If it contains NaN it doesnt help to mult by 0, ;# So we shuffle it and copy pos 0 to pos1! shufps xmm0, xmm0, 224 ;# 11100000 mulps xmm4, xmm0 ;# xmm4=r movaps [rsp + nb301_rinvO], xmm0 mulps xmm4, [rsp + nb301_tsc] movhlps xmm7, xmm4 cvttps2pi mm6, xmm4 cvttps2pi mm7, xmm7 ;# mm6/mm7 contain lu indices cvtpi2ps xmm3, mm6 cvtpi2ps xmm7, mm7 movlhps xmm3, xmm7 subps xmm4, xmm3 movaps xmm1, xmm4 ;# xmm1=eps movaps xmm2, xmm1 mulps xmm2, xmm2 ;# xmm2=eps2 pslld mm6, 2 pslld mm7, 2 movd mm0, eax movd mm1, ecx movd mm2, edx mov rsi, [rbp + nb301_VFtab] movd eax, mm6 movd ecx, mm7 psrlq mm7, 32 movd edx, mm7 movlps xmm5, [rsi + rax*4] movlps xmm7, [rsi + rcx*4] movhps xmm7, [rsi + rdx*4] ;# got half coulomb table movaps xmm4, xmm5 shufps xmm4, xmm7, 136 ;# 10001000 shufps xmm5, xmm7, 221 ;# 11011101 movlps xmm7, [rsi + rax*4 + 8] movlps xmm3, [rsi + rcx*4 + 8] movhps xmm3, [rsi + rdx*4 + 8] ;# other half of coulomb table movaps xmm6, xmm7 shufps xmm6, xmm3, 136 ;# 10001000 shufps xmm7, xmm3, 221 ;# 11011101 ;# coulomb table ready, in xmm4-xmm7 mulps xmm6, xmm1 ;# xmm6=Geps mulps xmm7, xmm2 ;# xmm7=Heps2 addps xmm5, xmm6 addps xmm5, xmm7 ;# xmm5=Fp mulps xmm7, [rsp + nb301_two] ;# two*Heps2 movaps xmm0, [rsp + nb301_qqO] addps xmm7, xmm6 addps xmm7, xmm5 ;# xmm7=FF mulps xmm5, xmm1 ;# xmm5=eps*Fp addps xmm5, xmm4 ;# xmm5=VV mulps xmm5, xmm0 ;# vcoul=qq*VV mulps xmm0, xmm7 ;# fijC=FF*qq ;# at this point mm5 contains vcoul and xmm0 fijC ;# increment vcoul - then we can get rid of mm5 addps xmm5, [rsp + nb301_vctot] movaps [rsp + nb301_vctot], xmm5 xorps xmm4, xmm4 mulps xmm0, [rsp + nb301_tsc] mulps xmm0, [rsp + nb301_rinvO] subps xmm4, xmm0 movd eax, mm0 movd ecx, mm1 movd edx, mm2 movaps xmm0, [rsp + nb301_dxO] movaps xmm1, [rsp + nb301_dyO] movaps xmm2, [rsp + nb301_dzO] mulps xmm0, xmm4 mulps xmm1, xmm4 mulps xmm2, xmm4 ;# xmm0-xmm2 now contains tx-tz (partial force) movss xmm3, [rsp + nb301_fixO] movss xmm4, [rsp + nb301_fiyO] movss xmm5, [rsp + nb301_fizO] addss xmm3, xmm0 addss xmm4, xmm1 addss xmm5, xmm2 movss [rsp + nb301_fixO], xmm3 movss [rsp + nb301_fiyO], xmm4 movss [rsp + nb301_fizO], xmm5 ;# updated the O force now do the H's movaps xmm3, xmm0 movaps xmm4, xmm1 movaps xmm5, xmm2 shufps xmm3, xmm3, 230 ;# 11100110 ;# shift right shufps xmm4, xmm4, 230 ;# 11100110 shufps xmm5, xmm5, 230 ;# 11100110 addss xmm3, [rsp + nb301_fixH1] addss xmm4, [rsp + nb301_fiyH1] addss xmm5, [rsp + nb301_fizH1] movss [rsp + nb301_fixH1], xmm3 movss [rsp + nb301_fiyH1], xmm4 movss [rsp + nb301_fizH1], xmm5 ;# updated the H1 force mov rdi, [rbp + nb301_faction] shufps xmm3, xmm3, 231 ;# 11100111 ;# shift right shufps xmm4, xmm4, 231 ;# 11100111 shufps xmm5, xmm5, 231 ;# 11100111 addss xmm3, [rsp + nb301_fixH2] addss xmm4, [rsp + nb301_fiyH2] addss xmm5, [rsp + nb301_fizH2] movss [rsp + nb301_fixH2], xmm3 movss [rsp + nb301_fiyH2], xmm4 movss [rsp + nb301_fizH2], xmm5 ;# updated the H2 force ;# the fj's - start by accumulating the tx/ty/tz force in xmm0, xmm1 xorps xmm5, xmm5 movaps xmm3, xmm0 movlps xmm6, [rdi + rax*4] movss xmm7, [rdi + rax*4 + 8] unpcklps xmm3, xmm1 movlhps xmm3, xmm5 unpckhps xmm0, xmm1 addps xmm0, xmm3 movhlps xmm3, xmm0 addps xmm0, xmm3 ;# x,y sum in xmm0 movhlps xmm1, xmm2 addss xmm2, xmm1 shufps xmm1, xmm1, 1 addss xmm2, xmm1 ;# z sum in xmm2 addps xmm6, xmm0 addss xmm7, xmm2 movlps [rdi + rax*4], xmm6 movss [rdi + rax*4 + 8], xmm7 dec dword ptr [rsp + nb301_innerk] jz .nb301_updateouterdata jmp .nb301_odd_loop.nb301_updateouterdata: mov ecx, [rsp + nb301_ii3] mov rdi, [rbp + nb301_faction] mov rsi, [rbp + nb301_fshift] mov edx, [rsp + nb301_is3] ;# accumulate Oi forces in xmm0, xmm1, xmm2
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?