Presentation is loading. Please wait.

Presentation is loading. Please wait.

矩陣乘法 實作矩陣乘法 利用 threads 來加速運算速度 – Matrix1 row x Matrix2 column = Ans (x,y) Matrix 1Matrix 2Answer.

Similar presentations


Presentation on theme: "矩陣乘法 實作矩陣乘法 利用 threads 來加速運算速度 – Matrix1 row x Matrix2 column = Ans (x,y) Matrix 1Matrix 2Answer."— Presentation transcript:

1 矩陣乘法 實作矩陣乘法 利用 threads 來加速運算速度 – Matrix1 row x Matrix2 column = Ans (x,y) Matrix 1Matrix 2Answer

2 要求說明 不限制 threads 多少, 但一定要開 2 個以上. 主程式也可以做運算. Bonus(+10%) – 可利用其他方法來加速矩陣乘法的速度 – 速度越快會有額外加分

3 The Sleeping-Barber Problem. A barbershop consists of a waiting room with s seats and a barber room with one barber chair. There are c customers and one barber. Customers alternate between growing hair and getting a haircut. The barber sleeps and cuts hair. If there are no customers to be served, the barber sleeps. If a customer wants a haircut and all chairs are occupied, then the customer leaves the shop and skips the haircut. If chairs are available but the barber is busy, then the customer waits in one of the available chairs until the barber is free. If the barber is asleep, the customer wakes up the barber.

4 要求說明 利用以下條件來實作 Sleeping-Barber problem 的方法 – 5 個學生 (customers c) – 1 個管理員 (Barber b) – 每次預約限制 2 個學生 (chairs) – 5 台的機器 (buffer) – 學生利用機器的時間 (wait time) 假設每個學生都要找管理員預約機器來做作業, 但機器只有 5 台, 每個學生要使用機器的數目在 1-5 台內, 管理員要負責登記機器的使用狀況, 隨機或連續選擇機器都可以.

5 範例 學生 A,B,C,D,E 管理員 admin 機器 0-4 使用人數 K=2 – A 學生要用 2 台機器做作業 A 學生找 admin 登記要用 2 台機器 (1,2), 需要 1hr, K=2-1 – B 學生要用 2 台機器做作業 B 學生找 admin 登記要用 2 台機器 (3,4), 需要 2hr, K=1-1 – A 學生作業完成 A 學生找 admin 登記使用完成, release(1,2), K=0+1 – C 學生要用 2 台機器做作業 C 學生找 admin 登記要用 2 台機器 (1,3), 需要 1hr, K=1-1. 因為 B 學生 在使用第 3 台機器, 因此 C 學生要等 B 學生釋放第 3 台機器才開始 做作業 – …

6 範例 (bonus) 學生 A,B,C,D,E 管理員 admin 機器 0-4 使用人數 K=2 – A 學生要用 2 台機器做作業 A 學生找 admin 登記要用 2 台機器 (1,2), 需要 1hr, K=2-1 – B 學生要用 2 台機器做作業 B 學生找 admin 登記要用 2 台機器 (3,4), 需要 2hr, K=1-1 – A 學生作業完成 A 學生找 admin 登記使用完成, release(1,2), K=0+1 – C 學生要用 2 台機器做作業 C 學生找 admin 登記要用 2 台機器 (1,3), 需要 1hr, K=1-1. 因為 B 學生 在使用第 3 台機器, 但第 1 台機器並不在使用中, 所以 C 學生可以 先利用第 1 台機器, 等到第 3 台機器可以使用再使用第 3 台機器. – …


Download ppt "矩陣乘法 實作矩陣乘法 利用 threads 來加速運算速度 – Matrix1 row x Matrix2 column = Ans (x,y) Matrix 1Matrix 2Answer."

Similar presentations


Ads by Google