14,081 karma · joined Mar 7, 2014 (12y ago) · 1,887 submissions
comment 6y ago · link · parent
I've spent a fair amount of time investigating this and have a mostly written blog post on it, but right now I'm kind of sick of the topic - it's a good illustration of how easily software evolves into stuff that's complex and broken.
comment 6y ago · link · parent
[1]: https://www.raspberrypi.org/blog/vulkan-raspberry-pi-first-t...
comment 6y ago · link · parent
One of the reasons I'm excited is that I believe I can get very high performance, and high quality 2D rendering using an evolution of the techniques explored in the piet-metal prototype. This work extensively uses GPU compute capabilities, which are not available in older versions of OpenGL or in WebGL.
comment 6y ago · link · parent
The behavior of shift operations on signed integers will be fixed in C++20 and C2x, as part of the effort to require twos complement representation. It is a massive potential source of UB in currently standardized C and C++.
All the other problems listed remain.
[1]: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p090...
comment 6y ago · link · parent
I wrote some more of my thoughts on the xi Zulip #gpu channel (login required, open to everybody with Github): https://xi.zulipchat.com/#narrow/stream/197075-gpu/topic/Pre...
comment 6y ago · link · parent
comment 6y ago · link · parent
If people want their software to work well across the world, they should not use simple libraries like this. Unfortunately, software that gets it right is complex and messy. See "Text Rendering Hates You" for a taste of some of the issues, or some of my blogging about skribo (I tried to solve some of this for Rust but ran out of time on my contract).
comment 6y ago · link · parent
comment 6y ago · link · parent
The problem with the approach is that it assumes several things that, shall we say, there is not yet evidence for.
1. The disease is relatively mild, certainly less than an order of magnitude more fatal than influenza.
2. It is possible to protect older people and other vulnerable populations while the disease spreads through most of the rest of society.
3. After people recover from the infection, there is lasting immunity.
If these three things are true (and some other things that I'm not going to argue with, including that it will take a long time to get a vaccine), then herd immunity is a reasonable strategy. But let's look at each in turn.
1. The death rate in New York City is already 0.1% of the entire population. Even under very strict assumptions, that we're exactly at the peak of a totally symmetrical curve, and that herd immunity results in 50% of the population being infected, that results in a lower bound of the IFR at 0.4%. Lombardy gives similar results (0.12% of the population directly attributed to Covid-19)
2. Prof. Giesecke admitted that they failed to do so in Sweden. It is not clear how this could be done, as elderly people do not live in a bubble, but rather have lots of workers coming in and out of the facility to help take care of them.
3. SARS-CoV-2 is a new virus, and we just don't have the data yet. You can extrapolate from existing coronaviruses, which suggest that immunity will last at least a year for most people, but there are worrying signs (low antibody production, reports of reinfection that might or might not be testing artifacts). We just don't know.
To me, it was a gamble, and we'll know before long whether it pays off. There were some things that bothered me about Prof. Giesecke, such as his dismissal of the experience of China ("it's a different world"), and other things that made a lot of sense. People who want to believe will be citing this video as authoritative support for their beliefs. If these assumptions turn out not to be consistent with evidence, then people will be citing this video as a case study in how smart people can get stuff horribly wrong.
comment 6y ago · link · parent
I strongly suspect Intel and NVidia are similar here, but haven't experimented.
[1]: http://shader-playground.timjones.io/4d7402168290f8922da5df3...
comment 6y ago · link · parent
If anyone is interested in tuning this and doing a performance comparison, please get in touch. It'd make a good blog post, I think, but already the time I've spent on it is a distraction from the renderer.
comment 6y ago · link · parent
I'll note that these "cache guarantees" in the Vulkan world are the Vulkan 1.2 memory model, and are supported by the latest drivers for AMD, Intel, and NVidia [1]. This recent change is one big reason I'm saying Vulkan + SPIR-V is getting ready for real compute workloads, and this wasn't the case even months ago.
[1]: https://vulkan.gpuinfo.org/listdevicescoverage.php?extension...
comment 6y ago · link · parent
Intel GPU has three hidden strengths:
* CPU <-> GPU communication is cheaper, because they can actually share memory (a separate copy to staging buffers is not needed).
* Latency is potentially lower, although it's not clear to me yet that driver software can take advantage of the potential offered by the hardware. (More empirical measurement is needed)
* Subgroup operations on Intel appear to be wicked-fast, shuffle in particular.
Long story short, I think there is opportunity here that most people aren't exploiting.
comment 6y ago · link · parent
I agree 100% that prefix sum is an excellent litmus test for this platform.
I'll give one example to fill in more specifics. The fence-free descriptor updates described in section 4.4 of your linked paper depend on 64 bit atomics. These are available using the VK_KHR_shader_atomic_int64 extension, and appear (using vulkan.gpuinfo.org) to be available on NV and AMD hardware but not Intel (and basically not at all on mobile). On Vulkan, you query at runtime for the presence of this extension, and swap in the appropriate kernel based on the result of the query; optimizing for hardware without 64 bit atomics might give you a different approach.
Not having to deal with all this is the reason NVidia owns the space :)
comment 6y ago · link · parent
First, the basic principles of how to write an efficient prefix sum are the same as before. Definitely read [1]. Also see [2] for an exploration into how much subgroups help over threadgroup shared memory. In fact, [2] has much of the answer you seek, as it's already written in Vulkan and GLSL (compiling to SPIR-V), though it does miss a direct performance comparison to CUB.
Second, doing this depends on WebGPU exposing threadgroup shared memory and subgroups operations. I'm not sure where the standard and implementations are on this; there are significant challenges. For example, subgroup shuffle is not available in DX12, though subgroup reduce operations such as WavePrefixSum are. So in general an implementation will need to do runtime detection of capabilities and choose a most-optimum kernel based on that.
In theory, it should be possible to achieve comparable performance. But it's likely that WebGPU implementations haven't really been tuned for performance yet, while CUB has seen a ton of work. So, as always, the thing to do is implement and measure.
[1]: https://developer.nvidia.com/gpugems/gpugems3/part-vi-gpu-co...
[2]: https://cachemiss.xyz/blog/parallel-reduce-and-scan-on-the-G...
comment 6y ago · link · parent
If you have a workload that runs really well on GPU, then it can be adapted to run on CPU. There are automated tools for this, but it's not mainstream. To answer one of your questions, spirv-cross has a C++ generator.
There are a bunch of things that are in the space between GPU and traditional scalar CPU. One of the most interesting is Intel's ispc. The Larabee project was also an attempt to build some GPU features into a CPU, and that is evolving into AVX-512. The new mask features are particularly useful for emulating the bitmap of active threads, as this is something that's hard to emulate with traditional SIMD.
I think it would be a very interesting project to build a compiler from SPIR-V compute workloads to optimized multithreaded SIMD, and there are projects exploring that: https://software.intel.com/en-us/articles/spir-v-to-ispc-con...
The main reason this hasn't happened is that when doing optimization it's always better to target the actual hardware than go through layers of translation. If you want to run a neural network on CPU, you're definitely going to get better performance out of matrix multiply code tuned for the specific SIMD implementation than something adapted from GPU. But I think there may still be a niche, especially if it's possible to get "pretty good" results.
For machine learning and imaging workloads in particular, there's probably a lot more juice in having a high level (Halide) or medium level (MLIR) representation, and targeting both GPU and CPU as backends that do optimization specific to their targets.
I'm really interested to see how this space evolves, it feels like there are major opportunities, while the scalar CPU side feels largely mined out to me.
comment 6y ago · link · parent
comment 6y ago · link · parent
comment 6y ago · link · parent
But it's still early days, and I don't think there's a complete solution comparable to either of those yet.
comment 6y ago · link · parent
One thing to keep in mind though, programming directly in Vulkan is too low-level for most users, while OpenCL is a fairly friendly API. We need tools that can compile to SPIR-V and deploy on Vulkan, but high enough level you can express your problem rather than (for example) manually placing pipeline barriers between dispatches. The lack of such tools, and having to build some of my own, is one of the reasons for the slowdown in progress on my renderer project.
comment 6y ago · link · parent
comment 6y ago · link · parent
comment 6y ago · link · parent
If you're doing image-like stuff, Halide is good, there's lots of stuff shipping on it.
One other project I'd add is emu, which is built on wgpu. I think that's closest to the future I have in mind, but still in early stages.