Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pystencils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pycodegen
pystencils
Commits
237648ae
Commit
237648ae
authored
8 years ago
by
Martin Bauer
Browse files
Options
Downloads
Patches
Plain Diff
lbmpy: bugfix & tests for split optimization
parent
93b1d694
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cpu/kernelcreation.py
+8
-2
8 additions, 2 deletions
cpu/kernelcreation.py
sympyextensions.py
+21
-1
21 additions, 1 deletion
sympyextensions.py
with
29 additions
and
3 deletions
cpu/kernelcreation.py
+
8
−
2
View file @
237648ae
...
...
@@ -3,7 +3,7 @@ import sympy as sp
from
pystencils.astnodes
import
SympyAssignment
,
Block
,
LoopOverCoordinate
,
KernelFunction
from
pystencils.transformations
import
resolveFieldAccesses
,
makeLoopOverDomain
,
\
typeAllEquations
,
getOptimalLoopOrdering
,
parseBasePointerInfo
,
moveConstantsBeforeLoop
,
splitInnerLoop
from
pystencils.types
import
TypedSymbol
,
BasicType
,
StructType
from
pystencils.types
import
TypedSymbol
,
BasicType
,
StructType
,
createType
from
pystencils.field
import
Field
import
pystencils.astnodes
as
ast
...
...
@@ -30,11 +30,17 @@ def createKernel(listOfEquations, functionName="kernel", typeForSymbol=None, spl
:return: :class:`pystencils.ast.KernelFunction` node
"""
if
typeForSymbol
is
None
:
typeForSymbol
=
'
double
'
def
typeSymbol
(
term
):
if
isinstance
(
term
,
Field
.
Access
)
or
isinstance
(
term
,
TypedSymbol
):
return
term
elif
isinstance
(
term
,
sp
.
Symbol
):
return
TypedSymbol
(
term
.
name
,
typeForSymbol
[
term
.
name
])
if
isinstance
(
typeForSymbol
,
str
):
return
TypedSymbol
(
term
.
name
,
createType
(
typeForSymbol
))
else
:
return
TypedSymbol
(
term
.
name
,
typeForSymbol
[
term
.
name
])
else
:
raise
ValueError
(
"
Term has to be field access or symbol
"
)
...
...
This diff is collapsed.
Click to expand it.
sympyextensions.py
+
21
−
1
View file @
237648ae
...
...
@@ -326,7 +326,9 @@ def countNumberOfOperations(term):
elif
t
.
func
is
sp
.
Float
:
pass
elif
isinstance
(
t
,
sp
.
Symbol
):
pass
visitChildren
=
False
elif
isinstance
(
t
,
sp
.
tensor
.
Indexed
):
visitChildren
=
False
elif
t
.
is_integer
:
pass
elif
t
.
func
is
sp
.
Pow
:
...
...
@@ -352,6 +354,24 @@ def countNumberOfOperations(term):
return
result
def
countNumberOfOperationsInAst
(
ast
):
"""
Counts number of operations in an abstract syntax tree, see also :func:`countNumberOfOperations`
"""
from
pystencils.astnodes
import
SympyAssignment
result
=
{
'
adds
'
:
0
,
'
muls
'
:
0
,
'
divs
'
:
0
}
def
visit
(
node
):
if
isinstance
(
node
,
SympyAssignment
):
r
=
countNumberOfOperations
(
node
.
rhs
)
result
[
'
adds
'
]
+=
r
[
'
adds
'
]
result
[
'
muls
'
]
+=
r
[
'
muls
'
]
result
[
'
divs
'
]
+=
r
[
'
divs
'
]
else
:
for
arg
in
node
.
args
:
visit
(
arg
)
visit
(
ast
)
return
result
def
matrixFromColumnVectors
(
columnVectors
):
"""
Creates a sympy matrix from column vectors.
:param columnVectors: nested sequence - i.e. a sequence of column vectors
...
...
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