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
28 #include "util/compat.hpp"
50 /// Class that represents an error that can be converted to an
51 /// OpenCL status code.
53 class error : public compat::runtime_error {
55 error(cl_int code, compat::string what = "") :
56 compat::runtime_error(what), code(code) {
67 class build_error : public error {
69 build_error(const compat::string &what = "") :
70 error(CL_COMPILE_PROGRAM_FAILURE, what) {
75 class invalid_object_error;
78 class invalid_object_error<command_queue> : public error {
80 invalid_object_error(std::string what = "") :
81 error(CL_INVALID_COMMAND_QUEUE, what) {}
85 class invalid_object_error<context> : public error {
87 invalid_object_error(std::string what = "") :
88 error(CL_INVALID_CONTEXT, what) {}
92 class invalid_object_error<device> : public error {
94 invalid_object_error(std::string what = "") :
95 error(CL_INVALID_DEVICE, what) {}
99 class invalid_object_error<event> : public error {
101 invalid_object_error(std::string what = "") :
102 error(CL_INVALID_EVENT, what) {}
106 class invalid_object_error<soft_event> : public error {
108 invalid_object_error(std::string what = "") :
109 error(CL_INVALID_EVENT, what) {}
113 class invalid_object_error<kernel> : public error {
115 invalid_object_error(std::string what = "") :
116 error(CL_INVALID_KERNEL, what) {}
120 class invalid_object_error<memory_obj> : public error {
122 invalid_object_error(std::string what = "") :
123 error(CL_INVALID_MEM_OBJECT, what) {}
127 class invalid_object_error<buffer> : public error {
129 invalid_object_error(std::string what = "") :
130 error(CL_INVALID_MEM_OBJECT, what) {}
134 class invalid_object_error<root_buffer> : public error {
136 invalid_object_error(std::string what = "") :
137 error(CL_INVALID_MEM_OBJECT, what) {}
141 class invalid_object_error<sub_buffer> : public error {
143 invalid_object_error(std::string what = "") :
144 error(CL_INVALID_MEM_OBJECT, what) {}
148 class invalid_object_error<image> : public error {
150 invalid_object_error(std::string what = "") :
151 error(CL_INVALID_MEM_OBJECT, what) {}
155 class invalid_object_error<image2d> : public error {
157 invalid_object_error(std::string what = "") :
158 error(CL_INVALID_MEM_OBJECT, what) {}
162 class invalid_object_error<image3d> : public error {
164 invalid_object_error(std::string what = "") :
165 error(CL_INVALID_MEM_OBJECT, what) {}
169 class invalid_object_error<platform> : public error {
171 invalid_object_error(std::string what = "") :
172 error(CL_INVALID_PLATFORM, what) {}
176 class invalid_object_error<program> : public error {
178 invalid_object_error(std::string what = "") :
179 error(CL_INVALID_PROGRAM, what) {}
183 class invalid_object_error<sampler> : public error {
185 invalid_object_error(std::string what = "") :
186 error(CL_INVALID_SAMPLER, what) {}
189 class invalid_wait_list_error : public error {
191 invalid_wait_list_error(std::string what = "") :
192 error(CL_INVALID_EVENT_WAIT_LIST, what) {}