Hi, This issue has been sitting in my personal to-do list for quite long. We can do so many performance hints with asserts, likely and unlikely hints and it would be good not to have them as runtime checks.
I think right now we don't have a mechanism to have a workaround for that. Could you please file an issue, so we don't miss it for the next release? Dmitry. On Thu, Jan 14, 2021 at 1:06 AM [email protected] < [email protected]> wrote: > Hi, > > I use asserts to a) guarantee compliance (eg preconditions), and b) hint > to the compiler about constraints it can take advantage of. > > A contrived example: > https://godbolt.org/z/fb5x8s > > unmasked uniform int Total(uniform int numbers[], uniform int count) > { > assert(count==32); > int total = 0; > foreach(i = 0...count) > { > total += numbers[i]; > } > return reduce_add(total); > } > > The assert for count==32 allows the compiler to generate much leaner code > for the loop. If I compile with --opt=disable-assertions for an optimized > release build, the code gen becomes worse. > > I think there are two parts to this: > 1) It seems counter-intuitive that the constraints introduced by asserts > are being removed. The reason I would disable asserts is to remove the > runtime checks, failure path and associated string constants. It would be > an unusual use-case to want to disable them in-order to allow non-compliant > data to be used, thus requiring the less optimal code-gen. > 2) Is there a reliable alternative to assert() that could apply hints to > the compiler instead? I know that there are tricks where you can add > mutating no-op statements like count=32; (https://godbolt.org/z/9411vc) > but sometimes the constraint is trickier to express than that (eg enforce a > pointer is not-null), or the data is const and can't be no-op mutated. For > these, assert is quite convenient. > > > -- > You received this message because you are subscribed to the Google Groups > "Intel SPMD Program Compiler Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ispc-users/62df8d30-9b1f-441f-9f2b-4060fa51fa4fn%40googlegroups.com > <https://groups.google.com/d/msgid/ispc-users/62df8d30-9b1f-441f-9f2b-4060fa51fa4fn%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Intel SPMD Program Compiler Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ispc-users/CACRFwuhRBr9yt_V7H_N7oU4jSUO2We90on5ek%2B34xw8oJ-uSAg%40mail.gmail.com.
