nb_kernel330_ia32_sse.s
来自「最著名最快的分子模拟软件」· S 代码 · 共 2,062 行 · 第 1/5 页
S
2,062 行
.set nb330nf_iz, 32.set nb330nf_iq, 48.set nb330nf_tsc, 64.set nb330nf_qq, 80.set nb330nf_c6, 96.set nb330nf_c12, 112.set nb330nf_vctot, 128.set nb330nf_Vvdwtot, 144.set nb330nf_half, 160.set nb330nf_three, 176.set nb330nf_is3, 192.set nb330nf_ii3, 196.set nb330nf_ntia, 200.set nb330nf_innerjjnr, 204.set nb330nf_innerk, 208.set nb330nf_n, 212.set nb330nf_nn1, 216.set nb330nf_nri, 220.set nb330nf_facel, 224.set nb330nf_ntype, 228.set nb330nf_nouter, 232.set nb330nf_ninner, 236.set nb330nf_salign, 240 pushl %ebp movl %esp,%ebp pushl %eax pushl %ebx pushl %ecx pushl %edx pushl %esi pushl %edi subl $244,%esp ## local stack space movl %esp,%eax andl $0xf,%eax subl %eax,%esp movl %eax,nb330nf_salign(%esp) emms ## Move args passed by reference to stack movl nb330nf_p_nri(%ebp),%ecx movl nb330nf_p_facel(%ebp),%esi movl nb330nf_p_ntype(%ebp),%edi movl (%ecx),%ecx movl (%esi),%esi movl (%edi),%edi movl %ecx,nb330nf_nri(%esp) movl %esi,nb330nf_facel(%esp) movl %edi,nb330nf_ntype(%esp) ## zero iteration counters movl $0,%eax movl %eax,nb330nf_nouter(%esp) movl %eax,nb330nf_ninner(%esp) movl nb330nf_p_tabscale(%ebp),%eax movss (%eax),%xmm3 shufps $0,%xmm3,%xmm3 movaps %xmm3,nb330nf_tsc(%esp) ## create constant floating-point factors on stack movl $0x3f000000,%eax ## constant 0.5 in IEEE (hex) movl %eax,nb330nf_half(%esp) movss nb330nf_half(%esp),%xmm1 shufps $0,%xmm1,%xmm1 ## splat to all elements movaps %xmm1,%xmm2 addps %xmm2,%xmm2 ## constant 1.0 movaps %xmm2,%xmm3 addps %xmm2,%xmm2 ## constant 2.0 addps %xmm2,%xmm3 ## constant 3.0 movaps %xmm1,nb330nf_half(%esp) movaps %xmm3,nb330nf_three(%esp)_nb_kernel330nf_ia32_sse.nb330nf_threadloop: movl nb330nf_count(%ebp),%esi ## pointer to sync counter movl (%esi),%eax_nb_kernel330nf_ia32_sse.nb330nf_spinlock: movl %eax,%ebx ## ebx=*count=nn0 addl $1,%ebx ## ebx=nn1=nn0+10 lock cmpxchgl %ebx,(%esi) ## write nn1 to *counter, ## if it hasnt changed. ## or reread *counter to eax. pause ## -> better p4 performance jnz _nb_kernel330nf_ia32_sse.nb330nf_spinlock ## if(nn1>nri) nn1=nri movl nb330nf_nri(%esp),%ecx movl %ecx,%edx subl %ebx,%ecx cmovlel %edx,%ebx ## if(nn1>nri) nn1=nri ## Cleared the spinlock if we got here. ## eax contains nn0, ebx contains nn1. movl %eax,nb330nf_n(%esp) movl %ebx,nb330nf_nn1(%esp) subl %eax,%ebx ## calc number of outer lists movl %eax,%esi ## copy n to esi jg _nb_kernel330nf_ia32_sse.nb330nf_outerstart jmp _nb_kernel330nf_ia32_sse.nb330nf_end_nb_kernel330nf_ia32_sse.nb330nf_outerstart: ## ebx contains number of outer iterations addl nb330nf_nouter(%esp),%ebx movl %ebx,nb330nf_nouter(%esp)_nb_kernel330nf_ia32_sse.nb330nf_outer: movl nb330nf_shift(%ebp),%eax ## eax = pointer into shift[] movl (%eax,%esi,4),%ebx ## ebx=shift[n] leal (%ebx,%ebx,2),%ebx ## ebx=3*is movl %ebx,nb330nf_is3(%esp) ## store is3 movl nb330nf_shiftvec(%ebp),%eax ## eax = base of shiftvec[] movss (%eax,%ebx,4),%xmm0 movss 4(%eax,%ebx,4),%xmm1 movss 8(%eax,%ebx,4),%xmm2 movl nb330nf_iinr(%ebp),%ecx ## ecx = pointer into iinr[] movl (%ecx,%esi,4),%ebx ## ebx =ii movl nb330nf_charge(%ebp),%edx movss (%edx,%ebx,4),%xmm3 mulss nb330nf_facel(%esp),%xmm3 shufps $0,%xmm3,%xmm3 movl nb330nf_type(%ebp),%edx movl (%edx,%ebx,4),%edx imull nb330nf_ntype(%esp),%edx shll %edx movl %edx,nb330nf_ntia(%esp) leal (%ebx,%ebx,2),%ebx ## ebx = 3*ii=ii3 movl nb330nf_pos(%ebp),%eax ## eax = base of pos[] addss (%eax,%ebx,4),%xmm0 addss 4(%eax,%ebx,4),%xmm1 addss 8(%eax,%ebx,4),%xmm2 movaps %xmm3,nb330nf_iq(%esp) shufps $0,%xmm0,%xmm0 shufps $0,%xmm1,%xmm1 shufps $0,%xmm2,%xmm2 movaps %xmm0,nb330nf_ix(%esp) movaps %xmm1,nb330nf_iy(%esp) movaps %xmm2,nb330nf_iz(%esp) movl %ebx,nb330nf_ii3(%esp) ## clear vctot xorps %xmm4,%xmm4 movaps %xmm4,nb330nf_vctot(%esp) movaps %xmm4,nb330nf_Vvdwtot(%esp) movl nb330nf_jindex(%ebp),%eax movl (%eax,%esi,4),%ecx ## jindex[n] movl 4(%eax,%esi,4),%edx ## jindex[n+1] subl %ecx,%edx ## number of innerloop atoms movl nb330nf_pos(%ebp),%esi movl nb330nf_jjnr(%ebp),%eax shll $2,%ecx addl %ecx,%eax movl %eax,nb330nf_innerjjnr(%esp) ## pointer to jjnr[nj0] movl %edx,%ecx subl $4,%edx addl nb330nf_ninner(%esp),%ecx movl %ecx,nb330nf_ninner(%esp) addl $0,%edx movl %edx,nb330nf_innerk(%esp) ## number of innerloop atoms jge _nb_kernel330nf_ia32_sse.nb330nf_unroll_loop jmp _nb_kernel330nf_ia32_sse.nb330nf_finish_inner_nb_kernel330nf_ia32_sse.nb330nf_unroll_loop: ## quad-unroll innerloop here movl nb330nf_innerjjnr(%esp),%edx ## pointer to jjnr[k] movl (%edx),%eax movl 4(%edx),%ebx movl 8(%edx),%ecx movl 12(%edx),%edx ## eax-edx=jnr1-4 addl $16,nb330nf_innerjjnr(%esp) ## advance pointer (unrolled 4) movl nb330nf_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 movaps nb330nf_iq(%esp),%xmm2 shufps $0,%xmm6,%xmm3 shufps $0,%xmm7,%xmm4 shufps $136,%xmm4,%xmm3 ## constant 10001000 ;# all charges in xmm3 movd %eax,%mm0 ## use mmx registers as temp storage movd %ebx,%mm1 mulps %xmm2,%xmm3 movd %ecx,%mm2 movd %edx,%mm3 movaps %xmm3,nb330nf_qq(%esp) movl nb330nf_type(%ebp),%esi movl (%esi,%eax,4),%eax movl (%esi,%ebx,4),%ebx movl (%esi,%ecx,4),%ecx movl (%esi,%edx,4),%edx movl nb330nf_vdwparam(%ebp),%esi shll %eax shll %ebx shll %ecx shll %edx movl nb330nf_ntia(%esp),%edi addl %edi,%eax addl %edi,%ebx addl %edi,%ecx addl %edi,%edx movlps (%esi,%eax,4),%xmm6 movlps (%esi,%ecx,4),%xmm7 movhps (%esi,%ebx,4),%xmm6 movhps (%esi,%edx,4),%xmm7 movaps %xmm6,%xmm4 shufps $136,%xmm7,%xmm4 ## constant 10001000 shufps $221,%xmm7,%xmm6 ## constant 11011101 movd %mm0,%eax movd %mm1,%ebx movd %mm2,%ecx movd %mm3,%edx movaps %xmm4,nb330nf_c6(%esp) movaps %xmm6,nb330nf_c12(%esp) movl nb330nf_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 nb330nf_ix(%esp),%xmm4 movaps nb330nf_iy(%esp),%xmm5 movaps nb330nf_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 nb330nf_three(%esp),%xmm1 mulps %xmm4,%xmm5 ## rsq*lu*lu movaps nb330nf_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 nb330nf_tsc(%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 nb330nf_VFtab(%ebp),%esi movd %mm6,%eax psrlq $32,%mm6 movd %mm7,%ecx psrlq $32,%mm7 movd %mm6,%ebx movd %mm7,%edx leal (%eax,%eax,2),%eax leal (%ebx,%ebx,2),%ebx leal (%ecx,%ecx,2),%ecx leal (%edx,%edx,2),%edx movlps (%esi,%eax,4),%xmm5 movlps (%esi,%ecx,4),%xmm7 movhps (%esi,%ebx,4),%xmm5 movhps (%esi,%edx,4),%xmm7 ## got half coulomb table movaps %xmm5,%xmm4 shufps $136,%xmm7,%xmm4 ## constant 10001000 shufps $221,%xmm7,%xmm5 ## constant 11011101 movlps 8(%esi,%eax,4),%xmm7 movlps 8(%esi,%ecx,4),%xmm3 movhps 8(%esi,%ebx,4),%xmm7 movhps 8(%esi,%edx,4),%xmm3 ## other half of coulomb table movaps %xmm7,%xmm6 shufps $136,%xmm3,%xmm6 ## constant 10001000 shufps $221,%xmm3,%xmm7 ## constant 11011101 ## 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 nb330nf_qq(%esp),%xmm3 mulps %xmm1,%xmm5 ## xmm5=eps*Fp addps %xmm4,%xmm5 ## xmm5=VV mulps %xmm3,%xmm5 ## vcoul=qq*VV ## at this point mm5 contains vcoul ## increment vcoul - then we can get rid of mm5 ## update vctot addps nb330nf_vctot(%esp),%xmm5 movaps %xmm5,nb330nf_vctot(%esp) ## dispersion movlps 16(%esi,%eax,4),%xmm5 movlps 16(%esi,%ecx,4),%xmm7 movhps 16(%esi,%ebx,4),%xmm5 movhps 16(%esi,%edx,4),%xmm7 ## got half dispersion table movaps %xmm5,%xmm4 shufps $136,%xmm7,%xmm4 ## constant 10001000 shufps $221,%xmm7,%xmm5 ## constant 11011101 movlps 24(%esi,%eax,4),%xmm7 movlps 24(%esi,%ecx,4),%xmm3 movhps 24(%esi,%ebx,4),%xmm7 movhps 24(%esi,%edx,4),%xmm3 ## other half of dispersion table movaps %xmm7,%xmm6 shufps $136,%xmm3,%xmm6 ## constant 10001000 shufps $221,%xmm3,%xmm7 ## constant 11011101 ## dispersion table ready, in xmm4-xmm7 mulps %xmm1,%xmm6 ## xmm6=Geps mulps %xmm2,%xmm7 ## xmm7=Heps2 addps %xmm6,%xmm5 addps %xmm7,%xmm5 ## xmm5=Fp mulps %xmm1,%xmm5 ## xmm5=eps*Fp addps %xmm4,%xmm5 ## xmm5=VV movaps nb330nf_c6(%esp),%xmm4 mulps %xmm4,%xmm5 ## Vvdw6 ## put scalar force on stack addps nb330nf_Vvdwtot(%esp),%xmm5 movaps %xmm5,nb330nf_Vvdwtot(%esp) ## repulsion movlps 32(%esi,%eax,4),%xmm5 movlps 32(%esi,%ecx,4),%xmm7 movhps 32(%esi,%ebx,4),%xmm5 movhps 32(%esi,%edx,4),%xmm7 ## got half repulsion table movaps %xmm5,%xmm4 shufps $136,%xmm7,%xmm4 ## constant 10001000 shufps $221,%xmm7,%xmm5 ## constant 11011101 movlps 40(%esi,%eax,4),%xmm7 movlps 40(%esi,%ecx,4),%xmm3 movhps 40(%esi,%ebx,4),%xmm7 movhps 40(%esi,%edx,4),%xmm3 ## other half of repulsion table movaps %xmm7,%xmm6 shufps $136,%xmm3,%xmm6 ## constant 10001000 shufps $221,%xmm3,%xmm7 ## constant 11011101 ## table ready, in xmm4-xmm7 mulps %xmm1,%xmm6 ## xmm6=Geps mulps %xmm2,%xmm7 ## xmm7=Heps2 addps %xmm6,%xmm5 addps %xmm7,%xmm5 ## xmm5=Fp
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?