nb_kernel101_x86_64_sse.s

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

S
1,416
字号
.set nb101nf_nn1, 336.set nb101nf_nouter, 340.set nb101nf_ninner, 344        push %rbp        movq %rsp,%rbp        push %rbx        subq $360,%rsp        emms        ## zero 32-bit iteration counters        movl $0,%eax        movl %eax,nb101nf_nouter(%rsp)        movl %eax,nb101nf_ninner(%rsp)        movl (%rdi),%edi        movl %edi,nb101nf_nri(%rsp)        movq %rsi,nb101nf_iinr(%rsp)        movq %rdx,nb101nf_jindex(%rsp)        movq %rcx,nb101nf_jjnr(%rsp)        movq %r8,nb101nf_shift(%rsp)        movq %r9,nb101nf_shiftvec(%rsp)        movq nb101nf_p_facel(%rbp),%rsi        movss (%rsi),%xmm0        movss %xmm0,nb101nf_facel(%rsp)        ## assume we have at least one i particle - start directly         movq  nb101nf_iinr(%rsp),%rcx         ## rcx = pointer into iinr[]              movl  (%rcx),%ebx           ## ebx =ii         movq  nb101nf_charge(%rbp),%rdx        movss (%rdx,%rbx,4),%xmm3        movss 4(%rdx,%rbx,4),%xmm4        movq nb101nf_p_facel(%rbp),%rsi        movss (%rsi),%xmm0        movss nb101nf_facel(%rsp),%xmm5        mulss  %xmm5,%xmm3        mulss  %xmm5,%xmm4        shufps $0,%xmm3,%xmm3        shufps $0,%xmm4,%xmm4        movaps %xmm3,nb101nf_iqO(%rsp)        movaps %xmm4,nb101nf_iqH(%rsp)        ## create constant floating-point factors on stack        movl $0x3f000000,%eax   ## half in IEEE (hex)        movl %eax,nb101nf_half(%rsp)        movss nb101nf_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,nb101nf_half(%rsp)        movaps %xmm3,nb101nf_three(%rsp)_nb_kernel101nf_x86_64_sse.nb101nf_threadloop:         movq  nb101nf_count(%rbp),%rsi            ## pointer to sync counter        movl  (%rsi),%eax_nb_kernel101nf_x86_64_sse.nb101nf_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_kernel101nf_x86_64_sse.nb101nf_spinlock        ## if(nn1>nri) nn1=nri        movl nb101nf_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,nb101nf_n(%rsp)        movl %ebx,nb101nf_nn1(%rsp)        subl %eax,%ebx                          ## calc number of outer lists        movl %eax,%esi                          ## copy n to esi        jg  _nb_kernel101nf_x86_64_sse.nb101nf_outerstart        jmp _nb_kernel101nf_x86_64_sse.nb101nf_end_nb_kernel101nf_x86_64_sse.nb101nf_outerstart:         ## ebx contains number of outer iterations        addl nb101nf_nouter(%rsp),%ebx        movl %ebx,nb101nf_nouter(%rsp)_nb_kernel101nf_x86_64_sse.nb101nf_outer:         movq  nb101nf_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,nb101nf_is3(%rsp)            ## store is3         movq  nb101nf_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  nb101nf_iinr(%rsp),%rcx         ## rcx = pointer into iinr[]              movl  (%rcx,%rsi,4),%ebx            ## ebx =ii         movaps %xmm0,%xmm3        movaps %xmm1,%xmm4        movaps %xmm2,%xmm5        lea  (%rbx,%rbx,2),%rbx        ## rbx = 3*ii=ii3         movq  nb101nf_pos(%rbp),%rax      ## rax = base of pos[]          movl  %ebx,nb101nf_ii3(%rsp)        addss (%rax,%rbx,4),%xmm3        addss 4(%rax,%rbx,4),%xmm4        addss 8(%rax,%rbx,4),%xmm5        shufps $0,%xmm3,%xmm3        shufps $0,%xmm4,%xmm4        shufps $0,%xmm5,%xmm5        movaps %xmm3,nb101nf_ixO(%rsp)        movaps %xmm4,nb101nf_iyO(%rsp)        movaps %xmm5,nb101nf_izO(%rsp)        movss %xmm0,%xmm3        movss %xmm1,%xmm4        movss %xmm2,%xmm5        addss 12(%rax,%rbx,4),%xmm0        addss 16(%rax,%rbx,4),%xmm1        addss 20(%rax,%rbx,4),%xmm2        addss 24(%rax,%rbx,4),%xmm3        addss 28(%rax,%rbx,4),%xmm4        addss 32(%rax,%rbx,4),%xmm5        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 %xmm0,nb101nf_ixH1(%rsp)        movaps %xmm1,nb101nf_iyH1(%rsp)        movaps %xmm2,nb101nf_izH1(%rsp)        movaps %xmm3,nb101nf_ixH2(%rsp)        movaps %xmm4,nb101nf_iyH2(%rsp)        movaps %xmm5,nb101nf_izH2(%rsp)        ## clear vctot and i forces         xorps %xmm4,%xmm4        movaps %xmm4,nb101nf_vctot(%rsp)        movq  nb101nf_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  nb101nf_pos(%rbp),%rsi        movq  nb101nf_jjnr(%rsp),%rax        shll  $2,%ecx        addq  %rcx,%rax        movq  %rax,nb101nf_innerjjnr(%rsp)       ## pointer to jjnr[nj0]         movl  %edx,%ecx        subl  $4,%edx        addl  nb101nf_ninner(%rsp),%ecx        movl  %ecx,nb101nf_ninner(%rsp)        addl  $0,%edx        movl  %edx,nb101nf_innerk(%rsp)      ## number of innerloop atoms         jge   _nb_kernel101nf_x86_64_sse.nb101nf_unroll_loop        jmp   _nb_kernel101nf_x86_64_sse.nb101nf_odd_inner_nb_kernel101nf_x86_64_sse.nb101nf_unroll_loop:         ## quad-unroll innerloop here         movq  nb101nf_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,nb101nf_innerjjnr(%rsp)             ## advance pointer (unrolled 4)         movq nb101nf_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        shufps $0,%xmm6,%xmm3        shufps $0,%xmm7,%xmm4        shufps $136,%xmm4,%xmm3 ## 10001000 ;# all charges in xmm3          movaps %xmm3,%xmm4           ## and in xmm4         mulps  nb101nf_iqO(%rsp),%xmm3        mulps  nb101nf_iqH(%rsp),%xmm4        movaps  %xmm3,nb101nf_qqO(%rsp)        movaps  %xmm4,nb101nf_qqH(%rsp)        movq nb101nf_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 ixO-izO to xmm4-xmm6         movaps nb101nf_ixO(%rsp),%xmm4        movaps nb101nf_iyO(%rsp),%xmm5        movaps nb101nf_izO(%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        movaps %xmm4,%xmm7        ## rsqO in xmm7         ## move ixH1-izH1 to xmm4-xmm6         movaps nb101nf_ixH1(%rsp),%xmm4        movaps nb101nf_iyH1(%rsp),%xmm5        movaps nb101nf_izH1(%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,%xmm6        addps %xmm4,%xmm6        ## rsqH1 in xmm6         ## move ixH2-izH2 to xmm3-xmm5          movaps nb101nf_ixH2(%rsp),%xmm3        movaps nb101nf_iyH2(%rsp),%xmm4        movaps nb101nf_izH2(%rsp),%xmm5        ## calc dr         subps %xmm0,%xmm3        subps %xmm1,%xmm4        subps %xmm2,%xmm5        ## square it         mulps %xmm3,%xmm3        mulps %xmm4,%xmm4        mulps %xmm5,%xmm5        addps %xmm4,%xmm5        addps %xmm3,%xmm5        ## rsqH2 in xmm5, rsqH1 in xmm6, rsqO in xmm7         ## start with rsqO - seed in xmm2               rsqrtps %xmm7,%xmm2        movaps  %xmm2,%xmm3        mulps   %xmm2,%xmm2        movaps  nb101nf_three(%rsp),%xmm4        mulps   %xmm7,%xmm2     ## rsq*lu*lu         subps   %xmm2,%xmm4     ## 30-rsq*lu*lu         mulps   %xmm3,%xmm4     ## lu*(3-rsq*lu*lu)         mulps   nb101nf_half(%rsp),%xmm4        movaps  %xmm4,%xmm7     ## rinvO in xmm7         ## rsqH1 - seed in xmm2         rsqrtps %xmm6,%xmm2        movaps  %xmm2,%xmm3        mulps   %xmm2,%xmm2        movaps  nb101nf_three(%rsp),%xmm4        mulps   %xmm6,%xmm2     ## rsq*lu*lu         subps   %xmm2,%xmm4     ## 30-rsq*lu*lu         mulps   %xmm3,%xmm4     ## lu*(3-rsq*lu*lu)         mulps   nb101nf_half(%rsp),%xmm4        movaps  %xmm4,%xmm6     ## rinvH1 in xmm6         ## rsqH2 - seed in xmm2         rsqrtps %xmm5,%xmm2        movaps  %xmm2,%xmm3        mulps   %xmm2,%xmm2        movaps  nb101nf_three(%rsp),%xmm4        mulps   %xmm5,%xmm2     ## rsq*lu*lu         subps   %xmm2,%xmm4     ## 30-rsq*lu*lu         mulps   %xmm3,%xmm4     ## lu*(3-rsq*lu*lu)         mulps   nb101nf_half(%rsp),%xmm4        movaps  %xmm4,%xmm5     ## rinvH2 in xmm5         ## do O interactions         mulps  nb101nf_qqO(%rsp),%xmm7          ## xmm7=vcoul         addps  nb101nf_vctot(%rsp),%xmm7        movaps %xmm7,nb101nf_vctot(%rsp)        ## H1 interactions         mulps  nb101nf_qqH(%rsp),%xmm6          ## xmm6=vcoul         addps  nb101nf_vctot(%rsp),%xmm6        movaps %xmm6,nb101nf_vctot(%rsp)        ## H2 interactions         mulps  nb101nf_qqH(%rsp),%xmm5          ## xmm5=vcoul         addps  nb101nf_vctot(%rsp),%xmm5        movaps %xmm5,nb101nf_vctot(%rsp)        ## should we do one more iteration?         subl $4,nb101nf_innerk(%rsp)        jl    _nb_kernel101nf_x86_64_sse.nb101nf_odd_inner        jmp   _nb_kernel101nf_x86_64_sse.nb101nf_unroll_loop_nb_kernel101nf_x86_64_sse.nb101nf_odd_inner:         addl $4,nb101nf_innerk(%rsp)        jnz   _nb_kernel101nf_x86_64_sse.nb101nf_odd_loop        jmp   _nb_kernel101nf_x86_64_sse.nb101nf_updateouterdata_nb_kernel101nf_x86_64_sse.nb101nf_odd_loop:         movq  nb101nf_innerjjnr(%rsp),%rdx       ## pointer to jjnr[k]         movl  (%rdx),%eax        addq $4,nb101nf_innerjjnr(%rsp)        xorps %xmm4,%xmm4        movss nb101nf_iqO(%rsp),%xmm4        movq nb101nf_charge(%rbp),%rsi        movhps nb101nf_iqH(%rsp),%xmm4        movss (%rsi,%rax,4),%xmm3       ## charge in xmm3         shufps $0,%xmm3,%xmm3        mulps %xmm4,%xmm3        movaps %xmm3,nb101nf_qqO(%rsp)          ## use oxygen qq for storage         movq nb101nf_pos(%rbp),%rsi        lea  (%rax,%rax,2),%rax        ## move j coords to xmm0-xmm2         movss (%rsi,%rax,4),%xmm0        movss 4(%rsi,%rax,4),%xmm1        movss 8(%rsi,%rax,4),%xmm2        shufps $0,%xmm0,%xmm0        shufps $0,%xmm1,%xmm1        shufps $0,%xmm2,%xmm2        movss nb101nf_ixO(%rsp),%xmm3        movss nb101nf_iyO(%rsp),%xmm4        movss nb101nf_izO(%rsp),%xmm5        movlps nb101nf_ixH1(%rsp),%xmm6        movlps nb101nf_ixH2(%rsp),%xmm7        unpcklps %xmm7,%xmm6        movlhps %xmm6,%xmm3        movlps nb101nf_iyH1(%rsp),%xmm6        movlps nb101nf_iyH2(%rsp),%xmm7        unpcklps %xmm7,%xmm6        movlhps %xmm6,%xmm4        movlps nb101nf_izH1(%rsp),%xmm6        movlps nb101nf_izH2(%rsp),%xmm7        unpcklps %xmm7,%xmm6        movlhps %xmm6,%xmm5        subps %xmm0,%xmm3        subps %xmm1,%xmm4        subps %xmm2,%xmm5        mulps  %xmm3,%xmm3        mulps  %xmm4,%xmm4        mulps  %xmm5,%xmm5        addps  %xmm3,%xmm4        addps  %xmm5,%xmm4        ## rsq in xmm4         rsqrtps %xmm4,%xmm5        ## lookup seed in xmm5         movaps %xmm5,%xmm2        mulps %xmm5,%xmm5        movaps nb101nf_three(%rsp),%xmm1        mulps %xmm4,%xmm5       ## rsq*lu*lu                            movaps nb101nf_half(%rsp),%xmm0        subps %xmm5,%xmm1       ## 30-rsq*lu*lu         mulps %xmm2,%xmm1        mulps %xmm1,%xmm0       ## xmm0=rinv         ## a little trick to avoid NaNs:         ## positions 0,2,and 3 are valid, but not 1.         ## If it contains NaN it doesnt help to mult by 0,         ## So we shuffle it and copy pos 0 to pos1!         shufps $224,%xmm0,%xmm0 ## 11100000              movaps nb101nf_qqO(%rsp),%xmm3        mulps  %xmm0,%xmm3      ## xmm3=vcoul         addps  nb101nf_vctot(%rsp),%xmm3        movaps %xmm3,nb101nf_vctot(%rsp)        decl  nb101nf_innerk(%rsp)        jz    _nb_kernel101nf_x86_64_sse.nb101nf_updateouterdata        jmp   _nb_kernel101nf_x86_64_sse.nb101nf_odd_loop_nb_kernel101nf_x86_64_sse.nb101nf_updateouterdata:         ## accumulate total potential energy and update it         ## get n from stack        movl nb101nf_n(%rsp),%esi        ## get group index for i particle         movq  nb101nf_gid(%rbp),%rdx            ## base of gid[]        movl  (%rdx,%rsi,4),%edx                ## ggid=gid[n]        movaps nb101nf_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  nb101nf_Vc(%rbp),%rax        addss (%rax,%rdx,4),%xmm7        ## move back to mem         movss %xmm7,(%rax,%rdx,4)        ## finish if last         movl nb101nf_nn1(%rsp),%ecx        ## esi already loaded with n        incl %esi        subl %esi,%ecx        jz _nb_kernel101nf_x86_64_sse.nb101nf_outerend        ## not last, iterate outer loop once more!        movl %esi,nb101nf_n(%rsp)        jmp _nb_kernel101nf_x86_64_sse.nb101nf_outer_nb_kernel101nf_x86_64_sse.nb101nf_outerend:         ## check if more outer neighborlists remain        movl  nb101nf_nri(%rsp),%ecx        ## esi already loaded with n above        subl  %esi,%ecx        jz _nb_kernel101nf_x86_64_sse.nb101nf_end        ## non-zero, do one more workunit        jmp   _nb_kernel101nf_x86_64_sse.nb101nf_threadloop_nb_kernel101nf_x86_64_sse.nb101nf_end:         movl nb101nf_nouter(%rsp),%eax        movl nb101nf_ninner(%rsp),%ebx        movq nb101nf_outeriter(%rbp),%rcx        movq nb101nf_inneriter(%rbp),%rdx        movl %eax,(%rcx)        movl %ebx,(%rdx)        addq $360,%rsp        emms        pop %rbx        pop    %rbp        ret

⌨️ 快捷键说明

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