Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Conversion] lowering XeGPU.ops to VC-Intrinsics #669

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions include/imex/Conversion/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,10 @@ memref, arith and math.
}];
let constructor = "imex::createConvertGPUXToSPIRVPass()";
let dependentDialects = ["::mlir::spirv::SPIRVDialect"];
let options = [
Option<"enableSimtIntrinsic", "enable-simt-intrinsic","bool", "false",
"Enable XeGPU.simt Ops lowered to intel genISA simt Intrinsics">
];
}

//===----------------------------------------------------------------------===//
Expand Down
46 changes: 18 additions & 28 deletions include/imex/Dialect/XeGPU/IR/XeGPUOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -575,38 +575,28 @@ def XeGPU_InvokeSIMDOp : XeGPU_Op<"invoke_SIMD", []> {

}

def XeGPU_AtomicRMWOp
: XeGPU_Op<"atomic_rmw", []> {
let summary = "performa ready-modify-write operation that is free from data races.";

let arguments = (ins
XeGPU_AtomicRMWKindAttr:$kind,
XeGPU_Vector2DType:$value,
XeGPU_TensorDesc:$tensorDesc,
XeGPU_MaskType:$mask,
DefaultValuedAttr<XeGPU_ModeAttr, "imex::xegpu::Mode::SIMT">: $mode
);

let assemblyFormat = [{
$kind $value `,` $tensorDesc `,` $mask (`{` `mode` `=` $mode^ `}`)?
attr-dict
`:` `(` qualified(type($value)) `,` qualified(type($tensorDesc)) `,` qualified(type($mask)) `)`
}];
}
def XeGPU_AtomicRMWOp: XeGPU_Op<"atomic_rmw", []> {
let summary = "perform ready-modify-write operation that is free from data races.";
let arguments = (ins
XeGPU_AtomicRMWKindAttr:$kind,
XeGPU_TensorDesc:$tensorDesc,
XeGPU_MaskType:$mask,
Optional<XeGPU_ValueType>:$value,
DefaultValuedAttr<XeGPU_ModeAttr, "imex::xegpu::Mode::SIMT">: $mode
);
let results = (outs XeGPU_ValueType:$result);
let assemblyFormat = [{
$kind $tensorDesc `,` $mask (`,` $value^)? (`{` `mode` `=` $mode^ `}`)? attr-dict `:` qualified(type(operands)) `->` type($result)
}];
}


def XeGPU_AllocNbarrierOp
: XeGPU_Op<"alloc_nbarrier", []> {
def XeGPU_AllocNbarrierOp: XeGPU_Op<"alloc_nbarrier", []> {
let summary = "allocate a specific number of named barriers.";
let arguments = (ins I32Attr: $nbarrierCount);
let assemblyFormat = "$nbarrierCount attr-dict";
}

let arguments = (ins
I8: $nbarrier_count
);

let assemblyFormat = [{
$nbarrier_count attr-dict `:` qualified(type($nbarrier_count))
}];
}

def XeGPU_CreateNbarrierOp
: XeGPU_Op<"create_nbarrier", []> {
Expand Down
5 changes: 4 additions & 1 deletion lib/Conversion/GPUToSPIRV/GPUToSPIRVPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ void GPUXToSPIRVPass::runOnOperation() {
target->addIllegalDialect<imex::xegpu::XeGPUDialect>();
typeConverter.addConversion(
[&](xegpu::TensorDescType type) -> ::mlir::Type {
return ::mlir::IntegerType::get(context, 64);
auto i64Type = ::mlir::IntegerType::get(context, 64);
return ::mlir::VectorType::get(2, i64Type);
});
typeConverter.addConversion([&](::mlir::VectorType type) -> ::mlir::Type {
unsigned rank = type.getRank();
Expand All @@ -175,6 +176,8 @@ void GPUXToSPIRVPass::runOnOperation() {
for (unsigned i = 0; i < rank; i++) {
sum *= type.getShape()[i];
}
if (llvm::isa<mlir::IndexType>(elemType))
elemType = ::mlir::IntegerType::get(context, 64);
return ::mlir::VectorType::get(sum, elemType);
}
});
Expand Down
Loading
Loading