This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP][libomptarget] Improve kernel initialization in plugins
ClosedPublic

Authored by kevinsala on Aug 2 2023, 10:18 AM.

Details

Summary

This patch modifies the plugins so that the initialization of <Dev>KernelTy objects
is done in the init method. Part of the initialization was done in the
constructKernelEntry method. Now this method is called constructKernel
and only allocates and constructs a <Dev>KernelTy object.

This patch prepares the kernel class for the new implementation of device
reductions.

Diff Detail

Event Timeline

kevinsala created this revision.Aug 2 2023, 10:18 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 2 2023, 10:18 AM
kevinsala requested review of this revision.Aug 2 2023, 10:18 AM
tianshilei1992 added inline comments.Aug 3 2023, 7:28 AM
openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp
1911–1912

Potentially this can fail right?

kevinsala added inline comments.Aug 3 2023, 7:57 AM
openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp
1911–1912

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);
kevinsala updated this revision to Diff 547126.Aug 4 2023, 12:50 AM

Fixing issues

kevinsala marked an inline comment as done.Aug 4 2023, 12:50 AM
tianshilei1992 accepted this revision.Aug 4 2023, 7:21 AM
This revision is now accepted and ready to land.Aug 4 2023, 7:21 AM