For faster navigation, this Iframe is preloading the Wikiwand page for Futhark (programming language).

Futhark (programming language)

Futhark
Paradigmarray, functional
FamilyML
Designed byTroels Henriksen, Cosmin Oancea, Martin Elsman
DeveloperUniversity of Copenhagen[1]
First appeared2014; 10 years ago (2014)
Typing disciplineinferred, static, strong, Hindley–Milner, uniqueness, dependent
OScross-platform
LicenseISC
Websitefuthark-lang.org
Influenced by
APL, Haskell, NESL, Standard ML

Futhark is a multi-paradigm, high-level, functional, data parallel, array programming language. It is a dialect of the language ML, originally developed at UCPH Department of Computer Science (DIKU) as part of the HIPERFIT project.[2] It focuses on enabling data parallel programs written in a functional style to be executed with high performance on massively parallel hardware, especially graphics processing units (GPUs). Futhark is strongly inspired by NESL, and its implementation uses a variant of the flattening transformation, but imposes constraints on how parallelism can be expressed in order to enable more aggressive compiler optimisations. In particular, irregular nested data parallelism is not supported.[3] It is free and open-source software released under an ISC license.

Overview

[edit]

Futhark is a language in the ML family, with an indentation-insensitive syntax derived from OCaml, Standard ML, and Haskell. The type system is based on a Hindley–Milner type system with a variety of extensions, such as uniqueness types and size-dependent types. Futhark is not intended as a general-purpose programming language for writing full applications, but is instead focused on writing compute kernels (not always the same as a GPU kernel) which are then invoked from applications written in conventional languages.[4]

Futhark is named after the first six letters of the Runic alphabet.[5]: 2 

Examples

[edit]

Dot product

[edit]

The following program computes the dot product of two vectors containing double-precision numbers.

def dotprod xs ys = f64.sum (map2 (*) xs ys))

It can also be equivalently written with explicit type annotations as follows.

def dotprod [n] (xs: [n]f64) (ys: [n]f64) : f64 = f64.sum (map2 (*) xs ys))

This makes the size-dependent types explicit: this function can only be invoked with two arrays of the same size, and the type checker will reject any program where this cannot be statically determined.

Matrix multiplication

[edit]

The following program performs matrix multiplication, using the definition of dot product above.

def matmul [n][m][p] (A: [n][m]f64) (B: [m][p]f64) : [n][p]f64 =
  map (\A_row ->
         map (\B_col -> dotprod A_row B_col)
             (transpose B))
      A

This shows how the types enforce that the function is only invoked with matrices of compatible size. Also, it is an example of nested data parallelism.

References

[edit]
  1. ^ "License". futhark-lang.org. Retrieved 2023-03-26. Developed at DIKU
  2. ^ "Home". hiperfit.dk.
  3. ^ Henriksen, Troels; Serup, Niels G. W.; Elsman, Martin; Henglein, Fritz; Oancea, Cosmin (2017). "Futhark: Purely Functional GPU-Programming with Nested Parallelism and In-Place Array Updates" (PDF). Proceedings of the 38th ACM SIGPLAN Conference on Programming Language Design and Implementation. PLDI 2017. ACM.
  4. ^ "Futhark User's Guide". futhark.readthedocs.io.
  5. ^ Troels, Henriksen (November 2017). Design and Implementation of the Futhark Programming Language (PDF) (PhD thesis). University of Copenhagen. Retrieved 2024-05-25.
{{bottomLinkPreText}} {{bottomLinkText}}
Futhark (programming language)
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?