Thread-safely and lazily initialise several variables
Instead of initialising them at load-time with non-trivial types, let's use the C++11 requirement that function-local statics are thread-safely initialised on first use. This also removes the need to keep a boolean indicating whether the variable has already been initialised in the first place.
Hi @thiagomacieira, thank you for the PR. Unfortunately, this PR breaks the priority of calls reflected in oneDNN doc. Env variable is respected if and only if functional call hasn't been used.
That is retained for the verbose flag. All others don't have an API to set a value with.
That is retained for the
verboseflag. All others don't have an API to set a value with.
I have certain doubts it is retained in new version. Let's imagine the case when user calls dnnl_set_verbose(0) specifically making the program not to respect env var before any calls to primitive descriptors. Imagine we call this binary with DNNL_VERBOSE=2 wanting to figure out oneDNN calls. With new logic it goes to static function, reads env var regardless of program choice AND if value was bigger than 0 (exactly our case) will dump the header information. Then it will set the value to 0.
With old version such behavior would never happen.
We don't have tests for this but I don't think this can be tested easily since it involves stdout.
Could you check if it happens the way described, please? Thank you.
Edit: It seems that moving header printing logic under get_verbose() call after get() call should make it work as expected. What do you think?
Closing as there are no plans to promote this PR.