Esme
    • 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 New
    • Engagement control
    • Make a copy
    • 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 Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
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
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
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # PP Assignment 4 ###### tags: `PP` :::info **Webpage** [Description](https://nycu-sslab.github.io/PP-f22/assignments/HW4/) ::: ## Q1 :::success 1. How do you control the number of MPI processes on each node? 2. Which functions do you use for retrieving the rank of an MPI process and the total number of processes? ::: 1. 如同後面的功課說明所表示,可以在```hostfile```每個機器後面加上```slot=n```來限制每台機器為節點的情況下最多可以執行的processor數量 ```bash! pp1 slots=1 # pp1 最多1個processor pp3 slots=2 # pp3 最多2個processor ``` 2. ```cc! // 取得目前這個processor的排號: rank of an MPI process MPI_Comm_rank(MPI_COMM_WORLD, &world_rank) // 取得整個程式的processor數量: total number of processes MPI_Comm_size(MPI_COMM_WORLD, &world_size) ``` ## Q2 :::success <MPI BLOCKING COMMUNICATION & LINEAR REDUCTION ALGORITHM> 1. Why MPI_Send and MPI_Recv are called “blocking” communication? 2. Measure the performance (execution time) of the code for 2, 4, 8, 12, 16 MPI processes and plot it. ::: 1. ```MPI_Send```, ```MPI_Recv```: 等到整個訊息完成後才回傳,所以這個process就必須等這兩個函式處理完才會繼續執行後續的動作 2. |processor cnt|1|2|4|8|12|16| |-|-|-|-|-|-|-| |Time(s)|11.80677|6.106424|3.205323|2.189460|1.485867|1.049591| |Speedup(times)|1|1.93350|3.68349|5.39255|7.94605|11.24892| ![](https://i.imgur.com/HEy4dg9.png) ## Q3 :::success <MPI BLOCKING COMMUNICATION & BINARY TREE REDUCTION COMMUNICATION ALGORITHM> 1. Measure the performance (execution time) of the code for 2, 4, 8, 16 MPI processes and plot it. 2. How does the performance of binary tree reduction compare to the performance of linear reduction? 3. Increasing the number of processes, which approach (linear/tree) is going to perform better? Why? Think about the number of messages and their costs. ::: 1. |processor cnt|1|2|4|8|12|16| |-|-|-|-|-|-|-| |Time(s)|12.193638|6.071536|3.111489|2.488243|1.540553|1.657527| |Speedup(times)|1|2.00833|3.91891|4.90050|7.91510|7.35652| ![](https://i.imgur.com/ph0TdfV.png) 2. ![](https://i.imgur.com/vTjMJJO.png) 根據圖表所示,兩者的相差不大,但大體來說linear的時間會比binary tree的時間還要短一些,就算是較多的也是0.1秒內的差距,因此可以推斷linear的效果會比binary還要好。 3. 可以由圖中的差值看出在processor越來越多的狀態下linear跟binary tree的相差有加大的趨勢,因此在processor多的狀況下也是linear會有比較好的表現 ## Q4 :::success <MPI NON-BLOCKING COMMUNICATION & LINEAR REDUCTION ALGORITHM> 1. Measure the performance (execution time) of the code for 2, 4, 8, 12, 16 MPI processes and plot it. 2. What are the MPI functions for non-blocking communication? 3. How the performance of non-blocking communication compares to the performance of blocking communication? ::: 1. |processor cnt|1|2|4|8|12|16| |-|-|-|-|-|-|-| |Time(s)|11.930514|6.122414|3.135446|1.596679|1.084176|0.809097| |Speedup(times)|1|1.94866|3.80505|7.47208|11.00422|14.74547| ![](https://i.imgur.com/O6O0Jyk.png) 2. Some functions in the indirect communication: ```MPI_Isend```, ```MPI_Irecv```, ```MPI_Wait```, ```MPI_Waitall```, ```MPI_Gather``` 3. ![](https://i.imgur.com/m4YbX6z.png) 由圖可知blocking跟nonblocking的效果在processor數量越大的時候效果顯著,可以看到確切時間的減少 ## Q5 :::success < MPI COLLECTIVE: MPI_GATHER> Measure the performance (execution time) of the code for 2, 4, 8, 12, 16 MPI processes and plot it. ::: |processor cnt|1|2|4|8|12|16| |-|-|-|-|-|-|-| |Time(s)|11.805508|6.041052|3.115950|1.586252|1.084110|0.810262| |Speedup(times)|1|1.95421|3.78873|7.44239|10.88959|14.56999| ![](https://i.imgur.com/S4zkFNe.png) ## Q6 :::success < MPI COLLECTIVE: MPI_REDUCE> Measure the performance (execution time) of the code for 2, 4, 8, 12, 16 MPI processes and plot it. ::: |processor cnt|1|2|4|8|12|16| |-|-|-|-|-|-|-| |Time(s)|11.815341|6.054686|3.121058|1.570721|1.076561|0.808215| |Speedup(times)|1|2.00833|3.91891|4.90050|7.91510|7.35652| ![](https://i.imgur.com/MxhQ9jp.png) ## Q7 :::success < Matrix Multiplication with MPI> Describe what approach(es) were used in your MPI matrix multiplication for each data set. ::: - 首先會先在root將兩個矩陣讀進來之後透過```MPI_Bcast```進行廣播,讓其他的process知道矩陣的內容 ```cc= MPI_Bcast(*a_mat_ptr, matrix_a_size, MPI_INT, 0, MPI_COMM_WORLD); MPI_Bcast(*b_mat_ptr, matrix_b_size, MPI_INT, 0, MPI_COMM_WORLD); ``` - 之後的每個process會平分整個運算量,透過第一個矩陣的行來區分,計算完成後共用的結果矩陣會透過```MPI_Reduce```進行整合。 ```cc= MPI_Reduce(local_result, result, total_size, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD); ```

    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