Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loop doacross #1542

Draft
wants to merge 401 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
401 commits
Select commit Hold shift + click to select a range
b317a12
Allow orelse and break continue
phschaad Dec 20, 2023
240ff79
Fix free symbols for loops
phschaad Dec 20, 2023
f35d555
Add tests for arbitrary array sizes
mcopik Dec 20, 2023
aa45e7c
Fix handling of array attributes for arbitrary arrays in Fortran
mcopik Dec 20, 2023
c23eea8
Add failing test
mcopik Dec 20, 2023
7544814
wip
Dec 21, 2023
a2d2654
merge fix
Dec 21, 2023
e88e417
Add first implementation of positional optional arguments in Fortran
mcopik Dec 21, 2023
4fea737
Add more complex type for handling of optional args
mcopik Dec 21, 2023
9829a41
Merge branch 'multi_sdfg' of github.com:spcl/dace into multi_sdfg
mcopik Dec 21, 2023
b685832
add Fortran PRESENT intrinsic
mcopik Dec 21, 2023
136b377
Add support for DOT_PRODUCT intrinsic with DaCe library nodes
mcopik Dec 21, 2023
7e9dfac
WIP hex constant
Dec 23, 2023
eb76104
wip
Dec 23, 2023
1992876
Ensure that intrinsic replaced is not applied to other functions
mcopik Dec 23, 2023
c0a58a9
wip
Dec 24, 2023
653f63b
bugs
Dec 25, 2023
3bfb576
Fix typo
mcopik Dec 27, 2023
abaaf62
WIP
Dec 27, 2023
91b5d95
Support scalar arguments to MERgE
mcopik Dec 27, 2023
e772b16
WIP
Jan 1, 2024
ec7061a
elemental fixes
Jan 3, 2024
239c6e4
argument extractor fixes
Jan 3, 2024
7758edc
Support par decl ranges with arbitrary ranges
mcopik Jan 4, 2024
04732b6
structure fixes
Jan 5, 2024
d30ecc1
more working structs
Jan 6, 2024
92a081a
more working structs and a new bug
Jan 6, 2024
e4176f0
Support module-level type declarations in Fortran
mcopik Jan 6, 2024
dd245a6
WIP
Jan 6, 2024
a8e3f87
some bugs fixed
Jan 7, 2024
496d5db
some bugs fixed
Jan 7, 2024
8a741b8
WIP
Jan 8, 2024
30f09a5
Merge branch 'master' into fortran_phil
phschaad Jan 9, 2024
ca4953d
Merge branch 'master' into fortran_phil
phschaad Jan 9, 2024
c935d62
Sync
phschaad Jan 10, 2024
7f5a5a5
Add struct access to view access lifting pass
phschaad Jan 10, 2024
ff576b2
circular type elimination superpass
Jan 14, 2024
c2a8fb6
Finalize struct view lifting pass
phschaad Jan 15, 2024
178daaa
Merge remote-tracking branch 'origin/multi_sdfg' into fortran_phil
phschaad Jan 15, 2024
538247a
Merge remote-tracking branch 'origin/frontend-add-structure-support' …
phschaad Jan 15, 2024
c42f8be
struct fixes
Jan 16, 2024
9bc3a03
Merge remote-tracking branch 'origin/multi_sdfg' into fortran_phil
phschaad Jan 16, 2024
815328b
Merge remote-tracking branch 'origin/users/lukas/propagation-with-off…
phschaad Jan 16, 2024
9459692
Fix incorrect sotrage type inference for nested struct types
phschaad Jan 16, 2024
cbab7d3
Fix allocating / declaring scalar fields of structs
phschaad Jan 16, 2024
016b21c
Merge branch 'master' into loop_architecture_pt_3
phschaad Jan 17, 2024
567701b
many fixes
Jan 18, 2024
0c2aae3
many fixes
Jan 18, 2024
19214b4
Fix pass
phschaad Jan 19, 2024
b92d25e
yet more fixes for initialization
Jan 21, 2024
9900043
Merge branch 'multi_sdfg' of https://github.com/spcl/dace into multi_…
Jan 21, 2024
3f55bc8
init test
Jan 22, 2024
06cf92f
tests updated
Jan 22, 2024
eef71e4
When triggering recursive allocation of nested data, use the SDFG dat…
alexnick83 Jan 23, 2024
61c9490
bugfixes
Jan 23, 2024
28177c7
Merge remote-tracking branch 'origin/master' into loop_architecture_pt_3
phschaad Jan 24, 2024
69eaf92
Provide pass compatibility check for passes and transformations
phschaad Jan 24, 2024
d932a79
bug found and isolated
Jan 24, 2024
af18052
fix
Jan 25, 2024
975d79e
Update passes and transformations
phschaad Jan 25, 2024
80e96bb
Make sure auto opt "works"
phschaad Jan 26, 2024
93baf8e
Fix handling of optional args in Fortran
mcopik Jan 26, 2024
11f8355
fix for comparison
Jan 26, 2024
a9c552c
Update test case
mcopik Jan 26, 2024
4371484
Add missing initialization to array nodes
mcopik Jan 26, 2024
6d8ee01
Correctly handle null initialization in Fortran parser
mcopik Jan 26, 2024
1c4c6e0
bug found and isolated
Jan 26, 2024
5f52add
bug found and isolated
Jan 26, 2024
dc1e352
new failing test with structs
Jan 26, 2024
eb53398
Fix parsing of variable definition within a Fortran structure
mcopik Jan 26, 2024
93107f5
Add dedicated data structure to parse Fortran structure
mcopik Jan 26, 2024
5e59ea6
Extend Fortran struct handling
mcopik Jan 27, 2024
69dc0f1
more bugs found
Jan 27, 2024
631af73
more bugs found and fixed
Jan 28, 2024
9c3f993
Add derivation of offsets for assumed shapes
mcopik Jan 29, 2024
a88259f
Merge branch 'multi_sdfg' of github.com:spcl/dace into multi_sdfg
mcopik Jan 29, 2024
fd2579d
fix
Jan 29, 2024
c9e0eb0
fix
Jan 29, 2024
a9793d1
Fix scalar struct member views being promoted to symbols
phschaad Jan 29, 2024
9b7f840
Refactor SDFG List to CFG List
phschaad Jan 29, 2024
bc8679f
Make sure no old style `sdfg_list` calls remain
phschaad Jan 29, 2024
68a6b62
Fix deserializataion for control flow regions
phschaad Jan 29, 2024
40cd861
Fix deserialization
phschaad Jan 29, 2024
482c30f
Remove legacy calls to sdfg_list
phschaad Jan 29, 2024
ae2e068
Merge branch 'refactor_sdfg_list_to_cfg_list' into loop_architecture_…
phschaad Jan 29, 2024
e596496
Fix transformation architecture
phschaad Jan 29, 2024
39ad527
Fix broken implementation of name range nodes in tasklet writer
mcopik Jan 29, 2024
deed8e3
Initializat optional field for symbols in Fortran frontend
mcopik Jan 29, 2024
27a350e
Address review comments, update docs
phschaad Jan 29, 2024
4404126
Add missing line number definition in Fortran frontend
mcopik Jan 29, 2024
697e8f6
Move web-browser based tests to a separate directory
mcopik Jan 29, 2024
61c9267
Move web-browser based tests to a separate directory
mcopik Jan 29, 2024
706c702
Move a broken test with unsupported feature to a separate subdirectory
mcopik Jan 29, 2024
f36ba3f
Add missing structure initialization for Fortran AST manipulations
mcopik Jan 29, 2024
1671e0f
Add testcase that exposes problems with struct reads on isedges
phschaad Jan 29, 2024
5aeec96
Fix blunder
phschaad Jan 29, 2024
7e2aa45
Merge remote-tracking branch 'origin/refactor_sdfg_list_to_cfg_list' …
phschaad Jan 29, 2024
81b6972
Fix incorrect arg passing
phschaad Jan 29, 2024
4ca1fea
Fix control flow inlining
phschaad Jan 29, 2024
303c605
Fix control flow region traversal
phschaad Jan 29, 2024
c1ec438
Bugfixes
phschaad Jan 29, 2024
7fa30b3
big fix!
Jan 29, 2024
829202a
Merge branch 'multi_sdfg' of https://github.com/spcl/dace into multi_…
Jan 29, 2024
562e0be
fixes
Jan 29, 2024
4125d67
Support structure refs as arguments to some of the intrinsics
mcopik Jan 29, 2024
d6427db
Merge branch 'multi_sdfg' of github.com:spcl/dace into multi_sdfg
mcopik Jan 29, 2024
a966044
Fix test
phschaad Jan 30, 2024
01b3593
Fix missing reset of cfg list for inlining
phschaad Jan 30, 2024
8af34d5
Fix test
phschaad Jan 30, 2024
85e5876
Merge remote-tracking branch 'origin/master' into fortran_phil
phschaad Jan 30, 2024
350dd08
Merge remote-tracking branch 'origin/loop_architecture_pt_3' into for…
phschaad Jan 30, 2024
03e976c
Added loops to fortran frontend
phschaad Jan 30, 2024
2d3d77e
Ensure compatibility checks
phschaad Jan 30, 2024
a89c64d
Cleanup
phschaad Jan 30, 2024
9c06e06
Cleanup
phschaad Jan 30, 2024
a608779
Cleanup
phschaad Jan 30, 2024
47e171c
interesting
Jan 30, 2024
926ad49
Fix codegen bug (for loops)
phschaad Jan 31, 2024
03f0d75
Fix SDFG references for complex loop condition tests
phschaad Jan 31, 2024
aad6c28
Make dreport file sorting based on version instead of state id
phschaad Jan 31, 2024
a04bf0b
Fix dinstr test
phschaad Jan 31, 2024
22b7456
Fix duplicate control flow block naming for while condition checks
phschaad Jan 31, 2024
e8b4871
Merge remote-tracking branch 'origin/multi_sdfg' into fortran_phil
phschaad Jan 31, 2024
cd12e2c
Merge branch 'loop_architecture_pt_3' into fortran_phil
phschaad Jan 31, 2024
311e78b
Fix conflicts
phschaad Jan 31, 2024
cdb9361
Implemented custom setter method for transient property.
alexnick83 Feb 1, 2024
bee7e9b
Do not allocate (i.e., write declaration) scalar struct members.
alexnick83 Feb 1, 2024
656061a
InterstateEdgeUnparser now handles struct members.
alexnick83 Feb 1, 2024
952c09d
Fixed test.
alexnick83 Feb 1, 2024
a46c802
Take into account case of non-data struct members.
alexnick83 Feb 2, 2024
abcd09e
Workflow debugging
phschaad Feb 2, 2024
ada5bc8
Bugfixes for global module variables
phschaad Feb 2, 2024
4b1145e
Bugfixes for global module variables
phschaad Feb 2, 2024
144b025
Merge remote-tracking branch 'origin/struct_access_interstate_edge_bu…
phschaad Feb 2, 2024
3e779fd
pytest debugging
phschaad Feb 2, 2024
809fa13
Merge remote-tracking branch 'origin/multi_sdfg' into fortran_phil
phschaad Feb 2, 2024
43ffeb7
big fixes!
Feb 3, 2024
96caa84
Merge branch 'multi_sdfg' of https://github.com/spcl/dace into multi_…
Feb 3, 2024
b420525
more tests
Feb 3, 2024
e0194e2
more bugs and more bugs fixed
Feb 4, 2024
0386e03
Fix double type emission
phschaad Feb 5, 2024
b4d50ac
Fix wrong operator on deleting allocated structs
phschaad Feb 5, 2024
e2561ed
Fix type inference for array of struct member accesses
phschaad Feb 5, 2024
9831ac1
fixes
Feb 5, 2024
5675594
fixes
Feb 5, 2024
0b70264
Implement derivation of type of structure fields
mcopik Feb 5, 2024
01e9c79
Remove debug printouts
mcopik Feb 5, 2024
1c7a569
Fixes
phschaad Feb 5, 2024
4111578
fixes
Feb 5, 2024
8e8a8dd
Merge branch 'multi_sdfg' of https://github.com/spcl/dace into multi_…
Feb 5, 2024
24a3d8a
Revert two changes
phschaad Feb 6, 2024
dd0aec5
Merge remote-tracking branch 'origin/multi_sdfg' into fortran_phil
phschaad Feb 6, 2024
3d94833
Merge branch 'loop_architecture_pt_3' into fortran_phil
phschaad Feb 6, 2024
83e7d74
Cleanup
phschaad Feb 6, 2024
a70c9c1
Fixes that allow us to validate all 5 big SDFGs
Feb 6, 2024
4ed9781
Add state data dependency analysis pass
phschaad Feb 7, 2024
9719f12
Add pass to analyze data dependencies of control flow regions
phschaad Feb 7, 2024
8c8b326
More fixes
Feb 7, 2024
162f3e2
More fixes
Feb 7, 2024
dd8135a
Pass adaptations
phschaad Feb 8, 2024
288b6ae
Initial framework for loop carry dependency analysis pass
phschaad Feb 8, 2024
a2ac00c
Fix handling of assumed shapes within struct
mcopik Feb 8, 2024
c84eb92
Fix non-transient struct views from struct view lifting pass
phschaad Feb 8, 2024
55e4327
Merge branch 'multi_sdfg' of github.com:spcl/dace into multi_sdfg
mcopik Feb 8, 2024
3eb5552
More fixes
Feb 8, 2024
cddfce6
More bugs
Feb 8, 2024
297dcef
Nested structures and struct-arrays in non-transient top-level data m…
alexnick83 Feb 9, 2024
eada164
Fixed import issue with Python 3.7.
alexnick83 Feb 9, 2024
12edd26
StructureViews are simple pointers to the base type of the Structure.…
alexnick83 Feb 9, 2024
c14f7f5
When generating a StructureView, use the same name for the underlying…
alexnick83 Feb 9, 2024
37d3de2
Consider elements of StructArrays as pseudo-scalars.
alexnick83 Feb 9, 2024
f23a1c1
Work in progress on assigning symbols for structures
mcopik Feb 9, 2024
c9d59ac
Merge branch 'multi_sdfg' of github.com:spcl/dace into multi_sdfg
mcopik Feb 9, 2024
4524932
Extend structure definitions in Fortran
mcopik Feb 9, 2024
43bdf61
Implement pass over subroutine structures to handle assumed array sizes
mcopik Feb 9, 2024
1d0026d
minor
Feb 10, 2024
d16a583
Merge branch 'multi_sdfg' of https://github.com/spcl/dace into multi_…
Feb 10, 2024
e8ca982
Provide a RAW loop carry dependency analysis pass
phschaad Feb 10, 2024
75e6eef
Apply subroutine args pass only to the toplevel subroutine
mcopik Feb 10, 2024
dde20e7
Ignore literals
mcopik Feb 10, 2024
8342f30
Merge branch 'multi_sdfg' of https://github.com/spcl/dace into multi_…
Feb 10, 2024
be9262d
Consider `id` to be a symbol when it appears in a string (symbolic ex…
alexnick83 Feb 12, 2024
d844c32
Merge branch 'multi_sdfg' of https://github.com/spcl/dace into multi_…
Feb 12, 2024
1ab7a59
Rename test module.
alexnick83 Feb 13, 2024
2ed0f16
Merge branch 'multi_sdfg' into fix-non-transient-nested-data-definitions
alexnick83 Feb 13, 2024
87f6e4c
Merge branch 'multi_sdfg' of https://github.com/spcl/dace into multi_…
Feb 13, 2024
42dbefb
Adapt more passes and auto optimizations
phschaad Feb 13, 2024
72fcefe
Support structure references in Fortran normalization
mcopik Feb 13, 2024
2a3a132
Enable normalization for SDFGs generated from a file
mcopik Feb 13, 2024
ad2ac74
Remove debug printout
mcopik Feb 13, 2024
08046fe
local
Feb 13, 2024
ccee346
local
Feb 13, 2024
c6a92aa
Adapt move loop into map
phschaad Feb 14, 2024
ea5cd60
Bugfix
phschaad Feb 14, 2024
2cfacce
Support structure references in Fortran normalization
mcopik Feb 13, 2024
6618fab
Enable normalization for SDFGs generated from a file
mcopik Feb 13, 2024
fda380f
Remove debug printout
mcopik Feb 13, 2024
60600cc
Merge branch 'multi_sdfg' of github.com:spcl/dace into multi_sdfg
mcopik Feb 15, 2024
72f1d20
dissapearing variable fix
Feb 15, 2024
b805446
dissapearing variable fix
Feb 15, 2024
ad6d4f9
Extend offset normalization with global variables
mcopik Feb 16, 2024
f33198c
Fix forgottten initialization
mcopik Feb 16, 2024
efe5a20
Merge branch 'multi_sdfg' of github.com:spcl/dace into multi_sdfg
mcopik Feb 16, 2024
8281de6
Implement parsing of interface blocks
mcopik Feb 16, 2024
280e5a2
changes
Feb 16, 2024
da30d37
Merge branch 'multi_sdfg' of https://github.com/spcl/dace into multi_…
Feb 16, 2024
5188a55
Implement parsing of interface blocks
mcopik Feb 16, 2024
d6770e8
Include fortran interface blocks into parsing
mcopik Feb 16, 2024
c0f0ad4
Merge branch 'multi_sdfg' of github.com:spcl/dace into multi_sdfg
mcopik Feb 16, 2024
40b8c85
Merge branch 'multi_sdfg' into loop_doacross
phschaad Feb 16, 2024
d5391b0
Merge branch 'multi_sdfg' into loop_doacross
phschaad Feb 16, 2024
2475c4d
Support modules with non-existing specification
mcopik Feb 16, 2024
dd55ca3
Change storage of interface blocks in Fortran, from strings to fparse…
mcopik Feb 16, 2024
723b0f5
wip
Feb 16, 2024
fd4bb7f
Support proper replacement of interfaces on dependency graph
mcopik Feb 16, 2024
896c191
maybe next bug fixed?
Feb 16, 2024
7f6d443
Merge branch 'multi_sdfg' of github.com:spcl/dace into multi_sdfg
mcopik Feb 17, 2024
a8f6a03
Merge branch 'multi_sdfg2' into multi_sdfg
mcopik Feb 17, 2024
d021202
yet another fix
Feb 18, 2024
c534363
yet another fix
Feb 18, 2024
fda4642
tiny fix
Feb 18, 2024
c068539
Add test reproducing symbol error
mcopik Feb 19, 2024
1f49f3a
maybe next bug fixed?
Feb 19, 2024
dc39c33
Fix handling of assumed array shapes for multiple declarations
mcopik Feb 19, 2024
b630ffc
Adapt shape parsing to the new size definition
mcopik Feb 19, 2024
631b690
Fix one more bug in array shape parsing
mcopik Feb 19, 2024
22889c3
adding stuff
Feb 19, 2024
c831401
Fix for array creation in Fortran
mcopik Feb 19, 2024
f2e7678
Merge branch 'multi_sdfg' of github.com:spcl/dace into multi_sdfg
mcopik Feb 19, 2024
4ba9da7
Add new failing test
mcopik Feb 19, 2024
79096a4
Fix bug in normalization
mcopik Feb 19, 2024
b37b3dc
Fix for already declared (nested) Structures.
alexnick83 Feb 19, 2024
b80531a
maybe next bug fixed?
Feb 19, 2024
e231027
maybe next bug fixed?
Feb 19, 2024
062db4d
maybe next bug fixed?
Feb 19, 2024
4d26adf
Merge branch 'multi_sdfg' into loop_doacross
phschaad Feb 20, 2024
02281aa
Cleanup
phschaad Feb 20, 2024
f025624
Add doacross parallelization scaffold
phschaad Feb 25, 2024
7d69396
Finalize doacross parallelization transformation
phschaad Feb 25, 2024
1953915
Finalize doacross codegen and add doacross map collapsing
phschaad Feb 26, 2024
77e9588
Cleanup
phschaad Feb 26, 2024
e61b088
Bugfixes
phschaad Feb 26, 2024
57069df
Bugfixes
phschaad Feb 28, 2024
0d896d6
Bugfixes
phschaad Mar 4, 2024
b13e39b
Add move sequentialism into parallelism pass
phschaad Mar 4, 2024
aa17d90
Pointer incrementation on CPU draft
phschaad Mar 7, 2024
852b29e
Support multi-level loop pointer incrementation
phschaad Mar 7, 2024
731c9ee
Fix otf map fusion
phschaad Mar 8, 2024
225067a
Output ptr increment generation
phschaad Mar 8, 2024
bd02fb9
Fix redundant increments for pointer incrementations
phschaad Mar 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 6 additions & 5 deletions dace/codegen/codegen.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2019-2021 ETH Zurich and the DaCe authors. All rights reserved.
import functools
import os
from typing import List, Set
from typing import Dict, List, Set

import dace
from dace import dtypes
Expand Down Expand Up @@ -95,7 +95,7 @@ def _get_codegen_targets(sdfg: SDFG, frame: framecode.DaCeCodeGenerator):
for node, parent in sdfg.all_nodes_recursive():
# Query nodes and scopes
if isinstance(node, SDFGState):
frame.targets.add(disp.get_state_dispatcher(parent, node))
frame.targets.add(disp.get_state_dispatcher(node.sdfg, node))
elif isinstance(node, dace.nodes.EntryNode):
frame.targets.add(disp.get_scope_dispatcher(node.schedule))
elif isinstance(node, dace.nodes.Node):
Expand Down Expand Up @@ -149,7 +149,7 @@ def _get_codegen_targets(sdfg: SDFG, frame: framecode.DaCeCodeGenerator):
disp.instrumentation[sdfg.instrument] = provider_mapping[sdfg.instrument]


def generate_code(sdfg, validate=True) -> List[CodeObject]:
def generate_code(sdfg: SDFG, validate=True) -> List[CodeObject]:
"""
Generates code as a list of code objects for a given SDFG.

Expand Down Expand Up @@ -189,6 +189,7 @@ def generate_code(sdfg, validate=True) -> List[CodeObject]:
# Convert any loop constructs with hierarchical loop regions into simple 1-level state machine loops.
# TODO (later): Adapt codegen to deal with hierarchical CFGs instead.
sdutils.inline_loop_blocks(sdfg)
sdutils.inline_control_flow_regions(sdfg)

# Before generating the code, run type inference on the SDFG connectors
infer_types.infer_connector_types(sdfg)
Expand All @@ -207,12 +208,12 @@ def generate_code(sdfg, validate=True) -> List[CodeObject]:

# Instantiate CPU first (as it is used by the other code generators)
# TODO: Refactor the parts used by other code generators out of CPU
default_target = cpu.CPUCodeGen
default_target: TargetCodeGenerator = cpu.CPUCodeGen
for k, v in TargetCodeGenerator.extensions().items():
# If another target has already been registered as CPU, use it instead
if v['name'] == 'cpu':
default_target = k
targets = {'cpu': default_target(frame, sdfg)}
targets: Dict[str, TargetCodeGenerator] = {'cpu': default_target(frame, sdfg)}

# Instantiate the rest of the targets
targets.update(
Expand Down
17 changes: 9 additions & 8 deletions dace/codegen/control_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class SingleState(ControlFlow):
def as_cpp(self, codegen, symbols) -> str:
sdfg = self.state.parent

expr = '__state_{}_{}:;\n'.format(sdfg.sdfg_id, self.state.label)
expr = '__state_{}_{}:;\n'.format(sdfg.cfg_id, self.state.label)
if self.state.number_of_nodes() > 0:
expr += '{\n'
expr += self.dispatch_state(self.state)
Expand All @@ -138,7 +138,7 @@ def as_cpp(self, codegen, symbols) -> str:

# If any state has no children, it should jump to the end of the SDFG
if not self.last_state and sdfg.out_degree(self.state) == 0:
expr += 'goto __state_exit_{};\n'.format(sdfg.sdfg_id)
expr += 'goto __state_exit_{};\n'.format(sdfg.cfg_id)
return expr

def generate_transition(self,
Expand Down Expand Up @@ -175,7 +175,7 @@ def generate_transition(self,

if (not edge.data.is_unconditional()
or ((successor is None or edge.dst is not successor) and not assignments_only)):
expr += 'goto __state_{}_{};\n'.format(sdfg.sdfg_id, edge.dst.label)
expr += 'goto __state_{}_{};\n'.format(sdfg.cfg_id, edge.dst.label)

if not edge.data.is_unconditional() and not assignments_only:
expr += '}\n'
Expand Down Expand Up @@ -257,7 +257,7 @@ def as_cpp(self, codegen, symbols) -> str:
# One unconditional edge
if (len(out_edges) == 1 and out_edges[0].data.is_unconditional()):
continue
expr += f'goto __state_exit_{sdfg.sdfg_id};\n'
expr += f'goto __state_exit_{sdfg.cfg_id};\n'

return expr

Expand Down Expand Up @@ -326,7 +326,7 @@ def as_cpp(self, codegen, symbols) -> str:
# execution should end, so we emit an "else goto exit" here.
if len(self.body) > 0:
expr += ' else {\n'
expr += 'goto __state_exit_{};\n'.format(self.sdfg.sdfg_id)
expr += 'goto __state_exit_{};\n'.format(self.sdfg.cfg_id)
if len(self.body) > 0:
expr += '\n}'
return expr
Expand Down Expand Up @@ -390,7 +390,8 @@ def as_cpp(self, codegen, symbols) -> str:

update = ''
if self.update is not None:
update = f'{self.itervar} = {self.update}'
cppupdate = unparse_interstate_edge(self.update, sdfg, codegen=codegen)
update = f'{self.itervar} = {cppupdate}'

expr = f'{preinit}\nfor ({init}; {cond}; {update}) {{\n'
expr += _clean_loop_body(self.body.as_cpp(codegen, symbols))
Expand Down Expand Up @@ -475,7 +476,7 @@ def as_cpp(self, codegen, symbols) -> str:
expr += f'case {case}: {{\n'
expr += body.as_cpp(codegen, symbols)
expr += 'break;\n}\n'
expr += f'default: goto __state_exit_{self.sdfg.sdfg_id};'
expr += f'default: goto __state_exit_{self.sdfg.cfg_id};'
expr += '\n}\n'
return expr

Expand Down Expand Up @@ -841,7 +842,7 @@ def structured_control_flow_tree(sdfg: SDFG, dispatch_state: Callable[[SDFGState
from dace.sdfg.analysis import cfg

# Get parent states and back-edges
ptree = cfg.state_parent_tree(sdfg)
ptree = cfg.control_flow_block_parent_tree(sdfg)
back_edges = cfg.back_edges(sdfg)

# Annotate branches
Expand Down
2 changes: 1 addition & 1 deletion dace/codegen/dispatcher.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019-2021 ETH Zurich and the DaCe authors. All rights reserved.
# Copyright 2019-2024 ETH Zurich and the DaCe authors. All rights reserved.
"""
Contains the DaCe code generator target dispatcher, which is responsible for
flexible code generation with multiple backends by dispatching certain
Expand Down
4 changes: 2 additions & 2 deletions dace/codegen/instrumentation/data/data_dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def on_node_end(self, sdfg: SDFG, state: SDFGState, node: nodes.AccessNode, oute
# Create UUID
state_id = sdfg.node_id(state)
node_id = state.node_id(node)
uuid = f'{sdfg.sdfg_id}_{state_id}_{node_id}'
uuid = f'{sdfg.cfg_id}_{state_id}_{node_id}'

# Get optional pre/postamble for instrumenting device data
preamble, postamble = '', ''
Expand Down Expand Up @@ -277,7 +277,7 @@ def on_node_begin(self, sdfg: SDFG, state: SDFGState, node: nodes.AccessNode, ou
# Create UUID
state_id = sdfg.node_id(state)
node_id = state.node_id(node)
uuid = f'{sdfg.sdfg_id}_{state_id}_{node_id}'
uuid = f'{sdfg.cfg_id}_{state_id}_{node_id}'

# Get optional pre/postamble for instrumenting device data
preamble, postamble = '', ''
Expand Down
4 changes: 2 additions & 2 deletions dace/codegen/instrumentation/gpu_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ def _report(self, timer_name: str, sdfg=None, state=None, node=None):
int __dace_micros_{id} = (int) (__dace_ms_{id} * 1000.0);
unsigned long int __dace_ts_end_{id} = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count();
unsigned long int __dace_ts_start_{id} = __dace_ts_end_{id} - __dace_micros_{id};
__state->report.add_completion("{timer_name}", "GPU", __dace_ts_start_{id}, __dace_ts_end_{id}, {sdfg_id}, {state_id}, {node_id});'''.format(
__state->report.add_completion("{timer_name}", "GPU", __dace_ts_start_{id}, __dace_ts_end_{id}, {cfg_id}, {state_id}, {node_id});'''.format(
id=idstr,
timer_name=timer_name,
backend=self.backend,
sdfg_id=sdfg.sdfg_id,
cfg_id=sdfg.cfg_id,
state_id=state_id,
node_id=node_id)

Expand Down
52 changes: 26 additions & 26 deletions dace/codegen/instrumentation/likwid.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def on_sdfg_end(self, sdfg, local_stream, global_stream):
'''
local_stream.write(outer_code, sdfg)

for region, sdfg_id, state_id, node_id in self._regions:
for region, cfg_id, state_id, node_id in self._regions:
report_code = f'''
#pragma omp parallel
{{
Expand All @@ -187,7 +187,7 @@ def on_sdfg_end(self, sdfg, local_stream, global_stream):

for (int t = 0; t < num_threads; t++)
{{
__state->report.add_completion("Timer", "likwid", 0, time[t] * 1000 * 1000, t, {sdfg_id}, {state_id}, {node_id});
__state->report.add_completion("Timer", "likwid", 0, time[t] * 1000 * 1000, t, {cfg_id}, {state_id}, {node_id});
}}

for (int i = 0; i < nevents; i++)
Expand All @@ -196,7 +196,7 @@ def on_sdfg_end(self, sdfg, local_stream, global_stream):

for (int t = 0; t < num_threads; t++)
{{
__state->report.add_counter("{region}", "likwid", event_name, events[t][i], t, {sdfg_id}, {state_id}, {node_id});
__state->report.add_counter("{region}", "likwid", event_name, events[t][i], t, {cfg_id}, {state_id}, {node_id});
}}
}}
}}
Expand All @@ -214,11 +214,11 @@ def on_state_begin(self, sdfg, state, local_stream, global_stream):
return

if state.instrument == dace.InstrumentationType.LIKWID_CPU:
sdfg_id = sdfg.sdfg_id
cfg_id = sdfg.cfg_id
state_id = sdfg.node_id(state)
node_id = -1
region = f"state_{sdfg_id}_{state_id}_{node_id}"
self._regions.append((region, sdfg_id, state_id, node_id))
region = f"state_{cfg_id}_{state_id}_{node_id}"
self._regions.append((region, cfg_id, state_id, node_id))

marker_code = f'''
#pragma omp parallel
Expand Down Expand Up @@ -250,10 +250,10 @@ def on_state_end(self, sdfg, state, local_stream, global_stream):
return

if state.instrument == dace.InstrumentationType.LIKWID_CPU:
sdfg_id = sdfg.sdfg_id
cfg_id = sdfg.cfg_id
state_id = sdfg.node_id(state)
node_id = -1
region = f"state_{sdfg_id}_{state_id}_{node_id}"
region = f"state_{cfg_id}_{state_id}_{node_id}"

marker_code = f'''
#pragma omp parallel
Expand All @@ -272,12 +272,12 @@ def on_scope_entry(self, sdfg, state, node, outer_stream, inner_stream, global_s
elif node.schedule not in LIKWIDInstrumentationCPU.perf_whitelist_schedules:
raise TypeError("Unsupported schedule on scope")

sdfg_id = sdfg.sdfg_id
cfg_id = sdfg.cfg_id
state_id = sdfg.node_id(state)
node_id = state.node_id(node)
region = f"scope_{sdfg_id}_{state_id}_{node_id}"
region = f"scope_{cfg_id}_{state_id}_{node_id}"

self._regions.append((region, sdfg_id, state_id, node_id))
self._regions.append((region, cfg_id, state_id, node_id))
marker_code = f'''
#pragma omp parallel
{{
Expand All @@ -294,10 +294,10 @@ def on_scope_exit(self, sdfg, state, node, outer_stream, inner_stream, global_st
if not self._likwid_used or entry_node.instrument != dace.InstrumentationType.LIKWID_CPU:
return

sdfg_id = sdfg.sdfg_id
cfg_id = sdfg.cfg_id
state_id = sdfg.node_id(state)
node_id = state.node_id(entry_node)
region = f"scope_{sdfg_id}_{state_id}_{node_id}"
region = f"scope_{cfg_id}_{state_id}_{node_id}"

marker_code = f'''
#pragma omp parallel
Expand Down Expand Up @@ -366,7 +366,7 @@ def on_sdfg_end(self, sdfg, local_stream, global_stream):
if not self._likwid_used or sdfg.parent is not None:
return

for region, sdfg_id, state_id, node_id in self._regions:
for region, cfg_id, state_id, node_id in self._regions:
report_code = f'''
{{
double *events = (double*) malloc(MAX_NUM_EVENTS * sizeof(double));
Expand All @@ -377,14 +377,14 @@ def on_sdfg_end(self, sdfg, local_stream, global_stream):

LIKWID_NVMARKER_GET("{region}", &ngpus, &nevents, &events, &time, &count);

__state->report.add_completion("Timer", "likwid_gpu", 0, time * 1000 * 1000, 0, {sdfg_id}, {state_id}, {node_id});
__state->report.add_completion("Timer", "likwid_gpu", 0, time * 1000 * 1000, 0, {cfg_id}, {state_id}, {node_id});

int gid = nvmon_getIdOfActiveGroup();
for (int i = 0; i < nevents; i++)
{{
char* event_name = nvmon_getEventName(gid, i);

__state->report.add_counter("{region}", "likwid_gpu", event_name, events[i], 0, {sdfg_id}, {state_id}, {node_id});
__state->report.add_counter("{region}", "likwid_gpu", event_name, events[i], 0, {cfg_id}, {state_id}, {node_id});
}}

free(events);
Expand All @@ -402,11 +402,11 @@ def on_state_begin(self, sdfg, state, local_stream, global_stream):
return

if state.instrument == dace.InstrumentationType.LIKWID_GPU:
sdfg_id = sdfg.sdfg_id
cfg_id = sdfg.cfg_id
state_id = sdfg.node_id(state)
node_id = -1
region = f"state_{sdfg_id}_{state_id}_{node_id}"
self._regions.append((region, sdfg_id, state_id, node_id))
region = f"state_{cfg_id}_{state_id}_{node_id}"
self._regions.append((region, cfg_id, state_id, node_id))

marker_code = f'''
LIKWID_NVMARKER_REGISTER("{region}");
Expand All @@ -424,10 +424,10 @@ def on_state_end(self, sdfg, state, local_stream, global_stream):
return

if state.instrument == dace.InstrumentationType.LIKWID_GPU:
sdfg_id = sdfg.sdfg_id
cfg_id = sdfg.cfg_id
state_id = sdfg.node_id(state)
node_id = -1
region = f"state_{sdfg_id}_{state_id}_{node_id}"
region = f"state_{cfg_id}_{state_id}_{node_id}"

marker_code = f'''
LIKWID_NVMARKER_STOP("{region}");
Expand All @@ -443,12 +443,12 @@ def on_scope_entry(self, sdfg, state, node, outer_stream, inner_stream, global_s
elif node.schedule not in LIKWIDInstrumentationGPU.perf_whitelist_schedules:
raise TypeError("Unsupported schedule on scope")

sdfg_id = sdfg.sdfg_id
cfg_id = sdfg.cfg_id
state_id = sdfg.node_id(state)
node_id = state.node_id(node)
region = f"scope_{sdfg_id}_{state_id}_{node_id}"
region = f"scope_{cfg_id}_{state_id}_{node_id}"

self._regions.append((region, sdfg_id, state_id, node_id))
self._regions.append((region, cfg_id, state_id, node_id))
marker_code = f'''
LIKWID_NVMARKER_REGISTER("{region}");

Expand All @@ -465,10 +465,10 @@ def on_scope_exit(self, sdfg, state, node, outer_stream, inner_stream, global_st
if not self._likwid_used or entry_node.instrument != dace.InstrumentationType.LIKWID_GPU:
return

sdfg_id = sdfg.sdfg_id
cfg_id = sdfg.cfg_id
state_id = sdfg.node_id(state)
node_id = state.node_id(entry_node)
region = f"scope_{sdfg_id}_{state_id}_{node_id}"
region = f"scope_{cfg_id}_{state_id}_{node_id}"

marker_code = f'''
LIKWID_NVMARKER_STOP("{region}");
Expand Down
2 changes: 1 addition & 1 deletion dace/codegen/instrumentation/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class types, given the currently-registered extensions of this class.

def _idstr(self, sdfg, state, node):
""" Returns a unique identifier string from a node or state. """
result = str(sdfg.sdfg_id)
result = str(sdfg.cfg_id)
if state is not None:
result += '_' + str(sdfg.node_id(state))
if node is not None:
Expand Down
8 changes: 4 additions & 4 deletions dace/codegen/instrumentation/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
def _uuid_to_dict(uuid: UUIDType) -> Dict[str, int]:
result = {}
if uuid[0] != -1:
result['sdfg_id'] = uuid[0]
result['cfg_id'] = uuid[0]
if uuid[1] != -1:
result['state_id'] = uuid[1]
if uuid[2] != -1:
Expand Down Expand Up @@ -83,13 +83,13 @@ def get_event_uuid_and_other_info(event) -> Tuple[UUIDType, Dict[str, Any]]:
other_info = {}
if 'args' in event:
args = event['args']
if 'sdfg_id' in args and args['sdfg_id'] is not None:
uuid = (args['sdfg_id'], -1, -1)
if 'cfg_id' in args and args['cfg_id'] is not None:
uuid = (args['cfg_id'], -1, -1)
if 'state_id' in args and args['state_id'] is not None:
uuid = (uuid[0], args['state_id'], -1)
if 'id' in args and args['id'] is not None:
uuid = (uuid[0], uuid[1], args['id'])
other_info = {k: v for k, v in args.items() if k not in ('sdfg_id', 'state_id', 'id')}
other_info = {k: v for k, v in args.items() if k not in ('cfg_id', 'state_id', 'id')}
return uuid, other_info

def __init__(self, filename: str):
Expand Down
4 changes: 2 additions & 2 deletions dace/codegen/instrumentation/timer.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ def on_tend(self, timer_name: str, stream: CodeIOStream, sdfg=None, state=None,
stream.write('''auto __dace_tend_{id} = std::chrono::high_resolution_clock::now();
unsigned long int __dace_ts_start_{id} = std::chrono::duration_cast<std::chrono::microseconds>(__dace_tbegin_{id}.time_since_epoch()).count();
unsigned long int __dace_ts_end_{id} = std::chrono::duration_cast<std::chrono::microseconds>(__dace_tend_{id}.time_since_epoch()).count();
__state->report.add_completion("{timer_name}", "Timer", __dace_ts_start_{id}, __dace_ts_end_{id}, {sdfg_id}, {state_id}, {node_id});'''
.format(timer_name=timer_name, id=idstr, sdfg_id=sdfg.sdfg_id, state_id=state_id, node_id=node_id))
__state->report.add_completion("{timer_name}", "Timer", __dace_ts_start_{id}, __dace_ts_end_{id}, {cfg_id}, {state_id}, {node_id});'''
.format(timer_name=timer_name, id=idstr, cfg_id=sdfg.cfg_id, state_id=state_id, node_id=node_id))

# Code generation hooks
def on_state_begin(self, sdfg, state, local_stream, global_stream):
Expand Down
2 changes: 1 addition & 1 deletion dace/codegen/prettycode.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def write(self, contents, sdfg=None, state_id=None, node_id=None):

# If SDFG/state/node location is given, annotate this line
if sdfg is not None:
location_identifier = ' ////__DACE:%d' % sdfg.sdfg_id
location_identifier = ' ////__DACE:%d' % sdfg.cfg_id
if state_id is not None:
location_identifier += ':' + str(state_id)
if node_id is not None:
Expand Down