How to parallelize a loop?
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 threads as many times as the do is executed. And I would like to say outwardly that we need to create two threads that will execute this code, while they do not need to be deleted and created 100500 times.
0
Author: van9petryk, 2016-05-31
2 answers
Omp_set_dynamic + omp_set_num_threads will allow you to prevent changing the number of threads and set this number, respectively.
1
Author: Владимир Мартьянов, 2016-05-31 16:24:29
Threads will be created when entering #pragma omp parallel. Next, they will be assigned iterations, the threads will continue to live without being destroyed. So it will be possible to parallelize only for.
0
Author: WhereColdWindsBlow, 2016-06-13 11:09:45