[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
guess.

On Mon, Nov 21, 2016 at 2:53 PM, Gurunath Kadam <gurunath.kadam at gmail.com>
wrote:

> Hi,
>
> 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.
>
> Regards,
> Gurunath
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161121/bec01d49/attachment.html>


More information about the llvm-dev mailing list