nb_kernel400_ia32_sse.s
来自「最著名最快的分子模拟软件」· S 代码 · 共 1,703 行 · 第 1/4 页
S
1,703 行
mulss %xmm1,%xmm5 ## xmm5=eps*Fp addss %xmm4,%xmm5 ## xmm5=VV mulss %xmm3,%xmm5 ## vcoul=qq*VV mulss %xmm7,%xmm3 ## fijC=FF*qq ## at this point mm5 contains vcoul and mm3 fijC movd %mm0,%ebx movl nb400_dvda(%ebp),%esi ## Calculate dVda xorps %xmm7,%xmm7 mulss nb400_gbscale(%esp),%xmm3 movaps %xmm3,%xmm6 mulss nb400_r(%esp),%xmm6 addss %xmm5,%xmm6 addss nb400_vctot(%esp),%xmm5 movss %xmm5,nb400_vctot(%esp) ## xmm6=(vcoul+fijC*r) subps %xmm6,%xmm7 movaps %xmm7,%xmm6 ## update dvdasum addps nb400_dvdasum(%esp),%xmm7 movaps %xmm7,nb400_dvdasum(%esp) ## update j atoms dvdaj addss (%esi,%ebx,4),%xmm6 movss %xmm6,(%esi,%ebx,4) xorps %xmm4,%xmm4 mulss %xmm0,%xmm3 subss %xmm3,%xmm4 movl nb400_faction(%ebp),%edi movss nb400_dx(%esp),%xmm0 movss nb400_dy(%esp),%xmm1 movss nb400_dz(%esp),%xmm2 mulss %xmm4,%xmm0 mulss %xmm4,%xmm1 mulss %xmm4,%xmm2 ## xmm0-xmm2 contains tx-tz (partial force) ## now update f_i movss nb400_fix(%esp),%xmm3 movss nb400_fiy(%esp),%xmm4 movss nb400_fiz(%esp),%xmm5 addss %xmm0,%xmm3 addss %xmm1,%xmm4 addss %xmm2,%xmm5 movss %xmm3,nb400_fix(%esp) movss %xmm4,nb400_fiy(%esp) movss %xmm5,nb400_fiz(%esp) ## update fj movss (%edi,%eax,4),%xmm3 movss 4(%edi,%eax,4),%xmm4 movss 8(%edi,%eax,4),%xmm5 subss %xmm0,%xmm3 subss %xmm1,%xmm4 subss %xmm2,%xmm5 movss %xmm3,(%edi,%eax,4) movss %xmm4,4(%edi,%eax,4) movss %xmm5,8(%edi,%eax,4)_nb_kernel400_ia32_sse.nb400_updateouterdata: movl nb400_ii3(%esp),%ecx movl nb400_faction(%ebp),%edi movl nb400_fshift(%ebp),%esi movl nb400_is3(%esp),%edx ## accumulate i forces in xmm0, xmm1, xmm2 movaps nb400_fix(%esp),%xmm0 movaps nb400_fiy(%esp),%xmm1 movaps nb400_fiz(%esp),%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 (%edi,%ecx,4),%xmm3 movss 4(%edi,%ecx,4),%xmm4 movss 8(%edi,%ecx,4),%xmm5 addss %xmm0,%xmm3 addss %xmm1,%xmm4 addss %xmm2,%xmm5 movss %xmm3,(%edi,%ecx,4) movss %xmm4,4(%edi,%ecx,4) movss %xmm5,8(%edi,%ecx,4) ## increment fshift force movss (%esi,%edx,4),%xmm3 movss 4(%esi,%edx,4),%xmm4 movss 8(%esi,%edx,4),%xmm5 addss %xmm0,%xmm3 addss %xmm1,%xmm4 addss %xmm2,%xmm5 movss %xmm3,(%esi,%edx,4) movss %xmm4,4(%esi,%edx,4) movss %xmm5,8(%esi,%edx,4) ## get n from stack movl nb400_n(%esp),%esi ## get group index for i particle movl nb400_gid(%ebp),%edx ## base of gid[] movl (%edx,%esi,4),%edx ## ggid=gid[n] ## accumulate total potential energy and update it movaps nb400_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 nb400_Vc(%ebp),%eax addss (%eax,%edx,4),%xmm7 ## move back to mem movss %xmm7,(%eax,%edx,4) ## accumulate dVda and update it movaps nb400_dvdasum(%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 movl nb400_ii(%esp),%edx movl nb400_dvda(%ebp),%eax addss (%eax,%edx,4),%xmm7 movss %xmm7,(%eax,%edx,4) ## finish if last movl nb400_nn1(%esp),%ecx ## esi already loaded with n incl %esi subl %esi,%ecx jz _nb_kernel400_ia32_sse.nb400_outerend ## not last, iterate outer loop once more! movl %esi,nb400_n(%esp) jmp _nb_kernel400_ia32_sse.nb400_outer_nb_kernel400_ia32_sse.nb400_outerend: ## check if more outer neighborlists remain movl nb400_nri(%esp),%ecx ## esi already loaded with n above subl %esi,%ecx jz _nb_kernel400_ia32_sse.nb400_end ## non-zero, do one more workunit jmp _nb_kernel400_ia32_sse.nb400_threadloop_nb_kernel400_ia32_sse.nb400_end: emms movl nb400_nouter(%esp),%eax movl nb400_ninner(%esp),%ebx movl nb400_outeriter(%ebp),%ecx movl nb400_inneriter(%ebp),%edx movl %eax,(%ecx) movl %ebx,(%edx) movl nb400_salign(%esp),%eax addl %eax,%esp addl $400,%esp popl %edi popl %esi popl %edx popl %ecx popl %ebx popl %eax leave ret.globl nb_kernel400nf_ia32_sse.globl _nb_kernel400nf_ia32_ssenb_kernel400nf_ia32_sse: _nb_kernel400nf_ia32_sse: .set nb400nf_p_nri, 8.set nb400nf_iinr, 12.set nb400nf_jindex, 16.set nb400nf_jjnr, 20.set nb400nf_shift, 24.set nb400nf_shiftvec, 28.set nb400nf_fshift, 32.set nb400nf_gid, 36.set nb400nf_pos, 40.set nb400nf_faction, 44.set nb400nf_charge, 48.set nb400nf_p_facel, 52.set nb400nf_argkrf, 56.set nb400nf_argcrf, 60.set nb400nf_Vc, 64.set nb400nf_type, 68.set nb400nf_p_ntype, 72.set nb400nf_vdwparam, 76.set nb400nf_Vvdw, 80.set nb400nf_p_tabscale, 84.set nb400nf_VFtab, 88.set nb400nf_invsqrta, 92.set nb400nf_dvda, 96.set nb400nf_p_gbtabscale, 100.set nb400nf_GBtab, 104.set nb400nf_p_nthreads, 108.set nb400nf_count, 112.set nb400nf_mtx, 116.set nb400nf_outeriter, 120.set nb400nf_inneriter, 124.set nb400nf_work, 128 ## stack offsets for local variables ## bottom of stack is cache-aligned for sse use .set nb400nf_ix, 0.set nb400nf_iy, 16.set nb400nf_iz, 32.set nb400nf_iq, 48.set nb400nf_gbtsc, 64.set nb400nf_qq, 80.set nb400nf_vctot, 96.set nb400nf_half, 112.set nb400nf_three, 128.set nb400nf_isai, 144.set nb400nf_isaprod, 160.set nb400nf_gbscale, 176.set nb400nf_is3, 192.set nb400nf_ii3, 196.set nb400nf_innerjjnr, 200.set nb400nf_innerk, 204.set nb400nf_n, 208.set nb400nf_nn1, 212.set nb400nf_nri, 216.set nb400nf_facel, 220.set nb400nf_nouter, 224.set nb400nf_ninner, 228.set nb400nf_salign, 232 pushl %ebp movl %esp,%ebp pushl %eax pushl %ebx pushl %ecx pushl %edx pushl %esi pushl %edi subl $236,%esp ## local stack space movl %esp,%eax andl $0xf,%eax subl %eax,%esp movl %eax,nb400nf_salign(%esp) emms ## Move args passed by reference to stack movl nb400nf_p_nri(%ebp),%ecx movl nb400nf_p_facel(%ebp),%esi movl (%ecx),%ecx movl (%esi),%esi movl %ecx,nb400nf_nri(%esp) movl %esi,nb400nf_facel(%esp) ## zero iteration counters movl $0,%eax movl %eax,nb400nf_nouter(%esp) movl %eax,nb400nf_ninner(%esp) movl nb400nf_p_gbtabscale(%ebp),%eax movss (%eax),%xmm3 shufps $0,%xmm3,%xmm3 movaps %xmm3,nb400nf_gbtsc(%esp) ## create constant floating-point factors on stack movl $0x3f000000,%eax ## constant 0.5 in IEEE (hex) movl %eax,nb400nf_half(%esp) movss nb400nf_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,nb400nf_half(%esp) movaps %xmm3,nb400nf_three(%esp)_nb_kernel400nf_ia32_sse.nb400nf_threadloop: movl nb400nf_count(%ebp),%esi ## pointer to sync counter movl (%esi),%eax_nb_kernel400nf_ia32_sse.nb400nf_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_kernel400nf_ia32_sse.nb400nf_spinlock ## if(nn1>nri) nn1=nri movl nb400nf_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,nb400nf_n(%esp) movl %ebx,nb400nf_nn1(%esp) subl %eax,%ebx ## calc number of outer lists movl %eax,%esi ## copy n to esi jg _nb_kernel400nf_ia32_sse.nb400nf_outerstart jmp _nb_kernel400nf_ia32_sse.nb400nf_end_nb_kernel400nf_ia32_sse.nb400nf_outerstart: ## ebx contains number of outer iterations addl nb400nf_nouter(%esp),%ebx movl %ebx,nb400nf_nouter(%esp)_nb_kernel400nf_ia32_sse.nb400nf_outer: movl nb400nf_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,nb400nf_is3(%esp) ## store is3 movl nb400nf_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 nb400nf_iinr(%ebp),%ecx ## ecx = pointer into iinr[] movl (%ecx,%esi,4),%ebx ## ebx =ii movl nb400nf_charge(%ebp),%edx movss (%edx,%ebx,4),%xmm3 mulss nb400nf_facel(%esp),%xmm3 shufps $0,%xmm3,%xmm3 movl nb400nf_invsqrta(%ebp),%edx ## load invsqrta[ii] movss (%edx,%ebx,4),%xmm4 shufps $0,%xmm4,%xmm4 leal (%ebx,%ebx,2),%ebx ## ebx = 3*ii=ii3 movl nb400nf_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,nb400nf_iq(%esp) movaps %xmm4,nb400nf_isai(%esp) shufps $0,%xmm0,%xmm0 shufps $0,%xmm1,%xmm1 shufps $0,%xmm2,%xmm2 movaps %xmm0,nb400nf_ix(%esp) movaps %xmm1,nb400nf_iy(%esp) movaps %xmm2,nb400nf_iz(%esp) movl %ebx,nb400nf_ii3(%esp) ## clear vctot xorps %xmm4,%xmm4 movaps %xmm4,nb400nf_vctot(%esp) movl nb400nf_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 nb400nf_pos(%ebp),%esi movl nb400nf_faction(%ebp),%edi movl nb400nf_jjnr(%ebp),%eax shll $2,%ecx addl %ecx,%eax movl %eax,nb400nf_innerjjnr(%esp) ## pointer to jjnr[nj0] movl %edx,%ecx subl $4,%edx addl nb400nf_ninner(%esp),%ecx movl %ecx,nb400nf_ninner(%esp) addl $0,%edx movl %edx,nb400nf_innerk(%esp) ## number of innerloop atoms jge _nb_kernel400nf_ia32_sse.nb400nf_unroll_loop jmp _nb_kernel400nf_ia32_sse.nb400nf_finish_inner_nb_kernel400nf_ia32_sse.nb400nf_unroll_loop: ## quad-unroll innerloop here movl nb400nf_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,nb400nf_innerjjnr(%esp) ## advance pointer (unrolled 4) ## load isa2 movl nb400nf_invsqrta(%ebp),%esi movss (%esi,%eax,4),%xmm3 movss (%esi,%ecx,4),%xmm4 movss (%esi,%ebx,4),%xmm6 movss (%esi,%edx,4),%xmm7 movaps nb400nf_isai(%esp),%xmm2 shufps $0,%xmm6,%xmm3 shufps $0,%xmm7,%xmm4 shufps $136,%xmm4,%xmm3 ## constant 10001000 ;# all charges in xmm3 mulps %xmm3,%xmm2 movaps %xmm2,nb400nf_isaprod(%esp) movaps %xmm2,%xmm1
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?