-
Notifications
You must be signed in to change notification settings - Fork 614
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[LLVMGPU][ROCm] Add validation on finalized llvm bitcode (#18552)
Check that there are no unresolved external functions that will otherwise compile fine but be rejected by the driver. The validation happens on the llvm bitcode after bitcode linking, when there is no chance for anything to resolve these external functions. This is to guard against future issues similar to #18534 that are close to undebuggable for end users.
- Loading branch information
Showing
3 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
compiler/plugins/target/ROCM/test/external_function_validation.mlir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// RUN: iree-opt --pass-pipeline='builtin.module(hal.executable(iree-hal-serialize-target-executables{target=rocm}))' \ | ||
// RUN: --verify-diagnostics %s -o - | ||
|
||
// The final bitcode validation should error out on any external functions that | ||
// remain in the final bitcode (post device bitcode linking). | ||
|
||
#executable_target_rocm_hsaco_fb = #hal.executable.target<"rocm", "rocm-hsaco-fb", | ||
{iree.gpu.target = #iree_gpu.target<arch = "gfx942", features = "", | ||
wgp = <compute = fp16, storage = b16, | ||
subgroup = none, dot = none, mma = [], | ||
subgroup_size_choices = [64], | ||
max_workgroup_sizes = [1024, 1024, 1024], | ||
max_thread_count_per_workgroup = 1024, | ||
max_workgroup_memory_bytes = 65536, | ||
max_workgroup_counts = [2147483647, 2147483647, 2147483647]>>, | ||
ukernels = "none"}> | ||
#pipeline_layout = #hal.pipeline.layout<bindings = [#hal.pipeline.binding<storage_buffer, Indirect>], | ||
flags = Indirect> | ||
builtin.module { | ||
hal.executable public @test { | ||
// expected-error @+2 {{found an unresolved external function 'external_func' in the final bitcode}} | ||
// expected-error @+1 {{failed to serialize executable for target backend rocm}} | ||
hal.executable.variant public @rocm_hsaco_fb target(#executable_target_rocm_hsaco_fb) { | ||
hal.executable.export public @test ordinal(0) layout(#pipeline_layout) | ||
attributes {subgroup_size = 64 : index, workgroup_size = [128 : index, 2 : index, 1 : index]} { | ||
^bb0(%arg0: !hal.device): | ||
%c128 = arith.constant 128 : index | ||
%c2 = arith.constant 2 : index | ||
%c1 = arith.constant 1 : index | ||
hal.return %c128, %c2, %c1 : index, index, index | ||
} | ||
builtin.module { | ||
llvm.func @external_func() attributes {sym_visibility = "private"} | ||
llvm.func @test() { | ||
llvm.call @external_func() : () -> () | ||
llvm.return | ||
} | ||
} | ||
} | ||
} | ||
} |