summaryrefslogtreecommitdiffstats
path: root/src/com/mbien/opencl/CLException.java
blob: e8ed771f0953ae3a6cdfc2094e53236c6aed8809 (plain)
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
package com.mbien.opencl;

/**
 * Main Exception type for runtime OpenCL errors and unsuccessfull function calls (e.g. returning other values than CL_SUCCESS).
 * @author Michael Bien
 */
public class CLException extends RuntimeException {

    public CLException(Throwable cause) {
        super(cause);
    }

    public CLException(String message, Throwable cause) {
        super(message, cause);
    }

    public CLException(String message) {
        super(message);
    }

    public CLException(int error, String message) {
        super(identifyError(error) + ": " + message);
    }

    private static final String identifyError(int error) {

        switch (error) {
            case CL.CL_INVALID_VALUE:
                return "CL_INVALID_VALUE";

            case CL.CL_INVALID_DEVICE_TYPE:
                return "CL_INVALID_DEVICE_TYPE";

            case CL.CL_INVALID_PLATFORM:
                return "CL_INVALID_PLATFORM";

            case CL.CL_INVALID_DEVICE:
                return "CL_INVALID_DEVICE";

            case CL.CL_INVALID_CONTEXT:
                return "CL_INVALID_CONTEXT";

            case CL.CL_INVALID_QUEUE_PROPERTIES:
                return "CL_INVALID_QUEUE_PROPERTIES";

            case CL.CL_INVALID_COMMAND_QUEUE:
                return "CL_INVALID_COMMAND_QUEUE";

            case CL.CL_INVALID_HOST_PTR:
                return "CL_INVALID_HOST_PTR";

            case CL.CL_INVALID_MEM_OBJECT:
                return "CL_INVALID_MEM_OBJECT";

            case CL.CL_INVALID_IMAGE_FORMAT_DESCRIPTOR:
                return "CL_INVALID_IMAGE_FORMAT_DESCRIPTOR";

            case CL.CL_INVALID_IMAGE_SIZE:
                return "CL_INVALID_IMAGE_SIZE";

            case CL.CL_INVALID_SAMPLER:
                return "CL_INVALID_SAMPLER";

            case CL.CL_INVALID_BINARY:
                return "CL_INVALID_BINARY";

            case CL.CL_INVALID_BUILD_OPTIONS:
                return "CL_INVALID_BUILD_OPTIONS";

            case CL.CL_INVALID_PROGRAM:
                return "CL_INVALID_PROGRAM";

            case CL.CL_INVALID_PROGRAM_EXECUTABLE:
                return "CL_INVALID_PROGRAM_EXECUTABLE";

            case CL.CL_INVALID_KERNEL_NAME:
                return "CL_INVALID_KERNEL_NAME";

            case CL.CL_INVALID_KERNEL_DEFINITION:
                return "CL_INVALID_KERNEL_DEFINITION";

            case CL.CL_INVALID_KERNEL:
                return "CL_INVALID_KERNEL";

            case CL.CL_INVALID_ARG_INDEX:
                return "CL_INVALID_ARG_INDEX";

            case CL.CL_INVALID_ARG_VALUE:
                return "CL_INVALID_ARG_VALUE";

            case CL.CL_INVALID_ARG_SIZE:
                return "CL_INVALID_ARG_SIZE";

            case CL.CL_INVALID_KERNEL_ARGS:
                return "CL_INVALID_KERNEL_ARGS";

            case CL.CL_INVALID_WORK_DIMENSION:
                return "CL_INVALID_WORK_DIMENSION";

            case CL.CL_INVALID_WORK_GROUP_SIZE:
                return "CL_INVALID_WORK_GROUP_SIZE";

            case CL.CL_INVALID_WORK_ITEM_SIZE:
                return "CL_INVALID_WORK_ITEM_SIZE";

            case CL.CL_INVALID_GLOBAL_OFFSET:
                return "CL_INVALID_GLOBAL_OFFSET";

            case CL.CL_INVALID_EVENT_WAIT_LIST:
                return "CL_INVALID_EVENT_WAIT_LIST";

            case CL.CL_INVALID_EVENT:
                return "CL_INVALID_EVENT";

            case CL.CL_INVALID_OPERATION:
                return "CL_INVALID_OPERATION";

            case CL.CL_INVALID_GL_OBJECT:
                return "CL_INVALID_GL_OBJECT";

            case CL.CL_INVALID_BUFFER_SIZE:
                return "CL_INVALID_BUFFER_SIZE";

            case CL.CL_INVALID_MIP_LEVEL:
                return "CL_INVALID_MIP_LEVEL";

            default:
                return "unknown cause";
        }
    }


}