-
Notifications
You must be signed in to change notification settings - Fork 20
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
Add safety check for fusion #281
Conversation
…ins a reference to the thread ID
def is_safe_to_fuse(self, current: List[TracerOperation], current_views: Set[ViewType], current_safety_info: Dict[Tuple[int, int], Tuple[AccessIndex, AccessMode]], next: TracerOperation, next_views: Set[ViewType]) -> bool: | ||
""" | ||
Check whether the next operation is safe to fuse with the | ||
current operations |
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 comment should document the conditions under which it would be safe to fuse
@@ -305,7 +458,7 @@ def fuse_operations(self, operations: List[TracerOperation]) -> TracerOperation: | |||
# Avoid long names | |||
fused_name = "_".join(names[:5]) + hashlib.md5(("".join(names)).encode()).hexdigest() | |||
|
|||
return TracerOperation(None, future, fused_name, policy, workunits, operation, parsers, fused_name, args, dependencies) | |||
return TracerOperation(None, future, fused_name, policy, workunits, operation, parsers, fused_name, args, dependencies, fused_safety_info) |
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.
some tests for the newly introduced checks?
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.
would be easier to review if some tests were there
Added a safety check to prevent fusion of kernels that could introduce a dependency between threads in the fused kernel. Dependencies can only come from views, so the safety check looks at the what indices are used to access the views. Two kernels which access views only through their thread ID will not introduce a dependency between threads in the fused kernel.