nb_kernel400_x86_64_sse.s
来自「最著名最快的分子模拟软件」· S 代码 · 共 1,640 行 · 第 1/4 页
S
1,640 行
addss %xmm5,%xmm6 ## increment vctot (sum in xmm12) addss %xmm5,%xmm12 ## xmm6=(vcoul+fijC*r) subss %xmm6,%xmm7 movaps %xmm7,%xmm6 ## update dvdasum addss nb400_dvdasum(%rsp),%xmm7 movss %xmm7,nb400_dvdasum(%rsp) ## update j atoms dvdaj addss (%rsi,%rax,4),%xmm6 movss %xmm6,(%rsi,%rax,4) xorps %xmm4,%xmm4 mulss %xmm0,%xmm3 subss %xmm3,%xmm4 mulss %xmm4,%xmm9 mulss %xmm4,%xmm10 mulss %xmm4,%xmm11 ## accumulate i forces addss %xmm9,%xmm13 addss %xmm10,%xmm14 addss %xmm11,%xmm15 movq nb400_faction(%rbp),%rsi ## add to j forces addss (%rsi,%r8,4),%xmm9 addss 4(%rsi,%r8,4),%xmm10 addss 8(%rsi,%r8,4),%xmm11 movss %xmm9,(%rsi,%r8,4) movss %xmm10,4(%rsi,%r8,4) movss %xmm11,8(%rsi,%r8,4)_nb_kernel400_x86_64_sse.nb400_updateouterdata: movl nb400_ii3(%rsp),%ecx movq nb400_faction(%rbp),%rdi movq nb400_fshift(%rbp),%rsi movl nb400_is3(%rsp),%edx ## accumulate i forces in xmm13, xmm14, xmm15 movhlps %xmm13,%xmm0 movhlps %xmm14,%xmm1 movhlps %xmm15,%xmm2 addps %xmm13,%xmm0 addps %xmm14,%xmm1 addps %xmm15,%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) ## increment fshift force movss (%rsi,%rdx,4),%xmm3 movss 4(%rsi,%rdx,4),%xmm4 movss 8(%rsi,%rdx,4),%xmm5 subss %xmm0,%xmm3 subss %xmm1,%xmm4 subss %xmm2,%xmm5 movss %xmm3,(%rsi,%rdx,4) movss %xmm4,4(%rsi,%rdx,4) movss %xmm5,8(%rsi,%rdx,4) ## get n from stack movl nb400_n(%rsp),%esi ## get group index for i particle movq nb400_gid(%rbp),%rdx ## base of gid[] movl (%rdx,%rsi,4),%edx ## ggid=gid[n] ## accumulate total potential energy and update it ## accumulate movhlps %xmm12,%xmm6 addps %xmm6,%xmm12 ## pos 0-1 in xmm12 have the sum now movaps %xmm12,%xmm6 shufps $1,%xmm6,%xmm6 addss %xmm6,%xmm12 ## add earlier value from mem movq nb400_Vc(%rbp),%rax addss (%rax,%rdx,4),%xmm12 ## move back to mem movss %xmm12,(%rax,%rdx,4) ## accumulate dVda and update it movaps nb400_dvdasum(%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 movl nb400_ii(%rsp),%edx movq nb400_dvda(%rbp),%rax addss (%rax,%rdx,4),%xmm7 movss %xmm7,(%rax,%rdx,4) ## finish if last movl nb400_nn1(%rsp),%ecx ## esi already loaded with n incl %esi subl %esi,%ecx jz _nb_kernel400_x86_64_sse.nb400_outerend ## not last, iterate outer loop once more! movl %esi,nb400_n(%rsp) jmp _nb_kernel400_x86_64_sse.nb400_outer_nb_kernel400_x86_64_sse.nb400_outerend: ## check if more outer neighborlists remain movl nb400_nri(%rsp),%ecx ## esi already loaded with n above subl %esi,%ecx jz _nb_kernel400_x86_64_sse.nb400_end ## non-zero, do one more workunit jmp _nb_kernel400_x86_64_sse.nb400_threadloop_nb_kernel400_x86_64_sse.nb400_end: movl nb400_nouter(%rsp),%eax movl nb400_ninner(%rsp),%ebx movq nb400_outeriter(%rbp),%rcx movq nb400_inneriter(%rbp),%rdx movl %eax,(%rcx) movl %ebx,(%rdx) addq $456,%rsp emms pop %r15 pop %r14 pop %r13 pop %r12 pop %rbx pop %rbp ret.globl nb_kernel400nf_x86_64_sse.globl _nb_kernel400nf_x86_64_ssenb_kernel400nf_x86_64_sse: _nb_kernel400nf_x86_64_sse: .set nb400nf_fshift, 16.set nb400nf_gid, 24.set nb400nf_pos, 32.set nb400nf_faction, 40.set nb400nf_charge, 48.set nb400nf_p_facel, 56.set nb400nf_argkrf, 64.set nb400nf_argcrf, 72.set nb400nf_Vc, 80.set nb400nf_type, 88.set nb400nf_p_ntype, 96.set nb400nf_vdwparam, 104.set nb400nf_Vvdw, 112.set nb400nf_p_tabscale, 120.set nb400nf_VFtab, 128.set nb400nf_invsqrta, 136.set nb400nf_dvda, 144.set nb400nf_p_gbtabscale, 152.set nb400nf_GBtab, 160.set nb400nf_p_nthreads, 168.set nb400nf_count, 176.set nb400nf_mtx, 184.set nb400nf_outeriter, 192.set nb400nf_inneriter, 200.set nb400nf_work, 208 ## 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_nri, 192.set nb400nf_iinr, 200.set nb400nf_jindex, 208.set nb400nf_jjnr, 216.set nb400nf_shift, 224.set nb400nf_shiftvec, 232.set nb400nf_facel, 240.set nb400nf_innerjjnr, 248.set nb400nf_is3, 256.set nb400nf_ii3, 260.set nb400nf_innerk, 264.set nb400nf_n, 268.set nb400nf_nn1, 272.set nb400nf_nouter, 276.set nb400nf_ninner, 280 push %rbp movq %rsp,%rbp push %rbx emms push %r12 push %r13 push %r14 push %r15 subq $296,%rsp ## local variable stack space (n*16+8) ## zero 32-bit iteration counters movl $0,%eax movl %eax,nb400nf_nouter(%rsp) movl %eax,nb400nf_ninner(%rsp) movl (%rdi),%edi movl %edi,nb400nf_nri(%rsp) movq %rsi,nb400nf_iinr(%rsp) movq %rdx,nb400nf_jindex(%rsp) movq %rcx,nb400nf_jjnr(%rsp) movq %r8,nb400nf_shift(%rsp) movq %r9,nb400nf_shiftvec(%rsp) movq nb400nf_p_facel(%rbp),%rsi movss (%rsi),%xmm0 movss %xmm0,nb400nf_facel(%rsp) movq nb400nf_p_gbtabscale(%rbp),%rbx movss (%rbx),%xmm4 shufps $0,%xmm4,%xmm4 movaps %xmm4,nb400nf_gbtsc(%rsp) ## create constant floating-point factors on stack movl $0x3f000000,%eax ## half in IEEE (hex) movl %eax,nb400nf_half(%rsp) movss nb400nf_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,nb400nf_half(%rsp) movaps %xmm3,nb400nf_three(%rsp)_nb_kernel400nf_x86_64_sse.nb400nf_threadloop: movq nb400nf_count(%rbp),%rsi ## pointer to sync counter movl (%rsi),%eax_nb_kernel400nf_x86_64_sse.nb400nf_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_kernel400nf_x86_64_sse.nb400nf_spinlock ## if(nn1>nri) nn1=nri movl nb400nf_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,nb400nf_n(%rsp) movl %ebx,nb400nf_nn1(%rsp) subl %eax,%ebx ## calc number of outer lists movl %eax,%esi ## copy n to esi jg _nb_kernel400nf_x86_64_sse.nb400nf_outerstart jmp _nb_kernel400nf_x86_64_sse.nb400nf_end_nb_kernel400nf_x86_64_sse.nb400nf_outerstart: ## ebx contains number of outer iterations addl nb400nf_nouter(%rsp),%ebx movl %ebx,nb400nf_nouter(%rsp)_nb_kernel400nf_x86_64_sse.nb400nf_outer: movq nb400nf_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,nb400nf_is3(%rsp) ## store is3 movq nb400nf_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 nb400nf_iinr(%rsp),%rcx ## rcx = pointer into iinr[] movl (%rcx,%rsi,4),%ebx ## ebx =ii movq nb400nf_charge(%rbp),%rdx movss (%rdx,%rbx,4),%xmm3 mulss nb400nf_facel(%rsp),%xmm3 shufps $0,%xmm3,%xmm3 movq nb400nf_invsqrta(%rbp),%rdx ## load invsqrta[ii] movss (%rdx,%rbx,4),%xmm4 shufps $0,%xmm4,%xmm4 lea (%rbx,%rbx,2),%rbx ## rbx = 3*ii=ii3 movq nb400nf_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,nb400nf_iq(%rsp) movaps %xmm4,nb400nf_isai(%rsp) shufps $0,%xmm0,%xmm0 shufps $0,%xmm1,%xmm1 shufps $0,%xmm2,%xmm2 movaps %xmm0,nb400nf_ix(%rsp) movaps %xmm1,nb400nf_iy(%rsp) movaps %xmm2,nb400nf_iz(%rsp) movl %ebx,nb400nf_ii3(%rsp) ## clear vctot xorps %xmm4,%xmm4 movaps %xmm4,nb400nf_vctot(%rsp) movq nb400nf_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 nb400nf_pos(%rbp),%rsi movq nb400nf_faction(%rbp),%rdi movq nb400nf_jjnr(%rsp),%rax shll $2,%ecx addq %rcx,%rax movq %rax,nb400nf_innerjjnr(%rsp) ## pointer to jjnr[nj0] movl %edx,%ecx subl $4,%edx addl nb400nf_ninner(%rsp),%ecx movl %ecx,nb400nf_ninner(%rsp) addl $0,%edx movl %edx,nb400nf_innerk(%rsp) ## number of innerloop atoms jge _nb_kernel400nf_x86_64_sse.nb400nf_unroll_loop jmp _nb_kernel400nf_x86_64_sse.nb400nf_finish_inner_nb_kernel400nf_x86_64_sse.nb400nf_unroll_loop: ## quad-unroll innerloop here movq nb400nf_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,nb400nf_innerjjnr(%rsp) ## advance pointer (unrolled 4) ## load isa2 movq nb400nf_invsqrta(%rbp),%rsi movss (%rsi,%rax,4),%xmm3 movss (%rsi,%rcx,4),%xmm4 movss (%rsi,%rbx,4),%xmm6 movss (%rsi,%rdx,4),%xmm7 movaps nb400nf_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,nb400nf_isaprod(%rsp) movaps %xmm2,%xmm1 mulps nb400nf_gbtsc(%rsp),%xmm1 movaps %xmm1,nb400nf_gbscale(%rsp) movq nb400nf_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 nb400nf_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,nb400nf_qq(%rsp)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?