Opened 5 years ago

Last modified 4 years ago

#10049 new feature request

Lower level memcpy primop

Reported by: chadaustin Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.8.4
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Runtime performance bug Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

I'm doing some really low-level buffer stuff, and it would be quite helpful if there were lower-level memcpy primitives.

I'm thinking something like:

copyBytes# :: Addr# -> Addr# -> Int# -> State# s -> State# s
copyBytes dst src size _ = ...

I would expect it to compile, on x86, into "rep movsb", which is frequently optimal on Ivy Bridge and Haswell.

The other memcpy primitives use Array# or MutableArray#, and it's not clear how, if all you have is an Addr#, how to get the corresponding Array# or MutableArray#. (Can you just cast?)

It may be appropriate to have corresponding 16-bit and 32-bit operations; "rep movsw" and "rep movsd", respectively.

Change History (4)

comment:1 Changed 5 years ago by tibbe

That's indeed the only one we're missing. We have e.g. copyAddrToByteArray#. There's a separate ticket (and Phab entry) for the rep movsw. Austin was working on that.

comment:2 Changed 4 years ago by bgamari

For the record we have had rep movsw support for quite a while as a result of Phab:D166. Someone just needs to expose it as a primop.

Last edited 4 years ago by bgamari (previous) (diff)

comment:3 Changed 4 years ago by tibbe

Phab:D166 still needs to be merged though.

comment:4 Changed 4 years ago by thomie

Type of failure: None/UnknownRuntime performance bug
Note: See TracTickets for help on using tickets.