
This (mostly) removes one of the largest remaining limitations of `hipstdpar` based algorithm acceleration, by adding support for global variable usage in offloaded algorithms. It is mean to compose with a run time component that will live in the support library, and fires iff a special variable is provided by the latter. In short, things work as follows: - We replace uses some global `G` with an indirect access via an implicitly created anonymous global `F`, which is of pointer type and is expected to hold the program-wide address of `G`; - We append 'F', alongside 'G''s name, to an table structure; - At run-time, the support library uses the table to look-up the program-wide address of a contained symbol based on its name, and then stores the address via the paired pointer. This doesn't handle internal linkage symbols (`static foo` or `namespace { foo }`) if they are not unique i.e. if there's a name clash that is solved by the linker, as the resolution would not be visible. Also, initially we will only support "true" globals in RDC mode. Things would be much simpler if we had direct access to the accelerator loader, but since the expectation is to compose at the HIP RT level we have to jump through additional hoops.
16 lines
702 B
LLVM
16 lines
702 B
LLVM
; REQUIRES: amdgpu-registered-target
|
|
; RUN: not opt -S -mtriple=amdgcn-amd-amdhsa -passes=hipstdpar-select-accelerator-code \
|
|
; RUN: %s 2>&1 | FileCheck %s
|
|
|
|
; CHECK: error: The second element in the Indirection Table must be a pointer; %struct.anon.1 = type { ptr, ptr } is incorrect.
|
|
%struct.anon.1 = type { ptr, ptr }
|
|
%class.anon = type { i64, %struct.anon.1, %struct.anon.1 }
|
|
@a = external hidden local_unnamed_addr addrspace(1) global ptr, align 8
|
|
@__hipstdpar_symbol_indirection_table = weak_odr protected addrspace(4) externally_initialized constant %class.anon zeroinitializer, align 8
|
|
|
|
define amdgpu_kernel void @store(ptr %p) {
|
|
entry:
|
|
store ptr %p, ptr addrspace(1) @a, align 8
|
|
ret void
|
|
}
|