@@ -143,6 +143,10 @@ abstract type AbstractKernel{F, TT} end
143143 call_t = Type[x[1 ] for x in zip (sig. parameters, to_pass) if x[2 ]]
144144 call_args = Union{Expr,Symbol}[x[1 ] for x in zip (args, to_pass) if x[2 ]]
145145
146+ # add the kernel state as the first argument
147+ pushfirst! (call_t, KernelState)
148+ pushfirst! (call_args, :(kernel. state))
149+
146150 # replace non-isbits arguments (they should be unused, or compilation would have failed)
147151 for (i,dt) in enumerate (call_t)
148152 if ! isbitstype (dt)
@@ -156,6 +160,16 @@ abstract type AbstractKernel{F, TT} end
156160
157161 quote
158162 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+
159173 clcall (kernel. fun, $ call_tt, $ (call_args... ); indirect_memory, call_kwargs... )
160174 end
161175end
167181struct HostKernel{F,TT} <: AbstractKernel{F,TT}
168182 f:: F
169183 fun:: cl.Kernel
184+ state:: KernelState
170185end
171186
172187
@@ -191,7 +206,9 @@ function clfunction(f::F, tt::TT=Tuple{}; kwargs...) where {F,TT}
191206 kernel = get (_kernel_instances, h, nothing )
192207 if kernel === nothing
193208 # 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)
195212 _kernel_instances[h] = kernel
196213 end
197214 return kernel:: HostKernel{F,tt}
0 commit comments