xref: /llvm-project/mlir/test/Integration/GPU/CUDA/printf.mlir (revision eb206e9ea84eff0a0596fed2de8316d924f946d1)
1// RUN: mlir-opt %s \
2// RUN: | mlir-opt -gpu-lower-to-nvvm-pipeline="cubin-format=%gpu_compilation_format" \
3// RUN: | mlir-runner \
4// RUN:   --shared-libs=%mlir_cuda_runtime \
5// RUN:   --shared-libs=%mlir_runner_utils \
6// RUN:   --entry-point-result=void \
7// RUN: | FileCheck %s
8
9// CHECK: Hello from 0, 2, 3.000000
10// CHECK: Hello from 1, 2, 3.000000
11module attributes {gpu.container_module} {
12    gpu.module @kernels {
13        gpu.func @hello() kernel {
14            %0 = gpu.thread_id x
15            %csti8 = arith.constant 2 : i8
16            %cstf32 = arith.constant 3.0 : f32
17            gpu.printf "Hello from %lld, %d, %f\n", %0, %csti8, %cstf32  : index, i8, f32
18            gpu.return
19        }
20    }
21
22    func.func @main() {
23        %c2 = arith.constant 2 : index
24        %c1 = arith.constant 1 : index
25        gpu.launch_func @kernels::@hello
26            blocks in (%c1, %c1, %c1)
27            threads in (%c2, %c1, %c1)
28        return
29    }
30}
31