如何直接访问GPU?

发布于 2024-09-11 02:26:51 字数 226 浏览 1 评论 0原文

大多数人都知道,与 GPU 相比,CPU 的设计并不适合进行浮点计算。我想知道如何在没有任何抽象层或驱动程序的情况下使用 GPU 的能力。我可以使用汇编语言、C、C++ 语言对 GPU 进行编程吗(我的意思是如何编程?)。虽然汇编似乎可以帮助我直接访问GPU,但C/C++可能需要一个介质库(例如OpenCL)来访问GPU。

让我问你另一个问题:在没有任何第三方驱动程序的情况下,现代 GPU 的功能有多少会暴露给程序员?

As most of you know CPUs are not well designed to do floating point calculation in contrast to GPUs. I am wondering how to use GPU's power without any abstraction layer or driver. Can I program for a GPU using assembly, C, C++ language (I mean how?). Although assembly seems to help me access the gpu directly, C/C++ are likely to need a medium library (e.g. OpenCL) to access the GPU.

Let me ask you another question: How much of a modern GPU's capability will be exposed to a programmer without any third-party driver?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

西瑶 2024-09-18 02:26:51

这些接口没有记录,因此像 OpenCL 之类的东西是直接对 GPU 进行编程的唯一实用方法。

如果没有驱动程序,您将无法自行对 GPU 的完整功能进行逆向工程。

The interfaces aren't documented so something like OpenCL is the only practical way to program the GPU directly.

Without a driver you would be stuck trying to reverse engineer the complete functionality of the GPU on your own.

完美的未来在梦里 2024-09-18 02:26:51

像 NVDIA 和 ATI 这样的 GPU 制造商都是闭源公司,他们选择不向公众透露 GPU 架构和工作方式。这就是为什么我们不能像使用最多CPU那样直接对GPU进行编程。我们利用 GPU 的能力进行计算的唯一方法是使用提供的库,例如 NVDIA 中的 CUDA。但是有一种可能的方法,您可以直接对 GPU 进行编程以进行计算,但为此您需要进行逆向工程并记录所有 GPU 及其寄存器和系统调用,并且您知道,由于我们的资源和时间有限,这是不可能的。

PS:唯一的其他方法是作为 GPU 核心开发人员登录并与供应商签署 NDA(保密协议),这对于像我们这样的初学者和个人来说可能不会发生。

The GPU manufacturer like NVDIA and ATI are closed source companies which has chosen not to disclose the GPU architecture and working abouts to the general public. This is why we cannot directly program the GPU as we can with the most CPU. The only way we can harness the power of the GPU for calculation is by using the provided library like CUDA in case of NVDIA. But there is a possible way where you can directly program a GPU for calculations but for that you need to reverse engineer and document all GPU and its registers and SYSTEMCALLS and you know that is not possible with our access to limited resources and limited time.

PS: The only other way is to sign in as a core developer for the GPU and sign a NDA (Non Disclosure Agreement) with the vendors which is likely not going to happen for starters and individuals like us.

花间憩 2024-09-18 02:26:51

嗯,本质上,您必须在 Windows 或 Linux 上编写驱动程序。接口可能会根据您尝试使用的芯片组进行记录。英特尔网站上有大量 PDF 文档。然而,这充其量只是一个不简单的练习,您的代码只能在该组硬件上使用。在大多数情况下,仅仅阅读和理解文档就需要花费一些时间,因为“面向对象编程并不是它真正的工作原理”,并且如何执行此操作或操作方法不仅仅记录了硬件和寄存器。然而,如果真的想这样做,你最好的选择是从 Linux 上针对特定芯片组的开源驱动程序开始,然后根据你的 SICK TWISTED 目的进行调整。总而言之,除了学习方面之外,这可能是一个坏主意。

Well, essentially, you would have to write a driver on either Windows or Linux. And the interfaces may be documented depending on which chipset you are trying to use. Intel has loads of PDF documentation on there website. However, this is a non trivial exercise at best and your code would only be able to used on that set of hardware. Meerly reading and understanding the documentation will take a bit of doing in most cases because "OOPs that's not how it really works" and how-tos do this or that aren't documented just the hardware and registers. However if REALLY want to do this your best bet would be to start with open source drivers on Linux for a particular chipset and tweek the to your SICK TWISTED purpose. All in all, other than for the learning aspect, it's prob a BAD idea.

≈。彩虹 2024-09-18 02:26:51

是的,不幸的是,没有像 CPU 那样的单一开放 GPU 架构。甚至单独打开nVidia/AMD架构。太糟糕了。想象一下,您可以像为 x64 CPU 编译程序一样为 GPU 编译程序。这将消除驱动程序、不同操作系统等方面的任何问题,并允许使用 GPU 真正的全部功能。但是,是的,现代软件世界真是一团糟,有 9000 层抽象,没有静态链接,数以百万计的第三方依赖项……在过去,大多数游戏都有自己的操作系统,直接在硬件上运行,没有任何操作系统之间。我并不是说我们应该去那里,但是...

Yeah, unfortunatelly there's no single open GPU architecture, like CPUs have. Or even open nVidia/AMD architectures separately. It sucks. Imagine you could just compile programm for GPU the same way you compile it for x64 CPU. That would remove any problems with drivers, different os, etc. and would allow to use THE TRUE FULL POWER of GPU. But yeah, modern software world is a fkng mess with 9000 layers of abstractions, no static linking, millions third-party dependencies... In old days most games would be there own OS, that would just run directly on hardware without any OS in between. I'm not saying we should go there, but...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文