I have the following C/C++ code using OpenMP:
int nProcessors=omp_get_max_threads();
if(argv[4]!=NULL){
printf(\"argv[4]: %s\\n\",argv[4]);
The omp_get_num_threads()
call returns 1 in the serial section of the code. See Link
So you need to have parallel code to get the correct value, here how your code should look like:
#include
#include
int main (int argc, const char * argv[])
{
int nProcessors = omp_get_max_threads();
std::cout<
This code produces:
2
1
0 tid
2 nThreads
0 tid
2 nThreads
0 tid
2 nThreads
1 tid
2 nThreads
1 tid
2 nThreads
It seems that you have either open mp not enabled or your loop is not in the form that can be parallized by openmp