[flang-commits] [openmp] [libcxx] [clang-tools-extra] [clang] [llvm] [libc] [flang] [lld] [lldb] [compiler-rt] [PGO][OpenMP] Instrumentation for GPU devices (PR #76587)

Ethan Luis McDonough via flang-commits flang-commits at lists.llvm.org
Thu Jan 4 20:45:08 PST 2024


================
@@ -58,6 +60,22 @@ class GlobalTy {
   void setPtr(void *P) { Ptr = P; }
 };
 
+typedef void *IntPtrT;
+struct __llvm_profile_data {
+#define INSTR_PROF_DATA(Type, LLVMType, Name, Initializer) Type Name;
+#include "llvm/ProfileData/InstrProfData.inc"
+};
+
+/// PGO profiling data extracted from a GPU device
+struct GPUProfGlobals {
+  std::string names;
+  std::vector<std::vector<int64_t>> counts;
+  std::vector<__llvm_profile_data> data;
+  Triple targetTriple;
+
----------------
EthanLuisMcDonough wrote:

The basic idea is that the fields in this struct are going to be passed to compiler-rt to be made into a profraw file for this specific target.

I don't know if `llvm::StringRef` would work for the names field. The names data is constant on the GPU device, but dynamic data still has to be allocated on the host in order to read the GPU value. I think it makes the most sense to make the struct own the name data. 

Do you think I should change all the vectors to `SmallVector` or just the innermost `Counts` vector?

https://github.com/llvm/llvm-project/pull/76587


More information about the flang-commits mailing list