- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am trying to understand the behavior of the Openmp implementation when a parallel do is enclosed in a task. When using nested the parallel do uses multiple threads. The first question is is that possible to restrict the number of threads to the original thread pool (hardware thread), so that they work on the parallel construct has they become available after completing other task ? (see code below)
From reading the forum, i suspect the answer will be no, then what is the best way to combine task and parallel do , inside a task and outside a task.
Is it worth it to close the master or single region to do a parallel one, and reopen it right after ?
Last question, is there any becnhmark of using task for a loop instead of a classic parallel do , in both case, fixed work load, and variable work load for each iteration ?
Thanks
program omptest use omp_lib implicit none integer :: i !$omp parallel !$omp master print *,'omp get max threads',omp_get_max_threads(),omp_get_nested() !$omp task call omp_set_nested(.true.) print *,'thread task1',omp_get_thread_num(),omp_get_max_threads(),omp_get_nested(),omp_get_thread_limit(),omp_get_num_threads() !$omp parallel do do i=1,10 print *,'thread task1 parallel do',omp_get_thread_num(),omp_get_ancestor_thread_num(omp_get_level()-1),omp_get_nested() end do !$omp end parallel do !$omp end task !$omp task call omp_set_nested(.false.) print *,'thread task2',omp_get_thread_num(),omp_get_max_threads(),omp_get_thread_limit(),omp_get_num_threads() !$omp parallel do do i=1,10 print *,'thread task2 parallel do',omp_get_thread_num() end do !$omp end parallel do !$omp end task !$omp taskwait !$omp parallel do do i=1,10 print *,'thread parallel do',omp_get_thread_num() end do !$omp end parallel do !$omp end master !$omp end parallel end program omptest
- Tags:
- Parallel Computing
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If (IIF) your actual program is intended to be like your test program, then consider starting your outer parallel region with a limit of 2 threads. Then have each fork (assuming two), enable nested and set max active levels to 1, and have each set number of threads to half the threads. Then on your parallel for experiment with using dynamic scheduling.
Please report your findings.
Jim Dempsey
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page