nb_kernel400_ia32_sse.intel_syntax.s
来自「最著名最快的分子模拟软件」· S 代码 · 共 1,730 行 · 第 1/3 页
S
1,730 行
mov eax, [ecx] mov ebx, [ecx + 4] add dword ptr [esp + nb400_innerjjnr], 8 xorps xmm2, xmm2 movaps xmm6, xmm2 ;# load isaj mov esi, [ebp + nb400_invsqrta] movss xmm2, [esi + eax*4] movss xmm3, [esi + ebx*4] unpcklps xmm2, xmm3 ;# isaj in xmm2(0,1) mulps xmm2, [esp + nb400_isai] movaps [esp + nb400_isaprod], xmm2 movaps xmm1, xmm2 mulps xmm1, [esp + nb400_gbtsc] movaps [esp + nb400_gbscale], xmm1 mov esi, [ebp + nb400_charge] ;# base of charge[] movss xmm3, [esi + eax*4] movss xmm6, [esi + ebx*4] unpcklps xmm3, xmm6 ;# constant 00001000 ;# xmm3(0,1) has the charges mulps xmm2, [esp + nb400_iq] mulps xmm3, xmm2 movaps [esp + nb400_qq], xmm3 mov edi, [ebp + nb400_pos] movd mm0, eax ;# copy jnr to mm0/mm1 movd mm1, ebx lea eax, [eax + eax*2] lea ebx, [ebx + ebx*2] ;# move coordinates to xmm0-xmm2 movlps xmm1, [edi + eax*4] movss xmm2, [edi + eax*4 + 8] movhps xmm1, [edi + ebx*4] movss xmm0, [edi + ebx*4 + 8] movlhps xmm3, xmm7 shufps xmm2, xmm0, 0 movaps xmm0, xmm1 shufps xmm2, xmm2, 136 ;# constant 10001000 shufps xmm0, xmm0, 136 ;# constant 10001000 shufps xmm1, xmm1, 221 ;# constant 11011101 mov edi, [ebp + nb400_faction] ;# move ix-iz to xmm4-xmm6 xorps xmm7, xmm7 movaps xmm4, [esp + nb400_ix] movaps xmm5, [esp + nb400_iy] movaps xmm6, [esp + nb400_iz] ;# calc dr subps xmm4, xmm0 subps xmm5, xmm1 subps xmm6, xmm2 ;# store dr movaps [esp + nb400_dx], xmm4 movaps [esp + nb400_dy], xmm5 movaps [esp + nb400_dz], xmm6 ;# square it mulps xmm4,xmm4 mulps xmm5,xmm5 mulps xmm6,xmm6 addps xmm4, xmm5 addps xmm4, xmm6 ;# rsq in xmm4 rsqrtps xmm5, xmm4 ;# lookup seed in xmm5 movaps xmm2, xmm5 mulps xmm5, xmm5 movaps xmm1, [esp + nb400_three] mulps xmm5, xmm4 ;# rsq*lu*lu movaps xmm0, [esp + nb400_half] subps xmm1, xmm5 ;# constant 30-rsq*lu*lu mulps xmm1, xmm2 mulps xmm0, xmm1 ;# xmm0=rinv mulps xmm4, xmm0 ;# xmm4=r movaps [esp + nb400_r], xmm4 mulps xmm4, [esp + nb400_gbscale] cvttps2pi mm6, xmm4 ;# mm6 contain lu indices cvtpi2ps xmm6, mm6 subps xmm4, xmm6 movaps xmm1, xmm4 ;# xmm1=eps movaps xmm2, xmm1 mulps xmm2, xmm2 ;# xmm2=eps2 pslld mm6, 2 mov esi, [ebp + nb400_GBtab] movd ecx, mm6 psrlq mm6, 32 movd edx, mm6 ;# load coulomb table movaps xmm4, [esi + ecx*4] movaps xmm7, [esi + edx*4] ;# transpose, using xmm3 for scratch movaps xmm6, xmm4 unpcklps xmm4, xmm7 ;# Y1 Y2 F1 F2 unpckhps xmm6, xmm7 ;# G1 G2 H1 H2 movhlps xmm5, xmm4 ;# F1 F2 movhlps xmm7, xmm6 ;# H1 H2 ;# 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, [esp + nb400_two] ;# two*Heps2 movaps xmm3, [esp + nb400_qq] 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 mm5 contains vcoul and mm3 fijC ;# get jnr from mm0/mm1 movd ecx, mm0 movd edx, mm1 mov esi, [ebp + nb400_dvda] ;# Calculate dVda xorps xmm7, xmm7 mulps xmm3, [esp + nb400_gbscale] movaps xmm6, xmm3 mulps xmm6, [esp + nb400_r] addps xmm6, xmm5 addps xmm5, [esp + nb400_vctot] movaps [esp + nb400_vctot], xmm5 ;# xmm6=(vcoul+fijC*r) subps xmm7, xmm6 movaps xmm6, xmm7 ;# update dvdasum addps xmm7, [esp + nb400_dvdasum] movaps [esp + nb400_dvdasum], xmm7 ;# update j atoms dvdaj movaps xmm7, xmm6 shufps xmm7, xmm7, 0x1 addss xmm6, [esi + ecx*4] addss xmm7, [esi + edx*4] movss [esi + ecx*4], xmm6 movss [esi + edx*4], xmm7 xorps xmm4, xmm4 mulps xmm3, xmm0 subps xmm4, xmm3 movaps xmm0, [esp + nb400_dx] movaps xmm1, [esp + nb400_dy] movaps xmm2, [esp + nb400_dz] mulps xmm0, xmm4 mulps xmm1, xmm4 mulps xmm2, xmm4 ;# xmm0-xmm2 contains tx-tz (partial force) ;# now update f_i movaps xmm3, [esp + nb400_fix] movaps xmm4, [esp + nb400_fiy] movaps xmm5, [esp + nb400_fiz] addps xmm3, xmm0 addps xmm4, xmm1 addps xmm5, xmm2 movaps [esp + nb400_fix], xmm3 movaps [esp + nb400_fiy], xmm4 movaps [esp + nb400_fiz], xmm5 ;# update the fj's movss xmm3, [edi + eax*4] movss xmm4, [edi + eax*4 + 4] movss xmm5, [edi + eax*4 + 8] subss xmm3, xmm0 subss xmm4, xmm1 subss xmm5, xmm2 movss [edi + eax*4], xmm3 movss [edi + eax*4 + 4], xmm4 movss [edi + eax*4 + 8], xmm5 shufps xmm0, xmm0, 225 ;# constant 11100001 shufps xmm1, xmm1, 225 ;# constant 11100001 shufps xmm2, xmm2, 225 ;# constant 11100001 movss xmm3, [edi + ebx*4] movss xmm4, [edi + ebx*4 + 4] movss xmm5, [edi + ebx*4 + 8] subss xmm3, xmm0 subss xmm4, xmm1 subss xmm5, xmm2 movss [edi + ebx*4], xmm3 movss [edi + ebx*4 + 4], xmm4 movss [edi + ebx*4 + 8], xmm5 .nb400_checksingle: mov edx, [esp + nb400_innerk] and edx, 1 jnz .nb400_dosingle jmp .nb400_updateouterdata.nb400_dosingle: mov esi, [ebp + nb400_charge] mov edx, [ebp + nb400_invsqrta] mov edi, [ebp + nb400_pos] mov ecx, [esp + nb400_innerjjnr] mov eax, [ecx] xorps xmm2, xmm2 movaps xmm6, xmm2 movss xmm2, [edx + eax*4] ;# isaj mulss xmm2, [esp + nb400_isai] movss [esp + nb400_isaprod], xmm2 movss xmm1, xmm2 mulss xmm1, [esp + nb400_gbtsc] movss [esp + nb400_gbscale], xmm1 mulss xmm2, [esp + nb400_iq] movss xmm6, [esi + eax*4] ;# xmm6(0) has the charge mulss xmm6, xmm2 movss [esp + nb400_qq], xmm6 movd mm0, eax lea eax, [eax + eax*2] ;# move coordinates to xmm0-xmm2 movss xmm0, [edi + eax*4] movss xmm1, [edi + eax*4 + 4] movss xmm2, [edi + eax*4 + 8] movss xmm4, [esp + nb400_ix] movss xmm5, [esp + nb400_iy] movss xmm6, [esp + nb400_iz] ;# calc dr subss xmm4, xmm0 subss xmm5, xmm1 subss xmm6, xmm2 ;# store dr movss [esp + nb400_dx], xmm4 movss [esp + nb400_dy], xmm5 movss [esp + nb400_dz], xmm6 ;# square it mulss xmm4,xmm4 mulss xmm5,xmm5 mulss xmm6,xmm6 addss xmm4, xmm5 addss xmm4, xmm6 ;# rsq in xmm4 rsqrtss xmm5, xmm4 ;# lookup seed in xmm5 movss xmm2, xmm5 mulss xmm5, xmm5 movss xmm1, [esp + nb400_three] mulss xmm5, xmm4 ;# rsq*lu*lu movss xmm0, [esp + nb400_half] subss xmm1, xmm5 ;# constant 30-rsq*lu*lu mulss xmm1, xmm2 mulss xmm0, xmm1 ;# xmm0=rinv mulss xmm4, xmm0 ;# xmm4=r movss [esp + nb400_r], xmm4 mulss xmm4, [esp + nb400_gbscale] cvttss2si ebx, xmm4 ;# mm6 contain lu indices cvtsi2ss xmm6, ebx subss xmm4, xmm6 movss xmm1, xmm4 ;# xmm1=eps movss xmm2, xmm1 mulss xmm2, xmm2 ;# xmm2=eps2 shl ebx, 2 mov esi, [ebp + nb400_GBtab] movaps xmm4, [esi + ebx*4] movhlps xmm6, xmm4 movaps xmm5, xmm4 movaps xmm7, xmm6 shufps xmm5, xmm5, 1 shufps xmm7, xmm7, 1 ;# table ready in xmm4-xmm7 mulss xmm6, xmm1 ;# xmm6=Geps mulss xmm7, xmm2 ;# xmm7=Heps2 addss xmm5, xmm6 addss xmm5, xmm7 ;# xmm5=Fp mulss xmm7, [esp + nb400_two] ;# two*Heps2 movss xmm3, [esp + nb400_qq] addss xmm7, xmm6 addss xmm7, xmm5 ;# xmm7=FF mulss xmm5, xmm1 ;# xmm5=eps*Fp addss xmm5, xmm4 ;# xmm5=VV mulss xmm5, xmm3 ;# vcoul=qq*VV mulss xmm3, xmm7 ;# fijC=FF*qq ;# at this point mm5 contains vcoul and mm3 fijC movd ebx, mm0 mov esi, [ebp + nb400_dvda] ;# Calculate dVda xorps xmm7, xmm7 mulss xmm3, [esp + nb400_gbscale] movaps xmm6, xmm3 mulss xmm6, [esp + nb400_r] addss xmm6, xmm5 addss xmm5, [esp + nb400_vctot] movss [esp + nb400_vctot], xmm5 ;# xmm6=(vcoul+fijC*r) subps xmm7, xmm6 movaps xmm6, xmm7 ;# update dvdasum addps xmm7, [esp + nb400_dvdasum] movaps [esp + nb400_dvdasum], xmm7 ;# update j atoms dvdaj addss xmm6, [esi + ebx*4] movss [esi + ebx*4], xmm6 xorps xmm4, xmm4 mulss xmm3, xmm0 subss xmm4, xmm3 mov edi, [ebp + nb400_faction] movss xmm0, [esp + nb400_dx] movss xmm1, [esp + nb400_dy] movss xmm2, [esp + nb400_dz] mulss xmm0, xmm4 mulss xmm1, xmm4 mulss xmm2, xmm4 ;# xmm0-xmm2 contains tx-tz (partial force) ;# now update f_i movss xmm3, [esp + nb400_fix] movss xmm4, [esp + nb400_fiy] movss xmm5, [esp + nb400_fiz] addss xmm3, xmm0 addss xmm4, xmm1 addss xmm5, xmm2 movss [esp + nb400_fix], xmm3 movss [esp + nb400_fiy], xmm4 movss [esp + nb400_fiz], xmm5 ;# update fj movss xmm3, [edi + eax*4] movss xmm4, [edi + eax*4 + 4] movss xmm5, [edi + eax*4 + 8] subss xmm3, xmm0 subss xmm4, xmm1 subss xmm5, xmm2 movss [edi + eax*4], xmm3 movss [edi + eax*4 + 4], xmm4 movss [edi + eax*4 + 8], xmm5 .nb400_updateouterdata: mov ecx, [esp + nb400_ii3] mov edi, [ebp + nb400_faction] mov esi, [ebp + nb400_fshift] mov edx, [esp + nb400_is3] ;# accumulate i forces in xmm0, xmm1, xmm2 movaps xmm0, [esp + nb400_fix] movaps xmm1, [esp + nb400_fiy] movaps xmm2, [esp + nb400_fiz] 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, [edi + ecx*4] movss xmm4, [edi + ecx*4 + 4] movss xmm5, [edi + ecx*4 + 8] addss xmm3, xmm0 addss xmm4, xmm1 addss xmm5, xmm2 movss [edi + ecx*4], xmm3 movss [edi + ecx*4 + 4], xmm4 movss [edi + ecx*4 + 8], xmm5 ;# increment fshift force movss xmm3, [esi + edx*4] movss xmm4, [esi + edx*4 + 4] movss xmm5, [esi + edx*4 + 8] addss xmm3, xmm0 addss xmm4, xmm1 addss xmm5, xmm2 movss [esi + edx*4], xmm3 movss [esi + edx*4 + 4], xmm4 movss [esi + edx*4 + 8], xmm5 ;# get n from stack mov esi, [esp + nb400_n] ;# get group index for i particle mov edx, [ebp + nb400_gid] ;# base of gid[] mov edx, [edx + esi*4] ;# ggid=gid[n] ;# accumulate total potential energy and update it movaps xmm7, [esp + nb400_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 eax, [ebp + nb400_Vc] addss xmm7, [eax + edx*4] ;# move back to mem movss [eax + edx*4], xmm7 ;# accumulate dVda and update it movaps xmm7, [esp + nb400_dvdasum] ;# 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 mov edx, [esp + nb400_ii] mov eax, [ebp + nb400_dvda] addss xmm7, [eax + edx*4] movss [eax + edx*4], xmm7 ;# finish if last mov ecx, [esp + nb400_nn1] ;# esi already loaded with n inc esi sub ecx, esi jecxz .nb400_outerend ;# not last, iterate outer loop once more! mov [esp + nb400_n], esi jmp .nb400_outer.nb400_outerend: ;# check if more outer neighborlists remain mov ecx, [esp + nb400_nri] ;# esi already loaded with n above sub ecx, esi jecxz .nb400_end ;# non-zero, do one more workunit jmp .nb400_threadloop.nb400_end: emms mov eax, [esp + nb400_nouter] mov ebx, [esp + nb400_ninner] mov ecx, [ebp + nb400_outeriter] mov edx, [ebp + nb400_inneriter] mov [ecx], eax mov [edx], ebx mov eax, [esp + nb400_salign] add esp, eax add esp, 400 pop edi pop esi pop edx pop ecx pop ebx pop eax leave ret .globl nb_kernel400nf_ia32_sse.globl _nb_kernel400nf_ia32_ssenb_kernel400nf_ia32_sse: _nb_kernel400nf_ia32_sse: .equiv nb400nf_p_nri, 8.equiv nb400nf_iinr, 12.equiv nb400nf_jindex, 16.equiv nb400nf_jjnr, 20.equiv nb400nf_shift, 24.equiv nb400nf_shiftvec, 28.equiv nb400nf_fshift, 32.equiv nb400nf_gid, 36.equiv nb400nf_pos, 40.equiv nb400nf_faction, 44.equiv nb400nf_charge, 48.equiv nb400nf_p_facel, 52.equiv nb400nf_argkrf, 56.equiv nb400nf_argcrf, 60.equiv nb400nf_Vc, 64.equiv nb400nf_type, 68.equiv nb400nf_p_ntype, 72.equiv nb400nf_vdwparam, 76.equiv nb400nf_Vvdw, 80.equiv nb400nf_p_tabscale, 84.equiv nb400nf_VFtab, 88.equiv nb400nf_invsqrta, 92.equiv nb400nf_dvda, 96.equiv nb400nf_p_gbtabscale, 100.equiv nb400nf_GBtab, 104.equiv nb400nf_p_nthreads, 108.equiv nb400nf_count, 112.equiv nb400nf_mtx, 116.equiv nb400nf_outeriter, 120.equiv nb400nf_inneriter, 124.equiv nb400nf_work, 128 ;# stack offsets for local variables ;# bottom of stack is cache-aligned for sse use .equiv nb400nf_ix, 0.equiv nb400nf_iy, 16.equiv nb400nf_iz, 32.equiv nb400nf_iq, 48.equiv nb400nf_gbtsc, 64.equiv nb400nf_qq, 80.equiv nb400nf_vctot, 96.equiv nb400nf_half, 112.equiv nb400nf_three, 128.equiv nb400nf_isai, 144.equiv nb400nf_isaprod, 160.equiv nb400nf_gbscale, 176.equiv nb400nf_is3, 192.equiv nb400nf_ii3, 196.equiv nb400nf_innerjjnr, 200.equiv nb400nf_innerk, 204.equiv nb400nf_n, 208.equiv nb400nf_nn1, 212.equiv nb400nf_nri, 216.equiv nb400nf_facel, 220.equiv nb400nf_nouter, 224.equiv nb400nf_ninner, 228.equiv nb400nf_salign, 232 push ebp mov ebp,esp push eax push ebx push ecx push edx push esi push edi sub esp, 236 ;# local stack space mov eax, esp and eax, 0xf sub esp, eax mov [esp + nb400nf_salign], eax emms ;# Move args passed by reference to stack mov ecx, [ebp + nb400nf_p_nri] mov esi, [ebp + nb400nf_p_facel]
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?