How to create a semaphore importable by cuImportExternalSemaphore?

How can I create a semaphore importable by cuImportExternalSemaphore (specifically on Windows)? Is creating a semaphore via Vulkan the only option (CreateSemaphore does not work for me)? Dragging in a complex (graphics!) dependency in seems like a pain, especially if I want to use the new cuMem-options for IPC on Windows (no graphics), or if I want to use OpenGL for graphics and not Vulkan.

1 Like

I’m also curious about this - we really would like to use the timeline semaphore semantics in CUDA to get the various signal/wait behaviors but not have to bring in Vulkan to create them :)

Good to see that I am not the only one to have run into this issue. The IPC example synchronizes both sides with a CPU semaphore and cudaStreamSynchronize which seems less than optimal (especially if I want to synchronize, say - OpenGL rendering in one process and CUDA in the other… or two CUDA processes). It would be so great if we could create shareable handles from a CUDA event.

You can create IPC shareable handles from a CUDA event.

But cudaIpc is Linux-only? So not relevant to my use case (Windows/Cross-Platform).

Also: is it OpenGL-Importable?

with the latest versions of CUDA on windows 10, cuda IPC mechanisms work on windows, both in TCC and WDDM driver models. Take a look at the simpleIPC sample code in CUDA 11.2

I don’t know what you mean by OpenGL-Importable.

That’s nice for the IPC case. re OpenGL i’m talking about: https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_external_objects.txt (Vulkan semaphores can be imported in both CUDA and OpenGL)