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, ¶llel_data, &team_size); - ParallelData *PData = new ParallelData; + ParallelData *PData = new ParallelData(nullptr); parallel_data->ptr = PData; Data = new TaskData(PData); Index: openmp/tools/archer/tests/CMakeLists.txt =================================================================== --- openmp/tools/archer/tests/CMakeLists.txt +++ openmp/tools/archer/tests/CMakeLists.txt @@ -26,7 +26,7 @@ pythonize_bool(LIBARCHER_HAVE_LIBATOMIC) -add_openmp_testsuite(check-libarcher "Running libarcher tests" ${CMAKE_CURRENT_BINARY_DIR} DEPENDS archer) +add_openmp_testsuite(check-libarcher "Running libarcher tests" ${CMAKE_CURRENT_BINARY_DIR} DEPENDS archer omp) # Configure the lit.site.cfg.in file set(AUTO_GEN_COMMENT "## Autogenerated by libarcher configuration.\n# Do not edit!")