OpenMP, for loop inside section

后端 未结 3 454
迷失自我
迷失自我 2020-12-06 08:28

I would like to run the following code (below). I want to spawn two independent threads, each one would run a parallel for loop. Unfortunately, I get an error. Apparently, p

3条回答
  •  执笔经年
    2020-12-06 08:48

    Practically, optimal number of threads is equal to number of available CPU cores. So, every parallel for should be handled in all available cores, which is impossible inside of omp sections. So, what you are trying to achieve, is not optimal. tune2fs' suggestion to execute two loops without sections makes sense and gives the best possible performance. You can execute parallel loops inside of another functions, but this "cheating" doesn't give performance boost.

提交回复
热议问题