Skip to content
Open
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
24 changes: 14 additions & 10 deletions mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4707,16 +4707,20 @@ LogicalResult NVVMTargetAttr::verifyTarget(Operation *gpuModule) {
"Minimum NVVM target SM version is sm_20");
}

gpuModuleOp->walk([&](Operation *op) {
if (auto reqOp = llvm::dyn_cast<NVVM::RequiresSMInterface>(op)) {
const NVVMCheckSMVersion requirement = reqOp.getRequiredMinSMVersion();
if (!requirement.isCompatibleWith(targetSMVersion)) {
op->emitOpError() << "is not supported on " << getChip();
return WalkResult::interrupt();
}
}
return WalkResult::advance();
});
if (gpuModuleOp
->walk([&](Operation *op) {
if (auto reqOp = llvm::dyn_cast<NVVM::RequiresSMInterface>(op)) {
const NVVMCheckSMVersion requirement =
reqOp.getRequiredMinSMVersion();
if (!requirement.isCompatibleWith(targetSMVersion)) {
op->emitOpError() << "is not supported on " << getChip();
return WalkResult::interrupt();
}
}
return WalkResult::advance();
})
.wasInterrupted())
return failure();

return success();
}
Expand Down
11 changes: 11 additions & 0 deletions mlir/test/Dialect/LLVMIR/nvvm-target-invalid.mlir
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// RUN: not mlir-opt %s 2>&1 | FileCheck %s
// CHECK: 'nvvm.tcgen05.alloc' op is not supported on sm_90

module {
gpu.module @mod [#nvvm.target<chip = "sm_90">] {
func.func @tcgen05_alloc(%arg0: !llvm.ptr<7>, %arg1: i32) {
nvvm.tcgen05.alloc %arg0, %arg1 : !llvm.ptr<7>, i32
return
}
}
}