[Openmp-commits] [openmp] cec855a - [OpenMP][OMPT] Fix ompt_get_task_memory implementation

Joachim Jenke via Openmp-commits openmp-commits at lists.llvm.org
Mon Aug 28 00:19:59 PDT 2023


Author: Joachim Jenke
Date: 2023-08-28T09:19:52+02:00
New Revision: cec855af3e17274b4bceda9f96c6a80aa7a5252d

URL: https://github.com/llvm/llvm-project/commit/cec855af3e17274b4bceda9f96c6a80aa7a5252d
DIFF: https://github.com/llvm/llvm-project/commit/cec855af3e17274b4bceda9f96c6a80aa7a5252d.diff

LOG: [OpenMP][OMPT] Fix ompt_get_task_memory implementation

Since td_allow_completion_event is a member of the taskdata struct, not all
firstprivate/shared variables are stored at the end of the task memory
allocation. Simply report the whole allocation instead.

Furthermore, the function should always return 0 since in no case there is
another block to report.

Differential Review: https://reviews.llvm.org/D158080

Added: 
    

Modified: 
    openmp/runtime/src/ompt-specific.cpp

Removed: 
    


################################################################################
diff  --git a/openmp/runtime/src/ompt-specific.cpp b/openmp/runtime/src/ompt-specific.cpp
index 54edd6e6af7cac..9743f35d2c4ff3 100644
--- a/openmp/runtime/src/ompt-specific.cpp
+++ b/openmp/runtime/src/ompt-specific.cpp
@@ -463,6 +463,7 @@ int __ompt_get_task_info_internal(int ancestor_level, int *type,
 }
 
 int __ompt_get_task_memory_internal(void **addr, size_t *size, int blocknum) {
+  *size = 0;
   if (blocknum != 0)
     return 0; // support only a single block
 
@@ -471,27 +472,13 @@ int __ompt_get_task_memory_internal(void **addr, size_t *size, int blocknum) {
     return 0;
 
   kmp_taskdata_t *taskdata = thr->th.th_current_task;
-  kmp_task_t *task = KMP_TASKDATA_TO_TASK(taskdata);
 
   if (taskdata->td_flags.tasktype != TASK_EXPLICIT)
     return 0; // support only explicit task
 
-  void *ret_addr;
-  int64_t ret_size = taskdata->td_size_alloc - sizeof(kmp_taskdata_t);
-
-  // kmp_task_t->data1 is an optional member
-  if (taskdata->td_flags.destructors_thunk)
-    ret_addr = &task->data1 + 1;
-  else
-    ret_addr = &task->part_id + 1;
-
-  ret_size -= (char *)(ret_addr) - (char *)(task);
-  if (ret_size < 0)
-    return 0;
-
-  *addr = ret_addr;
-  *size = (size_t)ret_size;
-  return 1;
+  *addr = taskdata;
+  *size = taskdata->td_size_alloc;
+  return 0;
 }
 
 //----------------------------------------------------------


        


More information about the Openmp-commits mailing list