How to directly access a GPU?
Asked Answered
C

4

9

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?

Competent answered 22/7, 2010 at 7:49 Comment(0)
S
9

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.

Seleucia answered 22/7, 2010 at 8:18 Comment(4)
Yes, in a practical sense, it's impossible.Reflux
It's not impossible, it's just REALLY, REALLY, REALLY, a bad idea. To access the hardware you have to essentially write a driver. And spend weeks/months/years learning how the hardware works.Eruptive
<nitpick> AFAIK the interfaces are pretty well documented for current Intel and ATI chips. VIA documentation, otoh, is just a register list.</nitpick>Geraint
How about onboard chips like Intel HD, or APUs like Ryzen? Can I access those?Sava
A
4

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.

Apetalous answered 4/6, 2016 at 17:23 Comment(1)
ATI/AMD employs some of the devs for the open-source radeon drivers, and releases some specs. AFAIK it's really only NVidia that totally refuses to open up anything.Yamauchi
E
1

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.

Eruptive answered 26/7, 2010 at 18:26 Comment(0)
L
1

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

Leupold answered 26/6, 2024 at 17:33 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.