Re: [問題] Multithread Coding and Parallel Coding
※ 引述《liquidcrysta (crystal)》之銘言:
: Hello people,
: Apologize I can only type English for now.
: I've been working on image processing and graphics application for a while,
: and found that "think parallely" is critical to modern applications.
: But I always have a question:
: Do you think we should learn multithread coding (which I mean single/multicore)
: before getting into parallel coding (which i mean gpgpu/multiprocessor)?
: As my littile knowledge in these two fields,
: multithread is to utilize the concept of "shared memory" rather than
: speeding up by multicores, while parallel computing is intended to speed up
: by the power of multiple processors.
: I'm interested in how people compare with these two models.
以個人的淺見來看
multithread比較適合偏向CPU的利用
如果你所需要執行的工作牽涉到作業系統
就會用thread
這類型的程式撰寫困難點
在於資料同步、死結、餓死問題
以及問題發生之後
很難重現當時的事件順序
以致除錯不易
而另外一方面
關於gpgpu
通常就是偏向GPU的利用
例如3d的shading language或是cuda
這類程式有個特性
就是被寫入的資料不能同時還被讀取
總是只能成為讀或是寫的其中一種
所以不像thread有資料同步問題
但是因為計算在顯示卡上面
所以多了兩個限制存在
一是會增加搬資料的負擔
特別是主記憶體和顯示卡之間的資料交換
很容易成為效能瓶頸
第二點則是顯示卡只能用來計算
這句話不是說沒有條件判斷、迴圈等東西
這些都沒有問題
有問題的是,不能在顯示卡中呼叫系統函數
現在來回答原問的問題
原問主要工作是影像處理
而影像處理的可平行性
在於圖片的像素
通常會有相同的處理規則
這種運算比較適合GPGPU
因為功能需求上與系統呼叫無關
也沒有同步的需求
而GPU的運算核心個數
總是遠超過CPU核心個數
用GPU會快非常多
至於要不要先學multithread呢?
我的回答是:NO
multithread programming的重點
對你目前的工作幫助不大
--
※ 發信站 :批踢踢實業坊(ptt.cc)
◆ From: 140.113.210.62
→
10/15 01:09, , 1F
10/15 01:09, 1F
→
10/15 01:09, , 2F
10/15 01:09, 2F
→
10/15 01:10, , 3F
10/15 01:10, 3F
→
10/15 01:10, , 4F
10/15 01:10, 4F
→
10/15 04:37, , 5F
10/15 04:37, 5F
→
10/15 04:42, , 6F
10/15 04:42, 6F
→
10/15 04:43, , 7F
10/15 04:43, 7F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 3 篇):