Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
loopy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Andreas Klöckner
loopy
Commits
11d87fcc
Commit
11d87fcc
authored
9 years ago
by
Andreas Klöckner
Browse files
Options
Downloads
Patches
Plain Diff
buffer_array caching
parent
a336b851
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
loopy/buffer.py
+10
-4
10 additions, 4 deletions
loopy/buffer.py
loopy/tools.py
+15
-0
15 additions, 0 deletions
loopy/tools.py
test/test_fortran.py
+2
-0
2 additions, 0 deletions
test/test_fortran.py
with
27 additions
and
4 deletions
loopy/buffer.py
+
10
−
4
View file @
11d87fcc
...
@@ -30,11 +30,14 @@ from loopy.symbolic import (get_dependencies,
...
@@ -30,11 +30,14 @@ from loopy.symbolic import (get_dependencies,
SubstitutionMapper
)
SubstitutionMapper
)
from
pymbolic.mapper.substitutor
import
make_subst_func
from
pymbolic.mapper.substitutor
import
make_subst_func
from
pytools.persistent_dict
import
PersistentDict
from
pytools.persistent_dict
import
PersistentDict
from
loopy.tools
import
LoopyKeyBuilder
from
loopy.tools
import
LoopyKeyBuilder
,
PymbolicExpressionHashWrapper
from
loopy.version
import
DATA_MODEL_VERSION
from
loopy.version
import
DATA_MODEL_VERSION
from
pymbolic
import
var
from
pymbolic
import
var
import
logging
logger
=
logging
.
getLogger
(
__name__
)
# {{{ replace array access
# {{{ replace array access
...
@@ -186,12 +189,15 @@ def buffer_array(kernel, var_name, buffer_inames, init_expression=None,
...
@@ -186,12 +189,15 @@ def buffer_array(kernel, var_name, buffer_inames, init_expression=None,
from
loopy
import
CACHING_ENABLED
from
loopy
import
CACHING_ENABLED
cache_key
=
(
kernel
,
var_name
,
tuple
(
buffer_inames
),
cache_key
=
(
kernel
,
var_name
,
tuple
(
buffer_inames
),
init_expression
,
store_expression
,
within
,
PymbolicExpressionHashWrapper
(
init_expression
),
PymbolicExpressionHashWrapper
(
store_expression
),
within
,
default_tag
,
temporary_is_local
,
fetch_bounding_box
)
default_tag
,
temporary_is_local
,
fetch_bounding_box
)
if
CACHING_ENABLED
:
if
CACHING_ENABLED
:
try
:
try
:
return
buffer_array_cache
[
cache_key
]
result
=
buffer_array_cache
[
cache_key
]
logger
.
info
(
"
%s: buffer_array cache hit
"
%
kernel
.
name
)
return
result
except
KeyError
:
except
KeyError
:
pass
pass
...
@@ -437,7 +443,7 @@ def buffer_array(kernel, var_name, buffer_inames, init_expression=None,
...
@@ -437,7 +443,7 @@ def buffer_array(kernel, var_name, buffer_inames, init_expression=None,
from
loopy
import
tag_inames
from
loopy
import
tag_inames
kernel
=
tag_inames
(
kernel
,
new_iname_to_tag
)
kernel
=
tag_inames
(
kernel
,
new_iname_to_tag
)
if
0
and
CACHING_ENABLED
:
if
CACHING_ENABLED
:
from
loopy.preprocess
import
prepare_for_caching
from
loopy.preprocess
import
prepare_for_caching
buffer_array_cache
[
cache_key
]
=
prepare_for_caching
(
kernel
)
buffer_array_cache
[
cache_key
]
=
prepare_for_caching
(
kernel
)
...
...
This diff is collapsed.
Click to expand it.
loopy/tools.py
+
15
−
0
View file @
11d87fcc
...
@@ -96,6 +96,21 @@ class LoopyKeyBuilder(KeyBuilderBase):
...
@@ -96,6 +96,21 @@ class LoopyKeyBuilder(KeyBuilderBase):
else
:
else
:
PersistentHashWalkMapper
(
key_hash
)(
key
)
PersistentHashWalkMapper
(
key_hash
)(
key
)
class
PymbolicExpressionHashWrapper
(
object
):
def
__init__
(
self
,
expression
):
self
.
expression
=
expression
def
__eq__
(
self
,
other
):
return
(
type
(
self
)
==
type
(
other
)
and
self
.
expression
==
other
.
expression
)
def
__ne__
(
self
,
other
):
return
not
self
.
__eq__
(
other
)
def
update_persistent_hash
(
self
,
key_hash
,
key_builder
):
key_builder
.
update_for_pymbolic_expression
(
key_hash
,
self
.
expression
)
# }}}
# }}}
...
...
This diff is collapsed.
Click to expand it.
test/test_fortran.py
+
2
−
0
View file @
11d87fcc
...
@@ -275,6 +275,8 @@ def test_tagged(ctx_factory):
...
@@ -275,6 +275,8 @@ def test_tagged(ctx_factory):
"
i_inner,j_inner
"
,
"
i_inner,j_inner
"
,
])
])
def
test_matmul
(
ctx_factory
,
buffer_inames
):
def
test_matmul
(
ctx_factory
,
buffer_inames
):
logging
.
basicConfig
(
level
=
logging
.
INFO
)
fortran_src
=
"""
fortran_src
=
"""
subroutine dgemm(m,n,l,a,b,c)
subroutine dgemm(m,n,l,a,b,c)
implicit none
implicit none
...
...
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