Vanderson Martins do Rosario
2014-Sep-17 19:53 UTC
[LLVMdev] Measure execution time of each basic block
Guys, Someone have any idea how could I measure the execution time of each LLVM basic block of a program? I tried to use some profiling tools like gcov and perf, but as far as I know they can only give me the frequency that each basic block is executed. I was thinking about writing a pass to add PAPI instructions in each LLVM basic block. Do you think is a good idea? Thanks Vanderson M. Rosario -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140917/b704227d/attachment.html>
Jonathan Roelofs
2014-Sep-17 20:26 UTC
[LLVMdev] Measure execution time of each basic block
I think if you do this, you're quickly going to realize that there's quite a lot of overhead in getting the time stamps needed to record basic block duration, so you're not going to get accurate results except for really big basic blocks. Cheers, Jon On 9/17/14 1:53 PM, Vanderson Martins do Rosario wrote:> Guys, > > Someone have any idea how could I measure the execution time of each LLVM basic > block of a program? > > I tried to use some profiling tools like gcov and perf, but as far as I know > they can only give me the frequency that each basic block is executed. > > I was thinking about writing a pass to add PAPI instructions in each LLVM basic > block. Do you think is a good idea? > > Thanks > > Vanderson M. Rosario > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-- Jon Roelofs jonathan at codesourcery.com CodeSourcery / Mentor Embedded
Vanderson Martins do Rosario
2014-Sep-17 20:35 UTC
[LLVMdev] Measure execution time of each basic block
Jon, I need to create a database of basics blocks and their execution time. The only thing I'm concerned is if a block A is more expensive than a block B. Do you think that even with the overhead I would be able to get the A > B information? Like: overhead + time(A) > overhead + time(B) => A > B. If so, I'm not too much concerned about the accuracy. Not sure if I was clear, Thanks again Vanderson M. Rosario 2014-09-17 17:26 GMT-03:00 Jonathan Roelofs <jonathan at codesourcery.com>:> I think if you do this, you're quickly going to realize that there's quite > a lot of overhead in getting the time stamps needed to record basic block > duration, so you're not going to get accurate results except for really big > basic blocks. > > > Cheers, > > Jon > > > On 9/17/14 1:53 PM, Vanderson Martins do Rosario wrote: > >> Guys, >> >> Someone have any idea how could I measure the execution time of each LLVM >> basic >> block of a program? >> >> I tried to use some profiling tools like gcov and perf, but as far as I >> know >> they can only give me the frequency that each basic block is executed. >> >> I was thinking about writing a pass to add PAPI instructions in each LLVM >> basic >> block. Do you think is a good idea? >> >> Thanks >> >> Vanderson M. Rosario >> >> >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >> >> > -- > Jon Roelofs > jonathan at codesourcery.com > CodeSourcery / Mentor Embedded >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140917/5e1218d4/attachment.html>
Hi, I tried to use some profiling tools like gcov and perf, but as far as I> know they can only give me the frequency that each basic block is executed. >For perf, this really depends on what you’re sampling on. For your use case, it seems that sampling CPU cycles would give the data that you want. If you run something like perf record -e cycles -c 1000000 /path/to/program, is that perf will collect one sample every 1’000’000 cpu cycles. If you have a 2GHz CPU, that would mean one sample every 0.5ms. So the time taken by a basic block is roughly the number of samples in that block times 0.5ms. GCOV on the other hand will give you the number of times each basic block was executed, which does not tell much about the running time. Cheers, Jonas PS: try to just run perf stat /path/to/program to see the relationships between cycles, runtime, and other metrics. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140920/6f044a2f/attachment.html>