This is an archive of the discontinued LLVM Phabricator instance.

[libomptarget][amdgpu] Implement dlopen of libhsa
ClosedPublic

Authored by JonChesterfield on Jul 22 2021, 8:22 AM.

Details

Summary

AMDGPU plugin equivalent of D95155, build without HSA installed locally

Compiles a new file, plugins/amdgpu/dynamic_hsa/hsa.cpp, to an object file that
exposes the same symbols that the plugin presently uses from hsa. The object
file contains dlopen of hsa and cached dlsym calls. Also provides header files
corresponding to the subset that is used.

This is behind a feature flag, LIBOMPTARGET_FORCE_DLOPEN_LIBHSA, default off.
That allows developers to build against the dlopen/dlsym implementation, e.g.
while testing this mode.

Enabling by default will cause this plugin to build on a wider variety of
machines than it does at present so may break some CI builds. That risk can
be minimised by reviewing the header dependencies of the library and ensuring
it doesn't use any libraries that are not already used by libomptarget.

Separating the implementation from enabling by default in case the latter needs
to be rolled back after wider CI results.

Diff Detail

Event Timeline

JonChesterfield requested review of this revision.Jul 22 2021, 8:22 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 22 2021, 8:22 AM
openmp/libomptarget/plugins/amdgpu/CMakeLists.txt
91

drive by fix, this logic was inspired by the nvptx one, where CMAKE_DL_LIBS is used instead of dl

openmp/libomptarget/plugins/amdgpu/dynamic_hsa/hsa.h
2

This file was semi-automatically reduced from https://github.com/RadeonOpenCompute/ROCR-Runtime/tree/master/src/inc and preserves the header block as written there.

Dumped hsa symbols used by the amdgpu plugin then used grep to find them in the ROCR headers, manually cleaned up, then copied across the type definitions and enums that are currently in use.

The ROCR API is expected to be backwards compatible. Elided the comments on the basis that developers are better off reading the official header files.

jdoerfert accepted this revision.Jul 22 2021, 8:30 AM

LG, it's a plugin.

openmp/libomptarget/plugins/amdgpu/dynamic_hsa/hsa.h
42

Please use the LLVM licence header.

openmp/libomptarget/plugins/amdgpu/dynamic_hsa/hsa_ext_amd.h
42

LLVM licence.

This revision is now accepted and ready to land.Jul 22 2021, 8:30 AM
  • Change header to llvm as requested in review
This revision was landed with ongoing or failed builds.Jul 22 2021, 8:54 AM
This revision was automatically updated to reflect the committed changes.