This patch fixes: https://github.com/llvm/llvm-project/issues/64738
We observed multiple issues, primarily that the DeviceId was reported as -1
in certain scenarios. The reason for this is simply that the device is not
initialized at that point. Hence, we need to move the RAII object creation just
after the checkDeviceAndCtors, closer to the actual call we want to observe.
This also solves an odering issue where one target enter data callback would
be executed before the Init callback.
Additionally, this change will also fix that the callbacks corresponding to
enter / exit data and update in conjunction with nowait would not result
in the emission of an OMPT callback.
Added a testcase to cover initialized device number and omp target constructs.
Can't you have the RAII here? That way, you don't need the new/delete.
You can add an assert that the type is one of the expected 3.
InterfaceRAII(