1 // DerelictCL - a Derelict based dynamic binding for OpenCL 2 // written in the D programming language 3 // 4 // Copyright: MeinMein 2013-2014. 5 // License: Boost License 1.0 6 // (See accompanying file LICENSE_1_0.txt or copy at 7 // http://www.boost.org/LICENSE_1_0.txt) 8 // Authors: Gerbrand Kamphuis (meinmein.com), 9 // Marvin Meeng (meinmein.com). 10 module derelict.opencl.constants; 11 12 import derelict.opencl.types; 13 14 // cl.h 15 16 // Error Codes 17 enum 18 { 19 CL_SUCCESS = 0, 20 CL_DEVICE_NOT_FOUND = -1, 21 CL_DEVICE_NOT_AVAILABLE = -2, 22 CL_COMPILER_NOT_AVAILABLE = -3, 23 CL_MEM_OBJECT_ALLOCATION_FAILURE = -4, 24 CL_OUT_OF_RESOURCES = -5, 25 CL_OUT_OF_HOST_MEMORY = -6, 26 CL_PROFILING_INFO_NOT_AVAILABLE = -7, 27 CL_MEM_COPY_OVERLAP = -8, 28 CL_IMAGE_FORMAT_MISMATCH = -9, 29 CL_IMAGE_FORMAT_NOT_SUPPORTED = -10, 30 CL_BUILD_PROGRAM_FAILURE = -11, 31 CL_MAP_FAILURE = -12, 32 CL_MISALIGNED_SUB_BUFFER_OFFSET = -13, 33 CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST= -14, 34 CL_COMPILE_PROGRAM_FAILURE = -15, 35 CL_LINKER_NOT_AVAILABLE = -16, 36 CL_LINK_PROGRAM_FAILURE = -17, 37 CL_DEVICE_PARTITION_FAILED = -18, 38 CL_KERNEL_ARG_INFO_NOT_AVAILABLE = -19, 39 40 CL_INVALID_VALUE = -30, 41 CL_INVALID_DEVICE_TYPE = -31, 42 CL_INVALID_PLATFORM = -32, 43 CL_INVALID_DEVICE = -33, 44 CL_INVALID_CONTEXT = -34, 45 CL_INVALID_QUEUE_PROPERTIES = -35, 46 CL_INVALID_COMMAND_QUEUE = -36, 47 CL_INVALID_HOST_PTR = -37, 48 CL_INVALID_MEM_OBJECT = -38, 49 CL_INVALID_IMAGE_FORMAT_DESCRIPTOR = -39, 50 CL_INVALID_IMAGE_SIZE = -40, 51 CL_INVALID_SAMPLER = -41, 52 CL_INVALID_BINARY = -42, 53 CL_INVALID_BUILD_OPTIONS = -43, 54 CL_INVALID_PROGRAM = -44, 55 CL_INVALID_PROGRAM_EXECUTABLE = -45, 56 CL_INVALID_KERNEL_NAME = -46, 57 CL_INVALID_KERNEL_DEFINITION = -47, 58 CL_INVALID_KERNEL = -48, 59 CL_INVALID_ARG_INDEX = -49, 60 CL_INVALID_ARG_VALUE = -50, 61 CL_INVALID_ARG_SIZE = -51, 62 CL_INVALID_KERNEL_ARGS = -52, 63 CL_INVALID_WORK_DIMENSION = -53, 64 CL_INVALID_WORK_GROUP_SIZE = -54, 65 CL_INVALID_WORK_ITEM_SIZE = -55, 66 CL_INVALID_GLOBAL_OFFSET = -56, 67 CL_INVALID_EVENT_WAIT_LIST = -57, 68 CL_INVALID_EVENT = -58, 69 CL_INVALID_OPERATION = -59, 70 CL_INVALID_GL_OBJECT = -60, 71 CL_INVALID_BUFFER_SIZE = -61, 72 CL_INVALID_MIP_LEVEL = -62, 73 CL_INVALID_GLOBAL_WORK_SIZE = -63, 74 CL_INVALID_PROPERTY = -64, 75 CL_INVALID_IMAGE_DESCRIPTOR = -65, 76 CL_INVALID_COMPILER_OPTIONS = -66, 77 CL_INVALID_LINKER_OPTIONS = -67, 78 CL_INVALID_DEVICE_PARTITION_COUNT = -68, 79 CL_INVALID_PIPE_SIZE = -69, 80 CL_INVALID_DEVICE_QUEUE = -70, 81 CL_INVALID_SPEC_ID = -71, 82 CL_MAX_SIZE_RESTRICTION_EXCEEDED = -72, 83 } 84 85 // cl_bool 86 enum 87 { 88 CL_FALSE = 0, 89 CL_TRUE = 1, 90 CL_BLOCKING = CL_TRUE, 91 CL_NON_BLOCKING = CL_FALSE 92 } 93 94 // cl_platform_info 95 enum 96 { 97 CL_PLATFORM_PROFILE = 0x0900, 98 CL_PLATFORM_VERSION = 0x0901, 99 CL_PLATFORM_NAME = 0x0902, 100 CL_PLATFORM_VENDOR = 0x0903, 101 CL_PLATFORM_EXTENSIONS = 0x0904, 102 } 103 104 // cl_device_type - bitfield 105 enum : cl_bitfield 106 { 107 CL_DEVICE_TYPE_DEFAULT = (1 << 0), 108 CL_DEVICE_TYPE_CPU = (1 << 1), 109 CL_DEVICE_TYPE_GPU = (1 << 2), 110 CL_DEVICE_TYPE_ACCELERATOR = (1 << 3), 111 CL_DEVICE_TYPE_CUSTOM = (1 << 4), 112 CL_DEVICE_TYPE_ALL = 0xFFFFFFFF, 113 } 114 115 // cl_device_info 116 enum 117 { 118 CL_DEVICE_TYPE = 0x1000, 119 CL_DEVICE_VENDOR_ID = 0x1001, 120 CL_DEVICE_MAX_COMPUTE_UNITS = 0x1002, 121 CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS = 0x1003, 122 CL_DEVICE_MAX_WORK_GROUP_SIZE = 0x1004, 123 CL_DEVICE_MAX_WORK_ITEM_SIZES = 0x1005, 124 CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR = 0x1006, 125 CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT = 0x1007, 126 CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT = 0x1008, 127 CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG = 0x1009, 128 CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT = 0x100A, 129 CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE = 0x100B, 130 CL_DEVICE_MAX_CLOCK_FREQUENCY = 0x100C, 131 CL_DEVICE_ADDRESS_BITS = 0x100D, 132 CL_DEVICE_MAX_READ_IMAGE_ARGS = 0x100E, 133 CL_DEVICE_MAX_WRITE_IMAGE_ARGS = 0x100F, 134 CL_DEVICE_MAX_MEM_ALLOC_SIZE = 0x1010, 135 CL_DEVICE_IMAGE2D_MAX_WIDTH = 0x1011, 136 CL_DEVICE_IMAGE2D_MAX_HEIGHT = 0x1012, 137 CL_DEVICE_IMAGE3D_MAX_WIDTH = 0x1013, 138 CL_DEVICE_IMAGE3D_MAX_HEIGHT = 0x1014, 139 CL_DEVICE_IMAGE3D_MAX_DEPTH = 0x1015, 140 CL_DEVICE_IMAGE_SUPPORT = 0x1016, 141 CL_DEVICE_MAX_PARAMETER_SIZE = 0x1017, 142 CL_DEVICE_MAX_SAMPLERS = 0x1018, 143 CL_DEVICE_MEM_BASE_ADDR_ALIGN = 0x1019, 144 CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE = 0x101A, // Deprecated in OpenCl 1.2 145 CL_DEVICE_SINGLE_FP_CONFIG = 0x101B, 146 CL_DEVICE_GLOBAL_MEM_CACHE_TYPE = 0x101C, 147 CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE = 0x101D, 148 CL_DEVICE_GLOBAL_MEM_CACHE_SIZE = 0x101E, 149 CL_DEVICE_GLOBAL_MEM_SIZE = 0x101F, 150 CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE = 0x1020, 151 CL_DEVICE_MAX_CONSTANT_ARGS = 0x1021, 152 CL_DEVICE_LOCAL_MEM_TYPE = 0x1022, 153 CL_DEVICE_LOCAL_MEM_SIZE = 0x1023, 154 CL_DEVICE_ERROR_CORRECTION_SUPPORT = 0x1024, 155 CL_DEVICE_PROFILING_TIMER_RESOLUTION = 0x1025, 156 CL_DEVICE_ENDIAN_LITTLE = 0x1026, 157 CL_DEVICE_AVAILABLE = 0x1027, 158 CL_DEVICE_COMPILER_AVAILABLE = 0x1028, 159 CL_DEVICE_EXECUTION_CAPABILITIES = 0x1029, 160 CL_DEVICE_QUEUE_PROPERTIES = 0x102A, 161 CL_DEVICE_NAME = 0x102B, 162 CL_DEVICE_VENDOR = 0x102C, 163 CL_DRIVER_VERSION = 0x102D, 164 CL_DEVICE_PROFILE = 0x102E, 165 CL_DEVICE_VERSION = 0x102F, 166 CL_DEVICE_EXTENSIONS = 0x1030, 167 CL_DEVICE_PLATFORM = 0x1031, 168 CL_DEVICE_DOUBLE_FP_CONFIG = 0x1032, 169 // 0x1033 reserved for CL_DEVICE_HALF_FP_CONFIG 170 CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF = 0x1034, 171 CL_DEVICE_HOST_UNIFIED_MEMORY = 0x1035, 172 CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR = 0x1036, 173 CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT = 0x1037, 174 CL_DEVICE_NATIVE_VECTOR_WIDTH_INT = 0x1038, 175 CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG = 0x1039, 176 CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT = 0x103A, 177 CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE = 0x103B, 178 CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF = 0x103C, 179 CL_DEVICE_OPENCL_C_VERSION = 0x103D, 180 CL_DEVICE_LINKER_AVAILABLE = 0x103E, 181 CL_DEVICE_BUILT_IN_KERNELS = 0x103F, 182 CL_DEVICE_IMAGE_MAX_BUFFER_SIZE = 0x1040, 183 CL_DEVICE_IMAGE_MAX_ARRAY_SIZE = 0x1041, 184 CL_DEVICE_PARENT_DEVICE = 0x1042, 185 CL_DEVICE_PARTITION_MAX_SUB_DEVICES = 0x1043, 186 CL_DEVICE_PARTITION_PROPERTIES = 0x1044, 187 CL_DEVICE_PARTITION_AFFINITY_DOMAIN = 0x1045, 188 CL_DEVICE_PARTITION_TYPE = 0x1046, 189 CL_DEVICE_REFERENCE_COUNT = 0x1047, 190 CL_DEVICE_PREFERRED_INTEROP_USER_SYNC = 0x1048, 191 CL_DEVICE_PRINTF_BUFFER_SIZE = 0x1049, 192 CL_DEVICE_IMAGE_PITCH_ALIGNMENT = 0x104A, 193 CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT = 0x104B, 194 CL_DEVICE_MAX_READ_WRITE_IMAGE_ARGS = 0x104C, 195 CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE = 0x104D, 196 CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES = 0x104E, 197 CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE = 0x104F, 198 CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE = 0x1050, 199 CL_DEVICE_MAX_ON_DEVICE_QUEUES = 0x1051, 200 CL_DEVICE_MAX_ON_DEVICE_EVENTS = 0x1052, 201 CL_DEVICE_SVM_CAPABILITIES = 0x1053, 202 CL_DEVICE_GLOBAL_VARIABLE_PREFERRED_TOTAL_SIZE = 0x1054, 203 CL_DEVICE_MAX_PIPE_ARGS = 0x1055, 204 CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS = 0x1056, 205 CL_DEVICE_PIPE_MAX_PACKET_SIZE = 0x1057, 206 CL_DEVICE_PREFERRED_PLATFORM_ATOMIC_ALIGNMENT = 0x1058, 207 CL_DEVICE_PREFERRED_GLOBAL_ATOMIC_ALIGNMENT = 0x1059, 208 CL_DEVICE_PREFERRED_LOCAL_ATOMIC_ALIGNMENT = 0x105A, 209 } 210 211 // cl_device_fp_config 212 enum : cl_bitfield 213 { 214 CL_FP_DENORM = (1 << 0), 215 CL_FP_INF_NAN = (1 << 1), 216 CL_FP_ROUND_TO_NEAREST = (1 << 2), 217 CL_FP_ROUND_TO_ZERO = (1 << 3), 218 CL_FP_ROUND_TO_INF = (1 << 4), 219 CL_FP_FMA = (1 << 5), 220 CL_FP_SOFT_FLOAT = (1 << 6), 221 CL_FP_CORRECTLY_ROUNDED_DIVIDE_SQRT = (1 << 7), 222 } 223 224 // cl_device_mem_cache_type 225 enum 226 { 227 CL_NONE = 0x0, 228 CL_READ_ONLY_CACHE = 0x1, 229 CL_READ_WRITE_CACHE = 0x2, 230 } 231 232 // cl_device_local_mem_type 233 enum 234 { 235 CL_LOCAL = 0x1, 236 CL_GLOBAL = 0x2, 237 } 238 239 // cl_device_exec_capabilities 240 enum : cl_bitfield 241 { 242 CL_EXEC_KERNEL = (1 << 0), 243 CL_EXEC_NATIVE_KERNEL = (1 << 1), 244 } 245 246 // cl_command_queue_properties 247 enum : cl_bitfield 248 { 249 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE = (1 << 0), 250 CL_QUEUE_PROFILING_ENABLE = (1 << 1), 251 CL_QUEUE_ON_DEVICE = (1 << 2), 252 CL_QUEUE_ON_DEVICE_DEFAULT = (1 << 3), 253 } 254 255 // cl_context_info 256 enum 257 { 258 CL_CONTEXT_REFERENCE_COUNT = 0x1080, 259 CL_CONTEXT_DEVICES = 0x1081, 260 CL_CONTEXT_PROPERTIES = 0x1082, 261 CL_CONTEXT_NUM_DEVICES = 0x1083, 262 } 263 264 // cl_context_properties 265 enum 266 { 267 CL_CONTEXT_PLATFORM = 0x1084, 268 CL_CONTEXT_INTEROP_USER_SYNC = 0x1085, 269 } 270 271 // cl_device_partition_property 272 enum : ptrdiff_t 273 { 274 CL_DEVICE_PARTITION_EQUALLY = 0x1086, 275 CL_DEVICE_PARTITION_BY_COUNTS = 0x1087, 276 CL_DEVICE_PARTITION_BY_COUNTS_LIST_END = 0x0, 277 CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN = 0x1088, 278 } 279 280 // cl_device_affinity_domain 281 enum : cl_bitfield 282 { 283 CL_DEVICE_AFFINITY_DOMAIN_NUMA = (1 << 0), 284 CL_DEVICE_AFFINITY_DOMAIN_L4_CACHE = (1 << 1), 285 CL_DEVICE_AFFINITY_DOMAIN_L3_CACHE = (1 << 2), 286 CL_DEVICE_AFFINITY_DOMAIN_L2_CACHE = (1 << 3), 287 CL_DEVICE_AFFINITY_DOMAIN_L1_CACHE = (1 << 4), 288 CL_DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE = (1 << 5), 289 } 290 291 // cl_device_svm_capabilities 292 enum 293 { 294 CL_DEVICE_SVM_COARSE_GRAIN_BUFFER = (1 << 0), 295 CL_DEVICE_SVM_FINE_GRAIN_BUFFER = (1 << 1), 296 CL_DEVICE_SVM_FINE_GRAIN_SYSTEM = (1 << 2), 297 CL_DEVICE_SVM_ATOMICS = (1 << 3), 298 } 299 // cl_command_queue_info 300 enum 301 { 302 CL_QUEUE_CONTEXT = 0x1090, 303 CL_QUEUE_DEVICE = 0x1091, 304 CL_QUEUE_REFERENCE_COUNT = 0x1092, 305 CL_QUEUE_PROPERTIES = 0x1093, 306 CL_QUEUE_SIZE = 0x1094, 307 } 308 309 // cl_mem_flags and cl_svm_mem_flags - bitfield 310 enum : cl_bitfield 311 { 312 CL_MEM_READ_WRITE = (1 << 0), 313 CL_MEM_WRITE_ONLY = (1 << 1), 314 CL_MEM_READ_ONLY = (1 << 2), 315 CL_MEM_USE_HOST_PTR = (1 << 3), 316 CL_MEM_ALLOC_HOST_PTR = (1 << 4), 317 CL_MEM_COPY_HOST_PTR = (1 << 5), 318 // reserved = (1 << 6), 319 CL_MEM_HOST_WRITE_ONLY = (1 << 7), 320 CL_MEM_HOST_READ_ONLY = (1 << 8), 321 CL_MEM_HOST_NO_ACCESS = (1 << 9), 322 CL_MEM_SVM_FINE_GRAIN_BUFFER = (1 << 10), // cl_svm_mem_flags only 323 CL_MEM_SVM_ATOMICS = (1 << 11), // cl_svm_mem_flags only 324 CL_MEM_KERNEL_READ_AND_WRITE = (1 << 12), 325 } 326 327 // cl_mem_migration_flags 328 enum : cl_bitfield 329 { 330 CL_MIGRATE_MEM_OBJECT_HOST = (1 << 0), 331 CL_MIGRATE_MEM_OBJECT_CONTENT_UNDEFINED = (1 << 1), 332 } 333 334 // cl_channel_order 335 enum 336 { 337 CL_R = 0x10B0, 338 CL_A = 0x10B1, 339 CL_RG = 0x10B2, 340 CL_RA = 0x10B3, 341 CL_RGB = 0x10B4, 342 CL_RGBA = 0x10B5, 343 CL_BGRA = 0x10B6, 344 CL_ARGB = 0x10B7, 345 CL_INTENSITY = 0x10B8, 346 CL_LUMINANCE = 0x10B9, 347 CL_Rx = 0x10BA, 348 CL_RGx = 0x10BB, 349 CL_RGBx = 0x10BC, 350 CL_DEPTH = 0x10BD, 351 CL_DEPTH_STENCIL = 0x10BE, 352 CL_sRGB = 0x10BF, 353 CL_sRGBx = 0x10C0, 354 CL_sRGBA = 0x10C1, 355 CL_sBRGA = 0x10C2, 356 CL_ABGR = 0x10C3, 357 } 358 359 // cl_channel_type 360 enum 361 { 362 CL_SNORM_INT8 = 0x10D0, 363 CL_SNORM_INT16 = 0x10D1, 364 CL_UNORM_INT8 = 0x10D2, 365 CL_UNORM_INT16 = 0x10D3, 366 CL_UNORM_SHORT_565 = 0x10D4, 367 CL_UNORM_SHORT_555 = 0x10D5, 368 CL_UNORM_INT_101010 = 0x10D6, 369 CL_SIGNED_INT8 = 0x10D7, 370 CL_SIGNED_INT16 = 0x10D8, 371 CL_SIGNED_INT32 = 0x10D9, 372 CL_UNSIGNED_INT8 = 0x10DA, 373 CL_UNSIGNED_INT16 = 0x10DB, 374 CL_UNSIGNED_INT32 = 0x10DC, 375 CL_HALF_FLOAT = 0x10DD, 376 CL_FLOAT = 0x10DE, 377 CL_UNORM_INT24 = 0x10DF, 378 } 379 380 // cl_mem_object_type 381 enum 382 { 383 CL_MEM_OBJECT_BUFFER = 0x10F0, 384 CL_MEM_OBJECT_IMAGE2D = 0x10F1, 385 CL_MEM_OBJECT_IMAGE3D = 0x10F2, 386 CL_MEM_OBJECT_IMAGE2D_ARRAY = 0x10F3, 387 CL_MEM_OBJECT_IMAGE1D = 0x10F4, 388 CL_MEM_OBJECT_IMAGE1D_ARRAY = 0x10F5, 389 CL_MEM_OBJECT_IMAGE1D_BUFFER = 0x10F6, 390 CL_MEM_OBJECT_PIPE = 0x10F7, 391 } 392 393 // cl_mem_info 394 enum 395 { 396 CL_MEM_TYPE = 0x1100, 397 CL_MEM_FLAGS = 0x1101, 398 CL_MEM_SIZE = 0x1102, 399 CL_MEM_HOST_PTR = 0x1103, 400 CL_MEM_MAP_COUNT = 0x1104, 401 CL_MEM_REFERENCE_COUNT = 0x1105, 402 CL_MEM_CONTEXT = 0x1106, 403 CL_MEM_ASSOCIATED_MEMOBJECT = 0x1107, 404 CL_MEM_OFFSET = 0x1108, 405 CL_MEM_USES_SVM_POINTER = 0x1109, 406 } 407 408 // cl_image_info 409 enum 410 { 411 CL_IMAGE_FORMAT = 0x1110, 412 CL_IMAGE_ELEMENT_SIZE = 0x1111, 413 CL_IMAGE_ROW_PITCH = 0x1112, 414 CL_IMAGE_SLICE_PITCH = 0x1113, 415 CL_IMAGE_WIDTH = 0x1114, 416 CL_IMAGE_HEIGHT = 0x1115, 417 CL_IMAGE_DEPTH = 0x1116, 418 CL_IMAGE_ARRAY_SIZE = 0x1117, 419 CL_IMAGE_BUFFER = 0x1118, 420 CL_IMAGE_NUM_MIP_LEVELS = 0x1119, 421 CL_IMAGE_NUM_SAMPLES = 0x111A, 422 } 423 424 // cl_pipe_info 425 enum 426 { 427 CL_PIPE_PACKET_SIZE = 0x1120, 428 CL_PIPE_MAX_PACKETS = 0x1121, 429 } 430 431 // cl_addressing_mode 432 enum 433 { 434 CL_ADDRESS_NONE = 0x1130, 435 CL_ADDRESS_CLAMP_TO_EDGE = 0x1131, 436 CL_ADDRESS_CLAMP = 0x1132, 437 CL_ADDRESS_REPEAT = 0x1133, 438 CL_ADDRESS_MIRRORED_REPEAT = 0x1134, 439 } 440 441 // cl_filter_mode 442 enum 443 { 444 CL_FILTER_NEAREST = 0x1140, 445 CL_FILTER_LINEAR = 0x1141, 446 } 447 448 // cl_sampler_info 449 enum 450 { 451 CL_SAMPLER_REFERENCE_COUNT = 0x1150, 452 CL_SAMPLER_CONTEXT = 0x1151, 453 CL_SAMPLER_NORMALIZED_COORDS = 0x1152, 454 CL_SAMPLER_ADDRESSING_MODE = 0x1153, 455 CL_SAMPLER_FILTER_MODE = 0x1154, 456 CL_SAMPLER_MIP_FILTER_MODE = 0x1155, 457 CL_SAMPLER_LOD_MIN = 0x1156, 458 CL_SAMPLER_LOD_MAX = 0x1157, 459 } 460 461 // cl_map_flags - bitfield 462 enum : cl_bitfield 463 { 464 CL_MAP_READ = (1 << 0), 465 CL_MAP_WRITE = (1 << 1), 466 CL_MAP_WRITE_INVALIDATE_REGION = (1 << 2), 467 } 468 469 // cl_program_info 470 enum 471 { 472 CL_PROGRAM_REFERENCE_COUNT = 0x1160, 473 CL_PROGRAM_CONTEXT = 0x1161, 474 CL_PROGRAM_NUM_DEVICES = 0x1162, 475 CL_PROGRAM_DEVICES = 0x1163, 476 CL_PROGRAM_SOURCE = 0x1164, 477 CL_PROGRAM_BINARY_SIZES = 0x1165, 478 CL_PROGRAM_BINARIES = 0x1166, 479 CL_PROGRAM_NUM_KERNELS = 0x1167, 480 CL_PROGRAM_KERNEL_NAMES = 0x1168, 481 CL_PROGRAM_IL = 0x1169, 482 CL_PROGRAM_SCOPE_GLOBAL_CTORS_PRESENT = 0x116A, 483 CL_PROGRAM_SCOPE_GLOBAL_DTORS_PRESENT = 0x116B, 484 } 485 486 // cl_program_build_info 487 enum 488 { 489 CL_PROGRAM_BUILD_STATUS = 0x1181, 490 CL_PROGRAM_BUILD_OPTIONS = 0x1182, 491 CL_PROGRAM_BUILD_LOG = 0x1183, 492 CL_PROGRAM_BINARY_TYPE = 0x1184, 493 CL_PROGRAM_BUILD_GLOBAL_VARIABLE_TOTAL_SIZE = 0x1185, 494 } 495 496 // cl_program_binary_type 497 enum 498 { 499 CL_PROGRAM_BINARY_TYPE_NONE = 0x0, 500 CL_PROGRAM_BINARY_TYPE_COMPILED_OBJECT = 0x1, 501 CL_PROGRAM_BINARY_TYPE_LIBRARY = 0x2, 502 CL_PROGRAM_BINARY_TYPE_EXECUTABLE = 0x4, 503 } 504 505 // cl_build_status 506 enum 507 { 508 CL_BUILD_SUCCESS = 0, 509 CL_BUILD_NONE = -1, 510 CL_BUILD_ERROR = -2, 511 CL_BUILD_IN_PROGRESS = -3, 512 } 513 514 // cl_kernel_info 515 enum 516 { 517 CL_KERNEL_FUNCTION_NAME = 0x1190, 518 CL_KERNEL_NUM_ARGS = 0x1191, 519 CL_KERNEL_REFERENCE_COUNT = 0x1192, 520 CL_KERNEL_CONTEXT = 0x1193, 521 CL_KERNEL_PROGRAM = 0x1194, 522 CL_KERNEL_ATTRIBUTES = 0x1195, 523 } 524 525 // cl_kernel_arg_info 526 enum 527 { 528 CL_KERNEL_ARG_ADDRESS_QUALIFIER = 0x1196, 529 CL_KERNEL_ARG_ACCESS_QUALIFIER = 0x1197, 530 CL_KERNEL_ARG_TYPE_NAME = 0x1198, 531 CL_KERNEL_ARG_TYPE_QUALIFIER = 0x1199, 532 CL_KERNEL_ARG_NAME = 0x119A, 533 } 534 535 // cl_kernel_arg_address_qualifier 536 enum 537 { 538 CL_KERNEL_ARG_ADDRESS_GLOBAL = 0x119B, 539 CL_KERNEL_ARG_ADDRESS_LOCAL = 0x119C, 540 CL_KERNEL_ARG_ADDRESS_CONSTANT = 0x119D, 541 CL_KERNEL_ARG_ADDRESS_PRIVATE = 0x119E, 542 } 543 544 // cl_kernel_arg_access_qualifier 545 enum 546 { 547 CL_KERNEL_ARG_ACCESS_READ_ONLY = 0x11A0, 548 CL_KERNEL_ARG_ACCESS_WRITE_ONLY = 0x11A1, 549 CL_KERNEL_ARG_ACCESS_READ_WRITE = 0x11A2, 550 CL_KERNEL_ARG_ACCESS_NONE = 0x11A3, 551 } 552 553 // cl_kernel_arg_type_qualifer 554 enum : cl_bitfield 555 { 556 CL_KERNEL_ARG_TYPE_NONE = 0, 557 CL_KERNEL_ARG_TYPE_CONST = (1 << 0), 558 CL_KERNEL_ARG_TYPE_RESTRICT = (1 << 1), 559 CL_KERNEL_ARG_TYPE_VOLATILE = (1 << 2), 560 CL_KERNEL_ARG_TYPE_PIPE = (1 << 3), 561 } 562 563 // cl_kernel_work_group_info 564 enum 565 { 566 CL_KERNEL_WORK_GROUP_SIZE = 0x11B0, 567 CL_KERNEL_COMPILE_WORK_GROUP_SIZE = 0x11B1, 568 CL_KERNEL_LOCAL_MEM_SIZE = 0x11B2, 569 CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE= 0x11B3, 570 CL_KERNEL_PRIVATE_MEM_SIZE = 0x11B4, 571 CL_KERNEL_GLOBAL_WORK_SIZE = 0x11B5, 572 } 573 574 // cl_kernel_exec_info 575 enum 576 { 577 CL_KERNEL_EXEC_INFO_SVM_PTRS = 0x11B6, 578 CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM = 0x11B7, 579 } 580 581 // cl_event_info 582 enum 583 { 584 CL_EVENT_COMMAND_QUEUE = 0x11D0, 585 CL_EVENT_COMMAND_TYPE = 0x11D1, 586 CL_EVENT_REFERENCE_COUNT = 0x11D2, 587 CL_EVENT_COMMAND_EXECUTION_STATUS = 0x11D3, 588 CL_EVENT_CONTEXT = 0x11D4, 589 } 590 591 // cl_command_type 592 enum 593 { 594 CL_COMMAND_NDRANGE_KERNEL = 0x11F0, 595 CL_COMMAND_TASK = 0x11F1, 596 CL_COMMAND_NATIVE_KERNEL = 0x11F2, 597 CL_COMMAND_READ_BUFFER = 0x11F3, 598 CL_COMMAND_WRITE_BUFFER = 0x11F4, 599 CL_COMMAND_COPY_BUFFER = 0x11F5, 600 CL_COMMAND_READ_IMAGE = 0x11F6, 601 CL_COMMAND_WRITE_IMAGE = 0x11F7, 602 CL_COMMAND_COPY_IMAGE = 0x11F8, 603 CL_COMMAND_COPY_IMAGE_TO_BUFFER = 0x11F9, 604 CL_COMMAND_COPY_BUFFER_TO_IMAGE = 0x11FA, 605 CL_COMMAND_MAP_BUFFER = 0x11FB, 606 CL_COMMAND_MAP_IMAGE = 0x11FC, 607 CL_COMMAND_UNMAP_MEM_OBJECT = 0x11FD, 608 CL_COMMAND_MARKER = 0x11FE, 609 CL_COMMAND_ACQUIRE_GL_OBJECTS = 0x11FF, 610 CL_COMMAND_RELEASE_GL_OBJECTS = 0x1200, 611 CL_COMMAND_READ_BUFFER_RECT = 0x1201, 612 CL_COMMAND_WRITE_BUFFER_RECT = 0x1202, 613 CL_COMMAND_COPY_BUFFER_RECT = 0x1203, 614 CL_COMMAND_USER = 0x1204, 615 CL_COMMAND_BARRIER = 0x1205, 616 CL_COMMAND_MIGRATE_MEM_OBJECTS = 0x1206, 617 CL_COMMAND_FILL_BUFFER = 0x1207, 618 CL_COMMAND_FILL_IMAGE = 0x1208, 619 CL_COMMAND_SVM_FREE = 0x1209, 620 CL_COMMAND_SVM_MEMCPY = 0x120A, 621 CL_COMMAND_SVM_MEMFILL = 0x120B, 622 CL_COMMAND_SVM_MAP = 0x120C, 623 CL_COMMAND_SVM_UNMAP = 0x120D, 624 } 625 626 // cl_command_execution_status 627 enum 628 { 629 CL_COMPLETE = 0x0, 630 CL_RUNNING = 0x1, 631 CL_SUBMITTED = 0x2, 632 CL_QUEUED = 0x3, 633 } 634 635 // cl_buffer_create_type 636 enum 637 { 638 CL_BUFFER_CREATE_TYPE_REGION = 0x1220, 639 } 640 641 // cl_profiling_info 642 enum 643 { 644 CL_PROFILING_COMMAND_QUEUED = 0x1280, 645 CL_PROFILING_COMMAND_SUBMIT = 0x1281, 646 CL_PROFILING_COMMAND_START = 0x1282, 647 CL_PROFILING_COMMAND_END = 0x1283, 648 CL_PROFILING_COMMAND_COMPLETE = 0x1284, 649 } 650 651 652 // cl_ext.h 653 654 // cl_khr_fp16 extension 655 enum CL_DEVICE_HALF_FP_CONFIG = 0x1033; 656 657 // cl_APPLE_SetMemObjectDestructor extension 658 enum cl_APPLE_SetMemObjectDestructor = 1; 659 660 // cl_APPLE_ContextLoggingFunctions 661 enum cl_APPLE_ContextLoggingFunctions = 1; 662 663 // cl_khr_icd extension 664 enum cl_khr_icd = 1; 665 // cl_platform_info 666 enum CL_PLATFORM_ICD_SUFFIX_KHR = 0x0920; 667 // Additional Error Codes 668 enum CL_PLATFORM_NOT_FOUND_KHR = -1001; 669 670 // cl_khr_initalize_memory extension 671 enum CL_CONTEXT_MEMORY_INITIALIZE_KHR = 0x200E; 672 673 // cl_khr_terminate_context extension 674 enum cl_khr_terminate_context = 1; 675 enum 676 { 677 CL_DEVICE_TERMINATE_CAPABILITY_KHR = 0x200F, 678 CL_CONTEXT_TERMINATE_KHR = 0x2010, 679 } 680 681 // cl_nv_device_attribute_query extension 682 enum 683 { 684 CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV = 0x4000, 685 CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV = 0x4001, 686 CL_DEVICE_REGISTERS_PER_BLOCK_NV = 0x4002, 687 CL_DEVICE_WARP_SIZE_NV = 0x4003, 688 CL_DEVICE_GPU_OVERLAP_NV = 0x4004, 689 CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV = 0x4005, 690 CL_DEVICE_INTEGRATED_MEMORY_NV = 0x4006, 691 } 692 693 // cl_amd_device_attribute_query extension 694 enum CL_DEVICE_PROFILING_TIMER_OFFSET_AMD = 0x4036; 695 696 // cl_ext_device_fission extension 697 enum cl_ext_device_fission = 1; 698 699 // cl_device_partition_property_ext extension 700 enum 701 { 702 CL_DEVICE_PARTITION_EQUALLY_EXT = 0x4050, 703 CL_DEVICE_PARTITION_BY_COUNTS_EXT = 0x4051, 704 CL_DEVICE_PARTITION_BY_NAMES_EXT = 0x4052, 705 CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN_EXT = 0x4053, 706 } 707 708 // clDeviceGetInfo selectors 709 enum 710 { 711 CL_DEVICE_PARENT_DEVICE_EXT = 0x4054, 712 CL_DEVICE_PARTITION_TYPES_EXT = 0x4055, 713 CL_DEVICE_AFFINITY_DOMAINS_EXT = 0x4056, 714 CL_DEVICE_REFERENCE_COUNT_EXT = 0x4057, 715 CL_DEVICE_PARTITION_STYLE_EXT = 0x4058, 716 } 717 718 // error codes 719 enum 720 { 721 CL_DEVICE_PARTITION_FAILED_EXT = -1057, 722 CL_INVALID_PARTITION_COUNT_EXT = -1058, 723 CL_INVALID_PARTITION_NAME_EXT = -1059, 724 } 725 726 // CL_AFFINITY_DOMAINs 727 enum 728 { 729 CL_AFFINITY_DOMAIN_L1_CACHE_EXT = 0x1, 730 CL_AFFINITY_DOMAIN_L2_CACHE_EXT = 0x2, 731 CL_AFFINITY_DOMAIN_L3_CACHE_EXT = 0x3, 732 CL_AFFINITY_DOMAIN_L4_CACHE_EXT = 0x4, 733 CL_AFFINITY_DOMAIN_NUMA_EXT = 0x10, 734 CL_AFFINITY_DOMAIN_NEXT_FISSIONABLE_EXT = 0x100, 735 } 736 737 // cl_device_partition_property_ext list terminators 738 enum 739 { 740 CL_PROPERTIES_LIST_END_EXT = (cast(cl_device_partition_property_ext) 0), 741 CL_PARTITION_BY_COUNTS_LIST_END_EXT = (cast(cl_device_partition_property_ext) 0), 742 CL_PARTITION_BY_NAMES_LIST_END_EXT = (cast(cl_device_partition_property_ext) 0 - 1), 743 } 744 745 746 // cl_egl.h 747 748 // Command type for events created with clEnqueueAcquireEGLObjectsKHR 749 enum 750 { 751 CL_COMMAND_EGL_FENCE_SYNC_OBJECT_KHR = 0x202F, 752 CL_COMMAND_ACQUIRE_EGL_OBJECTS_KHR = 0x202D, 753 CL_COMMAND_RELEASE_EGL_OBJECTS_KHR = 0x202E, 754 } 755 756 // Error type for clCreateFromEGLImageKHR 757 enum 758 { 759 CL_INVALID_EGL_OBJECT_KHR = -1093, 760 CL_EGL_RESOURCE_NOT_ACQUIRED_KHR = -1092, 761 } 762 763 // cl_khr_egl_image extension 764 enum cl_khr_egl_image = 1; 765 766 // cl_khr_egl_event extension 767 enum cl_khr_egl_event = 1; 768 769 770 // cl_gl.h 771 772 // cl_gl_object_type 773 enum 774 { 775 CL_GL_OBJECT_BUFFER = 0x2000, 776 CL_GL_OBJECT_TEXTURE2D = 0x2001, 777 CL_GL_OBJECT_TEXTURE3D = 0x2002, 778 CL_GL_OBJECT_RENDERBUFFER = 0x2003, 779 CL_GL_OBJECT_TEXTURE2D_ARRAY = 0x200E, 780 CL_GL_OBJECT_TEXTURE1D = 0x200F, 781 CL_GL_OBJECT_TEXTURE1D_ARRAY = 0x2010, 782 CL_GL_OBJECT_TEXTURE_BUFFER = 0x2011, 783 } 784 785 // cl_gl_texture_info 786 enum 787 { 788 CL_GL_TEXTURE_TARGET = 0x2004, 789 CL_GL_MIPMAP_LEVEL = 0x2005, 790 CL_GL_NUM_SAMPLES = 0x2012, 791 } 792 793 // Additional Error Codes 794 enum CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR = -1000; 795 796 // cl_gl_context_info 797 enum 798 { 799 CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR = 0x2006, 800 CL_DEVICES_FOR_GL_CONTEXT_KHR = 0x2007, 801 } 802 803 // Additional cl_context_properties 804 enum 805 { 806 CL_GL_CONTEXT_KHR = 0x2008, 807 CL_EGL_DISPLAY_KHR = 0x2009, 808 CL_GLX_DISPLAY_KHR = 0x200A, 809 CL_WGL_HDC_KHR = 0x200B, 810 CL_CGL_SHAREGROUP_KHR = 0x200C, 811 } 812 813 // cl_khr_gl_sharing extension 814 enum cl_khr_gl_sharing = 1; 815 816 817 // cl_gl_ext.h 818 819 // cl_khr_gl_event extension 820 enum CL_COMMAND_GL_FENCE_SYNC_OBJECT_KHR = 0x200D; 821 822 823 // cl_d3d10.h 824 825 // cl_khr_d3d10_sharing extension 826 enum cl_khr_d3d10_sharing = 1; 827 828 // Error Codes 829 enum 830 { 831 CL_INVALID_D3D10_DEVICE_KHR = -1002, 832 CL_INVALID_D3D10_RESOURCE_KHR = -1003, 833 CL_D3D10_RESOURCE_ALREADY_ACQUIRED_KHR = -1004, 834 CL_D3D10_RESOURCE_NOT_ACQUIRED_KHR = -1005, 835 } 836 837 // cl_d3d10_device_source_nv 838 enum 839 { 840 CL_D3D10_DEVICE_KHR = 0x4010, 841 CL_D3D10_DXGI_ADAPTER_KHR = 0x4011, 842 } 843 844 // cl_d3d10_device_set_nv 845 enum 846 { 847 CL_PREFERRED_DEVICES_FOR_D3D10_KHR = 0x4012, 848 CL_ALL_DEVICES_FOR_D3D10_KHR = 0x4013, 849 } 850 851 // cl_context_info 852 enum 853 { 854 CL_CONTEXT_D3D10_DEVICE_KHR = 0x4014, 855 CL_CONTEXT_D3D10_PREFER_SHARED_RESOURCES_KHR = 0x402C, 856 } 857 858 // cl_mem_info 859 enum CL_MEM_D3D10_RESOURCE_KHR = 0x4015; 860 861 // cl_image_info 862 enum CL_IMAGE_D3D10_SUBRESOURCE_KHR = 0x4016; 863 864 // cl_command_type 865 enum CL_COMMAND_ACQUIRE_D3D10_OBJECTS_KHR = 0x4017; 866 enum CL_COMMAND_RELEASE_D3D10_OBJECTS_KHR = 0x4018; 867 868 869 // cl_d3d11.h 870 871 // cl_khr_d3d11_sharing extension 872 enum cl_khr_d3d11_sharing = 1; 873 874 // Error Codes 875 enum 876 { 877 CL_INVALID_D3D11_DEVICE_KHR = -1006, 878 CL_INVALID_D3D11_RESOURCE_KHR = -1007, 879 CL_D3D11_RESOURCE_ALREADY_ACQUIRED_KHR = -1008, 880 CL_D3D11_RESOURCE_NOT_ACQUIRED_KHR = -1009, 881 } 882 883 // cl_d3d11_device_source 884 enum 885 { 886 CL_D3D11_DEVICE_KHR = 0x4019, 887 CL_D3D11_DXGI_ADAPTER_KHR = 0x401A, 888 } 889 890 // cl_d3d11_device_set 891 enum 892 { 893 CL_PREFERRED_DEVICES_FOR_D3D11_KHR = 0x401B, 894 CL_ALL_DEVICES_FOR_D3D11_KHR = 0x401C, 895 } 896 897 // cl_context_info 898 enum 899 { 900 CL_CONTEXT_D3D11_DEVICE_KHR = 0x401D, 901 CL_CONTEXT_D3D11_PREFER_SHARED_RESOURCES_KHR = 0x402D, 902 } 903 904 // cl_mem_info 905 enum CL_MEM_D3D11_RESOURCE_KHR = 0x401E; 906 907 // cl_image_info 908 enum CL_IMAGE_D3D11_SUBRESOURCE_KHR = 0x401F; 909 910 // cl_command_type 911 enum 912 { 913 CL_COMMAND_ACQUIRE_D3D11_OBJECTS_KHR = 0x4020, 914 CL_COMMAND_RELEASE_D3D11_OBJECTS_KHR = 0x4021, 915 } 916 917 918 // cl_dx9_media_sharing.h extension 919 920 // cl_khr_dx9_media_sharing 921 enum cl_khr_dx9_media_sharing = 1; 922 923 // Error Codes 924 enum 925 { 926 CL_INVALID_DX9_MEDIA_ADAPTER_KHR = -1010, 927 CL_INVALID_DX9_MEDIA_SURFACE_KHR = -1011, 928 CL_DX9_MEDIA_SURFACE_ALREADY_ACQUIRED_KHR = -1012, 929 CL_DX9_MEDIA_SURFACE_NOT_ACQUIRED_KHR = -1013, 930 } 931 932 // cl_media_adapter_type_khr 933 enum 934 { 935 CL_ADAPTER_D3D9_KHR = 0x2020, 936 CL_ADAPTER_D3D9EX_KHR = 0x2021, 937 CL_ADAPTER_DXVA_KHR = 0x2022, 938 } 939 940 // cl_media_adapter_set_khr 941 enum 942 { 943 CL_PREFERRED_DEVICES_FOR_DX9_MEDIA_ADAPTER_KHR = 0x2023, 944 CL_ALL_DEVICES_FOR_DX9_MEDIA_ADAPTER_KHR = 0x2024, 945 } 946 947 // cl_context_info 948 enum 949 { 950 CL_CONTEXT_ADAPTER_D3D9_KHR = 0x2025, 951 CL_CONTEXT_ADAPTER_D3D9EX_KHR = 0x2026, 952 CL_CONTEXT_ADAPTER_DXVA_KHR = 0x2027, 953 } 954 955 // cl_mem_info 956 enum 957 { 958 CL_MEM_DX9_MEDIA_ADAPTER_TYPE_KHR = 0x2028, 959 CL_MEM_DX9_MEDIA_SURFACE_INFO_KHR = 0x2029, 960 } 961 962 // cl_image_info 963 enum CL_IMAGE_DX9_MEDIA_PLANE_KHR = 0x202A; 964 965 // cl_command_type 966 enum 967 { 968 CL_COMMAND_ACQUIRE_DX9_MEDIA_SURFACES_KHR = 0x202B, 969 CL_COMMAND_RELEASE_DX9_MEDIA_SURFACES_KHR = 0x202C, 970 } 971 972 973 // cl_platform.h 974 975 /* Macro names and corresponding values defined by OpenCL */ 976 enum CL_CHAR_BIT = 8; 977 enum CL_SCHAR_MAX = 127; 978 enum CL_SCHAR_MIN = (-127-1); 979 enum CL_CHAR_MAX = CL_SCHAR_MAX; 980 enum CL_CHAR_MIN = CL_SCHAR_MIN; 981 enum CL_UCHAR_MAX = 255; 982 enum CL_SHRT_MAX = 32767; 983 enum CL_SHRT_MIN = (-32767-1); 984 enum CL_USHRT_MAX = 65535; 985 enum CL_INT_MAX = 2147483647; 986 enum CL_INT_MIN = (-2147483647-1); 987 enum CL_UINT_MAX = 0xffffffffU; 988 enum CL_LONG_MAX = (cast(cl_long) 0x7FFFFFFFFFFFFFFF); 989 enum CL_LONG_MIN = (cast(cl_long) -0x7FFFFFFFFFFFFFFF - 1); 990 enum CL_ULONG_MAX = (cast(cl_ulong) 0xFFFFFFFFFFFFFFFF); 991 992 enum CL_FLT_DIG = 6; 993 enum CL_FLT_MANT_DIG = 24; 994 enum CL_FLT_MAX_10_EXP = +38; 995 enum CL_FLT_MAX_EXP = +128; 996 enum CL_FLT_MIN_10_EXP = -37; 997 enum CL_FLT_MIN_EXP = -125; 998 enum CL_FLT_RADIX = 2; 999 1000 enum CL_FLT_MAX = float.max; 1001 enum CL_FLT_MIN = float.min_normal; 1002 enum CL_FLT_EPSILON = 0x1.0p-23f; 1003 1004 enum CL_DBL_DIG = 15; 1005 enum CL_DBL_MANT_DIG = 53; 1006 enum CL_DBL_MAX_10_EXP = +308; 1007 enum CL_DBL_MAX_EXP = +1024; 1008 enum CL_DBL_MIN_10_EXP = -307; 1009 enum CL_DBL_MIN_EXP = -1021; 1010 enum CL_DBL_RADIX = 2; 1011 1012 enum CL_DBL_MAX = double.max; 1013 enum CL_DBL_MIN = double.min_normal; 1014 enum CL_DBL_EPSILON = double.epsilon; 1015 1016 enum CL_M_E = 2.718281828459045090796; 1017 enum CL_M_LOG2E = 1.442695040888963387005; 1018 enum CL_M_LOG10E = 0.434294481903251816668; 1019 enum CL_M_LN2 = 0.693147180559945286227; 1020 enum CL_M_LN10 = 2.302585092994045901094; 1021 enum CL_M_PI = 3.141592653589793115998; 1022 enum CL_M_PI_2 = 1.570796326794896557999; 1023 enum CL_M_PI_4 = 0.785398163397448278999; 1024 enum CL_M_1_PI = 0.318309886183790691216; 1025 enum CL_M_2_PI = 0.636619772367581382433; 1026 enum CL_M_2_SQRTPI = 1.128379167095512558561; 1027 enum CL_M_SQRT2 = 1.414213562373095145475; 1028 enum CL_M_SQRT1_2 = 0.707106781186547572737; 1029 1030 enum CL_M_E_F = 2.71828174591064f; 1031 enum CL_M_LOG2E_F = 1.44269502162933f; 1032 enum CL_M_LOG10E_F = 0.43429449200630f; 1033 enum CL_M_LN2_F = 0.69314718246460f; 1034 enum CL_M_LN10_F = 2.30258512496948f; 1035 enum CL_M_PI_F = 3.14159274101257f; 1036 enum CL_M_PI_2_F = 1.57079637050629f; 1037 enum CL_M_PI_4_F = 0.78539818525314f; 1038 enum CL_M_1_PI_F = 0.31830987334251f; 1039 enum CL_M_2_PI_F = 0.63661974668503f; 1040 enum CL_M_2_SQRTPI_F = 1.12837922573090f; 1041 enum CL_M_SQRT2_F = 1.41421353816986f; 1042 enum CL_M_SQRT1_2_F = 0.70710676908493f; 1043 1044 enum CL_NAN = cl_float.nan; 1045 enum CL_HUGE_VALF = cl_float.infinity; 1046 enum CL_HUGE_VAL = cl_double.infinity; 1047 enum CL_MAXFLOAT = CL_FLT_MAX; 1048 enum CL_INFINITY = CL_HUGE_VALF; 1049 1050 1051 // generate code for the CL vector types 1052 // this might look crazy, but eases further changes 1053 // do a pragma(msg, genCLVectorTypes()); for debugging 1054 import std.conv; 1055 version(GNU) import gcc.attribute; 1056 1057 // TODO: finish compiler-specific vector types, e.g. __attribute__((vector_size(16))); for GDC 1058 // TODO: CPU instruction sets-specific alignment (MMX, SSE*, AVX) 1059 private string genCLVectorTypes() 1060 { 1061 string res; 1062 foreach(type; ["cl_char", "cl_uchar", "cl_short", "cl_ushort", "cl_int", "cl_uint", "cl_long", "cl_ulong", "cl_float", "cl_double"]) 1063 { 1064 res ~= "alias " ~ type ~ "4 " ~ type ~ "3;"; // cl_xx3 is identical in size, alignment and behavior to cl_xx4. See section 6.1.5. of the spec 1065 // now add the rest of the types 1066 foreach (size; [2,4,8,16]) 1067 { 1068 res ~= ` 1069 union ` ~ type ~ to!string(size) ~ ` 1070 { 1071 `; 1072 // add aligned attribute if inside GDC 1073 version(GNU) res ~= `@attribute("aligned", (` ~ to!string(size) ~ ` * ` ~ type ~ `.sizeof).to!string) `; 1074 res ~= type ~ "[" ~ to!string(size) ~ `] s; 1075 alias s this; // allow array access and implicit conversion to the array 1076 struct { ` ~ type ~ ` x, y` ~ (size<=2 ? "" : ", z, w") ~ (size>=16 ? ", __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf" : "") ~ `; } 1077 struct { ` ~ type ~ ` s0, s1` ~ (size<=2 ? "" : ", s2, s3") ~ (size>=8 ? ", s4, s5, s6, s7" : "") ~ (size>=16 ? ", s8, s9, sA, sB, sC, sD, sE, sF" : "") ~ `; } 1078 struct { ` ~ type ~ (size>2 ? to!string(size/2) : "") ~ ` lo, hi; }`; 1079 version(GNU) res ~= ` 1080 @attribute("vector_size", (` ~ to!string(size) ~ ` * ` ~ type ~ `.sizeof).to!string) ` ~ type ~ " v" ~ to!string(size) ~ `;`; 1081 res ~= ` 1082 } 1083 `; 1084 } 1085 } 1086 1087 return res; 1088 } 1089 1090 //pragma(msg, genCLVectorTypes()); 1091 mixin(genCLVectorTypes()); 1092 // NOTE: There are no vector types for half 1093 1094 1095 /** 1096 * Macro to facilitate debugging 1097 * Usage: 1098 * Place mixin(CL_PROGRAM_STRING_DEBUG_INFO) on the line before the first line of your source. 1099 * The first line ends with: CL_PROGRAM_STRING_BEGIN \" 1100 * Each line thereafter of OpenCL C source must have a line end 1101 * The last line is empty; 1102 * 1103 * Example: 1104 * 1105 * string code = mixin(CL_PROGRAM_STRING_DEBUG_INFO) ~ q{ 1106 * kernel void foo( int a, float * b ) 1107 * { 1108 * // my comment 1109 * *b[ get_global_id(0)] = a; 1110 * } 1111 * }; 1112 * 1113 * This should correctly set up the line, (column) and file information for your source 1114 * string so you can do source level debugging. 1115 */ 1116 1117 // Workaround: OpenCL expects Linux dir separators ("unrecognized character escape sequence") 1118 // Usage: createProgram( CL_PROGRAM_STRING_DEBUG_INFO(__LINE__, __FILE__) ~ q{ __kernel code }); 1119 import std..string; 1120 1121 string CL_PROGRAM_STRING_DEBUG_INFO(size_t line = __LINE__, string file = __FILE__) 1122 { 1123 string ret = ""; 1124 1125 debug 1126 { 1127 file = tr(file, "\\", "/"); 1128 ret = "#line " ~ to!string(line) ~ " \"" ~ file ~ "\"" ~ "\n\n"; 1129 } 1130 1131 return ret; 1132 }