有一种方法可以在线程中创建更多线程?
我有这部分代码:
omp_set_num_threads(3);
#prgama omp parallel
{
printf("Thread %d execute in extern parallel region\n", omp_get_thread_num());
#pragma omp parallel num_threads(2)
{
printf("Thread %d execute in intern parallel region\n", omp_get_thread_num());
}
}
可以吗?如果没有,如何创建更多线程? 如果没有办法,那么如何识别线程? 在此示例中,输出为:
Thread 0 execute in extern parallel region
Thread 1 execute in extern parallel region
Thread 2 execute in extern parallel region
Thread 0 execute in intern parallel region
Thread 0 execute in intern parallel region
Thread 0 execute in intern parallel region
那么这意味着主机在内部并行区域中执行相同的代码?我将并行区域设置为仅2个线程,那么为什么它出现3次主线程?