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