nb_kernel304_x86_64_sse.intel_syntax.s
来自「最著名最快的分子模拟软件」· S 代码 · 共 2,305 行 · 第 1/5 页
S
2,305 行
movaps xmm1, [rsp + nb304_rsqH2M] mulps xmm1, xmm0 ;# xmm0=rinv, xmm1=r mulps xmm1, [rsp + nb304_tsc] movhlps xmm2, xmm1 cvttps2pi mm6, xmm1 cvttps2pi mm7, xmm2 ;# mm6/mm7 contain lu indices cvtpi2ps xmm3, mm6 cvtpi2ps xmm2, mm7 movlhps xmm3, xmm2 subps xmm1, xmm3 ;# xmm1=eps movaps xmm2, xmm1 mulps xmm2, xmm2 ;# xmm2=eps2 pslld mm6, 2 pslld mm7, 2 movd ebx, mm6 movd ecx, mm7 psrlq mm7, 32 movd edx, mm7 ;# table indices in ebx,ecx,edx movlps xmm5, [rsi + rbx*4] movlps xmm7, [rsi + rcx*4] movhps xmm7, [rsi + rdx*4] ;# got half coulomb table movaps xmm4, xmm5 shufps xmm4, xmm7, 136 ;# 10001000 shufps xmm5, xmm7, 221 ;# 11011101 movlps xmm7, [rsi + rbx*4 + 8] movlps xmm3, [rsi + rcx*4 + 8] movhps xmm3, [rsi + rdx*4 + 8] ;# other half of coulomb table movaps xmm6, xmm7 shufps xmm6, xmm3, 136 ;# 10001000 shufps xmm7, xmm3, 221 ;# 11011101 ;# coulomb table ready, in xmm4-xmm7 mulps xmm6, xmm1 ;# xmm6=Geps mulps xmm7, xmm2 ;# xmm7=Heps2 addps xmm5, xmm6 addps xmm5, xmm7 ;# xmm5=Fp mulps xmm7, [rsp + nb304_two] ;# two*Heps2 xorps xmm3, xmm3 ;# fetch charges to xmm3 (temporary) movss xmm3, [rsp + nb304_qqMH] movhps xmm3, [rsp + nb304_qqHH] addps xmm7, xmm6 addps xmm7, xmm5 ;# xmm7=FF mulps xmm5, xmm1 ;# xmm5=eps*Fp addps xmm5, xmm4 ;# xmm5=VV mulps xmm5, xmm3 ;# vcoul=qq*VV mulps xmm3, xmm7 ;# fijC=FF*qq ;# at this point xmm5 contains vcoul and xmm3 fijC addps xmm5, [rsp + nb304_vctot] movaps [rsp + nb304_vctot], xmm5 xorps xmm1, xmm1 mulps xmm3, [rsp + nb304_tsc] mulps xmm3, xmm0 subps xmm1, xmm3 movaps xmm0, xmm1 movaps xmm2, xmm1 mulps xmm0, [rsp + nb304_dxH2M] mulps xmm1, [rsp + nb304_dyH2M] mulps xmm2, [rsp + nb304_dzH2M] movaps xmm3, [rsp + nb304_fjxM] movaps xmm4, [rsp + nb304_fjyM] movaps xmm5, [rsp + nb304_fjzM] addps xmm3, xmm0 addps xmm4, xmm1 addps xmm5, xmm2 mov rsi, [rbp + nb304_faction] movaps [rsp + nb304_fjxM], xmm3 movaps [rsp + nb304_fjyM], xmm4 movaps [rsp + nb304_fjzM], xmm5 addps xmm0, [rsp + nb304_fixH2] addps xmm1, [rsp + nb304_fiyH2] addps xmm2, [rsp + nb304_fizH2] movaps [rsp + nb304_fixH2], xmm0 movaps [rsp + nb304_fiyH2], xmm1 movaps [rsp + nb304_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 + nb304_fjxM] movaps xmm4, [rsp + nb304_fjyM] movaps xmm5, [rsp + nb304_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 + nb304_innerk] jz .nb304_updateouterdata jmp .nb304_single_loop.nb304_updateouterdata: mov ecx, [rsp + nb304_ii3] mov rdi, [rbp + nb304_faction] mov rsi, [rbp + nb304_fshift] mov edx, [rsp + nb304_is3] ;# accumulate H1 i forces in xmm0, xmm1, xmm2 movaps xmm0, [rsp + nb304_fixH1] movaps xmm1, [rsp + nb304_fiyH1] movaps xmm2, [rsp + nb304_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 H2 i forces in xmm0, xmm1, xmm2 movaps xmm0, [rsp + nb304_fixH2] movaps xmm1, [rsp + nb304_fiyH2] movaps xmm2, [rsp + nb304_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 + nb304_fixM] movaps xmm1, [rsp + nb304_fiyM] movaps xmm2, [rsp + nb304_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 + nb304_n] ;# get group index for i particle mov rdx, [rbp + nb304_gid] ;# base of gid[] mov edx, [rdx + rsi*4] ;# ggid=gid[n] ;# accumulate total potential energy and update it movaps xmm7, [rsp + nb304_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 + nb304_Vc] addss xmm7, [rax + rdx*4] ;# move back to mem movss [rax + rdx*4], xmm7 ;# finish if last mov ecx, [rsp + nb304_nn1] ;# esi already loaded with n inc esi sub ecx, esi jz .nb304_outerend ;# not last, iterate outer loop once more! mov [rsp + nb304_n], esi jmp .nb304_outer.nb304_outerend: ;# check if more outer neighborlists remain mov ecx, [rsp + nb304_nri] ;# esi already loaded with n above sub ecx, esi jz .nb304_end ;# non-zero, do one more workunit jmp .nb304_threadloop.nb304_end: mov eax, [rsp + nb304_nouter] mov ebx, [rsp + nb304_ninner] mov rcx, [rbp + nb304_outeriter] mov rdx, [rbp + nb304_inneriter] mov [rcx], eax mov [rdx], ebx add rsp, 1528 emms pop r15 pop r14 pop r13 pop r12 pop rbx pop rbp ret .globl nb_kernel304nf_x86_64_sse.globl _nb_kernel304nf_x86_64_ssenb_kernel304nf_x86_64_sse: _nb_kernel304nf_x86_64_sse: ;# Room for return address and rbp (16 bytes).equiv nb304nf_fshift, 16.equiv nb304nf_gid, 24.equiv nb304nf_pos, 32.equiv nb304nf_faction, 40.equiv nb304nf_charge, 48.equiv nb304nf_p_facel, 56.equiv nb304nf_argkrf, 64.equiv nb304nf_argcrf, 72.equiv nb304nf_Vc, 80.equiv nb304nf_type, 88.equiv nb304nf_p_ntype, 96.equiv nb304nf_vdwparam, 104.equiv nb304nf_Vvdw, 112.equiv nb304nf_p_tabscale, 120.equiv nb304nf_VFtab, 128.equiv nb304nf_invsqrta, 136.equiv nb304nf_dvda, 144.equiv nb304nf_p_gbtabscale, 152.equiv nb304nf_GBtab, 160.equiv nb304nf_p_nthreads, 168.equiv nb304nf_count, 176.equiv nb304nf_mtx, 184.equiv nb304nf_outeriter, 192.equiv nb304nf_inneriter, 200.equiv nb304nf_work, 208 ;# stack offsets for local variables ;# bottom of stack is cache-aligned for sse use .equiv nb304nf_ixH1, 0.equiv nb304nf_iyH1, 16.equiv nb304nf_izH1, 32.equiv nb304nf_ixH2, 48.equiv nb304nf_iyH2, 64.equiv nb304nf_izH2, 80.equiv nb304nf_ixM, 96.equiv nb304nf_iyM, 112.equiv nb304nf_izM, 128.equiv nb304nf_jxH1, 144.equiv nb304nf_jyH1, 160.equiv nb304nf_jzH1, 176.equiv nb304nf_jxH2, 192.equiv nb304nf_jyH2, 208.equiv nb304nf_jzH2, 224.equiv nb304nf_jxM, 240.equiv nb304nf_jyM, 256.equiv nb304nf_jzM, 272.equiv nb304nf_qqHH, 288.equiv nb304nf_qqMH, 304.equiv nb304nf_qqMM, 320.equiv nb304nf_tsc, 336.equiv nb304nf_vctot, 352.equiv nb304nf_half, 368.equiv nb304nf_three, 384.equiv nb304nf_rsqH1H1, 400.equiv nb304nf_rsqH1H2, 416.equiv nb304nf_rsqH1M, 432.equiv nb304nf_rsqH2H1, 448.equiv nb304nf_rsqH2H2, 464.equiv nb304nf_rsqH2M, 480.equiv nb304nf_rsqMH1, 496.equiv nb304nf_rsqMH2, 512.equiv nb304nf_rsqMM, 528.equiv nb304nf_rinvH1H1, 544.equiv nb304nf_rinvH1H2, 560.equiv nb304nf_rinvH1M, 576.equiv nb304nf_rinvH2H1, 592.equiv nb304nf_rinvH2H2, 608.equiv nb304nf_rinvH2M, 624.equiv nb304nf_rinvMH1, 640.equiv nb304nf_rinvMH2, 656.equiv nb304nf_rinvMM, 672.equiv nb304nf_is3, 688.equiv nb304nf_ii3, 692.equiv nb304nf_nri, 696.equiv nb304nf_iinr, 704.equiv nb304nf_jindex, 712.equiv nb304nf_jjnr, 720.equiv nb304nf_shift, 728.equiv nb304nf_shiftvec, 736.equiv nb304nf_facel, 744.equiv nb304nf_innerjjnr, 752.equiv nb304nf_innerk, 760.equiv nb304nf_n, 764.equiv nb304nf_nn1, 768.equiv nb304nf_nouter, 772.equiv nb304nf_ninner, 776 push rbp mov rbp, rsp push rbx emms push r12 push r13 push r14 push r15 sub rsp, 792 ;# local variable stack space (n*16+8) ;# zero 32-bit iteration counters mov eax, 0 mov [rsp + nb304nf_nouter], eax mov [rsp + nb304nf_ninner], eax mov edi, [rdi] mov [rsp + nb304nf_nri], edi mov [rsp + nb304nf_iinr], rsi mov [rsp + nb304nf_jindex], rdx mov [rsp + nb304nf_jjnr], rcx mov [rsp + nb304nf_shift], r8 mov [rsp + nb304nf_shiftvec], r9 mov rsi, [rbp + nb304nf_p_facel] movss xmm0, [rsi] movss [rsp + nb304nf_facel], xmm0 mov rax, [rbp + nb304nf_p_tabscale] movss xmm3, [rax] shufps xmm3, xmm3, 0 movaps [rsp + nb304nf_tsc], xmm3 ;# create constant floating-point factors on stack mov eax, 0x3f000000 ;# half in IEEE (hex) mov [rsp + nb304nf_half], eax movss xmm1, [rsp + nb304nf_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 + nb304nf_half], xmm1 movaps [rsp + nb304nf_three], xmm3 ;# assume we have at least one i particle - start directly mov rcx, [rsp + nb304nf_iinr] ;# rcx = pointer into iinr[] mov ebx, [rcx] ;# ebx =ii mov rdx, [rbp + nb304nf_charge] movss xmm3, [rdx + rbx*4 + 4] movss xmm4, xmm3 movss xmm5, [rdx + rbx*4 + 12] mov rsi, [rbp + nb304nf_p_facel] movss xmm0, [rsi]
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?