Jack-Chen
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    --- tags: 研究所 --- # 2017q3 Homework3 ## 事前準備(現代處理器設計導讀) ### 原理和關鍵特徵 資料:[Modern Microprocessors A 90-Minute Guide!](http://www.lighterra.com/papers/modernmicroprocessors/) :::warning #### 現代處理器所面臨的障礙 1. 單純的提高時脈數已經不符合最佳的優化方案。即便提高CPU時脈,但是CPU依然還是要等待較慢的裝置,最主要是RAM,以及更慢的hard disk。 2. 解決的方法是,如何讓CPU在固定的clock cycle內,做更多的事。以及引入了多層式記憶體架構(Cache),來解決主記憶體造成的latence。 3. 引入硬體的新技術則必須有效透過硬體來提高ILP。 4. 軟體關注的點是,如何透過合理的程式碼撰寫,來提高cache的利用效率。 ::: :::danger #### 單純提高CPU時脈所產生的影響 + ___ILP Wall___ + 當時脈愈來愈提高的時候,ILP在現有程式中的效益將愈來愈不明顯,因為要再程式中找到能夠平行處理的指令是困難的。 + ___Memory Wall___ + 記憶體的儲存速度已經遠遠趕不上現有處理器的時脈頻率,再快的處理器等不到指令來執行一樣也是閒置。 + ___Power Wall___ + 提高的時脈數,與所額外消耗的能源不成比例。假如我們提高了13%的效能,功耗可能必須提高73%。如此的交易並不划算。 ::: :::info __1. 單純的提高時脈數並不符合最佳的優化方案,因為CPU的效率取決於「再一個clock cycle 裡可以做多少事」__ ::: #### Pipelining(流水線,管線化) + 原理 + 原先的(mid 1980s)CPU設計,在同一個時間,只有一道指令會進入CPU,但是因為指令的執行會拆分成4個以上的步驟(IF,ID,EX,WB),假設當A指令進入ID時,IF單元就會閒置,假設A指令進入WB階段時,則IF,ID,EX 3個單元皆會閒置,對系統效能而言,有閒置的處理單元就是可以改進效能的地方。 ![](https://i.imgur.com/ZJ7kFiS.png) + 對於throughput來說,CPI=4 + 為了改進效能,我們在A指令進入ID階段時,讓B指令進入IF階段。當A指令進入WB階段時,B指令將會在EX階段,而後面可能會有C和D指令分別再ID和IF,如此一來,我們便可以 __理論上__ 的讓所有處理單元在任意時間都有事情可以作。 ![](https://i.imgur.com/DVdhinJ.png) + 對於throughput,CPI=1 + 對於單一個指令來說,其運算時間並沒有減少,減少的是閒置的運算單元,因此提升了整體的效能。 + 增加pipeline的硬體成本是,必須新增latcg gate來儲存每一個階段到下一個階段前的暫存數值,以及可能必須增加bypasses hard line來處理資料相依性的問題。 + __pipeline的優點是可以在不提高CPU時脈數的情況下,增加throughput。__ #### Superpipeling(超級流水線) + 原理 + Pipelining CPU的colck speed受限於pipeline中最長(處理時間最久)的階段,假設我們可以把Stage在切分成更小的單元,如此一來,每一個指令所需要執行的stage會變多,但是整體的throughput依然是1,唯一不同的地方是,既然stage變小且每個stage變快了,因此我們可以提高clock speed,進而讓每秒能夠處理的指令變多。 ![](https://i.imgur.com/LyvhI4Y.png) #### Superscalar(超純量) + 原理 + 現代處理器的概念是,通常 __一個核心中會有多種不同功能的運算單元__ ,例如整數運算單元,浮點數運算單元,位移運算單元。 + 在Pipeline的架構下,雖然可以確保 ___核心___ 在任何時候都不會閒置,但是一個指令進來時,只會有 ___一個運算單元___ 在運作。 + 如果我們能在Decode階段時,就把指令分門別類,讓多個指令進入 ___同一個核心___ 但是進入 ___不同的運算單元___ ,我們就可以更進一步提高核心效能的利用率。 + 因為每種運算單元所需的運算時間不一樣,自我們將指令分門別類後,每一種類型的指令將可以有自己專屬的pipeline stage depth,例如我們可以將浮點數運算切成3個pipeline stage,這樣clock speed就不用遷就於最慢的pipeline stage。 ![](https://i.imgur.com/UbNG184.png) + 要達成superscalar的條件是,IF和ID階段的元件必須加強,ID同時還必須分類指令的種類,並指派(issue)指令到不同的pipeline裏面。 ![](https://i.imgur.com/INn1sT5.png) + 利用superscalar我們可以在同一個cycle裏面處理數個不同的指令,要注意的是,superscalar的寬度必須<=實際有的運算單元。 #### Very Long Instruction Word(VLIW,超長指令字) + 原理 + 就算我們在硬體上引入了superscalar的概念,但是我們依舊無法確保每次進來的數個指令彼此之間沒有相依性或是他們不會需要數個一樣運算單元,例如同時進入兩個以上的整數運算,假設再整數運算單原只有一個的情況下,這樣子superscalar就無法達到加速的效果。 + 解決的方法有幾個,例如Out-Of-Order execution(OOO),但是OOO依舊需要考慮指令相依性的問題,另外一種方法就是VLIW。 + VLIW的概念是,把彼此沒有相依性,且性質不同的指令,打包成一個超長的指令(128 bits or more),如此一來,我們就可以得到一個類似superscaler的指令執行平行度。 ![](https://i.imgur.com/rZ1Lgh1.png) + 優點是,在IF和ID階段的硬體設計相對簡單,因為不必要同時擷取數個指令進來,在dispatch階段也比superscaler簡單。 + 但是VLIW的架構對於cache miss等狀況來說,通常必須暫停整個處理器的運作,而且VLIW的硬體通常不會檢查資料相依性,所以 __VLIW的實現大部份是透過compiler來處理__ 的,硬體來講,通常電路設計會比superscaler簡單,但是軟體部份的複雜度就會大幅提高,因為軟體必須偵測所有資料相依性,並適時的插入nops。 #### 指令相依性與指令延遲 + 定義 + __指令相依性__ :A指令執行完後,B指令緊接著執行,且B指令必須用到A的運算輸出 + __指令延遲__ :在pipelining且兩個指令彼此有相依性的情況下,A再處理完前,處理器別無選擇,必須將B暫停,因為A的輸出 __可能__ 來不及回饋(bypasses)到B指令當前所再的階段,處理器必須插入空隙(bubble)到B指令的pipeline裏面,指令延遲的定義是,當一行指令進入EX階段,到它的結果可以被其他指令所運用,中間經過的cycles數,就是指令延遲。 + 假設我們現在有一個superpipeline,我們把EX階段切成五等份,如此一來clock cycle就會很小,但是當我們發生指令相依的情況,必須插入bubble時,插入1個EX bubble和插入五等份的EX bubble是一樣的,如此一來,superpipeline並不是越深就一定會有越高的加速效果,況且除了指令相依的情況發生之外,我們還必須考慮來自記憶體存取的延遲。 #### 分支與分支預測 + 定義 ```c=0 if (a > 7) b = c; else b = d; ``` + HT?Superscolar VLIW?SIMD

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully