nb_kernel104_x86_64_sse.intel_syntax.s
来自「最著名最快的分子模拟软件」· S 代码 · 共 2,223 行 · 第 1/5 页
S
2,223 行
movlhps xmm0, xmm1 shufps xmm0, xmm0, 8 ;# 00001000 addps xmm6, xmm0 ;# accumulate M i forces in xmm0, xmm1, xmm2 movaps xmm0, [rsp + nb104_fixM] movaps xmm1, [rsp + nb104_fiyM] movaps xmm2, [rsp + nb104_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 + nb104_n] ;# get group index for i particle mov rdx, [rbp + nb104_gid] ;# base of gid[] mov edx, [rdx + rsi*4] ;# ggid=gid[n] ;# accumulate total potential energy and update it movaps xmm7, [rsp + nb104_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 + nb104_Vc] addss xmm7, [rax + rdx*4] ;# move back to mem movss [rax + rdx*4], xmm7 ;# finish if last mov ecx, [rsp + nb104_nn1] ;# esi already loaded with n inc esi sub ecx, esi jz .nb104_outerend ;# not last, iterate outer loop once more! mov [rsp + nb104_n], esi jmp .nb104_outer.nb104_outerend: ;# check if more outer neighborlists remain mov ecx, [rsp + nb104_nri] ;# esi already loaded with n above sub ecx, esi jz .nb104_end ;# non-zero, do one more workunit jmp .nb104_threadloop.nb104_end: mov eax, [rsp + nb104_nouter] mov ebx, [rsp + nb104_ninner] mov rcx, [rbp + nb104_outeriter] mov rdx, [rbp + nb104_inneriter] mov [rcx], eax mov [rdx], ebx add rsp, 1512 emms pop r15 pop r14 pop r13 pop r12 pop rbx pop rbp ret .globl nb_kernel104nf_x86_64_sse.globl _nb_kernel104nf_x86_64_ssenb_kernel104nf_x86_64_sse: _nb_kernel104nf_x86_64_sse: .equiv nb104nf_fshift, 16.equiv nb104nf_gid, 24.equiv nb104nf_pos, 32.equiv nb104nf_faction, 40.equiv nb104nf_charge, 48.equiv nb104nf_p_facel, 56.equiv nb104nf_argkrf, 64.equiv nb104nf_argcrf, 72.equiv nb104nf_Vc, 80.equiv nb104nf_type, 88.equiv nb104nf_p_ntype, 96.equiv nb104nf_vdwparam, 104.equiv nb104nf_Vvdw, 112.equiv nb104nf_p_tabscale, 120.equiv nb104nf_VFtab, 128.equiv nb104nf_invsqrta, 136.equiv nb104nf_dvda, 144.equiv nb104nf_p_gbtabscale, 152.equiv nb104nf_GBtab, 160.equiv nb104nf_p_nthreads, 168.equiv nb104nf_count, 176.equiv nb104nf_mtx, 184.equiv nb104nf_outeriter, 192.equiv nb104nf_inneriter, 200.equiv nb104nf_work, 208 ;# stack offsets for local variables ;# bottom of stack is cache-aligned for sse use .equiv nb104nf_ixH1, 0.equiv nb104nf_iyH1, 16.equiv nb104nf_izH1, 32.equiv nb104nf_ixH2, 48.equiv nb104nf_iyH2, 64.equiv nb104nf_izH2, 80.equiv nb104nf_ixM, 96.equiv nb104nf_iyM, 112.equiv nb104nf_izM, 128.equiv nb104nf_jxH1, 144.equiv nb104nf_jyH1, 160.equiv nb104nf_jzH1, 176.equiv nb104nf_jxH2, 192.equiv nb104nf_jyH2, 208.equiv nb104nf_jzH2, 224.equiv nb104nf_jxM, 240.equiv nb104nf_jyM, 256.equiv nb104nf_jzM, 272.equiv nb104nf_dxMM, 288.equiv nb104nf_dyMM, 304.equiv nb104nf_dzMM, 320.equiv nb104nf_qqHH, 336.equiv nb104nf_qqMH, 352.equiv nb104nf_qqMM, 368.equiv nb104nf_vctot, 384.equiv nb104nf_half, 400.equiv nb104nf_three, 416.equiv nb104nf_rsqH1H1, 432.equiv nb104nf_rsqH1H2, 448.equiv nb104nf_rsqH1M, 464.equiv nb104nf_rsqH2H1, 480.equiv nb104nf_rsqH2H2, 496.equiv nb104nf_rsqH2M, 512.equiv nb104nf_rsqMH1, 528.equiv nb104nf_rsqMH2, 544.equiv nb104nf_rsqMM, 560.equiv nb104nf_rinvH1H1, 576.equiv nb104nf_rinvH1H2, 592.equiv nb104nf_rinvH1M, 608.equiv nb104nf_rinvH2H1, 624.equiv nb104nf_rinvH2H2, 640.equiv nb104nf_rinvH2M, 656.equiv nb104nf_rinvMH1, 672.equiv nb104nf_rinvMH2, 688.equiv nb104nf_rinvMM, 704.equiv nb104nf_is3, 720.equiv nb104nf_ii3, 724.equiv nb104nf_nri, 728.equiv nb104nf_iinr, 736.equiv nb104nf_jindex, 744.equiv nb104nf_jjnr, 752.equiv nb104nf_shift, 760.equiv nb104nf_shiftvec, 768.equiv nb104nf_facel, 776.equiv nb104nf_innerjjnr, 784.equiv nb104nf_innerk, 792.equiv nb104nf_n, 800.equiv nb104nf_nn1, 804.equiv nb104nf_nouter, 808.equiv nb104nf_ninner, 812 push rbp mov rbp, rsp push rbx emms sub rsp, 824 ;# zero 32-bit iteration counters mov eax, 0 mov [rsp + nb104nf_nouter], eax mov [rsp + nb104nf_ninner], eax mov edi, [rdi] mov [rsp + nb104nf_nri], edi mov [rsp + nb104nf_iinr], rsi mov [rsp + nb104nf_jindex], rdx mov [rsp + nb104nf_jjnr], rcx mov [rsp + nb104nf_shift], r8 mov [rsp + nb104nf_shiftvec], r9 mov rsi, [rbp + nb104nf_p_facel] movss xmm0, [rsi] movss [rsp + nb104nf_facel], xmm0 ;# create constant floating-point factors on stack mov eax, 0x3f000000 ;# half in IEEE (hex) mov [rsp + nb104nf_half], eax movss xmm1, [rsp + nb104nf_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 + nb104nf_half], xmm1 movaps [rsp + nb104nf_three], xmm3 ;# assume we have at least one i particle - start directly mov rcx, [rsp + nb104nf_iinr] ;# rcx = pointer into iinr[] mov ebx, [rcx] ;# ebx =ii mov rdx, [rbp + nb104nf_charge] movss xmm3, [rdx + rbx*4 + 4] movss xmm4, xmm3 movss xmm5, [rdx + rbx*4 + 12] mov rsi, [rbp + nb104nf_p_facel] movss xmm0, [rsi] movss xmm6, [rsp + nb104nf_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 + nb104nf_qqHH], xmm3 movaps [rsp + nb104nf_qqMH], xmm4 movaps [rsp + nb104nf_qqMM], xmm5.nb104nf_threadloop: mov rsi, [rbp + nb104nf_count] ;# pointer to sync counter mov eax, [rsi].nb104nf_spinlock: mov ebx, eax ;# ebx=*count=nn0 add ebx, 1 ;# ebx=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 .nb104nf_spinlock ;# if(nn1>nri) nn1=nri mov ecx, [rsp + nb104nf_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 + nb104nf_n], eax mov [rsp + nb104nf_nn1], ebx sub ebx, eax ;# calc number of outer lists mov esi, eax ;# copy n to esi jg .nb104nf_outerstart jmp .nb104nf_end .nb104nf_outerstart: ;# ebx contains number of outer iterations add ebx, [rsp + nb104nf_nouter] mov [rsp + nb104nf_nouter], ebx.nb104nf_outer: mov rax, [rsp + nb104nf_shift] ;# rax = pointer into shift[] mov ebx, [rax + rsi*4] ;# rbx=shift[n] lea rbx, [rbx + rbx*2] ;# rbx=3*is mov [rsp + nb104nf_is3],ebx ;# store is3 mov rax, [rsp + nb104nf_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 + nb104nf_iinr] ;# rcx = pointer into iinr[] mov ebx, [rcx + rsi*4] ;# ebx =ii lea rbx, [rbx + rbx*2] ;# rbx = 3*ii=ii3 mov rax, [rbp + nb104nf_pos] ;# rax = base of pos[] mov [rsp + nb104nf_ii3], ebx movaps xmm3, xmm0 movaps xmm4, xmm1 movaps xmm5, xmm2 addss xmm3, [rax + rbx*4 + 12] addss xmm4, [rax + rbx*4 + 16] addss xmm5, [rax + rbx*4 + 20] shufps xmm3, xmm3, 0 shufps xmm4, xmm4, 0 shufps xmm5, xmm5, 0 movaps [rsp + nb104nf_ixH1], xmm3 movaps [rsp + nb104nf_iyH1], xmm4 movaps [rsp + nb104nf_izH1], xmm5 movss xmm3, xmm0 movss xmm4, xmm1 movss xmm5, xmm2 addss xmm0, [rax + rbx*4 + 24] addss xmm1, [rax + rbx*4 + 28] addss xmm2, [rax + rbx*4 + 32] addss xmm3, [rax + rbx*4 + 36] addss xmm4, [rax + rbx*4 + 40] addss xmm5, [rax + rbx*4 + 44] 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 + nb104nf_ixH2], xmm0 movaps [rsp + nb104nf_iyH2], xmm1 movaps [rsp + nb104nf_izH2], xmm2 movaps [rsp + nb104nf_ixM], xmm3 movaps [rsp + nb104nf_iyM], xmm4 movaps [rsp + nb104nf_izM], xmm5 ;# clear vctot xorps xmm4, xmm4 movaps [rsp + nb104nf_vctot], xmm4 mov rax, [rsp + nb104nf_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 + nb104nf_pos] mov rdi, [rbp + nb104nf_faction] mov rax, [rsp + nb104nf_jjnr] shl ecx, 2 add rax, rcx mov [rsp + nb104nf_innerjjnr], rax ;# pointer to jjnr[nj0] mov ecx, edx sub edx, 4 add ecx, [rsp + nb104nf_ninner] mov [rsp + nb104nf_ninner], ecx add edx, 0 mov [rsp + nb104nf_innerk], edx ;# number of innerloop atoms jge .nb104nf_unroll_loop jmp .nb104nf_single_check.nb104nf_unroll_loop: ;# quad-unroll innerloop here mov rdx, [rsp + nb104nf_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 + nb104nf_innerjjnr], 16 ;# advance pointer (unrolled 4) mov rsi, [rbp + nb104nf_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 movlps xmm2, [rsi + rax*4 + 12] movlps xmm3, [rsi + rax*4 + 24] movlps xmm4, [rsi + rax*4 + 36] movlps xmm5, [rsi + rbx*4 + 12] movlps xmm6, [rsi + rbx*4 + 24] movlps xmm7, [rsi + rbx*4 + 36] movhps xmm2, [rsi + rcx*4 + 12] movhps xmm3, [rsi + rcx*4 + 24] movhps xmm4, [rsi + rcx*4 + 36] movhps xmm5, [rsi + rdx*4 + 12] movhps xmm6, [rsi + rdx*4 + 24] movhps xmm7, [rsi + rdx*4 + 36] ;# current state: ;# xmm2= jxh1a jyH1a jxH1c jyH1c ;# xmm3= jxH2a jyH2a jxH2c jyH2c ;# xmm4= jxMa jyMa jxMc jyMc ;# xmm5= jxH1b jyH1b jxH1d jyH1d ;# xmm6= jxH2b jyH2b jxH2d jyH2d ;# xmm7= jxMb jyMb jxMd jyMd movaps xmm0, xmm2 movaps xmm1, xmm3 unpcklps xmm0, xmm5 ;# xmm0= jxH1a jxH1b jyH1a jyH1b unpcklps xmm1, xmm6 ;# xmm1= jxH2a jxH2b jyH2a jyH2b unpckhps xmm2, xmm5 ;# xmm2= jxH1c jxH1d jyH1c jyH1d unpckhps xmm3, xmm6 ;# xmm3= jxH2c jxH2d jyH2c jyH2d movaps xmm5, xmm4 movaps xmm6, xmm0 unpcklps xmm4, xmm7 ;# xmm4= jxMa jxMb jyMa jyMb unpckhps xmm5, xmm7 ;# xmm5= jxMc jxMd jyMc jyMd movaps xmm7, xmm1 movlhps xmm0, xmm2 ;# xmm0= jxH1a jxH1b jxH1c jxH1d movaps [rsp + nb104nf_jxH1], xmm0 movhlps xmm2, xmm6 ;# xmm2= jyH1a jyH1b jyH1c jyH1d movaps [rsp + nb104nf_jyH1], xmm2 movlhps xmm1, xmm3 movaps [rsp + nb104nf_jxH2], xmm1 movhlps xmm3, xmm7 movaps xmm6, xmm4
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?