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 CudaPrimaryContext object has a destructor which calls into the driver (cuDevicePrimaryCtxRelease). But since these objects are stored in a static map, the destructor will run below main, and this is UB per the cuda programming guide
get_primary_cuda_context is not thread-safe since access to the static map is not protected by a lock.
Since kvikio is header-only, we rely on the linker to disambiguate inline functions that have (or return) static references. To do this, the relevant function must have __attribute__((visibility("default"))). If not, then if kvikio is used in two different DSOs, the function will appear twice, and there will be two static objects.
By default, I believe all rapids libraries are compiled with -fvisiblity-inline-hidden. So kvikio::get_primary_cuda_context (which is inline) will be __attribute((visibility("hidden"))). Thus, if kvikio is used from two separate DSOs, calls from the respective DSOs to get_primary_cuda_context will reference different global statics (since the functions are not the same).
To solve these:
We just need to leak the contexts, I think.
We can add a lock
We should explicitly mark this function as __attribute__((visibility("default")))
The text was updated successfully, but these errors were encountered:
CudaPrimaryContext
object has a destructor which calls into the driver (cuDevicePrimaryCtxRelease
). But since these objects are stored in astatic
map, the destructor will run below main, and this is UB per the cuda programming guideget_primary_cuda_context
is not thread-safe since access to thestatic
map is not protected by a lock.Since kvikio is header-only, we rely on the linker to disambiguate
inline
functions that have (or return) static references. To do this, the relevant function must have__attribute__((visibility("default")))
. If not, then if kvikio is used in two different DSOs, the function will appear twice, and there will be two static objects.By default, I believe all rapids libraries are compiled with
-fvisiblity-inline-hidden
. Sokvikio::get_primary_cuda_context
(which isinline
) will be__attribute((visibility("hidden")))
. Thus, if kvikio is used from two separate DSOs, calls from the respective DSOs toget_primary_cuda_context
will reference different global statics (since the functions are not the same).To solve these:
__attribute__((visibility("default")))
The text was updated successfully, but these errors were encountered: