]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add cuSOLVER asserts
authorBruno Turcksin <bruno.turcksin@gmail.com>
Mon, 23 Apr 2018 22:28:49 +0000 (18:28 -0400)
committerBruno Turcksin <bruno.turcksin@gmail.com>
Thu, 26 Apr 2018 21:23:41 +0000 (17:23 -0400)
include/deal.II/base/exceptions.h
source/base/exceptions.cc

index 9f03b13ab02286504fca5c820dde695c672da3af..3348946340906e57463228ad1a145fed7abea67d 100644 (file)
@@ -23,6 +23,7 @@
 #include <ostream>
 
 #ifdef DEAL_II_WITH_CUDA
+#include <cusolverSp.h>
 #include <cusparse.h>
 #endif
 
@@ -1088,6 +1089,12 @@ namespace deal_II_exceptions
      * function but there is no equivalent function for cuSPARSE.
      */
     std::string get_cusparse_error_string(const cusparseStatus_t error_code);
+
+    /**
+     * Return a string given an error code. This is similar to the cudaGetErrorString
+     * function but there is no equivalent function for cuSOLVER.
+     */
+    std::string get_cusolver_error_string(const cusolverStatus_t error_code);
 #endif
   } /*namespace internals*/
 
@@ -1320,6 +1327,15 @@ AssertThrow(error_code == MPI_SUCCESS, dealii::ExcMPI(error_code))
 #define AssertCusparse(error_code) { (void) (error_code); }
 #endif
 
+#ifdef DEBUG
+#define AssertCusolver(error_code) Assert(error_code == CUSOLVER_STATUS_SUCCESS, \
+                                          dealii::ExcCusparseError( \
+                                              dealii::deal_II_exceptions::internals:: \
+                                              get_cusolver_error_string(error_code)))
+#else
+#define AssertCusolver(error_code) { (void) (error_code); }
+#endif
+
 #endif
 
 using namespace StandardExceptions;
index 73ac86749158f1bb07b252509caae9a0636e45b6..6cc57bcba409f6ed1ab3ad3ca0190d11f07189cb 100644 (file)
@@ -522,6 +522,48 @@ namespace deal_II_exceptions
         }
         }
     }
+
+
+
+    std::string get_cusolver_error_string(cusolverStatus_t error_code)
+    {
+      std::string message;
+      switch (error_code)
+        {
+        case CUSOLVER_STATUS_NOT_INITIALIZED:
+        {
+          return "The cuSolver library was not initialized";
+        }
+        case CUSOLVER_STATUS_ALLOC_FAILED:
+        {
+          return "Resource allocation failed inside the cuSolver library";
+        }
+        case CUSOLVER_STATUS_INVALID_VALUE:
+        {
+          return "An unsupported value of a parameter was passed to the function";
+        }
+        case CUSOLVER_STATUS_ARCH_MISMATCH:
+        {
+          return "The function requires a feature absent from the device architecture";
+        }
+        case CUSOLVER_STATUS_EXECUTION_FAILED:
+        {
+          return "The GPU program failed to execute";
+        }
+        case CUSOLVER_STATUS_INTERNAL_ERROR:
+        {
+          return "An internal cuSolver operation failed";
+        }
+        case CUSOLVER_STATUS_MATRIX_TYPE_NOT_SUPPORTED:
+        {
+          return "The matrix type is not supported by this function";
+        }
+        default:
+        {
+          return "Unknown error";
+        }
+        }
+    }
 #endif
 
   } /*namespace internals*/

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.