openmp中平行截面内的平行截面

时间:2015-02-16 18:59:26

标签: c parallel-processing openmp

我正在尝试在并行部分中创建并行部分。从逻辑上讲,这里应该创建3个线程。在第一部分中有2个,其中一个应该生成2个线程。

#pragma omp parallel sections
{
    #pragma omp section
    {
        printf("section 1  thread = %d\n",omp_get_thread_num());
        omp_set_num_threads(2);
        #pragma omp parallel sections
        {
            #pragma omp section
            {
                printf("section 1.1.  thread = %d\n",omp_get_thread_num());
            }
            #pragma omp section
            {
                printf("section 1.2  thread = d\n",omp_get_thread_num());
            }
        }
    }
    #pragma omp setion
    {
        printf("section 2 thread = %d\n",omp_get_thread_num());
    }
}

代码的输出是: -

第2节线程= 0第1节线程= 1节1.1。 thread = 0 section 1.2 thread = 0

这意味着线程不会在第一部分中生成两个。 OpenMP是否支持此递归?

0 个答案:

没有答案