-
Notifications
You must be signed in to change notification settings - Fork 10
Buffer Handling: Multiple Arrays
Hüseyin Tuğrul BÜYÜKIŞIK edited this page Mar 31, 2017
·
3 revisions
When a kernel needs multiple parameters(opencl buffers in "C" space) like in this code:
__kernel void vectorAdd(__global int * a,__global int * b,__global int * c)
{
int i=get_global_id(0);
c[i]=a[i]+b[i];
}
client code needs to use nextParam
method to add new arrays(as parameters) in exact same order in kernel:
ClNumberCruncher cr = new ClNumberCruncher(
AcceleratorType.GPU, @"
__kernel void vectorAdd(__global int * a,__global int * b,__global int * c)
{
int i=get_global_id(0);
c[i]=a[i]+b[i];
}
");
ClArray<int> A = new ClArray<int>(1000);
ClArray<int> B = new ClArray<int>(1000);
ClArray<int> C = new ClArray<int>(1000);
A.nextParam(B,C).compute(cr, 1, "vectorAdd", 1000, 100);
so here A
is bound to __global int *a
, B
is bound to __global int *b
and C
is bound to __global int *c
then array C
will have results after compute(cr,...)
command.