This is the mail archive of the
mailing list for the GCC project.
Re: [GSoC'19, libgomp work-stealing] Task parallelism runtime
- From: Jakub Jelinek <jakub at redhat dot com>
- To: 김규래 <msca8h at naver dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Mon, 3 Jun 2019 20:21:01 +0200
- Subject: Re: [GSoC'19, libgomp work-stealing] Task parallelism runtime
- References: <email@example.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Tue, Jun 04, 2019 at 03:01:13AM +0900, 김규래 wrote:
> I've been studying the libgomp task parallelism system.
> I have a few questions.
> First, Tracing the events shows that only the main thread calls GOMP_task.
No, any thread can call GOMP_task, in particular the thread that encountered
the #pragma omp task construct.
The GOMP_task function then decides based on the clauses of the construct
(passed in various ways through the arguments of that function) whether it
will be included (executed by the encountering thread), or queued for
later execution. In the latter case, it will be scheduled during a barrier
(implicit or explicit), see gomp_barrier_handle_tasks called from the
bar.[ch] code, or at other spots, e.g. during taskwait construct
(GOMP_taskwait) or at the end of taskgroup (GOMP_taskgroup_end).
> How do the other worker threads enter the libgomp runtime?
If you never encounter a parallel, teams or target construct, then there is
just one thread that does everything (well, the library is written such that
if you by hand pthread_create, each such thread acts as a separate initial
thread from OpenMP POV).
Threads are created e.g. during parallel construct (GOMP_parallel), where
for non-nested parallelism as the standard requires it reuses existing
threads if possible or spawns new ones, see mainly team.c (gomp_team_start)
for the function that spawns new threads or awakes the ones waiting for
work, or gomp_thread_start in the same file for the function actually run by
the libgomp library created threads.
> I can't find the entry point of the worker threads from the event tracing and the assembly dump.
> Second, How is the task priority set?
By the user, through priority clause, passed to GOMP_task and then taken
into account when handling tasks in the various queues.