Using cudaStreamBeginCapture()

Hi
Is there a way to check if a kernel is called inside a stream capture mode?
There is an example from the manual:

cudaStreamBeginCapture(stream);

kernel_A<<< ..., stream >>>(...);
kernel_B<<< ..., stream >>>(...);
libraryCall(stream);
kernel_C<<< ..., stream >>>(...);

cudaStreamEndCapture(stream, &graph);

Assume there are cases in other part of the program that call kernel_A without capture mode. When kernel_A is called, I want to know if it is called after the beginCapture or not.
Any idea about that?

In the programming guide, it says below your quoted example: " When a stream is being captured, work launched into the stream is not enqueued for execution."

kernel_A will not be executed if stream capture is in progress for the kernel’s stream.

I am a bit confused about the functionality of that. If kernel_A is not executed because of cudaStreamBeginCapture, then when is it going to be executed? After cudaStreamEndCapture?

The kernel is executed when you launch the executable graph that needs to be constructed from the captured sequence.