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 invalid_build_options_error : public error {
70 invalid_build_options_error(const std::string &what = "") :
71 error(CL_INVALID_BUILD_OPTIONS, what) {}
74 class build_error : public error {
76 build_error(const std::string &what = "") :
77 error(CL_BUILD_PROGRAM_FAILURE, what) {}
81 class invalid_object_error;
84 class invalid_object_error<command_queue> : public error {
86 invalid_object_error(std::string what = "") :
87 error(CL_INVALID_COMMAND_QUEUE, what) {}
91 class invalid_object_error<context> : public error {
93 invalid_object_error(std::string what = "") :
94 error(CL_INVALID_CONTEXT, what) {}
98 class invalid_object_error<device> : public error {
100 invalid_object_error(std::string what = "") :
101 error(CL_INVALID_DEVICE, what) {}
105 class invalid_object_error<event> : public error {
107 invalid_object_error(std::string what = "") :
108 error(CL_INVALID_EVENT, what) {}
112 class invalid_object_error<soft_event> : public error {
114 invalid_object_error(std::string what = "") :
115 error(CL_INVALID_EVENT, what) {}
119 class invalid_object_error<kernel> : public error {
121 invalid_object_error(std::string what = "") :
122 error(CL_INVALID_KERNEL, what) {}
126 class invalid_object_error<memory_obj> : public error {
128 invalid_object_error(std::string what = "") :
129 error(CL_INVALID_MEM_OBJECT, what) {}
133 class invalid_object_error<buffer> : public error {
135 invalid_object_error(std::string what = "") :
136 error(CL_INVALID_MEM_OBJECT, what) {}
140 class invalid_object_error<root_buffer> : public error {
142 invalid_object_error(std::string what = "") :
143 error(CL_INVALID_MEM_OBJECT, what) {}
147 class invalid_object_error<sub_buffer> : public error {
149 invalid_object_error(std::string what = "") :
150 error(CL_INVALID_MEM_OBJECT, what) {}
154 class invalid_object_error<image> : public error {
156 invalid_object_error(std::string what = "") :
157 error(CL_INVALID_MEM_OBJECT, what) {}
161 class invalid_object_error<image2d> : public error {
163 invalid_object_error(std::string what = "") :
164 error(CL_INVALID_MEM_OBJECT, what) {}
168 class invalid_object_error<image3d> : public error {
170 invalid_object_error(std::string what = "") :
171 error(CL_INVALID_MEM_OBJECT, what) {}
175 class invalid_object_error<platform> : public error {
177 invalid_object_error(std::string what = "") :
178 error(CL_INVALID_PLATFORM, what) {}
182 class invalid_object_error<program> : public error {
184 invalid_object_error(std::string what = "") :
185 error(CL_INVALID_PROGRAM, what) {}
189 class invalid_object_error<sampler> : public error {
191 invalid_object_error(std::string what = "") :
192 error(CL_INVALID_SAMPLER, what) {}
195 class invalid_wait_list_error : public error {
197 invalid_wait_list_error(std::string what = "") :
198 error(CL_INVALID_EVENT_WAIT_LIST, what) {}