Replies: 3 comments 5 replies
-
It still doesn't have a short-circuiting ternary expression, however you can inject if statements around blocks of computation using RDom::where, to turn on and off individual update steps on an update definition as a function of some boolean expression |
Beta Was this translation helpful? Give feedback.
-
Thanks, that works. Is it possible to use vectorization on such an Is it also possible to inline the initialization in the update? E.g. in the following code:
Is it possible the schedule the init |
Beta Was this translation helpful? Give feedback.
-
You can vectorize one of the pure vars in an update definition (or an rvar that obeys the same restrictions as a pure var). The code that gets generated adds vector predicates to all loads and stores. You can't do much scheduling-wise with that update definition as you have written it. Is it possible to use Vars instead of RVars? E.g. if there's no actual reduction and you just need the RDom for the if statement, you could rewrite it as:
If you do that you can schedule canvas much more flexibly, e.g the following would wrap it up into a single loop nest and vectorize and parallelize it:
|
Beta Was this translation helpful? Give feedback.
-
I was skimming through this old paper about writing a ray-tracer in Halide, and they mention that Halide doesn't have a classical lazy if-then-else statement or ternary expression, because that doesn't vectorize.
Is that still the case?
Beta Was this translation helpful? Give feedback.
All reactions