[commit: ghc] master: codeGen: inline allocation optimization for clone array primops (1eece45)

git at git.haskell.org git at git.haskell.org
Sat Mar 22 09:32:26 UTC 2014


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/1eece45692fb5d1a5f4ec60c1537f8068237e9c1/ghc

>---------------------------------------------------------------

commit 1eece45692fb5d1a5f4ec60c1537f8068237e9c1
Author: Johan Tibell <johan.tibell at gmail.com>
Date:   Thu Mar 13 09:35:21 2014 +0100

    codeGen: inline allocation optimization for clone array primops
    
    The inline allocation version is 69% faster than the out-of-line
    version, when cloning an array of 16 unit elements on a 64-bit
    machine.
    
    Comparing the new and the old primop implementations isn't
    straightforward. The old version had a missing heap check that I
    discovered during the development of the new version. Comparing the
    old and the new version would requiring fixing the old version, which
    in turn means reimplementing the equivalent of MAYBE_CG in StgCmmPrim.
    
    The inline allocation threshold is configurable via
    -fmax-inline-alloc-size which gives the maximum array size, in bytes,
    to allocate inline. The size does not include the closure header size.
    
    Allowing the same primop to be either inline or out-of-line has some
    implication for how we lay out heap checks. We always place a heap
    check around out-of-line primops, as they may allocate outside of our
    knowledge. However, for the inline primops we only allow allocation
    via the standard means (i.e. virtHp). Since the clone primops might be
    either inline or out-of-line the heap check layout code now consults
    shouldInlinePrimOp to know whether a primop will be inlined.


>---------------------------------------------------------------

1eece45692fb5d1a5f4ec60c1537f8068237e9c1
 compiler/cmm/CLabel.hs                             |    6 +-
 compiler/codeGen/StgCmmExpr.hs                     |   33 +++--
 compiler/codeGen/StgCmmPrim.hs                     |  132 ++++++++------------
 compiler/main/DynFlags.hs                          |   12 +-
 compiler/prelude/primops.txt.pp                    |    4 +
 docs/users_guide/flags.xml                         |   13 ++
 includes/Cmm.h                                     |   31 +++++
 includes/stg/MiscClosures.h                        |    4 +
 rts/Linker.c                                       |    4 +
 rts/PrimOps.cmm                                    |   21 ++++
 testsuite/tests/codeGen/should_run/cgrun064.hs     |   79 +++++++++++-
 testsuite/tests/codeGen/should_run/cgrun064.stdout |    8 ++
 .../tests/perf/should_run/InlineCloneArrayAlloc.hs |   24 ++++
 testsuite/tests/perf/should_run/all.T              |    7 ++
 14 files changed, 279 insertions(+), 99 deletions(-)

Diff suppressed because of size. To see it, use:

    git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 1eece45692fb5d1a5f4ec60c1537f8068237e9c1


More information about the ghc-commits mailing list