nb_kernel204_x86_64_sse.intel_syntax.s
来自「最著名最快的分子模拟软件」· S 代码 · 共 2,224 行 · 第 1/5 页
S
2,224 行
movaps xmm5, [rsp + nb204_fjzM] addps xmm3, xmm0 addps xmm4, xmm1 addps xmm5, xmm2 mov rsi, [rbp + nb204_faction] movaps [rsp + nb204_fjxM], xmm3 movaps [rsp + nb204_fjyM], xmm4 movaps [rsp + nb204_fjzM], xmm5 addps xmm0, [rsp + nb204_fixH2] addps xmm1, [rsp + nb204_fiyH2] addps xmm2, [rsp + nb204_fizH2] movaps [rsp + nb204_fixH2], xmm0 movaps [rsp + nb204_fiyH2], xmm1 movaps [rsp + nb204_fizH2], xmm2 ;# update j water forces from local variables movlps xmm0, [rsi + rax*4 + 36] movlps xmm1, [rsi + rax*4 + 12] movhps xmm1, [rsi + rax*4 + 24] movaps xmm3, [rsp + nb204_fjxM] movaps xmm4, [rsp + nb204_fjyM] movaps xmm5, [rsp + nb204_fjzM] movaps xmm6, xmm5 movaps xmm7, xmm5 shufps xmm6, xmm6, 2 ;# 00000010 shufps xmm7, xmm7, 3 ;# 00000011 addss xmm5, [rsi + rax*4 + 44] addss xmm6, [rsi + rax*4 + 20] addss xmm7, [rsi + rax*4 + 32] movss [rsi + rax*4 + 44], xmm5 movss [rsi + rax*4 + 20], xmm6 movss [rsi + rax*4 + 32], xmm7 movaps xmm5, xmm3 unpcklps xmm3, xmm4 unpckhps xmm5, xmm4 addps xmm0, xmm3 addps xmm1, xmm5 movlps [rsi + rax*4 + 36], xmm0 movlps [rsi + rax*4 + 12], xmm1 movhps [rsi + rax*4 + 24], xmm1 dec dword ptr [rsp + nb204_innerk] jz .nb204_updateouterdata jmp .nb204_single_loop.nb204_updateouterdata: mov ecx, [rsp + nb204_ii3] mov rdi, [rbp + nb204_faction] mov rsi, [rbp + nb204_fshift] mov edx, [rsp + nb204_is3] ;# accumulate H1 i forces in xmm0, xmm1, xmm2 movaps xmm0, [rsp + nb204_fixH1] movaps xmm1, [rsp + nb204_fiyH1] movaps xmm2, [rsp + nb204_fizH1] movhlps xmm3, xmm0 movhlps xmm4, xmm1 movhlps xmm5, xmm2 addps xmm0, xmm3 addps xmm1, xmm4 addps xmm2, xmm5 ;# sum is in 1/2 in xmm0-xmm2 movaps xmm3, xmm0 movaps xmm4, xmm1 movaps xmm5, xmm2 shufps xmm3, xmm3, 1 shufps xmm4, xmm4, 1 shufps xmm5, xmm5, 1 addss xmm0, xmm3 addss xmm1, xmm4 addss xmm2, xmm5 ;# xmm0-xmm2 has single force in pos0 ;# increment i force movss xmm3, [rdi + rcx*4 + 12] movss xmm4, [rdi + rcx*4 + 16] movss xmm5, [rdi + rcx*4 + 20] subss xmm3, xmm0 subss xmm4, xmm1 subss xmm5, xmm2 movss [rdi + rcx*4 + 12], xmm3 movss [rdi + rcx*4 + 16], xmm4 movss [rdi + rcx*4 + 20], xmm5 ;# accumulate force in xmm6/xmm7 for fshift movaps xmm6, xmm0 movss xmm7, xmm2 movlhps xmm6, xmm1 shufps xmm6, xmm6, 8 ;# 00001000 ;# accumulate H2i forces in xmm0, xmm1, xmm2 movaps xmm0, [rsp + nb204_fixH2] movaps xmm1, [rsp + nb204_fiyH2] movaps xmm2, [rsp + nb204_fizH2] movhlps xmm3, xmm0 movhlps xmm4, xmm1 movhlps xmm5, xmm2 addps xmm0, xmm3 addps xmm1, xmm4 addps xmm2, xmm5 ;# sum is in 1/2 in xmm0-xmm2 movaps xmm3, xmm0 movaps xmm4, xmm1 movaps xmm5, xmm2 shufps xmm3, xmm3, 1 shufps xmm4, xmm4, 1 shufps xmm5, xmm5, 1 addss xmm0, xmm3 addss xmm1, xmm4 addss xmm2, xmm5 ;# xmm0-xmm2 has single force in pos0 ;# increment i force movss xmm3, [rdi + rcx*4 + 24] movss xmm4, [rdi + rcx*4 + 28] movss xmm5, [rdi + rcx*4 + 32] subss xmm3, xmm0 subss xmm4, xmm1 subss xmm5, xmm2 movss [rdi + rcx*4 + 24], xmm3 movss [rdi + rcx*4 + 28], xmm4 movss [rdi + rcx*4 + 32], xmm5 ;# accumulate force in xmm6/xmm7 for fshift addss xmm7, xmm2 movlhps xmm0, xmm1 shufps xmm0, xmm0, 8 ;# 00001000 addps xmm6, xmm0 ;# accumulate M i forces in xmm0, xmm1, xmm2 movaps xmm0, [rsp + nb204_fixM] movaps xmm1, [rsp + nb204_fiyM] movaps xmm2, [rsp + nb204_fizM] movhlps xmm3, xmm0 movhlps xmm4, xmm1 movhlps xmm5, xmm2 addps xmm0, xmm3 addps xmm1, xmm4 addps xmm2, xmm5 ;# sum is in 1/2 in xmm0-xmm2 movaps xmm3, xmm0 movaps xmm4, xmm1 movaps xmm5, xmm2 shufps xmm3, xmm3, 1 shufps xmm4, xmm4, 1 shufps xmm5, xmm5, 1 addss xmm0, xmm3 addss xmm1, xmm4 addss xmm2, xmm5 ;# xmm0-xmm2 has single force in pos0 ;# increment i force movss xmm3, [rdi + rcx*4 + 36] movss xmm4, [rdi + rcx*4 + 40] movss xmm5, [rdi + rcx*4 + 44] subss xmm3, xmm0 subss xmm4, xmm1 subss xmm5, xmm2 movss [rdi + rcx*4 + 36], xmm3 movss [rdi + rcx*4 + 40], xmm4 movss [rdi + rcx*4 + 44], xmm5 ;# accumulate force in xmm6/xmm7 for fshift addss xmm7, xmm2 movlhps xmm0, xmm1 shufps xmm0, xmm0, 8 ;# 00001000 addps xmm6, xmm0 ;# increment fshift force movlps xmm3, [rsi + rdx*4] movss xmm4, [rsi + rdx*4 + 8] subps xmm3, xmm6 subss xmm4, xmm7 movlps [rsi + rdx*4], xmm3 movss [rsi + rdx*4 + 8], xmm4 ;# get n from stack mov esi, [rsp + nb204_n] ;# get group index for i particle mov rdx, [rbp + nb204_gid] ;# base of gid[] mov edx, [rdx + rsi*4] ;# ggid=gid[n] ;# accumulate total potential energy and update it movaps xmm7, [rsp + nb204_vctot] ;# accumulate movhlps xmm6, xmm7 addps xmm7, xmm6 ;# pos 0-1 in xmm7 have the sum now movaps xmm6, xmm7 shufps xmm6, xmm6, 1 addss xmm7, xmm6 ;# add earlier value from mem mov rax, [rbp + nb204_Vc] addss xmm7, [rax + rdx*4] ;# move back to mem movss [rax + rdx*4], xmm7 ;# finish if last mov ecx, [rsp + nb204_nn1] ;# esi already loaded with n inc esi sub ecx, esi jz .nb204_outerend ;# not last, iterate outer loop once more! mov [rsp + nb204_n], esi jmp .nb204_outer.nb204_outerend: ;# check if more outer neighborlists remain mov ecx, [rsp + nb204_nri] ;# esi already loaded with n above sub ecx, esi jz .nb204_end ;# non-zero, do one more workunit jmp .nb204_threadloop.nb204_end: mov eax, [rsp + nb204_nouter] mov ebx, [rsp + nb204_ninner] mov rcx, [rbp + nb204_outeriter] mov rdx, [rbp + nb204_inneriter] mov [rcx], eax mov [rdx], ebx add rsp, 1544 emms pop r15 pop r14 pop r13 pop r12 pop rbx pop rbp ret .globl nb_kernel204nf_x86_64_sse.globl _nb_kernel204nf_x86_64_ssenb_kernel204nf_x86_64_sse: _nb_kernel204nf_x86_64_sse: ;# Room for return address and rbp (16 bytes).equiv nb204nf_fshift, 16.equiv nb204nf_gid, 24.equiv nb204nf_pos, 32.equiv nb204nf_faction, 40.equiv nb204nf_charge, 48.equiv nb204nf_p_facel, 56.equiv nb204nf_argkrf, 64.equiv nb204nf_argcrf, 72.equiv nb204nf_Vc, 80.equiv nb204nf_type, 88.equiv nb204nf_p_ntype, 96.equiv nb204nf_vdwparam, 104.equiv nb204nf_Vvdw, 112.equiv nb204nf_p_tabscale, 120.equiv nb204nf_VFtab, 128.equiv nb204nf_invsqrta, 136.equiv nb204nf_dvda, 144.equiv nb204nf_p_gbtabscale, 152.equiv nb204nf_GBtab, 160.equiv nb204nf_p_nthreads, 168.equiv nb204nf_count, 176.equiv nb204nf_mtx, 184.equiv nb204nf_outeriter, 192.equiv nb204nf_inneriter, 200.equiv nb204nf_work, 208 ;# stack offsets for local variables ;# bottom of stack is cache-aligned for sse use .equiv nb204nf_ixH1, 0.equiv nb204nf_iyH1, 16.equiv nb204nf_izH1, 32.equiv nb204nf_ixH2, 48.equiv nb204nf_iyH2, 64.equiv nb204nf_izH2, 80.equiv nb204nf_ixM, 96.equiv nb204nf_iyM, 112.equiv nb204nf_izM, 128.equiv nb204nf_jxH1, 144.equiv nb204nf_jyH1, 160.equiv nb204nf_jzH1, 176.equiv nb204nf_jxH2, 192.equiv nb204nf_jyH2, 208.equiv nb204nf_jzH2, 224.equiv nb204nf_jxM, 240.equiv nb204nf_jyM, 256.equiv nb204nf_jzM, 272.equiv nb204nf_qqHH, 288.equiv nb204nf_qqMH, 304.equiv nb204nf_qqMM, 320.equiv nb204nf_vctot, 336.equiv nb204nf_half, 352.equiv nb204nf_three, 368.equiv nb204nf_rsqH1H1, 384.equiv nb204nf_rsqH1H2, 400.equiv nb204nf_rsqH1M, 416.equiv nb204nf_rsqH2H1, 432.equiv nb204nf_rsqH2H2, 448.equiv nb204nf_rsqH2M, 464.equiv nb204nf_rsqMH1, 480.equiv nb204nf_rsqMH2, 496.equiv nb204nf_rsqMM, 512.equiv nb204nf_rinvH1H1, 528.equiv nb204nf_rinvH1H2, 544.equiv nb204nf_rinvH1M, 560.equiv nb204nf_rinvH2H1, 576.equiv nb204nf_rinvH2H2, 592.equiv nb204nf_rinvH2M, 608.equiv nb204nf_rinvMH1, 624.equiv nb204nf_rinvMH2, 640.equiv nb204nf_rinvMM, 656.equiv nb204nf_krf, 672.equiv nb204nf_crf, 688.equiv nb204nf_is3, 704.equiv nb204nf_ii3, 708.equiv nb204nf_innerjjnr, 712.equiv nb204nf_nri, 720.equiv nb204nf_iinr, 728.equiv nb204nf_jindex, 736.equiv nb204nf_jjnr, 744.equiv nb204nf_shift, 752.equiv nb204nf_shiftvec, 760.equiv nb204nf_facel, 768.equiv nb204nf_innerk, 776.equiv nb204nf_n, 780.equiv nb204nf_nn1, 784.equiv nb204nf_nouter, 788.equiv nb204nf_ninner, 792 push rbp mov rbp, rsp push rbx emms push r12 push r13 push r14 push r15 sub rsp, 808 ;# local variable stack space (n*16+8) ;# zero 32-bit iteration counters mov eax, 0 mov [rsp + nb204nf_nouter], eax mov [rsp + nb204nf_ninner], eax mov edi, [rdi] mov [rsp + nb204nf_nri], edi mov [rsp + nb204nf_iinr], rsi mov [rsp + nb204nf_jindex], rdx mov [rsp + nb204nf_jjnr], rcx mov [rsp + nb204nf_shift], r8 mov [rsp + nb204nf_shiftvec], r9 mov rsi, [rbp + nb204nf_p_facel] movss xmm0, [rsi] movss [rsp + nb204nf_facel], xmm0 mov rsi, [rbp + nb204nf_argkrf] mov rdi, [rbp + nb204nf_argcrf] movss xmm1, [rsi] movss xmm2, [rdi] shufps xmm1, xmm1, 0 shufps xmm2, xmm2, 0 movaps [rsp + nb204nf_krf], xmm1 movaps [rsp + nb204nf_crf], xmm2 ;# create constant floating-point factors on stack mov eax, 0x3f000000 ;# half in IEEE (hex) mov [rsp + nb204nf_half], eax movss xmm1, [rsp + nb204nf_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 + nb204nf_half], xmm1 movaps [rsp + nb204nf_three], xmm3 ;# assume we have at least one i particle - start directly mov rcx, [rsp + nb204nf_iinr] ;# rcx = pointer into iinr[] mov ebx, [rcx] ;# ebx =ii mov rdx, [rbp + nb204nf_charge] movss xmm3, [rdx + rbx*4 + 4] movss xmm4, xmm3 movss xmm5, [rdx + rbx*4 + 12] mov rsi, [rbp + nb204nf_p_facel] movss xmm0, [rsi] movss xmm6, [rsp + nb204nf_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 + nb204nf_qqHH], xmm3 movaps [rsp + nb204nf_qqMH], xmm4 movaps [rsp + nb204nf_qqMM], xmm5 .nb204nf_threadloop: mov rsi, [rbp + nb204nf_count] ;# pointer to sync counter mov eax, [rsi].nb204nf_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 .nb204nf_spinlock ;# if(nn1>nri) nn1=nri mov ecx, [rsp + nb204nf_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 + nb204nf_n], eax mov [rsp + nb204nf_nn1], ebx sub ebx, eax ;# calc number of outer lists mov esi, eax ;# copy n to esi jg .nb204nf_outerstart jmp .nb204nf_end .nb204nf_outerstart: ;# ebx contains number of outer iterations add ebx, [rsp + nb204nf_nouter] mov [rsp + nb204nf_nouter], ebx
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?