donney.blue at gmail.com
2014-Jul-17 02:10 UTC
[LLVMdev] Using CostModel to estimate machine cycles of each instruction
There is CostModel.cpp since LLVM3, I am wondering if anyone can give me an concrete example on how to use this pass to estimate cycles used in a given IR file. Thank you very much. Don
Jonas Wagner
2014-Jul-18 08:13 UTC
[LLVMdev] Using CostModel to estimate machine cycles of each instruction
Hi Don,
In it's current version, tha pass can only be used via "opt -cost-model
-analyze". It will then print out the estimated cost for every instruction.
In order to be able to use it from a different pass, I split it into a
source and header file (attached).
You can then add it to your pass dependencies, and use it as follows:
custom::CostModelAnalysis &CM =
getAnalysis<custom::CostModelAnalysis>();
Instruction *Inst = ...
unsigned Cost = CM.getInstructionCost(CI);
if (Cost != (unsigned)(-1)) {
// do something
}
Hope this helps!
Jonas
On Thu, Jul 17, 2014 at 4:10 AM, <donney.blue at gmail.com> wrote:
> There is CostModel.cpp since LLVM3, I am wondering if anyone can give me
> an concrete example on how to use this pass to estimate cycles used in a
> given IR file.
>
> Thank you very much.
>
>
> Don
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20140718/0a8b2f10/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CostModel.cpp
Type: text/x-c++src
Size: 15842 bytes
Desc: not available
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20140718/0a8b2f10/attachment.cpp>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CostModel.h
Type: text/x-chdr
Size: 916 bytes
Desc: not available
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20140718/0a8b2f10/attachment.h>
Manish Gupta
2014-Aug-04 17:08 UTC
[LLVMdev] Using CostModel to estimate machine cycles of each instruction
Ya I am using it the same way. By dividing it into header file and including it from "llvm/Analysis/CostModel.h" I believe it returns -1 for all function calls? How can I get make it return cost of each function call inside my basic block. One way is running it recursively on calls and return summaries. Is there a direct way than this? Thanks! Manish On Fri, Jul 18, 2014 at 1:13 AM, Jonas Wagner <jonas.wagner at epfl.ch> wrote:> Hi Don, > > In it's current version, tha pass can only be used via "opt -cost-model > -analyze". It will then print out the estimated cost for every instruction. > > In order to be able to use it from a different pass, I split it into a > source and header file (attached). > > You can then add it to your pass dependencies, and use it as follows: > custom::CostModelAnalysis &CM = getAnalysis<custom::CostModelAnalysis>(); > Instruction *Inst = ... > unsigned Cost = CM.getInstructionCost(CI); > if (Cost != (unsigned)(-1)) { > // do something > } > > Hope this helps! > Jonas > > > On Thu, Jul 17, 2014 at 4:10 AM, <donney.blue at gmail.com> wrote: > >> There is CostModel.cpp since LLVM3, I am wondering if anyone can give me >> an concrete example on how to use this pass to estimate cycles used in a >> given IR file. >> >> Thank you very much. >> >> >> Don >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >> > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140804/9f8d9c0a/attachment.html>
Manish Gupta
2014-Aug-04 17:15 UTC
[LLVMdev] Using CostModel to estimate machine cycles of each instruction
Ya I am using it the same way. By dividing it into header file and including it from "llvm/Analysis/CostModel.h" I believe it returns -1 for all function calls? How can I get make it return cost of each function call inside my basic block. One way is running it recursively on calls and return summaries. Is there a direct way than this? Thanks! On Fri, Jul 18, 2014 at 1:13 AM, Jonas Wagner <jonas.wagner at epfl.ch> wrote:> Hi Don, > > In it's current version, tha pass can only be used via "opt -cost-model > -analyze". It will then print out the estimated cost for every instruction. > > In order to be able to use it from a different pass, I split it into a > source and header file (attached). > > You can then add it to your pass dependencies, and use it as follows: > custom::CostModelAnalysis &CM = getAnalysis<custom::CostModelAnalysis>(); > Instruction *Inst = ... > unsigned Cost = CM.getInstructionCost(CI); > if (Cost != (unsigned)(-1)) { > // do something > } > > Hope this helps! > Jonas > > > On Thu, Jul 17, 2014 at 4:10 AM, <donney.blue at gmail.com> wrote: > >> There is CostModel.cpp since LLVM3, I am wondering if anyone can give me >> an concrete example on how to use this pass to estimate cycles used in a >> given IR file. >> >> Thank you very much. >> >> >> Don >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >> > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140804/d4b6c9e0/attachment.html>
Chandler Carruth
2014-Aug-04 17:15 UTC
[LLVMdev] Using CostModel to estimate machine cycles of each instruction
On Wed, Jul 16, 2014 at 7:10 PM, <donney.blue at gmail.com> wrote:> There is CostModel.cpp since LLVM3, I am wondering if anyone can give me > an concrete example on how to use this pass to estimate cycles used in a > given IR file. >While others have given specific advice about using the cost model analysis, note that it isn't actually measuring the expected cycles. At best it is measuring the size / number of instructions in the LLVM IR. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140804/b46ee17b/attachment.html>