@@ -143,6 +143,10 @@ abstract type AbstractKernel{F, TT} end
143
143
call_t = Type[x[1 ] for x in zip (sig. parameters, to_pass) if x[2 ]]
144
144
call_args = Union{Expr,Symbol}[x[1 ] for x in zip (args, to_pass) if x[2 ]]
145
145
146
+ # add the kernel state as the first argument
147
+ pushfirst! (call_t, KernelState)
148
+ pushfirst! (call_args, :(kernel. state))
149
+
146
150
# replace non-isbits arguments (they should be unused, or compilation would have failed)
147
151
for (i,dt) in enumerate (call_t)
148
152
if ! isbitstype (dt)
@@ -156,7 +160,20 @@ abstract type AbstractKernel{F, TT} end
156
160
157
161
quote
158
162
indirect_memory = cl. AbstractMemory[]
163
+
164
+ # add exception info buffer to indirect memory
165
+ # XXX : this is too expensive
166
+ if kernel. state. exception_info != C_NULL
167
+ ctx = cl. context ()
168
+ if haskey (exception_infos, ctx)
169
+ push! (indirect_memory, exception_infos[ctx])
170
+ end
171
+ end
172
+
159
173
clcall (kernel. fun, $ call_tt, $ (call_args... ); indirect_memory, call_kwargs... )
174
+
175
+ # check for exceptions after kernel execution
176
+ check_exceptions ()
160
177
end
161
178
end
162
179
167
184
struct HostKernel{F,TT} <: AbstractKernel{F,TT}
168
185
f:: F
169
186
fun:: cl.Kernel
187
+ state:: KernelState
170
188
end
171
189
172
190
@@ -191,7 +209,9 @@ function clfunction(f::F, tt::TT=Tuple{}; kwargs...) where {F,TT}
191
209
kernel = get (_kernel_instances, h, nothing )
192
210
if kernel === nothing
193
211
# create the kernel state object
194
- kernel = HostKernel {F,tt} (f, fun)
212
+ exception_info = create_exceptions! (ctx, dev)
213
+ state = KernelState (exception_info)
214
+ kernel = HostKernel {F,tt} (f, fun, state)
195
215
_kernel_instances[h] = kernel
196
216
end
197
217
return kernel:: HostKernel{F,tt}
0 commit comments