#omp.h unable to access all processors.

13 messages · Page 1 of 1 (latest)

covert glade
#

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,

#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

rancid fjordBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

frosty frigate
#

Set the Environment Variable:
Before running your program, set OMP_NUM_THREADS to match the number of logical cores:

export OMP_NUM_THREADS=9```
#

or try


    omp_set_num_threads(omp_get_num_procs()); // Set OpenMP 
covert glade
#
omp_get_num_procs()

also returns 1 for me

#

i was just wondering if the restriction on nproc could be somehow affecting omp

frosty frigate
#

try to open a ticket for asking this im not sure about the program you're using

covert glade
#

ok thanks!

radiant hollow
#

looks like cpu pod limitations

covert glade
#

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

radiant hollow
#

I suspect might be not. I was able to get it work on gpu though

covert glade
#

ah thats unfortunate