mimicking gomp_thead(void) for OMPD-API implementation

Ahmed Sayed Mousse ahmedsayedmousse@gmail.com
Thu Jun 2 09:13:11 GMT 2022


Hi everyone,

               To implement the function ompd_get_thread_handle (…) from
the OMPD API. I need to get  the gomp_thread struct using thread context
and address space context and in order to do that I want to apply the
functionality of/mimic  gomp_thread(void) from lipgomp.h using callbacks
but I don't know which of those two approaches should I use or whether I
should use both.


#elif defined HAVE_TLS || defined USE_EMUTLS
extern __thread struct gomp_thread gomp_tls_data;
static inline struct gomp_thread *gomp_thread (void)
{
  return &gomp_tls_data;
}
#else
extern pthread_key_t gomp_tls_key;
static inline struct gomp_thread *gomp_thread (void)
{
  return pthread_getspecific (gomp_tls_key);
}
#endif


My current thought is to try looking for the gomp_tls_data symbol and if I
don't find it I go looking for the gomp_tls_key then use
pthread_getspecific() on it.


Here is the current approach I think about using:


    lookup('gomp_tls_data')

    if return code != ok)

        go to try_key

    .....


    go to allocation

    try_key:

    lookup('gomp_tls_key')


    .....


    allocation:


    .....


    end of function


If I should use both should I save the first lookup by saving the result of
the first condition, if defined HAVE_TLS || defined USE_EMUTLS,  from
runtime in the shared library and then check on that result?


like

#if defined HAVE_TLS || defined USE_EMUTLS

#define GOMPD_USE_TLS

#endif

Thanks.


More information about the Gcc mailing list