14,081 karma · joined Mar 7, 2014 (12y ago) · 1,887 submissions
comment 4y ago · link · parent
comment 5y ago · link · parent
The value of this approach depends on the workload. If it's mostly rasterizing large triangles with simple shaders, then a hardware rasterizer buys you a lot. However, as triangles get smaller, a pure software rasterizer can win (as demonstrated by Nanite). And as you spend more time in shaders, the relative amount of overhead from software rasterization decreases; this was shown in the cudaraster paper[1].
Overall, if we can get simpler hardware with more of a focus on compute power, I think that's a good thing, and I think it's completely fine to call that a GPU.
[1]: https://research.nvidia.com/publication/high-performance-sof...
comment 5y ago · link · parent
[0]: https://vortex.cc.gatech.edu/
[1]: https://vortex.cc.gatech.edu/publications/vortex_micro21_fin...
comment 5y ago · link · parent
If you get to the envelope hardware, you'll find it's just as clever as the exponential and sine generators. There's some info at [1], but it doesn't capture every single thing I found - there are cases where there is a slight amount of additional noise in the amplitude, I'm not sure whether intentional to give more character or an unintentional artifact. That's also missing from the msfa source.
[1]: https://github.com/google/music-synthesizer-for-android/blob...
ETA: Also see https://levien.com/dx7-envelope.html for a somewhat interactive JavaScript implementation of the envelope algorithm. This accurately emulates the envelope shape and quantization of the DX7 (ie it uses the same reduced number of bits to drive its state machine), but I do not claim it is bit-perfect.
comment 5y ago · link · parent
I think Dexed is quite accurate, but this work will allow the authors to take it to the next level. I suspect most people won't be able to hear the difference, however.
comment 5y ago · link · parent
Claiming OpenCL bitcode is "forward compatible" is a pretty strong claim considering that OpenCL has been deprecated for over 3 years, and the main thing you get when searching OpenCL docs on the Apple site is an exhortation to migrate to Metal. To the extent there's a forward compatibility guarantee for AIR, I'm sure it only applies to output generated by official Apple tools, and I'm pretty sure by now there's no way to get those to output a device-scope barrier.
comment 5y ago · link · parent
comment 5y ago · link · parent
[1]: https://github.com/EmbarkStudios/rust-gpu/blob/46c9ea0c9c7b7...
comment 5y ago · link · parent
If you do get a definitive answer from Apple you can share, please follow up here, as I would like to be able to cite it. I would be quite shocked if it's different than what I just said, though.
comment 5y ago · link · parent
[1]: https://docs.google.com/presentation/d/1ilUE_r5WNGlRhfGx71XH...
comment 5y ago · link · parent
comment 5y ago · link · parent
It looks like objc_retainAutoreleasedReturnValue might be exactly what I'm looking for, even if it isn't 100% guaranteed; if I'm understanding, it would be safe, and wouldn't actually leak as long as you had an autorelease pool somewhere in the chain. However, I'm not seeing a binding to it in the objc crate[3]. Sounds like maybe I should file an issue?
Also, given that such a method seems obviously useful, I wonder why it's not being called from these C++ bindings?
[1]: https://developer.apple.com/documentation/metal/mtlcommandbu...
[2]: https://github.com/gfx-rs/metal-rs/blob/master/src/commandbu...
comment 5y ago · link · parent
That said, there would be challenges, and big ones, the more you tried to make it actually Metal compatible. You'd need a C++ compiler for the shaders, and certain idioms (pointers, scalar types other than 32 bits) would be difficult to translate portably.
And as adamnemecek points out, the role of a friendly cross-platform GPU layer is largely being occupied by WebGPU (wgpu in particular in Rust-land). That'll be very comfortable for people used to Metal, as there's been lots of input from Apple folks. However, WGSL is much lower level than Metal Shading Language, and there are lots of important capabilities (subgroups, etc) missing that Metal and other advanced (>DX11) APIs can do.
comment 5y ago · link · parent
comment 5y ago · link · parent
OpenCL is a little strange because older variants don't have advanced atomics (or subgroups), but does have pointers. I'd be curious to know what specific thing is not available on DX12 and Metal but missing in Vulkan, especially because I'm not aware of any DX12 feature on the critical path for OpenCL that's missing from Vulkan (at least as an extension).
comment 5y ago · link · parent
comment 5y ago · link · parent
I suspect that progress on this front will overlap a bit with the previous category, as more often than not you run machine learning workloads on GPU anyway.
comment 5y ago · link · parent
comment 5y ago · link · parent
comment 5y ago · link · parent
Looking at the ISA[2] you can get a glimpse of the magic that happens under the hood to make that happen. (Note: this test case is slightly simplified from what's in the repo for pedagogical reasons).
[1]: https://github.com/linebender/piet-gpu/blob/master/tests/sha...
[2]: https://shader-playground.timjones.io/da907f46d8bace9e5db7bd...
comment 5y ago · link · parent
Okay, I see your point about dev environments. It's like cameras, the best dev toolchain is the one you already have installed on your machine. I'll fix this but want to think about the best way to say it. I still believe there's a case to be made that CUDA is a heavyweight dependency.
comment 5y ago · link · parent
> Using atomics to solve this is rarely a good idea, atomics will make things go slowly, and there is often a way to restructure the problem so that you can let threads read data from a previous dispatch, and break your pipeline into more dispatches if necessary.
This depends on the exact workload, but I disagree. A multiple dispatch solution to prefix sum requires reading the input at least twice, while decoupled look-back is single pass. That's a 1.5x difference if you're memory saturated, which is a good assumption here.
The Nanite talk (which I linked) showed a very similar result, for very similar reasons. They have a multi-dispatch approach to their adaptive LOD resolver, and it's about 25% slower than the one that uses atomics to manage the job queue.
Thus, I think we can solidly conclud that atomics are an essential part of the toolkit for GPU compute.
You do make an important distinction between runtime and development environment, and I should fix that, but there's still a point to be made. Most people doing machine learning work need a dev environment (or use Colab), even if they're theoretically just consuming GPU code that other people wrote. And if you do distribute a CUDA binary, it only runs on Nvidia. By contrast, my stuff is a 20-second "cargo build" and you can write your own GPU code with very minimal additional setup.
[1]: https://github.com/googlefonts/compute-shader-101/blob/main/...
654.
Prefix sum on portable compute shaders(raphlinus.github.io ↗)
116 points · by raphlinus · 5y ago · 15 comments
comment 5y ago · link · parent
I also expect the language support and tooling to get a lot better. The fact that it's based on SPIR-V means it doesn't lock you into any one language, it's possible to develop good tools that run on top of it. That's happening to a large extent in the machine learning space with IREE, much less so here though.
I should also say, I'm not disagreeing with the strategy Blender has chosen, specifically getting vendors to support tuned ports to their hardware. I'm just saying that these specific criticisms of Vulkan (like lacking pointers) aren't really valid.
comment 5y ago · link · parent
If an open source project of this scope came to me for advice, I would absolutely 100% recommend they base their stuff on Vulkan. It's getting very good quite quickly; there's basically nothing holding you back any more if you're willing to use the latest extensions. There is a tendency in open source to move more slowly though, and I understand that.
I agree with you that GLSL/HLSL is a bad programming language, but you can still get your work done in it. I'm personally excited about rust-gpu, but that is not ready yet.
[1]: https://www.khronos.org/registry/vulkan/specs/1.2-extensions...
[2]: https://community.arm.com/arm-community-blogs/b/graphics-gam...
comment 5y ago · link · parent