We would like to add user task analysis to a project. The collection in our case is best achieved using a callback registration mechanism, which has a bit of overhead, but has the advantage that the overhead could potentially zero in case no user task analysis has been requested.
To achieve this, we check the domain->flag to see if analysis is active, and only in that case register the callbacks. Unfortunately, it seems that the flag is non-zero as soon vtune is attached (regardless if user task analysis has been requested or not).
Is there a way to check from within the application if user task analysis has been requested?
I think there is no easy way to detect from a user app whether User Task Analysis is enabled.
In my opinion, as it's a static mechanism of registering call backs, its control should be done at compile time as well. But if you decide to take a risk and leave the itt library linked with your production app, than you should expect it is launched under profiler and the callbacks are active (creating some overhead). In this case you can only control by checking "if (profile == TRUE)" condition before calling itt API functions in your code.