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

Codegen_C: buffer compilation needs to special-case scalar buffers #6442

Merged
merged 1 commit into from
Nov 23, 2021

Conversation

steven-johnson
Copy link
Contributor

The existing code will emit something like halide_dimension_t foo_buffer_shape[] = {}; for these, which is a zero-length array, which some compilers will (justifiably) say has no effect. We should be able to just use nullptr for the shape in these cases.

The existing code will emit something like `halide_dimension_t foo_buffer_shape[] = {};` for these, which is a zero-length array, which some compilers will (justifiably) say has no effect. We should be able to just use nullptr for the shape in these cases.
@steven-johnson steven-johnson requested a review from vksnk November 23, 2021 02:05
stream << "halide_dimension_t(" << buffer.dim(i).min()
<< ", " << buffer.dim(i).extent()
<< ", " << buffer.dim(i).stride() << ")";
if (i < buffer.dimensions() - 1) {
Copy link
Contributor

Choose a reason for hiding this comment

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

An alternative (maybe simpler) solution is to just emit a dummy default constructed halide_dimension_t, i.e. {{}}.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True, but then we need to allocate a (trivial) amount of extra space for dimensions that shouldn't ever be used.

@steven-johnson steven-johnson merged commit d12fbd1 into master Nov 23, 2021
@steven-johnson steven-johnson deleted the srj/scalar-c-buffers branch November 23, 2021 17:33
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