[clang] [compiler-rt] [llvm] [PGO][HIP] Fix HIP device profile collection and sections emission (PR #202095)
Larry Meadows via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 11 06:02:58 PDT 2026
================
@@ -845,10 +1128,41 @@ extern "C" int __llvm_profile_hip_collect_device_data(void) {
return Ret;
}
-/* Interceptors for hipModuleLoad* / hipModuleUnload. Linux only. */
+/* Linux HIP interceptors. */
#if defined(__linux__) && !defined(_WIN32)
+typedef struct {
+ unsigned int x;
+ unsigned int y;
+ unsigned int z;
+} HipDim3;
+
+typedef void *HipFunction;
+typedef void *HipStream;
+
+static int recordHipLaunchResult(int Rc) {
+ if (Rc == 0)
+ markCurrentDeviceUsed();
+ return Rc;
+}
+
----------------
lfmeadow wrote:
There are several additional untracked launch APis: hipExtLaunchKernel, hipLaunchCooperativeKernel, hipExtModuleLaunchKernel, HIP graph launches (hipGraphLaunch).
If only those APIs are used, there will be a crash: AnyDeviceUsed == 0 -> falls back to collect-all
If, say, device 0 uses a tracked APi and device 1 uses an untracked API, then any data from device 1 will be lost.
The tracked APIs should be listed as a limitation, and probably should track the other APIs also.
https://github.com/llvm/llvm-project/pull/202095
More information about the cfe-commits
mailing list