Unboxed mutable variables (was: Easiest way to extend CAS (casMutVar#) to boxed/unboxed Vector elements?)

Johan Tibell johan.tibell at gmail.com
Thu Jan 12 18:55:57 CET 2012


On Thu, Jan 12, 2012 at 12:54 AM, Simon Marlow <marlowsd at gmail.com> wrote:
> For boxed arrays you need a PrimOp of course (like catMutVar#).  For unboxed
> arrays you could get away with FFI, but a PrimOp would be better because it
> could be inline.  But to get it inline would mean modifying the native and
> LLVM backends to support CAS operations.
>
> If I were you I would use FFI for now.  The cost of the out-of-line call is
> much less than the cost of the CAS anyway.  A gcc dependency is not a big
> deal, it's available on all Unix-like platforms and I don't see us removing
> it from the Windows installs any time soon.

In a recent project (http://hackage.haskell.org/package/ekg) I found
myself wanting unboxed mutable integers with CAS semantics (to
implement simple counters). What would be required to support

 (1) unboxed mutable variables, and
 (2) CAS semantics for these.

I guess (2) is easy once you have (1). Just add some new primops.

-- Johan



More information about the Glasgow-haskell-users mailing list