How do I use local memory in OpenCL?

Posted by splicer on Stack Overflow See other posts from Stack Overflow or by splicer
Published on 2010-03-29T23:29:49Z Indexed on 2010/03/29 23:33 UTC
Read the original article Hit count: 669

Filed under:
|

I've been playing with OpenCL recently, and I'm able to write simple kernels that use only global memory. Now I'd like to start using local memory, but I can't seem to figure out how to use get_local_size() and get_local_id() to compute one "chunk" of output at a time.

For example, let's say I wanted to convert Apple's OpenCL Hello World example kernel to something the uses local memory. How would you do it? Here's the original kernel source:

__kernel square(
    __global float *input,
    __global float *output,
    const unsigned int count)
{
    int i = get_global_id(0);
    if (i < count)
        output[i] = input[i] * input[i];
}

If this example can't easily be converted into something that shows how to make use of local memory, any other simple example will do.

Thanks!

© Stack Overflow or respective owner

Related posts about opencl

Related posts about newbie