nb_kernel303_x86_64_sse.intel_syntax.s
来自「最著名最快的分子模拟软件」· S 代码 · 共 1,943 行 · 第 1/4 页
S
1,943 行
;#;# $Id: nb_kernel303_x86_64_sse.intel_syntax.s,v 1.1.2.2 2006/09/22 08:32:50 lindahl Exp $;#;# Gromacs 4.0 Copyright (c) 1991-2003 ;# David van der Spoel, Erik Lindahl;#;# This program is free software; you can redistribute it and/or;# modify it under the terms of the GNU General Public License;# as published by the Free Software Foundation; either version 2;# of the License, or (at your option) any later version.;#;# To help us fund GROMACS development, we humbly ask that you cite;# the research papers on the package. Check out http://www.gromacs.org;# ;# And Hey:;# Gnomes, ROck Monsters And Chili Sauce;#;# These files require GNU binutils 2.10 or later, since we;# use intel syntax for portability, or a recent version ;# of NASM that understands Extended 3DNow and SSE2 instructions.;# (NASM is normally only used with MS Visual C++).;# Since NASM and gnu as disagree on some definitions and use ;# completely different preprocessing options I have to introduce a;# trick: NASM uses ';' for comments, while gnu as uses '#' on x86.;# Gnu as treats ';' as a line break, i.e. ignores it. This is the;# reason why all comments need both symbols...;# The source is written for GNU as, with intel syntax. When you use;# NASM we redefine a couple of things. The false if-statement around ;# the following code is seen by GNU as, but NASM doesn't see it, so ;# the code inside is read by NASM but not gcc.; .if 0 # block below only read by NASM%define .section section%define .long dd%define .align align%define .globl global;# NASM only wants 'dword', not 'dword ptr'.%define ptr.equiv .equiv 2 %1 equ %2%endmacro; .endif # End of NASM-specific block; .intel_syntax noprefix # Line only read by gnu as.globl nb_kernel303_x86_64_sse.globl _nb_kernel303_x86_64_ssenb_kernel303_x86_64_sse: _nb_kernel303_x86_64_sse: ;# Room for return address and rbp (16 bytes).equiv nb303_fshift, 16.equiv nb303_gid, 24.equiv nb303_pos, 32.equiv nb303_faction, 40.equiv nb303_charge, 48.equiv nb303_p_facel, 56.equiv nb303_argkrf, 64.equiv nb303_argcrf, 72.equiv nb303_Vc, 80.equiv nb303_type, 88.equiv nb303_p_ntype, 96.equiv nb303_vdwparam, 104.equiv nb303_Vvdw, 112.equiv nb303_p_tabscale, 120.equiv nb303_VFtab, 128.equiv nb303_invsqrta, 136.equiv nb303_dvda, 144.equiv nb303_p_gbtabscale, 152.equiv nb303_GBtab, 160.equiv nb303_p_nthreads, 168.equiv nb303_count, 176.equiv nb303_mtx, 184.equiv nb303_outeriter, 192.equiv nb303_inneriter, 200.equiv nb303_work, 208 ;# stack offsets for local variables ;# bottom of stack is cache-aligned for sse use .equiv nb303_ixH1, 0.equiv nb303_iyH1, 16.equiv nb303_izH1, 32.equiv nb303_ixH2, 48.equiv nb303_iyH2, 64.equiv nb303_izH2, 80.equiv nb303_ixM, 96.equiv nb303_iyM, 112.equiv nb303_izM, 128.equiv nb303_iqH, 144.equiv nb303_iqM, 160.equiv nb303_dxH1, 176.equiv nb303_dyH1, 192.equiv nb303_dzH1, 208.equiv nb303_dxH2, 224.equiv nb303_dyH2, 240.equiv nb303_dzH2, 256.equiv nb303_dxM, 272.equiv nb303_dyM, 288.equiv nb303_dzM, 304.equiv nb303_qqH, 320.equiv nb303_qqM, 336.equiv nb303_rinvH1, 352.equiv nb303_rinvH2, 368.equiv nb303_rinvM, 384.equiv nb303_rH1, 400.equiv nb303_rH2, 416.equiv nb303_rM, 432.equiv nb303_tsc, 448.equiv nb303_two, 464.equiv nb303_vctot, 480.equiv nb303_fixH1, 496.equiv nb303_fiyH1, 512.equiv nb303_fizH1, 528.equiv nb303_fixH2, 544.equiv nb303_fiyH2, 560.equiv nb303_fizH2, 576.equiv nb303_fixM, 592.equiv nb303_fiyM, 608.equiv nb303_fizM, 624.equiv nb303_epsH1, 640.equiv nb303_epsH2, 656.equiv nb303_epsM, 672.equiv nb303_half, 688.equiv nb303_three, 704.equiv nb303_is3, 720.equiv nb303_ii3, 724.equiv nb303_nri, 728.equiv nb303_iinr, 736.equiv nb303_jindex, 744.equiv nb303_jjnr, 752.equiv nb303_shift, 760.equiv nb303_shiftvec, 768.equiv nb303_facel, 776.equiv nb303_innerjjnr, 784.equiv nb303_innerk, 792.equiv nb303_n, 796.equiv nb303_nn1, 800.equiv nb303_nouter, 804.equiv nb303_ninner, 808 push rbp mov rbp, rsp push rbx push r12 push r13 push r14 push r15 sub rsp, 824 ;# local variable stack space (n*16+8) emms ;# zero 32-bit iteration counters mov eax, 0 mov [rsp + nb303_nouter], eax mov [rsp + nb303_ninner], eax mov edi, [rdi] mov [rsp + nb303_nri], edi mov [rsp + nb303_iinr], rsi mov [rsp + nb303_jindex], rdx mov [rsp + nb303_jjnr], rcx mov [rsp + nb303_shift], r8 mov [rsp + nb303_shiftvec], r9 mov rsi, [rbp + nb303_p_facel] movss xmm0, [rsi] movss [rsp + nb303_facel], xmm0 mov rax, [rbp + nb303_p_tabscale] movss xmm3, [rax] shufps xmm3, xmm3, 0 movaps [rsp + nb303_tsc], xmm3 ;# create constant floating-point factors on stack mov eax, 0x3f000000 ;# half in IEEE (hex) mov [rsp + nb303_half], eax movss xmm1, [rsp + nb303_half] shufps xmm1, xmm1, 0 ;# splat to all elements movaps xmm2, xmm1 addps xmm2, xmm2 ;# one movaps xmm3, xmm2 addps xmm2, xmm2 ;# two addps xmm3, xmm2 ;# three movaps [rsp + nb303_half], xmm1 movaps [rsp + nb303_two], xmm2 movaps [rsp + nb303_three], xmm3 ;# assume we have at least one i particle - start directly mov rcx, [rsp + nb303_iinr] ;# rcx = pointer into iinr[] mov ebx, [rcx] ;# ebx =ii mov rdx, [rbp + nb303_charge] movss xmm3, [rdx + rbx*4 + 4] movss xmm4, [rdx + rbx*4 + 12] mov rsi, [rbp + nb303_p_facel] movss xmm0, [rsi] movss xmm5, [rsp + nb303_facel] mulss xmm3, xmm5 mulss xmm4, xmm5 shufps xmm3, xmm3, 0 shufps xmm4, xmm4, 0 movaps [rsp + nb303_iqH], xmm3 movaps [rsp + nb303_iqM], xmm4 .nb303_threadloop: mov rsi, [rbp + nb303_count] ;# pointer to sync counter mov eax, [rsi].nb303_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 .nb303_spinlock ;# if(nn1>nri) nn1=nri mov ecx, [rsp + nb303_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 + nb303_n], eax mov [rsp + nb303_nn1], ebx sub ebx, eax ;# calc number of outer lists mov esi, eax ;# copy n to esi jg .nb303_outerstart jmp .nb303_end .nb303_outerstart: ;# ebx contains number of outer iterations add ebx, [rsp + nb303_nouter] mov [rsp + nb303_nouter], ebx.nb303_outer: mov rax, [rsp + nb303_shift] ;# rax = pointer into shift[] mov ebx, [rax + rsi*4] ;# rbx=shift[n] lea rbx, [rbx + rbx*2] ;# rbx=3*is mov [rsp + nb303_is3],ebx ;# store is3 mov rax, [rsp + nb303_shiftvec] ;# rax = base of shiftvec[] movss xmm0, [rax + rbx*4] movss xmm1, [rax + rbx*4 + 4] movss xmm2, [rax + rbx*4 + 8] mov rcx, [rsp + nb303_iinr] ;# rcx = pointer into iinr[] mov ebx, [rcx + rsi*4] ;# ebx =ii movaps xmm3, xmm0 movaps xmm4, xmm1 movaps xmm5, xmm2 lea rbx, [rbx + rbx*2] ;# rbx = 3*ii=ii3 mov rax, [rbp + nb303_pos] ;# rax = base of pos[] mov [rsp + nb303_ii3], ebx addss xmm3, [rax + rbx*4 + 12] addss xmm4, [rax + rbx*4 + 16] addss xmm5, [rax + rbx*4 + 20] shufps xmm3, xmm3, 0 shufps xmm4, xmm4, 0 shufps xmm5, xmm5, 0 movaps [rsp + nb303_ixH1], xmm3 movaps [rsp + nb303_iyH1], xmm4 movaps [rsp + nb303_izH1], xmm5 movss xmm3, xmm0 movss xmm4, xmm1 movss xmm5, xmm2 addss xmm0, [rax + rbx*4 + 24] addss xmm1, [rax + rbx*4 + 28] addss xmm2, [rax + rbx*4 + 32] addss xmm3, [rax + rbx*4 + 36] addss xmm4, [rax + rbx*4 + 40] addss xmm5, [rax + rbx*4 + 44] shufps xmm0, xmm0, 0 shufps xmm1, xmm1, 0 shufps xmm2, xmm2, 0 shufps xmm3, xmm3, 0 shufps xmm4, xmm4, 0 shufps xmm5, xmm5, 0 movaps [rsp + nb303_ixH2], xmm0 movaps [rsp + nb303_iyH2], xmm1 movaps [rsp + nb303_izH2], xmm2 movaps [rsp + nb303_ixM], xmm3 movaps [rsp + nb303_iyM], xmm4 movaps [rsp + nb303_izM], xmm5 ;# clear vctot and i forces xorps xmm4, xmm4 movaps [rsp + nb303_vctot], xmm4 movaps [rsp + nb303_fixH1], xmm4 movaps [rsp + nb303_fiyH1], xmm4 movaps [rsp + nb303_fizH1], xmm4 movaps [rsp + nb303_fixH2], xmm4 movaps [rsp + nb303_fiyH2], xmm4 movaps [rsp + nb303_fizH2], xmm4 movaps [rsp + nb303_fixM], xmm4 movaps [rsp + nb303_fiyM], xmm4 movaps [rsp + nb303_fizM], xmm4 mov rax, [rsp + nb303_jindex] mov ecx, [rax + rsi*4] ;# jindex[n] mov edx, [rax + rsi*4 + 4] ;# jindex[n+1] sub edx, ecx ;# number of innerloop atoms mov rsi, [rbp + nb303_pos] mov rdi, [rbp + nb303_faction] mov rax, [rsp + nb303_jjnr] shl ecx, 2 add rax, rcx mov [rsp + nb303_innerjjnr], rax ;# pointer to jjnr[nj0] mov ecx, edx sub edx, 4 add ecx, [rsp + nb303_ninner] mov [rsp + nb303_ninner], ecx add edx, 0 mov [rsp + nb303_innerk], edx ;# number of innerloop atoms jge .nb303_unroll_loop jmp .nb303_odd_inner.nb303_unroll_loop: ;# quad-unroll innerloop here mov rdx, [rsp + nb303_innerjjnr] ;# pointer to jjnr[k] mov eax, [rdx] mov ebx, [rdx + 4] mov ecx, [rdx + 8] mov edx, [rdx + 12] ;# eax-edx=jnr1-4 add qword ptr [rsp + nb303_innerjjnr], 16 ;# advance pointer (unrolled 4) mov rsi, [rbp + nb303_charge] ;# base of charge[] movss xmm3, [rsi + rax*4] movss xmm4, [rsi + rcx*4] movss xmm6, [rsi + rbx*4] movss xmm7, [rsi + rdx*4] shufps xmm3, xmm6, 0 shufps xmm4, xmm7, 0 shufps xmm3, xmm4, 136 ;# 10001000 ;# all charges in xmm3 movaps xmm4, xmm3 ;# and in xmm4 mulps xmm3, [rsp + nb303_iqH] mulps xmm4, [rsp + nb303_iqM] movaps [rsp + nb303_qqH], xmm3 movaps [rsp + nb303_qqM], xmm4 mov rsi, [rbp + nb303_pos] ;# base of pos[] lea rax, [rax + rax*2] ;# replace jnr with j3 lea rbx, [rbx + rbx*2] lea rcx, [rcx + rcx*2] lea rdx, [rdx + rdx*2] ;# move four coordinates to xmm0-xmm2 movlps xmm4, [rsi + rax*4] movlps xmm5, [rsi + rcx*4] movss xmm2, [rsi + rax*4 + 8] movss xmm6, [rsi + rcx*4 + 8] movhps xmm4, [rsi + rbx*4] movhps xmm5, [rsi + rdx*4] movss xmm0, [rsi + rbx*4 + 8] movss xmm1, [rsi + rdx*4 + 8] shufps xmm2, xmm0, 0 shufps xmm6, xmm1, 0 movaps xmm0, xmm4 movaps xmm1, xmm4 shufps xmm2, xmm6, 136 ;# 10001000 shufps xmm0, xmm5, 136 ;# 10001000 shufps xmm1, xmm5, 221 ;# 11011101 ;# xmm0 = jx ;# xmm1 = jy ;# xmm2 = jz movaps xmm3, xmm0 movaps xmm4, xmm1 movaps xmm5, xmm2 movaps xmm6, xmm0 movaps xmm7, xmm1 movaps xmm8, xmm2 subps xmm0, [rsp + nb303_ixH1] subps xmm1, [rsp + nb303_iyH1] subps xmm2, [rsp + nb303_izH1] subps xmm3, [rsp + nb303_ixH2] subps xmm4, [rsp + nb303_iyH2] subps xmm5, [rsp + nb303_izH2] subps xmm6, [rsp + nb303_ixM] subps xmm7, [rsp + nb303_iyM] subps xmm8, [rsp + nb303_izM] movd mm0, eax ;# use mmx registers as temp storage movd mm1, ebx movd mm2, ecx movd mm3, edx movaps [rsp + nb303_dxH1], xmm0 movaps [rsp + nb303_dyH1], xmm1 movaps [rsp + nb303_dzH1], xmm2 mulps xmm0, xmm0 mulps xmm1, xmm1 mulps xmm2, xmm2 movaps [rsp + nb303_dxH2], xmm3 movaps [rsp + nb303_dyH2], xmm4 movaps [rsp + nb303_dzH2], xmm5 mulps xmm3, xmm3 mulps xmm4, xmm4 mulps xmm5, xmm5 movaps [rsp + nb303_dxM], xmm6 movaps [rsp + nb303_dyM], xmm7 movaps [rsp + nb303_dzM], xmm8 mulps xmm6, xmm6 mulps xmm7, xmm7 mulps xmm8, xmm8 addps xmm0, xmm1 addps xmm0, xmm2 addps xmm3, xmm4 addps xmm3, xmm5 addps xmm6, xmm7 addps xmm6, xmm8 ;# start doing invsqrt for j atoms rsqrtps xmm1, xmm0 rsqrtps xmm4, xmm3 rsqrtps xmm7, xmm6 movaps xmm2, xmm1 movaps xmm5, xmm4 movaps xmm8, xmm7 mulps xmm1, xmm1 ;# lu*lu mulps xmm4, xmm4 ;# lu*lu mulps xmm7, xmm7 ;# lu*lu movaps xmm9, [rsp + nb303_three] movaps xmm10, xmm9 movaps xmm11, xmm9 mulps xmm1, xmm0 ;# rsq*lu*lu mulps xmm4, xmm3 ;# rsq*lu*lu mulps xmm7, xmm6 ;# rsq*lu*lu subps xmm9, xmm1 subps xmm10, xmm4 subps xmm11, xmm7 ;# 3-rsq*lu*lu mulps xmm9, xmm2 mulps xmm10, xmm5 mulps xmm11, xmm8 ;# lu*(3-rsq*lu*lu) movaps xmm4, [rsp + nb303_half] mulps xmm9, xmm4 ;# rinvH1 mulps xmm10, xmm4 ;# rinvH2 mulps xmm11, xmm4 ;# rinvM movaps [rsp + nb303_rinvH1], xmm9 movaps [rsp + nb303_rinvH2], xmm10 movaps [rsp + nb303_rinvM], xmm11 ;# interactions ;# rsq in xmm0,xmm3,xmm6 ;# rinv in xmm9, xmm10, xmm11 movaps xmm1, [rsp + nb303_tsc] mulps xmm0, xmm9 ;# r mulps xmm3, xmm10 mulps xmm6, xmm11 mulps xmm0, xmm1 ;# rtab mulps xmm3, xmm1 mulps xmm6, xmm1
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?