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

Passing parent stack frames to spawn-helper functions #29

Merged
merged 4 commits into from
Jul 30, 2024

Conversation

neboat
Copy link
Contributor

@neboat neboat commented Jul 16, 2024

This PR drafts runtime-system changes to pass a pointer to the __cilkrts_stack_frame in a parent spawning function, along with other compile-time information, to a spawn helper. This change allows the spawn helper to access the parent stack frame more efficiently and enables a variety of optimizations to reduce spawn overhead.

  • Spawn helpers can avoid looking up the parent stack frame from worker-local storage, which can be costly to access.
  • Spawn-helper stack frames need not explicitly store a pointer to the parent stack frame.
  • By receiving the compile-time information about whether a spawn helper is itself a spawner, the spawn-helper routines can avoid unnecessary initialization and deinitialization work, such as adding themselves to the cactus stack of __cilkrts_stack_frames. In this case, the compiler is able to optimize away the spawn-helper's stack frame.

This PR requires the compiler changes in OpenCilk/opencilk-project#252.

@VoxSciurorum
Copy link
Contributor

This part looks good. Do you have any performance measurements?

@neboat
Copy link
Contributor Author

neboat commented Jul 30, 2024

I took some performance measurements on a couple AWS servers, using the Cilk-5 benchmarks and some older Intel codes. This change does improve performance a little bit on those benchmarks, though many of them may have been tuned already to minimize spawn overhead. On benchmarks that show more spawn overhead (cholesky and a coarsened fib), the improvement seems to be around 1–2% on Intel Cascade Lake and 2–4% on an M2.

@neboat neboat merged commit 452b2c8 into OpenCilk:dev Jul 30, 2024
@neboat neboat deleted the spawn-helper branch November 23, 2024 00:24
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.

2 participants