Results 1 to 10 of 11

Thread: vloadn and vstoren

Hybrid View

  1. #1
    Junior Member
    Join Date
    Feb 2014
    Posts
    15

    vloadn and vstoren

    Hi everybody, this is my first post on khronos forum so I would to say hello to community

    My problem concerns the access to an array using the vstore and vload functions. My kernel function is declared like:

    __kernel void wordCount(__global const char *a,__global char *o)
    {
    int index = get_global_id(0);

    char8 c = vload8(0,a);

    vstore8(c,0,o);

    }

    so the input is in *a and the output should be *o. This func should load a part of *a array to c (according to the thread id) and save it into the output variable so as to have same input and output.

    Ps I know it is stupid example but i have to understand how to access to an array.

    Thankyou

  2. #2
    Senior Member
    Join Date
    Oct 2012
    Posts
    111
    Your use of vload8() and vstore8() is legal but you probably mean:

    char8 c = vload8(index, a);
    vstore8(c, index, o);

  3. #3
    Junior Member
    Join Date
    Feb 2014
    Posts
    15
    yes I have already done this but it does not work. I know how the memory works.
    Unfortunately when I use an input greater than 2 letters I receive in output some strange symbols.

  4. #4
    Junior Member
    Join Date
    Feb 2014
    Posts
    15
    Can nobody else help me?

  5. #5
    Senior Member
    Join Date
    Oct 2012
    Posts
    111
    You should give more information, such as the way you allocate and fill your buffers, and the work sizes of clEnqueueNDRangeKernel().

  6. #6
    Junior Member
    Join Date
    Feb 2014
    Posts
    15

    char array Java C

    OK i'm sorry. Before I thought my problem was inside kernel, now I understood it could be the different size of a char array between c and java.
    In java one char is big 2 byte while in c it is just 1.

    Code :
     
    char chunk[] = new char[]{'a','b','c','d','e'};
     
    Pointer srcA = Pointer.to(chunk);
     
    memObjects[0] = clCreateBuffer(context, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR,Sizeof.cl_char * (chunk.length*2), srcA, null);
     
    clEnqueueWriteBuffer(commandQueue, memObjects[0], CL_TRUE, 0, chunk.length * Sizeof.cl_char, srcA, 0, null, null);
     
    clSetKernelArg(kernel, 0, Sizeof.cl_mem, Pointer.to(memObjects[0]));
     
    clEnqueueNDRangeKernel(commandQueue, kernel, 1, null, global_work_size, local_work_size, 0, null, null);

    the kernel is shown above.
    I run the kernel with just 5 threads. when I get out my output array (declared as the input) I don't obtain the same value, because surely I don't write correctly the array inside kernel.

    Now I would like to know if there is a way to resolve this problem that giving me worries!!

    Thankyou.

    Sorry if other info are missing.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •