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
Fix ir_utils._max_label
being updated incorrectly
#7156
Conversation
It is now changed to an object to avoid mutating global variable. The `_MaxLabel` class also enforce that its value must be mutated via the update method.
The tests are taking overly long because of high memory consumption. The problem is not unique to this PR branch. On mainline, running |
Like this: #7028 (comment) ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the patch. Few minor queries else looks good. I plan on testing this manually next.
self._value = max(newval, self._value) | ||
|
||
|
||
_the_max_label = _MaxLabel() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now delete the class? There should only be one of these so make it awkward to obtain another?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
ir_utils._max_label = max_label | ||
ir_utils._the_max_label.update(max_label) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this the bug?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of the bugs. I stopped looking further for where exactly the problems are and just batch fixes all the _max_label
f_ir.blocks = add_offset_to_labels(f_ir.blocks, _max_label + 1) | ||
f_ir.blocks = add_offset_to_labels(f_ir.blocks, _the_max_label.next()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is different? It's advancing the counter whereas originally the offset was set as _max_label+1
but the counter was not updated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The counter not updated part had me worried. That's why i changed it to advance. Worse case is that there's a hole the label space, but I want to be certain that there is no reuse of label.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, it seems like it ought to update else there is potential for reuse, and like you said, worse case is that the label space has gaps which is relatively harmless.
target_registry["CustomCPU"] = CustomCPU | ||
dispatcher_registry[target_registry["CustomCPU"]] = CustomCPUDispatcher |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is ok because this test is run in a subprocess. Were it run in the test suite there might be a name collision for the string "CustomCPU" had another test registered that as a target.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. The test is also highly dependent of the internal state of ir_utils
that it must be executing in a fresh process to replicate.
Co-authored-by: stuartarchibald <stuartarchibald@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the patch and fixes.
cancelling CI build until we have #7160 merged |
CI passed. Merging |
Fixes #7155.
This patch changes
ir_utils._max_label
into an instance of_MaxLabel
so it is easier to enforce the correct update logic. It also means that we no longer need to useglobal _max_label
to update it.Additional notes
As demonstrate by this patch, #7155 is not caused by the retargeting support or any of the recent work to make target-specific overload. It is just unfortunate that the bug is revealed in a case that make use of the retargeting support. I'm also unsure if we really should keep the included testcase, which is not representative of the problem but just a coincident that it revealed the problem. It is likely overly difficult to create a minimal reproducer for the problem.