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
9a932226
Commit
9a932226
authored
8 years ago
by
Dominic Kempf
Browse files
Options
Downloads
Patches
Plain Diff
Adjust infrastucture to allow multiple implementations of one pdelab interface
parent
7a875d3b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
python/dune/perftool/pdelab/localoperator.py
+46
-25
46 additions, 25 deletions
python/dune/perftool/pdelab/localoperator.py
python/dune/perftool/pdelab/signatures.py
+206
-176
206 additions, 176 deletions
python/dune/perftool/pdelab/signatures.py
with
252 additions
and
201 deletions
python/dune/perftool/pdelab/localoperator.py
+
46
−
25
View file @
9a932226
...
@@ -192,10 +192,26 @@ def assembler_routine_name():
...
@@ -192,10 +192,26 @@ def assembler_routine_name():
return
"
{}_{}
"
.
format
(
part1
,
part2
)
return
"
{}_{}
"
.
format
(
part1
,
part2
)
def
assembly_routine_signature
(
formdata
):
def
kernel_name
():
arn
=
assembler_routine_name
()
facedir_s
=
get_global_context_value
(
"
facedir_s
"
,
None
)
facedir_n
=
get_global_context_value
(
"
facedir_n
"
,
None
)
facemod_s
=
get_global_context_value
(
"
facemod_s
"
,
None
)
facemod_n
=
get_global_context_value
(
"
facemod_n
"
,
None
)
suffix
=
"
{}{}{}{}
"
.
format
(
"
_facedirs{}
"
.
format
(
facedir_s
)
if
facedir_s
is
not
None
else
""
,
"
_facedirn{}
"
.
format
(
facedir_n
)
if
facedir_n
is
not
None
else
""
,
"
_facemods{}
"
.
format
(
facemod_s
)
if
facemod_s
is
not
None
else
""
,
"
_facemodn{}
"
.
format
(
facemod_n
)
if
facemod_n
is
not
None
else
""
,
)
return
"
{}{}
"
.
format
(
arn
,
suffix
)
def
assembly_routine_signature
():
from
dune.perftool.generation
import
get_global_context_value
from
dune.perftool.generation
import
get_global_context_value
integral_type
=
get_global_context_value
(
"
integral_type
"
)
integral_type
=
get_global_context_value
(
"
integral_type
"
)
form_type
=
get_global_context_value
(
"
form_type
"
)
form_type
=
get_global_context_value
(
"
form_type
"
)
formdata
=
get_global_context_value
(
"
formdata
"
)
# Check if form is linear
# Check if form is linear
from
dune.perftool.pdelab.driver
import
is_linear
from
dune.perftool.pdelab.driver
import
is_linear
...
@@ -204,46 +220,46 @@ def assembly_routine_signature(formdata):
...
@@ -204,46 +220,46 @@ def assembly_routine_signature(formdata):
if
form_type
==
'
residual
'
:
if
form_type
==
'
residual
'
:
if
integral_type
==
'
cell
'
:
if
integral_type
==
'
cell
'
:
from
dune.perftool.pdelab.signatures
import
alpha_volume_signature
from
dune.perftool.pdelab.signatures
import
alpha_volume_signature
return
alpha_volume_signature
()
return
alpha_volume_signature
(
kernel_name
()
)
if
integral_type
==
'
exterior_facet
'
:
if
integral_type
==
'
exterior_facet
'
:
from
dune.perftool.pdelab.signatures
import
alpha_boundary_signature
from
dune.perftool.pdelab.signatures
import
alpha_boundary_signature
return
alpha_boundary_signature
()
return
alpha_boundary_signature
(
kernel_name
()
)
if
integral_type
==
'
interior_facet
'
:
if
integral_type
==
'
interior_facet
'
:
from
dune.perftool.pdelab.signatures
import
alpha_skeleton_signature
from
dune.perftool.pdelab.signatures
import
alpha_skeleton_signature
return
alpha_skeleton_signature
()
return
alpha_skeleton_signature
(
kernel_name
()
)
if
form_type
==
'
jacobian
'
:
if
form_type
==
'
jacobian
'
:
if
integral_type
==
'
cell
'
:
if
integral_type
==
'
cell
'
:
from
dune.perftool.pdelab.signatures
import
jacobian_volume_signature
from
dune.perftool.pdelab.signatures
import
jacobian_volume_signature
return
jacobian_volume_signature
()
return
jacobian_volume_signature
(
kernel_name
()
)
if
integral_type
==
'
exterior_facet
'
:
if
integral_type
==
'
exterior_facet
'
:
from
dune.perftool.pdelab.signatures
import
jacobian_boundary_signature
from
dune.perftool.pdelab.signatures
import
jacobian_boundary_signature
return
jacobian_boundary_signature
()
return
jacobian_boundary_signature
(
kernel_name
()
)
if
integral_type
==
'
interior_facet
'
:
if
integral_type
==
'
interior_facet
'
:
from
dune.perftool.pdelab.signatures
import
jacobian_skeleton_signature
from
dune.perftool.pdelab.signatures
import
jacobian_skeleton_signature
return
jacobian_skeleton_signature
()
return
jacobian_skeleton_signature
(
kernel_name
()
)
if
form_type
==
'
jacobian_apply
'
:
if
form_type
==
'
jacobian_apply
'
:
if
linear
:
if
linear
:
if
integral_type
==
'
cell
'
:
if
integral_type
==
'
cell
'
:
from
dune.perftool.pdelab.signatures
import
jacobian_apply_volume_signature
from
dune.perftool.pdelab.signatures
import
jacobian_apply_volume_signature
return
jacobian_apply_volume_signature
()
return
jacobian_apply_volume_signature
(
kernel_name
()
)
if
integral_type
==
'
exterior_facet
'
:
if
integral_type
==
'
exterior_facet
'
:
from
dune.perftool.pdelab.signatures
import
jacobian_apply_boundary_signature
from
dune.perftool.pdelab.signatures
import
jacobian_apply_boundary_signature
return
jacobian_apply_boundary_signature
()
return
jacobian_apply_boundary_signature
(
kernel_name
()
)
if
integral_type
==
'
interior_facet
'
:
if
integral_type
==
'
interior_facet
'
:
from
dune.perftool.pdelab.signatures
import
jacobian_apply_skeleton_signature
from
dune.perftool.pdelab.signatures
import
jacobian_apply_skeleton_signature
return
jacobian_apply_skeleton_signature
()
return
jacobian_apply_skeleton_signature
(
kernel_name
()
)
else
:
else
:
if
integral_type
==
'
cell
'
:
if
integral_type
==
'
cell
'
:
from
dune.perftool.pdelab.signatures
import
nonlinear_jacobian_apply_volume_signature
from
dune.perftool.pdelab.signatures
import
nonlinear_jacobian_apply_volume_signature
return
nonlinear_jacobian_apply_volume_signature
()
return
nonlinear_jacobian_apply_volume_signature
(
kernel_name
()
)
if
integral_type
==
'
exterior_facet
'
:
if
integral_type
==
'
exterior_facet
'
:
from
dune.perftool.pdelab.signatures
import
nonlinear_jacobian_apply_boundary_signature
from
dune.perftool.pdelab.signatures
import
nonlinear_jacobian_apply_boundary_signature
return
nonlinear_jacobian_apply_boundary_signature
()
return
nonlinear_jacobian_apply_boundary_signature
(
kernel_name
()
)
if
integral_type
==
'
interior_facet
'
:
if
integral_type
==
'
interior_facet
'
:
from
dune.perftool.pdelab.signatures
import
nonlinear_jacobian_apply_skeleton_signature
from
dune.perftool.pdelab.signatures
import
nonlinear_jacobian_apply_skeleton_signature
return
nonlinear_jacobian_apply_skeleton_signature
()
return
nonlinear_jacobian_apply_skeleton_signature
(
kernel_name
()
)
assert
False
assert
False
...
@@ -501,7 +517,12 @@ def generate_kernel(integrals):
...
@@ -501,7 +517,12 @@ def generate_kernel(integrals):
return
knl
return
knl
def
extract_kernel_from_cache
(
tag
):
@backend
(
interface
=
"
generate_kernels_per_integral
"
)
def
generate_kernels_per_integral
(
integrals
):
yield
generate_kernel
(
integrals
)
def
extract_kernel_from_cache
(
tag
,
wrap_in_cgen
=
True
):
# Now extract regular loopy kernel components
# Now extract regular loopy kernel components
from
dune.perftool.loopy.target
import
DuneTarget
from
dune.perftool.loopy.target
import
DuneTarget
domains
=
[
i
for
i
in
retrieve_cache_items
(
"
{} and domain
"
.
format
(
tag
))]
domains
=
[
i
for
i
in
retrieve_cache_items
(
"
{} and domain
"
.
format
(
tag
))]
...
@@ -555,6 +576,11 @@ def extract_kernel_from_cache(tag):
...
@@ -555,6 +576,11 @@ def extract_kernel_from_cache(tag):
# Do the loopy preprocessing!
# Do the loopy preprocessing!
kernel
=
preprocess_kernel
(
kernel
)
kernel
=
preprocess_kernel
(
kernel
)
if
wrap_in_cgen
:
# Wrap the kernel in something which can generate code
signature
=
assembly_routine_signature
()
kernel
=
LoopyKernelMethod
(
signature
,
kernel
)
return
kernel
return
kernel
...
@@ -662,7 +688,7 @@ def cgen_class_from_cache(tag, members=[]):
...
@@ -662,7 +688,7 @@ def cgen_class_from_cache(tag, members=[]):
tparams
=
[
i
for
i
in
retrieve_cache_items
(
'
{} and template_param
'
.
format
(
tag
))]
tparams
=
[
i
for
i
in
retrieve_cache_items
(
'
{} and template_param
'
.
format
(
tag
))]
# Construct the constructor
# Construct the constructor
constructor_knl
=
extract_kernel_from_cache
(
tag
)
constructor_knl
=
extract_kernel_from_cache
(
tag
,
wrap_in_cgen
=
False
)
from
dune.perftool.loopy.target
import
DuneTarget
from
dune.perftool.loopy.target
import
DuneTarget
constructor_knl
=
constructor_knl
.
copy
(
target
=
DuneTarget
(
declare_temporaries
=
False
))
constructor_knl
=
constructor_knl
.
copy
(
target
=
DuneTarget
(
declare_temporaries
=
False
))
signature
=
"
{}({})
"
.
format
(
basename
,
"
,
"
.
join
(
next
(
iter
(
p
.
generate
(
with_semicolon
=
False
)))
for
p
in
constructor_params
))
signature
=
"
{}({})
"
.
format
(
basename
,
"
,
"
.
join
(
next
(
iter
(
p
.
generate
(
with_semicolon
=
False
)))
for
p
in
constructor_params
))
...
@@ -740,7 +766,7 @@ def generate_localoperator_kernels(formdata, data):
...
@@ -740,7 +766,7 @@ def generate_localoperator_kernels(formdata, data):
pattern_baseclass
()
pattern_baseclass
()
enum_alpha
()
enum_alpha
()
with
global_context
(
kernel
=
assembler_routine_name
()):
with
global_context
(
kernel
=
assembler_routine_name
()):
kernel
=
generate_kernel
(
form
.
integrals_by_type
(
measure
))
kernel
=
[
k
for
k
in
get_backend
(
interface
=
"
generate_kernels_per_integral
"
)
(
form
.
integrals_by_type
(
measure
))
]
# Maybe add numerical differentiation
# Maybe add numerical differentiation
if
get_option
(
"
numerical_jacobian
"
):
if
get_option
(
"
numerical_jacobian
"
):
...
@@ -796,7 +822,7 @@ def generate_localoperator_kernels(formdata, data):
...
@@ -796,7 +822,7 @@ def generate_localoperator_kernels(formdata, data):
for
measure
in
set
(
i
.
integral_type
()
for
i
in
jacform
.
integrals
()):
for
measure
in
set
(
i
.
integral_type
()
for
i
in
jacform
.
integrals
()):
with
global_context
(
integral_type
=
measure
):
with
global_context
(
integral_type
=
measure
):
with
global_context
(
kernel
=
assembler_routine_name
()):
with
global_context
(
kernel
=
assembler_routine_name
()):
kernel
=
generate_kernel
(
jacform
.
integrals_by_type
(
measure
))
kernel
=
[
k
for
k
in
get_backend
(
interface
=
"
generate_kernels_per_integral
"
)
(
jacform
.
integrals_by_type
(
measure
))
]
operator_kernels
[(
measure
,
'
jacobian
'
)]
=
kernel
operator_kernels
[(
measure
,
'
jacobian
'
)]
=
kernel
# Generate dummy functions for those kernels, that vanished in the differentiation process
# Generate dummy functions for those kernels, that vanished in the differentiation process
...
@@ -822,7 +848,7 @@ def generate_localoperator_kernels(formdata, data):
...
@@ -822,7 +848,7 @@ def generate_localoperator_kernels(formdata, data):
for
measure
in
set
(
i
.
integral_type
()
for
i
in
jac_apply_form
.
integrals
()):
for
measure
in
set
(
i
.
integral_type
()
for
i
in
jac_apply_form
.
integrals
()):
with
global_context
(
integral_type
=
measure
):
with
global_context
(
integral_type
=
measure
):
with
global_context
(
kernel
=
assembler_routine_name
()):
with
global_context
(
kernel
=
assembler_routine_name
()):
kernel
=
generate_kernel
(
jac_apply_form
.
integrals_by_type
(
measure
))
kernel
=
[
k
for
k
in
get_backend
(
interface
=
"
generate_kernels_per_integral
"
)
(
jac_apply_form
.
integrals_by_type
(
measure
))
]
operator_kernels
[(
measure
,
'
jacobian_apply
'
)]
=
kernel
operator_kernels
[(
measure
,
'
jacobian_apply
'
)]
=
kernel
# Generate dummy functions for those kernels, that vanished in the differentiation process
# Generate dummy functions for those kernels, that vanished in the differentiation process
...
@@ -839,13 +865,8 @@ def generate_localoperator_kernels(formdata, data):
...
@@ -839,13 +865,8 @@ def generate_localoperator_kernels(formdata, data):
def
generate_localoperator_file
(
formdata
,
kernels
,
filename
):
def
generate_localoperator_file
(
formdata
,
kernels
,
filename
):
operator_methods
=
[]
operator_methods
=
[]
for
k
in
kernels
.
values
():
# Make generables from the given kernels
operator_methods
.
extend
(
k
)
for
method
,
kernel
in
kernels
.
items
():
it
,
ft
=
method
with
global_context
(
integral_type
=
it
,
form_type
=
ft
):
signature
=
assembly_routine_signature
(
formdata
)
operator_methods
.
append
(
LoopyKernelMethod
(
signature
,
kernel
))
if
get_option
(
'
timer
'
):
if
get_option
(
'
timer
'
):
include_file
(
'
dune/perftool/common/timer.hh
'
,
filetag
=
'
operatorfile
'
)
include_file
(
'
dune/perftool/common/timer.hh
'
,
filetag
=
'
operatorfile
'
)
...
...
This diff is collapsed.
Click to expand it.
python/dune/perftool/pdelab/signatures.py
+
206
−
176
View file @
9a932226
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