nb_kernel330_x86_64_sse2.intel_syntax.s

来自「最著名最快的分子模拟软件」· S 代码 · 共 1,474 行 · 第 1/3 页

S
1,474
字号
	movlpd [rdi + rax*8], xmm4	movlpd [rdi + rax*8 + 8], xmm5	movlpd [rdi + rax*8 + 16], xmm6    movapd [rsp + nb330_fix], xmm12    movapd [rsp + nb330_fiy], xmm13    movapd [rsp + nb330_fiz], xmm14 	movhpd [rdi + rbx*8], xmm4	movhpd [rdi + rbx*8 + 8], xmm5	movhpd [rdi + rbx*8 + 16], xmm6		;# should we do one more iteration? 	sub dword ptr [rsp + nb330_innerk],  2	jl    .nb330_checksingle	jmp   .nb330_unroll_loop.nb330_checksingle:	mov   edx, [rsp + nb330_innerk]	and   edx, 1	jnz    .nb330_dosingle	jmp    .nb330_updateouterdata.nb330_dosingle:	mov rsi, [rbp + nb330_charge]	mov rdi, [rbp + nb330_pos]	mov   rcx, [rsp + nb330_innerjjnr]	mov   eax, [rcx]		movsd xmm3, [rsi + rax*8]	mulsd  xmm3, [rsp + nb330_iq]	movapd [rsp + nb330_qq], xmm3		mov rsi, [rbp + nb330_type]	mov r8d, [rsi + rax*4]	mov rsi, [rbp + nb330_vdwparam]	shl r8d, 1	mov edi, [rsp + nb330_ntia]	add r8d, edi	movsd xmm4, [rsi + r8*8]	movsd xmm6, [rsi + r8*8 + 8]	movapd [rsp + nb330_c6], xmm4	movapd [rsp + nb330_c12], xmm6		mov rsi, [rbp + nb330_pos]		;# base of pos[] 	lea   rax, [rax + rax*2]     ;# replace jnr with j3 	;# move coordinate to xmm4-xmm6 	movsd xmm4, [rsi + rax*8]	movsd xmm5, [rsi + rax*8 + 8]	movsd xmm6, [rsi + rax*8 + 16]	mov    rdi, [rbp + nb330_faction]		;# calc dr 	subsd xmm4, [rsp + nb330_ix]	subsd xmm5, [rsp + nb330_iy]	subsd xmm6, [rsp + nb330_iz]	;# store dr 	movapd [rsp + nb330_dx], xmm4	movapd [rsp + nb330_dy], xmm5	movapd [rsp + nb330_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 + nb330_three]	mulsd xmm2, xmm4	;# rsq*lu*lu 				movapd xmm0, [rsp + nb330_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 + nb330_three]	mulsd xmm1, xmm4	;# rsq*lu*lu 				movapd xmm0, [rsp + nb330_half]	subsd xmm2, xmm1	;# 30-rsq*lu*lu 	mulsd xmm2, xmm5		mulsd xmm0, xmm2	;# xmm0=iter2 of rinv (new lu) 	mulsd xmm4, xmm0	;# xmm4=r 	mulsd xmm4, [rsp + nb330_tsc]    movapd xmm15, xmm0  ;# copy of rinv    	cvttsd2si r10d, xmm4	;# mm6 = lu idx 	cvtsi2sd xmm5, r10d	subsd xmm4, xmm5	movapd [rsp + nb330_eps], xmm4		shl   r10d, 2		;# idx *= 4 	mov  rsi, [rbp + nb330_VFtab]     	lea   r10, [r10 + r10*2]	;# idx*=3 (12 total now)     ;# load Coulomb and LJ table data in parallel        movapd xmm0,  [rsi + r10*8]        ;# Y1c F1c    movapd xmm4,  [rsi + r10*8 + 32]   ;# Y1d F1d    movapd xmm8,  [rsi + r10*8 + 64]   ;# Y1r F1r	movhlps xmm1, xmm0	movhlps xmm5, xmm4	movhlps xmm9, xmm8    movapd xmm2,  [rsi + r10*8 + 16]   ;# G1c H1c    movapd xmm6,  [rsi + r10*8 + 48]   ;# G1d H1d    movapd xmm10, [rsi + r10*8 + 80]   ;# G1r H1r	movhlps xmm3, xmm2	movhlps xmm7, xmm6	movhlps xmm11, xmm10    ;# table data ready. Coul in xmm0-xmm3 , disp in xmm4-xmm7 , rep. in xmm8-xmm11    movapd xmm12, [rsp + nb330_eps]        mulsd  xmm3, xmm12   ;# Heps    mulsd  xmm7, xmm12    mulsd  xmm11, xmm12    mulsd  xmm2, xmm12     ;# Geps    mulsd  xmm6, xmm12    mulsd  xmm10, xmm12    mulsd  xmm3, xmm12   ;# Heps2    mulsd  xmm7, xmm12    mulsd  xmm11, xmm12    addsd  xmm1, xmm2   ;# F+Geps    addsd  xmm5, xmm6    addsd  xmm9, xmm10     addsd  xmm1, xmm3   ;# F+Geps+Heps2 = Fp    addsd  xmm5, xmm7    addsd  xmm9, xmm11     addsd  xmm3, xmm3    ;# 2*Heps2    addsd  xmm7, xmm7    addsd  xmm11, xmm11    addsd  xmm3, xmm2    ;# 2*Heps2+Geps    addsd  xmm7, xmm6      addsd  xmm11, xmm10    addsd  xmm3, xmm1   ;# FF = Fp + 2*Heps2 + Geps    addsd  xmm7, xmm5    addsd  xmm11, xmm9    mulsd  xmm1, [rsp + nb330_eps]   ;# eps*Fp    mulsd  xmm5, [rsp + nb330_eps]    mulsd  xmm9, [rsp + nb330_eps]    addsd  xmm1, xmm0     ;# VV    addsd  xmm5, xmm4    addsd  xmm9, xmm8    mulsd  xmm1, [rsp + nb330_qq]   ;# VV*qq = vcoul    mulsd  xmm5, [rsp + nb330_c6]   ;# vnb6    mulsd  xmm9, [rsp + nb330_c12]   ;# vnb12    mulsd  xmm3, [rsp + nb330_qq]    ;# FF*qq = fij    mulsd  xmm7, [rsp + nb330_c6]   ;# fijD    mulsd  xmm11, [rsp + nb330_c12]   ;#fijR    ;# accumulate vctot    addsd  xmm1, [rsp + nb330_vctot]    movsd [rsp + nb330_vctot], xmm1    ;# accumulate Vvdwtot    addsd  xmm5, [rsp + nb330_Vvdwtot]    addsd  xmm5, xmm9    movsd [rsp + nb330_Vvdwtot], xmm5    xorpd  xmm9, xmm9        addsd  xmm3, xmm7    addsd  xmm3, xmm11    mulsd  xmm3, xmm15    mulsd  xmm3, [rsp + nb330_tsc]  ;# fscal        subsd  xmm9, xmm3    movapd xmm10, xmm9    movapd xmm11, xmm9        movapd xmm12, [rsp + nb330_fix]    movapd xmm13, [rsp + nb330_fiy]    movapd xmm14, [rsp + nb330_fiz]        mulsd  xmm9,  [rsp + nb330_dx]    mulsd  xmm10, [rsp + nb330_dy]    mulsd  xmm11, [rsp + nb330_dz]    ;# accumulate i forces    addsd xmm12, xmm9    addsd xmm13, xmm10    addsd xmm14, xmm11    movsd [rsp + nb330_fix], xmm12    movsd [rsp + nb330_fiy], xmm13    movsd [rsp + nb330_fiz], xmm14 	;# the fj's - start by accumulating forces from memory     mov rdi, [rbp + nb330_faction]	addsd xmm9,   [rdi + rax*8]	addsd xmm10,  [rdi + rax*8 + 8]	addsd xmm11,  [rdi + rax*8 + 16]	movsd [rdi + rax*8], xmm9	movsd [rdi + rax*8 + 8], xmm10	movsd [rdi + rax*8 + 16], xmm11	.nb330_updateouterdata:	mov   ecx, [rsp + nb330_ii3]	mov   rdi, [rbp + nb330_faction]	mov   rsi, [rbp + nb330_fshift]	mov   edx, [rsp + nb330_is3]	;# accumulate i forces in xmm0, xmm1, xmm2 	movapd xmm0, [rsp + nb330_fix]	movapd xmm1, [rsp + nb330_fiy]	movapd xmm2, [rsp + nb330_fiz]	movhlps xmm3, xmm0	movhlps xmm4, xmm1	movhlps xmm5, xmm2	addsd  xmm0, xmm3	addsd  xmm1, xmm4	addsd  xmm2, xmm5 ;# sum is in low xmm0-xmm2 	;# increment i force 	movsd  xmm3, [rdi + rcx*8]	movsd  xmm4, [rdi + rcx*8 + 8]	movsd  xmm5, [rdi + rcx*8 + 16]	subsd  xmm3, xmm0	subsd  xmm4, xmm1	subsd  xmm5, xmm2	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, xmm0	subsd  xmm4, xmm1	subsd  xmm5, xmm2	movsd  [rsi + rdx*8],     xmm3	movsd  [rsi + rdx*8 + 8], xmm4	movsd  [rsi + rdx*8 + 16], xmm5	;# get n from stack	mov esi, [rsp + nb330_n]        ;# get group index for i particle         mov   rdx, [rbp + nb330_gid]      	;# base of gid[]        mov   edx, [rdx + rsi*4]		;# ggid=gid[n]	;# accumulate total potential energy and update it 	movapd xmm7, [rsp + nb330_vctot]	;# accumulate 	movhlps xmm6, xmm7	addsd  xmm7, xmm6	;# low xmm7 has the sum now 	;# add earlier value from mem 	mov   rax, [rbp + nb330_Vc]	addsd xmm7, [rax + rdx*8] 	;# move back to mem 	movsd [rax + rdx*8], xmm7 		;# accumulate total lj energy and update it 	movapd xmm7, [rsp + nb330_Vvdwtot]	;# accumulate 	movhlps xmm6, xmm7	addsd  xmm7, xmm6	;# low xmm7 has the sum now 		;# add earlier value from mem 	mov   rax, [rbp + nb330_Vvdw]	addsd xmm7, [rax + rdx*8] 	;# move back to mem 	movsd [rax + rdx*8], xmm7 	        ;# finish if last         mov ecx, [rsp + nb330_nn1]	;# esi already loaded with n	inc esi        sub ecx, esi        jz .nb330_outerend        ;# not last, iterate outer loop once more!          mov [rsp + nb330_n], esi        jmp .nb330_outer.nb330_outerend:        ;# check if more outer neighborlists remain        mov   ecx, [rsp + nb330_nri]	;# esi already loaded with n above        sub   ecx, esi        jz .nb330_end        ;# non-zero, do one more workunit        jmp   .nb330_threadloop.nb330_end:	mov eax, [rsp + nb330_nouter]	mov ebx, [rsp + nb330_ninner]	mov rcx, [rbp + nb330_outeriter]	mov rdx, [rbp + nb330_inneriter]	mov [rcx], eax	mov [rdx], ebx	add rsp, 440	emms        pop r15        pop r14        pop r13        pop r12	pop rbx	pop	rbp	ret.globl nb_kernel330nf_x86_64_sse2.globl _nb_kernel330nf_x86_64_sse2nb_kernel330nf_x86_64_sse2:	_nb_kernel330nf_x86_64_sse2:	;#	Room for return address and rbp (16 bytes).equiv          nb330nf_fshift,         16.equiv          nb330nf_gid,            24.equiv          nb330nf_pos,            32.equiv          nb330nf_faction,        40.equiv          nb330nf_charge,         48.equiv          nb330nf_p_facel,        56.equiv          nb330nf_argkrf,         64.equiv          nb330nf_argcrf,         72.equiv          nb330nf_Vc,             80.equiv          nb330nf_type,           88.equiv          nb330nf_p_ntype,        96.equiv          nb330nf_vdwparam,       104.equiv          nb330nf_Vvdw,           112.equiv          nb330nf_p_tabscale,     120.equiv          nb330nf_VFtab,          128.equiv          nb330nf_invsqrta,       136.equiv          nb330nf_dvda,           144.equiv          nb330nf_p_gbtabscale,   152.equiv          nb330nf_GBtab,          160.equiv          nb330nf_p_nthreads,     168.equiv          nb330nf_count,          176.equiv          nb330nf_mtx,            184.equiv          nb330nf_outeriter,      192.equiv          nb330nf_inneriter,      200.equiv          nb330nf_work,           208	;# stack offsets for local variables  	;# bottom of stack is cache-aligned for sse use .equiv          nb330nf_ix,             0.equiv          nb330nf_iy,             16.equiv          nb330nf_iz,             32.equiv          nb330nf_iq,             48.equiv          nb330nf_tsc,            64.equiv          nb330nf_qq,             80.equiv          nb330nf_c6,             96.equiv          nb330nf_c12,            112.equiv          nb330nf_vctot,          128.equiv          nb330nf_Vvdwtot,        144.equiv          nb330nf_half,           160.equiv          nb330nf_three,          176.equiv          nb330nf_nri,            192.equiv          nb330nf_iinr,           200.equiv          nb330nf_jindex,         208.equiv          nb330nf_jjnr,           216.equiv          nb330nf_shift,          224.equiv          nb330nf_shiftvec,       232.equiv          nb330nf_facel,          240.equiv          nb330nf_innerjjnr,      248.equiv          nb330nf_is3,            256.equiv          nb330nf_ii3,            260.equiv          nb330nf_ntia,           264.equiv          nb330nf_innerk,         268.equiv          nb330nf_n,              272.equiv          nb330nf_nn1,            276.equiv          nb330nf_ntype,          280.equiv          nb330nf_nouter,         284.equiv          nb330nf_ninner,         288	push rbp	mov  rbp, rsp	push rbx	emms        push r12        push r13        push r14        push r15	sub rsp, 312		;# local variable stack space (n*16+8)	;# zero 32-bit iteration counters	mov eax, 0	mov [rsp + nb330nf_nouter], eax	mov [rsp + nb330nf_ninner], eax	mov edi, [rdi]	mov [rsp + nb330nf_nri], edi	mov [rsp + nb330nf_iinr], rsi	mov [rsp + nb330nf_jindex], rdx	mov [rsp + nb330nf_jjnr], rcx	mov [rsp + nb330nf_shift], r8	mov [rsp + nb330nf_shiftvec], r9	mov rdi, [rbp + nb330nf_p_ntype]	mov edi, [rdi]	mov [rsp + nb330nf_ntype], edi	mov rsi, [rbp + nb330nf_p_facel]	movsd xmm0, [rsi]	movsd [rsp + nb330nf_facel], xmm0	mov rax, [rbp + nb330nf_p_tabscale]	movsd xmm3, [rax]	shufpd xmm3, xmm3, 0	movapd [rsp + nb330nf_tsc], xmm3	;# create constant floating-point factors on stack	mov eax, 0x00000000     ;# lower half of double half IEEE (hex)	mov ebx, 0x3fe00000	mov [rsp + nb330nf_half], eax	mov [rsp + nb330nf_half+4], ebx	movsd xmm1, [rsp + nb330nf_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 + nb330nf_half], xmm1	movapd [rsp + nb330nf_three], xmm3.nb330nf_threadloop:        mov   rsi, [rbp + nb330nf_count]        ;# pointer to sync counter        mov   eax, [rsi].nb330nf_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 .nb330nf_spinlock        ;# if(nn1>nri) nn1=nri        mov ecx, [rsp + nb330nf_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 + nb330nf_n], eax        mov [rsp + nb330nf_nn1], ebx        sub ebx, eax                            ;# calc number of outer lists	mov esi, eax				;# copy n to esi        jg  .nb330nf_outerstart        jmp .nb330nf_end.nb330nf_outerstart:	;# ebx contains number of outer iterations	add ebx, [rsp + nb330nf_nouter]	mov [rsp + nb330nf_nouter], ebx.nb330nf_outer:	mov   rax, [rsp + nb330nf_shift]      ;# rax = pointer into shift[] 	mov   ebx, [rax + rsi*4]		;# rbx=shift[n] 		lea   rbx, [rbx + rbx*2]    ;# rbx=3*is 	mov   rax, [rsp + nb330nf_shiftvec]   ;# rax = base of shiftvec[] 	movsd xmm0, [rax + rbx*8]	movsd xmm1, [rax + rbx*8 + 8]	movsd xmm2, [rax + rbx*8 + 16] 	mov   rcx, [rsp + nb330nf_iinr]       ;# rcx = pointer into iinr[] 		mov   ebx, [rcx+rsi*4]	    ;# ebx =ii 	mov   rdx, [rbp + nb330nf_charge]	movsd xmm3, [rdx + rbx*8]		mulsd xmm3, [rsp + nb330nf_facel]	shufpd xmm3, xmm3, 0    	mov   rdx, [rbp + nb330nf_type]     	mov   edx, [rdx + rbx*4]    	imul  edx, [rsp + nb330nf_ntype]    	shl   edx, 1    	mov   [rsp + nb330nf_ntia], edx

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?