Opened 4 years ago

Last modified 2 years ago

#10809 new feature request

Add prefetch{Small}{Mutable}Array[0..3]#

Reported by: ekmett Owned by: simonmar
Priority: normal Milestone:
Component: Runtime System Version: 7.10.2
Keywords: prefetch Cc: ekmett, carter
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

We now have a number of prefetch operations:

prefetchAddr0#              prefetchMutableByteArray0#
prefetchAddr1#              prefetchMutableByteArray1#
prefetchAddr2#              prefetchMutableByteArray2#
prefetchAddr3#              prefetchMutableByteArray3#
prefetchByteArray0#         prefetchValue0#
prefetchByteArray1#         prefetchValue1#
prefetchByteArray2#         prefetchValue2#
prefetchByteArray3#         prefetchValue3#

but we are missing variants for fetching slots of a {Small}{Mutable}Array#.

This differs from fetching the item pointed to by the entry at that address, so prefetchValueX does us no good there. Basically this just needs to compute the offset of the appropriate slot and prefetch the memory for that portion of the array as an address like we do indexing into a byte array.

I have some code that could benefit a fair bit from being able to prefetch a binary search on array elements this way, when storing those elements either in a traditional sorted order or Eytzinger layout.

I've verified this experimentally by unsafeCoercing existing bytearray primitives to make them work on other array types.

Change History (2)

comment:1 Changed 4 years ago by ekmett

Cc: carter added

comment:2 Changed 2 years ago by bgamari

Keywords: prefetch added
Note: See TracTickets for help on using tickets.