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

Add buffer(Container) constructor #990

Merged
merged 5 commits into from
Apr 25, 2023

Conversation

nilsfriess
Copy link
Collaborator

This PR adds a missing constructor to the buffer class (see the description in the spec here). This constructor allows to construct buffers from containers for which std::data(container) and std::size(container) are valid, e.g., std::vector or std::array.

As described by the spec, write_back is disabled if std::data(container) does return a const pointer, and enabled otherwise. Because of this extra handling, we cannot just delegate to another constructor.

dpol.writes_back = true;

dpol.destructor_waits = true;
dpol.use_external_storage = true;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are we sure we don't want external storage in any case (i.e. never copy input data to internal storage)? For the pointer-based constructors, we:

  • Use external storage and write-back for non-const pointers
  • Copy to internal storage and disable write-back for const pointers

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think I just misunderstood what use_external_storage is supposed to be, I hope I got it right now

Copy link
Collaborator

@illuhad illuhad left a comment

Choose a reason for hiding this comment

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

Thanks, I think it's good now :)

I have only one minor nitpick: In the SYCL headers, we use CamelCase only for template arguments, and snake_case everywhere else, including type traits or constexpr variables - similarly to the C++ standard library.

@illuhad illuhad merged commit 7cff8d4 into AdaptiveCpp:develop Apr 25, 2023
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

2 participants