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

Deprecate old-style realize() methods #5676

Merged
merged 7 commits into from
Feb 5, 2021
Merged

Deprecate old-style realize() methods #5676

merged 7 commits into from
Feb 5, 2021

Conversation

steven-johnson
Copy link
Contributor

@steven-johnson steven-johnson commented Jan 28, 2021

We had 5 extra variants of realize() (for 0-dim thru 4-dim cases); these are a holdover from both having a limit of 4 dimensions (ie, pre-halide_buffer_t) and also from pre-C++11 (ie, passing in initializer-lists of int was less convenient). Let's deprecate these for Halide 12 and remove them in Halide 13.

(Yes, this touches a lot of existing code.)

We had 5 extra variants of realize() (for 0-dim thru 4-dim cases); these are a holdover from both having a limit of 4 dimensions (ie, pre-halide_buffer_t) and also from pre-C++11 (ie, passing in initializer-lists of int was less convenient). Let's deprecated these for Halide 12 and remove them in Halide 13.

(Yes, this touches a *lot* of existing code.)
@steven-johnson steven-johnson added the release_notes For changes that may warrant a note in README for official releases. label Jan 28, 2021
@@ -1174,7 +1174,7 @@ void test_async_tuple(const Backend &backend) {

// Run 10 times to make sure race condition do not happen
for (int iter = 0; iter < 10; iter++) {
Realization out = consumer1.realize(2 * img_size);
Realization out = consumer1.realize({2} * img_size);
Copy link
Member

Choose a reason for hiding this comment

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

?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yikes. My RegExp-fu for fixing these failed. Let me manually recheck them all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I missed a lot of stuff. Oops.

@steven-johnson
Copy link
Contributor Author

Only errors are the correctness_interpreter flakes.

@steven-johnson
Copy link
Contributor Author

Adding a few more folks for review to comment on the concept of this deprecation proposal.

@jrk
Copy link
Member

jrk commented Jan 29, 2021

Fortunately, JIT is certainly used less in most of the big codebases we know about, but perhaps this should go to the Gitter community, too, for wider feedback on potential adverse effects from something so fundamental?

Are there potentially bad consequences for affected code, or will this always just give a straightforward type error at compile time?

It seems more annoying in Python, where the errors won’t appear until runtime. (We could make the APIs diverge slightly with a little sugar at the Python level to still allow the old style interface, and pack the list before passing through to the new C++ interface.)

@steven-johnson
Copy link
Contributor Author

Are there potentially bad consequences for affected code, or will this always just give a straightforward type error at compile time?

Nope, it should always be a compile error for C++.

It seems more annoying in Python, where the errors won’t appear until runtime. (We could make the APIs diverge slightly with a little sugar at the Python level to still allow the old style interface, and pack the list before passing through to the new C++ interface.)

It's actually a little worse than that: AFAICT, you have to run Python with the right flags (eg -Wd for dev mode) to get the deprecation warnings to appear at all. (Not sure if there is some way to flag the methods in some way that would trigger PyLint warnings.)

I still think it's a minor but useful longterm change. Part of the motivation here (on my part) is to minimize divergence and reduce the API surface area. Having multiple API variants to do the same thing is IMHO an anti-feature; the old C++ API style was present for reasons that no longer apply. And at this point I think that having variadic arguments as part of our public API is something to generally be avoided, except where the language convenience of doing so is absolutely compelling.

@abadams
Copy link
Member

abadams commented Jan 29, 2021

I think it's a good change, but I'm not comfortable asserting that because of the python issue, and because I don't use the JIT a whole lot (except for tests). I agree we should check with more people. E.g. maybe @mikewoodworth could weigh in. I think he uses the JIT.

@mikewoodworth
Copy link
Contributor

I'm all for simplifying the api. I don't think this will affect us at all, we only ever realize into preallocated buffers.
It seems like other JIT users who do hit this deprecation will be caught by compiler and fixed with a few [] right?

@steven-johnson
Copy link
Contributor Author

It seems like other JIT users who do hit this deprecation will be caught by compiler and fixed with a few [] right?

In theory, yes.

@steven-johnson
Copy link
Contributor Author

Any more thoughts on this? (No rush to land it, obviously, but if we have consensus then moving forward seems good)

@steven-johnson
Copy link
Contributor Author

Any other comments from folks before I land this? I'll wait another day or two.

@steven-johnson
Copy link
Contributor Author

Failure is unrelated.

@steven-johnson steven-johnson merged commit 27be859 into master Feb 5, 2021
@steven-johnson steven-johnson deleted the srj/deprecate branch February 5, 2021 19:58
@alexreinking alexreinking added this to the v12.0.0 milestone Feb 16, 2021
@alexreinking alexreinking removed the release_notes For changes that may warrant a note in README for official releases. label Apr 6, 2022
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.

5 participants