Hi,
It looks like that “omp_set_num_threads()” does not affect the number of threads in a parallel region that belongs to a combined target construct.
Consider this code:
#include <omp.h>
#include <stdio.h>
int main()
{
int lp = 0;
omp_set_num_threads(1);
#pragma omp target teams distribute parallel for lastprivate(lp)
for(int i = 1; i < 10; i++) {
printf(“tid: %d\n”, omp_get_thread_num());
if(i == 1) {
lp = 0;
}
lp++;
}
printf(“lp: %d\n”, lp);
return 0;
}
This code when compiled with clang -fopenmp test.c
returns a value of lp
equal to 0, and the parallel region is executed by 9 threads in this case.
Shouldn’t the omp_set_num_threads(1)
set only one thread for the parallel region? Therefore, the expected result should be “9”?
Could this be a runtime bug? Otherwise, please help me understand this.
Thanks!
Simone