问题描述
我尝试以并行模式运行LIBSVM,但我的问题是在OpenMP中。根据,我已经修改了#pragma调用的代码使用OpenMP。我还通过添加一个-fopenmp参数修改了Makefile(对于un * x):
I am trying to run LIBSVM in parallel mode, however my question is in OpenMP in general. According to LIBSVM FAQ, I have modified the code with #pragma calls to use OpenMP. I also modified the Makefile (for un*x) by adding a -fopenmp argument so it becomes:
CFLAGS = -Wall -Wconversion -O3 -fPIC -fopenmp
代码编译良好。我检查(因为它不是我的电脑)OpenMP是否安装:
The code compiles well. I check (since it's not my PC) whether OpenMP is installed by :
/sbin/ldconfig -p | grep gomp
,并看到它可能安装:
libgomp.so.1 (libc6,x86-64) => /usr/lib64/libgomp.so.1
libgomp.so.1 (libc6) => /usr/lib/libgomp.so.1
当我运行程序,我没有看到任何速度的改进。此外,当我检查顶的过程是使用最多%100 CPU(有8个核心),也没有CPU瓶颈(只有一个更多的用户与%100 CPU使用),我期待看到超过
Now; when I run the program, I don't see any speed improvements. Also when I check with "top" the process is using at most %100 CPU (there are 8 cores), also there is not a CPU bottleneck (only one more user with %100 CPU usage), I was expecting to see more than %100 (or a different indicator) that process is using multiple cores.
有没有办法检查它是否正在使用多个核心?
Is there a way to check that it is working multiple core?
推荐答案
您可以使用函数 omp_get_num_threads()
。它将返回您的程序使用的线程数。
You can use the function omp_get_num_threads()
. It will return you the number of threads that are used by your program.
这篇关于如何判断OpenMP是否正常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!