Ketan Pundlik Umare
2008-Sep-29 01:43 UTC
[LLVMdev] Hi Cache Miss and Branch Misprediction
Hi Guys, I am an absolute newbie to the compiler community. I am experimenting a little bit with llvm. I have a few small questions, i would be really great if someone could help me. 1. Can i find out (is there something already built), if the previous instruction / or some instruction was a cache miss. Basically i want to detect cache misses and instructions that are causing this 2. Can i find if there was a branch misprediction? 3. Can i find if a branch was taken or not taken? It would be really great if someone could answer this for me. Thank you Ketan Georgia Institue of Technology
Ketan Pundlik Umare wrote:> Hi Guys, > I am an absolute newbie to the compiler community. I am experimenting a little bit with llvm. > I have a few small questions, i would be really great if someone could help me.It sounds like what you want is valgrind --tool=cachegrind (or --tool=callgrind). See http://valgrind.org/> 1. Can i find out (is there something already built), if the previous instruction / or some instruction was a cache miss. Basically i want to detect cache misses and instructions that are causing this > > 2. Can i find if there was a branch misprediction? > > 3. Can i find if a branch was taken or not taken? > > It would be really great if someone could answer this for me.I suppose you could instrument the existing LLVM JIT to collect this sort of information. Realize that much of LLVM works in the LLVM IR language, and we just 'lower' to assembly. LLVM 'passes' which modify code work by editing the IR, not the assembly, so things like 'branch prediction' and whatnot don't exist at that level. If you want to do it with LLVM, you'll likely need to build most of the infrastructure yourself. If you're interested in what we do have, see llvm/tools/llvm-prof.cpp, llvm/runtime/libprofile and llvm/utils/profile.pl . I have no idea what state this stuff is in, quite possibly bitrotted. Nick Lewycky
Ketan Pundlik Umare
2008-Sep-29 16:29 UTC
[LLVMdev] Hi Cache Miss and Branch Misprediction
Thanx a lot Nick!!! I will try to look at it and let you know. Thank you Ketan ----- Original Message ----- From: "Nick Lewycky" <nicholas at mxc.ca> To: "LLVM Developers Mailing List" <llvmdev at cs.uiuc.edu> Sent: Monday, September 29, 2008 3:21:31 AM GMT -05:00 US/Canada Eastern Subject: Re: [LLVMdev] Hi Cache Miss and Branch Misprediction Ketan Pundlik Umare wrote:> Hi Guys, > I am an absolute newbie to the compiler community. I am experimenting a little bit with llvm. > I have a few small questions, i would be really great if someone could help me.It sounds like what you want is valgrind --tool=cachegrind (or --tool=callgrind). See http://valgrind.org/> 1. Can i find out (is there something already built), if the previous instruction / or some instruction was a cache miss. Basically i want to detect cache misses and instructions that are causing this > > 2. Can i find if there was a branch misprediction? > > 3. Can i find if a branch was taken or not taken? > > It would be really great if someone could answer this for me.I suppose you could instrument the existing LLVM JIT to collect this sort of information. Realize that much of LLVM works in the LLVM IR language, and we just 'lower' to assembly. LLVM 'passes' which modify code work by editing the IR, not the assembly, so things like 'branch prediction' and whatnot don't exist at that level. If you want to do it with LLVM, you'll likely need to build most of the infrastructure yourself. If you're interested in what we do have, see llvm/tools/llvm-prof.cpp, llvm/runtime/libprofile and llvm/utils/profile.pl . I have no idea what state this stuff is in, quite possibly bitrotted. Nick Lewycky _______________________________________________ LLVM Developers mailing list LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
On Sep 28, 2008, at 6:43 PM, Ketan Pundlik Umare wrote:> I am an absolute newbie to the compiler community. I am > experimenting a little bit with llvm. > I have a few small questions, i would be really great if someone > could help me. > > 1. Can i find out (is there something already built), if the > previous instruction / or some instruction was a cache miss. > Basically i want to detect cache misses and instructions that are > causing thisWell, you could time it, though, doing that alters the code of course. Small time, in cache, bigger time, in farther away cache, bigger time, in dram, bigger time, page fault. No one in the real world does this. Instead the use tools like Shark or vtune. You can say, show me all the instructions that missed cache and how often they missed.> 2. Can i find if there was a branch misprediction?Likewise. Though, I'm trying to recall if mispredictions where one of the things one could watch for on x86. google around for performance counters on x86.> 3. Can i find if a branch was taken or not taken?:-) gcov will tell you this today.
On Mon, Sep 29, 2008 at 6:30 PM, Mike Stump <mrs at apple.com> wrote:> /* snip */AMD's CodeAnalyst is free and quite wonderful at this job. Shows details about just about anything the CPU reports (and on newer AMD CPU's there is an even more ridiculous amount of information) about every little function call, time they took, multiple profiling modes, etc...