c++ - call a function and loops in parallel -


I have no experience in OpenMP, so I have to do this how to do the following:

 For  (int i = 1; i & lt; = NumImages; i ++) {// call a function myfunction (...); For (int k = 0; k & lt; SumNumber k ++) {for (int l = 0; l & lt; elnum; l ++) {// do 2 while summarizing calculations within a time loop } // end k loop} // end I loop  

Now, at my disposal I have 40 cores.

For the number 50 to 150, the more general 150.

SumNumber <200p>

Alan will be around 5,000.

So, with this, the best behavior function is specifying each thread in the call and executes in parallel to the L-loop?

And if so, then it will be:

  paragraph for num_threads (40) for #pragma omp (int i = 1; i & lt; = NumImages; I ++) {myfunction (...); For (int k = 0; k & lt; SumNumber k ++) {#pragma for omp (int l = 0; l   

And above (for NumImages = 150) that myfunction will also be executed 40 times in parallel and L-loop and then when the l loop and the K-Loop end, then the next 40 threads function and the next 40 calls, so 3 * 40 = 120 and then the next 30?

  1. Normally the best way to divide the work is the same In order to maintain efficiency (no core is waiting), perhaps in your case, stationary scheduling is not a good idea, because 40 does not even divide 150 as equally, because for the last trip you have 25% computing If you lose power then it can be turned on, that before the second loop parallel b E would be better put. All this depends on the mode you choose, and how the work is actually distributed within the loop. For example, if myfunction is 99%, then it is a bad idea, if 99% of the work is in 2 inner loop, then it can be good.

  2. Not really. There are 3 scheduling modes but none of these works in a way that it blocks other threads. A pool of tasks (iterations) to be distributed in threads describes the strategy of handing assignments to the determination mode thread. When a thread ends, it just gets done next, no waiting strategies have been described here in more detail: (I'm not sure that the balance-copy paste from the wiki is a good idea, This is a good content.)

The method overhead is presented in the order of the amount of overhead that is not what is written, which Start Static Settled faster, then mobile , then directed . Which would be to use my advice, this is not the most accurate, but a good rule of thumb IMO:

  1. static If you know that Will be divided equally in threads and take the same time of time

  2. Dynamic If you know that the work will not be divided evenly or They do not even have the execution time

  3. guided for those tasks that do not tell you too much If your work is very small, you can also see the upper part for the stationary scheduling (for example), but I think that in your case, < > Dynamic should be fine and the best option.


Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -