creating a stack in the kernel

i wanted to create a stack in the kernel is it possible to use a c++ stack ? if not can u suggest me a way of creating a stack . i cannot use an array to create a stack because the size of the stack is going to be very large.

Use a “buffer” in OpenCL global device memory.

This sounds like a very interesting library / pattern to implement.
As Dithermaster said, you need to use a buffer, especially if you’re planning it to be large. There are a few explanations and open-source implementations which show how to create a stack using an array (which is what a buffer is).
For example: