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

Drop copy_parameters_t in favor of a nicer copy parameters builder #615

Open
eyalroz opened this issue Mar 16, 2024 · 0 comments
Open

Drop copy_parameters_t in favor of a nicer copy parameters builder #615

eyalroz opened this issue Mar 16, 2024 · 0 comments
Labels

Comments

@eyalroz
Copy link
Owner

eyalroz commented Mar 16, 2024

We currently user a builder-ish copy parameters class, which inherits the actual raw copy parameters. But - it involves a lot of code duplication, use of conditional expressions etc. Perhaps it would be better and simpler to have a builder class which doesn't immediately set the actual copy parameters, and is more structured , i.e. something like

struct copy_parameters_builder_t  {
enum end_t { start = 0, end = 1 };
struct endpoint_t = {
    // context, extent, offset, pitch etc. - possibly as optionals
};
endpoint_t endpoints[2];
endpoint_t& start() { return endpoints[end_t::start]; }
endpoint_t& end() { return endpoints[end_t::end]; }
copy_parameters_t build();
}

Then one could write something like my_builder.start().offset = dim3{1, 2, 3}; }

The downside of this design is less one-liners (although we can always add methods to endpoint_t, and make it hold a reference to the containing copy params build, which can be returned from setter methods)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant