hardware problem related to OpenCL

When get_global_id() is used to different devices, the return value is obviously different. Who is in charge of the id configruation to different device? Is is the hardware or the SDK by manufactor?

This Function will give you the thread ID and should be [0;get_global_size()-1] on all devices. if thats not the case, your openCL impelementation is not valid and the hardwaremanufactor who provides you your library should fix that.

Does the function get_global_id() ask the operating system to generate a new thread? If so, who index this thread? The operating system or the function get_global_id()?

No, the function get_global_id() just returns the index of the thread (work-item) that is executing. When you call clEnqueueNDRangeKernel(), you specify how many threads (work-items) you want to create. Each work-item will run an instance of your kernel, and each will receive a different index from get_global_id().

For example, if I have a kernel defined as:


__kernel void foobar()
{
  int i = get_global_id(0);
  printf("Executing work-item %d
", i);
}

and I execute this kernel like this:


size_t global = 4;
clEnqueueNDRangeKernel(queue, kernel, 1, NULL, &global, NULL, 0, NULL, NULL);

This will create 4 work-items (the global size), and you will see output like this:


Executing work-item 0
Executing work-item 1
Executing work-item 2
Executing work-item 3

(although these may appear in a different order, since these work-items can execute in parallel).

I hope that makes things a little clearer.

yes, I see. Thank you!