From b98af44fcf89b9946e1de438b1f5527e6bf28905 Mon Sep 17 00:00:00 2001 From: Ivan Shapovalov Date: Sat, 22 Oct 2016 05:14:19 +0300 Subject: treewide: use C++ exceptions properly Since the codebase is designed around proper C++ idioms such as RAII, it makes sense to only use C++ exceptions internally instead of mixing exceptions and error codes. The exceptions are now caught at top level to preserve compatibility with the existing error code-based API. Note that we deliberately do not catch C++ runtime errors (such as `std::bad_alloc`) nor logic errors (aka failed assertions) because no actual handling can ever happen for such errors. However, in the C interface we do catch _all_ exceptions (...) and convert them into a wild-card error code. --- include/clblast.h | 5 +++-- include/clblast_c.h | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/clblast.h b/include/clblast.h index 0f52b2f9..53e23669 100644 --- a/include/clblast.h +++ b/include/clblast.h @@ -75,13 +75,14 @@ enum class StatusCode { kInsufficientMemoryY = -1007, // Vector Y's OpenCL buffer is too small // Custom additional status codes for CLBlast - kKernelLaunchError = -2048, // Problem occurred when enqueuing the kernel - kKernelRunError = -2047, // Problem occurred while running the kernel kInvalidLocalMemUsage = -2046, // Not enough local memory available on this device kNoHalfPrecision = -2045, // Half precision (16-bits) not supported by the device kNoDoublePrecision = -2044, // Double precision (64-bits) not supported by the device kInvalidVectorScalar = -2043, // The unit-sized vector is not a valid OpenCL buffer kInsufficientMemoryScalar = -2042, // The unit-sized vector's OpenCL buffer is too small + kDatabaseError = -2041, // Entry for the device was not found in the database + kUnknownError = -2040, // A catch-all error code representing an unspecified error + kUnexpectedError = -2039, // A catch-all error code representing an unexpected exception }; // Matrix layout and transpose types diff --git a/include/clblast_c.h b/include/clblast_c.h index 33fb4acf..2805c20f 100644 --- a/include/clblast_c.h +++ b/include/clblast_c.h @@ -76,13 +76,14 @@ typedef enum StatusCode_ { kInsufficientMemoryY = -1007, // Vector Y's OpenCL buffer is too small // Custom additional status codes for CLBlast - kKernelLaunchError = -2048, // Problem occurred when enqueuing the kernel - kKernelRunError = -2047, // Problem occurred while running the kernel kInvalidLocalMemUsage = -2046, // Not enough local memory available on this device kNoHalfPrecision = -2045, // Half precision (16-bits) not supported by the device kNoDoublePrecision = -2044, // Double precision (64-bits) not supported by the device kInvalidVectorScalar = -2043, // The unit-sized vector is not a valid OpenCL buffer kInsufficientMemoryScalar = -2042, // The unit-sized vector's OpenCL buffer is too small + kDatabaseError = -2041, // Entry for the device was not found in the database + kUnknownError = -2040, // A catch-all error code representing an unspecified error + kUnexpectedError = -2039, // A catch-all error code representing an unexpected exception } StatusCode; // Matrix layout and transpose types -- cgit v1.2.3