Files
clang-p2996/mlir/test/Integration/GPU/CUDA/two-modules.mlir
Fabian Mora 119c489cc1 Reland [mlir][test][gpu] Migrate CUDA tests to the TargetAttr compilation workflow (llvm#65768)
The revert happened due to a build bot failure that threw 'CUDA_ERROR_UNSUPPORTED_PTX_VERSION'.
The failure's root cause was a pass using "+ptx76" for compilation and an old CUDA driver
on the bot. This commit relands the patch with "+ptx60".

Original Gh PR: #65768
Original commit message:
    Migrate tests referencing `gpu-to-cubin` to the new compilation workflow
    using `TargetAttrs`. The `test-lower-to-nvvm` pass pipeline was modified
    to use the new compilation workflow to simplify the introduction of
    future tests.

    The `createLowerGpuOpsToNVVMOpsPass` function was removed, as it didn't
    allow for passing all options available in the `ConvertGpuOpsToNVVMOp`
    pass.
2023-09-09 12:45:21 +00:00

35 lines
1.3 KiB
MLIR

// RUN: mlir-opt %s \
// RUN: | mlir-opt -test-lower-to-nvvm \
// RUN: | mlir-cpu-runner \
// RUN: --shared-libs=%mlir_cuda_runtime \
// RUN: --shared-libs=%mlir_runner_utils \
// RUN: --entry-point-result=void \
// RUN: | FileCheck %s
// CHECK: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
func.func @main() {
%arg = memref.alloc() : memref<13xi32>
%dst = memref.cast %arg : memref<13xi32> to memref<?xi32>
%one = arith.constant 1 : index
%c0 = arith.constant 0 : index
%sx = memref.dim %dst, %c0 : memref<?xi32>
%cast_dst = memref.cast %dst : memref<?xi32> to memref<*xi32>
gpu.host_register %cast_dst : memref<*xi32>
gpu.launch blocks(%bx, %by, %bz) in (%grid_x = %one, %grid_y = %one, %grid_z = %one)
threads(%tx, %ty, %tz) in (%block_x = %sx, %block_y = %one, %block_z = %one) {
%t0 = arith.index_cast %tx : index to i32
memref.store %t0, %dst[%tx] : memref<?xi32>
gpu.terminator
}
gpu.launch blocks(%bx, %by, %bz) in (%grid_x = %one, %grid_y = %one, %grid_z = %one)
threads(%tx, %ty, %tz) in (%block_x = %sx, %block_y = %one, %block_z = %one) {
%t0 = arith.index_cast %tx : index to i32
memref.store %t0, %dst[%tx] : memref<?xi32>
gpu.terminator
}
call @printMemrefI32(%cast_dst) : (memref<*xi32>) -> ()
return
}
func.func private @printMemrefI32(%memref : memref<*xi32>)