nb_kernel114_x86_64_sse.s
来自「最著名最快的分子模拟软件」· S 代码 · 共 2,123 行 · 第 1/5 页
S
2,123 行
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 nb114_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 nb114_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 nb114_Vvdw(%rbp),%rax addss (%rax,%rdx,4),%xmm7 ## move back to mem movss %xmm7,(%rax,%rdx,4) ## finish if last movl nb114_nn1(%rsp),%ecx ## esi already loaded with n incl %esi subl %esi,%ecx jz _nb_kernel114_x86_64_sse.nb114_outerend ## not last, iterate outer loop once more! movl %esi,nb114_n(%rsp) jmp _nb_kernel114_x86_64_sse.nb114_outer_nb_kernel114_x86_64_sse.nb114_outerend: ## check if more outer neighborlists remain movl nb114_nri(%rsp),%ecx ## esi already loaded with n above subl %esi,%ecx jz _nb_kernel114_x86_64_sse.nb114_end ## non-zero, do one more workunit jmp _nb_kernel114_x86_64_sse.nb114_threadloop_nb_kernel114_x86_64_sse.nb114_end: emms movl nb114_nouter(%rsp),%eax movl nb114_ninner(%rsp),%ebx movq nb114_outeriter(%rbp),%rcx movq nb114_inneriter(%rbp),%rdx movl %eax,(%rcx) movl %ebx,(%rdx) addq $1880,%rsp pop %r15 pop %r14 pop %r13 pop %r12 pop %rbx pop %rbp ret.globl nb_kernel114nf_x86_64_sse.globl _nb_kernel114nf_x86_64_ssenb_kernel114nf_x86_64_sse: _nb_kernel114nf_x86_64_sse: ## Room for return address and rbp (16 bytes).set nb114nf_fshift, 16.set nb114nf_gid, 24.set nb114nf_pos, 32.set nb114nf_faction, 40.set nb114nf_charge, 48.set nb114nf_p_facel, 56.set nb114nf_argkrf, 64.set nb114nf_argcrf, 72.set nb114nf_Vc, 80.set nb114nf_type, 88.set nb114nf_p_ntype, 96.set nb114nf_vdwparam, 104.set nb114nf_Vvdw, 112.set nb114nf_p_tabscale, 120.set nb114nf_VFtab, 128.set nb114nf_invsqrta, 136.set nb114nf_dvda, 144.set nb114nf_p_gbtabscale, 152.set nb114nf_GBtab, 160.set nb114nf_p_nthreads, 168.set nb114nf_count, 176.set nb114nf_mtx, 184.set nb114nf_outeriter, 192.set nb114nf_inneriter, 200.set nb114nf_work, 208 ## stack offsets for local variables ## bottom of stack is cache-aligned for sse use .set nb114nf_ixO, 0.set nb114nf_iyO, 16.set nb114nf_izO, 32.set nb114nf_ixH1, 48.set nb114nf_iyH1, 64.set nb114nf_izH1, 80.set nb114nf_ixH2, 96.set nb114nf_iyH2, 112.set nb114nf_izH2, 128.set nb114nf_ixM, 144.set nb114nf_iyM, 160.set nb114nf_izM, 176.set nb114nf_jxO, 192.set nb114nf_jyO, 208.set nb114nf_jzO, 224.set nb114nf_jxH1, 240.set nb114nf_jyH1, 256.set nb114nf_jzH1, 272.set nb114nf_jxH2, 288.set nb114nf_jyH2, 304.set nb114nf_jzH2, 320.set nb114nf_jxM, 336.set nb114nf_jyM, 352.set nb114nf_jzM, 368.set nb114nf_qqMM, 384.set nb114nf_qqMH, 400.set nb114nf_qqHH, 416.set nb114nf_two, 432.set nb114nf_c6, 448.set nb114nf_c12, 464.set nb114nf_vctot, 480.set nb114nf_Vvdwtot, 496.set nb114nf_half, 512.set nb114nf_three, 528.set nb114nf_rsqOO, 544.set nb114nf_rsqH1H1, 560.set nb114nf_rsqH1H2, 576.set nb114nf_rsqH1M, 592.set nb114nf_rsqH2H1, 608.set nb114nf_rsqH2H2, 624.set nb114nf_rsqH2M, 640.set nb114nf_rsqMH1, 656.set nb114nf_rsqMH2, 672.set nb114nf_rsqMM, 688.set nb114nf_rinvsqOO, 704.set nb114nf_rinvH1H1, 720.set nb114nf_rinvH1H2, 736.set nb114nf_rinvH1M, 752.set nb114nf_rinvH2H1, 768.set nb114nf_rinvH2H2, 784.set nb114nf_rinvH2M, 800.set nb114nf_rinvMH1, 816.set nb114nf_rinvMH2, 832.set nb114nf_rinvMM, 848.set nb114nf_nri, 864.set nb114nf_iinr, 872.set nb114nf_jindex, 880.set nb114nf_jjnr, 888.set nb114nf_shift, 896.set nb114nf_shiftvec, 904.set nb114nf_facel, 912.set nb114nf_innerjjnr, 920.set nb114nf_innerk, 928.set nb114nf_is3, 932.set nb114nf_ii3, 936.set nb114nf_n, 940.set nb114nf_nn1, 944.set nb114nf_nouter, 948.set nb114nf_ninner, 952.set nb114nf_salign, 956 push %rbp movq %rsp,%rbp push %rbx push %r12 push %r13 push %r14 push %r15 subq $968,%rsp emms ## zero 32-bit iteration counters movl $0,%eax movl %eax,nb114nf_nouter(%rsp) movl %eax,nb114nf_ninner(%rsp) movl (%rdi),%edi movl %edi,nb114nf_nri(%rsp) movq %rsi,nb114nf_iinr(%rsp) movq %rdx,nb114nf_jindex(%rsp) movq %rcx,nb114nf_jjnr(%rsp) movq %r8,nb114nf_shift(%rsp) movq %r9,nb114nf_shiftvec(%rsp) movq nb114nf_p_facel(%rbp),%rsi movss (%rsi),%xmm0 movss %xmm0,nb114nf_facel(%rsp) ## create constant floating-point factors on stack movl $0x3f000000,%eax ## half in IEEE (hex) movl %eax,nb114nf_half(%rsp) movss nb114nf_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,nb114nf_half(%rsp) movaps %xmm2,nb114nf_two(%rsp) movaps %xmm3,nb114nf_three(%rsp) ## assume we have at least one i particle - start directly movq nb114nf_iinr(%rsp),%rcx ## rcx = pointer into iinr[] movl (%rcx),%ebx ## ebx =ii movq nb114nf_charge(%rbp),%rdx movss 4(%rdx,%rbx,4),%xmm5 movss 12(%rdx,%rbx,4),%xmm3 movss %xmm3,%xmm4 movq nb114nf_p_facel(%rbp),%rsi movss (%rsi),%xmm0 movss nb114nf_facel(%rsp),%xmm6 mulss %xmm3,%xmm3 mulss %xmm5,%xmm4 mulss %xmm5,%xmm5 mulss %xmm6,%xmm3 mulss %xmm6,%xmm4 mulss %xmm6,%xmm5 shufps $0,%xmm3,%xmm3 shufps $0,%xmm4,%xmm4 shufps $0,%xmm5,%xmm5 movaps %xmm3,nb114nf_qqMM(%rsp) movaps %xmm4,nb114nf_qqMH(%rsp) movaps %xmm5,nb114nf_qqHH(%rsp) xorps %xmm0,%xmm0 movq nb114nf_type(%rbp),%rdx movl (%rdx,%rbx,4),%ecx shll %ecx movl %ecx,%edx movq nb114nf_p_ntype(%rbp),%rdi imull (%rdi),%ecx ## rcx = ntia = 2*ntype*type[ii0] addq %rcx,%rdx movq nb114nf_vdwparam(%rbp),%rax movlps (%rax,%rdx,4),%xmm0 movaps %xmm0,%xmm1 shufps $0,%xmm0,%xmm0 shufps $0x55,%xmm1,%xmm1 movaps %xmm0,nb114nf_c6(%rsp) movaps %xmm1,nb114nf_c12(%rsp)_nb_kernel114nf_x86_64_sse.nb114nf_threadloop: movq nb114nf_count(%rbp),%rsi ## pointer to sync counter movl (%rsi),%eax_nb_kernel114nf_x86_64_sse.nb114nf_spinlock: movl %eax,%ebx ## ebx=*count=nn0 addq $1,%rbx ## rbx=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_kernel114nf_x86_64_sse.nb114nf_spinlock ## if(nn1>nri) nn1=nri movl nb114nf_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,nb114nf_n(%rsp) movl %ebx,nb114nf_nn1(%rsp) subl %eax,%ebx ## calc number of outer lists movl %eax,%esi ## copy n to esi jg _nb_kernel114nf_x86_64_sse.nb114nf_outerstart jmp _nb_kernel114nf_x86_64_sse.nb114nf_end_nb_kernel114nf_x86_64_sse.nb114nf_outerstart: ## ebx contains number of outer iterations addl nb114nf_nouter(%rsp),%ebx movl %ebx,nb114nf_nouter(%rsp)_nb_kernel114nf_x86_64_sse.nb114nf_outer: movq nb114nf_shift(%rsp),%rax ## rax = pointer into shift[] movl (%rax,%rsi,4),%ebx ## rbx=shift[n] lea (%rbx,%rbx,2),%rbx ## rbx=3*is movl %ebx,nb114nf_is3(%rsp) ## store is3 movq nb114nf_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 nb114nf_iinr(%rsp),%rcx ## rcx = pointer into iinr[] movl (%rcx,%rsi,4),%ebx ## ebx =ii lea (%rbx,%rbx,2),%rbx ## rbx = 3*ii=ii3 movq nb114nf_pos(%rbp),%rax ## rax = base of pos[] movl %ebx,nb114nf_ii3(%rsp) movaps %xmm0,%xmm3 movaps %xmm1,%xmm4 movaps %xmm2,%xmm5 movaps %xmm0,%xmm6 movaps %xmm1,%xmm7 addss (%rax,%rbx,4),%xmm3 ## ox addss 4(%rax,%rbx,4),%xmm4 ## oy addss 8(%rax,%rbx,4),%xmm5 ## oz addss 12(%rax,%rbx,4),%xmm6 ## h1x addss 16(%rax,%rbx,4),%xmm7 ## h1y shufps $0,%xmm3,%xmm3 shufps $0,%xmm4,%xmm4 shufps $0,%xmm5,%xmm5 shufps $0,%xmm6,%xmm6 shufps $0,%xmm7,%xmm7 movaps %xmm3,nb114nf_ixO(%rsp) movaps %xmm4,nb114nf_iyO(%rsp) movaps %xmm5,nb114nf_izO(%rsp) movaps %xmm6,nb114nf_ixH1(%rsp) movaps %xmm7,nb114nf_iyH1(%rsp) movss %xmm2,%xmm6 movss %xmm0,%xmm3 movss %xmm1,%xmm4 movss %xmm2,%xmm5 addss 20(%rax,%rbx,4),%xmm6 ## h1z addss 24(%rax,%rbx,4),%xmm0 ## h2x addss 28(%rax,%rbx,4),%xmm1 ## h2y addss 32(%rax,%rbx,4),%xmm2 ## h2z addss 36(%rax,%rbx,4),%xmm3 ## mx addss 40(%rax,%rbx,4),%xmm4 ## my addss 44(%rax,%rbx,4),%xmm5 ## mz shufps $0,%xmm6,%xmm6 shufps $0,%xmm0,%xmm0 shufps $0,%xmm1,%xmm1 shufps $0,%xmm2,%xmm2 shufps $0,%xmm3,%xmm3 shufps $0,%xmm4,%xmm4 shufps $0,%xmm5,%xmm5 movaps %xmm6,nb114nf_izH1(%rsp) movaps %xmm0,nb114nf_ixH2(%rsp) movaps %xmm1,nb114nf_iyH2(%rsp) movaps %xmm2,nb114nf_izH2(%rsp) movaps %xmm3,nb114nf_ixM(%rsp) movaps %xmm4,nb114nf_iyM(%rsp) movaps %xmm5,nb114nf_izM(%rsp) ## clear vctot xorps %xmm4,%xmm4 movaps %xmm4,nb114nf_vctot(%rsp) movaps %xmm4,nb114nf_Vvdwtot(%rsp) movq nb114nf_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 nb114nf_pos(%rbp),%rsi movq nb114nf_faction(%rbp),%rdi movq nb114nf_jjnr(%rsp),%rax shll $2,%ecx addq %rcx,%rax movq %rax,nb114nf_innerjjnr(%rsp) ## pointer to jjnr[nj0] movl %edx,%ecx subl $4,%edx addl nb114nf_ninner(%rsp),%ecx movl %ecx,nb114nf_ninner(%rsp) addl $0,%edx movl %edx,nb114nf_innerk(%rsp) ## number of innerloop atoms jge _nb_kernel114nf_x86_64_sse.nb114nf_unroll_loop jmp _nb_kernel114nf_x86_64_sse.nb114nf_single_check_nb_kernel114nf_x86_64_sse.nb114nf_unroll_loop: ## quad-unroll innerloop here movq nb114nf_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,nb114nf_innerjjnr(%rsp) ## advance pointer (unroll 4) movq nb114nf_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 j coordinates to local temp variables ## Load Ox, Oy, Oz, H1x movlps (%rsi,%rax,4),%xmm1 ## Oxa Oya - - movlps (%rsi,%rcx,4),%xmm4 ## Oxc Oyc - - movhps (%rsi,%rbx,4),%xmm1 ## Oxa Oya Oxb Oyb movhps (%rsi,%rdx,4),%xmm4 ## Oxc Oyc Oxd Oyd movaps %xmm1,%xmm0 ## Oxa Oya Oxb Oyb shufps $0x88,%xmm4,%xmm0 ## Oxa Oxb Oxc Oxd shufps $0xDD,%xmm4,%xmm1 ## Oya Oyb Oyc Oyd movlps 8(%rsi,%rax,4),%xmm3 ## Oza H1xa - - movlps 8(%rsi,%rcx,4),%xmm5 ## Ozc H1xc - - movhps 8(%rsi,%rbx,4),%xmm3 ## Oza H1xa Ozb H1xb movhps 8(%rsi,%rdx,4),%xmm5 ## Ozc H1xc Ozd H1xd movaps %xmm3,%xmm2 ## Oza H1xa Ozb H1xb shufps $0x88,%xmm5,%xmm2 ## Oza Ozb Ozc Ozd shufps $0xDD,%xmm5,%xmm3 ## H1xa H1xb H1xc H1xd ## coordinates in xmm0-xmm3 ## store movaps %xmm0,nb114nf_jxO(%rsp) movaps %xmm1,nb114nf_jyO(%rsp) movaps %xmm2,nb114nf_jzO(%rsp)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?