nb_kernel203_x86_64_sse.intel_syntax.s
来自「最著名最快的分子模拟软件」· S 代码 · 共 1,555 行 · 第 1/3 页
S
1,555 行
movhps xmm10, [rdi + rdx*4] ;# jxc jyc jxd jyd movss xmm11, [rdi + rax*4 + 8] ;# jza - - - movss xmm12, [rdi + rcx*4 + 8] ;# jzc - - - movss xmm6, [rdi + rbx*4 + 8] ;# jzb movss xmm8, [rdi + rdx*4 + 8] ;# jzd movlhps xmm11, xmm6 ;# jza - jzb - movlhps xmm12, xmm8 ;# jzc - jzd - shufps xmm11, xmm12, 136 ;# 10001000 => jza jzb jzc jzd ;# xmm9: jxa jya jxb jyb ;# xmm10: jxc jyc jxd jyd ;# xmm11: jza jzb jzc jzd movaps xmm0, xmm1 movaps xmm2, xmm1 movaps xmm3, xmm4 movaps xmm5, xmm4 movaps xmm6, xmm7 movaps xmm8, xmm7 mulps xmm0, [rsp + nb203_dxH1] mulps xmm1, [rsp + nb203_dyH1] mulps xmm2, [rsp + nb203_dzH1] mulps xmm3, [rsp + nb203_dxH2] mulps xmm4, [rsp + nb203_dyH2] mulps xmm5, [rsp + nb203_dzH2] mulps xmm6, [rsp + nb203_dxM] mulps xmm7, [rsp + nb203_dyM] mulps xmm8, [rsp + nb203_dzM] movaps xmm13, xmm0 movaps xmm14, xmm1 addps xmm11, xmm2 addps xmm0, [rsp + nb203_fixH1] addps xmm1, [rsp + nb203_fiyH1] addps xmm2, [rsp + nb203_fizH1] addps xmm13, xmm3 addps xmm14, xmm4 addps xmm11, xmm5 addps xmm3, [rsp + nb203_fixH2] addps xmm4, [rsp + nb203_fiyH2] addps xmm5, [rsp + nb203_fizH2] addps xmm13, xmm6 addps xmm14, xmm7 addps xmm11, xmm8 addps xmm6, [rsp + nb203_fixM] addps xmm7, [rsp + nb203_fiyM] addps xmm8, [rsp + nb203_fizM] movaps [rsp + nb203_fixH1], xmm0 movaps [rsp + nb203_fiyH1], xmm1 movaps [rsp + nb203_fizH1], xmm2 movaps [rsp + nb203_fixH2], xmm3 movaps [rsp + nb203_fiyH2], xmm4 movaps [rsp + nb203_fizH2], xmm5 movaps [rsp + nb203_fixM], xmm6 movaps [rsp + nb203_fiyM], xmm7 movaps [rsp + nb203_fizM], xmm8 ;# xmm9 = fjx ;# xmm10 = fjy ;# xmm11 = fjz movaps xmm15, xmm13 unpcklps xmm13, xmm14 unpckhps xmm15, xmm14 addps xmm9, xmm13 addps xmm10, xmm15 movhlps xmm12, xmm11 ;# fjzc fjzd movlps [rdi + rax*4], xmm9 movhps [rdi + rbx*4], xmm9 movlps [rdi + rcx*4], xmm10 movhps [rdi + rdx*4], xmm10 movss [rdi + rax*4 + 8], xmm11 movss [rdi + rcx*4 + 8], xmm12 shufps xmm11, xmm11, 1 shufps xmm12, xmm12, 1 movss [rdi + rbx*4 + 8], xmm11 movss [rdi + rdx*4 + 8], xmm12 ;# should we do one more iteration? sub dword ptr [rsp + nb203_innerk], 4 jl .nb203_odd_inner jmp .nb203_unroll_loop.nb203_odd_inner: add dword ptr [rsp + nb203_innerk], 4 jnz .nb203_odd_loop jmp .nb203_updateouterdata.nb203_odd_loop: mov rdx, [rsp + nb203_innerjjnr] ;# pointer to jjnr[k] mov eax, [rdx] add qword ptr [rsp + nb203_innerjjnr], 4 xorps xmm4, xmm4 movss xmm4, [rsp + nb203_iqM] mov rsi, [rbp + nb203_charge] movhps xmm4, [rsp + nb203_iqH] movss xmm3, [rsi + rax*4] ;# charge in xmm3 shufps xmm3, xmm3, 0 mulps xmm3, xmm4 movaps [rsp + nb203_qqM], xmm3 ;# use dummy qq for storage mov rsi, [rbp + nb203_pos] lea rax, [rax + rax*2] ;# move j coords to xmm0-xmm2 movss xmm3, [rsi + rax*4] movss xmm4, [rsi + rax*4 + 4] movss xmm5, [rsi + rax*4 + 8] shufps xmm3, xmm3, 0 shufps xmm4, xmm4, 0 shufps xmm5, xmm5, 0 movss xmm0, [rsp + nb203_ixM] movss xmm1, [rsp + nb203_iyM] movss xmm2, [rsp + nb203_izM] movlps xmm6, [rsp + nb203_ixH1] movlps xmm7, [rsp + nb203_ixH2] unpcklps xmm6, xmm7 movlhps xmm0, xmm6 movlps xmm6, [rsp + nb203_iyH1] movlps xmm7, [rsp + nb203_iyH2] unpcklps xmm6, xmm7 movlhps xmm1, xmm6 movlps xmm6, [rsp + nb203_izH1] movlps xmm7, [rsp + nb203_izH2] unpcklps xmm6, xmm7 movlhps xmm2, xmm6 subps xmm3, xmm0 subps xmm4, xmm1 subps xmm5, xmm2 ;# use dummy dx for storage movaps [rsp + nb203_dxM], xmm3 movaps [rsp + nb203_dyM], xmm4 movaps [rsp + nb203_dzM], xmm5 mulps xmm3, xmm3 mulps xmm4, xmm4 mulps xmm5, xmm5 addps xmm4, xmm3 addps xmm4, xmm5 ;# rsq in xmm4 movaps xmm0, xmm4 mulps xmm0, [rsp + nb203_krf] movaps [rsp + nb203_krsqM], xmm0 rsqrtps xmm5, xmm4 ;# lookup seed in xmm5 movaps xmm2, xmm5 mulps xmm5, xmm5 movaps xmm1, [rsp + nb203_three] mulps xmm5, xmm4 ;# rsq*lu*lu movaps xmm0, [rsp + nb203_half] subps xmm1, xmm5 ;# 30-rsq*lu*lu mulps xmm1, xmm2 mulps xmm0, xmm1 ;# 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 xmm0, xmm0, 224 ;# 11100000 movaps xmm4, xmm0 mulps xmm4, xmm4 ;# xmm4=rinvsq movaps xmm1, xmm0 ;# xmm1=rinv movaps xmm3, [rsp + nb203_krsqM] addps xmm0, xmm3 ;# xmm0=rinv+ krsq subps xmm0, [rsp + nb203_crf] ;# xmm0=rinv+ krsq-crf mulps xmm3, [rsp + nb203_two] subps xmm1, xmm3 ;# xmm1=rinv-2*krsq mulps xmm0, [rsp + nb203_qqM] ;# xmm0=vcoul mulps xmm1, [rsp + nb203_qqM] ;# xmm1=coul part of fs mulps xmm4, xmm1 ;# xmm4=total fscal addps xmm0, [rsp + nb203_vctot] movaps [rsp + nb203_vctot], xmm0 movaps xmm0, [rsp + nb203_dxM] movaps xmm1, [rsp + nb203_dyM] movaps xmm2, [rsp + nb203_dzM] mulps xmm0, xmm4 mulps xmm1, xmm4 mulps xmm2, xmm4 ;# xmm0-xmm2 contains tx-tz (partial force) movss xmm3, [rsp + nb203_fixM] movss xmm4, [rsp + nb203_fiyM] movss xmm5, [rsp + nb203_fizM] addss xmm3, xmm0 addss xmm4, xmm1 addss xmm5, xmm2 movss [rsp + nb203_fixM], xmm3 movss [rsp + nb203_fiyM], xmm4 movss [rsp + nb203_fizM], xmm5 ;# updated the O force now do the H's movaps xmm3, xmm0 movaps xmm4, xmm1 movaps xmm5, xmm2 shufps xmm3, xmm3, 230 ;# 11100110 ;# shift right shufps xmm4, xmm4, 230 ;# 11100110 shufps xmm5, xmm5, 230 ;# 11100110 addss xmm3, [rsp + nb203_fixH1] addss xmm4, [rsp + nb203_fiyH1] addss xmm5, [rsp + nb203_fizH1] movss [rsp + nb203_fixH1], xmm3 movss [rsp + nb203_fiyH1], xmm4 movss [rsp + nb203_fizH1], xmm5 ;# updated the H1 force mov rdi, [rbp + nb203_faction] shufps xmm3, xmm3, 231 ;# 11100111 ;# shift right shufps xmm4, xmm4, 231 ;# 11100111 shufps xmm5, xmm5, 231 ;# 11100111 addss xmm3, [rsp + nb203_fixH2] addss xmm4, [rsp + nb203_fiyH2] addss xmm5, [rsp + nb203_fizH2] movss [rsp + nb203_fixH2], xmm3 movss [rsp + nb203_fiyH2], xmm4 movss [rsp + nb203_fizH2], xmm5 ;# updated the H2 force ;# the fj's - start by accumulating the tx/ty/tz force in xmm0, xmm1 xorps xmm5, xmm5 movaps xmm3, xmm0 movlps xmm6, [rdi + rax*4] movss xmm7, [rdi + rax*4 + 8] unpcklps xmm3, xmm1 movlhps xmm3, xmm5 unpckhps xmm0, xmm1 addps xmm0, xmm3 movhlps xmm3, xmm0 addps xmm0, xmm3 ;# x,y sum in xmm0 movhlps xmm1, xmm2 addss xmm2, xmm1 shufps xmm1, xmm1, 1 addss xmm2, xmm1 ;# z sum in xmm2 addps xmm6, xmm0 addss xmm7, xmm2 movlps [rdi + rax*4], xmm6 movss [rdi + rax*4 + 8], xmm7 dec dword ptr [rsp + nb203_innerk] jz .nb203_updateouterdata jmp .nb203_odd_loop.nb203_updateouterdata: mov ecx, [rsp + nb203_ii3] mov rdi, [rbp + nb203_faction] mov rsi, [rbp + nb203_fshift] mov edx, [rsp + nb203_is3] ;# accumulate H1 i forces in xmm0, xmm1, xmm2 movaps xmm0, [rsp + nb203_fixH1] movaps xmm1, [rsp + nb203_fiyH1] movaps xmm2, [rsp + nb203_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 + nb203_fixH2] movaps xmm1, [rsp + nb203_fiyH2] movaps xmm2, [rsp + nb203_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 + nb203_fixM] movaps xmm1, [rsp + nb203_fiyM] movaps xmm2, [rsp + nb203_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 + nb203_n] ;# get group index for i particle mov rdx, [rbp + nb203_gid] ;# base of gid[] mov edx, [rdx + rsi*4] ;# ggid=gid[n] ;# accumulate total potential energy and update it movaps xmm7, [rsp + nb203_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 + nb203_Vc] addss xmm7, [rax + rdx*4] ;# move back to mem movss [rax + rdx*4], xmm7 ;# finish if last mov ecx, [rsp + nb203_nn1] ;# esi already loaded with n inc esi sub ecx, esi jz .nb203_outerend ;# not last, iterate outer loop once more! mov [rsp + nb203_n], esi jmp .nb203_outer.nb203_outerend: ;# check if more outer neighborlists remain mov ecx, [rsp + nb203_nri] ;# esi already loaded with n above sub ecx, esi jz .nb203_end ;# non-zero, do one more workunit jmp .nb203_threadloop.nb203_end: mov eax, [rsp + nb203_nouter] mov ebx, [rsp + nb203_ninner] mov rcx, [rbp + nb203_outeriter] mov rdx, [rbp + nb203_inneriter] mov [rcx], eax mov [rdx], ebx add rsp, 808 emms pop r15 pop r14 pop r13 pop r12 pop rbx pop rbp ret .globl nb_kernel203nf_x86_64_sse.globl _nb_kernel203nf_x86_64_ssenb_kernel203nf_x86_64_sse: _nb_kernel203nf_x86_64_sse: ;# Room for return address and rbp (16 bytes).equiv nb203nf_fshift, 16.equiv nb203nf_gid, 24.equiv nb203nf_pos, 32.equiv nb203nf_faction, 40.equiv nb203nf_charge, 48.equiv nb203nf_p_facel, 56.equiv nb203nf_argkrf, 64.equiv nb203nf_argcrf, 72.equiv nb203nf_Vc, 80.equiv nb203nf_type, 88.equiv nb203nf_p_ntype, 96.equiv nb203nf_vdwparam, 104.equiv nb203nf_Vvdw, 112.equiv nb203nf_p_tabscale, 120.equiv nb203nf_VFtab, 128.equiv nb203nf_invsqrta, 136.equiv nb203nf_dvda, 144.equiv nb203nf_p_gbtabscale, 152.equiv nb203nf_GBtab, 160.equiv nb203nf_p_nthreads, 168.equiv nb203nf_count, 176.equiv nb203nf_mtx, 184.equiv nb203nf_outeriter, 192.equiv nb203nf_inneriter, 200.equiv nb203nf_work, 208 ;# stack offsets for local variables ;# bottom of stack is cache-aligned for sse use .equiv nb203nf_ixH1, 0.equiv nb203nf_iyH1, 16.equiv nb203nf_izH1, 32.equiv nb203nf_ixH2, 48.equiv nb203nf_iyH2, 64.equiv nb203nf_izH2, 80.equiv nb203nf_ixM, 96.equiv nb203nf_iyM, 112.equiv nb203nf_izM, 128.equiv nb203nf_iqH, 144.equiv nb203nf_iqM, 160.equiv nb203nf_qqH, 176.equiv nb203nf_qqM, 192.equiv nb203nf_vctot, 208.equiv nb203nf_half, 224.equiv nb203nf_three, 240.equiv nb203nf_krf, 256.equiv nb203nf_crf, 272.equiv nb203nf_krsqH1, 288.equiv nb203nf_krsqH2, 304.equiv nb203nf_krsqM, 320.equiv nb203nf_is3, 336.equiv nb203nf_ii3, 340.equiv nb203nf_innerjjnr, 344.equiv nb203nf_nri, 352.equiv nb203nf_iinr, 360.equiv nb203nf_jindex, 368.equiv nb203nf_jjnr, 376.equiv nb203nf_shift, 384
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?