我来翻译此段内容:
很显然,没有调用设置线程数量的函数。有人对为什么会发生这种情况有想法吗?
clang版本(通过apt-get安装):
我有以下程序:
#include <omp.h>
#include <stdio.h>
int main() {
omp_set_num_threads(4);
#pragma omp parallel
printf("Hello from thread %d, nthreads %d\n", omp_get_thread_num(), omp_get_num_threads());
}
我使用 clang -fopenmp
进行编译,并得到了输出结果。
Hello from thread 0, nthreads 1
很显然,没有调用设置线程数量的函数。有人对为什么会发生这种情况有想法吗?
clang版本(通过apt-get安装):
Ubuntu clang version 3.5.0-4ubuntu2 (tags/RELEASE_350/final) (based on LLVM 3.5.0)
Target: x86_64-pc-linux-gnu
Thread model: posix
编辑:我还尝试将环境变量OMP_NUM_THREADS
设置为4。
编辑2:我还安装了Intel运行时以支持OpenMP。
-fopenmp
才能使用OpenMP。 - Mike