r/ProgrammingLanguages • Futhark • Feb 03 '26

Custom tuning parameters - a dubious feature

https://futhark-lang.org/blog/2026-02-03-tuning-params.html
20 Upvotes

4 comments sorted by

View all comments

Show parent comment

1

u/Athas Futhark Feb 03 '26

Well, looks like I'm really making "rusty imperative Futhark for Vulkan", because this is also on my todo list lol.

How do you make shaders particularly imperative? Fine-grained communication between work-items is pretty fraught with danger.

I don't think shipping your app as llvm ir and compiling on device is the best solution

It might actually be a good idea - the main problem is that you might not have a decent LLVM available on the device. For compilation of shaders, you know that the driver provides a compiler, so JIT compilation is less of a struggle, and is in fact the standard way of doing it.

2

u/tsanderdev Feb 03 '26 edited Feb 03 '26

How do you make shaders particularly imperative? Fine-grained communication between work-items is pretty fraught with danger.

Shaders have been imperative since the beginning with glsl. Communication between invocations is a problem, but modern vulkan at least has something up to the workgoup level. For more synchronization, I probably need to either wait until invocation forward progress is defined for Vulkan or just split the shaders into multiple pieces and schedule them together with synchronization in the middle. I'm also planning to go into a similar direction as DX12 work graphs, so when that comes to Vulkan, I can probably compile down to that if I keep my semantics vague enough. In the meantime I'll need to emulate that with device generated commands.

Also I want to go a similar route as Rust: the standard library will have some safe abstracted communication primitives and kernels, but you can always go lower level with unsafe code if needed.

It might actually be a good idea - the main problem is that you might not have a decent LLVM available on the device.

The only real option is to ship llvm with your app. Honestly that's not really worse than electron shipping basically 2 copies of V8, so it should actually be fine.