Hello,
I am trying to use tasks in a hybrid MPI / OpenMP Fortran code.
I would like to write data on disk with thread 0 only, and I would like to use tasks for this.
Ideally threads others than 0 will process data and then create a "write" task that thread 0 only can execute.
Is this possible? If it is, how can I do this?
Thanks for your help,
Fabrice
Tasks executed by thread 0 only
Re: Tasks executed by thread 0 only
There is no way to specify which thread executes a task. Most likely you do not need to restrict file I/O to thread 0, as long as you don't have multiple tasks/threads trying to write the same file concurrently. But a pattern like this might work for you:
Code: Select all
#pragma omp parallel
{
#pragma omp master
{
< create compute tasks >
#pragma omp taskwait
<write to file>
....
}
}
-
- Posts: 2
- Joined: Mon Aug 10, 2020 6:39 am
Re: Tasks executed by thread 0 only
Ok, thanks for your reply.