OpenMP: conditional use of #pragma

后端 未结 1 1625
刺人心
刺人心 2021-01-04 06:54

I\'m using OpenMP to improve my program efficiency on loops.

But recently I discovered that on small loops the use of this library decreased performances and that us

1条回答
  •  花落未央
    2021-01-04 07:05

    I think you should be able to achieve the effect you're looking for by using the optional schedule clause on your parallel for directive:

    #pragma omp parallel for schedule(static, OMP_MIN_VALUE)
     for (unsigned i = 0; i < size; ++i)
       do_some_stuff ();
    

    You might want to play around with different kinds of scheduling though and different chunk sizes to see what suits your library routines best.

    0 讨论(0)
提交回复
热议问题