nb_kernel400_ia32_sse.s
来自「最著名最快的分子模拟软件」· S 代码 · 共 1,703 行 · 第 1/4 页
S
1,703 行
mulps nb400nf_gbtsc(%esp),%xmm1 movaps %xmm1,nb400nf_gbscale(%esp) movl nb400nf_charge(%ebp),%esi ## base of charge[] movss (%esi,%eax,4),%xmm3 movss (%esi,%ecx,4),%xmm4 movss (%esi,%ebx,4),%xmm6 movss (%esi,%edx,4),%xmm7 mulps nb400nf_iq(%esp),%xmm2 shufps $0,%xmm6,%xmm3 shufps $0,%xmm7,%xmm4 shufps $136,%xmm4,%xmm3 ## constant 10001000 ;# all charges in xmm3 mulps %xmm2,%xmm3 movaps %xmm3,nb400nf_qq(%esp) movl nb400nf_pos(%ebp),%esi ## base of pos[] leal (%eax,%eax,2),%eax ## replace jnr with j3 leal (%ebx,%ebx,2),%ebx leal (%ecx,%ecx,2),%ecx ## replace jnr with j3 leal (%edx,%edx,2),%edx ## move four coordinates to xmm0-xmm2 movlps (%esi,%eax,4),%xmm4 movlps (%esi,%ecx,4),%xmm5 movss 8(%esi,%eax,4),%xmm2 movss 8(%esi,%ecx,4),%xmm6 movhps (%esi,%ebx,4),%xmm4 movhps (%esi,%edx,4),%xmm5 movss 8(%esi,%ebx,4),%xmm0 movss 8(%esi,%edx,4),%xmm1 shufps $0,%xmm0,%xmm2 shufps $0,%xmm1,%xmm6 movaps %xmm4,%xmm0 movaps %xmm4,%xmm1 shufps $136,%xmm6,%xmm2 ## constant 10001000 shufps $136,%xmm5,%xmm0 ## constant 10001000 shufps $221,%xmm5,%xmm1 ## constant 11011101 ## move ix-iz to xmm4-xmm6 movaps nb400nf_ix(%esp),%xmm4 movaps nb400nf_iy(%esp),%xmm5 movaps nb400nf_iz(%esp),%xmm6 ## calc dr subps %xmm0,%xmm4 subps %xmm1,%xmm5 subps %xmm2,%xmm6 ## square it mulps %xmm4,%xmm4 mulps %xmm5,%xmm5 mulps %xmm6,%xmm6 addps %xmm5,%xmm4 addps %xmm6,%xmm4 ## rsq in xmm4 rsqrtps %xmm4,%xmm5 ## lookup seed in xmm5 movaps %xmm5,%xmm2 mulps %xmm5,%xmm5 movaps nb400nf_three(%esp),%xmm1 mulps %xmm4,%xmm5 ## rsq*lu*lu movaps nb400nf_half(%esp),%xmm0 subps %xmm5,%xmm1 ## constant 30-rsq*lu*lu mulps %xmm2,%xmm1 mulps %xmm1,%xmm0 ## xmm0=rinv mulps %xmm0,%xmm4 ## xmm4=r mulps nb400nf_gbscale(%esp),%xmm4 movhlps %xmm4,%xmm5 cvttps2pi %xmm4,%mm6 cvttps2pi %xmm5,%mm7 ## mm6/mm7 contain lu indices cvtpi2ps %mm6,%xmm6 cvtpi2ps %mm7,%xmm5 movlhps %xmm5,%xmm6 subps %xmm6,%xmm4 movaps %xmm4,%xmm1 ## xmm1=eps movaps %xmm1,%xmm2 mulps %xmm2,%xmm2 ## xmm2=eps2 pslld $2,%mm6 pslld $2,%mm7 movd %eax,%mm0 movd %ebx,%mm1 movd %ecx,%mm2 movd %edx,%mm3 movl nb400nf_GBtab(%ebp),%esi movd %mm6,%eax psrlq $32,%mm6 movd %mm7,%ecx psrlq $32,%mm7 movd %mm6,%ebx movd %mm7,%edx ## load coulomb table movaps (%esi,%eax,4),%xmm4 movaps (%esi,%ebx,4),%xmm5 movaps (%esi,%ecx,4),%xmm6 movaps (%esi,%edx,4),%xmm7 ## transpose, using xmm3 for scratch movaps %xmm6,%xmm3 shufps $0xEE,%xmm7,%xmm3 shufps $0x44,%xmm7,%xmm6 movaps %xmm4,%xmm7 shufps $0xEE,%xmm5,%xmm7 shufps $0x44,%xmm5,%xmm4 movaps %xmm4,%xmm5 shufps $0xDD,%xmm6,%xmm5 shufps $0x88,%xmm6,%xmm4 movaps %xmm7,%xmm6 shufps $0x88,%xmm3,%xmm6 shufps $0xDD,%xmm3,%xmm7 ## coulomb table ready, in xmm4-xmm7 mulps %xmm1,%xmm6 ## xmm6=Geps mulps %xmm2,%xmm7 ## xmm7=Heps2 addps %xmm6,%xmm5 addps %xmm7,%xmm5 ## xmm5=Fp movaps nb400nf_qq(%esp),%xmm3 mulps %xmm1,%xmm5 ## xmm5=eps*Fp addps %xmm4,%xmm5 ## xmm5=VV mulps %xmm3,%xmm5 ## vcoul=qq*VV addps nb400nf_vctot(%esp),%xmm5 movaps %xmm5,nb400nf_vctot(%esp) ## should we do one more iteration? subl $4,nb400nf_innerk(%esp) jl _nb_kernel400nf_ia32_sse.nb400nf_finish_inner jmp _nb_kernel400nf_ia32_sse.nb400nf_unroll_loop_nb_kernel400nf_ia32_sse.nb400nf_finish_inner: ## check if at least two particles remain addl $4,nb400nf_innerk(%esp) movl nb400nf_innerk(%esp),%edx andl $2,%edx jnz _nb_kernel400nf_ia32_sse.nb400nf_dopair jmp _nb_kernel400nf_ia32_sse.nb400nf_checksingle_nb_kernel400nf_ia32_sse.nb400nf_dopair: movl nb400nf_innerjjnr(%esp),%ecx movl (%ecx),%eax movl 4(%ecx),%ebx addl $8,nb400nf_innerjjnr(%esp) xorps %xmm2,%xmm2 movaps %xmm2,%xmm6 ## load isa2 movl nb400nf_invsqrta(%ebp),%esi movss (%esi,%eax,4),%xmm2 movss (%esi,%ebx,4),%xmm3 unpcklps %xmm3,%xmm2 ## isa2 in xmm3(0,1) mulps nb400nf_isai(%esp),%xmm2 movaps %xmm2,nb400nf_isaprod(%esp) movaps %xmm2,%xmm1 mulps nb400nf_gbtsc(%esp),%xmm1 movaps %xmm1,nb400nf_gbscale(%esp) movl nb400nf_charge(%ebp),%esi ## base of charge[] movss (%esi,%eax,4),%xmm3 movss (%esi,%ebx,4),%xmm6 unpcklps %xmm6,%xmm3 ## constant 00001000 ;# xmm3(0,1) has the charges mulps nb400nf_iq(%esp),%xmm2 mulps %xmm2,%xmm3 movaps %xmm3,nb400nf_qq(%esp) movl nb400nf_pos(%ebp),%edi leal (%eax,%eax,2),%eax leal (%ebx,%ebx,2),%ebx ## move coordinates to xmm0-xmm2 movlps (%edi,%eax,4),%xmm1 movss 8(%edi,%eax,4),%xmm2 movhps (%edi,%ebx,4),%xmm1 movss 8(%edi,%ebx,4),%xmm0 movlhps %xmm7,%xmm3 shufps $0,%xmm0,%xmm2 movaps %xmm1,%xmm0 shufps $136,%xmm2,%xmm2 ## constant 10001000 shufps $136,%xmm0,%xmm0 ## constant 10001000 shufps $221,%xmm1,%xmm1 ## constant 11011101 movl nb400nf_faction(%ebp),%edi ## move ix-iz to xmm4-xmm6 xorps %xmm7,%xmm7 movaps nb400nf_ix(%esp),%xmm4 movaps nb400nf_iy(%esp),%xmm5 movaps nb400nf_iz(%esp),%xmm6 ## calc dr subps %xmm0,%xmm4 subps %xmm1,%xmm5 subps %xmm2,%xmm6 ## square it mulps %xmm4,%xmm4 mulps %xmm5,%xmm5 mulps %xmm6,%xmm6 addps %xmm5,%xmm4 addps %xmm6,%xmm4 ## rsq in xmm4 rsqrtps %xmm4,%xmm5 ## lookup seed in xmm5 movaps %xmm5,%xmm2 mulps %xmm5,%xmm5 movaps nb400nf_three(%esp),%xmm1 mulps %xmm4,%xmm5 ## rsq*lu*lu movaps nb400nf_half(%esp),%xmm0 subps %xmm5,%xmm1 ## constant 30-rsq*lu*lu mulps %xmm2,%xmm1 mulps %xmm1,%xmm0 ## xmm0=rinv mulps %xmm0,%xmm4 ## xmm4=r mulps nb400nf_gbscale(%esp),%xmm4 cvttps2pi %xmm4,%mm6 ## mm6 contain lu indices cvtpi2ps %mm6,%xmm6 subps %xmm6,%xmm4 movaps %xmm4,%xmm1 ## xmm1=eps movaps %xmm1,%xmm2 mulps %xmm2,%xmm2 ## xmm2=eps2 pslld $2,%mm6 movl nb400nf_GBtab(%ebp),%esi movd %mm6,%ecx psrlq $32,%mm6 movd %mm6,%edx ## load coulomb table movaps (%esi,%ecx,4),%xmm4 movaps (%esi,%edx,4),%xmm7 ## transpose, using xmm3 for scratch movaps %xmm4,%xmm6 unpcklps %xmm7,%xmm4 ## Y1 Y2 F1 F2 unpckhps %xmm7,%xmm6 ## G1 G2 H1 H2 movhlps %xmm4,%xmm5 ## F1 F2 movhlps %xmm6,%xmm7 ## H1 H2 ## coulomb table ready, in xmm4-xmm7 mulps %xmm1,%xmm6 ## xmm6=Geps mulps %xmm2,%xmm7 ## xmm7=Heps2 addps %xmm6,%xmm5 addps %xmm7,%xmm5 ## xmm5=Fp movaps nb400nf_qq(%esp),%xmm3 mulps %xmm1,%xmm5 ## xmm5=eps*Fp addps %xmm4,%xmm5 ## xmm5=VV mulps %xmm3,%xmm5 ## vcoul=qq*VV addps nb400nf_vctot(%esp),%xmm5 movaps %xmm5,nb400nf_vctot(%esp)_nb_kernel400nf_ia32_sse.nb400nf_checksingle: movl nb400nf_innerk(%esp),%edx andl $1,%edx jnz _nb_kernel400nf_ia32_sse.nb400nf_dosingle jmp _nb_kernel400nf_ia32_sse.nb400nf_updateouterdata_nb_kernel400nf_ia32_sse.nb400nf_dosingle: movl nb400nf_charge(%ebp),%esi movl nb400nf_invsqrta(%ebp),%edx movl nb400nf_pos(%ebp),%edi movl nb400nf_innerjjnr(%esp),%ecx movl (%ecx),%eax xorps %xmm2,%xmm2 movaps %xmm2,%xmm6 movss (%edx,%eax,4),%xmm2 ## isa2 mulss nb400nf_isai(%esp),%xmm2 movss %xmm2,nb400nf_isaprod(%esp) movss %xmm2,%xmm1 mulss nb400nf_gbtsc(%esp),%xmm1 movss %xmm1,nb400nf_gbscale(%esp) mulss nb400nf_iq(%esp),%xmm2 movss (%esi,%eax,4),%xmm6 ## xmm6(0) has the charge mulss %xmm2,%xmm6 movss %xmm6,nb400nf_qq(%esp) leal (%eax,%eax,2),%eax ## move coordinates to xmm0-xmm2 movss (%edi,%eax,4),%xmm0 movss 4(%edi,%eax,4),%xmm1 movss 8(%edi,%eax,4),%xmm2 movss nb400nf_ix(%esp),%xmm4 movss nb400nf_iy(%esp),%xmm5 movss nb400nf_iz(%esp),%xmm6 ## calc dr subss %xmm0,%xmm4 subss %xmm1,%xmm5 subss %xmm2,%xmm6 ## square it mulss %xmm4,%xmm4 mulss %xmm5,%xmm5 mulss %xmm6,%xmm6 addss %xmm5,%xmm4 addss %xmm6,%xmm4 ## rsq in xmm4 rsqrtss %xmm4,%xmm5 ## lookup seed in xmm5 movss %xmm5,%xmm2 mulss %xmm5,%xmm5 movss nb400nf_three(%esp),%xmm1 mulss %xmm4,%xmm5 ## rsq*lu*lu movss nb400nf_half(%esp),%xmm0 subss %xmm5,%xmm1 ## constant 30-rsq*lu*lu mulss %xmm2,%xmm1 mulss %xmm1,%xmm0 ## xmm0=rinv mulss %xmm0,%xmm4 ## xmm4=r mulss nb400nf_gbscale(%esp),%xmm4 cvttss2si %xmm4,%ebx ## mm6 contain lu indices cvtsi2ss %ebx,%xmm6 subss %xmm6,%xmm4 movss %xmm4,%xmm1 ## xmm1=eps movss %xmm1,%xmm2 mulss %xmm2,%xmm2 ## xmm2=eps2 shll $2,%ebx movl nb400nf_GBtab(%ebp),%esi movaps (%esi,%ebx,4),%xmm4 movhlps %xmm4,%xmm6 movaps %xmm4,%xmm5 movaps %xmm6,%xmm7 shufps $1,%xmm5,%xmm5 shufps $1,%xmm7,%xmm7 ## table ready in xmm4-xmm7 mulss %xmm1,%xmm6 ## xmm6=Geps mulss %xmm2,%xmm7 ## xmm7=Heps2 addss %xmm6,%xmm5 addss %xmm7,%xmm5 ## xmm5=Fp movss nb400nf_qq(%esp),%xmm3 mulss %xmm1,%xmm5 ## xmm5=eps*Fp addss %xmm4,%xmm5 ## xmm5=VV mulss %xmm3,%xmm5 ## vcoul=qq*VV addss nb400nf_vctot(%esp),%xmm5 movss %xmm5,nb400nf_vctot(%esp)_nb_kernel400nf_ia32_sse.nb400nf_updateouterdata: ## get n from stack movl nb400nf_n(%esp),%esi ## get group index for i particle movl nb400nf_gid(%ebp),%edx ## base of gid[] movl (%edx,%esi,4),%edx ## ggid=gid[n] ## accumulate total potential energy and update it movaps nb400nf_vctot(%esp),%xmm7 ## accumulate movhlps %xmm7,%xmm6 addps %xmm6,%xmm7 ## pos 0-1 in xmm7 have the sum now movaps %xmm7,%xmm6 shufps $1,%xmm6,%xmm6 addss %xmm6,%xmm7 ## add earlier value from mem movl nb400nf_Vc(%ebp),%eax addss (%eax,%edx,4),%xmm7 ## move back to mem movss %xmm7,(%eax,%edx,4) ## finish if last movl nb400nf_nn1(%esp),%ecx ## esi already loaded with n incl %esi subl %esi,%ecx jz _nb_kernel400nf_ia32_sse.nb400nf_outerend ## not last, iterate outer loop once more! movl %esi,nb400nf_n(%esp) jmp _nb_kernel400nf_ia32_sse.nb400nf_outer_nb_kernel400nf_ia32_sse.nb400nf_outerend: ## check if more outer neighborlists remain movl nb400nf_nri(%esp),%ecx ## esi already loaded with n above subl %esi,%ecx jz _nb_kernel400nf_ia32_sse.nb400nf_end ## non-zero, do one more workunit jmp _nb_kernel400nf_ia32_sse.nb400nf_threadloop_nb_kernel400nf_ia32_sse.nb400nf_end: emms movl nb400nf_nouter(%esp),%eax movl nb400nf_ninner(%esp),%ebx movl nb400nf_outeriter(%ebp),%ecx movl nb400nf_inneriter(%ebp),%edx movl %eax,(%ecx) movl %ebx,(%edx) movl nb400nf_salign(%esp),%eax addl %eax,%esp addl $236,%esp popl %edi popl %esi popl %edx popl %ecx popl %ebx popl %eax leave ret
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?