[GHC] #8256: adding locality levels to prefetch# and friends

GHC ghc-devs at haskell.org
Tue Oct 29 08:35:27 UTC 2013


#8256: adding locality levels to prefetch# and friends
-------------------------------------+------------------------------------
        Reporter:  carter            |            Owner:  carter
            Type:  task              |           Status:  patch
        Priority:  normal            |        Milestone:  7.8.1
       Component:  Compiler          |          Version:  7.7
      Resolution:                    |         Keywords:
Operating System:  Unknown/Multiple  |     Architecture:  Unknown/Multiple
 Type of failure:  None/Unknown      |       Difficulty:  Unknown
       Test Case:                    |       Blocked By:
        Blocking:                    |  Related Tickets:  #8252 ,#8107
-------------------------------------+------------------------------------

Comment (by simonpj):

 Thanks

 Do we have any performance tests that show that the new primops actually
 deliver performance improvements?

 I still don't understand this stuff about `can_fail` and hoisting/floating
 out.  Here are the types for a couple of the new primops:
 {{{
  prefetchByteArray2# :: ByteArray# -> Int# -> ByteArray#
  prefetchMutableByteArray1# :: MutableByteArray# s -> Int# -> State# s ->
 State# s
 }}}
 The latter returns a `State#`, which precisely sequences it between two
 other operations on that `State#`.  Simialarly the former returns a
 `ByteArray#` which (I assume) should be used in preference to the earlier
 one. That is, you should use this pattern:
 {{{
 let a1 = prefetchByteArray2# a n in ...a1...
   -- Use a1 rather than a in the body of the 1et
 }}}
 If I have this right, this usage pattern should be thoroughly documented,
 since the type system does not enforce it.

 Now in any loop involving prefetch, the `State#` or the `ByteArray#` is
 going to be carried along as a parameter to the recursive function, so
 there is no danger of it being floated out.

 My gut feel is that we should drop this `can_fail` stuff until we have
 actual evidence that it is benefiting us.  The whole `can_fail` thing is a
 bit of a hack, and I'd rather use it as little as possible.  It's not a
 major deal though.

 Simon

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


More information about the ghc-tickets mailing list