xref: /llvm-project/mlir/test/Integration/GPU/ROCM/printf.mlir (revision eb206e9ea84eff0a0596fed2de8316d924f946d1)
1// RUN: mlir-opt %s \
2// RUN: | mlir-opt -pass-pipeline='builtin.module(gpu.module(strip-debuginfo,convert-gpu-to-rocdl{index-bitwidth=32 runtime=HIP}),rocdl-attach-target{chip=%chip})' \
3// RUN: | mlir-opt -gpu-to-llvm -reconcile-unrealized-casts -gpu-module-to-binary \
4// RUN: | mlir-runner \
5// RUN:   --shared-libs=%mlir_rocm_runtime \
6// RUN:   --shared-libs=%mlir_runner_utils \
7// RUN:   --entry-point-result=void \
8// RUN: | FileCheck %s
9
10// CHECK: Hello from 0
11// CHECK: Hello from 1
12module attributes {gpu.container_module} {
13    gpu.module @kernels {
14        gpu.func @hello() kernel {
15            %0 = gpu.thread_id x
16            gpu.printf "Hello from %d\n", %0 : index
17            gpu.return
18        }
19    }
20
21    func.func @main() {
22        %c2 = arith.constant 2 : index
23        %c1 = arith.constant 1 : index
24        gpu.launch_func @kernels::@hello
25            blocks in (%c1, %c1, %c1)
26            threads in (%c2, %c1, %c1)
27        return
28    }
29}
30