should add the compiler directive:
#include <stdio.h>
#include <omp.h>
int main(){
int tid;
#pragma omp parallel
tid = omp_get_num_threads();
printf("thread = %d\n",tid);
return 0;
}
results:
thread = 8
if do not add the compile directive:
#include <stdio.h>
#include <omp.h>
int main(){
int tid;
tid = omp_get_num_threads();
printf("thread = %d\n",tid);
return 0;
}
the result will be
thread = 1