1 // RUN: mlir-opt -allow-unregistered-dialect -split-input-file -convert-gpu-to-spirv -verify-diagnostics %s | FileCheck %s
5 spirv.target_env = #spirv.target_env<#spirv.vce<v1.0, [Addresses, Int8, Kernel], []>, #spirv.resource_limits<>>
8 %c1 = arith.constant 1 : index
10 gpu.launch_func @kernels::@printf
11 blocks in (%c1, %c1, %c1) threads in (%c1, %c1, %c1)
17 // CHECK: spirv.module @{{.*}} Physical32 OpenCL
18 // CHECK-DAG: spirv.SpecConstant [[SPECCST:@.*]] = {{.*}} : i8
19 // CHECK-DAG: spirv.SpecConstantComposite [[SPECCSTCOMPOSITE:@.*]] ([[SPECCST]], {{.*}}) : !spirv.array<[[ARRAYSIZE:.*]] x i8>
20 // CHECK-DAG: spirv.GlobalVariable [[PRINTMSG:@.*]] initializer([[SPECCSTCOMPOSITE]]) {Constant} : !spirv.ptr<!spirv.array<[[ARRAYSIZE]] x i8>, UniformConstant>
21 gpu.func @printf() kernel
23 {spirv.entry_point_abi = #spirv.entry_point_abi<>} {
24 // CHECK: [[FMTSTR_ADDR:%.*]] = spirv.mlir.addressof [[PRINTMSG]] : !spirv.ptr<!spirv.array<[[ARRAYSIZE]] x i8>, UniformConstant>
25 // CHECK-NEXT: [[FMTSTR_PTR:%.*]] = spirv.Bitcast [[FMTSTR_ADDR]] : !spirv.ptr<!spirv.array<[[ARRAYSIZE]] x i8>, UniformConstant> to !spirv.ptr<i8, UniformConstant>
26 // CHECK-NEXT {{%.*}} = spirv.CL.printf [[FMTSTR_PTR]] : !spirv.ptr<i8, UniformConstant> -> i32
27 gpu.printf "\nHello\n"
28 // CHECK: spirv.Return
38 spirv.target_env = #spirv.target_env<#spirv.vce<v1.0, [Addresses, Int8, Kernel], []>, #spirv.resource_limits<>>
41 %c1 = arith.constant 1 : index
42 %c100 = arith.constant 100: i32
43 %cst_f32 = arith.constant 314.4: f32
45 gpu.launch_func @kernels1::@printf_args
46 blocks in (%c1, %c1, %c1) threads in (%c1, %c1, %c1)
47 args(%c100: i32, %cst_f32: f32)
51 gpu.module @kernels1 {
52 // CHECK: spirv.module @{{.*}} Physical32 OpenCL {
53 // CHECK-DAG: spirv.SpecConstant [[SPECCST:@.*]] = {{.*}} : i8
54 // CHECK-DAG: spirv.SpecConstantComposite [[SPECCSTCOMPOSITE:@.*]] ([[SPECCST]], {{.*}}) : !spirv.array<[[ARRAYSIZE:.*]] x i8>
55 // CHECK-DAG: spirv.GlobalVariable [[PRINTMSG:@.*]] initializer([[SPECCSTCOMPOSITE]]) {Constant} : !spirv.ptr<!spirv.array<[[ARRAYSIZE]] x i8>, UniformConstant>
56 gpu.func @printf_args(%arg0: i32, %arg1: f32) kernel
57 attributes {spirv.entry_point_abi = #spirv.entry_point_abi<>} {
62 // CHECK: [[FMTSTR_ADDR:%.*]] = spirv.mlir.addressof [[PRINTMSG]] : !spirv.ptr<!spirv.array<[[ARRAYSIZE]] x i8>, UniformConstant>
63 // CHECK-NEXT: [[FMTSTR_PTR1:%.*]] = spirv.Bitcast [[FMTSTR_ADDR]] : !spirv.ptr<!spirv.array<[[ARRAYSIZE]] x i8>, UniformConstant> to !spirv.ptr<i8, UniformConstant>
64 // CHECK-NEXT: {{%.*}} = spirv.CL.printf [[FMTSTR_PTR1]] {{%.*}}, {{%.*}}, {{%.*}} : !spirv.ptr<i8, UniformConstant>, i32, f32, i32 -> i32
65 gpu.printf "\nHello, world : %d %f \n Thread id: %d\n" %arg0, %arg1, %2: i32, f32, index
67 // CHECK: spirv.Return