setKernelArg as size in bytes and NULL for __global pointers

Similar to how you can pass a size in bytes and a NULL value for a __local pointer when you want to dynamically allocate some local memory, it would be useful to do the same for a __global pointer. If you don’t be read or write to the __global pointer from any other device, why must you create a buffer which would seem to have more overhead than necessary? Think of any time you need some temporary scratch local memory, but you need a lot more of it than available, i.e., some temporary scratch global memory. If you can program this way for local memory then why not for global memory?

Because global memory is a shared resource that persists beyond the scope of a kernel. It is better to let the application allocate and reused it’s allocated buffers as it knows best. Local memory cannot be preserved or shared in this way, and “allocation” of it for this purpose does not require a sophisticated allocator (it can be done with just a free pointer add at kernel launch).