作者school4303 (某爬蟲類)
看板C_and_CPP
標題[問題] openMP產生比section數多的thread
時間Fri Jan 21 02:36:34 2022
開發平台(Platform): (Ex: Win10, Linux, ...)
linux mint 20.3
編譯器(Ex: GCC, clang, VC++...)+目標環境(跟開發平台不同的話需列出)
gcc
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
openMP
問題(Question):
執行到sections區域後,產生的thread比我想像中還要多
餵入的資料(Input):
無
預期的正確結果(Expected Output):
5個thread
錯誤結果(Wrong Output):
16個thread (注:我的CPU是R7-3700X 8C16T)
程式碼(Code):(請善用置底文網頁, 記得排版,禁止使用圖檔)
#pragma omp parallel sections
{
#pragma omp section
funcA();
#pragma omp section
funcB();
#pragma omp section
funcC();
#pragma omp section
funcD();
#pragma omp section
funcE();
}
在執行到sections時,我從htop裡面看到了16個thread,但我只有5個section
除了這邊以外沒有其他#pragma omp的部分
如果只有5個thread在執行各個Function,其餘多的thread是在原地發呆還是?
補充說明(Supplement):
無
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.34.145.89 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1642703796.A.5FF.html
※ 編輯: school4303 (114.34.145.89 臺灣), 01/21/2022 02:37:50
→ sunneo: 通常是原地發呆等塞任務 01/23 14:50
→ sunneo: 可以用num_threads directive設定 01/23 14:51
→ rex0707: 沒有指定thread數通常會全開 02/01 23:33
→ school4303: 補個後續:對,就是發呆 02/10 03:27