Mila
Deep Neural Network Library
Loading...
Searching...
No Matches
Mila::Dnn::Compute::CudaError Class Referenceexport
module Cuda.Error

Exception class for CUDA runtime errors. More...

Inheritance diagram for Mila::Dnn::Compute::CudaError:
Collaboration diagram for Mila::Dnn::Compute::CudaError:

Public Member Functions

 CudaError (cudaError_t status, const std::source_location &location=std::source_location::current())
 Constructs a new CudaError exception.
 
cudaError_t getError () const noexcept
 Gets the CUDA error code.
 
const char * getFile () const noexcept
 Gets the filename where the error occurred.
 
const char * getFunction () const noexcept
 Gets the function name where the error occurred.
 
uint32_t getLine () const noexcept
 Gets the line number where the error occurred.
 

Static Private Member Functions

static std::string getMessage (cudaError_t status, const std::source_location &location)
 Generates a detailed error message from a CUDA error.
 

Private Attributes

cudaError_t cuda_error_ = cudaSuccess
 The CUDA error code.
 
const char * file_
 Source file where the error occurred.
 
const char * function_
 Function name where the error occurred.
 
uint32_t line_
 Line number where the error occurred.
 

Detailed Description

Exception class for CUDA runtime errors.

This class wraps CUDA runtime API errors with additional context information such as the file, line, and function where the error occurred. It inherits from std::runtime_error and provides methods to access error details.

Constructor & Destructor Documentation

◆ CudaError()

Mila::Dnn::Compute::CudaError::CudaError ( cudaError_t  status,
const std::source_location &  location = std::source_location::current() 
)
inline

Constructs a new CudaError exception.

Parameters
statusThe CUDA error status code.
locationSource location information (automatically populated by default).

Member Function Documentation

◆ getError()

cudaError_t Mila::Dnn::Compute::CudaError::getError ( ) const
inlinenoexcept

Gets the CUDA error code.

Returns
cudaError_t The original CUDA error status.

◆ getFile()

const char * Mila::Dnn::Compute::CudaError::getFile ( ) const
inlinenoexcept

Gets the filename where the error occurred.

Returns
const char* Pointer to the filename string.

◆ getFunction()

const char * Mila::Dnn::Compute::CudaError::getFunction ( ) const
inlinenoexcept

Gets the function name where the error occurred.

Returns
const char* Pointer to the function name string.

◆ getLine()

uint32_t Mila::Dnn::Compute::CudaError::getLine ( ) const
inlinenoexcept

Gets the line number where the error occurred.

Returns
uint32_t The line number in the source file.

◆ getMessage()

static std::string Mila::Dnn::Compute::CudaError::getMessage ( cudaError_t  status,
const std::source_location &  location 
)
inlinestaticprivate

Generates a detailed error message from a CUDA error.

Parameters
statusThe CUDA error status code.
locationSource location information.
Returns
std::string A formatted error message with context information.

Member Data Documentation

◆ cuda_error_

cudaError_t Mila::Dnn::Compute::CudaError::cuda_error_ = cudaSuccess
private

The CUDA error code.

◆ file_

const char* Mila::Dnn::Compute::CudaError::file_
private

Source file where the error occurred.

◆ function_

const char* Mila::Dnn::Compute::CudaError::function_
private

Function name where the error occurred.

◆ line_

uint32_t Mila::Dnn::Compute::CudaError::line_
private

Line number where the error occurred.


The documentation for this class was generated from the following file: