omp.h unable to access all processors.

Hi! I'm running a pod with 8 vCPUs, but it seems like omp.h can only access 1 of them while thread can access all of them. For example,
c++
#include <omp.h>
#include <thread>
#include <iostream>
using namespace std;

int main(){
cout << omp_get_max_threads() << endl;
cout << thread::hardware_concurrency() << endl;
}
c++
#include <omp.h>
#include <thread>
#include <iostream>
using namespace std;

int main(){
cout << omp_get_max_threads() << endl;
cout << thread::hardware_concurrency() << endl;
}
will print out 1 9
8 Replies
nerdylive
nerdylive2w ago
Set the Environment Variable: Before running your program, set OMP_NUM_THREADS to match the number of logical cores:
export OMP_NUM_THREADS=9
export OMP_NUM_THREADS=9
or try
omp_set_num_threads(omp_get_num_procs()); // Set OpenMP
omp_set_num_threads(omp_get_num_procs()); // Set OpenMP
||dank-memer||
||dank-memer||OP2w ago
c++
omp_get_num_procs()
c++
omp_get_num_procs()
also returns 1 for me i was just wondering if the restriction on nproc could be somehow affecting omp
nerdylive
nerdylive2w ago
try to open a ticket for asking this im not sure about the program you're using
||dank-memer||
||dank-memer||OP2w ago
ok thanks!
Madiator2011 (Work)
looks like cpu pod limitations
||dank-memer||
||dank-memer||OP2w ago
is there a way to multithread with omp on a cpu pod then? I cant seem to utilize more than one core at a time
Madiator2011 (Work)
I suspect might be not. I was able to get it work on gpu though
||dank-memer||
||dank-memer||OP2w ago
ah thats unfortunate thanks tho

Did you find this page helpful?