Dydaktyka
      • 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
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners 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 New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Help
Menu
Options
Engagement control Make a copy 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
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners 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
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Ćwiczenia 8, grupa śr. 17-19, 4. maja 2022 ###### tags: `SYK21` `ćwiczenia` `pwit` ## Deklaracje Gotowość rozwiązania zadania należy wyrazić poprzez postawienie X w odpowiedniej kolumnie! Jeśli pożądasz zreferować dane zadanie (co najwyżej jedno!) w trakcie dyskusji oznacz je znakiem ==X== na żółtym tle. **UWAGA: Tabelkę wolno edytować tylko wtedy, gdy jest na zielonym tle!** :::danger | | 1 | 2 | 3 | 4 | 5 | 6 | | ----------------------:| ----- | --- | --- | --- | --- | --- | Grzegorz Bielecki | | | | | | | Kamila Brzozowska | X | X | X | X | X | | Adam Ciężkowski | X | X | X | X | X | | Natalia Czerep | X | X | X | X | | | Jan Dalecki | X | X | X | X | X | | Marko Golovko | X | X | X | X | | | Adam Górkiewicz | X | X | X | X | X | X | Piotr Gunia | X | X | X | X | | | Krzysztof Jadłowski | | x | x | x | | | Magdalena Jarecka | X | | X | X | X | | Mikołaj Jaszcza | X | X | X |==X==| | | Monika Jędrzejkowska | | | | | | | Michał Kierul | X | X | X | | | | Damian Lukas | | | | | | | Karol Ochman-Milarski | | | | | | | Piotr Piesiak | | | | | | | Damian Ratajski | | | | | | | Aleksandra Rozkrut | | X | X | X | | | Marcin Sarnecki | X | X |==X==| X | | | Maria Szlasa | | X | X | X | | | Mateusz Burdyna | X | X | X | X | | | Magdalena Słonińska | | | | | | | Nikola Wrona | X | X | X | X | | | Marcin Wróbel | X |==X==| X | X | X | | ::: :::info **Uwaga:** Po rozwiązaniu zadania należy zmienić kolor nagłówka na zielony. ::: ## Zadanie 1 :::success Autor: Mateusz Burdyna ::: ![](https://i.imgur.com/kaHS33u.png) ![](https://i.imgur.com/aABlQSQ.png) ![](https://i.imgur.com/SZ5KeRx.jpg) (źródło: https://slideplayer.com/slide/14469754/) Algorytm tomasulo zapisuje dane out of order (w taki sposób, że w efekcie i tak dostajemy taki sam wynik jak w przypadku in order). Problem pojawia się gdy chcemy taki program debbugować. W środku działania programu instrukcje zapisywane są out of order, co jest problemem dla programisty. Aby rozwiązać problem skorzystamy z reorder buffera. Zamiast zapisywać do rejestrów będziemy zapisywać do reorder buffera, którego mechanika działania zadba o to, żeby zapis do rejestrów odbywał się in order. ## Zadanie 2 :::success Autor: Marcin Wróbel ::: Branch-target buffer to stuktura przechowująca historię poprzednich skoków. Zawiera ona adres instrukcji będącej instrukcją skoku, adres następnej instukcji, oraz to czy następna instukcja była wynikiem wykonania skoku, czy nie. ![](https://i.imgur.com/JXY8Qhy.png) Schemat użycia w prostym 5-fazowym procesorze potokowym: ![](https://i.imgur.com/LO38jz2.png) Automat będacy schematem 2-bitowego predyktora skoków ![](https://i.imgur.com/uoWqhIB.png) ```c for (int i = 0; i < 1000000; i++) { if (i > 500000) { // ... } } for (int i = 0; i < 1000000; i++) { int j =0; do { j++; } while(j<3); } ``` W przypadku predyktora statycznego połowa instrukcji if zostanie błędnie przewidziana. Predyktor 2-bitowy błędnie przewidzi ten skok maksymalnie 4 razy. Bity predyktora 2-bitowego można zapamiętać razem z instrukcją w pamięci instrukcji. Uogólniony predyktor $n$ bitowy będzie w jednym z $2^n$ stanów. ## Zadanie 3 :::success Autor: Marcin Sarnecki ::: Correlating predictors Pomysł polega na zapamiętaniu $m$ poprzednich decyzji. Mamy $2^m$ wszystkich możliwych kombinacji poprzednich $m$ decyzji, dla każdej z nich trzymamy osobno $n$ bitowy predyktor. Przykład kodu, dla którego predyktor lokalny nie jest w stanie osiągnąć idealnej precyzji: for(int i = 0; i < n; i++) $\quad$ if(i % 2 == 0) $\quad\quad$ ... W tym przykładzie if w środku pętli będzie wykonywał się naprzemiennie, predyktor lokalny nie będzie w stanie poprawnie przewidywać, czy wykonywać skok, natomiast correlating predictor poradzi sobie z tym bez problemu, ponieważ będzie osobno rozpatrywał maski bitowe poprzednich decyzji (01 oraz 11) Ogólnia struktura: (m, n) pamiętamy m ostatnich decyzji dla każdej z nich trzymamy n bitowy predyktor ![](https://i.imgur.com/v72hE8i.png) Predyktor gshare korzysta z pomysłu haszowania adresu instrukcji oraz stanu historii. Funkcja haszującą jest XOR ## Zadanie 4 :::success Autor: Mikołaj Jaszcza ::: Predyktory turniejowe to rodzaj "systemu" predykcji skoków, który pozwala łączyć zalety różnych predyktorów "zwykłych" opisywanych wcześniej. W praktyce takie systemy okazują się lepsze niż (rozpatrywane osobno) gshare czy lokalne predyktory n-bitowe. Zwyczajowo taki system jest złożony z trzech predyktorów (w tym dwóch przewidujących czy skok nastąpi oraz jednego predyktora pomocniczego). Predyktor "pomocniczy" przy każdym zapytaniu przez jednostkę sterującą o predykcję dot. skoku sprawdza, który z predyktorów głównych sprawdzał się lepiej w poprzednich zapytaniach ( * ) i zwraca jego predykcję. Następnie - mając dostęp do poprawnej odpowiedzi (tj. czy skok faktycznie nastąpił) - predyktor pomocniczy ocenia poprawność odpowiedzi obu predyktorów głównych i aktualizuje wewnętrzny stan wskazujący który z nich sprawuje się lepiej w ostatnim czasie (oczywiście wciąż - zupełnie niezależnie - aktualizujemy stany wewnętrzne predyktorów głównych tak jak robiliśmy to do tej pory w przypadku "zwykłych" predyktorów pojedynczych). Strukturę która obsługuje takie operacje można reprezentować wewnętrznie jako 2-bitowy rejestr. My natomiast, możemy myśleć o nim jak o automacie działającym w następujący sposób: ![](https://i.imgur.com/Os3lZav.png) ( * ) Zauważmy - na bazie schematu powyżej - że w ocenie skuteczności predyktorów liczy się tylko najnowsza historia ich działania. To pozwala na większą dynamikę wyboru predyktora głównego, niż np. liczenie średniej procentowej skuteczności predykcji od początku działania programu. Predyktory turniejowe najczęściej używane są do łączenia predyktorów lokalnych i globalnych/korelujących. Popularnym wyborem dla predyktora lokalnego bywa wtedy predyktor 2-bitowy. Jak widzimy na poniższym schemacie, predyktory turniejowe (zgodnie z intuicją) zazwyczaj sprawdzają się lepiej od pojedynczych predyktorów zwykłych będących ich częścią. ![](https://i.imgur.com/atrgw1D.png) [https://people.engr.ncsu.edu/efg/521/s06/common/lectures/notes/lec17.html] ## Zadanie 5 :::success Autor: Adam Ciężkowski ::: ![](https://i.imgur.com/22X9jk7.png) <!-- ![](https://i.imgur.com/PfwtCLB.png) --> ![](https://i.imgur.com/o5IJVrx.png) ![](https://i.imgur.com/N1Mnkni.png) ![](https://i.imgur.com/TmpIPau.png) "The tagged hybrid version of this predictor also includes a 2-bit use field in each of the history-indexed predictors. The use field indicates whether a prediction was recently used and therefore likely to be more accurate; the use field can be periodically reset in all entries so that old predictions are cleared." ## Zadanie 6 :::success Autor: Adam Górkiewicz ::: ![](https://i.imgur.com/HQaCXhT.png) [...] Założenia: * Inicjalne numery branchów w predyktorach odpowiadają operacjom o adresach kolejno 453, 543, 777. * "with one misprediction" <=> weak prediction (else strong). * Z cache'a predyktora usuwany jest branch, do którego odwołaliśmy się najdawniej. * Podczas cache'owania nowego brancha, jest on inicjalizowany na "weakly not taken" dla każdego "last outcome", natomiast jego historia jest inicjalizowana na T, T. * Update predyktora jest wdrażany przed następną predykcją Predyktor korelujący (1, 2): ![](https://i.imgur.com/K4GbeJY.png) ![](https://i.imgur.com/jcjp0tU.png) Predyktor lokalny (2, 2): ![](https://i.imgur.com/IxS0oqb.png) ![](https://i.imgur.com/qjKHOd0.png) <!-- Predyktor korelujący (2, 2): --> <!-- ![](https://i.imgur.com/PfiBwBU.png) --> <!-- ![](https://i.imgur.com/Tzy6vDK.png) -->

    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