[Openmp-commits] [PATCH] D70408: [OpenMP][Tool] Improving stack trace for Archer

Joachim Protze via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Tue Jan 14 00:17:36 PST 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rGed810da73270: [OpenMP][Tool] Improving stack trace for Archer (authored by protze.joachim).

Changed prior to commit:
  https://reviews.llvm.org/D70408?vs=229887&id=237865#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70408/new/

https://reviews.llvm.org/D70408

Files:
  openmp/tools/archer/ompt-tsan.cpp


Index: openmp/tools/archer/ompt-tsan.cpp
===================================================================
--- openmp/tools/archer/ompt-tsan.cpp
+++ openmp/tools/archer/ompt-tsan.cpp
@@ -162,6 +162,8 @@
   runOnTsan = 0;
   return 0;
 }
+void __attribute__((weak)) __tsan_func_entry(const void *call_pc) {}
+void __attribute__((weak)) __tsan_func_exit(void) {}
 #endif
 }
 
@@ -189,6 +191,10 @@
   AnnotateNewMemory(__FILE__, __LINE__, addr, size)
 #endif
 
+// Function entry/exit
+#define TsanFuncEntry(pc) __tsan_func_entry(pc)
+#define TsanFuncExit() __tsan_func_exit()
+
 /// Required OMPT inquiry functions.
 static ompt_get_parallel_info_t ompt_get_parallel_info;
 static ompt_get_thread_data_t ompt_get_thread_data;
@@ -301,10 +307,13 @@
   /// Two addresses for relationships with barriers.
   ompt_tsan_clockid Barrier[2];
 
+  const void *codePtr;
+
   void *GetParallelPtr() { return &(Barrier[1]); }
 
   void *GetBarrierPtr(unsigned Index) { return &(Barrier[Index]); }
 
+  ParallelData(const void *codeptr) : codePtr(codeptr) {}
   ~ParallelData() {
     TsanDeleteClock(&(Barrier[0]));
     TsanDeleteClock(&(Barrier[1]));
@@ -458,7 +467,7 @@
                                      uint32_t requested_team_size,
                                      int flag,
                                      const void *codeptr_ra) {
-  ParallelData *Data = new ParallelData;
+  ParallelData *Data = new ParallelData(codeptr_ra);
   parallel_data->ptr = Data;
 
   TsanHappensBefore(Data->GetParallelPtr());
@@ -491,8 +500,12 @@
                                     int type) {
   switch (endpoint) {
   case ompt_scope_begin:
+    if (type & ompt_task_initial) {
+      parallel_data->ptr = new ParallelData(nullptr);
+    }
     task_data->ptr = new TaskData(ToParallelData(parallel_data));
     TsanHappensAfter(ToParallelData(parallel_data)->GetParallelPtr());
+    TsanFuncEntry(ToParallelData(parallel_data)->codePtr);
     break;
   case ompt_scope_end:
     TaskData *Data = ToTaskData(task_data);
@@ -501,6 +514,7 @@
     assert(Data->RefCount == 1 &&
            "All tasks should have finished at the implicit barrier!");
     delete Data;
+    TsanFuncExit();
     break;
   }
 }
@@ -513,6 +527,7 @@
   TaskData *Data = ToTaskData(task_data);
   switch (endpoint) {
   case ompt_scope_begin:
+    TsanFuncEntry(codeptr_ra);
     switch (kind) {
       case ompt_sync_region_barrier_implementation:
       case ompt_sync_region_barrier_implicit:
@@ -546,6 +561,7 @@
     }
     break;
   case ompt_scope_end:
+    TsanFuncExit();
     switch (kind) {
       case ompt_sync_region_barrier_implementation:
       case ompt_sync_region_barrier_implicit:
@@ -641,7 +657,7 @@
     ompt_data_t *parallel_data;
     int team_size = 1;
     ompt_get_parallel_info(0, &parallel_data, &team_size);
-    ParallelData *PData = new ParallelData;
+    ParallelData *PData = new ParallelData(nullptr);
     parallel_data->ptr = PData;
 
     Data = new TaskData(PData);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70408.237865.patch
Type: text/x-patch
Size: 2974 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20200114/8712b7fe/attachment.bin>


More information about the Openmp-commits mailing list