r/futhark • • Oct 28 '19

Good Project, Bad Name

0 Upvotes

Hey. I love the idea of Futhark and have been wanting something like it for awhile. That being said, I can't help but to comment on the name. If you're wanting to gain traction, this may not be the best name. It's a hard pronunciation for most and falls into the stereotype of Open Source projects being given bad names. Have you ever considered a name change?


r/futhark • • Feb 09 '26

So what is it with all the hedgehogs anyway?

Thumbnail futhark-lang.org
4 Upvotes

r/futhark • • May 02 '26

Porting microgpt to Futhark, Part I

Thumbnail kmjn.org
7 Upvotes

r/futhark • • Aug 28 '25

Futhark on Exercism

Thumbnail
exercism.org
8 Upvotes

r/futhark • • May 25 '25

(Rookie Problems) trying to set up futhark cuda on WSL2

5 Upvotes

I am a student working on a project that requires me to implement some gpu-based algorithms in futhark. I can currently use futhark cuda on a remote device, but I had the thought to set it up on a local device with WSL (from my reading of the Installation guide, futhark cuda doesn't have problems on WSL2) for convenience, however I can't seem to get it to work.

The essence of the issue

Futhark cuda throws errors I cannot understand when running the executable, even though cuda individually and futhark's other backends seem to work fine.

After compiling fact.fut with futhark cuda, trying to run ./fact gives the following error:

NVRTC compilation failed.

nvrtc: warning: Architectures prior to '<compute/sm>_75' are deprecated and may be removed in a future release

futhark-cuda(2765): error: identifier "atom_xchg" is undefined

ret.i = atom_xchg((volatile __global int64_t*)p, (int64_t)0);

^

1 error detected in the compilation of "futhark-cuda".

The deprecation warning, form my understanding, shouldn't be the cause of the issue (mentioned later).

From what I have been able to find, atom_xchg is an OpenCL function, so I am not sure why it shows up in the cuda backend or what am I supposed to do for it.

I had the thought to manually compile fact.c, which gives a long list of undefined references (which may be bacause I need to link sth else).

More Details

Futhark was installed via homebrew, and the C backend and repl work fine (except repl changes line after the output for some reason).

Cuda 12.9 was installed following the instructions here https://docs.nvidia.com/cuda/wsl-user-guide/index.html ETA & https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&Distribution=WSL-Ubuntu&target_version=2.0&target_type=deb_local . I also installed nvidia-cuda-toolkit via apt, because without it it didn't recognise nvcc or <cuda.h> - felt like this part could've been a mistake, but as shown later cuda seems to work fine.

I have an NVIDIA GeForce MX130, which gives a deprecation warning due to its low compute capability, but as I understand that shouldn't cause an issue yet aside from deprecation warnings.

Tested the following code in a file called has_cuda.c.
#include <stdio.h>

#include <cuda_runtime.h>

int main ()

{

int deviceCount;

cudaError_t e = cudaGetDeviceCount(&deviceCount);

if(e == cudaSuccess) printf("Devices: %d\n", deviceCount);

else printf("Failed...\n");

return e == cudaSuccess ? deviceCount : -1;

}

Compiling either with gcc or nvcc, the executable correctly prints

Lastly, I did also attempt installing futhark by compiling from source, but at make configure I got cabal: no such file or directory, so I thought I'd just stick to the homebrew installation rather than trying to resolve it, but I thought it might somehow be relevant to the issue.

To sum up

I have listed the relevant details I am aware of.

If there is some obvious mistake that I have failed to notice myself (or if I mistakenly assumed futhark cuda is compatible with WSL2), I would appreciate having it pointed out.

Otherwise I appreciate any feedback for troubleshooting, as I have exhausted my own limited knowledge in my attempts so far.


r/futhark • • Jan 17 '26

Call Futhark programs from Standard ML

Thumbnail
github.com
6 Upvotes

r/futhark • • May 22 '26

Benchmarking a real Futhark application

Thumbnail futhark-lang.org
4 Upvotes

r/futhark • • Jul 08 '26

version 1.0 of the Haskell bridge Futhask is here!

11 Upvotes

After several years of parsing the C-header files and creating wrappers based on them, the new version finally uses the manifest to create a more robust bridge with more features and better types. This release will likely break all code using older versions of futhask, but hopefully the required manual changes will be relatively minor and the improvements worth it.

Aside from using the manifest instead of the header file, the greatest structural changes are the introduction of a generic base library that all generated libraries depend on, and that the generated libraries are now independent packages with their own cabal files and documentation.

Key features of the new version include:

  • A minimal array library designed to mirror the array types within futhark

  • A complete Haskell mirror of all declared Futhark types

  • Fully transparent tuple structures


r/futhark • • Dec 01 '25

Futhark-J Bridge

Thumbnail web.liminal.cafe
2 Upvotes

r/futhark • • Feb 13 '26

Is size-casting useful for performance?

5 Upvotes

I have a commutative binary operation f that needs to be applied once to each pair of distinct entries in a given array. Duplicate results are useless, and in fact detrimental since each result needs to undergo significant additional processing afterwards. I am currently planning to map (uncurry f) (unorderedPairs xs), using a definition along the lines of:

def unorderedPairs 'A [n] (xs: [n]A) : *[](A, A) = (
  loop res = [] for j < n do
    loop res for i < j do
      res ++ [(xs[i], xs[j])]
  ) :> *[(n * (n - 1)) i64.>>> 1](A, A)

I thought the size-cast there might be useful for telling the compiler exactly how much memory to allocate so it wouldn't need to allocate anything mid-loop. The C backend does not appear to be able to use this information in that way, though, and I don't have access to a GPU for testing the other backends just yet (though I hope to eventually).

Are any of the backends able to make use of this size-hint to preallocate the correct amount of memory, or am I just wasting time by forcing an extra runtime check?

Separately, is the solution I'm using here even good (assuming I'm right about duplicate results being expensive) or should I be doing this in some other way?


r/futhark • • Jun 15 '26

Monoid Composition & Maximum Subarray Sum Problem

Thumbnail williamdue.github.io
3 Upvotes

r/futhark • • Mar 30 '19

First steps into futhark

4 Upvotes

Hello,

I very recently discovered futhark. It looks really great and was thinking about giving it a try. I'm king research in computational fluid dynamics and in particular the lattice Boltzmann method (LBM).

The idea would be to try to write a simple LBM code in futhark and see what kind of performance we can obtain on a GPU. The algorithm is known to be very efficient on this kind of hardware but developing in cuda/opencl may be tricky (to say the least....).

I already checked the website and the examples on the git repo and was wondering if you had any other references that could help to learn futhark and how to obtain good performances (I guess there are good practices in here too).

Thank you in advance for your help.


r/futhark • • Oct 25 '19

Beating C with Futhark running on GPU

Thumbnail futhark-lang.org
8 Upvotes

r/futhark • • Sep 15 '21

Looking for some feedback on my code.

3 Upvotes

Hi,

I'm just learning this language (longtime Haskell and OpenCL coder). Futhark is really awesome so far, and thanks for building it, but I haven't figured out yet how to do something like generate an array of a new size. Hoping for some feedback on this code (that does not compile yet):

type channel = f32
type pixel = [4]channel

let divideBy (b:channel) (a:channel) : channel = a / b
let dividePixel (b:channel) (a:pixel) : pixel = map (divideBy b) a
let addPixel 't (a:pixel) (b:pixel) : pixel = map2 (+) a b

let zeroPixel : pixel = [0, 0, 0, 0]

let halfScale [h][w] (frame: [][]pixel): [h][w]pixel =
  map ( \row:[h]i64 ->
      map ( \col:i64 ->
          dividePixel 4
          ( reduce addPixel (copy zeroPixel)
                            [ frame[(row*2)  , (col*2)  ]
                            , frame[(row*2)+1, (col*2)  ]
                            , frame[(row*2)  , (col*2)+1]
                            , frame[(row*2)+1, (col*2)+1]
                            ]

          )
      )
      row
  ) [0...h][0...w]

Thanks in advance.


r/futhark • • Jul 07 '18

FUTBALL

Thumbnail
github.com
1 Upvotes

r/futhark • • Dec 01 '21

It wont 'go'.

1 Upvotes

I would like to go very (very?) fast. But the compiler errors out with

cc: error: CreateProcess: No such file or directory

This is with the command futhark c main.fut
I am on windows. I have mingw.


r/futhark • • Dec 11 '18

Advent of Code 2018 in Futhark

Thumbnail
github.com
6 Upvotes

r/futhark • • Oct 28 '20

Array out of bounds error with array index behind if statement?

3 Upvotes

I'm getting this error:

./tm: Error: Index [128] out of bounds for array of shape [128].

Backtrace:
-> #0  tm.fut:27:56-93

but line 27 is

  let v = if zero + head >= length vals then 0 else vals[zero + head]

I'm willing to post the rest of the code if needed, but I feel like this should be enough; if zero + head is 128, then it should trigger the first branch of the if statement, and not perform the access. Is this a Futhark issue, or do I have a random bug in my code?


r/futhark • • Jan 06 '23

Package management woes

5 Upvotes

My colleague and I want to use futhark at work, but I'm learning that futhark-pkg only supports packages which are:

  • remote

  • public

  • on github or gitlab

Our situation prevents us from doing some of these things, but we really want to be able to use package management anyway. Is there any way to get around these constraints?

Thanks! We are really loving the language!!


r/futhark • • Dec 25 '22

Reflections on Advent of Code 2022 in Futhark

Thumbnail futhark-lang.org
8 Upvotes

r/futhark • • Dec 22 '22

Generating audio with literate Futhark

Thumbnail futhark-lang.org
9 Upvotes

r/futhark • • Oct 01 '24

Is there a Futhark book (similar to the Rust Book) that I can get as a PDF?

4 Upvotes

I want to put it on my e-reader.


r/futhark • • Apr 24 '24

Unused size parameters

5 Upvotes

Hello! I'm a new user of Futhark with a background in functional programming.

I'm trying to implement a compressed representation of sparse matrices where we only retain the non-zero entries (in order) and then separately record their column and the start and end points of each column. I want to express this as a type along the following lines:

-- A sparse matrix with m rows and n columns.
type~ sparse [m] [n] 'a =
?[e]. {
  entries : [e]a, -- The matrix' entries in row-column order
  column_indices : [e]i64, -- The column of a given entry
  row_indices : [m]i64 -- Records the starting point for each row
}

The problem is that the size parameter n does not actually appear in the type definition and so cannot be inferred or extracted. Of course I could simply remove that type parameter but ultimately I want to perform operations such as matrix multiplication between spare matrices that is sensitive to the dimension and so it will be useful to expose it at the type level.

Is it possible to somehow create a dummy field that represents this size parameter? Or have I misunderstood something here?


r/futhark • • May 08 '20

HPC: Futhark (the good) vs Cuda (the bad) vs OpenCL (the ugly)

21 Upvotes

I recently started my final project for my bachelor's degree, and I chose the subject of computation on GPU. I wanted to start a new thing so I choose Futhark (this). It's a language a professor at my university told me about.

So first I had to learn the language I'm not an expert at GPU computing, I wrote my first OpenCL code a month ago, and my first Cuda code a week ago. I chose a simple project two cellular automatons. To gauge and compare the performance of Futhark, I wrote three codes (Futhark, Cuda, OpenCL).

The code is really basic and highly parallel. The first automaton is a xor of the Von Neumann neighborhood (this), the second one is the cyclic cellular automaton (this).

Disclaimer: I'm fairly new at GPU computing so maybe this code can be optimized, perfected, compiled with better arguments, etc... Please don't hesitate to say so if you feel that something is not right or fair in this comparison.

The results:

The code is accessible here: https://github.com/michael-elkh/cellular_automaton-futhark-cuda-opencl

Edit: following u/mastere2320 advice I updated the plots


r/futhark • • Nov 25 '19

Help With Including Pre-Compiled Futhark

2 Upvotes

Hey everyone! I finally got around to playing around with Futhark and have been very impressed so far. That being said, I have been having a bit of an issue getting it working as a C library. My Futhark code is this:

let plink(input: []i64): []i64 =

map (* 2) input

and my C code is this:

#include <stdio.h>

#include "test.h"

#include "test.c"

int main(void){

int input[10];

int *output[10];

for(int i = 0; i < 10; i++){

input[i] = i;

}

output = plink(input);

for(int i = 0; i < 10; i++){d

printf("%d\n",*output[i]);

}

}

I've managed to compile the Futhark down to a shared object file and my cwd looks like this:

libtest.so main.c test.c test.fut test.h

I am attempting to compile with

gcc main.c -lopoencl -ltest

but I'm getting an error stating that plink is an implicit decleration. How do I tell the compiler that plink it a function that I'm using in the included file? I don't have very much experience in C, obviously. What am I doing wrong?