58 lines · plain
1// RUN: mlir-opt %s -pass-pipeline='builtin.module(spirv-attach-target{ver=v1.0 caps=Addresses,Int64,Kernel},convert-gpu-to-spirv{use-64bit-index=true},gpu.module(spirv.module(spirv-lower-abi-attrs,spirv-update-vce)),func.func(llvm-request-c-wrappers),convert-scf-to-cf,convert-to-llvm,gpu-to-llvm{use-bare-pointers-for-kernels=true},gpu-module-to-binary,expand-strided-metadata,lower-affine,reconcile-unrealized-casts)' \2// RUN: | mlir-runner \3// RUN: --shared-libs=%mlir_levelzero_runtime \4// RUN: --shared-libs=%mlir_runner_utils \5// RUN: --entry-point-result=void \6// RUN: | FileCheck %s7 8module @add attributes {gpu.container_module} {9 memref.global "private" constant @__constant_3x3xi64_0 : memref<3x3xi64> = dense<[[1, 4098, 3], [16777220, 5, 4294967302], [7, 1099511627784, 9]]>10 memref.global "private" constant @__constant_3x3xi64 : memref<3x3xi64> = dense<[[1, 2, 3], [4, 5, 4102], [16777223, 4294967304, 1099511627785]]>11 func.func @main() {12 %0 = memref.get_global @__constant_3x3xi64 : memref<3x3xi64>13 %1 = memref.get_global @__constant_3x3xi64_0 : memref<3x3xi64>14 %2 = call @test(%0, %1) : (memref<3x3xi64>, memref<3x3xi64>) -> memref<3x3xi64>15 %cast = memref.cast %2 : memref<3x3xi64> to memref<*xi64>16 call @printMemrefI64(%cast) : (memref<*xi64>) -> ()17 return18 }19 func.func private @printMemrefI64(memref<*xi64>)20 func.func @test(%arg0: memref<3x3xi64>, %arg1: memref<3x3xi64>) -> memref<3x3xi64> {21 %c3 = arith.constant 3 : index22 %c1 = arith.constant 1 : index23 %mem = gpu.alloc host_shared () : memref<3x3xi64>24 memref.copy %arg1, %mem : memref<3x3xi64> to memref<3x3xi64>25 %memref_0 = gpu.alloc host_shared () : memref<3x3xi64>26 memref.copy %arg0, %memref_0 : memref<3x3xi64> to memref<3x3xi64>27 %memref_2 = gpu.alloc host_shared () : memref<3x3xi64>28 %2 = gpu.wait async29 %3 = gpu.launch_func async [%2] @test_kernel::@test_kernel blocks in (%c3, %c3, %c1) threads in (%c1, %c1, %c1)30 args(%memref_0 : memref<3x3xi64>, %mem : memref<3x3xi64>, %memref_2 : memref<3x3xi64>)31 gpu.wait [%3]32 %alloc = memref.alloc() : memref<3x3xi64>33 memref.copy %memref_2, %alloc : memref<3x3xi64> to memref<3x3xi64>34 %4 = gpu.wait async35 %5 = gpu.dealloc async [%4] %memref_2 : memref<3x3xi64>36 %6 = gpu.dealloc async [%5] %memref_0 : memref<3x3xi64>37 %7 = gpu.dealloc async [%6] %mem : memref<3x3xi64>38 gpu.wait [%7]39 return %alloc : memref<3x3xi64>40 }41 gpu.module @test_kernel42 attributes {spirv.target_env = #spirv.target_env<#spirv.vce<v1.0, [Addresses, Int64, Kernel], []>, api=OpenCL, #spirv.resource_limits<>>} {43 gpu.func @test_kernel(%arg0: memref<3x3xi64>, %arg1: memref<3x3xi64>, %arg2: memref<3x3xi64>) kernel44 attributes {gpu.known_block_size = array<i32: 1, 1, 1>, gpu.known_grid_size = array<i32: 3, 3, 1>, spirv.entry_point_abi = #spirv.entry_point_abi<>} {45 %0 = gpu.block_id x46 %1 = gpu.block_id y47 %2 = memref.load %arg0[%0, %1] : memref<3x3xi64>48 %3 = memref.load %arg1[%0, %1] : memref<3x3xi64>49 %4 = arith.addi %2, %3 : i6450 memref.store %4, %arg2[%0, %1] : memref<3x3xi64>51 gpu.return52 }53 }54 // CHECK: [2, 4100, 6],55 // CHECK: [16777224, 10, 4294971404],56 // CHECK: [16777230, 1103806595088, 1099511627794]57}58