brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.2 KiB · 7fe9752 Raw
72 lines · plain
1// RUN: mlir-opt -allow-unregistered-dialect -split-input-file  -convert-gpu-to-spirv -verify-diagnostics %s | FileCheck %s2 3module attributes {4  gpu.container_module,5  spirv.target_env = #spirv.target_env<#spirv.vce<v1.0, [Addresses, Int8, Kernel], []>, #spirv.resource_limits<>>6} {7  func.func @main() {8    %c1 = arith.constant 1 : index9 10    gpu.launch_func @kernels::@printf11        blocks in (%c1, %c1, %c1) threads in (%c1, %c1, %c1)12        args()13    return14  }15  16  gpu.module @kernels {17    // CHECK: spirv.module @{{.*}} Physical32 OpenCL18    // CHECK-DAG: spirv.SpecConstant [[SPECCST:@.*]] = {{.*}} : i819    // 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() kernel22      attributes 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> -> i3227          gpu.printf "\nHello\n"28          // CHECK: spirv.Return29          gpu.return30    }31  }32}33 34// -----35 36module attributes {37  gpu.container_module,38  spirv.target_env = #spirv.target_env<#spirv.vce<v1.0, [Addresses, Int8, Kernel], []>, #spirv.resource_limits<>>39} {40  func.func @main() {41    %c1   = arith.constant 1 : index42    %c100 = arith.constant 100: i3243    %cst_f32 = arith.constant 314.4: f3244 45    gpu.launch_func @kernels1::@printf_args46        blocks in (%c1, %c1, %c1) threads in (%c1, %c1, %c1)47        args(%c100: i32, %cst_f32: f32)48    return49  }50 51   gpu.module @kernels1 {52    // CHECK: spirv.module @{{.*}} Physical32 OpenCL {53    // CHECK-DAG: spirv.SpecConstant [[SPECCST:@.*]] = {{.*}} : i854    // 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) kernel57      attributes {spirv.entry_point_abi = #spirv.entry_point_abi<>} {58        %0 = gpu.block_id x59        %1 = gpu.block_id y60        %2 = gpu.thread_id x61 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 -> i3265        gpu.printf "\nHello, world : %d %f \n Thread id: %d\n", %arg0, %arg1, %2: i32, f32, index66 67        // CHECK: spirv.Return68        gpu.return69    }70  }71}72