summaryrefslogtreecommitdiffstats
path: root/mlir/lib/Conversion/GPUToCUDA
diff options
context:
space:
mode:
authorStephan Herhut <herhut@google.com>2019-06-25 06:44:58 -0700
committerA. Unique TensorFlower <gardener@tensorflow.org>2019-06-25 09:20:40 -0700
commit10f320f7c0d4b4fdedf69731ea803c34d814777e (patch)
treebc5a54098983ac50e9ed7dd49d16770040364e8a /mlir/lib/Conversion/GPUToCUDA
parent594c826578fcf1ca4977f35be4b514357df68ecb (diff)
downloadbcm5719-llvm-10f320f7c0d4b4fdedf69731ea803c34d814777e.tar.gz
bcm5719-llvm-10f320f7c0d4b4fdedf69731ea803c34d814777e.zip
Add gpu::GPUDialect::isKernel helper.
Also some mild cleanup of the kernel to cubin conversion pass. PiperOrigin-RevId: 254959303
Diffstat (limited to 'mlir/lib/Conversion/GPUToCUDA')
-rw-r--r--mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp12
1 files changed, 4 insertions, 8 deletions
diff --git a/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp b/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp
index 739bdde5330..2ff9435c357 100644
--- a/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp
+++ b/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp
@@ -83,7 +83,7 @@ std::string translateModuleToPtx(llvm::Module &module,
using OwnedCubin = std::unique_ptr<std::vector<char>>;
-llvm::Optional<OwnedCubin> compilePtxToCubin(std::string ptx,
+llvm::Optional<OwnedCubin> compilePtxToCubin(std::string &ptx,
Function &function) {
RETURN_ON_CUDA_ERROR(cuInit(0), "cuInit");
@@ -161,10 +161,8 @@ LogicalResult translateGpuKernelToCubinAnnotation(Function &function) {
auto llvmModule = translateModuleToNVVMIR(*module);
auto cubin = convertModuleToCubin(*llvmModule, function);
- if (!cubin) {
- function.emitError("Translation to CUDA binary failed.");
- return failure();
- }
+ if (!cubin)
+ return function.emitError("Translation to CUDA binary failed.");
function.setAttr(kCubinAnnotation,
builder.getStringAttr(
@@ -193,9 +191,7 @@ public:
LLVMInitializeNVPTXAsmPrinter();
for (auto &function : getModule()) {
- UnitAttr isKernelAttr = function.getAttrOfType<UnitAttr>(
- gpu::GPUDialect::getKernelFuncAttrName());
- if (!isKernelAttr || function.isExternal()) {
+ if (!gpu::GPUDialect::isKernel(&function) || function.isExternal()) {
continue;
}
if (failed(translateGpuKernelToCubinAnnotation(function)))
OpenPOWER on IntegriCloud