public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Mohamed Atef <mohamedatef1698@gmail.com>
To: gcc-patches@gcc.gnu.org, Jakub Jelinek <jakub@redhat.com>,
	 Mohamed Sayed <mohamedsayed22198@gmail.com>,
	ahmedsayedmousse@gmail.com,  youssef.magdy.775@gmail.com,
	aya.nashaat99@gmail.com
Subject: [PATCH] libgompd: Fix sizes in OMPD support and add local ICVs finctions.
Date: Fri, 10 Jun 2022 17:56:37 +0200	[thread overview]
Message-ID: <CAPFh8N+4YqVD2sk7H33mT7YdUT6Lzfdhz8Z0o_QbW9UObiNRzQ@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1054 bytes --]

libgomp/ChangeLog

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

* ompd-helper.h (DEREFERENCE, ACCESS_VALUE): New macros.
* ompd-helper.c (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, gompd_get_team_size): defined.
* ompd-icv.c (ompd_get_icv_from_scope): call the previous fincions,
thread_handle, task_handle and parallel handle: New variable.
Fix format in ashandle definition.
* ompd-init.c: call GET_VALUE with sizeof_short for gompd_state.
* ompd-support.h (gompd_state): size of short instead of long.
(GOMPD_FOREACH_ACCESS): Add
gompd_access (gomp_task, kind)
gompd_access (gomp_task, final_task)
gompd_access (gomp_team, nthreads)
* ompd-support.c: Define
gompd_get_offset
gompd_get_sizeof_member
gompd_get_size.
(gompd_load): Remove gompd_init_access,
gompd_init_sizeof_members, gompd_init_sizes
define gompd_access_gomp_thread_handle with __UINT16_TYPE__.

[-- Attachment #2: diff.txt --]
[-- Type: text/plain, Size: 21392 bytes --]

diff --git a/libgomp/ompd-helper.c b/libgomp/ompd-helper.c
index a488ba7df2e..5a79ef9581d 100644
--- a/libgomp/ompd-helper.c
+++ b/libgomp/ompd-helper.c
@@ -256,6 +256,350 @@ gompd_stringize_gompd_enabled (ompd_address_space_handle_t *ah,
 
 /* End of global ICVs functions.  */
 
+/* Get per thread ICVs.  */
+
+ompd_rc_t
+gompd_get_nthread (ompd_thread_handle_t *thread_handle,
+                   ompd_word_t *nthreads_var)
+{
+  /* 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;
+}
+
+ompd_rc_t
+gompd_get_default_device (ompd_thread_handle_t *thread_handle,
+                          ompd_word_t *defalut_device_var)
+{
+  /* gomp_thread->task->gomp_task_icv.default_device_var.  */
+  if (thread_handle == NULL)
+    return ompd_rc_stale_handle;
+  if (defalut_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);
+  *defalut_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.thred_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, ompd_word_t *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);
+  *bind_var = res;
+  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..7f5fcc69dfc 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) \
diff --git a/libgomp/ompd-icv.c b/libgomp/ompd-icv.c
index 7f198d1638d..746108ec632 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,28 @@ 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_bind_var:
+            return gompd_get_proc_bind (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;
 	}
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..1268aacb2ee 100644
--- a/libgomp/ompd-support.c
+++ b/libgomp/ompd-support.c
@@ -20,46 +20,58 @@
 
 #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__
+/* Get offset of the member m in struct t.  */
+#define gompd_get_offset(t, m) \
+  const __UINT16_TYPE__ gompd_access_##t##_##m __attribute__ ((used)) \
+    __attribute__ ((section ("OMPD"))) \
+      = (__UINT16_TYPE__) offsetof (struct t, m);
+  GOMPD_FOREACH_ACCESS (gompd_get_offset)
+#undef gompd_get_offset
+/* Get size of member m in struct t.  */
+#define gompd_get_sizeof_member(t, m) \
+  const __UINT16_TYPE__ gompd_sizeof_##t##_##m __attribute__ ((used)) \
+    __attribute__ ((section("OMPD")))\
+      = sizeof (((struct t *) NULL)->m);
+  GOMPD_FOREACH_ACCESS (gompd_get_sizeof_member)
+#undef gompd_get_sizeof_member
+/* Get size of struct t.  */
+#define gompd_get_size(t) \
+const __UINT16_TYPE__ gompd_sizeof_##t##_ __attribute__ ((used)) \
+    __attribute__ ((section ("OMPD"))) \
+      = sizeof (struct t);
+  GOMPD_SIZES (gompd_get_size)
+#undef gompd_get_size
+#else /* __ELF__ */
+#define gompd_get_offset(t, m) \
+  const __UINT16_TYPE__ gompd_access_##t##_##m __attribute__ ((used)) \
+    = (__UINT16_TYPE__) offsetof (struct t, m);
+  GOMPD_FOREACH_ACCESS (gompd_get_offset)
+#undef gompd_get_offset
+
+#define gompd_get_sizeof_member(t, m) \
+  const __UINT16_TYPE__ gompd_sizeof_##t##_##m __attribute__ ((used)) \
+    = sizeof (((struct t *) NULL)->m);
+  GOMPD_FOREACH_ACCESS (gompd_get_sizeof_member)
+#undef gompd_get_sizeof_member
+
+#define gompd_get_size(t) \
+  const __UINT16_TYPE__ gompd_sizeof_##t##_ __attribute__ ((used)) \
+    = sizeof (struct t);
+  GOMPD_SIZES (gompd_get_size)
+#undef gompd_get_size
+#endif /* __ELF__ */
 
 const char **ompd_dll_locations = NULL;
-__UINT64_TYPE__ gompd_state;
+__UINT16_TYPE__ 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
+    __UINT16_TYPE__ gompd_access_gomp_thread_handle
+      = (__UINT16_TYPE__) & (((struct gomp_thread *) NULL)->handle);
+    __UINT16_TYPE__ gompd_sizeof_gomp_thread_handle
       = sizeof (((struct gomp_thread *) NULL)->handle);
   #endif
   gomp_debug (2, "OMP OMPD active\n");
diff --git a/libgomp/ompd-support.h b/libgomp/ompd-support.h
index 39d55161132..5d7e5c24e3f 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 __UINT16_TYPE__ 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) \

             reply	other threads:[~2022-06-10 15:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-10 15:56 Mohamed Atef [this message]
2022-06-15  9:55 ` Mohamed Atef
2022-06-16 12:22 ` Jakub Jelinek
2022-06-16 23:20 Mohamed Atef
2022-06-20  7:31 ` Jakub Jelinek
2022-06-22  2:17   ` Mohamed Atef
2022-06-22  7:55     ` 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=CAPFh8N+4YqVD2sk7H33mT7YdUT6Lzfdhz8Z0o_QbW9UObiNRzQ@mail.gmail.com \
    --to=mohamedatef1698@gmail.com \
    --cc=ahmedsayedmousse@gmail.com \
    --cc=aya.nashaat99@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=mohamedsayed22198@gmail.com \
    --cc=youssef.magdy.775@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).