summaryrefslogtreecommitdiffstats
path: root/mlir/lib/Dialect
diff options
context:
space:
mode:
authorAlex Zinenko <zinenko@google.com>2019-12-18 03:38:18 -0800
committerA. Unique TensorFlower <gardener@tensorflow.org>2019-12-18 03:38:55 -0800
commit40ef46fba4a072065c04fa16ac9309b551fd7004 (patch)
tree414609c0a381ff6247b937435e0ca2ae95558d36 /mlir/lib/Dialect
parentc6c6a74d5557d1f373c3bb10fd8a383b0ae18182 (diff)
downloadbcm5719-llvm-40ef46fba4a072065c04fa16ac9309b551fd7004.tar.gz
bcm5719-llvm-40ef46fba4a072065c04fa16ac9309b551fd7004.zip
Harden the requirements to memory attribution types in gpu.func
When memory attributions are present in `gpu.func`, require that they are of memref type and live in memoryspaces 3 and 5 for workgroup and private memory attributions, respectively. Adapt the conversion from the GPU dialect to the NVVM dialect to drop the private memory space from attributions as NVVM is able to model them as local `llvm.alloca`s in the default memory space. PiperOrigin-RevId: 286161763
Diffstat (limited to 'mlir/lib/Dialect')
-rw-r--r--mlir/lib/Dialect/GPU/IR/GPUDialect.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
index 46a568caac5..1c20be6a453 100644
--- a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
+++ b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
@@ -739,6 +739,22 @@ LogicalResult GPUFuncOp::verifyType() {
return success();
}
+static LogicalResult verifyAttributions(Operation *op,
+ ArrayRef<BlockArgument *> attributions,
+ unsigned memorySpace) {
+ for (Value *v : attributions) {
+ auto type = v->getType().dyn_cast<MemRefType>();
+ if (!type)
+ return op->emitOpError() << "expected memref type in attribution";
+
+ if (type.getMemorySpace() != memorySpace) {
+ return op->emitOpError()
+ << "expected memory space " << memorySpace << " in attribution";
+ }
+ }
+ return success();
+}
+
/// Verifies the body of the function.
LogicalResult GPUFuncOp::verifyBody() {
unsigned numFuncArguments = getNumArguments();
@@ -758,6 +774,12 @@ LogicalResult GPUFuncOp::verifyBody() {
<< blockArgType;
}
+ if (failed(verifyAttributions(getOperation(), getWorkgroupAttributions(),
+ GPUDialect::getWorkgroupAddressSpace())) ||
+ failed(verifyAttributions(getOperation(), getPrivateAttributions(),
+ GPUDialect::getPrivateAddressSpace())))
+ return failure();
+
return success();
}
OpenPOWER on IntegriCloud