Skip to content

Expose a direct interface to CAS, FAA in haskell

Motivation

The uses of compare-and-swap and fetch-and-add are well known so I won't go into them.

Exposing this in haskell would allow GHC to implement things like genSym in Haskell without the overhead of calling into C.

We might also want to provide some of the other common primitive.

For inspiration here are the ones for gcc:
https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html

Proposal

Expose these primitives with an interface along the lines of

fadd# :: Addr# -> Int# -> State# s -> (# State# s, Int)
cas# :: Addr# -> Int# -> Int# -> State# s -> (# State# s, Int)
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information