You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
... the recommended best practice for instrumenting header-based libraries with NVTX C++ Wrappers is is to #define NVTX3_CPP_REQUIRE_EXPLICIT_VERSION before including nvtx3.hpp, #undef it afterward, and only use explicit-version symbols.
However, this breaks user code using the unversioned API directly.
For example:
#include<my_library.hpp>// includes NVTX3
#include<nvtx3/nvtx3.hpp>// user also includes NVTX3intmain() {
nvtx3::scoped_range domain; // user uses unversioned API
}
the above user program breaks, because the unversioned API is no longer provided.
This happens in the second case because the first inclusion of nvtx3.hpp defines NVTX3_CPP_DEFINITIONS_V1_0 and emits the symbols into namespace nvtx3::v1 and v1 is not an inline namespace because NVTX3_CPP_REQUIRE_EXPLICIT_VERSION is defined. The second inclusion will then see that NVTX3_CPP_DEFINITIONS_V1_0 is already defined and not provide the unversioned API (e.g., by inlining the v1 namespace).
We observed this behavior at the following PR to CCCL/CUB: NVIDIA/cccl#1688
I therefore think that header-only libraries must not define NVTX3_CPP_REQUIRE_EXPLICIT_VERSION to not break user code. Please correct me if I am wrong. Otherwise, I would kindly ask you to update the guidance provided by the documentation.
The text was updated successfully, but these errors were encountered:
The problem basically is that we cannot have the explicit and non-explicit API of the same version in the same TU. What is your guidance to resolve this? Thx!
Hi, the documentation for
NVTX3_CPP_REQUIRE_EXPLICIT_VERSION
in thenvtx3.hpp
header containing the C++ API explains the following:However, this breaks user code using the unversioned API directly.
For example:
If
my_library.hpp
now changes fromto
the above user program breaks, because the unversioned API is no longer provided.
This happens in the second case because the first inclusion of
nvtx3.hpp
definesNVTX3_CPP_DEFINITIONS_V1_0
and emits the symbols into namespacenvtx3::v1
andv1
is not an inline namespace becauseNVTX3_CPP_REQUIRE_EXPLICIT_VERSION
is defined. The second inclusion will then see thatNVTX3_CPP_DEFINITIONS_V1_0
is already defined and not provide the unversioned API (e.g., by inlining thev1
namespace).We observed this behavior at the following PR to CCCL/CUB: NVIDIA/cccl#1688
I therefore think that header-only libraries must not define
NVTX3_CPP_REQUIRE_EXPLICIT_VERSION
to not break user code. Please correct me if I am wrong. Otherwise, I would kindly ask you to update the guidance provided by the documentation.The text was updated successfully, but these errors were encountered: