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

std-indices: Capture in offload-friendly way #156

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

illuhad
Copy link
Contributor

@illuhad illuhad commented Jul 6, 2023

Previously, std-indices captured by reference. In an offload scenario, capture-by-value is generally preferred because if the reference points to stack memory on the host, offloaded kernels will encounter illegal memory accesses. This is also something that compilers generally cannot remedy using magic compiler transformations to make data GPU-accessible -- this only works for the heap.

The current code only works in an offload scenario, because the stream class itself is allocated on the heap (which compilers can then make GPU-accessible), and the kernels can then reference the std::vector objects for the data.

As I've said, this relies on an implementation detail and may be brittle in case the architecture ever changes, or someone wishes to reuse babelstream code in a different context.

This PR therefore attempts to make things more robust by directly capturing data pointers by value.

On Intel iGPU, I see no substantial performance difference between the two versions in an offload scenario.

@tom91136
Copy link
Member

@illuhad Can you check if this is resolved in develop?

@tomdeakin tomdeakin changed the base branch from main to develop May 13, 2024 16:47
@gonzalobg
Copy link
Contributor

@tom91136 i think this is indeed resolved in develop. Now a, b, and c are pointers, and are captured by value, avoiding the capture of the std::vector object by reference or a copy of the std::vector object itself to be captured.

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

3 participants