nb_kernel201_x86_64_sse2.s
来自「最著名最快的分子模拟软件」· S 代码 · 共 1,714 行 · 第 1/4 页
S
1,714 行
movl 4(%rdx),%ebx addq $8,nb201nf_innerjjnr(%rsp) ## advance pointer (unrolled 2) movq nb201nf_charge(%rbp),%rsi ## base of charge[] movlpd (%rsi,%rax,8),%xmm3 movhpd (%rsi,%rbx,8),%xmm3 movapd %xmm3,%xmm4 mulpd nb201nf_iqO(%rsp),%xmm3 mulpd nb201nf_iqH(%rsp),%xmm4 movapd %xmm3,nb201nf_qqO(%rsp) movapd %xmm4,nb201nf_qqH(%rsp) movq nb201nf_pos(%rbp),%rsi ## base of pos[] lea (%rax,%rax,2),%rax ## replace jnr with j3 lea (%rbx,%rbx,2),%rbx ## move two coordinates to xmm0-xmm2 movlpd (%rsi,%rax,8),%xmm0 movlpd 8(%rsi,%rax,8),%xmm1 movlpd 16(%rsi,%rax,8),%xmm2 movhpd (%rsi,%rbx,8),%xmm0 movhpd 8(%rsi,%rbx,8),%xmm1 movhpd 16(%rsi,%rbx,8),%xmm2 ## move ixO-izO to xmm4-xmm6 movapd nb201nf_ixO(%rsp),%xmm4 movapd nb201nf_iyO(%rsp),%xmm5 movapd nb201nf_izO(%rsp),%xmm6 ## calc dr subpd %xmm0,%xmm4 subpd %xmm1,%xmm5 subpd %xmm2,%xmm6 ## square it mulpd %xmm4,%xmm4 mulpd %xmm5,%xmm5 mulpd %xmm6,%xmm6 addpd %xmm5,%xmm4 addpd %xmm6,%xmm4 movapd %xmm4,%xmm7 ## rsqO in xmm7 ## move ixH1-izH1 to xmm4-xmm6 movapd nb201nf_ixH1(%rsp),%xmm4 movapd nb201nf_iyH1(%rsp),%xmm5 movapd nb201nf_izH1(%rsp),%xmm6 ## calc dr subpd %xmm0,%xmm4 subpd %xmm1,%xmm5 subpd %xmm2,%xmm6 ## square it mulpd %xmm4,%xmm4 mulpd %xmm5,%xmm5 mulpd %xmm6,%xmm6 addpd %xmm5,%xmm6 addpd %xmm4,%xmm6 ## rsqH1 in xmm6 ## move ixH2-izH2 to xmm3-xmm5 movapd nb201nf_ixH2(%rsp),%xmm3 movapd nb201nf_iyH2(%rsp),%xmm4 movapd nb201nf_izH2(%rsp),%xmm5 ## calc dr subpd %xmm0,%xmm3 subpd %xmm1,%xmm4 subpd %xmm2,%xmm5 ## square it mulpd %xmm3,%xmm3 mulpd %xmm4,%xmm4 mulpd %xmm5,%xmm5 addpd %xmm4,%xmm5 addpd %xmm3,%xmm5 ## rsqH2 in xmm5, rsqH1 in xmm6, rsqO in xmm7 movapd %xmm5,%xmm0 movapd %xmm6,%xmm1 movapd %xmm7,%xmm2 mulpd nb201nf_krf(%rsp),%xmm0 mulpd nb201nf_krf(%rsp),%xmm1 mulpd nb201nf_krf(%rsp),%xmm2 movapd %xmm0,nb201nf_krsqH2(%rsp) movapd %xmm1,nb201nf_krsqH1(%rsp) movapd %xmm2,nb201nf_krsqO(%rsp) ## start with rsqO - put seed in xmm2 cvtpd2ps %xmm7,%xmm2 rsqrtps %xmm2,%xmm2 cvtps2pd %xmm2,%xmm2 movapd %xmm2,%xmm3 mulpd %xmm2,%xmm2 movapd nb201nf_three(%rsp),%xmm4 mulpd %xmm7,%xmm2 ## rsq*lu*lu subpd %xmm2,%xmm4 ## 30-rsq*lu*lu mulpd %xmm3,%xmm4 ## lu*(3-rsq*lu*lu) mulpd nb201nf_half(%rsp),%xmm4 ## iter1 ( new lu) movapd %xmm4,%xmm3 mulpd %xmm4,%xmm4 ## lu*lu mulpd %xmm4,%xmm7 ## rsq*lu*lu movapd nb201nf_three(%rsp),%xmm4 subpd %xmm7,%xmm4 ## 3-rsq*lu*lu mulpd %xmm3,%xmm4 ## lu*( 3-rsq*lu*lu) mulpd nb201nf_half(%rsp),%xmm4 ## rinv movapd %xmm4,%xmm7 ## rinvO in xmm7 ## rsqH1 - seed in xmm2 cvtpd2ps %xmm6,%xmm2 rsqrtps %xmm2,%xmm2 cvtps2pd %xmm2,%xmm2 movapd %xmm2,%xmm3 mulpd %xmm2,%xmm2 movapd nb201nf_three(%rsp),%xmm4 mulpd %xmm6,%xmm2 ## rsq*lu*lu subpd %xmm2,%xmm4 ## 30-rsq*lu*lu mulpd %xmm3,%xmm4 ## lu*(3-rsq*lu*lu) mulpd nb201nf_half(%rsp),%xmm4 ## iter1 ( new lu) movapd %xmm4,%xmm3 mulpd %xmm4,%xmm4 ## lu*lu mulpd %xmm4,%xmm6 ## rsq*lu*lu movapd nb201nf_three(%rsp),%xmm4 subpd %xmm6,%xmm4 ## 3-rsq*lu*lu mulpd %xmm3,%xmm4 ## lu*( 3-rsq*lu*lu) mulpd nb201nf_half(%rsp),%xmm4 ## rinv movapd %xmm4,%xmm6 ## rinvH1 in xmm6 ## rsqH2 - seed in xmm2 cvtpd2ps %xmm5,%xmm2 rsqrtps %xmm2,%xmm2 cvtps2pd %xmm2,%xmm2 movapd %xmm2,%xmm3 mulpd %xmm2,%xmm2 movapd nb201nf_three(%rsp),%xmm4 mulpd %xmm5,%xmm2 ## rsq*lu*lu subpd %xmm2,%xmm4 ## 30-rsq*lu*lu mulpd %xmm3,%xmm4 ## lu*(3-rsq*lu*lu) mulpd nb201nf_half(%rsp),%xmm4 ## iter1 ( new lu) movapd %xmm4,%xmm3 mulpd %xmm4,%xmm4 ## lu*lu mulpd %xmm4,%xmm5 ## rsq*lu*lu movapd nb201nf_three(%rsp),%xmm4 subpd %xmm5,%xmm4 ## 3-rsq*lu*lu mulpd %xmm3,%xmm4 ## lu*( 3-rsq*lu*lu) mulpd nb201nf_half(%rsp),%xmm4 ## rinv movapd %xmm4,%xmm5 ## rinvH2 in xmm5 ## do O interactions movapd nb201nf_krsqO(%rsp),%xmm0 addpd %xmm0,%xmm7 ## xmm7=rinv+ krsq subpd nb201nf_crf(%rsp),%xmm7 mulpd nb201nf_qqO(%rsp),%xmm7 ## vcoul addpd nb201nf_vctot(%rsp),%xmm7 ## H1 interactions movapd nb201nf_krsqH1(%rsp),%xmm0 addpd %xmm0,%xmm6 ## xmm6=rinv+ krsq subpd nb201nf_crf(%rsp),%xmm6 mulpd nb201nf_qqH(%rsp),%xmm6 ## vcoul addpd %xmm7,%xmm6 ## H2 interactions movapd nb201nf_krsqH2(%rsp),%xmm0 addpd %xmm0,%xmm5 ## xmm5=rinv+ krsq subpd nb201nf_crf(%rsp),%xmm5 mulpd nb201nf_qqH(%rsp),%xmm5 ## vcoul addpd %xmm6,%xmm5 movapd %xmm5,nb201nf_vctot(%rsp) ## should we do one more iteration? subl $2,nb201nf_innerk(%rsp) jl _nb_kernel201nf_x86_64_sse2.nb201nf_checksingle jmp _nb_kernel201nf_x86_64_sse2.nb201nf_unroll_loop_nb_kernel201nf_x86_64_sse2.nb201nf_checksingle: movl nb201nf_innerk(%rsp),%edx andl $1,%edx jnz _nb_kernel201nf_x86_64_sse2.nb201nf_dosingle jmp _nb_kernel201nf_x86_64_sse2.nb201nf_updateouterdata_nb_kernel201nf_x86_64_sse2.nb201nf_dosingle: movq nb201nf_innerjjnr(%rsp),%rdx ## pointer to jjnr[k] movl (%rdx),%eax addq $4,nb201nf_innerjjnr(%rsp) movq nb201nf_charge(%rbp),%rsi ## base of charge[] xorpd %xmm3,%xmm3 movlpd (%rsi,%rax,8),%xmm3 movapd %xmm3,%xmm4 mulpd nb201nf_iqO(%rsp),%xmm3 mulpd nb201nf_iqH(%rsp),%xmm4 movapd %xmm3,nb201nf_qqO(%rsp) movapd %xmm4,nb201nf_qqH(%rsp) movq nb201nf_pos(%rbp),%rsi ## base of pos[] lea (%rax,%rax,2),%rax ## replace jnr with j3 ## move coordinates to xmm0-xmm2 movlpd (%rsi,%rax,8),%xmm0 movlpd 8(%rsi,%rax,8),%xmm1 movlpd 16(%rsi,%rax,8),%xmm2 ## move ixO-izO to xmm4-xmm6 movapd nb201nf_ixO(%rsp),%xmm4 movapd nb201nf_iyO(%rsp),%xmm5 movapd nb201nf_izO(%rsp),%xmm6 ## calc dr subsd %xmm0,%xmm4 subsd %xmm1,%xmm5 subsd %xmm2,%xmm6 ## square it mulsd %xmm4,%xmm4 mulsd %xmm5,%xmm5 mulsd %xmm6,%xmm6 addsd %xmm5,%xmm4 addsd %xmm6,%xmm4 movapd %xmm4,%xmm7 ## rsqO in xmm7 ## move ixH1-izH1 to xmm4-xmm6 movapd nb201nf_ixH1(%rsp),%xmm4 movapd nb201nf_iyH1(%rsp),%xmm5 movapd nb201nf_izH1(%rsp),%xmm6 ## calc dr subsd %xmm0,%xmm4 subsd %xmm1,%xmm5 subsd %xmm2,%xmm6 ## square it mulsd %xmm4,%xmm4 mulsd %xmm5,%xmm5 mulsd %xmm6,%xmm6 addsd %xmm5,%xmm6 addsd %xmm4,%xmm6 ## rsqH1 in xmm6 ## move ixH2-izH2 to xmm3-xmm5 movapd nb201nf_ixH2(%rsp),%xmm3 movapd nb201nf_iyH2(%rsp),%xmm4 movapd nb201nf_izH2(%rsp),%xmm5 ## calc dr subsd %xmm0,%xmm3 subsd %xmm1,%xmm4 subsd %xmm2,%xmm5 ## square it mulsd %xmm3,%xmm3 mulsd %xmm4,%xmm4 mulsd %xmm5,%xmm5 addsd %xmm4,%xmm5 addsd %xmm3,%xmm5 ## rsqH2 in xmm5, rsqH1 in xmm6, rsqO in xmm7 movapd %xmm5,%xmm0 movapd %xmm6,%xmm1 movapd %xmm7,%xmm2 mulsd nb201nf_krf(%rsp),%xmm0 mulsd nb201nf_krf(%rsp),%xmm1 mulsd nb201nf_krf(%rsp),%xmm2 movapd %xmm0,nb201nf_krsqH2(%rsp) movapd %xmm1,nb201nf_krsqH1(%rsp) movapd %xmm2,nb201nf_krsqO(%rsp) ## start with rsqO - put seed in xmm2 cvtsd2ss %xmm7,%xmm2 rsqrtss %xmm2,%xmm2 cvtss2sd %xmm2,%xmm2 movapd %xmm2,%xmm3 mulsd %xmm2,%xmm2 movapd nb201nf_three(%rsp),%xmm4 mulsd %xmm7,%xmm2 ## rsq*lu*lu subsd %xmm2,%xmm4 ## 30-rsq*lu*lu mulsd %xmm3,%xmm4 ## lu*(3-rsq*lu*lu) mulsd nb201nf_half(%rsp),%xmm4 ## iter1 ( new lu) movapd %xmm4,%xmm3 mulsd %xmm4,%xmm4 ## lu*lu mulsd %xmm4,%xmm7 ## rsq*lu*lu movapd nb201nf_three(%rsp),%xmm4 subsd %xmm7,%xmm4 ## 3-rsq*lu*lu mulsd %xmm3,%xmm4 ## lu*( 3-rsq*lu*lu) mulsd nb201nf_half(%rsp),%xmm4 ## rinv movapd %xmm4,%xmm7 ## rinvO in xmm7 ## rsqH1 - seed in xmm2 cvtsd2ss %xmm6,%xmm2 rsqrtss %xmm2,%xmm2 cvtss2sd %xmm2,%xmm2 movapd %xmm2,%xmm3 mulsd %xmm2,%xmm2 movapd nb201nf_three(%rsp),%xmm4 mulsd %xmm6,%xmm2 ## rsq*lu*lu subsd %xmm2,%xmm4 ## 30-rsq*lu*lu mulsd %xmm3,%xmm4 ## lu*(3-rsq*lu*lu) mulsd nb201nf_half(%rsp),%xmm4 ## iter1 ( new lu) movapd %xmm4,%xmm3 mulsd %xmm4,%xmm4 ## lu*lu mulsd %xmm4,%xmm6 ## rsq*lu*lu movapd nb201nf_three(%rsp),%xmm4 subsd %xmm6,%xmm4 ## 3-rsq*lu*lu mulsd %xmm3,%xmm4 ## lu*( 3-rsq*lu*lu) mulsd nb201nf_half(%rsp),%xmm4 ## rinv movapd %xmm4,%xmm6 ## rinvH1 in xmm6 ## rsqH2 - seed in xmm2 cvtsd2ss %xmm5,%xmm2 rsqrtss %xmm2,%xmm2 cvtss2sd %xmm2,%xmm2 movapd %xmm2,%xmm3 mulsd %xmm2,%xmm2 movapd nb201nf_three(%rsp),%xmm4 mulsd %xmm5,%xmm2 ## rsq*lu*lu subsd %xmm2,%xmm4 ## 30-rsq*lu*lu mulsd %xmm3,%xmm4 ## lu*(3-rsq*lu*lu) mulsd nb201nf_half(%rsp),%xmm4 ## iter1 ( new lu) movapd %xmm4,%xmm3 mulsd %xmm4,%xmm4 ## lu*lu mulsd %xmm4,%xmm5 ## rsq*lu*lu movapd nb201nf_three(%rsp),%xmm4 subsd %xmm5,%xmm4 ## 3-rsq*lu*lu mulsd %xmm3,%xmm4 ## lu*( 3-rsq*lu*lu) mulsd nb201nf_half(%rsp),%xmm4 ## rinv movapd %xmm4,%xmm5 ## rinvH2 in xmm5 ## do O interactions movapd nb201nf_krsqO(%rsp),%xmm0 addsd %xmm0,%xmm7 ## xmm7=rinv+ krsq subsd nb201nf_crf(%rsp),%xmm7 mulsd nb201nf_qqO(%rsp),%xmm7 ## vcoul addsd nb201nf_vctot(%rsp),%xmm7 ## H1 interactions movapd nb201nf_krsqH1(%rsp),%xmm0 addsd %xmm0,%xmm6 ## xmm6=rinv+ krsq subsd nb201nf_crf(%rsp),%xmm6 mulsd nb201nf_qqH(%rsp),%xmm6 ## vcoul addsd %xmm7,%xmm6 ## H2 interactions movapd nb201nf_krsqH2(%rsp),%xmm0 addsd %xmm0,%xmm5 ## xmm5=rinv+ krsq subsd nb201nf_crf(%rsp),%xmm5 mulsd nb201nf_qqH(%rsp),%xmm5 ## vcoul addsd %xmm6,%xmm5 movlpd %xmm5,nb201nf_vctot(%rsp)_nb_kernel201nf_x86_64_sse2.nb201nf_updateouterdata: ## get n from stack movl nb201nf_n(%rsp),%esi ## get group index for i particle movq nb201nf_gid(%rbp),%rdx ## base of gid[] movl (%rdx,%rsi,4),%edx ## ggid=gid[n] ## accumulate total potential energy and update it movapd nb201nf_vctot(%rsp),%xmm7 ## accumulate movhlps %xmm7,%xmm6 addsd %xmm6,%xmm7 ## low xmm7 has the sum now ## add earlier value from mem movq nb201nf_Vc(%rbp),%rax addsd (%rax,%rdx,8),%xmm7 ## move back to mem movsd %xmm7,(%rax,%rdx,8) ## finish if last movl nb201nf_nn1(%rsp),%ecx ## esi already loaded with n incl %esi subl %esi,%ecx jz _nb_kernel201nf_x86_64_sse2.nb201nf_outerend ## not last, iterate outer loop once more! movl %esi,nb201nf_n(%rsp) jmp _nb_kernel201nf_x86_64_sse2.nb201nf_outer_nb_kernel201nf_x86_64_sse2.nb201nf_outerend: ## check if more outer neighborlists remain movl nb201nf_nri(%rsp),%ecx ## esi already loaded with n above subl %esi,%ecx jz _nb_kernel201nf_x86_64_sse2.nb201nf_end ## non-zero, do one more workunit jmp _nb_kernel201nf_x86_64_sse2.nb201nf_threadloop_nb_kernel201nf_x86_64_sse2.nb201nf_end: movl nb201nf_nouter(%rsp),%eax movl nb201nf_ninner(%rsp),%ebx movq nb201nf_outeriter(%rbp),%rcx movq nb201nf_inneriter(%rbp),%rdx movl %eax,(%rcx) movl %ebx,(%rdx) addq $440,%rsp emms pop %r15 pop %r14 pop %r13 pop %r12 pop %rbx pop %rbp ret
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?