I have about a trace. code

for (;;) { do { //тут нужно расспараллелить } } 

I would like to parallelize what is in the loop. But the trouble is that if I write #pragma omp parallel where I need to parallelize, it will create and delete streams as many times as do. And I would like to say outwardly that you need to create two threads that will execute this code, and you don’t need to delete them and create them 100500 times.

    2 answers 2

    omp_set_dynamic + omp_set_num_threads will allow you to prevent changing the number of threads and set this number, respectively.

      Streams will be created when entering #pragma omp parallel. Then they will be entrusted with iteration, the streams will continue to live without being destroyed. So it will be possible to parallelize only for.