📄 nb_kernel100_ia32_3dnow.intel_syntax.s
字号:
movq [edi + eax*4], mm2 movd [edi + eax*4 +8], mm3 ;# done! .nb100_updateouterdata: mov ecx, [esp + nb100_ii3] movq mm6, [edi + ecx*4] ;# increment i force movd mm7, [edi + ecx*4 + 8] pfadd mm6, [esp + nb100_fix] pfadd mm7, [esp + nb100_fiz] movq [edi + ecx*4], mm6 movd [edi + ecx*4 +8], mm7 mov ebx, [ebp + nb100_fshift] ;# increment fshift force mov edx, [esp + nb100_is3] movq mm6, [ebx + edx*4] movd mm7, [ebx + edx*4 + 8] pfadd mm6, [esp + nb100_fix] pfadd mm7, [esp + nb100_fiz] movq [ebx + edx*4], mm6 movd [ebx + edx*4 + 8], mm7 ;# get n from stack mov esi, [esp + nb100_n] ;# get group index for i particle mov edx, [ebp + nb100_gid] ;# base of gid[] mov edx, [edx + esi*4] ;# ggid=gid[n] movq mm7, [esp + nb100_vctot] pfacc mm7,mm7 ;# get and sum the two parts of total potential mov eax, [ebp + nb100_Vc] movd mm6, [eax + edx*4] pfadd mm6, mm7 movd [eax + edx*4], mm6 ;# increment vc[gid] ;# finish if last mov ecx, [esp + nb100_nn1] ;# esi already loaded with n inc esi sub ecx, esi jecxz .nb100_outerend ;# not last, iterate outer loop once more! mov [esp + nb100_n], esi jmp .nb100_outer.nb100_outerend: ;# check if more outer neighborlists remain mov ecx, [esp + nb100_nri] ;# esi already loaded with n above sub ecx, esi jecxz .nb100_end ;# non-zero, do one more workunit jmp .nb100_threadloop.nb100_end: femms mov eax, [esp + nb100_nouter] mov ebx, [esp + nb100_ninner] mov ecx, [ebp + nb100_outeriter] mov edx, [ebp + nb100_inneriter] mov [ecx], eax mov [edx], ebx add esp, 104 pop edi pop esi pop edx pop ecx pop ebx pop eax leave ret .globl nb_kernel100nf_ia32_3dnow.globl _nb_kernel100nf_ia32_3dnownb_kernel100nf_ia32_3dnow: _nb_kernel100nf_ia32_3dnow: .equiv nb100nf_p_nri, 8.equiv nb100nf_iinr, 12.equiv nb100nf_jindex, 16.equiv nb100nf_jjnr, 20.equiv nb100nf_shift, 24.equiv nb100nf_shiftvec, 28.equiv nb100nf_fshift, 32.equiv nb100nf_gid, 36.equiv nb100nf_pos, 40 .equiv nb100nf_faction, 44.equiv nb100nf_charge, 48.equiv nb100nf_p_facel, 52.equiv nb100nf_p_krf, 56 .equiv nb100nf_p_crf, 60 .equiv nb100nf_Vc, 64 .equiv nb100nf_type, 68.equiv nb100nf_p_ntype, 72.equiv nb100nf_vdwparam, 76 .equiv nb100nf_Vvdw, 80 .equiv nb100nf_p_tabscale, 84 .equiv nb100nf_VFtab, 88.equiv nb100nf_invsqrta, 92 .equiv nb100nf_dvda, 96.equiv nb100nf_p_gbtabscale, 100.equiv nb100nf_GBtab, 104.equiv nb100nf_p_nthreads, 108.equiv nb100nf_count, 112.equiv nb100nf_mtx, 116.equiv nb100nf_outeriter, 120.equiv nb100nf_inneriter, 124.equiv nb100nf_work, 128 ;# stack offsets for local variables .equiv nb100nf_is3, 0.equiv nb100nf_ii3, 4.equiv nb100nf_ix, 8.equiv nb100nf_iy, 12.equiv nb100nf_iz, 16.equiv nb100nf_iq, 20 .equiv nb100nf_vctot, 28 .equiv nb100nf_innerjjnr, 36.equiv nb100nf_innerk, 40 .equiv nb100nf_n, 44 ;# idx for outer loop.equiv nb100nf_nn1, 48 ;# number of outer iterations.equiv nb100nf_nri, 52.equiv nb100nf_facel, 56.equiv nb100nf_nouter, 60.equiv nb100nf_ninner, 64 push ebp mov ebp,esp push eax push ebx push ecx push edx push esi push edi sub esp, 68 ;# local stack space femms mov ecx, [ebp + nb100nf_p_nri] mov esi, [ebp + nb100nf_p_facel] mov ecx, [ecx] mov esi, [esi] mov [esp + nb100nf_nri], ecx mov [esp + nb100nf_facel], esi ;# zero iteration counters mov eax, 0 mov [esp + nb100nf_nouter], eax mov [esp + nb100nf_ninner], eax.nb100nf_threadloop: mov esi, [ebp + nb100nf_count] ;# pointer to sync counter mov eax, [esi].nb100nf_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 .nb100nf_spinlock ;# if(nn1>nri) nn1=nri mov ecx, [esp + nb100nf_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 [esp + nb100nf_n], eax mov [esp + nb100nf_nn1], ebx sub ebx, eax ;# calc number of outer lists mov esi, eax ;# copy n to esi jg .nb100nf_outerstart jmp .nb100nf_end.nb100nf_outerstart: ;# ebx contains number of outer iterations add ebx, [esp + nb100nf_nouter] mov [esp + nb100nf_nouter], ebx .nb100nf_outer: mov eax, [ebp + nb100nf_shift] ;# eax = pointer into shift[] mov ebx, [eax + esi*4] ;# ebx=shift[n] lea ebx, [ebx + ebx*2] ;# ebx=3*is mov [esp + nb100nf_is3],ebx ;# store is3 mov eax, [ebp + nb100nf_shiftvec] ;# eax = base of shiftvec[] movq mm0, [eax + ebx*4] ;# move shX/shY to mm0 and shZ to mm1 movd mm1, [eax + ebx*4 + 8] mov ecx, [ebp + nb100nf_iinr] ;# ecx = pointer into iinr[] mov ebx, [ecx + esi*4] ;# ebx=ii mov edx, [ebp + nb100nf_charge] movd mm2, [edx + ebx*4] ;# mm2=charge[ii] pfmul mm2, [esp + nb100nf_facel] punpckldq mm2,mm2 ;# spread to both halves movq [esp + nb100nf_iq], mm2 ;# iq =facel*charge[ii] lea ebx, [ebx + ebx*2] ;# ebx = 3*ii=ii3 mov eax, [ebp + nb100nf_pos] ;# eax = base of pos[] pfadd mm0, [eax + ebx*4] ;# ix = shX + posX (and iy too) movd mm3, [eax + ebx*4 + 8] ;# cant use direct memory add for 4 bytes (iz) mov [esp + nb100nf_ii3], ebx pfadd mm1, mm3 movq [esp + nb100nf_ix], mm0 movd [esp + nb100nf_iz], mm1 ;# clear vctot pxor mm7,mm7 movq [esp + nb100nf_vctot], mm7 mov eax, [ebp + nb100nf_jindex] mov ecx, [eax + esi*4] ;# jindex[n] mov edx, [eax + esi*4 + 4] ;# jindex[n+1] sub edx, ecx ;# number of innerloop atoms mov esi, [ebp + nb100nf_pos] mov edi, [ebp + nb100nf_faction] mov eax, [ebp + nb100nf_jjnr] shl ecx, 2 add eax, ecx mov [esp + nb100nf_innerjjnr], eax ;# pointer to jjnr[nj0] mov ecx, edx sub edx, 2 add ecx, [esp + nb100nf_ninner] mov [esp + nb100nf_ninner], ecx mov [esp + nb100nf_innerk], edx ;# number of innerloop atoms add edx, 0 jge .nb100nf_unroll_loop jmp .nb100nf_finish_inner.nb100nf_unroll_loop: ;# paired innerloop starts here mov ecx, [esp + nb100nf_innerjjnr] ;# pointer to jjnr[k] mov eax, [ecx] mov ebx, [ecx + 4] ;# eax/ebx=jnr add dword ptr [esp + nb100nf_innerjjnr], 8 ;# advance pointer (unrolled 2) prefetch [ecx + 16] ;# prefetch data - trial and error says 16 is best mov ecx, [ebp + nb100nf_charge] ;# base of charge[] movq mm5, [esp + nb100nf_iq] movd mm3, [ecx + eax*4] ;# charge[jnr1] movd mm7, [ecx + ebx*4] ;# charge[jnr2] punpckldq mm3,mm7 ;# move charge 2 to high part of mm3 pfmul mm3,mm5 ;# mm3 now has qq for both particles lea eax, [eax + eax*2] ;# replace jnr with j3 lea ebx, [ebx + ebx*2] movq mm0, [esp + nb100nf_ix] movd mm1, [esp + nb100nf_iz] movq mm4, [esi + eax*4] ;# fetch first j coordinates movd mm5, [esi + eax*4 + 8] pfsubr mm4,mm0 ;# dr = ir - jr pfsubr mm5,mm1 pfmul mm4,mm4 ;# square dx,dy,dz pfmul mm5,mm5 pfacc mm4, mm5 ;# accumulate to get dx*dx+ dy*dy+ dz*dz pfacc mm4, mm5 ;# first rsq in lower mm4 movq mm6, [esi + ebx*4] ;# fetch second j coordinates movd mm7, [esi + ebx*4 + 8] pfsubr mm6,mm0 ;# dr = ir - jr pfsubr mm7,mm1 pfmul mm6,mm6 ;# square dx,dy,dz pfmul mm7,mm7 pfacc mm6, mm7 ;# accumulate to get dx*dx+ dy*dy+ dz*dz pfacc mm6, mm7 ;# second rsq in lower mm6 pfrsqrt mm0, mm4 ;# lookup inverse square root seed pfrsqrt mm1, mm6 punpckldq mm0,mm1 punpckldq mm4,mm6 ;# now 4 has rsq and 0 the seed for both pairs movq mm2,mm0 ;# amd 3dnow N-R iteration to get full precision pfmul mm0,mm0 pfrsqit1 mm0,mm4 pfrcpit2 mm0,mm2 ;# mm0=invsqrt ;# do potential and fscal pfmul mm3,mm0 ;# mm3 has both vcoul ;# update vctot pfadd mm3, [esp + nb100nf_vctot] ;# add the earlier value movq [esp + nb100nf_vctot], mm3 ;# store the sum ;# should we do one more iteration? sub dword ptr [esp + nb100nf_innerk], 2 jl .nb100nf_finish_inner jmp .nb100nf_unroll_loop.nb100nf_finish_inner: and dword ptr [esp + nb100nf_innerk], 1 jnz .nb100nf_single_inner jmp .nb100nf_updateouterdata .nb100nf_single_inner: ;# a single j particle iteration here - compare with the unrolled code for comments mov eax, [esp + nb100nf_innerjjnr] mov eax, [eax] ;# eax=jnr offset mov ecx, [ebp + nb100nf_charge] pxor mm6, mm6 movd mm6, [esp + nb100nf_iq] movd mm7, [ecx + eax*4] pfmul mm6, mm7 ;# mm6=qq lea eax, [eax + eax*2] movq mm0, [esp + nb100nf_ix] movd mm1, [esp + nb100nf_iz] movq mm2, [esi + eax*4] movd mm3, [esi + eax*4 + 8] pfsub mm0, mm2 pfsub mm1, mm3 pfmul mm0,mm0 pfmul mm1,mm1 pfacc mm0, mm1 pfacc mm0, mm1 ;# mm0=rsq pfrsqrt mm1,mm0 movq mm2,mm1 pfmul mm1,mm1 pfrsqit1 mm1,mm0 pfrcpit2 mm1,mm2 ;# mm1=invsqrt ;# calculate potential pfmul mm6, mm1 ;# mm6=vcoul ;# update vctot pfadd mm6, [esp + nb100nf_vctot] movq [esp + nb100nf_vctot], mm6 ;# done! .nb100nf_updateouterdata: ;# get n from stack mov esi, [esp + nb100nf_n] ;# get group index for i particle mov edx, [ebp + nb100nf_gid] ;# base of gid[] mov edx, [edx + esi*4] ;# ggid=gid[n] movq mm7, [esp + nb100nf_vctot] pfacc mm7,mm7 ;# get and sum the two parts of total potential mov eax, [ebp + nb100nf_Vc] movd mm6, [eax + edx*4] pfadd mm6, mm7 movd [eax + edx*4], mm6 ;# increment vc[gid] ;# finish if last mov ecx, [esp + nb100nf_nn1] ;# esi already loaded with n inc esi sub ecx, esi jecxz .nb100nf_outerend ;# not last, iterate outer loop once more! mov [esp + nb100nf_n], esi jmp .nb100nf_outer.nb100nf_outerend: ;# check if more outer neighborlists remain mov ecx, [esp + nb100nf_nri] ;# esi already loaded with n above sub ecx, esi jecxz .nb100nf_end ;# non-zero, do one more workunit jmp .nb100nf_threadloop.nb100nf_end: femms mov eax, [esp + nb100nf_nouter] mov ebx, [esp + nb100nf_ninner] mov ecx, [ebp + nb100nf_outeriter] mov edx, [ebp + nb100nf_inneriter] mov [ecx], eax mov [edx], ebx add esp, 68 pop edi pop esi pop edx pop ecx pop ebx pop eax leave ret
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -