2 // Copyright 2013 Francisco Jerez
4 // Permission is hereby granted, free of charge, to any person obtaining a
5 // copy of this software and associated documentation files (the "Software"),
6 // to deal in the Software without restriction, including without limitation
7 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 // and/or sell copies of the Software, and to permit persons to whom the
9 // Software is furnished to do so, subject to the following conditions:
11 // The above copyright notice and this permission notice shall be included in
12 // all copies or substantial portions of the Software.
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 // OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 // OTHER DEALINGS IN THE SOFTWARE.
23 #ifndef CLOVER_CORE_ERROR_HPP
24 #define CLOVER_CORE_ERROR_HPP
51 /// Class that represents an error that can be converted to an
52 /// OpenCL status code.
54 class error : public std::runtime_error {
56 error(cl_int code, std::string what = "") :
57 std::runtime_error(what), code(code) {
68 class build_error : public error {
70 build_error(const std::string &what = "") :
71 error(CL_COMPILE_PROGRAM_FAILURE, what) {
76 class invalid_object_error;
79 class invalid_object_error<command_queue> : public error {
81 invalid_object_error(std::string what = "") :
82 error(CL_INVALID_COMMAND_QUEUE, what) {}
86 class invalid_object_error<context> : public error {
88 invalid_object_error(std::string what = "") :
89 error(CL_INVALID_CONTEXT, what) {}
93 class invalid_object_error<device> : public error {
95 invalid_object_error(std::string what = "") :
96 error(CL_INVALID_DEVICE, what) {}
100 class invalid_object_error<event> : public error {
102 invalid_object_error(std::string what = "") :
103 error(CL_INVALID_EVENT, what) {}
107 class invalid_object_error<soft_event> : public error {
109 invalid_object_error(std::string what = "") :
110 error(CL_INVALID_EVENT, what) {}
114 class invalid_object_error<kernel> : public error {
116 invalid_object_error(std::string what = "") :
117 error(CL_INVALID_KERNEL, what) {}
121 class invalid_object_error<memory_obj> : public error {
123 invalid_object_error(std::string what = "") :
124 error(CL_INVALID_MEM_OBJECT, what) {}
128 class invalid_object_error<buffer> : public error {
130 invalid_object_error(std::string what = "") :
131 error(CL_INVALID_MEM_OBJECT, what) {}
135 class invalid_object_error<root_buffer> : public error {
137 invalid_object_error(std::string what = "") :
138 error(CL_INVALID_MEM_OBJECT, what) {}
142 class invalid_object_error<sub_buffer> : public error {
144 invalid_object_error(std::string what = "") :
145 error(CL_INVALID_MEM_OBJECT, what) {}
149 class invalid_object_error<image> : public error {
151 invalid_object_error(std::string what = "") :
152 error(CL_INVALID_MEM_OBJECT, what) {}
156 class invalid_object_error<image2d> : public error {
158 invalid_object_error(std::string what = "") :
159 error(CL_INVALID_MEM_OBJECT, what) {}
163 class invalid_object_error<image3d> : public error {
165 invalid_object_error(std::string what = "") :
166 error(CL_INVALID_MEM_OBJECT, what) {}
170 class invalid_object_error<platform> : public error {
172 invalid_object_error(std::string what = "") :
173 error(CL_INVALID_PLATFORM, what) {}
177 class invalid_object_error<program> : public error {
179 invalid_object_error(std::string what = "") :
180 error(CL_INVALID_PROGRAM, what) {}
184 class invalid_object_error<sampler> : public error {
186 invalid_object_error(std::string what = "") :
187 error(CL_INVALID_SAMPLER, what) {}
190 class invalid_wait_list_error : public error {
192 invalid_wait_list_error(std::string what = "") :
193 error(CL_INVALID_EVENT_WAIT_LIST, what) {}