[英]How to use OpenMP in Xcode 9.0
有誰知道如何在 Xcode 9.0 中啟用 OpenMP?
在 Xcode 8 中,我按照本教程中的描述進行處理,但它在 Xcode 9.0 中不再起作用......
錯誤是: clang-5.0: error: cannot specify -o when generating multiple output files
預先感謝您的幫助
我認為問題出在標志 -index-store-path 在構建設置> 構建選項中將啟用索引同時構建功能設置為否
Xcode 11.7
有2種方式(不需要同時使用)
llvm
libomp
遵循libomp
:
安裝libomp
brew install libomp
寫一些代碼:
#include <omp.h>
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
#pragma omp parallel num_threads(4)
{
printf("Hello from thread %d, nthreads %d\n", omp_get_thread_num(), omp_get_num_threads());
}
}
在構建設置中進行以下更改
-lomp
/usr/local/opt/libomp/include
/usr/local/opt/libomp/lib
-Xpreprocessor AND -fopenmp
任務成功:
2020-09-30 17:23:58.449045+0800 QRGenerator2[24352:3549441] Metal API Validation Enabled
Hello from thread 0, nthreads 4
Hello from thread 1, nthreads 4
Hello from thread 3, nthreads 4
Hello from thread 2, nthreads 4
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.