[Openmp-commits] [openmp] [OpenMP][AMDGPU] Adapt dynamic callstack sizes to HIP behavior (PR #74080)

Joseph Huber via Openmp-commits openmp-commits at lists.llvm.org
Fri Dec 1 07:06:15 PST 2023


================
@@ -1872,6 +1873,38 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy {
     else
       return Plugin::error("Unexpected AMDGPU wavefront %d", WavefrontSize);
 
+    // To determine the correct scratch memory size per thread, we need to check
+    // the device architecure generation. According to AOT_OFFLOADARCHS we may
+    // assume that AMDGPU offload archs are prefixed with "gfx" and suffixed
+    // with a two char arch specialization. In-between is the 1-2 char
+    // generation number we want to extract.
+    std::string CUKind{ComputeUnitKind};
----------------
jhuber6 wrote:

This code looks really complicated and should be using `StringRef`. Are we just trying to get the major version? That should be pretty trivial.
```c++
StringRef Arch(ComputeUnitKind)
unsigned Version = 0u;
if (llvm::to_integer(Arch.drop_front(sizeof("gfx") - 1), Version))
  return Plugin::error("Invalid GFX architecture string");
unsigned Major = Version / 100;
```

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


More information about the Openmp-commits mailing list