14,081 karma · joined Mar 7, 2014 (12y ago) · 1,887 submissions
comment 1y ago · link · parent
It's absolutely doable. There's the beginning of a tile demo (a scrolling brick wall) in the pico-dvi-rs repo.
comment 1y ago · link · parent
The pico-dvi-rs project has an early prototype of race-the-beam video generation, which I think has a lot of potential, it's going to allow much richer content than a framebuffer on this kind of device. One fun thing we've got going is proportionally spaced bitmap fonts, which is fairly unusual in this form factor. Please get in touch with me if you're interested in driving this thing with Rust.
comment 1y ago · link · parent
You are correct that conflation artifacts are a problem and that doing antialiasing in the right color space can improve quality. Long story short, that's future research. There are tradeoffs, one of which is that use of the system compositor is curtailed. Another is that font rendering tends to be weak and spindly compared with doing compositing in a device space.
comment 1y ago · link · parent
2. I skipped over this in the interest of time. `Nevermark has the central insight, but the full story is more interesting. For each tile, detect whether the line segment crosses the top edge of the tile, and if so, the direction. This gives you a delta of -1, 0, or +1. Then do a prefix sum of these deltas on the sorted tiles. That gives you the winding number at the top left corner of each tile, which in turn lets you compute the sparse fills and also which side to fill within the tile.
[1]: https://fgiesen.wordpress.com/2011/07/09/a-trip-through-the-...
127.
Faster, easier 2D vector rendering [video](youtube.com ↗)
152 points · by raphlinus · 1y ago · 43 comments
comment 1y ago · link · parent
While getting DVI/HDMI out from a RP2040 is an impressive hack, on the RP2350 it's pretty straightforward, and the chip will do standards-compatible 640x480 without overclocking. With overclocking, at least the one I have will do 1280x720 60Hz (albeit with reduced blanking). At those resolutions and the limited amount of RAM, framebuffers are not great (this is why bpp is so spare), so I'm exploring generating video on the fly.
Super fun chip, I highly recommend it for people who want to get into very low level programming.
comment 1y ago · link · parent
comment 1y ago · link · parent
By all means if you're doing a game (or another app with similar build requirements), figure out a shader precompilation pipeline so you're able to compile down to the lowest portable IR for each target, and ship that in your app bundle. Slang is meant for that, and this pipeline will almost certainly contain other tools written in C++ or even without source available (DXC, the Apple shader compiler tools, etc).
There are two main use cases where we want different pieces of shaders to come from different sources of truth, and link them together downstream. One is integrating samplers for (vello_hybrid) sparse strip textures so those can be combined with user paint sources in the user's 2D or 3D app. The other is that we're trying to make the renderer more modular so we have separate libraries for color space conversion and image filters (blur etc). To get maximal performance, you don't want to write out the blur result to a full-resolution texture, but rather have a function that can sample from an intermediate result. See [1] for more context and discussion of that point.
Stitching together these separate pieces of shader is a major potential source of developer friction. There is a happy path in the Rust ecosystem, albeit with some compromises, which is to fully embrace WGSL as the source of truth. The pieces can be combined with string-pasting, though we're looking at WESL as a more systematic approach. With WGSL, you can either do all your shader compilation at runtime (using wgpu for native), or do a build.rs script invoking naga to precompile. See [2] for the main PR that implements the latter in vello_hybrid. In the former case, you can even have hot reloading of shaders; implemented in Vello main but not (yet) vello_hybrid.
To get the same quality of developer experience with Slang, you'd need an implementation in Rust. I think this would be a good thing for Slang.
I've consistently underestimated the importance of developer friction in the past. As a contrast, we're also doing a CPU-only version of Vello now, and it's absolutely night and day, both for development velocity and attracting users. I think it's possible the GPU world gets better, but at the moment it's quite painful. I personally believe doing a Rust implementation of the Slang compiler would be an important step in the right direction, and is worth funding. Whether the rest of the world agrees with me, we'll see.
[1]: https://xi.zulipchat.com/#narrow/channel/197075-vello/topic/...
comment 1y ago · link · parent
But the main problem is not the shader language itself, but the binding model. It's a pretty big mess, and things change as you go in the direction of bindless (descriptor indexing). There are a few approaches to this, certainly reinventing WebGPU is one. Another intriguing approach is blade[1] by Dzmitry Malyshau.
I wish the authors well, but this is a hard road, especially if the goal is to enable more advanced features including compute.
comment 1y ago · link · parent
[1]: https://github.com/NVIDIA/cccl/blob/2d1fa6bc9235106740d9373c...
comment 1y ago · link · parent
Some of the most fun I've had programming assembly has been writing HDMI video scanout kernels for a RP2040 chip[1]. It was a delightful puzzle how to make every single cycle count. It is a great sense of satisfaction of using every one of the 8 "low" registers (the other 8 "high" registers generally take one more cycle to move into a low register, but there are exceptions such as add and compare where they can be free; thus you almost always use a high register for the loop termination comparison). Most satisfying, you can cycle-count and predict the performance very accurately, which is not at all true on modern 64 bit processors. These video kernels could not be written in Rust or C with anywhere near the same performance. Also, in general, Rust compiles to pretty verbose code, which matters a lot when you have limited memory.
Ironically, the reasons for this project being on hold also point to the downside of assembler: since then, the RP2350 chip has come out, and huge parts of the project would need to be rewritten (though it would be much, much more capable than the first version).
[1]: https://github.com/DusterTheFirst/pico-dvi-rs/blob/main/src/...
comment 1y ago · link · parent
That said, I have several times wanted to reach for LLVM intrinsics. In Rust, these are mostly available through a nightly-only feature (in std::intrinsics). One thing that potentially unlocks is "unordered" memory semantics, which are intermediate between nonatomic and relaxed atomics, in that they allow much of the optimization of the former, while also not being UB if there's a data race. In a similar vein is the LLVM "freeze" operation, which makes read from uninitialized memory into a well-defined bit pattern. There's some discussion ([1] [2], for example) of adding those to Rust proper, but it's tricky.
[1]: https://internals.rust-lang.org/t/using-llvms-unordered-read...
[2]: https://internals.rust-lang.org/t/what-if-reading-uninit-ram...
But as another data point, for something I really want to do that's not yet expressible in Rust (fp16 SIMD operations), I would rather write NEON assembly language than LLVM IR. And I am quite certain I don't want to write any of the GPU variants by hand either.
comment 1y ago · link · parent
139.
Towards fearless SIMD, 7 years later(linebender.org ↗)
177 points · by raphlinus · 1y ago · 175 comments
comment 1y ago · link · parent
Also, dtrace.org is excluded, which hosts four individual blogs that surely should qualify.
[1]: https://mastodon.online/@mjd@mathstodon.xyz/1142231895042721...
comment 1y ago · link · parent
comment 1y ago · link · parent
Probably the best overview to find out more is here: https://github.com/AsahiLinux/asahi-audio
comment 1y ago · link · parent
I've got a blog post and associated podcast on Rust SIMD in the pipeline, we'll touch on this.
comment 1y ago · link · parent
This is an odd claim. Clearly Xeon Phi is the shipping version of Larrabee, while Zen 4 is a completely different chip design that happens to run AVX-512. The first shipping Xeon Phi (Knights Corner) used the exact same P54C cores as Larrabee, while as you point out later versions of Xeon Phi switched to Atom.
It is extremely common to refer to all these as Larrabee, for example the Ian Cutress article on the last Xeon Phi chip was entitled "The Larrabee Chapter Closes: Intel's Final Xeon Phi Processors Now in EOL" [1]. Pat Gelsinger's recent interview at GTC [2] also refers to Larrabee. The section from around 44:00 has a discussion of workloads becoming more dynamic, and at 53:36 there's a section on Larrabee proper.
[1]: https://www.anandtech.com/show/14305/intel-xeon-phi-knights-...
comment 1y ago · link · parent
But the biggest problem I'm having is management of buffer space for intermediate objects. That's not relevant to the core of raytracing because you're fundamentally just accumulating an integral, then writing out the answer for a single pixel at the end.
The problem with the GPU raytracing work is that they built hardware and driver support for the specific problem, rather than more general primitives on which you could build not only raytracing but other applications. The same story goes for video encoding. Continuing that direction leads to unmanageable complexity.
Of course today's machines are better, they have orders of magnitude more transistors, and crystallize a ton of knowledge on how to build efficient, powerful machines. But from a design aesthetic perspective, they're becoming junkheaps of special-case logic. I do think there's something we can learn from the paths not taken, even if, quite obviously, it doesn't make sense to simply duplicate older designs.
comment 1y ago · link · parent
Optimization problems like scheduling and circuit routing. Search in theorem proving (the classical parts like model checking, not just LLM).
There's still a lot that is slow and should be faster, or at the very least made to run using less power. GPUs are good at that for graphics, and I'd like to see those techniques applied more broadly.
149.
I want a good parallel computer(raphlinus.github.io ↗)
233 points · by raphlinus · 1y ago · 194 comments
comment 1y ago · link · parent
The value of UB is to clearly document what the obligations are for valid programs. It's not valuable to indiscriminately expose that to programmers at scale without some mechanism to discharge those obligations. I don't think C's choices for UB are defensible in a modern world, and for part of that evidence see how many misconceptions there are in this thread (just to pick one, that at least some people think the move to two's complement means that signed overflow is no longer UB). On the other hand, unsafe Rust's choice to include more UB is defensible (aliasing a mutable reference is UB in unsafe Rust but not UB in C) is defensible, as it makes the whole system safer. And Odin's approach (claiming there's no UB when there actually is UB) is even worse from a "clear communication" perspective.
But maybe I should actually write the blog post some time.