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

Conditional Data Instrumentation #1202

Merged
merged 10 commits into from Mar 3, 2023
Merged

Conditional Data Instrumentation #1202

merged 10 commits into from Mar 3, 2023

Conversation

phschaad
Copy link
Collaborator

@phschaad phschaad commented Mar 1, 2023

No description provided.

@phschaad phschaad enabled auto-merge (squash) March 1, 2023 18:21
@phschaad phschaad requested a review from tbennun March 1, 2023 18:22
Copy link
Collaborator

@tbennun tbennun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost

@@ -106,6 +106,11 @@ def on_node_end(self, sdfg: SDFG, state: SDFGState, node: nodes.AccessNode, oute
# Only run on host code
return

condition_preamble, condition_postamble = '', ''
if node.instrument_condition is not None and not node.instrument_condition.as_string == '1':
condition_preamble = f'if ({node.instrument_condition.as_string})' + ' {'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check how we generate C++ from codeblocks

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Learned something new, thanks.. :-)

@@ -178,6 +185,11 @@ def on_node_begin(self, sdfg: SDFG, state: SDFGState, node: nodes.AccessNode, ou
# Only run on host code
return

condition_preamble, condition_postamble = '', ''
if node.instrument_condition is not None and not node.instrument_condition.as_string == '1':
condition_preamble = f'if ({node.instrument_condition.as_string})' + ' {'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

dace/sdfg/nodes.py Outdated Show resolved Hide resolved
for node, _ in sdfg.all_nodes_recursive():
if isinstance(node, nodes.AccessNode):
node.instrument = dace.DataInstrumentationType.Save
node.instrument_condition = CodeBlock('i == 0', language=dace.Language.CPP)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For completeness, please add a test with python codeblocks and “i ** 2 == 4”

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@phschaad phschaad requested a review from tbennun March 2, 2023 08:29
@phschaad phschaad merged commit ba25b2b into master Mar 3, 2023
@tbennun tbennun deleted the conditional_data_instr branch July 7, 2023 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants