cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

lanyuer
Journeyman III

why clGetDeviceIDs returns -1?

My Gpu is HD5470, and I've installed the newest Catalyst & Stream SDK.

Once I run the examples in the opencl demos, when it runs up to the line:

status = clGetDeviceIDs(platform, deviceType, 0, NULL, &deviceCount);

the variable "status" returns -1, and the program crashed!

I wanna to know what does that mean and how can I fix it?

0 Likes
2 Replies
himanshu_gautam
Grandmaster

Error code -1 means device not found. Most probably you have some installation issue if you are running the sample code.

I would like to tell that you can find meaning of any error code from file cl.h which is present in ATIStream\include\CL  folder. You can get more information about this error code and waht all might be the reasons for it from the openCL spec 1.1 which can be found easily online.

I hope with latest you mean catalyst 10.12 and SDK 2.3.

0 Likes

I don't think the spec actually lists error codes. Here is the function from clUtil that converts error codes into human readable strings.

const char* clUtilGetErrorCode(cl_int err)
{
  switch(err)
  {
    case CL_SUCCESS:
      return "No Error.";
    case CL_INVALID_MEM_OBJECT:
      return "Invalid memory object.";
    case CL_INVALID_ARG_INDEX:
      return "Invalid argument index for this kernel.";
    case CL_INVALID_ARG_VALUE:
      return "Invalid argument value.";
    case CL_INVALID_SAMPLER:
      return "Invalid sampler.";
    case CL_INVALID_ARG_SIZE:
      return "Invalid argument size.";
    case CL_INVALID_BUFFER_SIZE:
      return "Invalid buffer size.";
    case CL_INVALID_HOST_PTR:
      return "Invalid host pointer.";
    case CL_INVALID_DEVICE:
      return "Invalid device.";
    case CL_INVALID_VALUE:
      return "Invalid value.";
    case CL_INVALID_CONTEXT:
      return "Invalid Context.";
    case CL_INVALID_KERNEL:
      return "Invalid kernel.";
    case CL_INVALID_PROGRAM:
      return "Invalid program object.";
    case CL_INVALID_BINARY:
      return "Invalid program binary.";
    case CL_INVALID_OPERATION:
      return "Invalid operation.";
    case CL_INVALID_BUILD_OPTIONS:
      return "Invalid build options.";
    case CL_INVALID_PROGRAM_EXECUTABLE:
      return "Invalid executable.";
    case CL_INVALID_COMMAND_QUEUE:
      return "Invalid command queue.";
    case CL_INVALID_KERNEL_ARGS:
      return "Invalid kernel arguments.";
    case CL_INVALID_WORK_DIMENSION:
      return "Invalid work dimension.";
    case CL_INVALID_WORK_GROUP_SIZE:
      return "Invalid work group size.";
    case CL_INVALID_WORK_ITEM_SIZE:
      return "Invalid work item size.";
    case CL_INVALID_GLOBAL_OFFSET:
      return "Invalid global offset (should be NULL).";
    case CL_OUT_OF_RESOURCES:
      return "Insufficient resources.";
    case CL_MEM_OBJECT_ALLOCATION_FAILURE:
      return "Could not allocate mem object.";
    case CL_INVALID_EVENT_WAIT_LIST:
      return "Invalid event wait list.";
    case CL_OUT_OF_HOST_MEMORY:
      return "Out of memory on host.";
    case CL_INVALID_KERNEL_NAME:
      return "Invalid kernel name.";
    case CL_INVALID_KERNEL_DEFINITION:
      return "Invalid kernel definition.";
    case CL_BUILD_PROGRAM_FAILURE:
      return "Failed to build program.";
    case -1001: //This is CL_PLATFORM_NOT_FOUND_KHR
      return "No platforms found. (Did you put ICD files in /etc/OpenCL?)";
    default:
      return "Unknown error.";
  }
}

I then use this macro after every OpenCL call to check the error:

#define clUtilCheckErrorVoid(err)\
{\
  if(err != CL_SUCCESS)\
  {\
    printf("%s:%d:%s():\n\t%s\n",\
           __FILE__,\
           __LINE__,\
           __func__,\
           clUtilGetErrorCode(err));\
    raise(SIGTRAP);\
    return;\
  }\
}

0 Likes