Encoding/decoding arrays of floats
Hello! I am exploring the use of Futhark to do computationally intensive tasks on behalf of an Elm client. The kind of computation involves 2D arrays of float32’s. Call such an array a
. Then a typical computation has the form a -> f(a)
. Futhark is a typed functional language that compiles code for the GPU. It can compute f(a)
very quickly.
I’ve rigged up a Python server which hosts the Futhark code and maintains the array a
as part of its state. When the server receives a GET request, it sends a string representation of a
(bad) and then updates a
using f
. See this GitHub repo for code and a detailed README.
What is needed next is a fast way to send arrays of f32’s back and forth between Elm and Python. Once this is done, the client can give a visual display of the array. See this Example for a pure Elm version (press the ‘Step’ or ‘Ready’ buttons to advance the state).
The kind of computation is always at least O(N^2), where the array is NxN, so one reaches the limits of what Elm/Javascript can do pretty quickly. Futhark’s performance is amazing.
To summarize: what is needed for this project to proceed is a way to send arrays of float32s back and forth between Elm and Python.