@@ -49,7 +49,7 @@ function assign_args!(code, args)
4949 # assign arguments to variables
5050 vars = Tuple (gensym () for arg in args)
5151 map (vars, args) do var,arg
52- push! (code. args, :($ var = $ ( esc ( arg)) ))
52+ push! (code. args, :($ var = $ arg))
5353 end
5454
5555 # convert the arguments, compile the function and call the kernel
@@ -149,6 +149,9 @@ macro cuda(ex...)
149149 end
150150 end
151151
152+ # FIXME : macro hygiene wrt. escaping kwarg values (this broke with 1.5)
153+ # we esc() the whole thing now, necessitating gensyms...
154+ @gensym kernel_args kernel_tt kernel
152155 if dynamic
153156 # FIXME : we could probably somehow support kwargs with constant values by either
154157 # saving them in a global Dict here, or trying to pick them up from the Julia
@@ -159,9 +162,9 @@ macro cuda(ex...)
159162 push! (code. args,
160163 quote
161164 # we're in kernel land already, so no need to cudaconvert arguments
162- local kernel_tt = Tuple{$ ((:(Core. Typeof ($ var)) for var in var_exprs). .. )}
163- local kernel = dynamic_cufunction ($ ( esc (f)), kernel_tt)
164- kernel ($ (var_exprs... ); $ (map (esc, call_kwargs) ... ))
165+ local $ kernel_tt = Tuple{$ ((:(Core. Typeof ($ var)) for var in var_exprs). .. )}
166+ local $ kernel = $ dynamic_cufunction ($ f, $ kernel_tt)
167+ $ kernel ($ (var_exprs... ); $ (call_kwargs... ))
165168 end )
166169 else
167170 # regular, host-side kernel launch
@@ -171,16 +174,14 @@ macro cuda(ex...)
171174 push! (code. args,
172175 quote
173176 GC. @preserve $ (vars... ) begin
174- local kernel_args = map (cudaconvert, ($ (var_exprs... ),))
175- local kernel_tt = Tuple{Core. Typeof .(kernel_args)... }
176- local kernel = cufunction ($ (esc (f)), kernel_tt;
177- $ (map (esc, compiler_kwargs)... ))
178- kernel (kernel_args... ; $ (map (esc, call_kwargs)... ))
177+ local $ kernel_args = map ($ cudaconvert, ($ (var_exprs... ),))
178+ local $ kernel_tt = Tuple{Core. Typeof .($ kernel_args)... }
179+ local $ kernel = $ cufunction ($ f, $ kernel_tt; $ (compiler_kwargs... ))
180+ $ kernel ($ kernel_args... ; $ (call_kwargs... ))
179181 end
180182 end )
181183 end
182-
183- return code
184+ return esc (code)
184185end
185186
186187
0 commit comments