[Openmp-commits] [PATCH] D156917: [OpenMP][libomptarget] Improve kernel initialization in plugins

Kevin Sala via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Thu Aug 3 07:57:33 PDT 2023


kevinsala added inline comments.


================
Comment at: openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp:1906
+    // Allocate and construct the AMDGPU kernel.
     AMDGPUKernelTy *AMDKernel = Plugin::get().allocate<AMDGPUKernelTy>();
+    new (AMDKernel) AMDGPUKernelTy(KernelEntry.name, ExecMode);
----------------
tianshilei1992 wrote:
> Potentially this can fail right?
Right, this can potentially fail. However, our allocate function directly calls the `BumpPtrAllocator::Allocate()`, which doesn't seem to control errors (e.g., when no more memory is available) other than asserts.

But anyway, I'm OK adding the following check for safety:

```
if (!AMDKernel)
  return Plugin::error("Failed to allocate memory for kernel %s", KernelEntry.name);
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156917/new/

https://reviews.llvm.org/D156917



More information about the Openmp-commits mailing list