This repository was archived by the owner on Mar 12, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -202,13 +202,30 @@ macro allocated(ex)
202
202
end
203
203
end
204
204
205
+
206
+ """
207
+ @time ex
208
+
209
+ Run expression `ex` and report on execution time and GPU/CPU memory behavior. The GPU is
210
+ synchronized right before and after executing `ex` to exclude any external effects.
211
+
212
+ """
205
213
macro time (ex)
206
214
quote
215
+ # @time might surround an application, so be sure to initialize CUDA before that
216
+ # FIXME : this should be done in CUDAdrv (`synchronize(ctx=CuCurrentOrNewContext()`)
217
+ # but the CUDA initialization mechanics are part of CUDAnative.jl
218
+ CUDAnative. maybe_initialize (" @time" )
219
+
220
+ # coarse synchronization to exclude effects from previously-executed code
221
+ CUDAdrv. synchronize ()
222
+
207
223
local gpu_mem_stats0 = copy (alloc_stats)
208
224
local cpu_mem_stats0 = Base. gc_num ()
209
225
local cpu_time0 = time_ns ()
210
226
211
- local val = $ (esc (ex))
227
+ # fine-grained synchronization of the code under analysis
228
+ local val = @sync $ (esc (ex))
212
229
213
230
local cpu_time1 = time_ns ()
214
231
local cpu_mem_stats1 = Base. gc_num ()
You can’t perform that action at this time.
0 commit comments