Page 1 of 1

Tasks executed by thread 0 only

Posted: Tue Aug 11, 2020 7:26 am
by FabriceRoy
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

Re: Tasks executed by thread 0 only

Posted: Tue Aug 11, 2020 8:31 am
by MarkB
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> 
....
  }
}

Re: Tasks executed by thread 0 only

Posted: Wed Aug 12, 2020 12:48 am
by FabriceRoy
Ok, thanks for your reply.