@@ -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,6 +160,16 @@ 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... )
160
174
end
161
175
end
167
181
struct HostKernel{F,TT} <: AbstractKernel{F,TT}
168
182
f:: F
169
183
fun:: cl.Kernel
184
+ state:: KernelState
170
185
end
171
186
172
187
@@ -191,7 +206,9 @@ function clfunction(f::F, tt::TT=Tuple{}; kwargs...) where {F,TT}
191
206
kernel = get (_kernel_instances, h, nothing )
192
207
if kernel === nothing
193
208
# create the kernel state object
194
- kernel = HostKernel {F,tt} (f, fun)
209
+ exception_info = create_exceptions! (ctx, dev)
210
+ state = KernelState (exception_info)
211
+ kernel = HostKernel {F,tt} (f, fun, state)
195
212
_kernel_instances[h] = kernel
196
213
end
197
214
return kernel:: HostKernel{F,tt}
0 commit comments