[llvm] [AMDGPU][Offload] Enable memory manager use for up to ~3GB allocation size in omp_target_alloc (PR #151882)

Shilei Tian via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 4 07:25:50 PDT 2025


================
@@ -2944,6 +2944,41 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy {
     return Plugin::success();
   }
 
+  bool checkIfCoarseGrainMemoryNearOrAbove64GB() {
+    for (AMDGPUMemoryPoolTy *Pool : AllMemoryPools) {
+      if (Pool->isGlobal() && Pool->isCoarseGrained()) {
+        uint64_t Value;
+        hsa_status_t Status =
+            Pool->getAttrRaw(HSA_AMD_MEMORY_POOL_INFO_SIZE, Value);
+        if (Status != HSA_STATUS_SUCCESS)
+          continue;
+        constexpr uint64_t Almost64Gig = 0xFF0000000;
+        if (Value >= Almost64Gig)
+          return true;
+      }
+    }
+    return false; // CoarseGrain pool w/ 64GB or more capacity not found
+  }
+
+  size_t getMemoryManagerSizeThreshold() override {
+    // Targeting high memory capacity GPUs such as
+    // MI210 or later data center GPUs.
----------------
shiltian wrote:

Don't use product name in the code. Use code name instead please.

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


More information about the llvm-commits mailing list