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))
88
88
This is a CPU-only object not supported by GPUCompiler.""" ))
89
89
end
90
90
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
+
91
97
if ! isbitstype (dt)
92
98
throw (KernelError (job, " passing non-bitstype argument" ,
93
99
""" 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 162
162
ir = fetch (t)
163
163
@test contains (ir, r" add i64 %\d +, 3" )
164
164
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
165
177
end
166
178
167
179
# ###########################################################################################
You can’t perform that action at this time.
0 commit comments