memory - Declare __global object inside kernel -


i tried declare __global memory chunk inside kernel, like

__global float arr[200]; 

i assume create array in global memory referred in kernel. program compiled successfully, when run it, indicated:

error: variable automatic storage duration cannot stored in named address space

i don't know why happen. in order use global memory, did have create buffer on host side before use it?

if want create array shared threads, except passing new argument global array, can instead ?

you can allocate in program scope, @ least in opencl 2.

__global float arr[200]; kernel void foo() {    if(get_global_id(0) == 0)      arr[0] = 3; } 

though careful initialization of course, there's no way synchronize work-items across dispatch not practical initialize , use in same kernel if have multiple work-groups.

it doesn't make sense allocate in kernel scope. if work-groups serialized, lifetime of global array allocated in kernel code? should outlast workgroup, dispatch, stay permanently shared between kernel , next? obvious might have same lifetime kernel, impossible initialize , use without race. if persistent across multiple kernels host allocation or program scope allocation makes more sense.

why passing new argument such problem?


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -