0

I have been exploring the possibilities of Halide for a couple of weeks, and to better understand what Halide is doing I would like to try and use the halide profiler. Lets say I have a Func test. (For ease of reading I left out the variable declarations and such.) f=Func(test); f(x,y)=some_image(x,y)*2; If I want to run this i call f.realize(some_image.width(),some_image.height()). Now if I understand correctly, when want to profile this I need to use the class halide_profiler_func_stats. But I cannot find any way to access this and/or another way to get the profiling data.

Until now I have been running a separate timer in my software but I want to see the capabilities of the profiler from Halide itself. How do I do this?

  • For others this is the code I used: `Target t=get_host_target(); t.setfeature(Target::Profile); myfunc.compile_jit(t); result=myfunc.realize(width,height);` – pietervanderstar May 17 '16 at 07:59
  • I have a follow-up question. Now the profiler only does one run, but how do I set this to, lets say 100? I have only found functions that return the number of runs performed. Placing the realize in a loop lets the profiler run 100 times with 1 run, and this is not quite what I am looking for. – pietervanderstar May 18 '16 at 08:10
  • I tried compiling AOT and then the profiler accumulated over all runs. @Andrew Adams, it worked without me giving a single thought to HalideRuntime.h – pietervanderstar May 23 '16 at 15:42

2 Answers2

1

The usual way to use the profile is to add "-profile" to HL_TARGET or HL_JIT_TARGET, or use to build an equivalent Target object and pass it to realize. This prints out all the profiling info after each run.

You would need to worry about the stuff in HalideRuntime.h if you're compiling AOT and want to report the profiling info in some special way or inspect it with code.

Andrew Adams
  • 1,396
  • 7
  • 3
  • This helped to confirm I was on the right track, I think the fresh start of the week helped as well. I found I called jit_compile twice, once with the profile feature, once without. This meant the profiler was not active. – pietervanderstar May 17 '16 at 07:58
0

In the HalideRuntime.h header file, located in the same include directory as Halide.h, you will find a halide_profiler_get_state() function that will return a halide_profiler_state ptr; you can then use that ptr to get to the array of functions contained with the funcs member variable, which is a ptr to halide_profiler_func_stats.

Jaime
  • 1
  • 1