1 /* 2 * Copyright © 2012 Blaž Tomažič <blaz.tomazic@gmail.com> 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 (including the next 12 * paragraph) shall be included in all copies or substantial portions of the 13 * Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 * DEALINGS IN THE SOFTWARE. 22 */ 23 24 #pragma once 25 #ifndef PIGLIT_UTIL_CL_ENUM_H 26 #define PIGLIT_UTIL_CL_ENUM_H 27 28 #define CL_USE_DEPRECATED_OPENCL_1_0_APIS 29 #define CL_USE_DEPRECATED_OPENCL_1_1_APIS 30 #define CL_USE_DEPRECATED_OPENCL_1_2_APIS 31 #define CL_USE_DEPRECATED_OPENCL_2_0_APIS 32 33 #ifdef __APPLE__ 34 #include <OpenCL/opencl.h> 35 #else 36 #include <CL/opencl.h> 37 #endif 38 /** 39 * \brief Convert a CL enum to a string. 40 * 41 * For example, given CL_PLATFORM_NAME, return "CL_PLATFORM_NAME". 42 * 43 * Return "(unrecognized enum)" if the enum is not recognized. 44 * 45 * \warning Not all enums are recognized. Bitfield and non-unique 46 * enums will return "(unrecognized enum)" 47 */ 48 const char *piglit_cl_get_enum_name(cl_uint param); 49 50 /** 51 * \brief Convert a CL error to a string. 52 * 53 * For example, given CL_DEVICE_NOT_FOUND, return "CL_DEVICE_NOT_FOUND". 54 * 55 * Return "(unrecognized error)" if the error is not recognized. 56 */ 57 const char* piglit_cl_get_error_name(cl_int error); 58 59 60 #define PIGLIT_CL_ENUM_NUM(name, version) \ 61 version == 10 ? \ 62 piglit_##name##_num_1_0 : \ 63 version == 11 ? \ 64 piglit_##name##_num_1_1 : \ 65 version == 12 ? \ 66 piglit_##name##_num_1_2 : \ 67 version == 20 ? \ 68 piglit_##name##_num_2_0 : \ 69 0 70 71 #define PIGLIT_CL_ENUM_ARRAY(name) \ 72 piglit_##name 73 74 75 #define PIGLIT_CL_DEFINE_ENUM_PROTOTYPE(type, name) \ 76 extern const unsigned int piglit_##name##_num_1_0; \ 77 extern const unsigned int piglit_##name##_num_1_1; \ 78 extern const unsigned int piglit_##name##_num_1_2; \ 79 extern const unsigned int piglit_##name##_num_2_0; \ 80 extern const type* piglit_##name; 81 82 #define PIGLIT_CL_DEFINE_ENUM_PROTOTYPE_2(name) \ 83 PIGLIT_CL_DEFINE_ENUM_PROTOTYPE(name, name) 84 85 86 PIGLIT_CL_DEFINE_ENUM_PROTOTYPE_2(cl_mem_flags); 87 PIGLIT_CL_DEFINE_ENUM_PROTOTYPE_2(cl_device_type); 88 PIGLIT_CL_DEFINE_ENUM_PROTOTYPE_2(cl_program_info); 89 PIGLIT_CL_DEFINE_ENUM_PROTOTYPE_2(cl_program_build_info); 90 PIGLIT_CL_DEFINE_ENUM_PROTOTYPE_2(cl_mem_info); 91 PIGLIT_CL_DEFINE_ENUM_PROTOTYPE_2(cl_kernel_info); 92 #ifdef CL_VERSION_1_2 93 PIGLIT_CL_DEFINE_ENUM_PROTOTYPE_2(cl_kernel_arg_info); 94 #endif 95 PIGLIT_CL_DEFINE_ENUM_PROTOTYPE_2(cl_kernel_work_group_info); 96 PIGLIT_CL_DEFINE_ENUM_PROTOTYPE_2(cl_event_info); 97 PIGLIT_CL_DEFINE_ENUM_PROTOTYPE_2(cl_image_info); 98 PIGLIT_CL_DEFINE_ENUM_PROTOTYPE_2(cl_command_queue_info); 99 PIGLIT_CL_DEFINE_ENUM_PROTOTYPE_2(cl_context_info); 100 PIGLIT_CL_DEFINE_ENUM_PROTOTYPE_2(cl_platform_info); 101 PIGLIT_CL_DEFINE_ENUM_PROTOTYPE_2(cl_device_info); 102 PIGLIT_CL_DEFINE_ENUM_PROTOTYPE_2(cl_command_queue_properties); 103 104 PIGLIT_CL_DEFINE_ENUM_PROTOTYPE(cl_mem_flags, cl_mem_flags_mutexes); 105 PIGLIT_CL_DEFINE_ENUM_PROTOTYPE(cl_command_queue_properties, cl_command_queue_properties_mutexes); 106 107 #undef PIGLIT_CL_DEFINE_ENUM_PROTOTYPE 108 #undef PIGLIT_CL_DEFINE_ENUM_PROTOTYPE_2 109 110 #endif //PIGLIT_UTIL_CL_ENUM_H 111