]> granicus.if.org Git - llvm/commit
[AMDGPU] Lower enqueued blocks and generate runtime metadata
authorYaxun Liu <Yaxun.Liu@amd.com>
Tue, 10 Oct 2017 19:39:48 +0000 (19:39 +0000)
committerYaxun Liu <Yaxun.Liu@amd.com>
Tue, 10 Oct 2017 19:39:48 +0000 (19:39 +0000)
commit091c043b907bfb1a8756210f99b96d6fba7403fc
tree406208f6da3ae91f88532f3e9951468308942ea8
parentd015c78f400ba87409f4abbb21bd3cefb06d60ce
[AMDGPU] Lower enqueued blocks and generate runtime metadata

This patch adds a post-linking pass which replaces the function pointer of enqueued
block kernel with a global variable (runtime handle) and adds
runtime-handle attribute to the enqueued block kernel.

In LLVM CodeGen the runtime-handle metadata will be translated to
RuntimeHandle metadata in code object. Runtime allocates a global buffer
for each kernel with RuntimeHandel metadata and saves the kernel address
required for the AQL packet into the buffer. __enqueue_kernel function
in device library knows that the invoke function pointer in the block
literal is actually runtime handle and loads the kernel address from it
and puts it into AQL packet for dispatching.

This cannot be done in FE since FE cannot create a unique global variable
with external linkage across LLVM modules. The global variable with internal
linkage does not work since optimization passes will try to replace loads
of the global variable with its initialization value.

Differential Revision: https://reviews.llvm.org/D38610

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315352 91177308-0d34-0410-b5e6-96231b3b80d8
docs/AMDGPUUsage.rst
include/llvm/Support/AMDGPUCodeObjectMetadata.h
lib/Support/AMDGPUCodeObjectMetadata.cpp
lib/Target/AMDGPU/AMDGPU.h
lib/Target/AMDGPU/AMDGPUOpenCLEnqueuedBlockLowering.cpp [new file with mode: 0644]
lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
lib/Target/AMDGPU/CMakeLists.txt
lib/Target/AMDGPU/MCTargetDesc/AMDGPUCodeObjectMetadataStreamer.cpp
test/CodeGen/AMDGPU/code-object-metadata-from-llvm-ir-full.ll
test/CodeGen/AMDGPU/enqueue-kernel.ll [new file with mode: 0644]