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

GHC ghc-devs at haskell.org
Sat Aug 29 03:22:41 UTC 2015


#10809: Add prefetch{Small}{Mutable}Array[0..3]#
-------------------------------------+-------------------------------------
              Reporter:  ekmett      |             Owner:  simonmar
                  Type:  feature     |            Status:  new
  request                            |
              Priority:  normal      |         Milestone:
             Component:  Runtime     |           Version:  7.10.2
  System                             |
              Keywords:              |  Operating System:  Unknown/Multiple
          Architecture:              |   Type of failure:  Runtime
  Unknown/Multiple                   |  performance bug
             Test Case:              |        Blocked By:
              Blocking:              |   Related Tickets:
Differential Revisions:              |
-------------------------------------+-------------------------------------
 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.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10809>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list