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

Merger of MultiSDFG and Master #1671

Closed
wants to merge 658 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
658 commits
Select commit Hold shift + click to select a range
4638f6f
tmp_struct_symbol removed from arglist
lukastruemper Mar 5, 2024
ee9a118
Use lexicographical order for struct members' cpp definitions
BenWeber42 Mar 6, 2024
ed2aee4
float/double fix
Mar 6, 2024
858f047
Merge branch 'multi_sdfg' of https://github.com/spcl/dace into multi_…
Mar 6, 2024
722bd93
Fixup for InlineMultistateSDFG
lukastruemper Mar 6, 2024
a3a527e
Scalar2Symbol Promotion: Don't promote viewes
lukastruemper Mar 6, 2024
fa18ced
index extractor fix
Mar 6, 2024
2f25c14
InlineMultistateSDFG: Rename input arguments after use
lukastruemper Mar 6, 2024
b959f65
index extractor fix
Mar 6, 2024
fc1a35c
InlineMultistateSDFG fixup
lukastruemper Mar 6, 2024
5ff2c5f
Scalar2SymbolPromotion fixup
lukastruemper Mar 6, 2024
cf62bfd
index extractor fix
Mar 7, 2024
6f99d4e
Added InlineMap transformation
lukastruemper Mar 7, 2024
052d6b4
InlineMap: Prepare for multiple cases
lukastruemper Mar 7, 2024
3f3cb5f
Fix issue in optional args processing and normalizing offsets of arra…
mcopik Mar 8, 2024
d4d362f
Fix non error
mcopik Mar 8, 2024
54ab1db
Fix handling of potential nones
mcopik Mar 8, 2024
20f6c05
fix test
mcopik Mar 8, 2024
38cde51
Recursively declare/define StructureView members.
alexnick83 Mar 8, 2024
d1ea268
optional arg fix
Mar 8, 2024
da39f65
Merge branch 'multi_sdfg' of https://github.com/spcl/dace into multi_…
Mar 8, 2024
947e3d7
Confirm that node still exists in SDFGState.
alexnick83 Mar 9, 2024
7b6a0cc
Added entering and exiting scope code for `declared_arrays` in framec…
alexnick83 Mar 9, 2024
bf9f1b4
2 fixes
Mar 10, 2024
accd0e9
Merge branch 'multi_sdfg' of https://github.com/spcl/dace into multi_…
Mar 10, 2024
1e25089
new issue
Mar 10, 2024
547e597
last issue
Mar 11, 2024
de2ba60
reproducer
Mar 11, 2024
c11641b
InlinMap extended
lukastruemper Mar 11, 2024
f3ebbb1
InlineMap: Enable single-state inlining
lukastruemper Mar 11, 2024
3adc62e
testing optipipeline
Mar 11, 2024
17c22f8
Merge branch 'multi_sdfg' of https://github.com/spcl/dace into multi_…
Mar 11, 2024
cd30c85
Cache SDFG starting block before potentially removing it.
alexnick83 Mar 12, 2024
a64ea7f
Improved InlineMapByAssignment's symbol handling, including treating …
alexnick83 Mar 12, 2024
8c4ee43
container array fixes
Mar 13, 2024
e716ff5
Merge branch 'multi_sdfg' of https://github.com/spcl/dace into multi_…
Mar 13, 2024
9cfdd11
References must be declared and defined in the same line.
alexnick83 Mar 13, 2024
629d11c
Dereference extra StructureView pointer.
alexnick83 Mar 13, 2024
f621f39
Infer Structure out connectors as Scalars.
alexnick83 Mar 13, 2024
a999b17
Consider Structures Scalars.
alexnick83 Mar 13, 2024
9eaaf2a
More elaborate is_scalar inference.
alexnick83 Mar 13, 2024
8238c99
Instead of dereferencing extra pointers, cancel out pointer and refer…
alexnick83 Mar 13, 2024
8b58533
container array fixes
Mar 13, 2024
cf31ea8
Merge branch 'multi_sdfg' of https://github.com/spcl/dace into multi_…
Mar 13, 2024
7bda614
Minor fix in InlineMultistateSDFG
lukastruemper Mar 13, 2024
f92f692
container array fixes
Mar 14, 2024
5fb26f9
Merge branch 'multi_sdfg' of https://github.com/spcl/dace into multi_…
Mar 14, 2024
7298e4e
container array fixes
Mar 15, 2024
ac4c012
Create pointer removal pass
mcopik Mar 15, 2024
dced3b3
symbol fix
Mar 15, 2024
28c7b3c
container array fixes
Mar 15, 2024
8d60c85
Merge branch 'multi_sdfg' of github.com:spcl/dace into multi_sdfg
mcopik Mar 15, 2024
f464682
Rewrite pointerremoval pass to not use deepcopy
mcopik Mar 15, 2024
de714af
helpful annotations
mcopik Mar 15, 2024
02fefd8
InlineMultistateSDFG: Rename indirections with iconns
lukastruemper Mar 15, 2024
a1b144a
Minor fixes
lukastruemper Mar 16, 2024
a490c2f
InlineMap: Fixed symbol assignments
lukastruemper Mar 16, 2024
ccb664f
fixes for interfaces, container arrays, and optionals
Mar 17, 2024
d4baaaa
fixes for interfaces, container arrays, and optionals
Mar 17, 2024
9f21396
Fix pointer removal pass - make sure that ptr itself is removed
mcopik Mar 17, 2024
e15db7b
Change order of AST passes
mcopik Mar 17, 2024
7e8cb71
update test
mcopik Mar 17, 2024
fc97b75
Merge branch 'multi_sdfg' of github.com:spcl/dace into multi_sdfg
mcopik Mar 17, 2024
cea544d
still buggy
Mar 17, 2024
06cb554
still buggy
Mar 17, 2024
68217b4
Fix bad typo in LiftStructView
phschaad Mar 17, 2024
ecdcd92
still buggy
Mar 17, 2024
bc6543e
still buggy
Mar 17, 2024
c1a3068
Handle correctly unexpected Nones in AST structures
mcopik Mar 17, 2024
833649d
Merge branch 'multi_sdfg' of github.com:spcl/dace into multi_sdfg
mcopik Mar 17, 2024
ec1c61f
Connectors fix
phschaad Mar 17, 2024
98b5bd0
InlineMultistateSDFG: Updated symbol mapping
lukastruemper Mar 17, 2024
eeb5326
State fission after fixed
lukastruemper Mar 17, 2024
97e8d10
first dycore SDFG validate
Mar 17, 2024
6246a2e
still buggy
Mar 17, 2024
7b66647
first dycore validation
Mar 17, 2024
9ba1b46
Velocity Tendencies: auto-opt working
lukastruemper Mar 17, 2024
1030893
first dycore validation
Mar 18, 2024
694d9f5
nh_solve fix
Mar 18, 2024
491add7
nh_solve fix
Mar 18, 2024
94c46b8
nh_solve fix
Mar 18, 2024
99fb1e6
nh_solve fix
Mar 18, 2024
409c83c
try to fix bug in processing optional args
mcopik Mar 18, 2024
c9c1f07
nh_solve fix
Mar 19, 2024
571e7a6
Ensure `diag` is not interpeted as a function in `pystr_to_symbolic`.
alexnick83 Mar 19, 2024
aed1a1b
InlineMapByAssignment: Check for constants
lukastruemper Mar 20, 2024
d509143
InlineMultistateSDFG: Rename symbols to avoid clashes with map scopes
lukastruemper Mar 20, 2024
854e824
Bugfixes for lift_struct_views
phschaad Mar 21, 2024
e87d3a7
RemoveSliceView: don't apply to container arrays and container views
lukastruemper Mar 21, 2024
18cc774
nh_solve fix
Mar 22, 2024
0e942fb
Don't overwrite "prefix" since we need it later.
alexnick83 Mar 22, 2024
ec64861
Experimental Inlining Extension: To be tested
lukastruemper Mar 22, 2024
a858c42
Typo fix
lukastruemper Mar 22, 2024
e490e00
nh_solve fix
Mar 22, 2024
f4224b3
InlineMultistateSDFG: Minor fix
lukastruemper Mar 22, 2024
aa8e513
InlineMultistateSDFG: Removed workaround
lukastruemper Mar 23, 2024
ca3e610
Fixed tuple comprehension.
alexnick83 Mar 23, 2024
f5accde
LiftStructView fix
phschaad Mar 23, 2024
081b57c
Enable viewing individual states
phschaad Mar 24, 2024
dfc3051
fix for redundant array removing struct.field views
Mar 24, 2024
aeae7da
Merge branch 'multi_sdfg' of https://github.com/spcl/dace into multi_…
Mar 24, 2024
cb8b504
Minor fixes
lukastruemper Mar 24, 2024
fe95e89
fix frontend wrong argument added
Mar 24, 2024
ad3fed6
Merge branch 'multi_sdfg' of https://github.com/spcl/dace into multi_…
Mar 24, 2024
1613468
Liftstructview fix
phschaad Mar 25, 2024
64a747d
codegen issue
Mar 25, 2024
253aee3
nh_solve fix structureView instead of arrayView
Mar 26, 2024
d799a8a
wip
mcopik Mar 27, 2024
c59ee77
Fixing struct codegen (#1554)
alexnick83 Mar 27, 2024
f7614bc
fix memlet generation
mcopik Mar 27, 2024
116d246
nh_solve fix
Mar 27, 2024
747c591
cloudsc fix
Mar 27, 2024
4b288e3
cloudsc fix
Mar 27, 2024
e49f2d9
remove printouts
mcopik Mar 27, 2024
9cf41a0
remove debugs
mcopik Mar 27, 2024
3057e2b
LoopToMap for views
lukastruemper Mar 27, 2024
590ee24
cloudsc fix
Mar 27, 2024
c09adca
Merge branch 'multi_sdfg' of github.com:spcl/dace into multi_sdfg
mcopik Mar 27, 2024
3ebb9b7
cloudsc fix
Mar 27, 2024
f7df33b
InlineMap fixes
lukastruemper Mar 27, 2024
238ec2f
InlineMap fixes
lukastruemper Mar 29, 2024
e527b0a
InlineMap final fix
lukastruemper Mar 30, 2024
cdc552c
Argument flattening for nested SDFGs
lukastruemper Mar 31, 2024
4e140a6
deserialize issue
Mar 31, 2024
6854f7f
Codegen fixes
lukastruemper Mar 31, 2024
6ede21a
deserialize issue
Mar 31, 2024
aa96497
Merge branch 'multi_sdfg' of https://github.com/spcl/dace into multi_…
Mar 31, 2024
134f3d8
Added transformations
lukastruemper Apr 1, 2024
c7e03dd
Introduced temporary workaround to load old SDFG where the TensorTran…
alexnick83 Apr 1, 2024
657560d
Implement a transformation to add block schedule to a device schedule…
ThrudPrimrose Jun 25, 2024
89435f4
Implement transformation to change the range of a thread block schedule
ThrudPrimrose Jun 26, 2024
f2de78e
Clean unnecessary imports
ThrudPrimrose Jun 26, 2024
0efa23f
Merge branch 'master' of github.com:ThrudPrimrose/dace
ThrudPrimrose Jun 26, 2024
5224201
Fix bug in step size calculation
ThrudPrimrose Jun 26, 2024
e7e6f8d
Implement thread tiling, hack GPU code-gen a bit to override block si…
ThrudPrimrose Jun 26, 2024
ee72102
Fix GPU Block Dimensions to Range calculations
ThrudPrimrose Jun 26, 2024
6f9fb69
Remove rogue print statements
ThrudPrimrose Jun 26, 2024
52c5e52
Fix tile resizing in thread tiling
ThrudPrimrose Jun 26, 2024
a405da0
Improve range computations
ThrudPrimrose Jun 27, 2024
81d676f
Update description of thread tiling
ThrudPrimrose Jun 28, 2024
e752694
Refactoring changes
ThrudPrimrose Jul 1, 2024
08b7382
Fix range calculation for block coarsening and refactor code
ThrudPrimrose Jul 2, 2024
76e4e61
Implement load-compute transformation for GPUs for 1D
ThrudPrimrose Jul 4, 2024
fc9cc43
Fix dimensions errors appearing with >4 dimensions in a map
ThrudPrimrose Jul 4, 2024
86bfcc3
Refactoring and code simplifying changes
ThrudPrimrose Jul 4, 2024
550662b
Fixes for the blocksize computation
ThrudPrimrose Jul 8, 2024
c02f1ab
Fix transformation to support dimension counts higher than three
ThrudPrimrose Jul 8, 2024
01e6f5e
Add tests
ThrudPrimrose Jul 8, 2024
556c774
Fix fixture of helper transformations
ThrudPrimrose Jul 8, 2024
02c9a9f
Merge branch 'spcl:master' into master
ThrudPrimrose Jul 8, 2024
a685962
Merge branch 'spcl:master' into master
ThrudPrimrose Jul 9, 2024
a127e7b
Implement explicit memory move transformation from GPU global to GPU …
ThrudPrimrose Jul 9, 2024
51af96b
Merge branch 'master' of github.com:ThrudPrimrose/dace
ThrudPrimrose Jul 9, 2024
7e19da8
Fix out of range by 1d loads
ThrudPrimrose Jul 9, 2024
c93135c
Add explicit memory move tests, add support for negative iterator values
ThrudPrimrose Jul 10, 2024
d16a710
Better transposed iteration support
ThrudPrimrose Jul 10, 2024
5541855
Change memory approximation strategy and update tests
ThrudPrimrose Jul 11, 2024
bff104c
Fix for scalar nested sdfg arguments connected to a view.
alexnick83 Jul 12, 2024
33fd505
Views should not be const or ref.
alexnick83 Jul 13, 2024
ae6b0db
Use ptrname instead of name.
alexnick83 Jul 13, 2024
8361c8e
Fixes and improvements for explicit memory movement transformation
ThrudPrimrose Jul 16, 2024
0ffc08c
Minor improvements to have less ifs
ThrudPrimrose Jul 16, 2024
1003aca
Refactor code
ThrudPrimrose Jul 16, 2024
3d9beab
Use min for bound checks
ThrudPrimrose Jul 16, 2024
eac3695
Provide both implementations/variants of explicit memmove transformation
ThrudPrimrose Jul 16, 2024
416bbac
Fixes for the variant 2
ThrudPrimrose Jul 16, 2024
9fa14e0
Update thread coarsening to work with temporary scalars
ThrudPrimrose Jul 18, 2024
77b2a19
Update thread coarsening support for array reshaping, imrpove under a…
ThrudPrimrose Jul 19, 2024
5f70a19
Added new SDFG utiity methods for removing Views to Scalars and renam…
alexnick83 Jul 22, 2024
2fa670d
Add Blocktiling and updated coarsening transformations
ThrudPrimrose Jul 22, 2024
db93ca6
Set syncthreads as an option feature, improve block tiling
ThrudPrimrose Jul 23, 2024
6e970a7
Various fixed for block tiling transformation
ThrudPrimrose Jul 23, 2024
a2e167f
Refactor test, minor fix to explicit mem move
ThrudPrimrose Jul 23, 2024
78651e5
Change grouping of the amm guided transformations
ThrudPrimrose Jul 24, 2024
5a96497
Refactoring
ThrudPrimrose Jul 25, 2024
770d904
Refactoring
ThrudPrimrose Jul 25, 2024
161d606
Refactor
ThrudPrimrose Jul 25, 2024
82477fc
Do not make reference to Structure when setting a simple pointer to s…
alexnick83 Aug 12, 2024
98a17ab
Enhanced `remove_scalar_views` utility method to also remove views to…
alexnick83 Aug 12, 2024
e8735e4
Merge branch 'spcl:master' into master
ThrudPrimrose Aug 27, 2024
0502de1
Merge branch 'spcl:master' into master
ThrudPrimrose Aug 30, 2024
a1b88bf
Revise transofrmations start implementing remainder loop transformation
ThrudPrimrose Aug 30, 2024
01549aa
Merge branch 'master' of github.com:ThrudPrimrose/dace
ThrudPrimrose Aug 30, 2024
bfadc3a
Update block tiling transformation
ThrudPrimrose Sep 2, 2024
be8843d
Improve offsetting in the kernels (to better work with shared memory …
ThrudPrimrose Sep 3, 2024
8112d22
Add new option to force thread sync
ThrudPrimrose Sep 3, 2024
68c0640
Re-implement explicit memory transofrmation and update tiling params
ThrudPrimrose Sep 3, 2024
7149621
Add options to force a syncthread within a map and prefer the gpu_blo…
ThrudPrimrose Sep 3, 2024
8efe6b5
Add skew option map tiling transformation
ThrudPrimrose Sep 3, 2024
636c119
Improve location of the syncthreads call
ThrudPrimrose Sep 3, 2024
e8c134a
Improve grammar
ThrudPrimrose Sep 3, 2024
295ccb3
Merge branch 'additions'
ThrudPrimrose Sep 3, 2024
be11abc
Reimplement remainder loop and clena-up transformations
ThrudPrimrose Sep 5, 2024
675e1dc
Incorporate step size to thread block computation
ThrudPrimrose Sep 5, 2024
12abfa5
Merge branch 'spcl:master' into master
ThrudPrimrose Sep 5, 2024
335883c
Merge branch 'additions'
ThrudPrimrose Sep 5, 2024
0514043
Update gpu block size
ThrudPrimrose Sep 5, 2024
d57aa3e
Add optional setting map parameters (not forced to auto)
ThrudPrimrose Sep 5, 2024
899217d
Update transformations
ThrudPrimrose Sep 5, 2024
e32d1da
Enable user-defined map parameter types, infer if not set and do not …
ThrudPrimrose Sep 5, 2024
0cf56c8
Update dace/sdfg/nodes.py
ThrudPrimrose Sep 6, 2024
b25b95d
Update dace/codegen/targets/cpu.py
ThrudPrimrose Sep 6, 2024
54e29cc
Update according to the comments
ThrudPrimrose Sep 6, 2024
aa21812
Merge branch 'map_params' of https://github.com/spcl/dace into map_pa…
ThrudPrimrose Sep 6, 2024
a4079ac
Remove the rogue gpu force syncthreads parameter (again)
ThrudPrimrose Sep 6, 2024
88d5a07
Merge branch 'master' into map_params
ThrudPrimrose Sep 9, 2024
bd210b2
Merge branch 'spcl:master' into master
ThrudPrimrose Sep 9, 2024
a4b161f
Merge remote-tracking branch 'origin/map_params'
ThrudPrimrose Sep 9, 2024
192400d
Make transformations compatible with the new map_params
ThrudPrimrose Sep 9, 2024
c57ed05
Add mroe cases to explicit memory movement
ThrudPrimrose Sep 9, 2024
fd58575
Fix pruning of imported symbols when it appears in type definition
mcopik Sep 10, 2024
c5daabe
Refactor transformations and patch remainder loop to work without sha…
ThrudPrimrose Sep 10, 2024
68b6eca
Refactor transformations
ThrudPrimrose Sep 11, 2024
00086db
Merge branch 'spcl:master' into master
ThrudPrimrose Sep 14, 2024
8e801d7
Merge branch 'spcl:master' into master
ThrudPrimrose Sep 18, 2024
106df80
Refactor some transformations
ThrudPrimrose Sep 19, 2024
1da983d
More transformation refactoring
ThrudPrimrose Sep 19, 2024
b69c438
Merge branch 'spcl:master' into master
ThrudPrimrose Sep 26, 2024
0482709
Merge branch 'master' of github.com:ThrudPrimrose/dace
ThrudPrimrose Sep 26, 2024
0b2be6e
Updates to transformations
ThrudPrimrose Sep 26, 2024
77001a7
Merge branch 'spcl:master' into master
ThrudPrimrose Sep 30, 2024
1d23a85
Merge remote-tracking branch 'mainstream/master' into multi_merge
phschaad Oct 1, 2024
2125e3e
Merge remote-tracking branch 'origin/master' into multi_merge
phschaad Oct 1, 2024
87ba3aa
Update submodule again
phschaad Oct 1, 2024
c1b5a36
Some fixes
phschaad Oct 2, 2024
6dcb480
Fix
phschaad Oct 2, 2024
97682de
Add utility for auto apply and profile and improve remainder loop
ThrudPrimrose Oct 4, 2024
41b462d
Update tiling transformations
ThrudPrimrose Oct 5, 2024
bdafdcd
Improvements to the auto tiling pipeline
ThrudPrimrose Oct 6, 2024
913b5b9
Format string refactor to support python 3.8
ThrudPrimrose Oct 6, 2024
5671995
Merge branch 'spcl:master' into master
ThrudPrimrose Oct 9, 2024
5aa742b
Update test
ThrudPrimrose Oct 9, 2024
6244b16
Merge submodule?
ThrudPrimrose Oct 9, 2024
f65c727
Fix minor bug in mem move, improve auto apply pipeline
ThrudPrimrose Oct 10, 2024
4080cb0
Improve exception handling in auto apply
ThrudPrimrose Oct 10, 2024
8bcda4f
refactor
ThrudPrimrose Oct 10, 2024
373b9d8
Minor fix for ault
ThrudPrimrose Oct 10, 2024
1f74af0
Python 3.8 refactor
ThrudPrimrose Oct 10, 2024
e19e2c7
Update explicit memory move transformation to use properties and mino…
ThrudPrimrose Oct 10, 2024
6289300
Bring back exceptions
ThrudPrimrose Oct 10, 2024
9769206
Merge branch 'master' into multi_merge
ThrudPrimrose Oct 10, 2024
cc62ec0
Add Icon preprocessing transformations
ThrudPrimrose Oct 10, 2024
8070553
Improve map over tasklet access node
ThrudPrimrose Oct 14, 2024
a5452ce
Add flag to prevent a map to be mapped to gpu
ThrudPrimrose Oct 14, 2024
555927d
Revert GPU transformation changes
ThrudPrimrose Oct 14, 2024
a1a9fdc
Add host_map proeprty back
ThrudPrimrose Oct 14, 2024
400be7a
Add host_data and host_map properties
ThrudPrimrose Oct 15, 2024
aeaca67
Add host_data param
ThrudPrimrose Oct 15, 2024
1cef1c1
Add host_data property to all data types
ThrudPrimrose Oct 15, 2024
f56c000
Merge branch 'auto_tile_multi_sdfg_merge' into multi_merge
ThrudPrimrose Oct 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
url = https://github.com/definelicht/hlslib.git
[submodule "dace/viewer/webclient"]
path = dace/viewer/webclient
url = https://github.com/spcl/dace-webclient.git
url = git@github.com:spcl/dace-webclient.git
[submodule "dace/external/rtllib"]
path = dace/external/rtllib
url = https://github.com/carljohnsen/rtllib.git
[submodule "latex-tools"]
path = latex-tools
url = https://github.com/mcopik/latex-tools
4 changes: 4 additions & 0 deletions dace/codegen/dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,9 +373,11 @@ def dispatch_state(self, state: SDFGState, function_stream: CodeIOStream, callsi
""" Dispatches a code generator for an SDFG state. """

self.defined_vars.enter_scope(state)
self.declared_arrays.enter_scope(state)
disp = self.get_state_dispatcher(state.sdfg, state)
disp.generate_state(state.sdfg, state.parent_graph, state, function_stream, callsite_stream)
self.defined_vars.exit_scope(state)
self.declared_arrays.exit_scope(state)

def dispatch_subgraph(self,
sdfg: SDFG,
Expand Down Expand Up @@ -462,10 +464,12 @@ def dispatch_scope(self,

entry_node = sub_dfg.source_nodes()[0]
self.defined_vars.enter_scope(entry_node)
self.declared_arrays.enter_scope(entry_node)
self._used_targets.add(self._map_dispatchers[map_schedule])
self._map_dispatchers[map_schedule].generate_scope(sdfg, cfg, sub_dfg, state_id, function_stream,
callsite_stream)
self.defined_vars.exit_scope(entry_node)
self.declared_arrays.exit_scope(entry_node)

def get_array_dispatcher(self, storage: dtypes.StorageType) -> target.TargetCodeGenerator:
return self._array_dispatchers[storage]
Expand Down
100 changes: 91 additions & 9 deletions dace/codegen/targets/cpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,18 @@ def emit_memlet_reference(dispatcher: 'TargetDispatcher',
typedef = conntype.ctype
offset = cpp_offset_expr(desc, memlet.subset)
offset_expr = '[' + offset + ']'
is_scalar = not isinstance(conntype, dtypes.pointer)
is_scalar = not isinstance(conntype, dtypes.pointer) # or (isinstance(conntype, dtypes.pointer) and isinstance(desc, data.ContainerArray))
# is_scalar = not isinstance(conntype, dtypes.pointer)
# is_scalar = is_scalar or isinstance(desc, data.Structure)
# is_dtype_struct = isinstance(desc, data.ContainerArray) and isinstance(desc.dtype, dtypes.pointer) and isinstance(desc.dtype.base_type, dtypes.struct)
# is_scalar = is_scalar or (is_dtype_struct and memlet.subset and memlet.subset.num_elements() == 1)
ptrname = ptr(memlet.data, desc, sdfg, dispatcher.frame)
ref = ''

if isinstance(desc, data.Structure):
offset = ''
offset_expr = ''

# Get defined type (pointer, stream etc.) and change the type definition
# accordingly.
defined_types = None
Expand Down Expand Up @@ -324,6 +332,28 @@ def emit_memlet_reference(dispatcher: 'TargetDispatcher',
else:
datadef = ptr(memlet.data, desc, sdfg, dispatcher.frame)

if '.' in memlet.data:
tokens = memlet.data.split('.')
datadef = ''
for token in tokens[:-1]:
assert token in sdfg.arrays
desc = sdfg.arrays[token]
assert isinstance(desc, data.Structure)
if not datadef:
datadef = token
if isinstance(desc, data.StructureView) and isinstance(desc.dtype, dtypes.pointer):
datadef = f"(*{token})"
continue
if isinstance(desc.dtype, dtypes.struct):
datadef = f"{datadef}.{token}"
elif isinstance(desc.dtype, dtypes.pointer) and isinstance(desc.dtype.base_type, dtypes.struct):
datadef = f"{datadef}->{token}"
else:
raise TypeError(f"Unsupported structure type: {desc.dtype}")
datadef = f"({datadef}.{tokens[-1]})"
elif isinstance(desc, data.StructureView) and isinstance(desc.dtype, dtypes.pointer):
datadef = f"(*{datadef})"

def make_const(expr: str) -> str:
# check whether const has already been added before
if not expr.startswith("const "):
Expand All @@ -334,14 +364,18 @@ def make_const(expr: str) -> str:
if (defined_type == DefinedType.Pointer
or (defined_type == DefinedType.ArrayInterface and isinstance(desc, data.View))):
if not is_scalar and desc.dtype == conntype.base_type:
# Cast potential consts
typedef = defined_ctype
if isinstance(desc, data.Structure):
# typdef = defined_ctype
pass
else:
# Cast potential consts
typedef = defined_ctype

if is_scalar:
defined_type = DefinedType.Scalar
if is_write is False:
if is_write is False and not isinstance(desc, (data.View, data.ContainerArray)):
typedef = make_const(typedef)
ref = '&'
ref = '&'
else:
# constexpr arrays
if memlet.data in dispatcher.frame.symbols_and_constants(sdfg):
Expand Down Expand Up @@ -397,14 +431,22 @@ def make_const(expr: str) -> str:
ref = '&'
else:
# Cast as necessary
expr = make_ptr_vector_cast(datadef + offset_expr, desc.dtype, conntype, is_scalar, defined_type)
if ref == '&' and offset_expr:
ref = ''
offset_expr = ''
# NOTE: Structures are misunderstood as pointers to scalar in `make_ptr_vecor_cast`.
if isinstance(desc, data.Structure) and isinstance(conntype.base_type, dtypes.struct):
expr = datadef
else:
expr = make_ptr_vector_cast(datadef + offset_expr, desc.dtype, conntype, is_scalar, defined_type)
expr = expr.replace('.', '->')

# Register defined variable
dispatcher.defined_vars.add(pointer_name, defined_type, typedef, allow_shadowing=True)

# NOTE: `expr` may only be a name or a sequence of names and dots. The latter indicates nested data and structures.
# NOTE: Since structures are implemented as pointers, we replace dots with arrows.
expr = expr.replace('.', '->')
# expr = expr.replace('.', '->')

return (typedef + ref, pointer_name, expr)

Expand Down Expand Up @@ -1035,16 +1077,56 @@ def _Name(self, t: ast.Name):

# Replace values with their code-generated names (for example, persistent arrays)
desc = self.sdfg.arrays[t.id]
self.write(ptr(t.id, desc, self.sdfg, self.codegen))
to_write = ptr(t.id, desc, self.sdfg, self.codegen)
if isinstance(desc, data.StructureView):
to_write = f"(*{to_write})"
self.write(to_write)

def _Attribute(self, t: ast.Attribute):
from dace.frontend.python.astutils import rname, unparse

if '.' in unparse(t):
super().dispatch(t.value)
self.write(f'->{t.attr}')
return

name = rname(t)
if name not in self.sdfg.arrays:
return super()._Attribute(t)

# Replace values with their code-generated names (for example, persistent arrays)
desc = self.sdfg.arrays[name]
self.write(ptr(name, desc, self.sdfg, self.codegen))

def _Subscript(self, t: ast.Subscript):
from dace.frontend.python.astutils import subscript_to_slice
from dace.frontend.python.astutils import subscript_to_slice, unparse

if isinstance(t.value, ast.Name):
name = t.value.id
desc = self.sdfg.arrays[name]
if isinstance(desc, data.Structure):
to_write = name
if isinstance(desc, data.StructureView):
to_write = f"(*{to_write})"
self.write(to_write)
return

target, rng = subscript_to_slice(t, self.sdfg.arrays)
rng = subsets.Range(rng)
if rng.num_elements() != 1:
raise SyntaxError('Range subscripts disallowed in interstate edges')

memlet = mmlt.Memlet(data=target, subset=rng)
to_write = cpp_array_expr(self.sdfg, memlet, codegen=self.codegen)

if '.' in unparse(t):
super().dispatch(t.value)
desc = self.sdfg.arrays[target]
if not isinstance(desc, data.Structure):
i0 = to_write.find('[')
i1 = to_write.rfind(']')
self.write(to_write[i0:i1 + 1])
return

if target not in self.sdfg.arrays:
# This could be an FPGA array whose name has been mangled
Expand Down
Loading