簡體   English   中英

OpenMP編譯執行

[英]OpenMP compiling executing

我正在使用linux,但我不知道編譯OpenMP文件的命令行是什么,我可以簡單地寫一下:

g++ myprog.cpp -o myprog

還是g++編譯器不起作用?

以及我如何執行myprog 我在哪里選擇線程數?

您要使用-fopenmp進行編譯,並且在運行可執行文件之前,請設置OMP_NUM_THREADS變量以設置線程數,例如使用bash中的export 來自這里的一個例子:

$ gcc -o omp_helloc -fopenmp omp_hello.c
$ export OMP_NUM_THREADS=2
$ ./omp_helloc
Hello World from thread = 0
Hello World from thread = 1
Number of threads = 2

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM