Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-codegen
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
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Christian Heinigk
dune-codegen
Commits
030e2232
Commit
030e2232
authored
8 years ago
by
Dominic Kempf
Browse files
Options
Downloads
Patches
Plain Diff
Handle max/min through functions
parent
e7470548
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
python/dune/perftool/loopy/mangler.py
+20
-0
20 additions, 0 deletions
python/dune/perftool/loopy/mangler.py
python/dune/perftool/loopy/target.py
+0
-18
0 additions, 18 deletions
python/dune/perftool/loopy/target.py
python/dune/perftool/ufl/visitor.py
+17
-2
17 additions, 2 deletions
python/dune/perftool/ufl/visitor.py
with
37 additions
and
20 deletions
python/dune/perftool/loopy/mangler.py
+
20
−
0
View file @
030e2232
...
...
@@ -6,9 +6,17 @@ from dune.perftool.generation import (function_mangler,
from
loopy
import
CallMangleInfo
import
numpy
as
np
def
add_std
(
name
,
dtype
):
if
dtype
.
dtype
.
kind
==
"
f
"
:
return
"
std::{}
"
.
format
(
name
)
@function_mangler
def
dune_math_manglers
(
kernel
,
name
,
arg_dtypes
):
dt
=
arg_dtypes
[
0
]
if
name
==
"
exp
"
:
include_file
(
"
dune/perftool/common/vectorclass.hh
"
,
filetag
=
"
operatorfile
"
)
return
CallMangleInfo
(
"
exp
"
,
...
...
@@ -21,3 +29,15 @@ def dune_math_manglers(kernel, name, arg_dtypes):
arg_dtypes
,
arg_dtypes
,
)
if
name
==
"
max
"
:
return
CallMangleInfo
(
add_std
(
"
min
"
,
dt
),
(
dt
,),
arg_dtypes
,
)
if
name
==
"
min
"
:
return
CallMangleInfo
(
add_std
(
"
min
"
,
dt
),
(
dt
,),
arg_dtypes
,
)
This diff is collapsed.
Click to expand it.
python/dune/perftool/loopy/target.py
+
0
−
18
View file @
030e2232
...
...
@@ -108,24 +108,6 @@ class DuneCExpressionToCodeMapper(CExpressionToCodeMapper):
else
:
return
CExpressionToCodeMapper
.
map_remainder
(
expr
,
enclosing_prec
)
def
map_min
(
self
,
expr
,
enclosing_prec
):
"""
Max/Min is not implemented as a function!
TODO: Revisit this w.r.t. ADL problems
"""
what
=
type
(
expr
).
__name__
.
lower
()
children
=
list
(
set
(
expr
.
children
))
result
=
self
.
rec
(
children
.
pop
(),
PREC_NONE
)
while
children
:
result
=
"
%s(%s, %s)
"
%
(
what
,
self
.
rec
(
children
.
pop
(),
PREC_NONE
),
result
)
return
result
map_max
=
map_min
class
DuneASTBuilder
(
CASTBuilder
):
def
function_manglers
(
self
):
...
...
This diff is collapsed.
Click to expand it.
python/dune/perftool/ufl/visitor.py
+
17
−
2
View file @
030e2232
...
...
@@ -266,10 +266,25 @@ class UFL2LoopyVisitor(ModifiedTerminalTracker):
raise
NotImplementedError
(
"
Power function not really implemented
"
)
def
max_value
(
self
,
o
):
return
prim
.
Max
(
tuple
(
self
.
call
(
op
)
for
op
in
o
.
ufl_operands
))
# NB: There is a pymbolic node Max/Min, which we are intentionally
# avoiding here, as the C++ nature is so much more like a function!
children
=
set
(
self
.
call
(
op
)
for
op
in
o
.
ufl_operands
)
ret
=
children
.
pop
()
while
children
:
ret
=
prim
.
Call
(
prim
.
Variable
(
"
max
"
),
(
ret
,
children
.
pop
()))
return
ret
def
min_value
(
self
,
o
):
return
prim
.
Min
(
tuple
(
self
.
call
(
op
)
for
op
in
o
.
ufl_operands
))
# NB: There is a pymbolic node Max/Min, which we are intentionally
# avoiding here, as the C++ nature is so much more like a function!
children
=
set
(
self
.
call
(
op
)
for
op
in
o
.
ufl_operands
)
ret
=
children
.
pop
()
while
children
:
ret
=
prim
.
Call
(
prim
.
Variable
(
"
min
"
),
(
ret
,
children
.
pop
()))
return
ret
#
# Handler for conditionals, use pymbolic base implementation
...
...
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