Results 1 to 5 of 5

Thread: runtime error

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

    runtime error

    Hi, i am trying to "unwrapp" this Hello world C++ code http://developer.amd.com/gpu/ATIStreamS ... penCL.aspx to C. But during executing clEnqueueNDRangeKernel program drops with this msg:
    Code :
    Unhandled exception at 0x006adeea in LUA.exe: 0xC0000005: Access violation writing location 0x00b495fc.
    here is my program code:
    Code :
    int main (int argc, char *argv[])
    {
     
    ...
    char outH[200]; 
    cl_mem out = clCreateBuffer(context, CL_MEM_WRITE_ONLY | CL_MEM_USE_HOST_PTR, 200, outH, &err);
     
    	const char * ker = "#pragma OPENCL EXTENSION cl_khr_byte_addressable_store : enable \n" \
    					   "__constant char hw[] = \"Hello world!\\n\";						\n" \
    					   "__kernel void hello(__global char * out)                        \n" \
    					   "{                                                               \n" \
    					   "    size_t tid = get_local_id(0);                              \n" \
    					   "    out[0] = hw[0];                                         \n" \
    					   "}";
    	cl_program prog = clCreateProgramWithSource(context, 1,(const char **) &ker, NULL, &err);
    	err = clBuildProgram(prog, num_devices, devices, NULL, NULL, NULL);
     
    	cl_kernel krnl = clCreateKernel(prog, "hello", &err);
    	err = clSetKernelArg(krnl, 0, sizeof(out), out);  
    	cl_command_queue queue = clCreateCommandQueue(context, devices[0], 0, &err);
    	size_t global_size[] = {13, 0, 0};
    	size_t local_size[] = {1, 0, 0};
     
    	err = clEnqueueNDRangeKernel(queue,
    								 krnl,
    								 1,
    								 NULL,
    								 global_size,
    								 local_size, 0, NULL, NULL
    								 );
    ...
    C++ code from amd.com runs smoothly.
    Can anybody help ?

  2. #2
    Senior Member
    Join Date
    May 2010
    Location
    Toronto, Canada
    Posts
    845

    Re: runtime error

    The code is not checking whether any of the functions is returning an error. That is the first thing that you should look at.
    Disclaimer: Employee of Qualcomm Canada. Any opinions expressed here are personal and do not necessarily reflect the views of my employer. LinkedIn profile.

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

    Re: runtime error

    Quote Originally Posted by david.garcia
    The code is not checking whether any of the functions is returning an error. That is the first thing that you should look at.
    that's the first thing that I check in debug mode...every previous function returns CL_SUCCESS...

  4. #4
    Senior Member
    Join Date
    May 2010
    Location
    Toronto, Canada
    Posts
    845

    Re: runtime error

    Did you check the compilation status of the program after calling clBuildProgram()?

    Anyway, I think I found the problem:

    Code :
    err = clSetKernelArg(krnl, 0, sizeof(out), out);

    ...should be instead:


    Code :
    err = clSetKernelArg(krnl, 0, sizeof(out), &out);
    Disclaimer: Employee of Qualcomm Canada. Any opinions expressed here are personal and do not necessarily reflect the views of my employer. LinkedIn profile.

  5. #5
    Junior Member
    Join Date
    Nov 2010
    Posts
    3

    Re: runtime error

    Quote Originally Posted by david.garcia

    Anyway, I think I found the problem:

    Code :
    err = clSetKernelArg(krnl, 0, sizeof(out), out);

    ...should be instead:


    Code :
    err = clSetKernelArg(krnl, 0, sizeof(out), &out);
    thanks!

Similar Threads

  1. Runtime Error
    By luizdrumond in forum OpenCL
    Replies: 2
    Last Post: 01-17-2012, 05:04 AM
  2. fatal error C1189: #error : ERROR: Use of C runtime library
    By gjermani in forum OpenGL ES general technical discussions
    Replies: 1
    Last Post: 09-24-2007, 03:02 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
  •