How does OpenMP handle nested loops?

后端 未结 3 1035
温柔的废话
温柔的废话 2020-11-30 03:02

Does the following code just parallelize the first (outer) loops, or it parallelize the entire nested loops?

    #pragma omp parallel for
    for (int i=0;i&         


        
3条回答
  •  误落风尘
    2020-11-30 03:34

    The lines you have written will parallelize only the outer loop. To parallelize both you need to add a collapse clause:

    #pragma omp parallel for collapse(2)
        for (int i=0;i

    You may want to check OpenMP 3.1 specifications (sec 2.5.1) for more details.

提交回复
热议问题