nb_kernel300_x86_64_sse.s
来自「最著名最快的分子模拟软件」· S 代码 · 共 1,442 行 · 第 1/3 页
S
1,442 行
movl %ebx,nb300nf_is3(%rsp) ## store is3 movq nb300nf_shiftvec(%rsp),%rax ## rax = base of shiftvec[] movss (%rax,%rbx,4),%xmm0 movss 4(%rax,%rbx,4),%xmm1 movss 8(%rax,%rbx,4),%xmm2 movq nb300nf_iinr(%rsp),%rcx ## rcx = pointer into iinr[] movl (%rcx,%rsi,4),%ebx ## ebx =ii movq nb300nf_charge(%rbp),%rdx movss (%rdx,%rbx,4),%xmm3 mulss nb300nf_facel(%rsp),%xmm3 shufps $0,%xmm3,%xmm3 lea (%rbx,%rbx,2),%rbx ## rbx = 3*ii=ii3 movq nb300nf_pos(%rbp),%rax ## rax = base of pos[] addss (%rax,%rbx,4),%xmm0 addss 4(%rax,%rbx,4),%xmm1 addss 8(%rax,%rbx,4),%xmm2 movaps %xmm3,nb300nf_iq(%rsp) shufps $0,%xmm0,%xmm0 shufps $0,%xmm1,%xmm1 shufps $0,%xmm2,%xmm2 movaps %xmm0,nb300nf_ix(%rsp) movaps %xmm1,nb300nf_iy(%rsp) movaps %xmm2,nb300nf_iz(%rsp) movl %ebx,nb300nf_ii3(%rsp) ## clear vctot and i forces xorps %xmm4,%xmm4 movaps %xmm4,nb300nf_vctot(%rsp) movq nb300nf_jindex(%rsp),%rax movl (%rax,%rsi,4),%ecx ## jindex[n] movl 4(%rax,%rsi,4),%edx ## jindex[n+1] subl %ecx,%edx ## number of innerloop atoms movq nb300nf_pos(%rbp),%rsi movq nb300nf_jjnr(%rsp),%rax shll $2,%ecx addq %rcx,%rax movq %rax,nb300nf_innerjjnr(%rsp) ## pointer to jjnr[nj0] movl %edx,%ecx subl $4,%edx addl nb300nf_ninner(%rsp),%ecx movl %ecx,nb300nf_ninner(%rsp) addl $0,%edx movl %edx,nb300nf_innerk(%rsp) ## number of innerloop atoms jge _nb_kernel300nf_x86_64_sse.nb300nf_unroll_loop jmp _nb_kernel300nf_x86_64_sse.nb300nf_finish_inner_nb_kernel300nf_x86_64_sse.nb300nf_unroll_loop: ## quad-unroll innerloop here movq nb300nf_innerjjnr(%rsp),%rdx ## pointer to jjnr[k] movl (%rdx),%eax movl 4(%rdx),%ebx movl 8(%rdx),%ecx movl 12(%rdx),%edx ## eax-edx=jnr1-4 addq $16,nb300nf_innerjjnr(%rsp) ## advance pointer (unrolled 4) movq nb300nf_charge(%rbp),%rsi ## base of charge[] movss (%rsi,%rax,4),%xmm3 movss (%rsi,%rcx,4),%xmm4 movss (%rsi,%rbx,4),%xmm6 movss (%rsi,%rdx,4),%xmm7 movaps nb300nf_iq(%rsp),%xmm2 shufps $0,%xmm6,%xmm3 shufps $0,%xmm7,%xmm4 shufps $136,%xmm4,%xmm3 ## 10001000 ;# all charges in xmm3 mulps %xmm2,%xmm3 movaps %xmm3,nb300nf_qq(%rsp) movq nb300nf_pos(%rbp),%rsi ## base of pos[] lea (%rax,%rax,2),%rax ## replace jnr with j3 lea (%rbx,%rbx,2),%rbx lea (%rcx,%rcx,2),%rcx ## replace jnr with j3 lea (%rdx,%rdx,2),%rdx ## move four coordinates to xmm0-xmm2 movlps (%rsi,%rax,4),%xmm4 movlps (%rsi,%rcx,4),%xmm5 movss 8(%rsi,%rax,4),%xmm2 movss 8(%rsi,%rcx,4),%xmm6 movhps (%rsi,%rbx,4),%xmm4 movhps (%rsi,%rdx,4),%xmm5 movss 8(%rsi,%rbx,4),%xmm0 movss 8(%rsi,%rdx,4),%xmm1 shufps $0,%xmm0,%xmm2 shufps $0,%xmm1,%xmm6 movaps %xmm4,%xmm0 movaps %xmm4,%xmm1 shufps $136,%xmm6,%xmm2 ## 10001000 shufps $136,%xmm5,%xmm0 ## 10001000 shufps $221,%xmm5,%xmm1 ## 11011101 ## move ix-iz to xmm4-xmm6 movaps nb300nf_ix(%rsp),%xmm4 movaps nb300nf_iy(%rsp),%xmm5 movaps nb300nf_iz(%rsp),%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 nb300nf_three(%rsp),%xmm1 mulps %xmm4,%xmm5 ## rsq*lu*lu movaps nb300nf_half(%rsp),%xmm0 subps %xmm5,%xmm1 ## 30-rsq*lu*lu mulps %xmm2,%xmm1 mulps %xmm1,%xmm0 ## xmm0=rinv mulps %xmm0,%xmm4 ## xmm4=r mulps nb300nf_tsc(%rsp),%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 movq nb300nf_VFtab(%rbp),%rsi movd %mm6,%eax psrlq $32,%mm6 movd %mm7,%ecx psrlq $32,%mm7 movd %mm6,%ebx movd %mm7,%edx movlps (%rsi,%rax,4),%xmm5 movlps (%rsi,%rcx,4),%xmm7 movhps (%rsi,%rbx,4),%xmm5 movhps (%rsi,%rdx,4),%xmm7 ## got half coulomb table movaps %xmm5,%xmm4 shufps $136,%xmm7,%xmm4 ## 10001000 shufps $221,%xmm7,%xmm5 ## 11011101 movlps 8(%rsi,%rax,4),%xmm7 movlps 8(%rsi,%rcx,4),%xmm3 movhps 8(%rsi,%rbx,4),%xmm7 movhps 8(%rsi,%rdx,4),%xmm3 ## other half of coulomb table movaps %xmm7,%xmm6 shufps $136,%xmm3,%xmm6 ## 10001000 shufps $221,%xmm3,%xmm7 ## 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 nb300nf_qq(%rsp),%xmm3 mulps %xmm1,%xmm5 ## xmm5=eps*Fp addps %xmm4,%xmm5 ## xmm5=VV mulps %xmm3,%xmm5 ## vcoul=qq*VV ## at this point xmm5 contains vcoul ## increment vcoul - then we can get rid of mm5 ## update vctot addps nb300nf_vctot(%rsp),%xmm5 movaps %xmm5,nb300nf_vctot(%rsp) ## should we do one more iteration? subl $4,nb300nf_innerk(%rsp) jl _nb_kernel300nf_x86_64_sse.nb300nf_finish_inner jmp _nb_kernel300nf_x86_64_sse.nb300nf_unroll_loop_nb_kernel300nf_x86_64_sse.nb300nf_finish_inner: ## check if at least two particles remain addl $4,nb300nf_innerk(%rsp) movl nb300nf_innerk(%rsp),%edx andl $2,%edx jnz _nb_kernel300nf_x86_64_sse.nb300nf_dopair jmp _nb_kernel300nf_x86_64_sse.nb300nf_checksingle_nb_kernel300nf_x86_64_sse.nb300nf_dopair: movq nb300nf_charge(%rbp),%rsi movq nb300nf_innerjjnr(%rsp),%rcx movl (%rcx),%eax movl 4(%rcx),%ebx addq $8,nb300nf_innerjjnr(%rsp) xorps %xmm7,%xmm7 movss (%rsi,%rax,4),%xmm3 movss (%rsi,%rbx,4),%xmm6 shufps $0,%xmm6,%xmm3 shufps $8,%xmm3,%xmm3 ## 00001000 ;# xmm3(0,1) has the charges mulps nb300nf_iq(%rsp),%xmm3 movlhps %xmm7,%xmm3 movaps %xmm3,nb300nf_qq(%rsp) movq nb300nf_pos(%rbp),%rdi lea (%rax,%rax,2),%rax lea (%rbx,%rbx,2),%rbx ## move coordinates to xmm0-xmm2 movlps (%rdi,%rax,4),%xmm1 movss 8(%rdi,%rax,4),%xmm2 movhps (%rdi,%rbx,4),%xmm1 movss 8(%rdi,%rbx,4),%xmm0 movlhps %xmm7,%xmm3 shufps $0,%xmm0,%xmm2 movaps %xmm1,%xmm0 shufps $136,%xmm2,%xmm2 ## 10001000 shufps $136,%xmm0,%xmm0 ## 10001000 shufps $221,%xmm1,%xmm1 ## 11011101 ## move ix-iz to xmm4-xmm6 xorps %xmm7,%xmm7 movaps nb300nf_ix(%rsp),%xmm4 movaps nb300nf_iy(%rsp),%xmm5 movaps nb300nf_iz(%rsp),%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 nb300nf_three(%rsp),%xmm1 mulps %xmm4,%xmm5 ## rsq*lu*lu movaps nb300nf_half(%rsp),%xmm0 subps %xmm5,%xmm1 ## 30-rsq*lu*lu mulps %xmm2,%xmm1 mulps %xmm1,%xmm0 ## xmm0=rinv mulps %xmm0,%xmm4 ## xmm4=r mulps nb300nf_tsc(%rsp),%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 movq nb300nf_VFtab(%rbp),%rsi movd %mm6,%ecx psrlq $32,%mm6 movd %mm6,%edx movlps (%rsi,%rcx,4),%xmm5 movhps (%rsi,%rdx,4),%xmm5 ## got half coulomb table movaps %xmm5,%xmm4 shufps $136,%xmm4,%xmm4 ## 10001000 shufps $221,%xmm7,%xmm5 ## 11011101 movlps 8(%rsi,%rcx,4),%xmm7 movhps 8(%rsi,%rdx,4),%xmm7 movaps %xmm7,%xmm6 shufps $136,%xmm6,%xmm6 ## 10001000 shufps $221,%xmm7,%xmm7 ## 11011101 ## table ready in xmm4-xmm7 mulps %xmm1,%xmm6 ## xmm6=Geps mulps %xmm2,%xmm7 ## xmm7=Heps2 addps %xmm6,%xmm5 addps %xmm7,%xmm5 ## xmm5=Fp movaps nb300nf_qq(%rsp),%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 nb300nf_vctot(%rsp),%xmm5 movaps %xmm5,nb300nf_vctot(%rsp)_nb_kernel300nf_x86_64_sse.nb300nf_checksingle: movl nb300nf_innerk(%rsp),%edx andl $1,%edx jnz _nb_kernel300nf_x86_64_sse.nb300nf_dosingle jmp _nb_kernel300nf_x86_64_sse.nb300nf_updateouterdata_nb_kernel300nf_x86_64_sse.nb300nf_dosingle: movq nb300nf_charge(%rbp),%rsi movq nb300nf_pos(%rbp),%rdi movq nb300nf_innerjjnr(%rsp),%rcx movl (%rcx),%eax xorps %xmm6,%xmm6 movss (%rsi,%rax,4),%xmm6 ## xmm6(0) has the charge mulps nb300nf_iq(%rsp),%xmm6 movaps %xmm6,nb300nf_qq(%rsp) lea (%rax,%rax,2),%rax ## move coordinates to xmm0-xmm2 movss (%rdi,%rax,4),%xmm0 movss 4(%rdi,%rax,4),%xmm1 movss 8(%rdi,%rax,4),%xmm2 movaps nb300nf_ix(%rsp),%xmm4 movaps nb300nf_iy(%rsp),%xmm5 movaps nb300nf_iz(%rsp),%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 nb300nf_three(%rsp),%xmm1 mulps %xmm4,%xmm5 ## rsq*lu*lu movaps nb300nf_half(%rsp),%xmm0 subps %xmm5,%xmm1 ## 30-rsq*lu*lu mulps %xmm2,%xmm1 mulps %xmm1,%xmm0 ## xmm0=rinv mulps %xmm0,%xmm4 ## xmm4=r mulps nb300nf_tsc(%rsp),%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 movq nb300nf_VFtab(%rbp),%rsi movd %mm6,%ebx movlps (%rsi,%rbx,4),%xmm4 movlps 8(%rsi,%rbx,4),%xmm6 movaps %xmm4,%xmm5 movaps %xmm6,%xmm7 shufps $1,%xmm5,%xmm5 shufps $1,%xmm7,%xmm7 ## table ready in xmm4-xmm7 mulps %xmm1,%xmm6 ## xmm6=Geps mulps %xmm2,%xmm7 ## xmm7=Heps2 addps %xmm6,%xmm5 addps %xmm7,%xmm5 ## xmm5=Fp movaps nb300nf_qq(%rsp),%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 addss nb300nf_vctot(%rsp),%xmm5 movss %xmm5,nb300nf_vctot(%rsp)_nb_kernel300nf_x86_64_sse.nb300nf_updateouterdata: ## get n from stack movl nb300nf_n(%rsp),%esi ## get group index for i particle movq nb300nf_gid(%rbp),%rdx ## base of gid[] movl (%rdx,%rsi,4),%edx ## ggid=gid[n] ## accumulate total potential energy and update it movaps nb300nf_vctot(%rsp),%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 movq nb300nf_Vc(%rbp),%rax addss (%rax,%rdx,4),%xmm7 ## move back to mem movss %xmm7,(%rax,%rdx,4) ## finish if last movl nb300nf_nn1(%rsp),%ecx ## esi already loaded with n incl %esi subl %esi,%ecx jz _nb_kernel300nf_x86_64_sse.nb300nf_outerend ## not last, iterate outer loop once more! movl %esi,nb300nf_n(%rsp) jmp _nb_kernel300nf_x86_64_sse.nb300nf_outer_nb_kernel300nf_x86_64_sse.nb300nf_outerend: ## check if more outer neighborlists remain movl nb300nf_nri(%rsp),%ecx ## esi already loaded with n above subl %esi,%ecx jz _nb_kernel300nf_x86_64_sse.nb300nf_end ## non-zero, do one more workunit jmp _nb_kernel300nf_x86_64_sse.nb300nf_threadloop_nb_kernel300nf_x86_64_sse.nb300nf_end: movl nb300nf_nouter(%rsp),%eax movl nb300nf_ninner(%rsp),%ebx movq nb300nf_outeriter(%rbp),%rcx movq nb300nf_inneriter(%rbp),%rdx movl %eax,(%rcx) movl %ebx,(%rdx) addq $248,%rsp emms pop %r15 pop %r14 pop %r13 pop %r12 pop %rbx pop %rbp ret
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?