nb_kernel311_x86_64_sse.s
来自「最著名最快的分子模拟软件」· S 代码 · 共 2,136 行 · 第 1/5 页
S
2,136 行
unpcklps %xmm7,%xmm6 movlhps %xmm6,%xmm2 subps %xmm0,%xmm3 subps %xmm1,%xmm4 subps %xmm2,%xmm5 movaps %xmm3,nb311_dxO(%rsp) movaps %xmm4,nb311_dyO(%rsp) movaps %xmm5,nb311_dzO(%rsp) mulps %xmm3,%xmm3 mulps %xmm4,%xmm4 mulps %xmm5,%xmm5 addps %xmm3,%xmm4 addps %xmm5,%xmm4 ## rsq in xmm4 rsqrtps %xmm4,%xmm5 ## lookup seed in xmm5 movaps %xmm5,%xmm2 mulps %xmm5,%xmm5 movaps nb311_three(%rsp),%xmm1 mulps %xmm4,%xmm5 ## rsq*lu*lu movaps nb311_half(%rsp),%xmm0 subps %xmm5,%xmm1 ## 30-rsq*lu*lu mulps %xmm2,%xmm1 mulps %xmm1,%xmm0 ## 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 $224,%xmm0,%xmm0 ## 11100000 mulps %xmm0,%xmm4 ## xmm4=r movaps %xmm0,nb311_rinvO(%rsp) mulps nb311_tsc(%rsp),%xmm4 movhlps %xmm4,%xmm7 cvttps2pi %xmm4,%mm6 cvttps2pi %xmm7,%mm7 ## mm6/mm7 contain lu indices cvtpi2ps %mm6,%xmm3 cvtpi2ps %mm7,%xmm7 movlhps %xmm7,%xmm3 subps %xmm3,%xmm4 movaps %xmm4,%xmm1 ## xmm1=eps movaps %xmm1,%xmm2 mulps %xmm2,%xmm2 ## xmm2=eps2 pslld $2,%mm6 pslld $2,%mm7 movd %eax,%mm0 movd %ecx,%mm1 movd %edx,%mm2 movq nb311_VFtab(%rbp),%rsi movd %mm6,%eax movd %mm7,%ecx psrlq $32,%mm7 movd %mm7,%edx movlps (%rsi,%rax,4),%xmm5 movlps (%rsi,%rcx,4),%xmm7 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,%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 addps %xmm7,%xmm7 ## two*Heps2 movaps nb311_qqO(%rsp),%xmm0 addps %xmm6,%xmm7 addps %xmm5,%xmm7 ## xmm7=FF mulps %xmm1,%xmm5 ## xmm5=eps*Fp addps %xmm4,%xmm5 ## xmm5=VV mulps %xmm0,%xmm5 ## vcoul=qq*VV mulps %xmm7,%xmm0 ## fijC=FF*qq ## at this point mm5 contains vcoul and xmm0 fijC ## increment vcoul - then we can get rid of mm5 addps nb311_vctot(%rsp),%xmm5 movaps %xmm5,nb311_vctot(%rsp) ## do nontable L-J movaps nb311_rinvO(%rsp),%xmm2 mulps %xmm2,%xmm2 movaps %xmm2,%xmm1 mulps %xmm1,%xmm1 mulps %xmm2,%xmm1 ## xmm1=rinvsix movaps %xmm1,%xmm4 mulps %xmm4,%xmm4 ## xmm4=rinvtwelve mulps nb311_c6(%rsp),%xmm1 mulps nb311_c12(%rsp),%xmm4 movaps %xmm4,%xmm3 subps %xmm1,%xmm3 ## xmm3=Vvdw12-Vvdw6 mulps nb311_six(%rsp),%xmm1 mulps nb311_twelve(%rsp),%xmm4 subps %xmm1,%xmm4 addps nb311_Vvdwtot(%rsp),%xmm3 mulps nb311_rinvO(%rsp),%xmm4 mulps nb311_tsc(%rsp),%xmm0 subps %xmm0,%xmm4 movaps %xmm3,nb311_Vvdwtot(%rsp) mulps nb311_rinvO(%rsp),%xmm4 movd %mm0,%eax movd %mm1,%ecx movd %mm2,%edx movaps nb311_dxO(%rsp),%xmm0 movaps nb311_dyO(%rsp),%xmm1 movaps nb311_dzO(%rsp),%xmm2 mulps %xmm4,%xmm0 mulps %xmm4,%xmm1 mulps %xmm4,%xmm2 ## xmm0-xmm2 now contains tx-tz (partial force) movss nb311_fixO(%rsp),%xmm3 movss nb311_fiyO(%rsp),%xmm4 movss nb311_fizO(%rsp),%xmm5 addss %xmm0,%xmm3 addss %xmm1,%xmm4 addss %xmm2,%xmm5 movss %xmm3,nb311_fixO(%rsp) movss %xmm4,nb311_fiyO(%rsp) movss %xmm5,nb311_fizO(%rsp) ## updated the O force now do the H's movaps %xmm0,%xmm3 movaps %xmm1,%xmm4 movaps %xmm2,%xmm5 shufps $230,%xmm3,%xmm3 ## 11100110 ;# shift right shufps $230,%xmm4,%xmm4 ## 11100110 shufps $230,%xmm5,%xmm5 ## 11100110 addss nb311_fixH1(%rsp),%xmm3 addss nb311_fiyH1(%rsp),%xmm4 addss nb311_fizH1(%rsp),%xmm5 movss %xmm3,nb311_fixH1(%rsp) movss %xmm4,nb311_fiyH1(%rsp) movss %xmm5,nb311_fizH1(%rsp) ## updated the H1 force movq nb311_faction(%rbp),%rdi shufps $231,%xmm3,%xmm3 ## 11100111 ;# shift right shufps $231,%xmm4,%xmm4 ## 11100111 shufps $231,%xmm5,%xmm5 ## 11100111 addss nb311_fixH2(%rsp),%xmm3 addss nb311_fiyH2(%rsp),%xmm4 addss nb311_fizH2(%rsp),%xmm5 movss %xmm3,nb311_fixH2(%rsp) movss %xmm4,nb311_fiyH2(%rsp) movss %xmm5,nb311_fizH2(%rsp) ## updated the H2 force ## the fj's - start by accumulating the tx/ty/tz force in xmm0, xmm1 xorps %xmm5,%xmm5 movaps %xmm0,%xmm3 movlps (%rdi,%rax,4),%xmm6 movss 8(%rdi,%rax,4),%xmm7 unpcklps %xmm1,%xmm3 movlhps %xmm5,%xmm3 unpckhps %xmm1,%xmm0 addps %xmm3,%xmm0 movhlps %xmm0,%xmm3 addps %xmm3,%xmm0 ## x,y sum in xmm0 movhlps %xmm2,%xmm1 addss %xmm1,%xmm2 shufps $1,%xmm1,%xmm1 addss %xmm1,%xmm2 ## z sum in xmm2 addps %xmm0,%xmm6 addss %xmm2,%xmm7 movlps %xmm6,(%rdi,%rax,4) movss %xmm7,8(%rdi,%rax,4) decl nb311_innerk(%rsp) jz _nb_kernel311_x86_64_sse.nb311_updateouterdata jmp _nb_kernel311_x86_64_sse.nb311_odd_loop_nb_kernel311_x86_64_sse.nb311_updateouterdata: movl nb311_ii3(%rsp),%ecx movq nb311_faction(%rbp),%rdi movq nb311_fshift(%rbp),%rsi movl nb311_is3(%rsp),%edx ## accumulate Oi forces in xmm0, xmm1, xmm2 movaps nb311_fixO(%rsp),%xmm0 movaps nb311_fiyO(%rsp),%xmm1 movaps nb311_fizO(%rsp),%xmm2 movhlps %xmm0,%xmm3 movhlps %xmm1,%xmm4 movhlps %xmm2,%xmm5 addps %xmm3,%xmm0 addps %xmm4,%xmm1 addps %xmm5,%xmm2 ## sum is in 1/2 in xmm0-xmm2 movaps %xmm0,%xmm3 movaps %xmm1,%xmm4 movaps %xmm2,%xmm5 shufps $1,%xmm3,%xmm3 shufps $1,%xmm4,%xmm4 shufps $1,%xmm5,%xmm5 addss %xmm3,%xmm0 addss %xmm4,%xmm1 addss %xmm5,%xmm2 ## xmm0-xmm2 has single force in pos0 ## increment i force movss (%rdi,%rcx,4),%xmm3 movss 4(%rdi,%rcx,4),%xmm4 movss 8(%rdi,%rcx,4),%xmm5 subss %xmm0,%xmm3 subss %xmm1,%xmm4 subss %xmm2,%xmm5 movss %xmm3,(%rdi,%rcx,4) movss %xmm4,4(%rdi,%rcx,4) movss %xmm5,8(%rdi,%rcx,4) ## accumulate force in xmm6/xmm7 for fshift movaps %xmm0,%xmm6 movss %xmm2,%xmm7 movlhps %xmm1,%xmm6 shufps $8,%xmm6,%xmm6 ## 00001000 ## accumulate H1i forces in xmm0, xmm1, xmm2 movaps nb311_fixH1(%rsp),%xmm0 movaps nb311_fiyH1(%rsp),%xmm1 movaps nb311_fizH1(%rsp),%xmm2 movhlps %xmm0,%xmm3 movhlps %xmm1,%xmm4 movhlps %xmm2,%xmm5 addps %xmm3,%xmm0 addps %xmm4,%xmm1 addps %xmm5,%xmm2 ## sum is in 1/2 in xmm0-xmm2 movaps %xmm0,%xmm3 movaps %xmm1,%xmm4 movaps %xmm2,%xmm5 shufps $1,%xmm3,%xmm3 shufps $1,%xmm4,%xmm4 shufps $1,%xmm5,%xmm5 addss %xmm3,%xmm0 addss %xmm4,%xmm1 addss %xmm5,%xmm2 ## xmm0-xmm2 has single force in pos0 ## increment i force movss 12(%rdi,%rcx,4),%xmm3 movss 16(%rdi,%rcx,4),%xmm4 movss 20(%rdi,%rcx,4),%xmm5 subss %xmm0,%xmm3 subss %xmm1,%xmm4 subss %xmm2,%xmm5 movss %xmm3,12(%rdi,%rcx,4) movss %xmm4,16(%rdi,%rcx,4) movss %xmm5,20(%rdi,%rcx,4) ## accumulate force in xmm6/xmm7 for fshift addss %xmm2,%xmm7 movlhps %xmm1,%xmm0 shufps $8,%xmm0,%xmm0 ## 00001000 addps %xmm0,%xmm6 ## accumulate H2i forces in xmm0, xmm1, xmm2 movaps nb311_fixH2(%rsp),%xmm0 movaps nb311_fiyH2(%rsp),%xmm1 movaps nb311_fizH2(%rsp),%xmm2 movhlps %xmm0,%xmm3 movhlps %xmm1,%xmm4 movhlps %xmm2,%xmm5 addps %xmm3,%xmm0 addps %xmm4,%xmm1 addps %xmm5,%xmm2 ## sum is in 1/2 in xmm0-xmm2 movaps %xmm0,%xmm3 movaps %xmm1,%xmm4 movaps %xmm2,%xmm5 shufps $1,%xmm3,%xmm3 shufps $1,%xmm4,%xmm4 shufps $1,%xmm5,%xmm5 addss %xmm3,%xmm0 addss %xmm4,%xmm1 addss %xmm5,%xmm2 ## xmm0-xmm2 has single force in pos0 ## increment i force movss 24(%rdi,%rcx,4),%xmm3 movss 28(%rdi,%rcx,4),%xmm4 movss 32(%rdi,%rcx,4),%xmm5 subss %xmm0,%xmm3 subss %xmm1,%xmm4 subss %xmm2,%xmm5 movss %xmm3,24(%rdi,%rcx,4) movss %xmm4,28(%rdi,%rcx,4) movss %xmm5,32(%rdi,%rcx,4) ## accumulate force in xmm6/xmm7 for fshift addss %xmm2,%xmm7 movlhps %xmm1,%xmm0 shufps $8,%xmm0,%xmm0 ## 00001000 addps %xmm0,%xmm6 ## increment fshift force movlps (%rsi,%rdx,4),%xmm3 movss 8(%rsi,%rdx,4),%xmm4 subps %xmm6,%xmm3 subss %xmm7,%xmm4 movlps %xmm3,(%rsi,%rdx,4) movss %xmm4,8(%rsi,%rdx,4) ## get n from stack movl nb311_n(%rsp),%esi ## get group index for i particle movq nb311_gid(%rbp),%rdx ## base of gid[] movl (%rdx,%rsi,4),%edx ## ggid=gid[n] ## accumulate total potential energy and update it movaps nb311_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 nb311_Vc(%rbp),%rax addss (%rax,%rdx,4),%xmm7 ## move back to mem movss %xmm7,(%rax,%rdx,4) ## accumulate total lj energy and update it movaps nb311_Vvdwtot(%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 nb311_Vvdw(%rbp),%rax addss (%rax,%rdx,4),%xmm7 ## move back to mem movss %xmm7,(%rax,%rdx,4) ## finish if last movl nb311_nn1(%rsp),%ecx ## esi already loaded with n incl %esi subl %esi,%ecx jz _nb_kernel311_x86_64_sse.nb311_outerend ## not last, iterate outer loop once more! movl %esi,nb311_n(%rsp) jmp _nb_kernel311_x86_64_sse.nb311_outer_nb_kernel311_x86_64_sse.nb311_outerend: ## check if more outer neighborlists remain movl nb311_nri(%rsp),%ecx ## esi already loaded with n above subl %esi,%ecx jz _nb_kernel311_x86_64_sse.nb311_end ## non-zero, do one more workunit jmp _nb_kernel311_x86_64_sse.nb311_threadloop_nb_kernel311_x86_64_sse.nb311_end: movl nb311_nouter(%rsp),%eax movl nb311_ninner(%rsp),%ebx movq nb311_outeriter(%rbp),%rcx movq nb311_inneriter(%rbp),%rdx movl %eax,(%rcx) movl %ebx,(%rdx) addq $904,%rsp emms pop %r15 pop %r14 pop %r13 pop %r12 pop %rbx pop %rbp ret.globl nb_kernel311nf_x86_64_sse.globl _nb_kernel311nf_x86_64_ssenb_kernel311nf_x86_64_sse: _nb_kernel311nf_x86_64_sse: ## Room for return address and rbp (16 bytes).set nb311nf_fshift, 16.set nb311nf_gid, 24.set nb311nf_pos, 32.set nb311nf_faction, 40.set nb311nf_charge, 48.set nb311nf_p_facel, 56.set nb311nf_argkrf, 64.set nb311nf_argcrf, 72.set nb311nf_Vc, 80.set nb311nf_type, 88.set nb311nf_p_ntype, 96.set nb311nf_vdwparam, 104.set nb311nf_Vvdw, 112.set nb311nf_p_tabscale, 120.set nb311nf_VFtab, 128.set nb311nf_invsqrta, 136.set nb311nf_dvda, 144.set nb311nf_p_gbtabscale, 152.set nb311nf_GBtab, 160.set nb311nf_p_nthreads, 168.set nb311nf_count, 176.set nb311nf_mtx, 184.set nb311nf_outeriter, 192.set nb311nf_inneriter, 200.set nb311nf_work, 208
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?