[llvm-dev] CUDA: get thread id in a pass
Gurunath Kadam via llvm-dev
llvm-dev at lists.llvm.org
Mon Nov 21 12:00:12 PST 2016
Sorry, %id is a register! so I need *@llvm.nvvm.read.ptx.sreg.tid.* *I
On Mon, Nov 21, 2016 at 2:53 PM, Gurunath Kadam <gurunath.kadam at gmail.com>
> I am writing my first pass in LLVM.
> I need to collect the threadId in each kernel call and then associate that
> with the corresponding load/store calls.
> I am stuck at extracting the threadId.
> LLVM intrinsic for thread ID declaration:
> threadId @llvm.nvvm.read.ptx.sreg.tid.*
> Actual call:
> ; What is my ID?
> %id = tail call i32 @llvm.nvvm.read.ptx.sreg.tid.x() readnone nounwind
> So in the above LLVM IR instruction *@llvm.nvvm.read.ptx.sreg.tid.** is
> the operand 1, is that right? And then is *%id* operand 0?
> So I need to check for an instruction with the operand type matching above
> expression and then extract operand 0.
> Is my understanding right?
> Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev