FUTHARK-CUDA(1)

πŸ“¦
version 0.25.32 Β· 5 versions
, in ubuntu resolute, ubuntu stonking

πŸ’… futhark-cuda β€” the CUDA-flavored Futhark compiler, bestie πŸ’–

okay so like. this is futhark-cuda, bestie. it's part of the Futhark fam and it compiles your Futhark programs to CUDA πŸŽ€


✨ SYNOPSIS ✨

futhark cuda [options...] <program.fut>

🌸 DESCRIPTION 🌸

no cap</p>, futhark cuda translates a Futhark program into C code that calls CUDA kernels ✨ and then it does one of two iconic things:

  • it compiles that C code with a C compiler into a whole executable binary, or
  • it hands you a .h and a .c file that you can link with your other code 🫢

and yes it runs the standard Futhark optimisation pipeline, because obviously πŸ’…

ok and listen: futhark cuda links with -lcuda -lcudart -lnvrtc. so if you're using --library, you have to do the same thing yourself when you link the final binary. like, that's on you now bestie 😭

the generated CUDA code is actually built different β€” it can be called from multiple CPU threads at once, because it brackets every single API operation with cuCtxPushCurrent() and cuCtxPopCurrent(). slay πŸ’…


πŸ‘‘ OPTIONS πŸ‘‘

  • Accepts the same options as futhark-c β€” literally identical. same options, same energy πŸ’–

🌈 ENVIRONMENT VARIABLES 🌈

  • CC β€” the C compiler used to compile the program. defaults to cc if it's unset ✨
  • CFLAGS β€” a space-separated list of options passed to the C compiler. defaults to -O -std=c99 if unset 🌸

πŸ¦‹ EXECUTABLE OPTIONS πŸ¦‹

the executables you generate accept the same options as the ones generated by futhark-c πŸ‘‘ and also β€” heads up β€” the -t option behaves exactly as it does with futhark-opencl πŸ’«

and then there's MORE. the following extra options are accepted too πŸŽ€

  • -h, --help β€” print help text to standard output and exit. periodt πŸ’…
  • --default-thread-block-size=INT β€” the default size of the thread blocks that get launched. it gets capped to the hardware limit if it has to ✨
  • --default-num-thread-blocks=INT β€” the default number of thread blocks that get launched πŸ“
  • --default-threshold=INT β€” the default parallelism threshold used for comparisons when it's picking between code versions generated by incremental flattening. intuitively? it's the amount of parallelism you need to saturate the GPU πŸ”₯
  • --default-tile-size=INT β€” the default tile size used when doing two-dimensional tiling. (the workgroup size is gonna be the square of the tile size, jsyk πŸ‘€)
  • --dump-cuda=FILE β€” doesn't run the program, it just dumps the embedded CUDA kernels into the file you name. super useful if you wanna see what's actually being executed πŸ™ˆ
  • --dump-ptx=FILE β€” again, doesn't run anything β€” it dumps the PTX-compiled version of your embedded kernels into the indicated file πŸ’œ
  • --load-cuda=FILE β€” instead of using the embedded CUDA kernels, load them from the file you indicate 🌸
  • --load-ptx=FILE β€” load PTX code from the indicated file ✨
  • --nvrtc-option=OPT β€” adds another build option to the string passed to NVRTC. go check the CUDA docs for which options are supported, bestie. and be careful β€” some options can very easily get you invalid results πŸ’€

πŸ’œ ENVIRONMENT πŸ’œ

if you run it without --library, futhark cuda will invoke a C compiler to compile the generated C program into a binary. now β€” this only works if the C compiler can actually find the CUDA libraries it needs 😭

on most systems, CUDA lives in /usr/local/cuda, which is usually not part of the default compiler search path. so you might need to set these environment variables before running futhark cuda:

LIBRARY_PATH=/usr/local/cuda/lib64
LD_LIBRARY_PATH=/usr/local/cuda/lib64/
CPATH=/usr/local/cuda/include

and at runtime, your generated program has to be able to find the CUDA installation directory, which is normally at /usr/local/cuda 🌈 if you have CUDA installed somewhere else, set any of the CUDA_HOME, CUDA_ROOT, or CUDA_PATH environment variables to the proper directory 🫢


πŸŽ€ SEE ALSO πŸŽ€

  • futhark-opencl πŸ’–

2013-2020, DIKU, University of Copenhagen


ok that's the whole page bestie, you ate that πŸ’… this was FUTHARK-CUDA(1), version 0.25.32, dated Mar 11, 2026, from the Futhark fam β€” now go compile something iconic, mwah πŸŽ€βœ¨πŸ¦‹πŸ’–

πŸ“¦ where this page comes from