@@ -133,41 +133,46 @@ function compile(@nospecialize(job::CompilerJob))
133133 wait (proc)
134134 success (proc) || error (fetch (logger))
135135 catch err
136- file = tempname (cleanup= false ) * " .ll"
137- write (file , ir)
136+ ir_file = tempname (cleanup= false ) * " .ll"
137+ write (ir_file , ir)
138138 if parse (Bool, get (ENV , " BUILDKITE" , " false" ))
139- run (` buildkite-agent artifact upload $(file ) ` )
139+ run (` buildkite-agent artifact upload $(ir_file ) ` )
140140 end
141141 error (""" Compilation to AIR failed; see above for details.
142- If you think this is a bug, please file an issue and attach $(file ) """ )
142+ If you think this is a bug, please file an issue and attach $(ir_file ) """ )
143143 end
144144
145145 fetch (reader)
146146 end
147147 end
148148
149149 @signpost_interval log= log_compiler () " Create Metal library" begin
150- image = try
151- metallib_fun = MetalLibFunction (; name= entry, air_module= air,
152- air_version= job. config. target. air,
153- metal_version= job. config. target. metal)
154- metallib = MetalLib (; functions = [metallib_fun ])
155-
156- image_stream = IOBuffer ()
157- write (image_stream, metallib )
158- take! (image_stream )
150+ metallib = try
151+ fun = MetalLibFunction (; name= entry, air_module= air,
152+ air_version= job. config. target. air,
153+ metal_version= job. config. target. metal)
154+ lib = MetalLib (; functions = [fun ])
155+
156+ io = IOBuffer ()
157+ write (io, lib )
158+ take! (io )
159159 catch err
160- file = tempname (cleanup= false ) * " .air"
161- write (file, air)
160+ ir_file = tempname (cleanup= false ) * " .ll"
161+ write (ir_file, ir)
162+ air_file = tempname (cleanup= false ) * " .air"
163+ write (air_file, air)
162164 if parse (Bool, get (ENV , " BUILDKITE" , " false" ))
163- run (` buildkite-agent artifact upload $(file) ` )
165+ run (` buildkite-agent artifact upload $(ir_file) ` )
166+ run (` buildkite-agent artifact upload $(air_file) ` )
164167 end
165168 error (""" Compilation to Metal library failed; see below for details.
166- If you think this is a bug, please file an issue and attach $(file) """ )
169+ If you think this is a bug, please file an issue and attach the following files:
170+ - $(ir_file)
171+ - $(air_file) """ )
167172 end
168173 end
169174
170- return (; image , entry)
175+ return (; ir, air, metallib , entry)
171176end
172177
173178# link into an executable kernel
177182
178183 @signpost_interval log= log_compiler () " Instantiate compute pipeline" begin
179184 dev = device ()
180- lib = MTLLibraryFromData (dev, compiled. image )
185+ lib = MTLLibraryFromData (dev, compiled. metallib )
181186 fun = MTLFunction (lib, compiled. entry)
182187 pipeline_state = try
183188 MTLComputePipelineState (dev, fun)
@@ -187,13 +192,22 @@ end
187192
188193 # the back-end compiler likely failed
189194 # XXX : check more accurately? the error domain doesn't help much here
190- file = tempname (cleanup= false ) * " .metallib"
191- write (file, compiled. image)
195+ ir_file = tempname (cleanup= false ) * " .ll"
196+ write (ir_file, compiled. ir)
197+ air_file = tempname (cleanup= false ) * " .air"
198+ write (air_file, compiled. air)
199+ metallib_file = tempname (cleanup= false ) * " .metallib"
200+ write (metallib_file, compiled. metallib)
192201 if parse (Bool, get (ENV , " BUILDKITE" , " false" ))
193- run (` buildkite-agent artifact upload $(file) ` )
202+ run (` buildkite-agent artifact upload $(ir_file) ` )
203+ run (` buildkite-agent artifact upload $(air_file) ` )
204+ run (` buildkite-agent artifact upload $(metallib_file) ` )
194205 end
195206 error (""" Compilation to native code failed; see below for details.
196- If you think this is a bug, please file an issue and attach $(file) """ )
207+ If you think this is a bug, please file an issue and attach the following files:
208+ - $(ir_file)
209+ - $(air_file)
210+ - $(metallib_file) """ )
197211 end
198212 end
199213
0 commit comments