nb_kernel110_x86_64_sse.s

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

S
1,440
字号
        ## load coordinates        movq nb110_pos(%rbp),%rdi        movlps (%rdi,%rax,4),%xmm1      ## x1 y1 - -         movlps (%rdi,%rbx,4),%xmm2      ## x2 y2 - -         movss 8(%rdi,%rax,4),%xmm5      ## z1 - - -         movss 8(%rdi,%rbx,4),%xmm6      ## z2 - - -     unpcklps %xmm2,%xmm1 ## x1 x2 y1 y2    movhlps  %xmm1,%xmm2 ## y1 y2 -  -    unpcklps %xmm6,%xmm5 ## z1 z2 -  -        ## calc dr          subps nb110_ix(%rsp),%xmm1        subps nb110_iy(%rsp),%xmm2        subps nb110_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    ## calculate rinv=1/sqrt(rsq)        rsqrtps %xmm1,%xmm5        movaps %xmm5,%xmm6        mulps %xmm5,%xmm5        movaps nb110_three(%rsp),%xmm4        mulps %xmm1,%xmm5       ## rsq*lu*lu        subps %xmm5,%xmm4   ## 30-rsq*lu*lu         mulps %xmm6,%xmm4        mulps nb110_half(%rsp),%xmm4        movaps %xmm4,%xmm1        mulps  %xmm4,%xmm4    ## xmm1=rinv    ## xmm4=rinvsq         movaps %xmm4,%xmm5        mulps  %xmm4,%xmm5  ## rinv4        mulps  %xmm4,%xmm5      ## rinv6        movaps %xmm5,%xmm6        mulps  %xmm5,%xmm5      ## xmm5=rinv12    ## coulomb stuff    mulps  nb110_qq(%rsp),%xmm1    ## vcoul=rinv*qq    movaps %xmm1,%xmm8 ## fijC    ## add to vctot    addps  nb110_vctot(%rsp),%xmm1    movlps %xmm1,nb110_vctot(%rsp)        mulps  %xmm0,%xmm6  ## vvdw6=c6*rinv6        mulps  %xmm3,%xmm5  ## vvdw12=c12*rinv12             movaps %xmm5,%xmm7        subps  %xmm6,%xmm5      ## Vvdw=Vvdw12-Vvdw6        mulps  nb110_six(%rsp),%xmm6        mulps  nb110_twelve(%rsp),%xmm7        subps  %xmm6,%xmm7    addps  %xmm7,%xmm8        mulps  %xmm8,%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 nb110_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_kernel110_x86_64_sse.nb110_checksingle:         movl  nb110_innerk(%rsp),%edx    andl  $1,%edx    jnz    _nb_kernel110_x86_64_sse.nb110_dosingle    jmp    _nb_kernel110_x86_64_sse.nb110_updateouterdata_nb_kernel110_x86_64_sse.nb110_dosingle:     movq nb110_innerjjnr(%rsp),%rcx        movl  (%rcx),%eax        movq nb110_charge(%rbp),%rsi        movss (%rsi,%rax,4),%xmm0    mulss nb110_iq(%rsp),%xmm0    movaps %xmm0,nb110_qq(%rsp)        movq nb110_type(%rbp),%rsi        movl (%rsi,%rax,4),%r12d        shll %r12d    movl nb110_ntia(%rsp),%edi        addl %edi,%r12d        movq nb110_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 nb110_pos(%rbp),%rdi        ## load coordinates        movss (%rdi,%rax,4),%xmm1           ## x1 - - -         movss 4(%rdi,%rax,4),%xmm2       ## y2 - - -         movss 8(%rdi,%rax,4),%xmm5       ## 13 - - -         ## calc dr          subss nb110_ix(%rsp),%xmm1        subss nb110_iy(%rsp),%xmm2        subss nb110_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    ## calculate rinv=1/sqrt(rsq)        rsqrtss %xmm1,%xmm5        movaps %xmm5,%xmm6        mulss %xmm5,%xmm5        movaps nb110_three(%rsp),%xmm4        mulss %xmm1,%xmm5       ## rsq*lu*lu        subss %xmm5,%xmm4   ## 30-rsq*lu*lu         mulss %xmm6,%xmm4        mulss nb110_half(%rsp),%xmm4        movaps %xmm4,%xmm1        mulss  %xmm4,%xmm4    ## xmm1=rinv    ## xmm4=rinvsq         movaps %xmm4,%xmm5        mulss  %xmm4,%xmm5  ## rinv4        mulss  %xmm4,%xmm5      ## rinv6        movaps %xmm5,%xmm6        mulss  %xmm5,%xmm5      ## xmm5=rinv12    ## coulomb stuff    mulss  nb110_qq(%rsp),%xmm1    ## vcoul=rinv*qq    movaps %xmm1,%xmm8 ## fijC    ## add to vctot    addss  nb110_vctot(%rsp),%xmm1    movss %xmm1,nb110_vctot(%rsp)        mulss  %xmm0,%xmm6  ## vvdw6=c6*rinv6        mulss  %xmm3,%xmm5  ## vvdw12=c12*rinv12             movaps %xmm5,%xmm7        subss  %xmm6,%xmm5      ## Vvdw=Vvdw12-Vvdw6        mulss  nb110_six(%rsp),%xmm6        mulss  nb110_twelve(%rsp),%xmm7        subss  %xmm6,%xmm7    addss  %xmm7,%xmm8        mulss  %xmm8,%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 nb110_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_kernel110_x86_64_sse.nb110_updateouterdata:         movl  nb110_ii3(%rsp),%ecx        movq  nb110_faction(%rbp),%rdi        movq  nb110_fshift(%rbp),%rsi        movl  nb110_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 nb110_n(%rsp),%esi        ## get group index for i particle         movq  nb110_gid(%rbp),%rdx              ## base of gid[]        movl  (%rdx,%rsi,4),%edx                ## ggid=gid[n]        ## accumulate total potential energy and update it         movaps nb110_vctot(%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  nb110_Vc(%rbp),%rax        addss (%rax,%rdx,4),%xmm7        ## move back to mem         movss %xmm7,(%rax,%rdx,4)        ## 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  nb110_Vvdw(%rbp),%rax        addss (%rax,%rdx,4),%xmm12        ## move back to mem         movss %xmm12,(%rax,%rdx,4)        ## finish if last         movl nb110_nn1(%rsp),%ecx        ## esi already loaded with n        incl %esi        subl %esi,%ecx        jz _nb_kernel110_x86_64_sse.nb110_outerend        ## not last, iterate outer loop once more!          movl %esi,nb110_n(%rsp)        jmp _nb_kernel110_x86_64_sse.nb110_outer_nb_kernel110_x86_64_sse.nb110_outerend:         ## check if more outer neighborlists remain        movl  nb110_nri(%rsp),%ecx        ## esi already loaded with n above        subl  %esi,%ecx        jz _nb_kernel110_x86_64_sse.nb110_end        ## non-zero, do one more workunit        jmp   _nb_kernel110_x86_64_sse.nb110_threadloop_nb_kernel110_x86_64_sse.nb110_end:         movl nb110_nouter(%rsp),%eax        movl nb110_ninner(%rsp),%ebx        movq nb110_outeriter(%rbp),%rcx        movq nb110_inneriter(%rbp),%rdx        movl %eax,(%rcx)        movl %ebx,(%rdx)        addq $408,%rsp        emms        pop %r15        pop %r14        pop %r13        pop %r12        pop %rbx        pop    %rbp        ret.globl nb_kernel110nf_x86_64_sse.globl _nb_kernel110nf_x86_64_ssenb_kernel110nf_x86_64_sse:      _nb_kernel110nf_x86_64_sse:     ##      Room for return address and rbp (16 bytes).set nb110nf_fshift, 16.set nb110nf_gid, 24.set nb110nf_pos, 32.set nb110nf_faction, 40.set nb110nf_charge, 48.set nb110nf_p_facel, 56.set nb110nf_argkrf, 64.set nb110nf_argcrf, 72.set nb110nf_Vc, 80.set nb110nf_type, 88.set nb110nf_p_ntype, 96.set nb110nf_vdwparam, 104.set nb110nf_Vvdw, 112.set nb110nf_p_tabscale, 120.set nb110nf_VFtab, 128.set nb110nf_invsqrta, 136.set nb110nf_dvda, 144.set nb110nf_p_gbtabscale, 152.set nb110nf_GBtab, 160.set nb110nf_p_nthreads, 168.set nb110nf_count, 176.set nb110nf_mtx, 184.set nb110nf_outeriter, 192.set nb110nf_inneriter, 200.set nb110nf_work, 208        ## stack offsets for local variables          ## bottom of stack is cache-aligned for sse use .set nb110nf_ix, 0.set nb110nf_iy, 16.set nb110nf_iz, 32.set nb110nf_iq, 48.set nb110nf_c6, 64.set nb110nf_c12, 80.set nb110nf_vctot, 96.set nb110nf_Vvdwtot, 112.set nb110nf_half, 128.set nb110nf_three, 144.set nb110nf_nri, 160.set nb110nf_iinr, 168.set nb110nf_jindex, 176.set nb110nf_jjnr, 184.set nb110nf_shift, 192.set nb110nf_shiftvec, 200.set nb110nf_facel, 208.set nb110nf_innerjjnr, 216.set nb110nf_is3, 224.set nb110nf_ii3, 228.set nb110nf_ntia, 232.set nb110nf_innerk, 236.set nb110nf_n, 240.set nb110nf_nn1, 244.set nb110nf_ntype, 248.set nb110nf_nouter, 252.set nb110nf_ninner, 256        push %rbp        movq %rsp,%rbp        push %rbx        emms        subq $280,%rsp        ## zero 32-bit iteration counters        movl $0,%eax        movl %eax,nb110nf_nouter(%rsp)        movl %eax,nb110nf_ninner(%rsp)        movl (%rdi),%edi        movl %edi,nb110nf_nri(%rsp)        movq %rsi,nb110nf_iinr(%rsp)        movq %rdx,nb110nf_jindex(%rsp)        movq %rcx,nb110nf_jjnr(%rsp)        movq %r8,nb110nf_shift(%rsp)        movq %r9,nb110nf_shiftvec(%rsp)        movq nb110nf_p_ntype(%rbp),%rdi        movl (%rdi),%edi        movl %edi,nb110nf_ntype(%rsp)        movq nb110nf_p_facel(%rbp),%rsi        movss (%rsi),%xmm0        movss %xmm0,nb110nf_facel(%rsp)        ## create constant floating-point factors on stack        movl $0x3f000000,%eax   ## half in IEEE (hex)        movl %eax,nb110nf_half(%rsp)        movss nb110nf_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,nb110nf_half(%rsp)        movaps %xmm3,nb110nf_three(%rsp)_nb_kernel110nf_x86_64_sse.nb110nf_threadloop:         movq  nb110nf_count(%rbp),%rsi            ## pointer to sync counter        movl  (%rsi),%eax_nb_kernel110nf_x86_64_sse.nb110nf_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_kernel110nf_x86_64_sse.nb110nf_spinlock        ## if(nn1>nri) nn1=nri        movl nb110nf_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,nb110nf_n(%rsp)        movl %ebx,nb110nf_nn1(%rsp)        subl %eax,%ebx                          ## calc number of outer lists        movl %eax,%esi                          ## copy n to esi        jg  _nb_kernel110nf_x86_64_sse.nb110nf_outerstart        jmp _nb_kernel110nf_x86_64_sse.nb110nf_end_nb_kernel110nf_x86_64_sse.nb110nf_outerstart:         ## ebx contains number of outer iterations        addl nb110nf_nouter(%rsp),%ebx        movl %ebx,nb110nf_nouter(%rsp)_nb_kernel110nf_x86_64_sse.nb110nf_outer:         movq  nb110nf_shift(%rsp),%rax        ## rax = pointer into shift[] 

⌨️ 快捷键说明

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