File tree Expand file tree Collapse file tree 3 files changed +21
-28
lines changed Expand file tree Collapse file tree 3 files changed +21
-28
lines changed Original file line number Diff line number Diff line change @@ -409,8 +409,22 @@ function __synchronize()
409
409
error (" @synchronize used outside kernel or not captured" )
410
410
end
411
411
412
- function __print (items... )
413
- error (" @print used outside of kernel" )
412
+ @generated function __print (items... )
413
+ str = " "
414
+ args = []
415
+
416
+ for i in 1 : length (items)
417
+ item = :(items[$ i])
418
+ T = items[i]
419
+ if T <: Val
420
+ item = QuoteNode (T. parameters[1 ])
421
+ end
422
+ push! (args, item)
423
+ end
424
+
425
+ quote
426
+ print ($ (args... ))
427
+ end
414
428
end
415
429
416
430
# ##
Original file line number Diff line number Diff line change 153
153
end
154
154
end
155
155
156
- @generated function _print (items... )
157
- str = " "
158
- args = []
159
-
160
- for i in 1 : length (items)
161
- item = :(items[$ i])
162
- T = items[i]
163
- if T <: Val
164
- item = QuoteNode (T. parameters[1 ])
165
- end
166
- push! (args, item)
167
- end
168
-
169
- quote
170
- print ($ (args... ))
171
- end
172
-
173
- end
174
-
175
156
176
157
@inline function Cassette. overdub (ctx:: CPUCtx , :: typeof (__print), items... )
177
- _print (items... )
158
+ __print (items... )
178
159
end
179
160
180
161
generate_overdubs (CPUCtx)
Original file line number Diff line number Diff line change 11
11
end
12
12
13
13
function test_print (backend)
14
- if backend == CPU ()
15
- kernel = kernel_print (CPU (), 4 )
16
- else
17
- kernel = kernel_print (CUDA (), 4 )
18
- end
14
+ kernel = kernel_print (backend, 4 )
19
15
kernel (ndrange= (4 ,))
20
16
end
21
17
22
-
23
18
@testset " print test" begin
24
19
if CUDAapi. has_cuda_gpu ()
25
20
wait (test_print (CUDA ()))
28
23
29
24
wait (test_print (CPU ()))
30
25
@test true
26
+
27
+ @print (" Why this should work" )
28
+ @test true
31
29
end
You can’t perform that action at this time.
0 commit comments