This file is indexed.

/usr/include/viennacl/ocl/error.hpp is in libviennacl-dev 1.5.1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
#ifndef VIENNACL_OCL_ERROR_HPP_
#define VIENNACL_OCL_ERROR_HPP_

/* =========================================================================
   Copyright (c) 2010-2014, Institute for Microelectronics,
                            Institute for Analysis and Scientific Computing,
                            TU Wien.
   Portions of this software are copyright by UChicago Argonne, LLC.

                            -----------------
                  ViennaCL - The Vienna Computing Library
                            -----------------

   Project Head:    Karl Rupp                   rupp@iue.tuwien.ac.at

   (A list of authors and contributors can be found in the PDF manual)

   License:         MIT (X11), see file LICENSE in the base directory
============================================================================= */

/** @file viennacl/ocl/error.hpp
    @brief Error handling for the OpenCL layer of ViennaCL
*/

//error levels:
//#define VIENNACL_DEBUG_ALL           //print all of the following
//#define VIENNACL_DEBUG_KERNEL        //debug any modifications on viennacl::ocl::kernel objects
//#define VIENNACL_DEBUG_COPY          //print infos related to setting up/modifying memory objects
//#define VIENNACL_DEBUG_OPENCL        //display debug info for the OpenCL layer (platform/context/queue creation,
//#define VIENNACL_DEBUG_DEVICE        //Show device info upon allocation
//#define VIENNACL_DEBUG_CONTEXT       //Debug queries to context
//#define VIENNACL_DEBUG_BUILD         //Show debug info from OpenCL compiler


//backwards compatibility:
#ifdef VIENNACL_BUILD_INFO
  #define VIENNACL_DEBUG_ALL
#endif


#ifdef __APPLE__
#include <OpenCL/cl.h>
#else
#include <CL/cl.h>
#endif

#include <string>
#include <iostream>
#include <exception>

#define VIENNACL_BUG_REPORT_STRING  \
               "\nIf you think that this is a bug in ViennaCL, please report it at viennacl-support@lists.sourceforge.net and supply at least the following information:\n"\
               " * Operating System\n"\
               " * Which OpenCL implementation (AMD, NVIDIA, etc.)\n"\
               " * ViennaCL version\n"\
               "Many thanks in advance!";\

namespace viennacl
{
  namespace ocl
  {
    //Wrapper for OpenCL exceptions:

    /** @brief Exception thrown in the case that a requested compute device was not found.
      *
      * This exception usually shows up if a user requests a GPU for computation, but the OpenCL SDK does not support the GPU.
      */
    class device_not_found : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: CL_DEVICE_NOT_FOUND \n ViennaCL could not find a suitable device. Please check whether an OpenCL implementation is properly installed and a suitable device available."
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown if the selected compute device is not available (maybe locked by another process). */
    class device_not_available : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: CL_DEVICE_NOT_AVAILABLE \n ViennaCL could not use the compute device because it is not available."
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown if the OpenCL just-in-time compiler is not available. */
    class compiler_not_available : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: CL_COMPILER_NOT_AVAILABLE \n Your OpenCL framework does not provide an OpenCL compiler. Unfortunately, ViennaCL cannot be used without such a compiler."
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown if a memory object cannot be allocated. Usually the requested memory buffer is simply too large. */
    class mem_object_allocation_failure : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: CL_MEM_OBJECT_ALLOCATION_FAILURE \n ViennaCL could not allocate memory on the device. Most likely the device simply ran out of memory."
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown if the compute device is out of resources (either global memory, registers, etc.) for the requested operation. */
    class out_of_resources : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: CL_OUT_OF_RESOURCES \n ViennaCL tried to launch a compute kernel, but the device does not provide enough resources. Try changing the global and local work item sizes."
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown if the host cannot provide enough memory for the datastructures in the OpenCL backend (temporary arrays, etc.) to perform the requested operation. */
    class out_of_host_memory : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: CL_OUT_OF_HOST_MEMORY \n The host ran out of memory (usually CPU RAM). Please try again on smaller problems."
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown if the OpenCL context does not have CL_QUEUE_PROFILING_ENABLE set, if the execution is not complete, or the event object is a user event object. */
    class profiling_info_not_available : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: CL_PROFILING_INFO_NOT_AVAILABLE."
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown if the source buffer overlaps the destination buffer when copying from device memory to device memory. */
    class mem_copy_overlap : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: CL_MEM_COPY_OVERLAP."
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown if there is a mismatch in image formats for the operands. */
    class image_format_mismatch : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: CL_IMAGE_FORMAT_MISMATCH."
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown if the requested image format is not supported. */
    class image_format_not_supported : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: CL_IMAGE_FORMAT_NOT_SUPPORTED."
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown if the OpenCL program cannot be built, usually due to a syntax error in the OpenCL code. */
    class build_program_failure : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: CL_BUILD_PROGRAM_FAILURE \n The OpenCL compiler encountered an error during the compilation of ViennaCL sources. This is most likely a bug in ViennaCL."
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown if the mapping of device memory to the host memory space failed. */
    class map_failure : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: CL_MAP_FAILURE."
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown is an invalid value is provided to an OpenCL function. */
    class invalid_value : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: CL_INVALID_VALUE."
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown if an invalid device type is specified. */
    class invalid_device_type : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: CL_INVALID_DEVICE_TYPE."
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown if an invalid OpenCL platform is provided to an OpenCL function. */
    class invalid_platform : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: CL_INVALID_PLATFORM."
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown if an invalid OpenCL device is provided to an OpenCL function. */
    class invalid_device : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: CL_INVALID_DEVICE."
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown if an invalid OpenCL context is provided to an OpenCL function. */
    class invalid_context : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: CL_INVALID_CONTEXT."
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown if invalid OpenCL command queue properties are provided when creating a command queue. */
    class invalid_queue_properties : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: CL_INVALID_QUEUE_PROPERTIES."
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown if an invalid OpenCL command queue is provided to an OpenCL function. */
    class invalid_command_queue : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: CL_INVALID_COMMAND_QUEUE."
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown if the provided pointer to host memory is invalid. */
    class invalid_host_ptr : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: CL_INVALID_HOST_PTR."
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown if an invalid OpenCL memory object (of type cl_mem) is passed to an OpenCL funciton. */
    class invalid_mem_object : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: CL_INVALID_MEM_OBJECT."
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown if an invalid image format descriptor is provided. */
    class invalid_image_format_descriptor : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: CL_INVALID_IMAGE_FORMAT_DESCRIPTOR."
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown if the image size provided is invalid (e.g. zero). */
    class invalid_image_size : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: CL_INVALID_IMAGE_SIZE."
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown if an invalid sampler is provided for an image. */
    class invalid_sampler : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: CL_INVALID_SAMPLER."
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown if the OpenCL binary (generated from the jit-compiler or loaded from some other location) won't work on the device (e.g. due to a lack of double precision support). */
    class invalid_binary : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: CL_INVALID_BINARY."
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown if invalid build options are passed to the OpenCL just-in-time compiler. */
    class invalid_build_options : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: CL_INVALID_BUILD_OPTIONS."
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown if an OpenCL program object handle is invalid (e.g. not initialized). */
    class invalid_program : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: CL_INVALID_PROGRAM."
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown if there is no built program exectuable available for the device. */
    class invalid_program_executable : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: CL_INVALID_PROGRAM_EXECUTABLE."
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown if the provided kernel name is invalid (e.g. not part of the program provided). */
    class invalid_kernel_name : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: CL_INVALID_KERNEL_NAME \n The supplied kernel name is invalid. If you have written your own OpenCL kernel, please check that the correct kernel name is used in the initalization of the kernel object."
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown if the kernel definition (number of arguments, argument types, etc.) is not the same for all devices for which the program has been built. */
    class invalid_kernel_definition : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: CL_INVALID_KERNEL_DEFINITION."
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown if the provided kernel object (of type cl_kernel) is invalid (e.g. not initialized, from different context, or corrupted). */
    class invalid_kernel : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: CL_INVALID_KERNEL \n The supplied kernel argument is invalid."
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown if the kernel argument index is invalid, e.g. an arg index larger than the number of kernel arguments was provided. */
    class invalid_arg_index : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: CL_INVALID_ARG_INDEX."
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown if the kernel argument provided has an invalid value. */
    class invalid_arg_value : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: CL_INVALID_ARG_VALUE."
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown if the arguments to an OpenCL kernel have an invalid size e.g. not sizeof(cl_mem)). */
    class invalid_arg_size : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: CL_INVALID_ARG_SIZE."
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown if the kernel arguments are invalid and/or do not fit the kernel parameter list. */
    class invalid_kernel_args : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: CL_INVALID_KERNEL_ARGS \n The supplied kernel arguments do not fit the kernel parameter list. If you have written your own OpenCL kernel, please check that the correct kernel arguments are set in the appropriate order."
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown if the work dimension is invalid (usually this means that the work dimension was set to be larger than three. */
    class invalid_work_dimension : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: CL_INVALID_WORK_DIMENSION"
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown if the number of work groups is invalid (usually this means that more than 256/512/768/1024 work groups have been specified, but the device(s) cannot support this. */
    class invalid_work_group_size : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: CL_INVALID_WORK_GROUP_SIZE \n The supplied work group size is invalid. If you have set this value manually, please reconsider your choice."
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown if the number of work items per work group invalid (usually this means that more than 256/512/768/1024 work items have been specified, but the device(s) cannot support this. */
    class invalid_work_item_size : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: CL_INVALID_WORK_ITEM_SIZE \n The work item size is invalid. If you have set this value manually, please reconsider your choice."
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown if the provided offset for get_global_id() in OpenCL kernels is invalid. */
    class invalid_global_offset : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: CL_INVALID_GLOBAL_OFFSET."
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown if the provided event wait list is invalid. */
    class invalid_event_wait_list : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: CL_INVALID_EVENT_WAIT_LIST."
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown if the provided event object (of type cl_event) is invalid. */
    class invalid_event : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: CL_INVALID_EVENT."
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown if interoperability of OpenCL with other frameworks collide. */
    class invalid_operation : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: CL_INVALID_OPERATION."
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown if the provided OpenGL (not OpenCL) object is invalid. */
    class invalid_gl_object : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: CL_INVALID_GL_OBJECT."
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown if the provided buffer size is invalid (e.g. zero) */
    class invalid_buffer_size : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: CL_INVALID_BUFFER_SIZE."
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown if the provided miplevel is greater than zero, but the OpenGL implementation does not support creating from non-zero mipmap levels. */
    class invalid_mip_level : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: CL_INVALID_MIP_LEVEL."
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown if the total number of work items is invalid (for example, not divisible by the number of work items per work group). */
    class invalid_global_work_size : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: CL_INVALID_GLOBAL_WORK_SIZE."
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown if an invalid property is provided to a function (vague value). */
    class invalid_property : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: CL_INVALID_PROPERTY."
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown if the returned error cannot be resolved to some defined error constant. Might result from invalid sources, invalid memory operations, etc. */
    class unknown_error : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: ViennaCL encountered an unknown OpenCL error. In some cases, this might be due to an invalid global work size, but it can also be due to several compilation errors."
               VIENNACL_BUG_REPORT_STRING;
      }
    };

    /** @brief Exception thrown if the user wants to use double precision arithmetics, but the device does not support double precision. */
    class double_precision_not_provided_error : public std::exception
    {
      virtual const char* what() const throw()
      {
        return "ViennaCL: FATAL ERROR: You requested to create a ViennaCL type using double precision. However, double precision is not supported by your device."
               VIENNACL_BUG_REPORT_STRING;
      }
    };


    /** @brief An error reporting class. Template argument is used to avoid problems with external linkage.
    *
    *  Do not use this class directly, use the macro CL_ERROR_CHECK instead.
    *  @tparam T   Useless. Helps to avoid troubles with external linkage of namespace functions.
    */
    template <typename T>
    struct error_checker
    {

      /** @brief Trows exceptions that reflect OpenCL error codes */
      static void raise_exception(cl_int err)
      {
        switch (err)
        {
          case CL_DEVICE_NOT_FOUND:               throw device_not_found();
          case CL_DEVICE_NOT_AVAILABLE:           throw device_not_available();
          case CL_COMPILER_NOT_AVAILABLE:         throw compiler_not_available();
          case CL_MEM_OBJECT_ALLOCATION_FAILURE:  throw mem_object_allocation_failure();
          case CL_OUT_OF_RESOURCES:               throw out_of_resources();
          case CL_OUT_OF_HOST_MEMORY:             throw out_of_host_memory();
          case CL_PROFILING_INFO_NOT_AVAILABLE:   throw profiling_info_not_available();
          case CL_MEM_COPY_OVERLAP:               throw mem_copy_overlap();
          case CL_IMAGE_FORMAT_MISMATCH:          throw image_format_mismatch();
          case CL_IMAGE_FORMAT_NOT_SUPPORTED:     throw image_format_not_supported();
          case CL_BUILD_PROGRAM_FAILURE:          throw build_program_failure();
          case CL_MAP_FAILURE:                    throw map_failure();

          case CL_INVALID_VALUE:                  throw invalid_value();
          case CL_INVALID_DEVICE_TYPE:            throw invalid_device_type();
          case CL_INVALID_PLATFORM:               throw invalid_platform();
          case CL_INVALID_DEVICE:                 throw invalid_device();
          case CL_INVALID_CONTEXT:                throw invalid_context();
          case CL_INVALID_QUEUE_PROPERTIES:       throw invalid_queue_properties();
          case CL_INVALID_COMMAND_QUEUE:          throw invalid_command_queue();
          case CL_INVALID_HOST_PTR:               throw invalid_host_ptr();
          case CL_INVALID_MEM_OBJECT:             throw invalid_mem_object();
          case CL_INVALID_IMAGE_FORMAT_DESCRIPTOR: throw invalid_image_format_descriptor();
          case CL_INVALID_IMAGE_SIZE:             throw invalid_image_size();
          case CL_INVALID_SAMPLER:                throw invalid_sampler();
          case CL_INVALID_BINARY:                 throw invalid_binary();
          case CL_INVALID_BUILD_OPTIONS:          throw invalid_build_options();
          case CL_INVALID_PROGRAM:                throw invalid_program();
          case CL_INVALID_PROGRAM_EXECUTABLE:     throw invalid_program_executable();
          case CL_INVALID_KERNEL_NAME:            throw invalid_kernel_name();
          case CL_INVALID_KERNEL_DEFINITION:      throw invalid_kernel_definition();
          case CL_INVALID_KERNEL:                 throw invalid_kernel();
          case CL_INVALID_ARG_INDEX:              throw invalid_arg_index();
          case CL_INVALID_ARG_VALUE:              throw invalid_arg_value();
          case CL_INVALID_ARG_SIZE:               throw invalid_arg_size();
          case CL_INVALID_KERNEL_ARGS:            throw invalid_kernel_args();
          case CL_INVALID_WORK_DIMENSION:         throw invalid_work_dimension();
          case CL_INVALID_WORK_GROUP_SIZE:        throw invalid_work_group_size();
          case CL_INVALID_WORK_ITEM_SIZE:         throw invalid_work_item_size();
          case CL_INVALID_GLOBAL_OFFSET:          throw invalid_global_offset();
          case CL_INVALID_EVENT_WAIT_LIST:        throw invalid_event_wait_list();
          case CL_INVALID_EVENT:                  throw invalid_event();
          case CL_INVALID_OPERATION:              throw invalid_operation();
          case CL_INVALID_GL_OBJECT:              throw invalid_gl_object();
          case CL_INVALID_BUFFER_SIZE:            throw invalid_buffer_size();
          case CL_INVALID_MIP_LEVEL:              throw invalid_mip_level();
          case CL_INVALID_GLOBAL_WORK_SIZE:       throw invalid_global_work_size();
      #ifdef CL_INVALID_PROPERTY
    case CL_INVALID_PROPERTY:               throw invalid_property();
      #endif
          //  return "CL_INVALID_GLOBAL_WORK_SIZE";

          default: throw unknown_error();
        }

      } //getErrorString

      /** @brief Checks whether an OpenCL error has occured.
      *
      *  Do not use this function directly, use the macro CL_ERROR_CHECK instead.
      */
      static void checkError(cl_int err,
          #ifdef VIENNACL_DEBUG_ALL
                             const char * file,
                             const char * func,
                             int line)
          #else
                             const char *,
                             const char *,
                             int)
          #endif
      {
        if (err != CL_SUCCESS)
        {
          #ifdef VIENNACL_DEBUG_ALL
          std::cerr << "ViennaCL: Error " << err  << " in function " << func << " ( "<< file << ":" << line << " ) " << std::endl;
          #endif
          raise_exception(err);
        }
      } //checkError()

    }; //struct

    #define VIENNACL_ERR_CHECK(err) viennacl::ocl::error_checker<void>::checkError(err, __FILE__, __FUNCTION__, __LINE__);

  } //namespace ocl
} //namespace viennacl

#endif