x86/x86_64的一些基本概念

來源:互聯網
上載者:User

標籤:

本人在構建boost的時候,從"Start Menu" -> "Programs" -> "Visual Studio 2015" -> "Visual Studio Tools" -> "Windows Desktop Command Prompts":
    VS2015 x64 ARM Cross Tools Command Prompt.lnk
    VS2015 x64 Native Tools Command Prompt.lnk
    VS2015 x64 x86 Cross Tools Command Prompt.lnk
    VS2015 x86 ARM Cross Tools Command Prompt.lnk
    VS2015 x86 Native Tools Command Prompt.lnk
    VS2015 x86 x64 Cross Tools Command Prompt.lnk
開始鬱悶於
    VS2015 x64 Native Tools Command Prompt.lnk
    VS2015 x64 x86 Cross Tools Command Prompt.lnk
此兩者的區別。

區別在這裡
    %comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"" amd64
    %comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"" amd64_x86

而vcvarsall.bat內容如下

    @echo off    if "%1" == "" goto x86    if "%2" == "" goto check_platform    if not "%2" == "store" goto usage    :check_platform    if /i %1 == x86       goto x86    if /i %1 == amd64     goto amd64    if /i %1 == x64       goto amd64    if /i %1 == arm       goto arm    if /i %1 == x86_arm   goto x86_arm    if /i %1 == x86_amd64 goto x86_amd64    if /i %1 == amd64_x86 goto amd64_x86    if /i %1 == amd64_arm goto amd64_arm    goto usage    :x86    if not exist "%~dp0bin\vcvars32.bat" goto missing    call "%~dp0bin\vcvars32.bat" %2    goto :SetVisualStudioVersion    :amd64    if not exist "%~dp0bin\amd64\vcvars64.bat" goto missing    call "%~dp0bin\amd64\vcvars64.bat" %2    goto :SetVisualStudioVersion    :arm    if not exist "%~dp0bin\arm\vcvarsarm.bat" goto missing    call "%~dp0bin\arm\vcvarsarm.bat" %2    goto :SetVisualStudioVersion    :x86_amd64    if not exist "%~dp0bin\x86_amd64\vcvarsx86_amd64.bat" goto missing    call "%~dp0bin\x86_amd64\vcvarsx86_amd64.bat" %2    goto :SetVisualStudioVersion    :x86_arm    if not exist "%~dp0bin\x86_arm\vcvarsx86_arm.bat" goto missing    call "%~dp0bin\x86_arm\vcvarsx86_arm.bat" %2    goto :SetVisualStudioVersion    :amd64_x86    if not exist "%~dp0bin\amd64_x86\vcvarsamd64_x86.bat" goto missing    call "%~dp0bin\amd64_x86\vcvarsamd64_x86.bat" %2    goto :SetVisualStudioVersion    :amd64_arm    if not exist "%~dp0bin\amd64_arm\vcvarsamd64_arm.bat" goto missing    call "%~dp0bin\amd64_arm\vcvarsamd64_arm.bat" %2    goto :SetVisualStudioVersion    :SetVisualStudioVersion    set VisualStudioVersion=14.0    goto :eof    :usage    echo Error in script usage. The correct usage is:    echo     %0 [option]    echo   or    echo     %0 [option] store    echo where [option] is: x86 ^| amd64 ^| arm ^| x86_amd64 ^| x86_arm ^| amd64_x86 ^| amd64_arm    echo:    echo The store parameter sets environment variables to support    echo   store (rather than desktop) development.    echo:    echo For example:    echo     %0 x86_amd64    echo     %0 x86_arm store    goto :eof    :missing    echo The specified configuration type is missing.  The tools for the    echo configuration might not be installed.    goto :eof

也就是說,區別在於

    :x86_amd64    if not exist "%~dp0bin\x86_amd64\vcvarsx86_amd64.bat" goto missing    call "%~dp0bin\x86_amd64\vcvarsx86_amd64.bat" %2    goto :SetVisualStudioVersion


    :amd64_x86    if not exist "%~dp0bin\amd64_x86\vcvarsamd64_x86.bat" goto missing    call "%~dp0bin\amd64_x86\vcvarsamd64_x86.bat" %2    goto :SetVisualStudioVersion

之間

亦即
    x86_amd64\vcvarsx86_amd64.bat

    amd64_x86\vcvarsamd64_x86.bat
之間的區別

用beyond compare比較它兩,差不多兩百行的指令碼比較,我就傻在這裡了 ...

然後我查有關電腦體系架構的資料,有太多似是而非或者聊當放屁的“文章”,而以下一文對我有些許協助:

現在的x86 CPU在位元上有32/64bit之分,在ARCH上有又x86/x86_64/x64/i386/IA32/IA64/amd64,最近又新出來一個x32,還好不是ARCH,只是ABI,沒有那麼混亂。


先說一下x86的這些arch,不要求很嚴格的話,基本上可以用下面的公式來表達:

x86=i386=IA32

amd64=x86_64=x64!=IA64

其實這兩個等式裡很多都是別名,嚴格說的話,x86的世界裡只存在x86/x86_64/IA64三種架構。

當年AMD先於Intel推出向下相容的amd64 CPU,而Intel推出的不相容32位系統的IA64慘淡收場(被MS放了鴿子),後來Intel在指令上支援了amd64,不過不願意叫amd64,改了個名字x86_64。


再說64bit/32bit的相容性問題:

現在的64bit CPU實際上都做了相容32bit的特殊設計,所以64bit的CPU上運行32bit的軟體(包括kernel/app, driver除外)是沒有問題。反過來,32bit的CPU上運行64bit的軟體是不可以的。


最後說重點,64bit相比32bit的效能優勢:

這裡不考慮64bit硬體上運行32bit軟體的這種過度方式。

從架構上來說,64bit擁有64bit 的register和64bit的bus,在資料轉送效率上比32bit要高不少;另外,64bit地址匯流排的定址空間突破了4G的限制。

所以,對於大記憶體,密集資料運算的應用情境,64bit的優勢是非常明顯的。網上有一些benchmark,這裡不貼了。


但是,對於小記憶體系統,64bit的CPU在某些狀況下可能比32bit CPU的效率更低。

因為64 bit的CPU的地址是64位的,指標是64位的,編譯產生的二進位檔案更大,運行時佔用的記憶體更多;另一方面,因為64位地址的問題,cache中能存放的指令就更少,所以更容易導致cache的miss。


所以在某些應用情境,64 bitCPU的更大的定址空間,更快的資料傳遞,更快的浮點運算的特性, 與其64 bit的地址/指標所導致的cache miss的特性,始終並存。


為了充分利用64的優勢,又避免64bit地址導致的cache miss的問題,Intel提出了x32 ABI的概念。

x32不是一個ARCH,是一個ABI。

x32可以充分的使用64 bit硬體的64 bit寄存器,64bit匯流排,以及64bit新增的指令,從而獲得更快的資料處理速度。

同時x32又使用32bit的地址/pointer,32bit的C資料類型,因此cache miss並不會增加。


x32是一個ABI,其設計到的部分包括:kernel的support,toolchain的support,system lib的support。現在kernel(from 3.4)和toolchain的support都已經OK。



refrence:

http://blog.claudxiao.net/2012/05/x32-abi/

http://blog.csdn.net/force_eagle/article/details/7860574


但就算看到如此,我還是沒有搞懂
    x86_amd64\vcvarsx86_amd64.bat

    amd64_x86\vcvarsamd64_x86.bat
之間的區別


x86/x86_64的一些基本概念

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.