Ticket #4928 (closed feature request: fixed)
Add primops for copying/cloning an array in the new codegen
| Reported by: | tibbe | Owned by: | ezyang |
|---|---|---|---|
| Priority: | normal | Milestone: | 7.2.1 |
| Component: | Runtime System | Version: | 7.0.2 |
| Keywords: | Cc: | pumpkingod@…, johan.tibell@…, daniel.is.fischer@… | |
| Operating System: | Unknown/Multiple | Architecture: | Unknown/Multiple |
| Type of failure: | None/Unknown | Difficulty: | |
| Test Case: | Blocked By: | ||
| Blocking: | Related Tickets: |
Description
Daniel Peebles's benchmarks show that copying arrays using a indexArray#/writeArray# loop is much slower than using a (new) primop that calls memcpy. In addition, cloning arrays is slower than it need to be due to newArray# filling the array with a default element, just to have all the elements be overwritten by the contents of the array being cloned.
I suggest we add the following primops:
copyArray# :: Array# a -> Int# -> MutableArray# s a -> Int# -> Int# -> State# s -> State# s copyMutableArray# :: MutableArray# a -> Int# -> MutableArray# s a -> Int# -> Int# -> State# s -> State# s cloneArray# :: Array# a -> Int# -> Int# -> State# s -> (# State# s, Array# a #) cloneMutableArray# :: MutableArray# s a -> Int# -> Int# -> State# s -> (# State# s, MutableArray# s a #) freezeArray# :: MutableArray# s a -> Int# -> Int# -> State# s -> (# State# s, Array# a #) thawArray# :: Array# a -> Int# -> Int# -> State# s -> (# State# s, MutableArray# s a #)
Note that ByteArray# versions can be created using FFI calls to memcpy and thus don't need to be primops.
Attachments
Change History
Note: See
TracTickets for help on using
tickets.

