Alloction of local memory within kernel

I have a simple question that I have searched for but cannot find the answer. If within a kernel, I declare a variable to be __local, does openCL allocate a region in local memory for each work item within a work group so that each one gets its own memory space but just physically located within local memory, or does it allocate one piece of memory and each work item within the group shares the same piece of memory? From my understanding it is the second, but I wanted to make sure. Thanks

It’s the second.

__local is shared local memory, so it’s a single piece of memory that every work item in a work group can access. It’s essentially a programmer-managed cache, and frequent used for bandwidth optimizations. You’ll need barriers to ensure memory consistency between the filling and the using of shared local memory.

By contrast, __private is memory specific to each work item (each work item has a unique storage location).