5#ifndef GKO_PUBLIC_CORE_BASE_EXCEPTION_HPP_
6#define GKO_PUBLIC_CORE_BASE_EXCEPTION_HPP_
12#include <ginkgo/core/base/types.hpp>
57class Error :
public std::exception {
66 Error(
const std::string& file,
int line,
const std::string&
what)
67 : what_(file +
":" +
std::to_string(line) +
": " +
what)
74 virtual const char*
what() const noexcept
override {
return what_.c_str(); }
77 const std::string what_;
95 :
Error(file, line, func +
" is not implemented")
114 NotCompiled(
const std::string& file,
int line,
const std::string& func,
115 const std::string& module)
117 "feature " + func +
" is part of the " + module +
118 " module, which is not compiled on this system")
138 NotSupported(
const std::string& file,
int line,
const std::string& func,
139 const std::string& obj_type)
141 "Operation " + func +
" does not support parameters of type " +
159 MpiError(
const std::string& file,
int line,
const std::string& func,
161 :
Error(file, line, func +
": " + get_error(error_code))
165 static std::string get_error(
int64 error_code);
182 CudaError(
const std::string& file,
int line,
const std::string& func,
184 :
Error(file, line, func +
": " + get_error(error_code))
188 static std::string get_error(
int64 error_code);
205 CublasError(
const std::string& file,
int line,
const std::string& func,
207 :
Error(file, line, func +
": " + get_error(error_code))
211 static std::string get_error(
int64 error_code);
228 CurandError(
const std::string& file,
int line,
const std::string& func,
230 :
Error(file, line, func +
": " + get_error(error_code))
234 static std::string get_error(
int64 error_code);
253 :
Error(file, line, func +
": " + get_error(error_code))
257 static std::string get_error(
int64 error_code);
274 CufftError(
const std::string& file,
int line,
const std::string& func,
276 :
Error(file, line, func +
": " + get_error(error_code))
280 static std::string get_error(
int64 error_code);
297 HipError(
const std::string& file,
int line,
const std::string& func,
299 :
Error(file, line, func +
": " + get_error(error_code))
303 static std::string get_error(
int64 error_code);
320 HipblasError(
const std::string& file,
int line,
const std::string& func,
322 :
Error(file, line, func +
": " + get_error(error_code))
326 static std::string get_error(
int64 error_code);
343 HiprandError(
const std::string& file,
int line,
const std::string& func,
345 :
Error(file, line, func +
": " + get_error(error_code))
349 static std::string get_error(
int64 error_code);
369 :
Error(file, line, func +
": " + get_error(error_code))
373 static std::string get_error(
int64 error_code);
390 HipfftError(
const std::string& file,
int line,
const std::string& func,
392 :
Error(file, line, func +
": " + get_error(error_code))
396 static std::string get_error(
int64 error_code);
413 MetisError(
const std::string& file,
int line,
const std::string& func,
414 const std::string& error)
415 :
Error(file, line, func +
": " + error)
441 const std::string& func,
const std::string& first_name,
443 const std::string& second_name,
size_type second_rows,
444 size_type second_cols,
const std::string& clarification)
446 func +
": attempting to combine operators " + first_name +
447 " [" +
std::to_string(first_rows) +
" x " +
448 std::to_string(first_cols) +
"] and " + second_name +
" [" +
449 std::to_string(second_rows) +
" x " +
450 std::to_string(second_cols) +
"]: " + clarification)
472 BadDimension(
const std::string& file,
int line,
const std::string& func,
473 const std::string& op_name,
size_type op_num_rows,
474 size_type op_num_cols,
const std::string& clarification)
476 func +
": Object " + op_name +
" has dimensions [" +
477 std::to_string(op_num_rows) +
" x " +
478 std::to_string(op_num_cols) +
"]: " + clarification)
489template <
typename IndexType>
499 const int block_size,
const IndexType size)
501 "block size = " +
std::to_string(block_size) +
502 ", size = " +
std::to_string(size))
524 const std::string& clarification)
526 func +
": Value mismatch : " +
std::to_string(val1) +
" and " +
527 std::to_string(val2) +
" : " + clarification)
546 const std::string& device,
size_type bytes)
548 device +
": failed to allocate memory block of " +
549 std::to_string(bytes) +
"B")
571 "trying to access index " +
std::to_string(index) +
572 " in a memory block of " +
std::to_string(bound) +
590 const std::string& index_type)
591 :
Error(file, line,
"Overflowing " + index_type)
609 StreamError(
const std::string& file,
int line,
const std::string& func,
610 const std::string& message)
611 :
Error(file, line, func +
": " + message)
630 :
Error(file, line, func +
": unable to find an eligible kernel")
651 const std::string& msg)
652 :
Error(file, line, msg)
669 const std::string& func,
const std::string& clarification)
671 func +
": Invalid state encountered : " + clarification)
AllocationError(const std::string &file, int line, const std::string &device, size_type bytes)
Initializes an allocation error.
Definition exception.hpp:545
BadDimension(const std::string &file, int line, const std::string &func, const std::string &op_name, size_type op_num_rows, size_type op_num_cols, const std::string &clarification)
Initializes a bad dimension error.
Definition exception.hpp:472
BlockSizeError(const std::string &file, const int line, const int block_size, const IndexType size)
Definition exception.hpp:498
CublasError(const std::string &file, int line, const std::string &func, int64 error_code)
Initializes a cuBLAS error.
Definition exception.hpp:205
CudaError(const std::string &file, int line, const std::string &func, int64 error_code)
Initializes a CUDA error.
Definition exception.hpp:182
CufftError(const std::string &file, int line, const std::string &func, int64 error_code)
Initializes a cuFFT error.
Definition exception.hpp:274
CurandError(const std::string &file, int line, const std::string &func, int64 error_code)
Initializes a cuRAND error.
Definition exception.hpp:228
CusparseError(const std::string &file, int line, const std::string &func, int64 error_code)
Initializes a cuSPARSE error.
Definition exception.hpp:251
DimensionMismatch(const std::string &file, int line, const std::string &func, const std::string &first_name, size_type first_rows, size_type first_cols, const std::string &second_name, size_type second_rows, size_type second_cols, const std::string &clarification)
Initializes a dimension mismatch error.
Definition exception.hpp:440
Error(const std::string &file, int line, const std::string &what)
Initializes an error.
Definition exception.hpp:66
virtual const char * what() const noexcept override
Returns a human-readable string with a more detailed description of the error.
Definition exception.hpp:74
HipError(const std::string &file, int line, const std::string &func, int64 error_code)
Initializes a HIP error.
Definition exception.hpp:297
HipblasError(const std::string &file, int line, const std::string &func, int64 error_code)
Initializes a hipBLAS error.
Definition exception.hpp:320
HipfftError(const std::string &file, int line, const std::string &func, int64 error_code)
Initializes a hipFFT error.
Definition exception.hpp:390
HiprandError(const std::string &file, int line, const std::string &func, int64 error_code)
Initializes a hipRAND error.
Definition exception.hpp:343
HipsparseError(const std::string &file, int line, const std::string &func, int64 error_code)
Initializes a hipSPARSE error.
Definition exception.hpp:367
InvalidStateError(const std::string &file, int line, const std::string &func, const std::string &clarification)
Initializes an invalid state error.
Definition exception.hpp:668
KernelNotFound(const std::string &file, int line, const std::string &func)
Initializes a KernelNotFound error.
Definition exception.hpp:629
MetisError(const std::string &file, int line, const std::string &func, const std::string &error)
Initializes a METIS error.
Definition exception.hpp:413
MpiError(const std::string &file, int line, const std::string &func, int64 error_code)
Initializes a MPI error.
Definition exception.hpp:159
NotCompiled(const std::string &file, int line, const std::string &func, const std::string &module)
Initializes a NotCompiled error.
Definition exception.hpp:114
NotImplemented(const std::string &file, int line, const std::string &func)
Initializes a NotImplemented error.
Definition exception.hpp:94
NotSupported(const std::string &file, int line, const std::string &func, const std::string &obj_type)
Initializes a NotSupported error.
Definition exception.hpp:138
OutOfBoundsError(const std::string &file, int line, size_type index, size_type bound)
Initializes an OutOfBoundsError.
Definition exception.hpp:568
OverflowError(const std::string &file, const int line, const std::string &index_type)
Definition exception.hpp:589
StreamError(const std::string &file, int line, const std::string &func, const std::string &message)
Initializes a file access error.
Definition exception.hpp:609
UnsupportedMatrixProperty(const std::string &file, const int line, const std::string &msg)
Initializes the UnsupportedMatrixProperty error.
Definition exception.hpp:650
ValueMismatch(const std::string &file, int line, const std::string &func, size_type val1, size_type val2, const std::string &clarification)
Initializes a value mismatch error.
Definition exception.hpp:522
The Ginkgo namespace.
Definition abstract_factory.hpp:20
std::int64_t int64
64-bit signed integral type.
Definition types.hpp:113
std::size_t size_type
Integral type used for allocation quantities.
Definition types.hpp:90