Files
TheRock/compiler/amd-llvm/mlir/test/Conversion/XeGPUToXeVM/materializecast.mlir
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

93 lines
4.0 KiB
MLIR

// RUN: mlir-opt -convert-xegpu-to-xevm --split-input-file %s | FileCheck %s
// This file contains tests for materalization patterns added to handle custom type conversions
// added on top of LLVM type converter.
gpu.module @materializecast {
// CHECK-LABEL: gpu.func @materialize_memref
// CHECK-SAME: %[[ARG0:.*]]: memref<128xf32>
gpu.func @materialize_memref(%src: memref<128xf32>) kernel {
// CHECK: %[[INTPTR:.*]] = memref.extract_aligned_pointer_as_index %[[ARG0]] : memref<128xf32> -> index
// CHECK: %[[CASTED:.*]] = arith.index_castui %[[INTPTR]] : index to i64
%offset = arith.constant 0 : index
%mask = arith.constant 1 : i1
%val = xegpu.load %src[%offset], %mask : memref<128xf32>, index, i1 -> f32
gpu.return
}
}
// -----
gpu.module @materializecast {
// CHECK-LABEL: gpu.func @materialize_ui64
// CHECK-SAME: %[[ARG0:.*]]: ui64
gpu.func @materialize_ui64(%src: ui64) kernel {
// CHECK: %[[VAR0:.*]] = index.castu %[[ARG0]] : ui64 to index
// CHECK: %[[VAR1:.*]] = arith.index_castui %[[VAR0]] : index to i64
%offset = arith.constant 0 : index
%mask = arith.constant 1 : i1
%val = xegpu.load %src[%offset], %mask : ui64, index, i1 -> vector<1xf32>
gpu.return
}
}
// -----
gpu.module @materializecast {
// CHECK-LABEL: gpu.func @materialize_ui32
// CHECK-SAME: %[[ARG0:.*]]: ui32
gpu.func @materialize_ui32(%src: ui32) kernel {
// CHECK: %[[VAR0:.*]] = index.castu %[[ARG0]] : ui32 to index
// CHECK: %[[VAR1:.*]] = arith.index_castui %[[VAR0]] : index to i32
%offset = arith.constant 0 : index
%mask = arith.constant 1 : i1
%val = xegpu.load %src[%offset], %mask : ui32, index, i1 -> vector<1xf32>
gpu.return
}
}
// -----
gpu.module @materializecast {
// CHECK-LABEL: gpu.func @materialize_single_index_vector
// CHECK-SAME: %[[ARG0:.*]]: memref<128xf32>
gpu.func @materialize_single_index_vector(%src: memref<128xf32>) kernel {
// CHECK: %[[CST:.*]] = arith.constant dense<0> : vector<1xindex>
// CHECK: %[[VAR1:.*]] = vector.extract %[[CST]][0] : index from vector<1xindex>
// CHECK: %[[VAR2:.*]] = arith.index_castui %[[VAR1]] : index to i64
// CHECK: %[[CST1:.*]] = arith.constant dense<true> : vector<1xi1>
// CHECK: %[[VAR3:.*]] = vector.extract %[[CST1]][0] : i1 from vector<1xi1>
%offset = arith.constant dense<0> : vector<1xindex>
%mask = arith.constant dense<1> : vector<1xi1>
%val = xegpu.load %src[%offset], %mask : memref<128xf32>, vector<1xindex>, vector<1xi1> -> vector<1xf32>
gpu.return
}
}
// -----
gpu.module @materializecast [#xevm.target<chip = "pvc">]{
// CHECK-LABEL: gpu.func @materialize_element_to_2D_single_element_vector
gpu.func @materialize_element_to_2D_single_element_vector(%dst: memref<128xf32>) kernel {
%c0 = arith.constant 0 : index
%alloca_11 = memref.alloca() : memref<512xi8, 3>
%49 = xegpu.create_mem_desc %alloca_11 : memref<512xi8, 3> -> !xegpu.mem_desc<8x16xf32>
// CHECK: %[[LOAD:.*]] = llvm.load %{{.+}} : !llvm.ptr<3> -> f32
// CHECK: %[[BCST:.*]] = vector.broadcast %[[LOAD]] : f32 to vector<1x1xf32>
%50 = xegpu.load_matrix %49[%c0, %c0] : !xegpu.mem_desc<8x16xf32>, index, index -> vector<1x1xf32>
%51 = vector.shape_cast %50 : vector<1x1xf32> to vector<1xf32>
vector.store %51, %dst[%c0] : memref<128xf32>, vector<1xf32>
gpu.return
}
}
// -----
gpu.module @materializecast [#xevm.target<chip = "pvc">]{
// CHECK-LABEL: gpu.func @materialize_2D_single_element_vector_to_element
gpu.func @materialize_2D_single_element_vector_to_element(%dst: memref<512xi8, 3>) kernel {
%c0 = arith.constant 0 : index
%c0_f32 = arith.constant dense<0.0> : vector<1x1xf32>
%49 = xegpu.create_mem_desc %dst : memref<512xi8, 3> -> !xegpu.mem_desc<8x16xf32>
// CHECK: %[[EXTR:.*]] = vector.extract %{{.+}}[0, 0] : f32 from vector<1x1xf32>
// CHECK: llvm.store %[[EXTR]], %{{.+}} : f32, !llvm.ptr<3>
xegpu.store_matrix %c0_f32, %49[%c0, %c0] : vector<1x1xf32>, !xegpu.mem_desc<8x16xf32>, index, index
gpu.return
}
}