Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Learning PTX from scratch [closed]

Tags:

cuda

nvidia

ptx

I'd like to start learning PTX, where should I start? Is there any good book/resource to do this?

I already know x86/x64 ASM (more or less) if this might help

like image 261
Marco A. Avatar asked Dec 09 '22 14:12

Marco A.


1 Answers

It will help to be familiar with some other assembly language.

The definitive reference is the PTX guide. Although it serves as a reference manual for the instruction set, it's fairly readable and the first 7 or so chapters start from a relatively basic introduction of parallel thread exection to describe all the concepts.

You may also be interested in the shorter document:

/usr/local/cuda/doc/pdf/Inline_PTX_Assembly.pdf

(on a standard linux install. On windows, just search for "Inline_PTX_Assembly.pdf" The PTX ISA 3.2 document is there as well)

This document discusses enough of PTX so that you can try out little snippets without having to build a complete kernel out of it, if you don't want to.

You should also be aware of the nvcc options that may be useful, such as -ptx to generate ptx code, -G to eliminate most optimizations (which can make the generated ptx hard to understand), and -src-in-ptx which will interleave your lines of kernel source code with the generated ptx, to additionally help with your understanding.

Finally, be aware that PTX is not actually what the machine runs, although it's close to it. PTX is an intermediate code, which will go through an additional compilation step to create SASS code, which is the actual machine code. You can inspect the SASS code as well, using the cuobjdump utility (cuobjdump -sass mycode), but SASS doesn't have the same level of documentation as PTX. So you should start with an understanding of PTX.

like image 144
Robert Crovella Avatar answered Dec 11 '22 10:12

Robert Crovella