diff --git a/openmp/libomptarget/include/SourceInfo.h b/openmp/libomptarget/include/SourceInfo.h --- a/openmp/libomptarget/include/SourceInfo.h +++ b/openmp/libomptarget/include/SourceInfo.h @@ -70,13 +70,13 @@ end = sourceStr.find(';', begin + 1); } return sourceStr.substr(begin + 1, end - begin - 1); - }; + } /// Get the filename from a full path. std::string removePath(const std::string &path) const { std::size_t pos = (OS_WINDOWS) ? path.rfind('\\') : path.rfind('/'); return path.substr(pos + 1); - }; + } public: SourceInfo(const ident_t *loc) @@ -91,6 +91,7 @@ const char *getName() const { return name.c_str(); } const char *getFilename() const { return filename.c_str(); } + const char *getProfileLocation() const { return sourceStr.data(); } int32_t getLine() const { return line; } int32_t getColumn() const { return column; } bool isAvailible() const { return (line || column); } diff --git a/openmp/libomptarget/src/interface.cpp b/openmp/libomptarget/src/interface.cpp --- a/openmp/libomptarget/src/interface.cpp +++ b/openmp/libomptarget/src/interface.cpp @@ -132,7 +132,7 @@ int64_t *arg_types, map_var_info_t *arg_names, void **arg_mappers) { - TIMESCOPE(); + TIMESCOPE_WITH_IDENT(loc); if (IsOffloadDisabled()) return; DP("Entering data begin region for device %" PRId64 " with %d mappings\n", @@ -174,7 +174,7 @@ void **args, int64_t *arg_sizes, int64_t *arg_types, map_var_info_t *arg_names, void **arg_mappers, int32_t depNum, void *depList, int32_t noAliasDepNum, void *noAliasDepList) { - TIMESCOPE(); + TIMESCOPE_WITH_IDENT(loc); if (depNum + noAliasDepNum > 0) __kmpc_omp_taskwait(loc, __kmpc_global_thread_num(loc)); @@ -210,7 +210,7 @@ int64_t *arg_types, map_var_info_t *arg_names, void **arg_mappers) { - TIMESCOPE(); + TIMESCOPE_WITH_IDENT(loc); if (IsOffloadDisabled()) return; DP("Entering data end region with %d mappings\n", arg_num); @@ -257,7 +257,7 @@ void **args, int64_t *arg_sizes, int64_t *arg_types, map_var_info_t *arg_names, void **arg_mappers, int32_t depNum, void *depList, int32_t noAliasDepNum, void *noAliasDepList) { - TIMESCOPE(); + TIMESCOPE_WITH_IDENT(loc); if (depNum + noAliasDepNum > 0) __kmpc_omp_taskwait(loc, __kmpc_global_thread_num(loc)); @@ -290,7 +290,7 @@ int64_t *arg_types, map_var_info_t *arg_names, void **arg_mappers) { - TIMESCOPE(); + TIMESCOPE_WITH_IDENT(loc); if (IsOffloadDisabled()) return; DP("Entering data update with %d mappings\n", arg_num); @@ -320,7 +320,7 @@ void **args, int64_t *arg_sizes, int64_t *arg_types, map_var_info_t *arg_names, void **arg_mappers, int32_t depNum, void *depList, int32_t noAliasDepNum, void *noAliasDepList) { - TIMESCOPE(); + TIMESCOPE_WITH_IDENT(loc); if (depNum + noAliasDepNum > 0) __kmpc_omp_taskwait(loc, __kmpc_global_thread_num(loc)); @@ -351,7 +351,7 @@ int32_t arg_num, void **args_base, void **args, int64_t *arg_sizes, int64_t *arg_types, map_var_info_t *arg_names, void **arg_mappers) { - TIMESCOPE(); + TIMESCOPE_WITH_IDENT(loc); if (IsOffloadDisabled()) return OFFLOAD_FAIL; DP("Entering target region with entry point " DPxMOD " and device Id %" PRId64 "\n", DPxPTR(host_ptr), device_id); @@ -389,7 +389,7 @@ void **args_base, void **args, int64_t *arg_sizes, int64_t *arg_types, map_var_info_t *arg_names, void **arg_mappers, int32_t depNum, void *depList, int32_t noAliasDepNum, void *noAliasDepList) { - TIMESCOPE(); + TIMESCOPE_WITH_IDENT(loc); if (depNum + noAliasDepNum > 0) __kmpc_omp_taskwait(loc, __kmpc_global_thread_num(loc)); @@ -426,7 +426,7 @@ map_var_info_t *arg_names, void **arg_mappers, int32_t team_num, int32_t thread_limit) { - TIMESCOPE(); + TIMESCOPE_WITH_IDENT(loc); if (IsOffloadDisabled()) return OFFLOAD_FAIL; DP("Entering target region with entry point " DPxMOD " and device Id %" PRId64 "\n", DPxPTR(host_ptr), device_id); @@ -466,7 +466,7 @@ map_var_info_t *arg_names, void **arg_mappers, int32_t team_num, int32_t thread_limit, int32_t depNum, void *depList, int32_t noAliasDepNum, void *noAliasDepList) { - TIMESCOPE(); + TIMESCOPE_WITH_IDENT(loc); if (depNum + noAliasDepNum > 0) __kmpc_omp_taskwait(loc, __kmpc_global_thread_num(loc)); @@ -501,7 +501,7 @@ EXTERN void __kmpc_push_target_tripcount(ident_t *loc, int64_t device_id, uint64_t loop_tripcount) { - TIMESCOPE(); + TIMESCOPE_WITH_IDENT(loc); if (IsOffloadDisabled()) return; diff --git a/openmp/libomptarget/src/private.h b/openmp/libomptarget/src/private.h --- a/openmp/libomptarget/src/private.h +++ b/openmp/libomptarget/src/private.h @@ -151,8 +151,12 @@ #ifdef OMPTARGET_PROFILE_ENABLED #include "llvm/Support/TimeProfiler.h" #define TIMESCOPE() llvm::TimeTraceScope TimeScope(__FUNCTION__) +#define TIMESCOPE_WITH_IDENT(IDENT) \ + SourceInfo SI(IDENT); \ + llvm::TimeTraceScope TimeScope(__FUNCTION__, SI.getProfileLocation()) #else #define TIMESCOPE() +#define TIMESCOPE_WITH_IDENT(IDENT) #endif #endif