brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.9 KiB · 8bcbdad Raw
80 lines · plain
1// RUN: mlir-opt %s -convert-gpu-to-nvvm='index-bitwidth=32' -split-input-file | FileCheck %s2 3// RUN: mlir-opt %s -transform-interpreter | FileCheck %s4 5gpu.module @test_module_0 {6  // CHECK-LABEL: func @gpu_index_ops()7  func.func @gpu_index_ops()8      -> (index, index, index, index, index, index,9          index, index, index, index, index, index,10          index) {11    %tIdX = gpu.thread_id x12    %tIdY = gpu.thread_id y13    %tIdZ = gpu.thread_id z14 15    %bDimX = gpu.block_dim x16    %bDimY = gpu.block_dim y17    %bDimZ = gpu.block_dim z18 19    %bIdX = gpu.block_id x20    %bIdY = gpu.block_id y21    %bIdZ = gpu.block_id z22 23    %gDimX = gpu.grid_dim x24    %gDimY = gpu.grid_dim y25    %gDimZ = gpu.grid_dim z26 27    // CHECK-NOT: = llvm.sext %{{.*}} : i32 to i6428    %laneId = gpu.lane_id29 30    func.return %tIdX, %tIdY, %tIdZ, %bDimX, %bDimY, %bDimZ,31               %bIdX, %bIdY, %bIdZ, %gDimX, %gDimY, %gDimZ,32               %laneId33        : index, index, index, index, index, index,34          index, index, index, index, index, index,35          index36  }37}38 39 40 41gpu.module @test_module_1 {42  // CHECK-LABEL: func @gpu_index_comp43  func.func @gpu_index_comp(%idx : index) -> index {44    // CHECK: = llvm.add %{{.*}}, %{{.*}} : i3245    %0 = arith.addi %idx, %idx : index46    // CHECK: llvm.return %{{.*}} : i3247    func.return %0 : index48  }49}50 51module attributes {transform.with_named_sequence} {52  transform.named_sequence @__transform_main(%toplevel_module: !transform.any_op {transform.readonly}) {53    %gpu_module = transform.structured.match ops{["gpu.module"]} in %toplevel_module54      : (!transform.any_op) -> !transform.any_op55    transform.apply_conversion_patterns to %gpu_module {56      transform.apply_conversion_patterns.dialect_to_llvm "arith"57      transform.apply_conversion_patterns.dialect_to_llvm "cf"58      transform.apply_conversion_patterns.vector.vector_to_llvm59      transform.apply_conversion_patterns.func.func_to_llvm60      transform.apply_conversion_patterns.dialect_to_llvm "memref"61      transform.apply_conversion_patterns.gpu.gpu_to_nvvm {benefit = 10 : i16}62      transform.apply_conversion_patterns.gpu.gpu_wmma_to_nvvm63      transform.apply_conversion_patterns.gpu.gpu_subgroup_reduce_to_nvvm {has_redux = true}64      transform.apply_conversion_patterns.nvgpu.nvgpu_to_nvvm65    } with type_converter {66      transform.apply_conversion_patterns.memref.memref_to_llvm_type_converter67        {index_bitwidth = 32, use_opaque_pointers = true}68    } {69      legal_dialects = ["llvm", "memref", "nvvm"],70      legal_ops = ["func.func", "gpu.module", "gpu.yield"],71      illegal_dialects = ["gpu"],72      illegal_ops = ["llvm.cos", "llvm.exp", "llvm.exp2", "llvm.fabs", "llvm.fceil",73                    "llvm.ffloor", "llvm.log", "llvm.log10", "llvm.log2", "llvm.pow",74                    "llvm.sin", "llvm.sqrt"],75      partial_conversion76    } : !transform.any_op77    transform.yield78  }79}80