CUDA有汇编语言吗?
我问这个是因为我知道有一种方法可以使用二进制文件而不是源文件。
另外,我猜测使用汇编语言,模拟函数指针会更容易。除非GPU上的汇编与CPU上的完全不同。
I'm asking this because I know there's a way to use binary files instead of source files.
Also, I'm guessing that with an assembly language, it would be easier to simulate function pointers. Unless the assembly on a GPU is totally different from the one on a CPU.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可能想看看 PTX。 NVIDIA 在 CUDA 4.0 文档中提供了描述它的文档。
http://developer.nvidia.com/nvidia-gpu-computing-documentation
NVIDIA 将 PTX 描述为“低级并行线程执行虚拟机和指令集架构 (ISA)。PTX 将 GPU 作为数据并行计算设备公开。”不完全像 x86 汇编,但您可能会发现它读起来很有趣。
You might want to take a look at PTX. NVIDIA provides a document describing it in the CUDA 4.0 documentation.
http://developer.nvidia.com/nvidia-gpu-computing-documentation
NVIDIA describes PTX as "Ta low-level parallel thread execution virtual machine and instruction set architecture (ISA). PTX exposes the GPU as a data-parallel computing device." Not exactly like x86 assembly, but you might find it interesting reading.
事实上有两种不同的 CUDA 汇编语言。
PTX 是一种独立于机器的汇编语言,可编译为 SASS,即在特定 GPU 系列上执行的实际操作码。如果您构建 .cubins,那么您正在处理 SASS。大多数 CUDA 运行时应用程序都使用 PTX,因为这使它们能够在原始应用程序之后发布的 GPU 上运行。
另外,如果您的目标是 sm_20(Fermi/GTX 400 系列),则函数指针在 CUDA 中已经存在一段时间了。
There are in fact two different CUDA assembly languages.
PTX is a machine-independent assembly language that is compiled down to SASS, the actual opcodes executed on a particular GPU family. If you build .cubins, you're dealing with SASS. Most CUDA runtime applications use PTX, since this enables them to run on GPUs released after the original application.
Also, function pointers have been in CUDA for a while if you're targeting sm_20 (Fermi/GTX 400 series).
是的,GPU上的组装与CPU上的组装完全不同。
差异之一是 GPU 的指令集并未标准化。 NVidia(以及 AMD 和其他 GPU 供应商)可以并且确实将其指令集从一种 GPU 模型更改为另一种 GPU 模型。
因此 CUDA 不公开汇编语言。那就没有意义了。 (CUDA 的 C 方言以及它们支持的任何其他语言的限制都是由于 GPU 硬件的限制而存在,而不仅仅是因为 Nvidia 讨厌你并想惹恼你。所以即使你可以直接访问底层指令集和汇编语言,你将无法神奇地做你现在做不到的事情
(请注意,NVidia 确实定义了一个“虚拟”指令集,你可以使用它并将其嵌入到你的代码中。但事实并非如此。 指令集,它不直接映射到硬件指令,它只不过是一种更简单的编程语言,“看起来像”汇编语言。
Yes, the assembly on a GPU is totally different from that of a CPU.
One of the differences is that the instruction set for a GPU is not standardized. NVidia (and AMD and other GPU vendors) can and do change their instruction set from one GPU model to the next.
So CUDA does not expose an assembly language. There'd be no point. (And the limitations in CUDA's C dialect, and whatever other languages they support, are there because of limitations in the GPU hardware, not just because Nvidia hates you and wants to annoy you. So even if you had direct access to the underlying instruction set and assembly language, you wouldn't be able to magically do things you can't do now.
(Note that there's NVidia does define a "virtual" instruction set that you can use and embed in your code. But it's not the instruction set, and it doesn't map directly to the hardware instructions. It's little more than a simpler programming language which "looks like" a dialect of assembly