Extended CUDA Library (ecuda)  2.0
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros
cuda_error.hpp
Go to the documentation of this file.
1 /*
2 Copyright (c) 2014-2016, Scott Zuyderduyn
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7 
8 1. Redistributions of source code must retain the above copyright notice, this
9  list of conditions and the following disclaimer.
10 2. Redistributions in binary form must reproduce the above copyright notice,
11  this list of conditions and the following disclaimer in the documentation
12  and/or other materials provided with the distribution.
13 
14 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
18 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 
25 The views and conclusions contained in the software and documentation are those
26 of the authors and should not be interpreted as representing official policies,
27 either expressed or implied, of the FreeBSD Project.
28 */
29 
30 //----------------------------------------------------------------------------
31 // cuda_error.hpp
32 //
33 // Custom exception to throw CUDA API error codes.
34 //
35 // Author: Scott D. Zuyderduyn, Ph.D. (scott.zuyderduyn@utoronto.ca)
36 //----------------------------------------------------------------------------
37 
38 #pragma once
39 #ifndef ECUDA_CUDA_ERROR_HPP
40 #define ECUDA_CUDA_ERROR_HPP
41 
42 #include <stdexcept>
43 #include <string>
44 
45 #include "impl/host_emulation.hpp" // gets data structure definitions when compiling host-only without nvcc
46 
47 namespace ecuda {
48 
55 class cuda_error : public std::runtime_error
56 {
57 
58 private:
59  cudaError_t errorType;
60 
61 public:
66  explicit cuda_error( cudaError_t errorType ) : std::runtime_error(""), errorType(errorType) {}
67 
73  explicit cuda_error( cudaError_t errorType, const std::string& what_arg ) : std::runtime_error( what_arg ), errorType(errorType) {}
74 
80  explicit cuda_error( cudaError_t errorType, const char* what_arg ) : std::runtime_error( what_arg ), errorType(errorType) {}
81 
86  inline cudaError_t get_error_code() const { return errorType; }
87 
88 };
89 
90 } // namespace ecuda
91 
92 #endif
cuda_error(cudaError_t errorType, const char *what_arg)
Constructor.
Definition: cuda_error.hpp:80
Exception for CUDA API cudaError_t errors.
Definition: cuda_error.hpp:55
cuda_error(cudaError_t errorType, const std::string &what_arg)
Constructor.
Definition: cuda_error.hpp:73
cuda_error(cudaError_t errorType)
Constructor.
Definition: cuda_error.hpp:66
cudaError_t get_error_code() const
Gets the error code.
Definition: cuda_error.hpp:86