Results 1 to 4 of 4

Thread: clEnqueueWriteBuffer causes segmentation fault

  1. #1
    Junior Member
    Join Date
    Aug 2012
    Posts
    18

    clEnqueueWriteBuffer causes segmentation fault

    Hi,
    I am developing OpenCL code to run my application simultaneously on multiple platforms. For testing purpose I am using only one platform (AMD APP) with Cayman device (dual gpu card) and OpenCL 1.2 version.
    While developing, I am getting segmentation fault in the following bold line:

    Code :
    maxSize = 3;
    blockSize = 64;
    for(icount = 0; icount < numDevices; icount++)
    {
              //printf("Initializing Memory Buffer on device : %s\n", device_name[icount]);
              start_itr = (icount * maxSize);
              end_itr = start_itr + (maxSize -1);
          [b]clret = clEnqueueWriteBuffer(queue[icount], d_new_input_2d[icount], CL_TRUE, 0, maxSize * blockSize * sizeof(char), &hNewInputPerBlock[(start_itr * blockSize)], 0, NULL, NULL);[/b]
    }

    As I think, each OpenCL API's routines return error number if there is any mistake in its parameters. So what could be reason for segmentation fault in these routines ?

    Thanks !

  2. #2
    Senior Member
    Join Date
    Oct 2012
    Posts
    108

    Re: clEnqueueWriteBuffer causes segmentation fault

    Most probably a wrong pointer or an array overflow.
    In particular, check the size parameter. It seems dubious (shouldn't it take start_itr into account?)

  3. #3
    Junior Member
    Join Date
    Aug 2012
    Posts
    18

    Re: clEnqueueWriteBuffer causes segmentation fault

    I checked the size parameter and buffer overflow, everything is fine.
    Regarding the start_ptr, size parameter need not to include this.

    One doubt i have about OpenCL implementation for multiple platform to run my applications simultaneously on all available devices across all the available platforms. Please correct me, if my implementation is wrong. To do so, I declared the OpenCL data structures as following:
    Code :
    cl_platform_id          *platforms = NULL;  //OpenCL Platform IDs (single pointer)
    cl_uint                      num_platforms;       //Storing number of platforms
    cl_device_id             **devices = NULL;   //OpenCL Device IDs (double pointer)
    cl_uint                      *num_devices;      //Storing number of devices for each platform
    cl_context                 *context = NULL;   //OpenCL context pointer of size equal to number of available platforms (single pointer)
    [b]cl_command_queue  *command_queue1; //OpenCL command queues (single pointer)[/b]
    cl_uint                       *num_command_queues; //Storing number of command queues
    cl_int                         platform_id = -1;   //Counter variable to count number of platforms 
    [b]cl_mem                     *d_new_input_2d;  //OpenCL device buffer (single pointer)[/b]

    My doubt is in two declarations (command queues and device buffer). As i mentioned that i am developing OpenCL code for multiple platforms, considering this point in my mind,
    1. can i declare command queues as a single pointer of size equal to number of available OpenCL devices across all available platforms?
    2. can i declare device buffer as a single pointer of size equal to number of available OpenCL devices across all available platforms?

  4. #4
    Junior Member
    Join Date
    Aug 2012
    Posts
    18

    Re: clEnqueueWriteBuffer causes segmentation fault

    I found the reason of getting segmentation fault in clEnqueuWriteBuffer() function.
    the first parameter, command queue was NULL value, due to that I was getting segmentation fault.

Similar Threads

  1. Segmentation fault (core dumped )
    By jainx224 in forum OpenCL
    Replies: 1
    Last Post: 03-18-2013, 08:32 AM
  2. Segmentation fault while creating command queue
    By whitepearl in forum OpenCL
    Replies: 2
    Last Post: 03-23-2012, 01:13 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
  •