[Mlir-commits] [mlir] 616eb0b - [mlir][gpu] Fix error message on unknown CUDA error code.

Ingo Müller llvmlistbot at llvm.org
Fri Aug 11 01:05:03 PDT 2023


Author: Ingo Müller
Date: 2023-08-11T08:04:58Z
New Revision: 616eb0b2c4d5441ce9c649fd469f1778b8f4dd1b

URL: https://github.com/llvm/llvm-project/commit/616eb0b2c4d5441ce9c649fd469f1778b8f4dd1b
DIFF: https://github.com/llvm/llvm-project/commit/616eb0b2c4d5441ce9c649fd469f1778b8f4dd1b.diff

LOG: [mlir][gpu] Fix error message on unknown CUDA error code.

This patch fixes the output of the error message that is printed when
the CUDA library cannot identity the error code. In that case, no error
message is provided by the library, and the previous implementation just
printed the content of a randomly initialized pointer. This patch
initializes the pointer to nullptr and only prints the content if that
has changed.

Reviewed By: Mogball

Differential Revision: https://reviews.llvm.org/D156791

Added: 
    

Modified: 
    mlir/lib/Dialect/GPU/Transforms/SerializeToCubin.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Dialect/GPU/Transforms/SerializeToCubin.cpp b/mlir/lib/Dialect/GPU/Transforms/SerializeToCubin.cpp
index 0077debe26a0b2..f1c67019b262ff 100644
--- a/mlir/lib/Dialect/GPU/Transforms/SerializeToCubin.cpp
+++ b/mlir/lib/Dialect/GPU/Transforms/SerializeToCubin.cpp
@@ -27,13 +27,14 @@ using namespace mlir;
 
 static void emitCudaError(const llvm::Twine &expr, const char *buffer,
                           CUresult result, Location loc) {
-  const char *error;
+  const char *error = nullptr;
   cuGetErrorString(result, &error);
-  emitError(loc, expr.concat(" failed with error code ")
-                     .concat(llvm::Twine{error})
-                     .concat("[")
-                     .concat(buffer)
-                     .concat("]"));
+  emitError(loc,
+            expr.concat(error ? " failed with error code " + llvm::Twine{error}
+                              : llvm::Twine(" failed with unknown error "))
+                .concat("[")
+                .concat(buffer)
+                .concat("]"));
 }
 
 #define RETURN_ON_CUDA_ERROR(expr)                                             \


        


More information about the Mlir-commits mailing list