4 ms·
Why would anyone want pointers on the GPU?
by floatboth 5y ago
Why would anyone want pointers on the GPU?
- my123 5y agoAmong other things: C++ on the GPU, with lots of common code between the two worlds. It’s one of the core reasons why CUDA took off. You could adapt your code instead of a full rewrite, even mixing code within the same file. Types are checked at compile time too.
- shmerl 5y agoI'd take Rust over C++ for the GPU.
- my123 5y agoI don’t see why you’d want that, but if you want to do it you can. nvptx64-nvidia-cuda is a Tier 2 Rust target. (see https://doc.rust-lang.org/nightly/rustc/platform-support.html https://doc.rust-lang.org/nightly/rustc/platform-support.htm...)
- DonHopkins 5y agoThat reminds me of the line from the HP technical support person from the "X-Windows Disaster" chapter of the "Unix-Haters" handbook: https://donhopkins.medium.com/the-x-windows-disaster-128d398ebd47#7197 https://donhopkins.medium.com/the-x-windows-disaster-128d398... >My super 3D graphics, then, runs only on /dev/crt1, and X windows runs only on /dev/crt0. Of course, this means I cannot move my mouse over to the 3d graphics display, but as the HP technical support person said “Why would you ever need to point to something that you’ve drawn in 3D?” >Of course, HP claims X has a mode which allows you to run X in the overlay planes and “see through” to the graphics planes underneath. But of course, after 3 months of calls to HP technical support, we agreed that that doesn’t actually work with my particular hardware configuration. You see, I have the top-of-the-line Turbo SRX model (not one, but two on a single workstation!), and they’ve only tested it on the simpler, less advanced configurations. When you’ve got a hip, forward-thinking software innovator like Hewlett-Packard, they think running X windows release 2 is pretty advanced.
- WithinReason 5y agoExcept in this case the question makes sense, you don't have malloc on the GPU (it only allocates from a fixed array), and without dynamic memory allocation you could just use indices to an array any time you would use a pointer on the CPU. This also makes sense if you transfer your datastructure between GPU and CPU, since you don't need to translate pointers.
- DonHopkins 5y agoRight, and you can simply use your finger to point at things you drew on your top-of-the-line Turbo SRX 3D display, instead of your cursor. What does Brecht Van Lommel know about writing 3D graphics code and GPU kernels, anyway? https://www.blenderdiplom.com/en/interviews/400-interview-brecht-van-lommel-on-cycles.html https://www.blenderdiplom.com/en/interviews/400-interview-br... https://devtalk.blender.org/t/2021-08-31-blender-rendering-meeting/20206/16 https://devtalk.blender.org/t/2021-08-31-blender-rendering-m... So the hip, forward-thinking HP technical support person was right after all, decades ago! Makes me wonder why they're not still in business. Such nice hardware! Too bad about the software.
- my123 5y agoYou share the same pointers between CPU and GPU. Pointers in structures for example are one of the use cases. Also as an even more unique option, see cudaHostRegister (on CUDA) to make a CPU buffer not allocated through CUDA accessible from the GPU without a copy, at the same address[1]. This isn’t especially high performance because you have to go through the PCIe bus (on Tegra, this mechanism is even more attractive), it’s however very useful. Your address space is unified between CPU and GPU, with the same pointers used between both. [1] at the same address for host allocations registered through that mechanism is only there on recent GPUs. Allocations done through CUDA still share the same address on both worlds on GPUs where this is unsupported.
- MrLeap 5y agoIt would be nice if I could use function pointers in hlsl. It would let me pass a pointers to distance functions around. Doing anything complicated with signed distance fields is a bit hairbrained without them.