Fortran OpenMP: creating threads only once -


i working in fortran. purpose parallelize openmp program of kind:

do t=1, t_fin  (sequential)    sequence of loops (not sequential) end 

where cycle sequential (temporal). have tried create threads @ beginning of each sequential cycle iteration, makes code slower be. therefore, question if possible create threads once before starting cycle. practically:

!$omp parallel  !$omp sections !$omp critical t=1, t_fin     sequence of omp end !$omp end critical !$omp end parallel 

i have tried in way, works if 1 thread. suppose depends on fact there external critical section includes omp do. however, execute internal omp do more 1 thread. there way obtain this?

if understand question correctly, want avoid creating threads in each iteration of outer loop. can achieved taking omp parallel directive outside loop, , leave other statements inside loop. see 2 parallelization schemes.

you either parallelize inner loops:

!$omp parallel t=1, t_fin  (sequential)    !$omp    first loop    !$omp end     !$omp    second loop    !$omp end     !... end !$omp end parallel 

or, use sections run loops in parallel (if independent of each other):

!$omp parallel t=1, t_fin  (sequential)    !$omp sections     !$omp section     first loop    !$omp end section     !$omp section    second loop    !$omp end section     !...    !$omp end sections end !$omp end parallel 

in both versions, threads created outside loop.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -