This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP][WIP] Refactor global handling in plugins
AbandonedPublic

Authored by jdoerfert on Nov 13 2021, 12:40 PM.

Details

Summary

Global symbol handling is one of the common things the plugins do and we
should be uniform wrt. functionality, messaging, etc. The new
GlobalHandler will do most of the heavy lifting and the plugins simply
need to provide some information to it. Error checking and such is done
the same way for all plugins and more refactoring opportunities arise.

This removes two "functions" of the AMDGPU plugins for now:

  1. Write the device environment into the image. This is something we should investigate for CUDA and add to the GlobalHandler. For now, it is a single HtoD transfer we pay extra.
  2. If the device environment could not be transferred we used to check the architecture. The code needs to be ported to the llvm ELF handling and then we can do this again.

Diff Detail

Event Timeline

jdoerfert created this revision.Nov 13 2021, 12:40 PM
jdoerfert requested review of this revision.Nov 13 2021, 12:40 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 13 2021, 12:40 PM
Herald added a subscriber: sstefan1. · View Herald Transcript

Discussed a bit offline. I'd like to keep the capability to read/write to symbols in the device images, without first having to load the image onto the device and then call into cuda/hsa/etc to access the values that were originally in host memory. readGlobalFromImage exists in this patch, writeGlobalToImage would be very similar in implementation.

openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
1231

The memory optimisation that allocated omptarget_nvptx_device_State one per process instead of once per device image is obsolete with the new runtime

openmp/libomptarget/plugins/common/GlobalHandler/GlobalHandler.h
91

Confusing naming here - coping globals / copying from global symbols?

Discussed a bit offline. I'd like to keep the capability to read/write to symbols in the device images, without first having to load the image onto the device and then call into cuda/hsa/etc to access the values that were originally in host memory. readGlobalFromImage exists in this patch, writeGlobalToImage would be very similar in implementation.

We kept the capability to read symbols from device images with this patch. writeGlobalToImage is something that wasn't easily changeable to a generic scheme so I added a TODO and left it. Overall extra cost: 1x H2D.

openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
1231

I know. Once we don't need to keep the old for AMD we delete this :)

openmp/libomptarget/plugins/common/GlobalHandler/GlobalHandler.h
91

Not sure what you mean. Suggestions for rewording welcome.

jdoerfert abandoned this revision.Dec 2 2021, 2:49 AM