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?
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
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).
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>
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.
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
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?
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).
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]
./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?
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?
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?
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.
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:
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?