exceptions.h
Go to the documentation of this file.
/******************************************************************************
* Copyright (c) 2011-2019, NVIDIA CORPORATION. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are not permitted.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************/
#pragma once
#include <cuda_runtime.h>
#include <iosfwd>
#include <stdexcept>
#include "cutlass/platform/platform.h"
namespace cutlass {
class cuda_exception : public std::exception {
public:
cuda_exception(const char* msg = "", cudaError_t err = cudaErrorUnknown) : msg(msg), err(err) {}
cudaError_t cudaError() const { return err; }
protected:
const char* msg;
cudaError_t err;
};
inline std::ostream& operator<<(std::ostream& out, cudaError_t result) {
return out << cudaGetErrorString(result);
}
inline std::ostream& operator<<(std::ostream& out, cuda_exception const& e) {
return out << e.what() << ": " << e.cudaError();
}
} // namespace cutlass
cutlass
Definition: aligned_buffer.h:35
cutlass::cuda_exception::cudaError
cudaError_t cudaError() const
Returns the underlying CUDA cudaError_t.
Definition: exceptions.h:42
cutlass::cuda_exception::cuda_exception
cuda_exception(const char *msg="", cudaError_t err=cudaErrorUnknown)
Constructor.
Definition: exceptions.h:39
platform.h
C++ features that may be otherwise unimplemented for CUDA device functions.
cutlass::cuda_exception::msg
const char * msg
Explanatory string.
Definition: exceptions.h:46
cutlass::operator<<
std::ostream & operator<<(std::ostream &out, complex< T > const &z)
Definition: complex.h:291
cutlass::cuda_exception
C++ exception wrapper for CUDA cudaError_t.
Definition: exceptions.h:36
cutlass::cuda_exception::err
cudaError_t err
Underlying CUDA cudaError_t.
Definition: exceptions.h:49