File: lower-gpu-launch-vulkan-launch.mlir

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,998,492 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (35 lines) | stat: -rw-r--r-- 1,666 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// RUN: mlir-opt %s -convert-gpu-launch-to-vulkan-launch | FileCheck %s

// CHECK: %[[resource:.*]] = memref.alloc() : memref<12xf32>
// CHECK: %[[index:.*]] = arith.constant 1 : index
// CHECK: call @vulkanLaunch(%[[index]], %[[index]], %[[index]], %[[resource]]) {spirv_blob = "{{.*}}", spirv_element_types = [f32], spirv_entry_point = "kernel"}

module attributes {gpu.container_module} {
  spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader], [SPV_KHR_storage_buffer_storage_class]> {
    spirv.GlobalVariable @kernel_arg_0 bind(0, 0) : !spirv.ptr<!spirv.struct<(!spirv.array<12 x f32, stride=4> [0])>, StorageBuffer>
    spirv.func @kernel() "None" attributes {workgroup_attributions = 0 : i64} {
      %0 = spirv.mlir.addressof @kernel_arg_0 : !spirv.ptr<!spirv.struct<(!spirv.array<12 x f32, stride=4> [0])>, StorageBuffer>
      %2 = spirv.Constant 0 : i32
      %3 = spirv.mlir.addressof @kernel_arg_0 : !spirv.ptr<!spirv.struct<(!spirv.array<12 x f32, stride=4> [0])>, StorageBuffer>
      %4 = spirv.AccessChain %0[%2, %2] : !spirv.ptr<!spirv.struct<(!spirv.array<12 x f32, stride=4> [0])>, StorageBuffer>, i32, i32
      %5 = spirv.Load "StorageBuffer" %4 : f32
      spirv.Return
    }
    spirv.EntryPoint "GLCompute" @kernel
    spirv.ExecutionMode @kernel "LocalSize", 1, 1, 1
  }
  gpu.module @kernels {
    gpu.func @kernel(%arg0: memref<12xf32>) kernel {
      gpu.return
    }
  }
  func.func @foo() {
    %0 = memref.alloc() : memref<12xf32>
    %c1 = arith.constant 1 : index
    gpu.launch_func @kernels::@kernel
        blocks in(%c1, %c1, %c1)
        threads in(%c1, %c1, %c1)
        args(%0 : memref<12xf32>)
    return
  }
}