Results 1 to 3 of 3

Thread: Different pointer size on host and device causing problems

  1. #1
    Junior Member
    Join Date
    Aug 2010
    Posts
    3

    Different pointer size on host and device causing problems

    Hi there,

    I have the following situation. I have defined a structure on both host and device, i.e. I have the same definition in a C-header and in the program defining the kernel that is using the structure (since as far as I am aware, there is no way to include files in a program). The structure is something along the line of:
    Code :
    typedef struct tag_hash_table
    {
    	int 				size;
    	bucket *			buckets;
    	data_items *		source;
    } hash_table;

    If I try accessing a bucket in the kernel (say table->buckets[0]->seed), I get
    [CL_INVALID_COMMAND_QUEUE] : OpenCL Fatal Error : Finish caused an error that invalidated the queue (0x100112570). This may be due to a resource allocation failure at execution time.
    Break on OpenCLFatalBreak to debug.
    If I pass only the buckets as an argument to the kernel, everything is fine and I can access all my data. I've noticed that sizeof(hash_table) is 12 on the device, but 24 on the host (sizeof(pointer)=8 + sizeof(int)=4 + sizeof(padding added by compiler) = 4). So my guess is that the different sizes cause this problem. I'm providing the memory by invoking:

    Code :
    cl_mem mem_hash = clCreateBuffer(cl_ctx->ctx, CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR, hashtablesize, hashtable, NULL);

    Any idea how I can get this to work (optionally in a way that is portable), or any idea if this is actually the problem? Since the implementation seems to be getting along just fine with the difference in pointer sizes, since else none of my other code would be working at all. Let me know if you need some additional info.

    Thanks,
    Vassil

  2. #2

    Re: Different pointer size on host and device causing proble

    How do you fill the members in the struct and how to you pass it to the kernel?

    There is a thread that discusses a similar problem at http://www.khronos.org/message_board...hp?f=37&t=2900

  3. #3
    Junior Member
    Join Date
    Aug 2010
    Posts
    3

    Re: Different pointer size on host and device causing proble

    Ah, I guess that is exactly the problem I have! Thank you for pointing me in the right direction

Similar Threads

  1. Transferring Data from Host to Device
    By abhishekray07 in forum OpenCL
    Replies: 1
    Last Post: 02-02-2012, 02:48 AM
  2. Transfers between host and device memory
    By ldsolano in forum OpenCL
    Replies: 5
    Last Post: 11-09-2011, 05:35 PM
  3. Normal Pointer Array Size
    By NikLever in forum OpenGL ES 1.X - fixed function hardware
    Replies: 2
    Last Post: 06-10-2009, 09:32 AM

Posting Permissions

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