A couple of questions about C# wrappers

Hello,

I’m using OpenClTemplate passing vector variables through C# code, so there are some simple but unevident things about memory I cant understand.

  1. How can I allocate a buffer? I can’t use clCreateBuffer() 'cause it asks for OpenCl context which simply isnt declaring in the kernel - so I don’t even know a context name. Moreover, OpenClTemplate Codechecker shows an error facing cl_mem type (which seems quite strange).

  2. More obvious, maybe: is it possible to pass a variable directly to private memory either than such way:

kernel void MainKernel(global int *vector) 
{
  int vector2[10];
  for (int i=0; i<10; i++) 
  {
    vector2[i]=vector[i];
   }
}

In other words, can I write something like… kernel void MainKernel(private int *vector)? (that’s not working, of course). 'Cause the problem with the loop approach is that vector size can change and vector2 size is defined before compilation - and so it returns to first question about memory allocation.

Thanks.

Well now I know that there’s no dynamic allocation inside kernel, thanks the forum. First question is out then.

But there is still a problem about private memory (not even related to C# wrappers). It’s hardly possible to leave my vector in global memory - it causes a serious bank conflict and hangs down the screen for a couple of minutes. But how I can properly copy it to private memory without the ability to create variable length array?

Thanks.