My CPU has 2 physical cores, and it supports hyperthreading. Thus, I think I can manage 4 threads. (4 logical cores) However, using openmp, I can generate much more cores. It is strange.
I'm a newbie in parallel programming, and I learned that there are few ways to set the number of threads I wanna use. I've used two ways below.
- omp_set_num_threads(4);
- #pragma omp prarallel num_threads(4);
#pragma omp parallel num_threads(100)
{
printf("%d\n", omp_get_thread_num());
#pragma omp for
/* code I wanna parallelize */
}
What I think strange is, the logical core number is 4 in my CPU, but why omp_get_thread_num()
returned 0 to 99. I think it is impossible, what is the meaning of 100
in #pragma omp parallel num_threads(100)
?