nb_kernel410_x86_64_sse2.intel_syntax.s
来自「最著名最快的分子模拟软件」· S 代码 · 共 1,490 行 · 第 1/3 页
S
1,490 行
movsd [rsi + r15*8], xmm7 movhpd xmm2, [rdi + r11*8] movhpd xmm4, [rdi + r11*8 + 8] movhpd xmm5, [rdi + r11*8 + 16] subpd xmm9, xmm3 mulpd xmm9, xmm0 ;# fscal movapd xmm10, xmm9 movapd xmm11, xmm9 mulpd xmm9, [rsp + nb410_dx] mulpd xmm10, [rsp + nb410_dy] mulpd xmm11, [rsp + nb410_dz] addpd xmm2, xmm9 addpd xmm4, xmm10 addpd xmm5, xmm11 movlpd [rdi + r10*8], xmm2 movlpd [rdi + r10*8 + 8], xmm4 movlpd [rdi + r10*8 + 16], xmm5 ;# accumulate i forces addpd xmm13, xmm9 addpd xmm14, xmm10 addpd xmm15, xmm11 movhpd [rdi + r11*8], xmm2 movhpd [rdi + r11*8 + 8], xmm4 movhpd [rdi + r11*8 + 16], xmm5 ;# should we do one more iteration? sub dword ptr [rsp + nb410_innerk], 2 jl .nb410_checksingle jmp .nb410_unroll_loop.nb410_checksingle: mov edx, [rsp + nb410_innerk] and edx, 1 jnz .nb410_dosingle jmp .nb410_updateouterdata.nb410_dosingle: mov rsi, [rbp + nb410_charge] mov rdx, [rbp + nb410_invsqrta] mov rdi, [rbp + nb410_pos] mov rcx, [rsp + nb410_innerjjnr] mov eax, [rcx] ;# load isaj mov rsi, [rbp + nb410_invsqrta] movsd xmm2, [rsi + rax*8] mulsd xmm2, [rsp + nb410_isai] movapd [rsp + nb410_isaprod], xmm2 movapd xmm1, xmm2 mulsd xmm1, [rsp + nb410_gbtsc] movapd [rsp + nb410_gbscale], xmm1 mulsd xmm2, [rsp + nb410_iq] mov rsi, [rbp + nb410_charge] ;# base of charge[] movsd xmm3, [rsi + rax*8] mulsd xmm3, xmm2 movapd [rsp + nb410_qq], xmm3 mov rsi, [rbp + nb410_type] mov r8d, [rsi + rax*4] mov rsi, [rbp + nb410_vdwparam] shl r8d, 1 mov edi, [rsp + nb410_ntia] add r8d, edi movsd xmm4, [rsi + r8*8] movsd xmm6, [rsi + r8*8 + 8] movapd [rsp + nb410_c6], xmm4 movapd [rsp + nb410_c12], xmm6 mov rsi, [rbp + nb410_pos] ;# base of pos[] lea r10, [rax + rax*2] ;# replace jnr with j3 ;# move two coordinates to xmm4-xmm6 movsd xmm4, [rsi + r10*8] movsd xmm5, [rsi + r10*8 + 8] movsd xmm6, [rsi + r10*8 + 16] ;# calc dr subsd xmm4, [rsp + nb410_ix] subsd xmm5, [rsp + nb410_iy] subsd xmm6, [rsp + nb410_iz] ;# store dr movapd [rsp + nb410_dx], xmm4 movapd [rsp + nb410_dy], xmm5 movapd [rsp + nb410_dz], xmm6 ;# square it mulsd xmm4,xmm4 mulsd xmm5,xmm5 mulsd xmm6,xmm6 addsd xmm4, xmm5 addsd xmm4, xmm6 ;# rsq in xmm4 cvtsd2ss xmm5, xmm4 rsqrtss xmm5, xmm5 cvtss2sd xmm2, xmm5 ;# lu in low xmm2 ;# lookup seed in xmm2 movapd xmm5, xmm2 ;# copy of lu mulsd xmm2, xmm2 ;# lu*lu movapd xmm1, [rsp + nb410_three] mulsd xmm2, xmm4 ;# rsq*lu*lu movapd xmm0, [rsp + nb410_half] subsd xmm1, xmm2 ;# 30-rsq*lu*lu mulsd xmm1, xmm5 mulsd xmm1, xmm0 ;# xmm0=iter1 of rinv (new lu) movapd xmm5, xmm1 ;# copy of lu mulsd xmm1, xmm1 ;# lu*lu movapd xmm2, [rsp + nb410_three] mulsd xmm1, xmm4 ;# rsq*lu*lu movapd xmm0, [rsp + nb410_half] subsd xmm2, xmm1 ;# 30-rsq*lu*lu mulsd xmm2, xmm5 mulsd xmm0, xmm2 ;# xmm0=rinv mulsd xmm4, xmm0 ;# xmm4=r movapd [rsp + nb410_r], xmm4 mulsd xmm4, [rsp + nb410_gbscale] cvttsd2si r12d, xmm4 ;# mm6 = lu idx cvtsi2sd xmm5, r12d subsd xmm4, xmm5 movapd xmm1, xmm4 ;# xmm1=eps movapd xmm2, xmm1 mulsd xmm2, xmm2 ;# xmm2=eps2 shl r12d, 2 ;# idx *= 4 mov rsi, [rbp + nb410_GBtab] movapd xmm9, xmm0 ;# rinv mulsd xmm9, xmm9 ;# rinvsq movapd xmm10, xmm9 ;# rinvsq mulsd xmm10, xmm10 ;# rinv4 mulsd xmm10, xmm9 ;# rinv6 movapd xmm11, xmm10 mulsd xmm11, xmm11 ;# rinv12 ;# load table data movapd xmm4, [rsi + r12*8] ;# Y1 F1 movhlps xmm5, xmm4 mulsd xmm10, [rsp + nb410_c6] ;# vvdw6=c6*rinv6 mulsd xmm11, [rsp + nb410_c12] ;# vvdw12=c12*rinv12 movapd xmm9, xmm11 subsd xmm11, xmm10 ;# Vvdw=Vvdw12-Vvdw6 ;# add potential to vvdwtot addsd xmm11, [rsp + nb410_Vvdwtot] movsd [rsp + nb410_Vvdwtot], xmm11 movapd xmm6, [rsi + r12*8 + 16] ;# G1 H1 movhlps xmm7, xmm6 ;# coulomb table ready, in xmm4-xmm7 mulsd xmm7, xmm1 ;# xmm7=Heps mulsd xmm6, xmm1 ;# xmm6=Geps mulsd xmm7, xmm1 ;# xmm7=Heps2 addsd xmm5, xmm6 addsd xmm5, xmm7 ;# xmm5=Fp mulsd xmm7, [rsp + nb410_two] ;# two*Heps2 movapd xmm3, [rsp + nb410_qq] addsd xmm7, xmm6 addsd xmm7, xmm5 ;# xmm7=FF mulsd xmm5, xmm1 ;# xmm5=eps*Fp addsd xmm5, xmm4 ;# xmm5=VV mulsd xmm5, xmm3 ;# vcoul=qq*VV mulsd xmm3, xmm7 ;# fijC=FF*qq ;# LJ forces mulsd xmm10, [rsp + nb410_six] mulsd xmm9, [rsp + nb410_twelve] subsd xmm9, xmm10 mulsd xmm9, xmm0 ;# (12*vnb12-6*vnb6)*rinv mov rsi, [rbp + nb410_dvda] ;# Calculate dVda xorpd xmm7, xmm7 mulsd xmm3, [rsp + nb410_gbscale] movapd xmm6, xmm3 mulsd xmm6, [rsp + nb410_r] addsd xmm6, xmm5 ;# update vctot addsd xmm12, xmm5 ;# xmm6=(vcoul+fijC*r) subsd xmm7, xmm6 movapd xmm6, xmm7 ;# update dvdasum addsd xmm7, [rsp + nb410_dvdasum] movsd [rsp + nb410_dvdasum], xmm7 ;# update j atoms dvdaj movhlps xmm7, xmm6 addsd xmm6, [rsi + rax*8] addsd xmm7, [rsi + rbx*8] movsd [rsi + rax*8], xmm6 movsd [rsi + rbx*8], xmm7 subsd xmm9, xmm3 mulsd xmm9, xmm0 ;# fscal movapd xmm10, xmm9 movapd xmm11, xmm9 mulsd xmm9, [rsp + nb410_dx] mulsd xmm10, [rsp + nb410_dy] mulsd xmm11, [rsp + nb410_dz] ;# accumulate i forces addsd xmm13, xmm9 addsd xmm14, xmm10 addsd xmm15, xmm11 mov rdi, [rbp + nb410_faction] ;# the fj's - start by accumulating forces from memory addsd xmm9, [rdi + r10*8] addsd xmm10, [rdi + r10*8 + 8] addsd xmm11, [rdi + r10*8 + 16] movsd [rdi + r10*8], xmm9 movsd [rdi + r10*8 + 8], xmm10 movsd [rdi + r10*8 + 16], xmm11 .nb410_updateouterdata: mov ecx, [rsp + nb410_ii3] mov rdi, [rbp + nb410_faction] mov rsi, [rbp + nb410_fshift] mov edx, [rsp + nb410_is3] ;# accumulate i forces in xmm13, xmm14, xmm15 movhlps xmm3, xmm13 movhlps xmm4, xmm14 movhlps xmm5, xmm15 addsd xmm13, xmm3 addsd xmm14, xmm4 addsd xmm15, xmm5 ;# sum is in low xmm13-xmm15 ;# increment i force movsd xmm3, [rdi + rcx*8] movsd xmm4, [rdi + rcx*8 + 8] movsd xmm5, [rdi + rcx*8 + 16] subsd xmm3, xmm13 subsd xmm4, xmm14 subsd xmm5, xmm15 movsd [rdi + rcx*8], xmm3 movsd [rdi + rcx*8 + 8], xmm4 movsd [rdi + rcx*8 + 16], xmm5 ;# increment fshift force movsd xmm3, [rsi + rdx*8] movsd xmm4, [rsi + rdx*8 + 8] movsd xmm5, [rsi + rdx*8 + 16] subsd xmm3, xmm13 subsd xmm4, xmm14 subsd xmm5, xmm15 movsd [rsi + rdx*8], xmm3 movsd [rsi + rdx*8 + 8], xmm4 movsd [rsi + rdx*8 + 16], xmm5 ;# get n from stack mov esi, [rsp + nb410_n] ;# get group index for i particle mov rdx, [rbp + nb410_gid] ;# base of gid[] mov edx, [rdx + rsi*4] ;# ggid=gid[n] ;# accumulate total potential energy and update it movhlps xmm6, xmm12 addsd xmm12, xmm6 ;# low xmm12 has the sum now ;# add earlier value from mem mov rax, [rbp + nb410_Vc] addsd xmm12, [rax + rdx*8] ;# move back to mem movsd [rax + rdx*8], xmm12 ;# accumulate total lj energy and update it movapd xmm7, [rsp + nb410_Vvdwtot] ;# accumulate movhlps xmm6, xmm7 addsd xmm7, xmm6 ;# low xmm7 has the sum now ;# add earlier value from mem mov rax, [rbp + nb410_Vvdw] addsd xmm7, [rax + rdx*8] ;# move back to mem movsd [rax + rdx*8], xmm7 ;# accumulate dVda and update it movapd xmm7, [rsp + nb410_dvdasum] ;# accumulate movhlps xmm6, xmm7 addsd xmm7, xmm6 ;# low xmm7 has the sum now mov edx, [rsp + nb410_ii] mov rax, [rbp + nb410_dvda] addsd xmm7, [rax + rdx*8] movsd [rax + rdx*8], xmm7 ;# finish if last mov ecx, [rsp + nb410_nn1] ;# esi already loaded with n inc esi sub ecx, esi jz .nb410_outerend ;# not last, iterate outer loop once more! mov [rsp + nb410_n], esi jmp .nb410_outer.nb410_outerend: ;# check if more outer neighborlists remain mov ecx, [rsp + nb410_nri] ;# esi already loaded with n above sub ecx, esi jz .nb410_end ;# non-zero, do one more workunit jmp .nb410_threadloop.nb410_end: mov eax, [rsp + nb410_nouter] mov ebx, [rsp + nb410_ninner] mov rcx, [rbp + nb410_outeriter] mov rdx, [rbp + nb410_inneriter] mov [rcx], eax mov [rdx], ebx add rsp, 552 emms pop r15 pop r14 pop r13 pop r12 pop rbx pop rbp ret.globl nb_kernel410nf_x86_64_sse2.globl _nb_kernel410nf_x86_64_sse2nb_kernel410nf_x86_64_sse2: _nb_kernel410nf_x86_64_sse2: ;# Room for return address and rbp (16 bytes).equiv nb410nf_fshift, 16.equiv nb410nf_gid, 24.equiv nb410nf_pos, 32.equiv nb410nf_faction, 40.equiv nb410nf_charge, 48.equiv nb410nf_p_facel, 56.equiv nb410nf_argkrf, 64.equiv nb410nf_argcrf, 72.equiv nb410nf_Vc, 80.equiv nb410nf_type, 88.equiv nb410nf_p_ntype, 96.equiv nb410nf_vdwparam, 104.equiv nb410nf_Vvdw, 112.equiv nb410nf_p_tabscale, 120.equiv nb410nf_VFtab, 128.equiv nb410nf_invsqrta, 136.equiv nb410nf_dvda, 144.equiv nb410nf_p_gbtabscale, 152.equiv nb410nf_GBtab, 160.equiv nb410nf_p_nthreads, 168.equiv nb410nf_count, 176.equiv nb410nf_mtx, 184.equiv nb410nf_outeriter, 192.equiv nb410nf_inneriter, 200.equiv nb410nf_work, 208 ;# stack offsets for local variables ;# bottom of stack is cache-aligned for sse2 use .equiv nb410nf_ix, 0.equiv nb410nf_iy, 16.equiv nb410nf_iz, 32.equiv nb410nf_iq, 48.equiv nb410nf_two, 64.equiv nb410nf_gbtsc, 80.equiv nb410nf_qq, 96.equiv nb410nf_c6, 112.equiv nb410nf_c12, 128.equiv nb410nf_vctot, 144.equiv nb410nf_Vvdwtot, 160.equiv nb410nf_half, 176.equiv nb410nf_three, 192.equiv nb410nf_r, 208.equiv nb410nf_isai, 224.equiv nb410nf_isaprod, 240.equiv nb410nf_gbscale, 256.equiv nb410nf_nri, 272.equiv nb410nf_iinr, 280.equiv nb410nf_jindex, 288.equiv nb410nf_jjnr, 296.equiv nb410nf_shift, 304.equiv nb410nf_shiftvec, 312.equiv nb410nf_facel, 320.equiv nb410nf_innerjjnr, 328.equiv nb410nf_ii, 336.equiv nb410nf_is3, 340.equiv nb410nf_ii3, 344.equiv nb410nf_ntia, 348.equiv nb410nf_innerk, 352.equiv nb410nf_n, 356.equiv nb410nf_nn1, 360.equiv nb410nf_ntype, 364.equiv nb410nf_nouter, 368.equiv nb410nf_ninner, 372 push rbp mov rbp, rsp push rbx emms push r12 push r13 push r14 push r15 sub rsp, 392 ;# local variable stack space (n*16+8) ;# zero 32-bit iteration counters mov eax, 0 mov [rsp + nb410nf_nouter], eax mov [rsp + nb410nf_ninner], eax mov edi, [rdi] mov [rsp + nb410nf_nri], edi mov [rsp + nb410nf_iinr], rsi mov [rsp + nb410nf_jindex], rdx mov [rsp + nb410nf_jjnr], rcx mov [rsp + nb410nf_shift], r8 mov [rsp + nb410nf_shiftvec], r9 mov rdi, [rbp + nb410nf_p_ntype] mov edi, [rdi] mov [rsp + nb410nf_ntype], edi mov rsi, [rbp + nb410nf_p_facel] movsd xmm0, [rsi] movsd [rsp + nb410nf_facel], xmm0 mov rbx, [rbp + nb410nf_p_gbtabscale] movsd xmm4, [rbx] shufpd xmm4, xmm4, 0 movapd [rsp + nb410nf_gbtsc], xmm4 ;# create constant floating-point factors on stack mov eax, 0x00000000 ;# lower half of double half IEEE (hex) mov ebx, 0x3fe00000 mov [rsp + nb410nf_half], eax mov [rsp + nb410nf_half+4], ebx movsd xmm1, [rsp + nb410nf_half] shufpd xmm1, xmm1, 0 ;# splat to all elements movapd xmm3, xmm1 addpd xmm3, xmm3 ;# one movapd xmm2, xmm3 addpd xmm2, xmm2 ;# two addpd xmm3, xmm2 ;# three movapd [rsp + nb410nf_half], xmm1 movapd [rsp + nb410nf_two], xmm2 movapd [rsp + nb410nf_three], xmm3.nb410nf_threadloop: mov rsi, [rbp + nb410nf_count] ;# pointer to sync counter mov eax, [rsi].nb410nf_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 .nb410nf_spinlock ;# if(nn1>nri) nn1=nri mov ecx, [rsp + nb410nf_nri] mov edx, ecx
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?