For example, if I have :
size_t local_dim[2]= [what should I place here?]
size_t global_dim[2]= [what should I place here?]
ret = clEnqueueNDRangeKernel(command_queue, kernel, 1,
NULL, global_dim, local_dim, 0, NULL, NULL)
Or:
ret = clEnqueueNDRangeKernel(command_queue, kernel, 2,
NULL, global_dim, local_dim, 0, NULL, NULL)
What's the difference in practice if I have 2 dimensions instead of 1 when i call "get_global_id" function in Cl Kernel function? And if I do:
int i = get_global_id(0);
int j = get_global_id(1);
with only two dimensions in For example, if I have :
size_t local_dim[2]= [what should I place here?]
size_t global_dim[2]= [what should I place here?]
ret = clEnqueueNDRangeKernel(command_queue, kernel, 1,
NULL, global_dim, local_dim, 0, NULL, NULL)
Or:
ret = clEnqueueNDRangeKernel(command_queue, kernel, 2,
NULL, global_dim, local_dim, 0, NULL, NULL)
What's the difference in practice if I have 2 dimensions in clEnqueueNDRangeKernel instead of 1 when i call "get_global_id" function in Cl Kernel function? And if I do:
int i = get_global_id(0);
int j = get_global_id(1);
with only two dimensions, which values would I get? Thanks and sorry for such a mess, but I'm very confused!
The difference is obvious. It is not "needed" to have multiple dimensions, you can always have a single dimension. However, it is incredible easier to work with multiple dimension when you are writing a multidimensional problem (Image filters, particle simulations, etc...).
If you set a 2 dimensional 10x10, then 100 work items will be created with ids:
int i = get_global_id(0); int j = get_global_id(1); // 0,0
int i = get_global_id(0); int j = get_global_id(1); // 0,1
...
int i = get_global_id(0); int j = get_global_id(1); // 1,0
int i = get_global_id(0); int j = get_global_id(1); // 1,1
...
int i = get_global_id(0); int j = get_global_id(1); // 9,9
While if you set a 1 dimension of 10x10, OpenCL will ignore the second argument and just create 10x1 work items with ids:
int i = get_global_id(0); int j = get_global_id(1); // 0,0
int i = get_global_id(0); int j = get_global_id(1); // 1,0
...
int i = get_global_id(0); int j = get_global_id(1); // 9,0
You can still call get_global_id() for any dimension, however if it is not the dimension 0, the return value will be 0.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With