File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -88,6 +88,12 @@ function check_invocation(@nospecialize(job::CompilerJob))
8888 This is a CPU-only object not supported by GPUCompiler.""" ))
8989 end
9090
91+ # If an object doesn't have fields, it can only be used by identity, so we can allow
92+ # them to be passed to the GPU (this also applies to e.g. Symbols).
93+ if fieldcount (dt) == 0
94+ continue
95+ end
96+
9197 if ! isbitstype (dt)
9298 throw (KernelError (job, " passing non-bitstype argument" ,
9399 """ Argument $arg_i to your kernel function is of type $dt , which is not a bitstype:
Original file line number Diff line number Diff line change 162162 ir = fetch (t)
163163 @test contains (ir, r" add i64 %\d +, 3" )
164164 end
165+
166+ @testset " allowed mutable types" begin
167+ # when types have no fields, we should always allow them
168+ mod = @eval module $ (gensym ())
169+ struct Empty end
170+ end
171+
172+ Native. code_execution (Returns (nothing ), (mod. Empty,))
173+
174+ # this also applies to Symbols
175+ Native. code_execution (Returns (nothing ), (Symbol,))
176+ end
165177end
166178
167179# ###########################################################################################
You can’t perform that action at this time.
0 commit comments