nb_kernel430_x86_64_sse.s
来自「最著名最快的分子模拟软件」· S 代码 · 共 2,168 行 · 第 1/5 页
S
2,168 行
movl %esi,nb430_n(%rsp) jmp _nb_kernel430_x86_64_sse.nb430_outer_nb_kernel430_x86_64_sse.nb430_outerend: ## check if more outer neighborlists remain movl nb430_nri(%rsp),%ecx ## esi already loaded with n above subl %esi,%ecx jz _nb_kernel430_x86_64_sse.nb430_end ## non-zero, do one more workunit jmp _nb_kernel430_x86_64_sse.nb430_threadloop_nb_kernel430_x86_64_sse.nb430_end: movl nb430_nouter(%rsp),%eax movl nb430_ninner(%rsp),%ebx movq nb430_outeriter(%rbp),%rcx movq nb430_inneriter(%rbp),%rdx movl %eax,(%rcx) movl %ebx,(%rdx) addq $552,%rsp emms pop %r15 pop %r14 pop %r13 pop %r12 pop %rbx pop %rbp ret.globl nb_kernel430nf_x86_64_sse.globl _nb_kernel430nf_x86_64_ssenb_kernel430nf_x86_64_sse: _nb_kernel430nf_x86_64_sse: ## Room for return address and rbp (16 bytes).set nb430nf_fshift, 16.set nb430nf_gid, 24.set nb430nf_pos, 32.set nb430nf_faction, 40.set nb430nf_charge, 48.set nb430nf_p_facel, 56.set nb430nf_argkrf, 64.set nb430nf_argcrf, 72.set nb430nf_Vc, 80.set nb430nf_type, 88.set nb430nf_p_ntype, 96.set nb430nf_vdwparam, 104.set nb430nf_Vvdw, 112.set nb430nf_p_tabscale, 120.set nb430nf_VFtab, 128.set nb430nf_invsqrta, 136.set nb430nf_dvda, 144.set nb430nf_p_gbtabscale, 152.set nb430nf_GBtab, 160.set nb430nf_p_nthreads, 168.set nb430nf_count, 176.set nb430nf_mtx, 184.set nb430nf_outeriter, 192.set nb430nf_inneriter, 200.set nb430nf_work, 208 ## stack offsets for local variables ## bottom of stack is cache-aligned for sse use .set nb430nf_ix, 0.set nb430nf_iy, 16.set nb430nf_iz, 32.set nb430nf_iq, 48.set nb430nf_gbtsc, 64.set nb430nf_tsc, 80.set nb430nf_qq, 96.set nb430nf_c6, 112.set nb430nf_c12, 128.set nb430nf_vctot, 144.set nb430nf_Vvdwtot, 160.set nb430nf_half, 176.set nb430nf_three, 192.set nb430nf_isai, 208.set nb430nf_isaprod, 224.set nb430nf_gbscale, 240.set nb430nf_r, 256.set nb430nf_nri, 272.set nb430nf_iinr, 280.set nb430nf_jindex, 288.set nb430nf_jjnr, 296.set nb430nf_shift, 304.set nb430nf_shiftvec, 312.set nb430nf_facel, 320.set nb430nf_innerjjnr, 328.set nb430nf_is3, 336.set nb430nf_ii3, 340.set nb430nf_ntia, 344.set nb430nf_innerk, 348.set nb430nf_n, 352.set nb430nf_nn1, 356.set nb430nf_ntype, 360.set nb430nf_nouter, 364.set nb430nf_ninner, 368 push %rbp movq %rsp,%rbp push %rbx emms push %r12 push %r13 push %r14 push %r15 subq $392,%rsp ## local variable stack space (n*16+8) ## zero 32-bit iteration counters movl $0,%eax movl %eax,nb430nf_nouter(%rsp) movl %eax,nb430nf_ninner(%rsp) movl (%rdi),%edi movl %edi,nb430nf_nri(%rsp) movq %rsi,nb430nf_iinr(%rsp) movq %rdx,nb430nf_jindex(%rsp) movq %rcx,nb430nf_jjnr(%rsp) movq %r8,nb430nf_shift(%rsp) movq %r9,nb430nf_shiftvec(%rsp) movq nb430nf_p_ntype(%rbp),%rdi movl (%rdi),%edi movl %edi,nb430nf_ntype(%rsp) movq nb430nf_p_facel(%rbp),%rsi movss (%rsi),%xmm0 movss %xmm0,nb430nf_facel(%rsp) movq nb430nf_p_tabscale(%rbp),%rax movss (%rax),%xmm3 shufps $0,%xmm3,%xmm3 movaps %xmm3,nb430nf_tsc(%rsp) movq nb430nf_p_gbtabscale(%rbp),%rbx movss (%rbx),%xmm4 shufps $0,%xmm4,%xmm4 movaps %xmm4,nb430nf_gbtsc(%rsp) ## create constant floating-point factors on stack movl $0x3f000000,%eax ## half in IEEE (hex) movl %eax,nb430nf_half(%rsp) movss nb430nf_half(%rsp),%xmm1 shufps $0,%xmm1,%xmm1 ## splat to all elements movaps %xmm1,%xmm2 addps %xmm2,%xmm2 ## one movaps %xmm2,%xmm3 addps %xmm2,%xmm2 ## two addps %xmm2,%xmm3 ## three movaps %xmm1,nb430nf_half(%rsp) movaps %xmm3,nb430nf_three(%rsp)_nb_kernel430nf_x86_64_sse.nb430nf_threadloop: movq nb430nf_count(%rbp),%rsi ## pointer to sync counter movl (%rsi),%eax_nb_kernel430nf_x86_64_sse.nb430nf_spinlock: movl %eax,%ebx ## ebx=*count=nn0 addl $1,%ebx ## ebx=nn1=nn0+10 lock cmpxchgl %ebx,(%rsi) ## write nn1 to *counter, ## if it hasnt changed. ## or reread *counter to eax. pause ## -> better p4 performance jnz _nb_kernel430nf_x86_64_sse.nb430nf_spinlock ## if(nn1>nri) nn1=nri movl nb430nf_nri(%rsp),%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,nb430nf_n(%rsp) movl %ebx,nb430nf_nn1(%rsp) subl %eax,%ebx ## calc number of outer lists movl %eax,%esi ## copy n to esi jg _nb_kernel430nf_x86_64_sse.nb430nf_outerstart jmp _nb_kernel430nf_x86_64_sse.nb430nf_end_nb_kernel430nf_x86_64_sse.nb430nf_outerstart: ## ebx contains number of outer iterations addl nb430nf_nouter(%rsp),%ebx movl %ebx,nb430nf_nouter(%rsp)_nb_kernel430nf_x86_64_sse.nb430nf_outer: movq nb430nf_shift(%rsp),%rax ## rax = pointer into shift[] movl (%rax,%rsi,4),%ebx ## ebx=shift[n] lea (%rbx,%rbx,2),%rbx ## rbx=3*is movl %ebx,nb430nf_is3(%rsp) ## store is3 movq nb430nf_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 nb430nf_iinr(%rsp),%rcx ## rcx = pointer into iinr[] movl (%rcx,%rsi,4),%ebx ## ebx =ii movq nb430nf_charge(%rbp),%rdx movss (%rdx,%rbx,4),%xmm3 mulss nb430nf_facel(%rsp),%xmm3 shufps $0,%xmm3,%xmm3 movq nb430nf_invsqrta(%rbp),%rdx ## load invsqrta[ii] movss (%rdx,%rbx,4),%xmm4 shufps $0,%xmm4,%xmm4 movq nb430nf_type(%rbp),%rdx movl (%rdx,%rbx,4),%edx imull nb430nf_ntype(%rsp),%edx shll %edx movl %edx,nb430nf_ntia(%rsp) lea (%rbx,%rbx,2),%rbx ## rbx = 3*ii=ii3 movq nb430nf_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,nb430nf_iq(%rsp) movaps %xmm4,nb430nf_isai(%rsp) shufps $0,%xmm0,%xmm0 shufps $0,%xmm1,%xmm1 shufps $0,%xmm2,%xmm2 movaps %xmm0,nb430nf_ix(%rsp) movaps %xmm1,nb430nf_iy(%rsp) movaps %xmm2,nb430nf_iz(%rsp) movl %ebx,nb430nf_ii3(%rsp) ## clear vctot xorps %xmm4,%xmm4 movaps %xmm4,nb430nf_vctot(%rsp) movaps %xmm4,nb430nf_Vvdwtot(%rsp) movq nb430nf_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 nb430nf_pos(%rbp),%rsi movq nb430nf_faction(%rbp),%rdi movq nb430nf_jjnr(%rsp),%rax shll $2,%ecx addq %rcx,%rax movq %rax,nb430nf_innerjjnr(%rsp) ## pointer to jjnr[nj0] movl %edx,%ecx subl $4,%edx addl nb430nf_ninner(%rsp),%ecx movl %ecx,nb430nf_ninner(%rsp) addl $0,%edx movl %edx,nb430nf_innerk(%rsp) ## number of innerloop atoms jge _nb_kernel430nf_x86_64_sse.nb430nf_unroll_loop jmp _nb_kernel430nf_x86_64_sse.nb430nf_finish_inner_nb_kernel430nf_x86_64_sse.nb430nf_unroll_loop: ## quad-unroll innerloop here movq nb430nf_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,nb430nf_innerjjnr(%rsp) ## advance pointer (unrolled 4) ## load isa2 movq nb430nf_invsqrta(%rbp),%rsi movss (%rsi,%rax,4),%xmm3 movss (%rsi,%rcx,4),%xmm4 movss (%rsi,%rbx,4),%xmm6 movss (%rsi,%rdx,4),%xmm7 movaps nb430nf_isai(%rsp),%xmm2 shufps $0,%xmm6,%xmm3 shufps $0,%xmm7,%xmm4 shufps $136,%xmm4,%xmm3 ## 10001000 ;# all charges in xmm3 mulps %xmm3,%xmm2 movaps %xmm2,nb430nf_isaprod(%rsp) movaps %xmm2,%xmm1 mulps nb430nf_gbtsc(%rsp),%xmm1 movaps %xmm1,nb430nf_gbscale(%rsp) movq nb430nf_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 mulps nb430nf_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,nb430nf_qq(%rsp) movd %eax,%mm0 ## use mmx registers as temp storage movd %ebx,%mm1 movd %ecx,%mm2 movd %edx,%mm3 movq nb430nf_type(%rbp),%rsi movl (%rsi,%rax,4),%eax movl (%rsi,%rbx,4),%ebx movl (%rsi,%rcx,4),%ecx movl (%rsi,%rdx,4),%edx movq nb430nf_vdwparam(%rbp),%rsi shll %eax shll %ebx shll %ecx shll %edx movl nb430nf_ntia(%rsp),%edi addl %edi,%eax addl %edi,%ebx addl %edi,%ecx addl %edi,%edx movlps (%rsi,%rax,4),%xmm6 movlps (%rsi,%rcx,4),%xmm7 movhps (%rsi,%rbx,4),%xmm6 movhps (%rsi,%rdx,4),%xmm7 movaps %xmm6,%xmm4 shufps $136,%xmm7,%xmm4 ## 10001000 shufps $221,%xmm7,%xmm6 ## 11011101 movd %mm0,%eax movd %mm1,%ebx movd %mm2,%ecx movd %mm3,%edx movaps %xmm4,nb430nf_c6(%rsp) movaps %xmm6,nb430nf_c12(%rsp) movq nb430nf_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 nb430nf_ix(%rsp),%xmm4 movaps nb430nf_iy(%rsp),%xmm5 movaps nb430nf_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 nb430nf_three(%rsp),%xmm1 mulps %xmm4,%xmm5 ## rsq*lu*lu movaps nb430nf_half(%rsp),%xmm0 subps %xmm5,%xmm1 ## 30-rsq*lu*lu mulps %xmm2,%xmm1 mulps %xmm1,%xmm0 ## xmm0=rinv mulps %xmm0,%xmm4 ## xmm4=r movaps %xmm4,nb430nf_r(%rsp) mulps nb430nf_gbscale(%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 nb430nf_GBtab(%rbp),%rsi movd %mm6,%eax psrlq $32,%mm6 movd %mm7,%ecx psrlq $32,%mm7 movd %mm6,%ebx movd %mm7,%edx ## load coulomb table
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?