[Offload] Taskgraph representation and transmission protocol in libomptarget
When a taskgraph record contains target regions, we want to be able to
schedule those efficiently to run on offload hardware. At the moment
we have a processed taskgraph representation in libomp, but we need a
way to get that into libomptarget instead, since that is the part of
the runtime which currently handles target offload.
The representation here is somewhat decoupled from the one used within
libomp, partly because of the different coding style adopted by each
library, and partly because different aspects of the representation are
important when recording/host-replaying the graph vs. executing it on an
offload device. Particular care has been taken over avoiding the need
for strict binary compatibility (e.g. structure layout) between libomp
and libomptarget -- the interface between the two is via function calls
with POD argument types.
Some data is shallow copied/cross-linked to the recorded taskgraph data
in libomp: the mutex bits for surviving 'mutexinoutset' deps that aren't
representable by irreducible regions, and the deep-copied kernel args
and mapping arrays. As such, the libomp-side data must outlive the
libomptarget-side data.
We use a two-pass strategy to transmit the graph-shaped data so that we
can use a single allocation block on the libomptarget side.
Assisted-By: Claude Opus 5
Pull Request: https://github.com/llvm/llvm-project/pull/225708