public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Mohamed Sayed <mohamedsayed22198@gmail.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH]: libgompd add parallel handle functions
Date: Mon, 6 Jun 2022 19:12:37 +0200	[thread overview]
Message-ID: <Yp41hTBJI3GwyB4q@tucnak> (raw)
In-Reply-To: <CAKS6CCp=N2NKZLY1pBAs1rVeO2xy5rpsH=jn6zSi=ufserdWqg@mail.gmail.com>

On Mon, Jun 06, 2022 at 01:48:22AM +0200, Mohamed Sayed via Gcc-patches wrote:
> This patch adds parallel region handles specified in section 5.5.3.
> >From examining libgomp code, I found that struct gomp_team describes the
> parallel region.

I think it would be nice to first find out what the different
ompd_{parallel,thread,task}_handle_t should actually contain.

In GOMP, the first one maps to struct gomp_team, the middle one to
struct gomp_thread and the last one to struct gomp_task.

Functions that create those are:
For ompd_thread_handle_t that is ompd_get_thread_in_parallel and
ompd_get_thread_handle.
For ompd_parallel_handle_t that is ompd_get_curr_parallel_handle,
ompd_get_enclosing_parallel_handle and ompd_get_task_parallel_handle.
For ompd_task_handle_t that is ompd_get_curr_task_handle,
ompd_get_generating_task_handle, ompd_get_scheduling_task_handle and
ompd_get_task_in_parallel.

What those handles point to is something libgompd allocates using
the allocator callback and it is up to the library what it puts there,
typically it should contain the address of those corresponding
gomp structures and whatever else is needed (say address space handle
or some contexts).

> The Thread handle gives the address of gomp_thread so, I tried to
> access *team
> gomp_thread->ts->team.

Actually gomp_thread's ts.team (ts is not a pointer, but a nested struct).

> The parallel handle is the team pointer in team state.
> I have a question about ompd_get_task_parallel_handle
> https://www.openmp.org/spec-html/5.0/openmpsu218.html
> How can i reach gomp_team from gomp_taske
> And the union in gomp_task has two entries gomp_sem_t and gomp_team

So, for the 4 functions you want to implement:
ompd_get_curr_parallel_handle when you'll have struct gomp_thread *
and want struct gomp_team * you load thr->ts.team.
Note, the implicit parallel is usually represented by NULL in thr->ts.team,
that case then means it has just a single thread etc.

ompd_get_enclosing_parallel_handle when you'll have struct gomp_team *
and want the enclosing team.  team->prev_ts.team is what you are after,
if it is non-NULL, it is the enclosing parallel, if it is NULL, I think
one should verify e.g. host teams construct in that case, but
otherwise it is the implicit parallel that one probably needs to represent
somehow too.

ompd_get_task_parallel_handle when you'll have struct gomp_task *
and want the struct gomp_team it is in.
I'm afraid the library doesn't track this, it doesn't need it for anything.
One possibility to resolve this is perhaps if all functions that
allocate ompd_task_handle_t can't know the corresponding struct gomp_thread
too, then you could store in the private structure or ompd_task_handle_t
both struct gomp_task * and struct gomp_thread *.
If that is impossible, we could add such a pointer, but it would increase
both memory and runtime overhead of the library.

	Jakub


  parent reply	other threads:[~2022-06-06 17:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-05 23:48 Mohamed Sayed
2022-06-06 15:13 ` Mohamed Sayed
2022-06-06 17:34   ` Jakub Jelinek
2022-06-06 17:12 ` Jakub Jelinek [this message]
2022-06-06 17:32   ` Mohamed Atef
2022-06-06 17:59     ` Jakub Jelinek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Yp41hTBJI3GwyB4q@tucnak \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=mohamedsayed22198@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).