diff mbox series

libgompd: Fix sizes in OMPD support and add local ICVs finctions.

Message ID CAPFh8NLFxX2xF4XNXqLZePjrYO72Yr2jej9WiOgVumEcgxGxZw@mail.gmail.com
State New
Headers show
Series libgompd: Fix sizes in OMPD support and add local ICVs finctions. | expand

Commit Message

Mohamed Atef June 16, 2022, 11:20 p.m. UTC
libgomp/ChangeLog

2022-06-17  Mohamed Atef  <mohamedatef1698@gmail.com>

* ompd-helper.h (DEREFERENCE, ACCESS_VALUE): New macros.
(gompd_get_proc_bind): Change the returned value from ompd_word_t
to const char *.
(gompd_get_max_task_priority): Fix format.
(gompd_stringize_gompd_enabled): Removed.
(gompd_get_gompd_enabled): New function prototype.
* ompd-helper.c (gompd_get_affinity_format): Call CHECK_RET.
Fix format in gompd_enabled GET_VALUE.
(gompd_stringize_gompd_enabled): Removed.
(gompd_get_nthread, gompd_get_thread_limit, gompd_get_run_sched,
gompd_get_run_sched_chunk_size, gompd_get_default_device,
gompd_get_dynamic, gompd_get_max_active_levels, gompd_get_proc_bind,
gompd_is_final,
gompd_is_implicit, gompd_get_team_size): New functions.
(gompd_get_gompd_enabled): Change the returned value from
ompd_word_t to const char *.
* ompd-init.c (ompd_process_initialize): Use sizeof_short instead of
sizeof_long_long in GET_VALUE argument.
* ompd-support.h: Change type from __UINT64_TYPE__ to unsigned short.
(GOMPD_FOREACH_ACCESS): Add entries for gomp_task kind
and final_task and gomp_team nthreads.
* ompd-support.c (gompd_get_offset, gompd_get_sizeof_member,
gompd_get_size, OMPD_SECTION): Define.
(gompd_access_gomp_thread_handle,
gompd_sizeof_gomp_thread_handle): New variables.
(gompd_state): Change type from __UNIT64_TYPE__ to
unsigned short.
(gompd_load): Remove gompd_init_access, gompd_init_sizeof_members,
gompd_init_sizes, gompd_access_gomp_thread_handle,
gompd_sizeof_gomp_thread_handle.
* ompd-icv.c (ompd_get_icv_from_scope): Add thread_handle,
task_handle and parallel_handle. Fix format in ashandle definition.
Call gompd_get_nthread, gompd_get_thread_limit, gomp_get_run_shed,
gompd_get_run_sched_chunk_size, gompd_get_default_device,
gompd_get_dynamic, gompd_get_max_active_levels, gompd_get_proc_bind,
gompd_is_final,
gompd_is_implicit,
and gompd_get_team_size.
(ompd_get_icv_string_from_scope): Fix format in ashandle definition.
Add task_handle. Call gompd_get_gompd_enabled, and
gompd_get_proc_bind. Remove the call to
gompd_stringize_gompd_enabled.

Comments

Jakub Jelinek June 20, 2022, 7:31 a.m. UTC | #1
On Fri, Jun 17, 2022 at 01:20:28AM +0200, Mohamed Atef wrote:
> libgomp/ChangeLog
> 
> 2022-06-17  Mohamed Atef  <mohamedatef1698@gmail.com>
> 
> * ompd-helper.h (DEREFERENCE, ACCESS_VALUE): New macros.
> (gompd_get_proc_bind): Change the returned value from ompd_word_t
> to const char *.
> (gompd_get_max_task_priority): Fix format.
> (gompd_stringize_gompd_enabled): Removed.
> (gompd_get_gompd_enabled): New function prototype.
> * ompd-helper.c (gompd_get_affinity_format): Call CHECK_RET.
> Fix format in gompd_enabled GET_VALUE.
> (gompd_stringize_gompd_enabled): Removed.
> (gompd_get_nthread, gompd_get_thread_limit, gompd_get_run_sched,
> gompd_get_run_sched_chunk_size, gompd_get_default_device,
> gompd_get_dynamic, gompd_get_max_active_levels, gompd_get_proc_bind,
> gompd_is_final,
> gompd_is_implicit, gompd_get_team_size): New functions.
> (gompd_get_gompd_enabled): Change the returned value from
> ompd_word_t to const char *.
> * ompd-init.c (ompd_process_initialize): Use sizeof_short instead of
> sizeof_long_long in GET_VALUE argument.
> * ompd-support.h: Change type from __UINT64_TYPE__ to unsigned short.
> (GOMPD_FOREACH_ACCESS): Add entries for gomp_task kind
> and final_task and gomp_team nthreads.
> * ompd-support.c (gompd_get_offset, gompd_get_sizeof_member,
> gompd_get_size, OMPD_SECTION): Define.
> (gompd_access_gomp_thread_handle,
> gompd_sizeof_gomp_thread_handle): New variables.
> (gompd_state): Change type from __UNIT64_TYPE__ to
> unsigned short.
> (gompd_load): Remove gompd_init_access, gompd_init_sizeof_members,
> gompd_init_sizes, gompd_access_gomp_thread_handle,
> gompd_sizeof_gomp_thread_handle.
> * ompd-icv.c (ompd_get_icv_from_scope): Add thread_handle,
> task_handle and parallel_handle. Fix format in ashandle definition.

Just a nit.  After . there should be 2 spaces instead of one
unless it is at the end of line.

> Call gompd_get_nthread, gompd_get_thread_limit, gomp_get_run_shed,
> gompd_get_run_sched_chunk_size, gompd_get_default_device,
> gompd_get_dynamic, gompd_get_max_active_levels, gompd_get_proc_bind,
> gompd_is_final,
> gompd_is_implicit,
> and gompd_get_team_size.
> (ompd_get_icv_string_from_scope): Fix format in ashandle definition.
> Add task_handle. Call gompd_get_gompd_enabled, and

Here too.

> gompd_get_proc_bind. Remove the call to
> gompd_stringize_gompd_enabled.

> +
> +unsigned short gompd_access_gomp_thread_handle;
> +unsigned short gompd_sizeof_gomp_thread_handle;

This is undesirable, both because you are then mixing
const and non-const objects in OMPD_SECTION if GOMP_NEEDS_THREAD_HANDLE
is defined and because you need to duplicate the stuff in the macros.
I'd suggest
#ifndef GOMP_NEEDS_THREAD_HANDLE
const unsigned short gompd_access_gomp_thread_handle
  __attribute__ ((used)) OMPD_SECTION = 0;
const unsigned short gompd_sizeof_gomp_thread_handle
  __attribute__ ((used)) OMPD_SECTION = 0;
#endif

> +/* Get offset of the member m in struct t.  */
> +#define gompd_get_offset(t, m) \
> +  const unsigned short gompd_access_##t##_##m __attribute__ ((used)) \
> +    OMPD_SECTION \
> +      = (unsigned short) offsetof (struct t, m);
> +  GOMPD_FOREACH_ACCESS (gompd_get_offset)
> +#ifdef GOMP_NEEDS_THREAD_HANDLE
> +  gompd_access_gomp_thread_handle __attribute__ ((used)) OMPD_SECTION
> +    = (unsigned short) offsetof (gomp_thread, handle);
> +#endif

Remove the above 4 lines.

> +#undef gompd_get_offset
> +/* Get size of member m in struct t.  */
> +#define gompd_get_sizeof_member(t, m) \
> +  const unsigned short gompd_sizeof_##t##_##m __attribute__ ((used)) \
> +    OMPD_SECTION \
> +      = sizeof (((struct t *) NULL)->m);
> +  GOMPD_FOREACH_ACCESS (gompd_get_sizeof_member)
> +#ifdef GOMP_NEEDS_THREAD_HANDLE
> +  gompd_sizeof_gomp_thread_handle __attribute__ ((used)) OMPD_SECTION
> +    = sizeof (((struct gomp_thread *) NULL)->handle);
> +#endif

And these.

> +#undef gompd_get_sizeof_member
> +/* Get size of struct t.  */
> +#define gompd_get_size(t) \
> +  const unsigned short gompd_sizeof_##t##_ __attribute__ ((used)) \
> +    OMPD_SECTION \
> +      = sizeof (struct t);
> +  GOMPD_SIZES (gompd_get_size)
> +#undef gompd_get_size
>  
> --- a/libgomp/ompd-support.h
> +++ b/libgomp/ompd-support.h
> @@ -67,7 +67,7 @@
>  #endif
>  
>  void gompd_load (void);
> -extern __UINT64_TYPE__ gompd_state;
> +extern unsigned short gompd_state;
>  
>  #define OMPD_ENABLED 0x1

#ifdef GOMP_NEEDS_THREAD_HANDLE
#define gompd_thread_handle_access gompd_access (gomp_thread, handle)
#else
#define gompd_thread_handle_access
#endif

above the following macro.

> @@ -83,7 +83,10 @@ extern __UINT64_TYPE__ gompd_state;
>    gompd_access (gomp_thread_pool, threads) \
>    gompd_access (gomp_thread, ts) \
>    gompd_access (gomp_team_state, team_id) \
> -  gompd_access (gomp_task, icv)
> +  gompd_access (gomp_task, icv) \
> +  gompd_access (gomp_task, kind) \
> +  gompd_access (gomp_task, final_task) \
> +  gompd_access (gomp_team, nthreads)

and add \
  gompd_thread_handle_access
here.

Otherwise LGTM.

	Jakub
Mohamed Atef June 22, 2022, 2:17 a.m. UTC | #2
I forgot the DCO line. And I edited the commit message, but I can't push,
even forced push doesn't work.
Now I get the non-fast-forward error, is there any way to solve this?

On Mon, Jun 20, 2022 at 9:31 AM Jakub Jelinek <jakub@redhat.com> wrote:

> On Fri, Jun 17, 2022 at 01:20:28AM +0200, Mohamed Atef wrote:
> > libgomp/ChangeLog
> >
> > 2022-06-17  Mohamed Atef  <mohamedatef1698@gmail.com>
> >
> > * ompd-helper.h (DEREFERENCE, ACCESS_VALUE): New macros.
> > (gompd_get_proc_bind): Change the returned value from ompd_word_t
> > to const char *.
> > (gompd_get_max_task_priority): Fix format.
> > (gompd_stringize_gompd_enabled): Removed.
> > (gompd_get_gompd_enabled): New function prototype.
> > * ompd-helper.c (gompd_get_affinity_format): Call CHECK_RET.
> > Fix format in gompd_enabled GET_VALUE.
> > (gompd_stringize_gompd_enabled): Removed.
> > (gompd_get_nthread, gompd_get_thread_limit, gompd_get_run_sched,
> > gompd_get_run_sched_chunk_size, gompd_get_default_device,
> > gompd_get_dynamic, gompd_get_max_active_levels, gompd_get_proc_bind,
> > gompd_is_final,
> > gompd_is_implicit, gompd_get_team_size): New functions.
> > (gompd_get_gompd_enabled): Change the returned value from
> > ompd_word_t to const char *.
> > * ompd-init.c (ompd_process_initialize): Use sizeof_short instead of
> > sizeof_long_long in GET_VALUE argument.
> > * ompd-support.h: Change type from __UINT64_TYPE__ to unsigned short.
> > (GOMPD_FOREACH_ACCESS): Add entries for gomp_task kind
> > and final_task and gomp_team nthreads.
> > * ompd-support.c (gompd_get_offset, gompd_get_sizeof_member,
> > gompd_get_size, OMPD_SECTION): Define.
> > (gompd_access_gomp_thread_handle,
> > gompd_sizeof_gomp_thread_handle): New variables.
> > (gompd_state): Change type from __UNIT64_TYPE__ to
> > unsigned short.
> > (gompd_load): Remove gompd_init_access, gompd_init_sizeof_members,
> > gompd_init_sizes, gompd_access_gomp_thread_handle,
> > gompd_sizeof_gomp_thread_handle.
> > * ompd-icv.c (ompd_get_icv_from_scope): Add thread_handle,
> > task_handle and parallel_handle. Fix format in ashandle definition.
>
> Just a nit.  After . there should be 2 spaces instead of one
> unless it is at the end of line.
>
> > Call gompd_get_nthread, gompd_get_thread_limit, gomp_get_run_shed,
> > gompd_get_run_sched_chunk_size, gompd_get_default_device,
> > gompd_get_dynamic, gompd_get_max_active_levels, gompd_get_proc_bind,
> > gompd_is_final,
> > gompd_is_implicit,
> > and gompd_get_team_size.
> > (ompd_get_icv_string_from_scope): Fix format in ashandle definition.
> > Add task_handle. Call gompd_get_gompd_enabled, and
>
> Here too.
>
> > gompd_get_proc_bind. Remove the call to
> > gompd_stringize_gompd_enabled.
>
> > +
> > +unsigned short gompd_access_gomp_thread_handle;
> > +unsigned short gompd_sizeof_gomp_thread_handle;
>
> This is undesirable, both because you are then mixing
> const and non-const objects in OMPD_SECTION if GOMP_NEEDS_THREAD_HANDLE
> is defined and because you need to duplicate the stuff in the macros.
> I'd suggest
> #ifndef GOMP_NEEDS_THREAD_HANDLE
> const unsigned short gompd_access_gomp_thread_handle
>   __attribute__ ((used)) OMPD_SECTION = 0;
> const unsigned short gompd_sizeof_gomp_thread_handle
>   __attribute__ ((used)) OMPD_SECTION = 0;
> #endif
>
> > +/* Get offset of the member m in struct t.  */
> > +#define gompd_get_offset(t, m) \
> > +  const unsigned short gompd_access_##t##_##m __attribute__ ((used)) \
> > +    OMPD_SECTION \
> > +      = (unsigned short) offsetof (struct t, m);
> > +  GOMPD_FOREACH_ACCESS (gompd_get_offset)
> > +#ifdef GOMP_NEEDS_THREAD_HANDLE
> > +  gompd_access_gomp_thread_handle __attribute__ ((used)) OMPD_SECTION
> > +    = (unsigned short) offsetof (gomp_thread, handle);
> > +#endif
>
> Remove the above 4 lines.
>
> > +#undef gompd_get_offset
> > +/* Get size of member m in struct t.  */
> > +#define gompd_get_sizeof_member(t, m) \
> > +  const unsigned short gompd_sizeof_##t##_##m __attribute__ ((used)) \
> > +    OMPD_SECTION \
> > +      = sizeof (((struct t *) NULL)->m);
> > +  GOMPD_FOREACH_ACCESS (gompd_get_sizeof_member)
> > +#ifdef GOMP_NEEDS_THREAD_HANDLE
> > +  gompd_sizeof_gomp_thread_handle __attribute__ ((used)) OMPD_SECTION
> > +    = sizeof (((struct gomp_thread *) NULL)->handle);
> > +#endif
>
> And these.
>
> > +#undef gompd_get_sizeof_member
> > +/* Get size of struct t.  */
> > +#define gompd_get_size(t) \
> > +  const unsigned short gompd_sizeof_##t##_ __attribute__ ((used)) \
> > +    OMPD_SECTION \
> > +      = sizeof (struct t);
> > +  GOMPD_SIZES (gompd_get_size)
> > +#undef gompd_get_size
> >
> > --- a/libgomp/ompd-support.h
> > +++ b/libgomp/ompd-support.h
> > @@ -67,7 +67,7 @@
> >  #endif
> >
> >  void gompd_load (void);
> > -extern __UINT64_TYPE__ gompd_state;
> > +extern unsigned short gompd_state;
> >
> >  #define OMPD_ENABLED 0x1
>
> #ifdef GOMP_NEEDS_THREAD_HANDLE
> #define gompd_thread_handle_access gompd_access (gomp_thread, handle)
> #else
> #define gompd_thread_handle_access
> #endif
>
> above the following macro.
>
> > @@ -83,7 +83,10 @@ extern __UINT64_TYPE__ gompd_state;
> >    gompd_access (gomp_thread_pool, threads) \
> >    gompd_access (gomp_thread, ts) \
> >    gompd_access (gomp_team_state, team_id) \
> > -  gompd_access (gomp_task, icv)
> > +  gompd_access (gomp_task, icv) \
> > +  gompd_access (gomp_task, kind) \
> > +  gompd_access (gomp_task, final_task) \
> > +  gompd_access (gomp_team, nthreads)
>
> and add \
>   gompd_thread_handle_access
> here.
>
> Otherwise LGTM.
>
>         Jakub
>
>
Jakub Jelinek June 22, 2022, 7:55 a.m. UTC | #3
On Wed, Jun 22, 2022 at 04:17:45AM +0200, Mohamed Atef wrote:
> I forgot the DCO line. And I edited the commit message, but I can't push,
> even forced push doesn't work.

No, once you push, it will remain as is.
Don't forget next time...

	Jakub
diff mbox series

Patch

diff --git a/libgomp/ompd-helper.c b/libgomp/ompd-helper.c
index a488ba7df2e..9762b48dff8 100644
--- a/libgomp/ompd-helper.c
+++ b/libgomp/ompd-helper.c
@@ -116,6 +116,7 @@  gompd_get_affinity_format (ompd_address_space_handle_t *ah, const char **string)
   char *temp_str;
   ompd_word_t addr;
   ret = callbacks->alloc_memory (len + 1, (void **) &temp_str);
+  CHECK_RET (ret);
   temp_str[len] = '\0';
   ompd_address_t symbol_addr = {OMPD_SEGMENT_UNSPECIFIED, 0};
   ret = callbacks->symbol_addr_lookup (ah->context, NULL,
@@ -237,7 +238,7 @@  gompd_get_gompd_enabled (ompd_address_space_handle_t *ah, const char **string)
   ompd_rc_t ret;
   ompd_address_t symbol_addr = {OMPD_SEGMENT_UNSPECIFIED, 0};
   GET_VALUE (ah->context, NULL, "gompd_enabled", temp, temp,
-             target_sizes.sizeof_int, 1, ret, symbol_addr);
+	     target_sizes.sizeof_int, 1, ret, symbol_addr);
   static const char *temp_string = "disabled";
   if (temp == 1)
     temp_string = "enabled";
@@ -246,15 +247,363 @@  gompd_get_gompd_enabled (ompd_address_space_handle_t *ah, const char **string)
   *string = temp_string;
   return ret;
 }
+/* End of global ICVs functions.  */
 
+/* Get per thread ICVs.  */
 ompd_rc_t
-gompd_stringize_gompd_enabled (ompd_address_space_handle_t *ah,
-                               const char **string)
+gompd_get_nthread (ompd_thread_handle_t *thread_handle,
+		   ompd_word_t *nthreads_var)
 {
-  return gompd_get_gompd_enabled (ah, string);
+  /* gomp_thread->task->gomp_task_icv.nthreads_var.  */
+  if (thread_handle == NULL)
+    return ompd_rc_stale_handle;
+  if (nthreads_var == NULL)
+    return ompd_rc_bad_input;
+  CHECK (thread_handle->ah);
+
+  ompd_word_t res = 0;
+  ompd_address_t symbol_addr = thread_handle->th;
+  ompd_word_t temp_offset;
+  ompd_address_t temp_sym_addr;
+  ompd_addr_t temp_addr;
+  ompd_address_space_context_t *context = thread_handle->ah->context;
+  ompd_thread_context_t *t_context = thread_handle->thread_context;
+  ompd_rc_t ret;
+  /* gomp_thread->task.  */
+  ACCESS_VALUE (context, t_context, "gompd_access_gomp_thread_task",
+		temp_offset, 1, ret, symbol_addr, temp_sym_addr, temp_addr);
+  /* gomp_thread->task->task_icv.  */
+  ACCESS_VALUE (context, t_context, "gompd_access_gomp_task_icv", temp_offset,
+		1, ret, symbol_addr, temp_sym_addr, temp_addr);
+  /* gomp_thread->task->task_icv.nthreads_var.  */
+  ACCESS_VALUE (context, t_context, "gompd_access_gomp_task_icv_nthreads_var",
+		temp_offset, 0, ret, symbol_addr, temp_sym_addr, temp_addr);
+  DEREFERENCE (context, t_context, symbol_addr, target_sizes.sizeof_long_long,
+	       1, res, ret, 0);
+  *nthreads_var = res;
+  return ompd_rc_ok;
 }
 
-/* End of global ICVs functions.  */
+ompd_rc_t
+gompd_get_default_device (ompd_thread_handle_t *thread_handle,
+			  ompd_word_t *default_device_var)
+{
+  /* gomp_thread->task->gomp_task_icv.default_device_var.  */
+  if (thread_handle == NULL)
+    return ompd_rc_stale_handle;
+  if (default_device_var == NULL)
+    return ompd_rc_bad_input;
+  CHECK (thread_handle->ah);
+
+  ompd_word_t res = 0;
+  ompd_address_t symbol_addr = thread_handle->th;
+  ompd_word_t temp_offset;
+  ompd_address_t temp_sym_addr;
+  ompd_addr_t temp_addr;
+  ompd_address_space_context_t *context = thread_handle->ah->context;
+  ompd_thread_context_t *t_context = thread_handle->thread_context;
+  ompd_rc_t ret;
+  /* gomp_thread->task.  */
+  ACCESS_VALUE (context, t_context, "gompd_access_gomp_thread_task",
+		temp_offset, 1, ret, symbol_addr, temp_sym_addr, temp_addr);
+  /* gomp_thread->task->task_icv.  */
+  ACCESS_VALUE (context, t_context, "gompd_access_gomp_task_icv", temp_offset,
+		1, ret, symbol_addr, temp_sym_addr, temp_addr);
+  /* gomp_thread->task->task_icv.default_device_var.  */
+  ACCESS_VALUE (context, t_context,
+		"gompd_access_gomp_task_icv_default_device_var", temp_offset, 0,
+		ret, symbol_addr, temp_sym_addr, temp_addr);
+  DEREFERENCE (context, t_context, symbol_addr, target_sizes.sizeof_int, 1,
+	       res, ret, 0);
+  *default_device_var = res;
+  return ompd_rc_ok;
+}
+
+ompd_rc_t
+gompd_get_dynamic (ompd_thread_handle_t *thread_handle, ompd_word_t *dyn_var)
+{
+  /* gomp_thread->task->gomp_task_icv.dyn_var.  */
+  if (thread_handle == NULL)
+    return ompd_rc_stale_handle;
+  if (dyn_var == NULL)
+    return ompd_rc_bad_input;
+  CHECK (thread_handle->ah);
+
+  ompd_word_t res = 0;
+  ompd_address_t symbol_addr = thread_handle->th;
+  ompd_word_t temp_offset;
+  ompd_address_t temp_sym_addr;
+  ompd_addr_t temp_addr;
+  ompd_address_space_context_t *context = thread_handle->ah->context;
+  ompd_thread_context_t *t_context = thread_handle->thread_context;
+  ompd_rc_t ret;
+  /* gomp_thread->task.  */
+  ACCESS_VALUE (context, t_context, "gompd_access_gomp_thread_task",
+		temp_offset, 1, ret, symbol_addr, temp_sym_addr, temp_addr);
+  /* gomp_thread->task->task_icv.  */
+  ACCESS_VALUE (context, t_context, "gompd_access_gomp_task_icv", temp_offset,
+		1, ret, symbol_addr, temp_sym_addr, temp_addr);
+  /* gomp_thread->task->task_icv.dyn_var.  */
+  ACCESS_VALUE (context, t_context, "gompd_access_gomp_task_icv_dyn_var",
+		temp_offset, 0, ret, symbol_addr, temp_sym_addr, temp_addr);
+  DEREFERENCE (context, t_context, symbol_addr, target_sizes.sizeof_char, 1,
+	       res, ret, 0);
+  *dyn_var = res;
+  return ompd_rc_ok;
+}
+/* End of per thread ICVs.  */
+
+
+/* Get per task ICVs.  */
+
+ompd_rc_t
+gompd_get_thread_limit (ompd_task_handle_t *task_handle,
+			ompd_word_t *thread_limit_var)
+{
+  /* gomp_task->gomp_task_icv.thread_limit_var.  */
+  if (task_handle == NULL)
+    return ompd_rc_stale_handle;
+  if (thread_limit_var == NULL)
+    return ompd_rc_bad_input;
+  CHECK (task_handle->ah);
+
+  ompd_word_t res = 0;
+  ompd_address_t symbol_addr = task_handle->th;
+  ompd_word_t temp_offset;
+  ompd_address_t temp_sym_addr;
+  ompd_addr_t temp_addr;
+  ompd_address_space_context_t *context = task_handle->ah->context;
+  ompd_rc_t ret;
+  /* gomp_task->task_icv.  */
+  ACCESS_VALUE (context, NULL, "gompd_access_gomp_task_icv", temp_offset,
+		1, ret, symbol_addr, temp_sym_addr, temp_addr);
+  /* gomp_task->task_icv.thread_limit_var.  */
+  ACCESS_VALUE (context, NULL,
+		"gompd_access_gomp_task_icv_thread_limit_var", temp_offset, 0,
+		ret, symbol_addr, temp_sym_addr, temp_addr);
+  DEREFERENCE (context, NULL, symbol_addr, target_sizes.sizeof_int, 1,
+	       res, ret, 0);
+  *thread_limit_var = res;
+  return ompd_rc_ok;
+}
+
+ompd_rc_t
+gompd_get_run_sched_chunk_size (ompd_task_handle_t *task_handle,
+				ompd_word_t *run_sched_chunk_size)
+{
+  /* gomp_task->gomp_task_icv.run_sched_chunk_size.  */
+  if (task_handle == NULL)
+    return ompd_rc_stale_handle;
+  if (run_sched_chunk_size == NULL)
+    return ompd_rc_bad_input;
+  CHECK (task_handle->ah);
+
+  ompd_word_t res = 0;
+  ompd_address_t symbol_addr = task_handle->th;
+  ompd_word_t temp_offset;
+  ompd_address_t temp_sym_addr;
+  ompd_addr_t temp_addr;
+  ompd_address_space_context_t *context = task_handle->ah->context;
+  ompd_rc_t ret;
+  /* gomp_task->task_icv.  */
+  ACCESS_VALUE (context, NULL, "gompd_access_gomp_task_icv", temp_offset,
+		1, ret, symbol_addr, temp_sym_addr, temp_addr);
+  /* gomp_task->task_icv.run_sched_chunk_size.  */
+  ACCESS_VALUE (context, NULL,
+		"gompd_access_gomp_task_icv_run_sched_chunk_size", temp_offset,
+		0, ret, symbol_addr, temp_sym_addr, temp_addr);
+  DEREFERENCE (context, NULL, symbol_addr, target_sizes.sizeof_int, 1,
+	       res, ret, 0);
+  *run_sched_chunk_size = res;
+  return ompd_rc_ok;
+}
+
+ompd_rc_t
+gompd_get_run_sched (ompd_task_handle_t *task_handle,
+		     ompd_word_t *run_sched_var)
+{
+  /* gomp_task->gomp_task_icv.run_sched_var.  */
+  if (task_handle == NULL)
+    return ompd_rc_stale_handle;
+  if (run_sched_var == NULL)
+    return ompd_rc_bad_input;
+  CHECK (task_handle->ah);
+
+  ompd_word_t res = 0;
+  ompd_address_t symbol_addr = task_handle->th;
+  ompd_word_t temp_offset;
+  ompd_address_t temp_sym_addr;
+  ompd_addr_t temp_addr;
+  ompd_address_space_context_t *context = task_handle->ah->context;
+  ompd_rc_t ret;
+  /* gomp_task->task_icv.  */
+  ACCESS_VALUE (context, NULL, "gompd_access_gomp_task_icv", temp_offset,
+		1, ret, symbol_addr, temp_sym_addr, temp_addr);
+  /* gomp_task->task_icv.run_sched_var.  */
+  ACCESS_VALUE (context, NULL, "gompd_access_gomp_task_icv_run_sched_var",
+		temp_offset, 0, ret, symbol_addr, temp_sym_addr, temp_addr);
+  DEREFERENCE (context, NULL, symbol_addr, target_sizes.sizeof_int, 1,
+	       res, ret, 0);
+  *run_sched_var = res;
+  return ompd_rc_ok;
+}
+
+ompd_rc_t
+gompd_get_max_active_levels (ompd_task_handle_t *task_handle,
+			     ompd_word_t *max_active_levels_var)
+{
+  /* gomp_task->gomp_task_icv.max_active_levels_var.  */
+  if (task_handle == NULL)
+    return ompd_rc_stale_handle;
+  if (max_active_levels_var == NULL)
+    return ompd_rc_bad_input;
+  CHECK (task_handle->ah);
+
+  ompd_word_t res = 0;
+  ompd_address_t symbol_addr = task_handle->th;
+  ompd_word_t temp_offset;
+  ompd_address_t temp_sym_addr;
+  ompd_addr_t temp_addr;
+  ompd_address_space_context_t *context = task_handle->ah->context;
+  ompd_rc_t ret;
+  /* gomp_task->task_icv.  */
+  ACCESS_VALUE (context, NULL, "gompd_access_gomp_task_icv", temp_offset,
+		1, ret, symbol_addr, temp_sym_addr, temp_addr);
+  /* gomp_task->task_icv.run_sched_var.  */
+  ACCESS_VALUE (context, NULL,
+		"gompd_access_gomp_task_icv_max_active_levels_var", temp_offset,
+		0, ret, symbol_addr, temp_sym_addr, temp_addr);
+  DEREFERENCE (context, NULL, symbol_addr, target_sizes.sizeof_char, 1,
+	       res, ret, 0);
+  *max_active_levels_var = res;
+  return ompd_rc_ok;
+}
+
+ompd_rc_t
+gompd_get_proc_bind (ompd_task_handle_t *task_handle, const char **bind_var)
+{
+  /* gomp_task->gomp_task_icv.bind_var.  */
+  if (task_handle == NULL)
+    return ompd_rc_stale_handle;
+  if (bind_var == NULL)
+    return ompd_rc_bad_input;
+  CHECK (task_handle->ah);
+
+  ompd_word_t res = 0;
+  ompd_address_t symbol_addr = task_handle->th;
+  ompd_word_t temp_offset;
+  ompd_address_t temp_sym_addr;
+  ompd_addr_t temp_addr;
+  ompd_address_space_context_t *context = task_handle->ah->context;
+  ompd_rc_t ret;
+  /* gomp_task->task_icv.  */
+  ACCESS_VALUE (context, NULL, "gompd_access_gomp_task_icv", temp_offset,
+		1, ret, symbol_addr, temp_sym_addr, temp_addr);
+  /* gomp_task->task_icv.bind_var.  */
+  ACCESS_VALUE (context, NULL, "gompd_access_gomp_task_icv_bind_var",
+		temp_offset, 0, ret, symbol_addr, temp_sym_addr, temp_addr);
+  DEREFERENCE (context, NULL, symbol_addr, target_sizes.sizeof_char, 1,
+	       res, ret, 0);
+  static const char *temp_string = "undefined";
+  if (res == 0)
+    temp_string = "FALSE";
+  else if (res == 1)
+    temp_string = "TRUE";
+  else if (res == 2)
+    temp_string = "PRIMARY";
+  else if (res == 3)
+    temp_string = "CLOSE";
+  else if (res == 4)
+    temp_string = "SPREAD";
+  else
+    return ompd_rc_error;
+  *bind_var = temp_string;
+  return ompd_rc_ok;
+}
+
+ompd_rc_t
+gompd_is_final (ompd_task_handle_t *task_handle, ompd_word_t *final_task)
+{
+  /* gomp_task->final_task.  */
+  if (task_handle == NULL)
+    return ompd_rc_stale_handle;
+  if (final_task == NULL)
+    return ompd_rc_bad_input;
+  CHECK (task_handle->ah);
+
+  ompd_word_t res = 0;
+  ompd_address_t symbol_addr = task_handle->th;
+  ompd_word_t temp_offset;
+  ompd_address_t temp_sym_addr;
+  ompd_addr_t temp_addr;
+  ompd_address_space_context_t *context = task_handle->ah->context;
+  ompd_rc_t ret;
+  /* gomp_task->final_task.  */
+  ACCESS_VALUE (context, NULL, "gompd_access_gomp_task_final_task", temp_offset,
+		1, ret, symbol_addr, temp_sym_addr, temp_addr);
+  DEREFERENCE (context, NULL, symbol_addr, target_sizes.sizeof_char, 1,
+	       res, ret, 0);
+  *final_task = res;
+  return ompd_rc_ok;
+}
+
+ompd_rc_t
+gompd_is_implicit (ompd_task_handle_t *task_handle, ompd_word_t *task_kind)
+{
+  /* gomp_task->kind.  */
+  if (task_handle == NULL)
+    return ompd_rc_stale_handle;
+  if (task_kind == NULL)
+    return ompd_rc_bad_input;
+  CHECK (task_handle->ah);
+
+  ompd_word_t res = -1;
+  ompd_address_t symbol_addr = task_handle->th;
+  ompd_word_t temp_offset;
+  ompd_address_t temp_sym_addr;
+  ompd_addr_t temp_addr;
+  ompd_address_space_context_t *context = task_handle->ah->context;
+  ompd_rc_t ret;
+  /* gomp_task->kind.  */
+  ACCESS_VALUE (context, NULL, "gompd_access_gomp_task_kind", temp_offset, 1,
+		ret, symbol_addr, temp_sym_addr, temp_addr);
+  DEREFERENCE (context, NULL, symbol_addr, target_sizes.sizeof_int, 1, res,
+	       ret, 0);
+  /* if task is implicit, then res = 0.  */
+  res = res ? -1: 0;
+  *task_kind = res;
+  return ompd_rc_ok;
+}
+/* End of task ICVs.  */
+
+/* Get per parallel handle ICVs.  */
+ompd_rc_t
+gompd_get_team_size (ompd_parallel_handle_t *parallel_handle,
+		     ompd_word_t *nthreads)
+{
+  /* gomp_team->nthreads.  */
+  if (parallel_handle == NULL)
+    return ompd_rc_stale_handle;
+  if (nthreads == NULL)
+    return ompd_rc_bad_input;
+  CHECK (parallel_handle->ah);
+
+  ompd_word_t res = -1;
+  ompd_address_t symbol_addr = parallel_handle->th;
+  ompd_word_t temp_offset;
+  ompd_address_t temp_sym_addr;
+  ompd_addr_t temp_addr;
+  ompd_address_space_context_t *context = parallel_handle->ah->context;
+  ompd_rc_t ret;
+  /* gomp_team->nthreads.  */
+  ACCESS_VALUE (context, NULL, "gompd_access_gomp_team_nthreads", temp_offset,
+		1, ret, symbol_addr, temp_sym_addr, temp_addr);
+  DEREFERENCE (context, NULL, symbol_addr, target_sizes.sizeof_int, 1,
+	       res, ret, 0);
+  *nthreads = res;
+  return ompd_rc_ok;
+}
+/* End of parallel handle ICVs.  */
 
 ompd_rc_t
 gompd_get_sizes (ompd_address_space_context_t *context)
diff --git a/libgomp/ompd-helper.h b/libgomp/ompd-helper.h
index 22516af012a..db3cad3db25 100644
--- a/libgomp/ompd-helper.h
+++ b/libgomp/ompd-helper.h
@@ -90,6 +90,29 @@  typedef struct _ompd_task_handle
     CHECK_RET (ret); \
   } while (0)
 
+#define DEREFERENCE(context, thread_context, symbol_addr, size, count,\
+  buff, ret, is_ptr) \
+  do {\
+    ret = callbacks->read_memory (context, thread_context, &symbol_addr, \
+				  size, &buff); \
+    CHECK_RET (ret); \
+    ret = callbacks->device_to_host (context, &buff, size, count, &buff); \
+    CHECK_RET (ret); \
+    if (is_ptr) \
+      symbol_addr.address = buff; \
+  } while (0);
+
+#define ACCESS_VALUE(context, thread_context, name, temp_offset, \
+  access_pointer, ret, symbol_addr, temp_sym_addr, temp_addr) \
+  do { \
+    GET_VALUE (context, thread_context, name, temp_offset, temp_offset, \
+	       target_sizes.sizeof_short, 1, ret, temp_sym_addr); \
+    symbol_addr.address += temp_offset; \
+    for (int i = 0; i < access_pointer; i++) \
+      DEREFERENCE (context, thread_context, symbol_addr, \
+		   target_sizes.sizeof_pointer, 1, temp_addr, ret, 1); \
+  } while (0);
+
 #define CHECK(ah) \
   do {   \
     if (ah == NULL || ah->context == NULL) \
@@ -158,7 +181,7 @@  ompd_rc_t gompd_get_run_sched_chunk_size (ompd_task_handle_t *, ompd_word_t *);
 ompd_rc_t gompd_get_default_device (ompd_thread_handle_t *, ompd_word_t *);
 ompd_rc_t gompd_get_dynamic (ompd_thread_handle_t *, ompd_word_t *);
 ompd_rc_t gompd_get_max_active_levels (ompd_task_handle_t *, ompd_word_t *);
-ompd_rc_t gompd_get_proc_bind (ompd_task_handle_t *, ompd_word_t *);
+ompd_rc_t gompd_get_proc_bind (ompd_task_handle_t *, const char **);
 ompd_rc_t gompd_is_final (ompd_task_handle_t *, ompd_word_t *);
 ompd_rc_t gompd_is_implicit (ompd_task_handle_t *, ompd_word_t *);
 ompd_rc_t gompd_get_team_size (ompd_parallel_handle_t *, ompd_word_t *);
@@ -166,7 +189,7 @@  ompd_rc_t gompd_get_team_size (ompd_parallel_handle_t *, ompd_word_t *);
 /* Get Global ICVs.  */
 ompd_rc_t gompd_get_cancellation (ompd_address_space_handle_t *, ompd_word_t *);
 ompd_rc_t gompd_get_max_task_priority (ompd_address_space_handle_t *,
-  				       ompd_word_t *);
+				       ompd_word_t *);
 ompd_rc_t gompd_get_stacksize (ompd_address_space_handle_t *, ompd_word_t *);
 ompd_rc_t gompd_get_debug (ompd_address_space_handle_t *, ompd_word_t *);
 ompd_rc_t gompd_get_display_affinity (ompd_address_space_handle_t *,
@@ -186,8 +209,8 @@  ompd_rc_t gompd_get_throttled_spin_count (ompd_address_space_handle_t *,
 					  ompd_word_t *);
 ompd_rc_t gompd_get_managed_threads (ompd_address_space_handle_t *,
 				     ompd_word_t *);
-ompd_rc_t gompd_stringize_gompd_enabled (ompd_address_space_handle_t *,
-                                         const char **);
+ompd_rc_t gompd_get_gompd_enabled (ompd_address_space_handle_t *,
+				   const char **);
 /*End of Global ICVs.  */
 
 
diff --git a/libgomp/ompd-icv.c b/libgomp/ompd-icv.c
index 7f198d1638d..74c8fbf124a 100644
--- a/libgomp/ompd-icv.c
+++ b/libgomp/ompd-icv.c
@@ -97,7 +97,13 @@  ompd_get_icv_from_scope (void *handle, ompd_scope_t scope, ompd_icv_id_t icv_id,
     }
   /* No offloading support for now.  */
   ompd_address_space_handle_t *ashandle
-    = (ompd_address_space_handle_t *)handle;
+    = (ompd_address_space_handle_t *) handle;
+  ompd_thread_handle_t *thread_handle
+    = (ompd_thread_handle_t *) handle;
+  ompd_task_handle_t *task_handle
+    = (ompd_task_handle_t *) handle;
+  ompd_parallel_handle_t *parallel_handle
+    = (ompd_parallel_handle_t *) handle;
   if (device == OMPD_DEVICE_KIND_HOST)
     {
       switch (icv_id)
@@ -130,6 +136,26 @@  ompd_get_icv_from_scope (void *handle, ompd_scope_t scope, ompd_icv_id_t icv_id,
 	    return gompd_get_throttled_spin_count (ashandle, icv_value);
 	  case gompd_icv_managed_threads_var:
 	    return gompd_get_managed_threads (ashandle, icv_value);
+	  case gompd_icv_nthreads_var:
+	    return gompd_get_nthread (thread_handle, icv_value);
+	  case gompd_icv_default_device_var:
+	    return gompd_get_default_device (thread_handle, icv_value);
+	  case gompd_icv_dyn_var:
+	    return gompd_get_dynamic (thread_handle, icv_value);
+	  case gompd_icv_thread_limit_var:
+	    return gompd_get_thread_limit (task_handle, icv_value);
+	  case gompd_icv_run_sched_chunk_size:
+	    return gompd_get_run_sched_chunk_size (task_handle, icv_value);
+	  case gompd_icv_run_sched_var:
+	    return gompd_get_run_sched (task_handle, icv_value);
+	  case gompd_icv_max_active_levels_var:
+	    return gompd_get_max_active_levels (task_handle, icv_value);
+	  case gompd_icv_final_task_var:
+	    return gompd_is_final (task_handle, icv_value);
+	  case gompd_icv_implicit_task_var:
+	    return gompd_is_implicit (task_handle, icv_value);
+	  case gompd_icv_team_size_var:
+	    return gompd_get_team_size (parallel_handle, icv_value);
 	  default:
 	    return ompd_rc_unsupported;
 	}
@@ -167,7 +193,9 @@  ompd_get_icv_string_from_scope (void *handle, ompd_scope_t scope,
     }
   /* No offloading support for now.  */
   ompd_address_space_handle_t *ashandle
-    = (ompd_address_space_handle_t *)handle;
+    = (ompd_address_space_handle_t *) handle;
+  ompd_task_handle_t *task_handle
+    = (ompd_task_handle_t *) handle;
   if (device == OMPD_DEVICE_KIND_HOST)
     {
       switch (icv_id)
@@ -175,7 +203,9 @@  ompd_get_icv_string_from_scope (void *handle, ompd_scope_t scope,
 	  case gompd_icv_affinity_format_var:
 	    return gompd_get_affinity_format (ashandle, icv_value);
 	  case gompd_icv_ompd_state:
-	    return gompd_stringize_gompd_enabled (ashandle, icv_value);
+	    return gompd_get_gompd_enabled (ashandle, icv_value);
+	  case gompd_icv_bind_var:
+	    return gompd_get_proc_bind (task_handle, icv_value);
 	  default:
 	    return ompd_rc_unsupported;
 	}
diff --git a/libgomp/ompd-init.c b/libgomp/ompd-init.c
index 52866e4a99d..12679df0565 100644
--- a/libgomp/ompd-init.c
+++ b/libgomp/ompd-init.c
@@ -89,7 +89,7 @@  ompd_process_initialize (ompd_address_space_context_t *context,
   /* Naive way to read from memory.  */
   ompd_address_t symbol_addr = {OMPD_SEGMENT_UNSPECIFIED, 0};
   GET_VALUE (context, NULL, "gompd_state", gompd_state, gompd_state,
-	     target_sizes.sizeof_long_long, 1, ret, symbol_addr);
+	     target_sizes.sizeof_short, 1, ret, symbol_addr);
 
   ret = callbacks->alloc_memory (sizeof (ompd_address_space_handle_t),
 				 (void **) (handle));
diff --git a/libgomp/ompd-support.c b/libgomp/ompd-support.c
index d8a7174b2f3..7c33e618d42 100644
--- a/libgomp/ompd-support.c
+++ b/libgomp/ompd-support.c
@@ -20,48 +20,51 @@ 
 
 #include "ompd-support.h"
 
-#define gompd_declare_access(t, m) __UINT64_TYPE__ gompd_access_##t##_##m;
-  GOMPD_FOREACH_ACCESS (gompd_declare_access)
-#undef gompd_declare_access
-
-#define gompd_declare_sizeof_members(t, m) \
-  __UINT64_TYPE__ gompd_sizeof_##t##_##m;
-  GOMPD_FOREACH_ACCESS (gompd_declare_sizeof_members)
-#undef gompd_declare_sizeof_members
-
-#define gompd_declare_sizes(t) __UINT64_TYPE__ gompd_sizeof_##t;
-  GOMPD_SIZES (gompd_declare_sizes)
-#undef gompd_declare_sizes
+#ifdef __ELF__
+#define OMPD_SECTION __attribute__ ((section ("OMPD")))
+#else
+#define OMPD_SECTION
+#endif
+
+unsigned short gompd_access_gomp_thread_handle;
+unsigned short gompd_sizeof_gomp_thread_handle;
+
+/* Get offset of the member m in struct t.  */
+#define gompd_get_offset(t, m) \
+  const unsigned short gompd_access_##t##_##m __attribute__ ((used)) \
+    OMPD_SECTION \
+      = (unsigned short) offsetof (struct t, m);
+  GOMPD_FOREACH_ACCESS (gompd_get_offset)
+#ifdef GOMP_NEEDS_THREAD_HANDLE
+  gompd_access_gomp_thread_handle __attribute__ ((used)) OMPD_SECTION
+    = (unsigned short) offsetof (gomp_thread, handle);
+#endif
+#undef gompd_get_offset
+/* Get size of member m in struct t.  */
+#define gompd_get_sizeof_member(t, m) \
+  const unsigned short gompd_sizeof_##t##_##m __attribute__ ((used)) \
+    OMPD_SECTION \
+      = sizeof (((struct t *) NULL)->m);
+  GOMPD_FOREACH_ACCESS (gompd_get_sizeof_member)
+#ifdef GOMP_NEEDS_THREAD_HANDLE
+  gompd_sizeof_gomp_thread_handle __attribute__ ((used)) OMPD_SECTION
+    = sizeof (((struct gomp_thread *) NULL)->handle);
+#endif
+#undef gompd_get_sizeof_member
+/* Get size of struct t.  */
+#define gompd_get_size(t) \
+  const unsigned short gompd_sizeof_##t##_ __attribute__ ((used)) \
+    OMPD_SECTION \
+      = sizeof (struct t);
+  GOMPD_SIZES (gompd_get_size)
+#undef gompd_get_size
 
 const char **ompd_dll_locations = NULL;
-__UINT64_TYPE__ gompd_state;
+unsigned short gompd_state;
 
 void
 gompd_load (void)
 {
-  /* Get the offset of the struct members.  */
-  #define gompd_init_access(t, m)  \
-    gompd_access_##t##_##m = (__UINT64_TYPE__) & (((struct t *) NULL)->m);
-    GOMPD_FOREACH_ACCESS (gompd_init_access);
-  #undef gompd_init_access
-
-  /* Get sizeof members.  */
-
-  #define gompd_init_sizeof_members(t, m) \
-    gompd_sizeof_##t##_##m = sizeof (((struct t *) NULL)->m);
-    GOMPD_FOREACH_ACCESS (gompd_init_sizeof_members);
-  #undef gompd_declare_sizeof_members
-
-  #define gompd_init_sizes(t) gompd_sizeof_##t = sizeof (struct t);
-    GOMPD_SIZES (gompd_init_sizes)
-  #undef gompd_init_sizes
-
-  #ifdef GOMP_NEEDS_THREAD_HANDLE
-    __UINT64_TYPE__ gompd_access_gomp_thread_handle
-      = (__UINT64_TYPE__) & (((struct gomp_thread *) NULL)->handle);
-    __UINT64_TYPE__ gompd_sizeof_gomp_thread_handle
-      = sizeof (((struct gomp_thread *) NULL)->handle);
-  #endif
   gomp_debug (2, "OMP OMPD active\n");
   static const char *ompd_dll_locations_array[2]
     = {"libgompd" SONAME_SUFFIX (1) , NULL};
diff --git a/libgomp/ompd-support.h b/libgomp/ompd-support.h
index 39d55161132..172f5928335 100644
--- a/libgomp/ompd-support.h
+++ b/libgomp/ompd-support.h
@@ -67,7 +67,7 @@ 
 #endif
 
 void gompd_load (void);
-extern __UINT64_TYPE__ gompd_state;
+extern unsigned short gompd_state;
 
 #define OMPD_ENABLED 0x1
 
@@ -83,7 +83,10 @@  extern __UINT64_TYPE__ gompd_state;
   gompd_access (gomp_thread_pool, threads) \
   gompd_access (gomp_thread, ts) \
   gompd_access (gomp_team_state, team_id) \
-  gompd_access (gomp_task, icv)
+  gompd_access (gomp_task, icv) \
+  gompd_access (gomp_task, kind) \
+  gompd_access (gomp_task, final_task) \
+  gompd_access (gomp_team, nthreads)
 
 #define GOMPD_SIZES(gompd_size) \
   gompd_size (gomp_thread) \