nb_kernel010_x86_64_sse.s

来自「最著名最快的分子模拟软件」· S 代码 · 共 1,275 行 · 第 1/3 页

S
1,275
字号
    xorps  %xmm7,%xmm7        movaps %xmm3,%xmm0        shufps $136,%xmm7,%xmm0 ## 10001000        shufps $221,%xmm7,%xmm3 ## 11011101    ## xmm0=c6    ## xmm3=c12        lea  (%rax,%rax,2),%rax     ## replace jnr with j3         lea  (%rbx,%rbx,2),%rbx        movq nb010_pos(%rbp),%rdi        ## load coordinates        movlps (%rdi,%rax,4),%xmm1      ## x1 y1  -  -         movlps (%rdi,%rbx,4),%xmm4      ## x2 y2  -  -        movss 8(%rdi,%rax,4),%xmm5      ## z1 - - -         movss 8(%rdi,%rbx,4),%xmm7      ## z2 - - -     unpcklps %xmm4,%xmm1 ## x1 x2 y1 y2    movhlps  %xmm1,%xmm2 ## y1 y2 -  -    unpcklps %xmm7,%xmm5 ## z1 z2 -  -         ## calc dr          subps nb010_ix(%rsp),%xmm1        subps nb010_iy(%rsp),%xmm2        subps nb010_iz(%rsp),%xmm5        ## store dr in xmm9-xmm11    movaps %xmm1,%xmm9    movaps %xmm2,%xmm10    movaps %xmm5,%xmm11        ## square it         mulps %xmm1,%xmm1        mulps %xmm2,%xmm2        mulps %xmm5,%xmm5        addps %xmm2,%xmm1        addps %xmm5,%xmm1        ## rsq in xmm1        rcpps %xmm1,%xmm5        ## 1/x lookup seed in xmm5         movaps nb010_two(%rsp),%xmm6        mulps %xmm5,%xmm1        subps %xmm1,%xmm6        mulps %xmm5,%xmm6       ## xmm6=rinvsq        movaps %xmm6,%xmm4  ## rinvsq        movaps %xmm6,%xmm1        mulps  %xmm6,%xmm1  ## rinv4        mulps  %xmm6,%xmm1      ## rinv6        movaps %xmm1,%xmm2        mulps  %xmm2,%xmm2      ## xmm2=rinv12        mulps  %xmm0,%xmm1        mulps  %xmm3,%xmm2        movaps %xmm2,%xmm5        subps  %xmm1,%xmm5      ## Vvdw=Vvdw12-Vvdw6         mulps  nb010_six(%rsp),%xmm1        mulps  nb010_twelve(%rsp),%xmm2        subps  %xmm1,%xmm2        mulps  %xmm2,%xmm4      ## xmm4=total fscal     xorps  %xmm7,%xmm7    movlhps %xmm7,%xmm5    ## add potential to Vvdwtot (sum in xmm12)        addps  %xmm5,%xmm12    ## calculate scalar force by multiplying dx/dy/dz with fscal        mulps  %xmm4,%xmm9        mulps  %xmm4,%xmm10        mulps  %xmm4,%xmm11    movlhps %xmm7,%xmm9    movlhps %xmm7,%xmm10    movlhps %xmm7,%xmm11        ## xmm0-xmm2 contains tx-tz (partial force)         ## accumulate i forces    addps %xmm9,%xmm13    addps %xmm10,%xmm14    addps %xmm11,%xmm15        movq nb010_faction(%rbp),%rsi        ## the fj's - start by accumulating x & y forces from memory         movlps (%rsi,%rax,4),%xmm0 ## x1 y1 - -        movhps (%rsi,%rbx,4),%xmm0 ## x1 y1 x2 y2    unpcklps %xmm10,%xmm9 ## x1 y1 x2 y2    addps    %xmm9,%xmm0        movlps %xmm0,(%rsi,%rax,4)        movhps %xmm0,(%rsi,%rbx,4)    ## z forces    pshufd $1,%xmm11,%xmm8    addss  8(%rsi,%rax,4),%xmm11    addss  8(%rsi,%rbx,4),%xmm8    movss  %xmm11,8(%rsi,%rax,4)    movss  %xmm8,8(%rsi,%rbx,4)_nb_kernel010_x86_64_sse.nb010_checksingle:         movl  nb010_innerk(%rsp),%edx    andl  $1,%edx    jnz    _nb_kernel010_x86_64_sse.nb010_dosingle    jmp    _nb_kernel010_x86_64_sse.nb010_updateouterdata_nb_kernel010_x86_64_sse.nb010_dosingle:     movq nb010_innerjjnr(%rsp),%rcx        movl  (%rcx),%eax        movq nb010_type(%rbp),%rsi        movl (%rsi,%rax,4),%r12d        shll %r12d    movl nb010_ntia(%rsp),%edi        addl %edi,%r12d        movq nb010_vdwparam(%rbp),%rsi        movss (%rsi,%r12,4),%xmm0    movss 4(%rsi,%r12,4),%xmm3    ## xmm0=c6    ## xmm3=c12        lea  (%rax,%rax,2),%rax     ## replace jnr with j3         movq nb010_pos(%rbp),%rdi        ## load coordinates        movss (%rdi,%rax,4),%xmm1        movss 4(%rdi,%rax,4),%xmm2        movss 8(%rdi,%rax,4),%xmm5        ## calc dr          subss nb010_ix(%rsp),%xmm1        subss nb010_iy(%rsp),%xmm2        subss nb010_iz(%rsp),%xmm5        ## store dr in xmm9-xmm11    movaps %xmm1,%xmm9    movaps %xmm2,%xmm10    movaps %xmm5,%xmm11        ## square it         mulss %xmm1,%xmm1        mulss %xmm2,%xmm2        mulss %xmm5,%xmm5        addss %xmm2,%xmm1        addss %xmm5,%xmm1        ## rsq in xmm1        ## rsq in xmm4         rcpss %xmm1,%xmm5        ## 1/x lookup seed in xmm5         movaps nb010_two(%rsp),%xmm6        mulss %xmm5,%xmm1        subss %xmm1,%xmm6        mulss %xmm5,%xmm6       ## xmm6=rinvsq        movaps %xmm6,%xmm4  ## rinvsq        movaps %xmm6,%xmm1        mulss  %xmm6,%xmm1  ## rinv4        mulss  %xmm6,%xmm1      ## rinv6        movaps %xmm1,%xmm2        mulss  %xmm2,%xmm2      ## xmm2=rinv12        mulss  %xmm0,%xmm1        mulss  %xmm3,%xmm2        movaps %xmm2,%xmm5        subss  %xmm1,%xmm5      ## Vvdw=Vvdw12-Vvdw6         mulss  nb010_six(%rsp),%xmm1        mulss  nb010_twelve(%rsp),%xmm2        subss  %xmm1,%xmm2        mulss  %xmm2,%xmm4      ## xmm4=total fscal     ## add potential to Vvdwtot (sum in xmm12)        addss  %xmm5,%xmm12    ## calculate scalar force by multiplying dx/dy/dz with fscal        mulss  %xmm4,%xmm9        mulss  %xmm4,%xmm10        mulss  %xmm4,%xmm11        ## xmm0-xmm2 contains tx-tz (partial force)         ## accumulate i forces    addss %xmm9,%xmm13    addss %xmm10,%xmm14    addss %xmm11,%xmm15        movq nb010_faction(%rbp),%rsi    ## add to j forces    addss  (%rsi,%rax,4),%xmm9    addss  4(%rsi,%rax,4),%xmm10    addss  8(%rsi,%rax,4),%xmm11    movss  %xmm9,(%rsi,%rax,4)    movss  %xmm10,4(%rsi,%rax,4)    movss  %xmm11,8(%rsi,%rax,4)_nb_kernel010_x86_64_sse.nb010_updateouterdata:         movl  nb010_ii3(%rsp),%ecx        movq  nb010_faction(%rbp),%rdi        movq  nb010_fshift(%rbp),%rsi        movl  nb010_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 nb010_n(%rsp),%esi    ## get group index for i particle     movq  nb010_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  nb010_Vvdw(%rbp),%rax        addss (%rax,%rdx,4),%xmm12        ## move back to mem         movss %xmm12,(%rax,%rdx,4)        ## finish if last         movl nb010_nn1(%rsp),%ecx        ## esi already loaded with n        incl %esi        subl %esi,%ecx        jz _nb_kernel010_x86_64_sse.nb010_outerend        ## not last, iterate outer loop once more!          movl %esi,nb010_n(%rsp)        jmp _nb_kernel010_x86_64_sse.nb010_outer_nb_kernel010_x86_64_sse.nb010_outerend:         ## check if more outer neighborlists remain        movl  nb010_nri(%rsp),%ecx        ## esi already loaded with n above        subl  %esi,%ecx        jz _nb_kernel010_x86_64_sse.nb010_end        ## non-zero, do one more workunit        jmp   _nb_kernel010_x86_64_sse.nb010_threadloop_nb_kernel010_x86_64_sse.nb010_end:         emms        movl nb010_nouter(%rsp),%eax        movl nb010_ninner(%rsp),%ebx        movq nb010_outeriter(%rbp),%rcx        movq nb010_inneriter(%rbp),%rdx        movl %eax,(%rcx)        movl %ebx,(%rdx)        addq $392,%rsp        pop %r15        pop %r14        pop %r13        pop %r12        pop %rbx        pop    %rbp        ret.globl nb_kernel010nf_x86_64_sse.globl _nb_kernel010nf_x86_64_ssenb_kernel010nf_x86_64_sse:      _nb_kernel010nf_x86_64_sse:     ##      Room for return address and rbp (16 bytes).set nb010nf_fshift, 16.set nb010nf_gid, 24.set nb010nf_pos, 32.set nb010nf_faction, 40.set nb010nf_charge, 48.set nb010nf_p_facel, 56.set nb010nf_argkrf, 64.set nb010nf_argcrf, 72.set nb010nf_Vc, 80.set nb010nf_type, 88.set nb010nf_p_ntype, 96.set nb010nf_vdwparam, 104.set nb010nf_Vvdw, 112.set nb010nf_p_tabscale, 120.set nb010nf_VFtab, 128.set nb010nf_invsqrta, 136.set nb010nf_dvda, 144.set nb010nf_p_gbtabscale, 152.set nb010nf_GBtab, 160.set nb010nf_p_nthreads, 168.set nb010nf_count, 176.set nb010nf_mtx, 184.set nb010nf_outeriter, 192.set nb010nf_inneriter, 200.set nb010nf_work, 208        ## The mutex (last arg) is not used in assembly.        ## stack offsets for local variables          ## bottom of stack is cache-aligned for sse use .set nb010nf_ix, 0.set nb010nf_iy, 16.set nb010nf_iz, 32.set nb010nf_two, 48.set nb010nf_c6, 64.set nb010nf_c12, 80.set nb010nf_Vvdwtot, 96.set nb010nf_half, 112.set nb010nf_three, 128.set nb010nf_nri, 144.set nb010nf_iinr, 152.set nb010nf_jindex, 160.set nb010nf_jjnr, 168.set nb010nf_shift, 176.set nb010nf_shiftvec, 184.set nb010nf_innerjjnr, 192.set nb010nf_facel, 200.set nb010nf_ntia, 208.set nb010nf_innerk, 216.set nb010nf_is3, 220.set nb010nf_ii3, 224.set nb010nf_n, 228.set nb010nf_nn1, 232.set nb010nf_ntype, 236.set nb010nf_nouter, 240.set nb010nf_ninner, 244        push %rbp        movq %rsp,%rbp        push %rbx        subq $264,%rsp          # # local variable stack space (n*16+8)                                                                 emms        ## zero 32-bit iteration counters        movl $0,%eax        movl %eax,nb010nf_nouter(%rsp)        movl %eax,nb010nf_ninner(%rsp)        movl (%rdi),%edi        movl %edi,nb010nf_nri(%rsp)        movq %rsi,nb010nf_iinr(%rsp)        movq %rdx,nb010nf_jindex(%rsp)        movq %rcx,nb010nf_jjnr(%rsp)        movq %r8,nb010nf_shift(%rsp)        movq %r9,nb010nf_shiftvec(%rsp)        movq nb010nf_p_ntype(%rbp),%rdi        movl (%rdi),%edi        movl %edi,nb010nf_ntype(%rsp)        ## create constant floating-point factors on stack        movl $0x40000000,%eax   ## 2.0 in IEEE (hex)        movl %eax,nb010nf_two(%rsp)        movss nb010nf_two(%rsp),%xmm1        shufps $0,%xmm1,%xmm1  ## splat to all elements        movaps %xmm1,nb010nf_two(%rsp)_nb_kernel010nf_x86_64_sse.nb010nf_threadloop:         movq  nb010nf_count(%rbp),%rsi          ## pointer to sync counter        movl  (%rsi),%eax_nb_kernel010nf_x86_64_sse.nb010nf_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_kernel010nf_x86_64_sse.nb010nf_spinlock        ## if(nn1>nri) nn1=nri        movl nb010nf_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,nb010nf_n(%rsp)

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?