How can i identify the stream number inside a callback function

I have a project which contains a kernel, two streams and a callback function.

Let me show you the code skeleton.

/* The parameters i am passing to callback function */
typedef struct {

           uint8_t alpha;
           uint16_t beta;
           uint8_t gamma;
           .
           uint32_t stream0_argument;
           uint32_t stream1_argument;
           .
           .           
}CallbackArgumentStruct *CallbackArgumentsPointer;

The main body:

loop {
.
.
kernel<,,,stream0>
kernel<,,,stream1>

cudaStreamAddCallback(stream0,...., &CallBackFunction1, 0);
cudaStreamAddCallback(stream1,...., &CallBackFunction2, 0);
.
.
}

The CallBackFunction1 and CallBackFunction2 are identical in their procedure but their is only a single argument which is different for both, let say stream0_argument is used when the callback function is called by stream0 and stream1_argument is used if callback function is called by stream1.
So instead of two callbacks, i would like to use a single callback definition for both.

The solution that i have in mind:

  1. I can use a simple if-statement inside callback to select the corresponding value if i somehow knew the stream number in which the callback is called. [One function definition, Same pointer passed to both]

  2. Use two definitions of callbacks [Two function definition, single pointer passed to both]

  3. Use single callback definition with two different pointers. [Single function definition, two different pointers]

Any suggestions ?

have you read the programming guide documentation?

https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#stream-callbacks

the first parameter passed to your callback function is the stream

also note, for reference, that it is illegal to make any cuda runtime or driver API calls inside a callback

Oh!, i think i need a coffee.

Thank you Robert_C*