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

Sync before exiting a cilk_scope with a non-compound statement body #320

Open
wants to merge 1 commit into
base: dev/19.x
Choose a base branch
from

Conversation

VoxSciurorum
Copy link
Contributor

Fixes #319.

EmitStmt(S.getBody());
EmitStmt(S.getBody());
} else {
PushSyncRegion()->addImplicitSync();
Copy link
Collaborator

Choose a reason for hiding this comment

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

It took me a while to figure out why these changes were necessary, given that the SyncRegionRAII is meant to handle pushing and popping of sync regions.

I think the simpler approach to resolving this issue is to set ScopeIsSynced to true before pushing the TapirRuntimeEndCleanup, e.g., on line 472. That flag is used to ensure that implicit syncs and cleanups/destructors are ordered correctly within a lexical scope. Does that approach work for your tests?

@VoxSciurorum
Copy link
Contributor Author

The second version crashes on this input, processed by the first version:

void f()
{
  extern void function(void);
  cilk_scope { cilk_scope cilk_spawn { function(); } }
}

@neboat
Copy link
Collaborator

neboat commented Mar 11, 2025

I see. It looks like we also need to ensure the sync is inserted before any taskframe.end intrinsics.

Does it work if we move the ScopeIsSynced = true assignment to line 468, before the TaskFrameScope RAII variable is defined? Does anything else break in that case?

@VoxSciurorum
Copy link
Contributor Author

Moving the assignment earlier worked. I added another test for nested cilk_scope.

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.

cilk_scope without braces fails to sync
2 participants