[Openmp-commits] [PATCH] D61657: Add implementation to two OMPT API routines

Hansang Bae via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Tue May 7 14:34:38 PDT 2019


hbae created this revision.
hbae added reviewers: AndreyChurbanov, tlwilmar, jlpeyton, protze.joachim.
hbae added a project: OpenMP.
Herald added a subscriber: jdoerfert.

This change adds implementation to `ompt_finalize_tool()` and `ompt_get_task_memory()`.


Repository:
  rOMP OpenMP

https://reviews.llvm.org/D61657

Files:
  runtime/src/ompt-general.cpp
  runtime/src/ompt-specific.cpp


Index: runtime/src/ompt-specific.cpp
===================================================================
--- runtime/src/ompt-specific.cpp
+++ runtime/src/ompt-specific.cpp
@@ -427,6 +427,35 @@
   return 0;
 }
 
+int __ompt_get_task_memory_internal(void **addr, size_t *size, int blocknum) {
+  if (blocknum != 0)
+    return 0; // support only a single block
+
+  kmp_info_t *thr = ompt_get_thread();
+  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 = ret_size;
+  return 1;
+}
+
 //----------------------------------------------------------
 // team support
 //----------------------------------------------------------
Index: runtime/src/ompt-general.cpp
===================================================================
--- runtime/src/ompt-general.cpp
+++ runtime/src/ompt-general.cpp
@@ -523,8 +523,7 @@
 
 OMPT_API_ROUTINE int ompt_get_task_memory(void **addr, size_t *size,
                                           int block) {
-  // stub
-  return 0;
+  return __ompt_get_task_memory_internal(addr, size, block);
 }
 
 /*****************************************************************************
@@ -699,9 +698,7 @@
   return __ompt_get_unique_id_internal();
 }
 
-OMPT_API_ROUTINE void ompt_finalize_tool(void) {
-  // stub
-}
+OMPT_API_ROUTINE void ompt_finalize_tool(void) { __kmp_internal_end_atexit(); }
 
 /*****************************************************************************
  * Target


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61657.198530.patch
Type: text/x-patch
Size: 1963 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20190507/64b88eee/attachment.bin>


More information about the Openmp-commits mailing list