brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.8 KiB · 8101dbe Raw
71 lines · plain
1// RUN: mlir-opt %s -test-spirv-cpu-runner-pipeline \2// RUN: | mlir-runner - -e main --entry-point-result=void --shared-libs=%mlir_runner_utils,%mlir_spirv_cpu_runtime --link-nested-modules \3// RUN: | FileCheck %s4 5// CHECK: [8,  8,  8,  8,  8,  8]6module attributes {7  gpu.container_module,8  spirv.target_env = #spirv.target_env<9    #spirv.vce<v1.0, [Shader], [SPV_KHR_variable_pointers]>,10    #spirv.resource_limits<11     max_compute_workgroup_invocations = 128,12     max_compute_workgroup_size = [128, 128, 64]>>13} {14  gpu.module @kernels {15    gpu.func @double(%arg0 : memref<6xi32>, %arg1 : memref<6xi32>)16      kernel attributes { spirv.entry_point_abi = #spirv.entry_point_abi<workgroup_size = [1, 1, 1]>} {17      %factor = arith.constant 2 : i3218 19      %i0 = arith.constant 0 : index20      %i1 = arith.constant 1 : index21      %i2 = arith.constant 2 : index22      %i3 = arith.constant 3 : index23      %i4 = arith.constant 4 : index24      %i5 = arith.constant 5 : index25 26      %x0 = memref.load %arg0[%i0] : memref<6xi32>27      %x1 = memref.load %arg0[%i1] : memref<6xi32>28      %x2 = memref.load %arg0[%i2] : memref<6xi32>29      %x3 = memref.load %arg0[%i3] : memref<6xi32>30      %x4 = memref.load %arg0[%i4] : memref<6xi32>31      %x5 = memref.load %arg0[%i5] : memref<6xi32>32 33      %y0 = arith.muli %x0, %factor : i3234      %y1 = arith.muli %x1, %factor : i3235      %y2 = arith.muli %x2, %factor : i3236      %y3 = arith.muli %x3, %factor : i3237      %y4 = arith.muli %x4, %factor : i3238      %y5 = arith.muli %x5, %factor : i3239 40      memref.store %y0, %arg1[%i0] : memref<6xi32>41      memref.store %y1, %arg1[%i1] : memref<6xi32>42      memref.store %y2, %arg1[%i2] : memref<6xi32>43      memref.store %y3, %arg1[%i3] : memref<6xi32>44      memref.store %y4, %arg1[%i4] : memref<6xi32>45      memref.store %y5, %arg1[%i5] : memref<6xi32>46      gpu.return47    }48  }49  func.func @main() {50    %input = memref.alloc() : memref<6xi32>51    %output = memref.alloc() : memref<6xi32>52    %four = arith.constant 4 : i3253    %zero = arith.constant 0 : i3254    %input_casted = memref.cast %input : memref<6xi32> to memref<?xi32>55    %output_casted = memref.cast %output : memref<6xi32> to memref<?xi32>56    call @fillI32Buffer(%input_casted, %four) : (memref<?xi32>, i32) -> ()57    call @fillI32Buffer(%output_casted, %zero) : (memref<?xi32>, i32) -> ()58 59    %one = arith.constant 1 : index60    gpu.launch_func @kernels::@double61        blocks in (%one, %one, %one) threads in (%one, %one, %one)62        args(%input : memref<6xi32>, %output : memref<6xi32>)63    %result = memref.cast %output : memref<6xi32> to memref<*xi32>64    call @printMemrefI32(%result) : (memref<*xi32>) -> ()65    return66  }67 68  func.func private @fillI32Buffer(%arg0 : memref<?xi32>, %arg1 : i32)69  func.func private @printMemrefI32(%ptr : memref<*xi32>)70}71