Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
rtree
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
chrg
rtree
Commits
c387e382
Commit
c387e382
authored
1 year ago
by
chrg
Browse files
Options
Downloads
Patches
Plain Diff
Improve performance even more
parent
f3730fa9
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
rtree-c/package.yaml
+5
-6
5 additions, 6 deletions
rtree-c/package.yaml
rtree-c/rtree-c.cabal
+5
-5
5 additions, 5 deletions
rtree-c/rtree-c.cabal
rtree-c/src/ReduceC.hs
+49
-27
49 additions, 27 deletions
rtree-c/src/ReduceC.hs
with
59 additions
and
38 deletions
rtree-c/package.yaml
+
5
−
6
View file @
c387e382
...
...
@@ -5,7 +5,7 @@ name: rtree-c
# category: categories
# extra-source-files: []
ghc-options
:
-Wall -fno-warn-incomplete-uni-patterns
ghc-options
:
-Wall -fno-warn-incomplete-uni-patterns
-fprof-auto
dependencies
:
-
base >= 4.9 && <
5
...
...
@@ -71,11 +71,10 @@ benchmarks:
source-dirs
:
bench/
main
:
Main.hs
ghc-options
:
-O
-threaded
-fprof-auto
-fprof-late
"-with-rtsopts=-N -p -s -hc -i0.1 -L500"
-O
-threaded
-fprof-late
"-with-rtsopts=-N -p -s -hc -i0.1 -L500"
dependencies
:
-
rtree
-
rtree-c
...
...
This diff is collapsed.
Click to expand it.
rtree-c/rtree-c.cabal
+
5
−
5
View file @
c387e382
...
...
@@ -15,7 +15,7 @@ library
Paths_rtree_c
hs-source-dirs:
src
ghc-options: -Wall -fno-warn-incomplete-uni-patterns
ghc-options: -Wall -fno-warn-incomplete-uni-patterns
-fprof-auto
build-depends:
base >=4.9 && <5
, containers
...
...
@@ -34,7 +34,7 @@ executable rtree-c
Paths_rtree_c
hs-source-dirs:
bin/
ghc-options: -Wall -fno-warn-incomplete-uni-patterns
ghc-options: -Wall -fno-warn-incomplete-uni-patterns
-fprof-auto
build-depends:
base >=4.9 && <5
, co-log
...
...
@@ -64,7 +64,7 @@ test-suite rtree-c-test
Paths_rtree_c
hs-source-dirs:
test/src
ghc-options: -Wall -fno-warn-incomplete-uni-patterns
ghc-options: -Wall -fno-warn-incomplete-uni-patterns
-fprof-auto
build-depends:
base >=4.9 && <5
, containers
...
...
@@ -93,7 +93,7 @@ benchmark rtree-c-bench
Paths_rtree_c
hs-source-dirs:
bench/
ghc-options: -Wall -fno-warn-incomplete-uni-patterns -O2 -threaded
ghc-options: -Wall -fno-warn-incomplete-uni-patterns
-fprof-auto
-O2 -threaded
build-depends:
base >=4.9 && <5
, containers
...
...
@@ -119,7 +119,7 @@ benchmark rtree-c-profile
Paths_rtree_c
hs-source-dirs:
bench/
ghc-options: -Wall -fno-warn-incomplete-uni-patterns -
O -threaded -fprof-auto
-fprof-late "-with-rtsopts=-N -p -s -hc -i0.1 -L500"
ghc-options: -Wall -fno-warn-incomplete-uni-patterns -
fprof-auto -O -threaded
-fprof-late "-with-rtsopts=-N -p -s -hc -i0.1 -L500"
build-depends:
base >=4.9 && <5
, containers
...
...
This diff is collapsed.
Click to expand it.
rtree-c/src/ReduceC.hs
+
49
−
27
View file @
c387e382
...
...
@@ -38,6 +38,7 @@ import Data.Vector.Internal.Check (HasCallStack)
-- import Debug.Trace
import
qualified
Control.Monad.IRTree
as
IRTree
import
Data.Monoid
import
qualified
Language.C
as
C
import
qualified
Language.C.Data.Ident
as
C
...
...
@@ -193,7 +194,19 @@ reduceCFunDef (C.CFunDef spc dec cdecls smt ni) ctx = do
smt'
ni
where
!
ctx'
=
foldr
(`
addInlineExpr
`
IEKeep
)
ctx
(
identifiers
dec
)
!
ctx'
=
foldr
(`
addInlineExpr
`
IEKeep
)
ctx
ids
ids
=
params
dec
params
::
C
.
CDeclarator
C
.
NodeInfo
->
[
C
.
Ident
]
params
=
\
case
C
.
CDeclr
_
[
C
.
CFunDeclr
(
C
.
CFunParamsNew
decls
_
)
_
_
]
_
_
_
->
decls
&
concatMap
\
case
C
.
CDecl
_
items
_
->
items
&
concatMap
\
case
C
.
CDeclarationItem
(
C
.
CDeclr
(
Just
idx
)
_
_
_
_
)
_
_
->
[
idx
]
_ow
->
[]
a
->
don'tHandle
a
a
->
don'tHandle
a
reduceCCompoundBlockItem
::
(
MonadReduce
Lab
m
,
HasCallStack
)
...
...
@@ -511,7 +524,6 @@ reduceCExpr expr ctx = case expr of
inlineTypeDefsCDeclaration
::
C
.
CDeclaration
C
.
NodeInfo
->
Context
->
C
.
CDeclaration
C
.
NodeInfo
inlineTypeDefsCDeclaration
decl
ctx
=
{-# SCC "inlineTypeDefsCDeclaration" #-}
case
decl
of
C
.
CDecl
items
decli
ni
->
C
.
CDecl
(
inlineTypeDefsSpecs
items
ctx
)
(
map
(`
inlineTypeDefsCDI
`
ctx
)
decli
)
ni
...
...
@@ -519,7 +531,6 @@ inlineTypeDefsCDeclaration decl ctx =
inlineTypeDefsSpecs
::
[
C
.
CDeclarationSpecifier
C
.
NodeInfo
]
->
Context
->
[
C
.
CDeclarationSpecifier
C
.
NodeInfo
]
inlineTypeDefsSpecs
r
ctx
=
{-# SCC "inlineTypeDefsSpecs" #-}
r
&
concatMap
\
case
a
@
(
C
.
CTypeSpec
(
C
.
CTypeDef
idx
_
))
->
do
case
Map
.
lookup
idx
.
typeDefs
$
ctx
of
...
...
@@ -534,38 +545,49 @@ inlineTypeDefsCDeclarator
->
Context
->
C
.
CDeclarator
C
.
NodeInfo
inlineTypeDefsCDeclarator
(
C
.
CDeclr
idn
derivedd
st
atr
ni
)
ctx
=
C
.
CDeclr
idn
(
inlineTypeDefs
derivedd
ctx
)
st
atr
ni
C
.
CDeclr
idn
(
map
(
inlineTypeDefsX
ctx
)
derivedd
)
st
atr
ni
inlineTypeDefsX
::
Context
->
C
.
CDerivedDeclarator
C
.
NodeInfo
->
C
.
CDerivedDeclarator
C
.
NodeInfo
inlineTypeDefsX
ctx
=
\
case
C
.
CFunDeclr
(
C
.
CFunParamsNew
x
y
)
b
c
->
C
.
CFunDeclr
(
C
.
CFunParamsNew
(
map
(`
inlineTypeDefsCDeclaration
`
ctx
)
x
)
y
)
b
c
C
.
CArrDeclr
a
b
c
->
C
.
CArrDeclr
a
b
c
C
.
CPtrDeclr
a
b
->
C
.
CPtrDeclr
a
b
a
->
don'tHandle
a
inlineTypeDefsCDI
::
C
.
CDeclarationItem
C
.
NodeInfo
->
Context
->
C
.
CDeclarationItem
C
.
NodeInfo
inlineTypeDefsCDI
di
ctx
=
case
di
of
C
.
CDeclarationItem
a
b
ni
->
C
.
CDeclarationItem
(
inlineTypeDefsCDeclarator
a
ctx
)
b
ni
a
->
don'tHandle
a
inlineTypeDefs
::
forall
d
.
(
Data
d
)
=>
d
->
Context
->
d
inlineTypeDefs
r
ctx
|
hasReplacementTypeDef
ctx
r
=
{-# SCC "inlineTypeDefs" #-}
case
eqT
@
d
@
[
C
.
CDeclarationSpecifier
C
.
NodeInfo
]
of
Just
Refl
->
inlineTypeDefsSpecs
r
ctx
Nothing
->
gmapT
(`
inlineTypeDefs
`
ctx
)
r
|
otherwise
=
r
{-# NOINLINE inlineTypeDefs #-}
hasReplacementTypeDef
::
forall
a
.
(
Data
a
)
=>
Context
->
a
->
Bool
hasReplacementTypeDef
ctx
d
=
case
cast
d
of
Just
(
C
.
CTypeSpec
(
C
.
CTypeDef
idx
_
))
->
case
Map
.
lookup
idx
.
typeDefs
$
ctx
of
Just
IT
Keep
->
Fals
e
Just
(
ITInline
_
)
->
True
Nothing
->
error
(
"could not find typedef:"
<>
show
idx
)
Just
_
->
False
Nothing
->
gmapQl
(
||
)
False
(
hasReplacementTypeDef
ctx
)
d
--
inlineTypeDefs :: forall d. (Data d) => d -> Context -> d
--
inlineTypeDefs r ctx
--
| hasReplacementTypeDef ctx r =
--
case eqT @d @[C.CDeclarationSpecifier C.NodeInfo] of
--
Just Refl -> inlineTypeDefsSpecs r ctx
--
Nothing ->
--
gmapT (`inlineTypeDefs` ctx) r
--
| otherwise =
r
-- {-# NOINLINE inlineTypeDefs #-}
--
-- hasReplacementTypeDef :: forall a. (Data a) => Context -> a -> Bool
--
hasReplacementTypeDef
ctx d = case cast d of
-- Just (C.CTypeSpec (C.CTypeDef idx _)) ->
-- case Map.lookup idx . typeDefs $ ctx of
--
Just ITKeep -> False
--
Just
(
IT
Inline _) -> Tru
e
--
Nothing -> error ("could not find typedef:" <> show idx)
-- Just _ -> False
-- Nothing -> gmapQl (||) False (hasReplacementTypeDef ctx) d
-- {-# NOINLINE
hasReplacementTypeDef
#-}
identifiers
::
forall
a
.
(
Data
a
)
=>
a
->
[
C
.
Ident
]
identifiers
d
=
case
cast
d
of
Just
l
->
[
l
]
Nothing
->
concat
$
gmapQ
identifiers
d
identifiers
d
=
appEndo
(
go
d
)
[]
where
go
::
forall
a'
.
(
Data
a'
)
=>
a'
->
Endo
[
C
.
Ident
]
go
d'
=
case
cast
d'
of
Just
l
->
Endo
(
l
:
)
Nothing
->
gmapQl
(
<>
)
mempty
go
d'
-- instance CReducible C.CExtDecl where
-- reduceC (C.CFunDef spc dec cdecls smt ni) = do
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment