Skip to content

Instantly share code, notes, and snippets.

@ginkgo
Last active August 29, 2015 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ginkgo/9a552a07075c2cec726a to your computer and use it in GitHub Desktop.
Save ginkgo/9a552a07075c2cec726a to your computer and use it in GitHub Desktop.
void krnl1_fn(__global int* A,
local int* l)
{
if (get_local_id(0)==0) {
*l = A[get_global_id(0)];
}
barrier(CLK_LOCAL_MEM_FENCE);
A[get_global_id(0)] = *l;
}
void kernel krnl1(global int* A)
{
// Create a local variable and use it
local int l;
krnl1_fn(A, &l);
}
void kernel call(__global int* A)
{
void (^block)(void) =
^{
local int l;
krnl1_fn(A, &l);
};
clk_event_t done;
enqueue_kernel(get_default_queue(),
CLK_ENQUEUE_FLAGS_NO_WAIT,
ndrange_1D(1024,64), 0, NULL, &done,
block);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment