data-science

phronmophobic 2024-07-15T17:04:33.800919Z

I've been interested in a cross platform gpu compute option for a while now. I've previously tried vulkan, but even running the most basic computation requires a ton of boilerplate. A project called https://github.com/AnswerDotAI/gpu.cpp recently popped up on hacker news which uses webgpu. Despite the name, webgpu can also run outside the browser and it was relatively easy to make a working example. I've created a small wrapper API inspired by gpu.cpp, https://github.com/phronmophobic/clj-webgpu. I'm not totally settled on the wrapper API, but it should be usable. Does anyone have any benchmarks or workloads that might benefit from running on the GPU? My toy examples seem to be much faster, but it would be interesting to try compare the numbers with some more realistic use cases.

💯 1
🔥 1
🙏 4
🚀 3
grounded_sage 2024-07-18T17:28:13.067019Z

Tagging in @lambdacoder so he knows about convo.

octahedrion 2024-07-16T07:04:29.345659Z

thank you for this! Do you plan to add compilation of a subset of Clojure to shader source ? It would be nice to be able to write shaders in Clojure too

phronmophobic 2024-07-16T17:06:55.201909Z

@octo221, the coupling between shaders and the programs that use them is annoying. I did investigate options for bridging the divide (like a clj->shader compiler), but I think that's currently beyond the scope of what I'm trying to do for now. There are options like https://github.com/markus-wa/lssl, Spir-v, and https://github.com/gfx-rs/naga so maybe that will be worth revisiting in the future.

👍 1
grounded_sage 2024-07-17T01:28:08.003339Z

Amazing. I have had my eyes on WebGPU outside the browser for a bit. For both compute and rendering

grounded_sage 2024-07-17T01:30:33.535189Z

Thanks for taking the lead on this initiative!

👍 1
phronmophobic 2024-07-17T01:31:46.723749Z

I've only tried a few compute examples, but the low level API is comprehensive and can do the rendering side as well.

phronmophobic 2024-07-17T04:25:38.519699Z

@grounded_sage Do you have any particular use cases in mind?

grounded_sage 2024-07-17T04:26:49.000599Z

Native application UI’s generally.

👍 1
grounded_sage 2024-07-17T04:28:56.778439Z

Render target for Humble/Membrane etc

phronmophobic 2024-07-17T04:32:22.075669Z

Both humble ui and membrane use skia which uses the GPU. Is there anything in particular that you don't think is covered?

phronmophobic 2024-07-17T04:32:46.828429Z

Humble UI exposes more of skia's functionality which I think includes their own shading language.

grounded_sage 2024-07-17T04:34:02.153629Z

Not really. Just having more of the stack in Clojure.

👍 1
phronmophobic 2024-07-17T04:37:18.380779Z

Cool. Just trying to keep in mind what use cases folks might be interested in.

grounded_sage 2024-07-17T04:38:18.058729Z

Having access to lower level abstractions without leaving Clojure would open up possibilities that are unclear at present.

1
teodorlu 2024-07-21T12:08:18.953999Z

This is super interesting. Is the shader source code plain WGSL? (like this one: https://github.com/phronmophobic/clj-webgpu/blob/a171dfac26099a35f78ea811e148e91153b1dc05/examples/basic/src/basic/core.clj#L4)

phronmophobic 2024-07-21T15:42:57.055909Z

Webgpu supports wgsl. There's also a project called https://github.com/gfx-rs/wgpu/tree/trunk/naga that can translate between various shader languages. Among the shader languages, there is a standard intermediate language called spir-v which can serve as a target for higher level languages. Basically, there are options.

👍 1
grounded_sage 2024-07-17T10:24:47.117629Z

Currently there is 2D, 3D interfaces, games, VR, AR. The tools to implement these are often radically different and I believe the simplicity Clojure often brings could bridge some gaps.

💯 1
Daniel Slutsky 2024-07-15T18:02:03.335729Z

Interesting 👀 Possibly it is worth sharing at the #uncomplicate channel, where some users of https://neanderthal.uncomplicate.org/ may have an idea about use cases.

👀 1