PageRenderTime 47ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/src/gallium/state_trackers/clover/core/error.hpp

https://github.com/dscharrer/black_mesa
C++ Header | 196 lines | 144 code | 27 blank | 25 comment | 0 complexity | 6e425f088e8746d2614f940063c28005 MD5 | raw file
Possible License(s): LGPL-2.0
  1. //
  2. // Copyright 2013 Francisco Jerez
  3. //
  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:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  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.
  21. //
  22. #ifndef CLOVER_CORE_ERROR_HPP
  23. #define CLOVER_CORE_ERROR_HPP
  24. #include "CL/cl.h"
  25. #include "util/compat.hpp"
  26. namespace clover {
  27. class command_queue;
  28. class context;
  29. class device;
  30. class event;
  31. class hard_event;
  32. class soft_event;
  33. class kernel;
  34. class memory_obj;
  35. class buffer;
  36. class root_buffer;
  37. class sub_buffer;
  38. class image;
  39. class image2d;
  40. class image3d;
  41. class platform;
  42. class program;
  43. class sampler;
  44. ///
  45. /// Class that represents an error that can be converted to an
  46. /// OpenCL status code.
  47. ///
  48. class error : public compat::runtime_error {
  49. public:
  50. error(cl_int code, compat::string what = "") :
  51. compat::runtime_error(what), code(code) {
  52. }
  53. cl_int get() const {
  54. return code;
  55. }
  56. protected:
  57. cl_int code;
  58. };
  59. class build_error : public error {
  60. public:
  61. build_error(const compat::string &log) :
  62. error(CL_BUILD_PROGRAM_FAILURE, log) {
  63. }
  64. };
  65. template<typename O>
  66. class invalid_object_error;
  67. template<>
  68. class invalid_object_error<command_queue> : public error {
  69. public:
  70. invalid_object_error(std::string what = "") :
  71. error(CL_INVALID_COMMAND_QUEUE, what) {}
  72. };
  73. template<>
  74. class invalid_object_error<context> : public error {
  75. public:
  76. invalid_object_error(std::string what = "") :
  77. error(CL_INVALID_CONTEXT, what) {}
  78. };
  79. template<>
  80. class invalid_object_error<device> : public error {
  81. public:
  82. invalid_object_error(std::string what = "") :
  83. error(CL_INVALID_DEVICE, what) {}
  84. };
  85. template<>
  86. class invalid_object_error<event> : public error {
  87. public:
  88. invalid_object_error(std::string what = "") :
  89. error(CL_INVALID_EVENT, what) {}
  90. };
  91. template<>
  92. class invalid_object_error<soft_event> : public error {
  93. public:
  94. invalid_object_error(std::string what = "") :
  95. error(CL_INVALID_EVENT, what) {}
  96. };
  97. template<>
  98. class invalid_object_error<kernel> : public error {
  99. public:
  100. invalid_object_error(std::string what = "") :
  101. error(CL_INVALID_KERNEL, what) {}
  102. };
  103. template<>
  104. class invalid_object_error<memory_obj> : public error {
  105. public:
  106. invalid_object_error(std::string what = "") :
  107. error(CL_INVALID_MEM_OBJECT, what) {}
  108. };
  109. template<>
  110. class invalid_object_error<buffer> : public error {
  111. public:
  112. invalid_object_error(std::string what = "") :
  113. error(CL_INVALID_MEM_OBJECT, what) {}
  114. };
  115. template<>
  116. class invalid_object_error<root_buffer> : public error {
  117. public:
  118. invalid_object_error(std::string what = "") :
  119. error(CL_INVALID_MEM_OBJECT, what) {}
  120. };
  121. template<>
  122. class invalid_object_error<sub_buffer> : public error {
  123. public:
  124. invalid_object_error(std::string what = "") :
  125. error(CL_INVALID_MEM_OBJECT, what) {}
  126. };
  127. template<>
  128. class invalid_object_error<image> : public error {
  129. public:
  130. invalid_object_error(std::string what = "") :
  131. error(CL_INVALID_MEM_OBJECT, what) {}
  132. };
  133. template<>
  134. class invalid_object_error<image2d> : public error {
  135. public:
  136. invalid_object_error(std::string what = "") :
  137. error(CL_INVALID_MEM_OBJECT, what) {}
  138. };
  139. template<>
  140. class invalid_object_error<image3d> : public error {
  141. public:
  142. invalid_object_error(std::string what = "") :
  143. error(CL_INVALID_MEM_OBJECT, what) {}
  144. };
  145. template<>
  146. class invalid_object_error<platform> : public error {
  147. public:
  148. invalid_object_error(std::string what = "") :
  149. error(CL_INVALID_PLATFORM, what) {}
  150. };
  151. template<>
  152. class invalid_object_error<program> : public error {
  153. public:
  154. invalid_object_error(std::string what = "") :
  155. error(CL_INVALID_PROGRAM, what) {}
  156. };
  157. template<>
  158. class invalid_object_error<sampler> : public error {
  159. public:
  160. invalid_object_error(std::string what = "") :
  161. error(CL_INVALID_SAMPLER, what) {}
  162. };
  163. class invalid_wait_list_error : public error {
  164. public:
  165. invalid_wait_list_error(std::string what = "") :
  166. error(CL_INVALID_EVENT_WAIT_LIST, what) {}
  167. };
  168. }
  169. #endif