[PATCH] libgomp: Add OMPD process functions and datatypes.

y2s1982 . y2s1982@gmail.com
Tue Jul 7 18:52:37 GMT 2020


Hello,

On Tue, Jul 7, 2020 at 7:46 AM Jakub Jelinek <jakub@redhat.com> wrote:

> On Tue, Jul 07, 2020 at 07:38:13AM -0400, y2s1982 . wrote:
> > > I have no idea what this function is doing, but e.g. from aliasing
> point of
> > > view trying to access something as short/int/long long is dangerous,
> and
> > > there might be alignment implications too.
> > >
> >
> > This function is used in ompd_device_initialize(). The initializing
> function
> > receives a void *id and ompd_size_t sizeof_id. My first attempt tried to
> > just
> > preserve both information as is, but I wasn't sure how the void * would
> > ultimately be read. In the second attempt, I tried to cast the value,
> based
> > on
> > the sizeof_id, and store it in a large enough type. This does assume the
> > void * is pointing at a numerical value.
> > What would be the best way to handle the void *id?
>
> Well, you should know what it is and only depending on that handle it.
> If it e.g. would be string, you'd want to use memcpy to copy it somewhere,
> or parse immediately, etc.
>

I have re-read the documentation trying to find a different solution.
In particular, ompd_device_initialize states that
ompd_device_t kind, ompd_size_t sizeof_id, and void *id represents
a device identifier. To dig further, I read up on the ompd_device_t. A
passage from ompd_device_t says that the OMPD library and a tool that uses
it must agree on the format of the object that is passed.
It also says that ompd_device_t is a pointer to where the device identifier
is stored and the size of the device identifier. I am not sure how this
works to ompd_device_initialize as those two information seems to be
supplied separately: *id and sizeof_id. In fact, ompd-type.h provides 4
examples, 2 of which are host and cuda, and they all simply contain unique
numerical values.  So does this mean that I should just decide on what the
library and tool will use for device id data type and simply stick to it?

Otherwise, Is it possible to know the proper data type to cast the void *id
based on the device type (host/cuda)?

Tony


More information about the Gcc-patches mailing list