#4928: Add primops for copying/cloning an array
---------------------------------+------------------------------------------
Reporter: tibbe | Owner:
Type: feature request | Status: new
Priority: normal | Component: Runtime System
Version: 7.0.1 | Keywords:
Testcase: | Blockedby:
Os: Unknown/Multiple | Blocking:
Architecture: Unknown/Multiple | Failure: None/Unknown
---------------------------------+------------------------------------------
Comment(by pumpkin):
The new patch has all the primops listed above, but apart from some
trivial testing I did in ghci, it still needs some testing love.
Current issues with the implementation lie mostly in the card copying
logic. Since we allow different source and destination offsets to be
specified in the primop call, and these offsets may not be aligned mod 128
(or whatever the card width is), a single source card may overlap two
destination cards. So the current logic simply optimizes for the current
case, and if the two offsets are aligned mod 128, it uses a
memcpy/memmove, and otherwise it simply memsets the cards all to 1 (so the
GC may do some extra work).
For future work, it's worth seeing how expensive the cmm loop would be
that does the "right" thing for copying the subcard-shifted cards would
be. Also, for tibbe's common case, we're cloning 32-element arrays, which
only have one card. Calling out to memcpy for a single word (it gets
rounded up to a multiple of a word) seems silly, but only profiling can
tell us when it makes sense to call out to memcpy and when it's faster to
just do a (partially unrolled?) memory copy loop in cmm. I expect tibbe's
1-word copy would be a bit faster in cmm, but I don't think any of his
loops are tight enough to care about a single function call.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4928#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs