PDA

View Full Version : Serveral problems in OpenCl,Help!



fuxianjun
06-10-2010, 02:00 AM
I want to program an algebra calculation which must be devided into two parts, the latter's input is the former's output.
For example:
The former part is to use a vector (vectorA with n factors) as its input to add another vector(vectorB with n factors), the output is vectorC.
The latter part is to use vectorC as the input paramter of some algebra fucntions F(X)(X is vector type), because of F(X) is variable, the whole calculation must be took apart.

My problems are:
For the first part, if the kernel is:
__kernel void adder(__global const float* a, __global const float* b, __global float* result)
{
int idx = get_global_id(0);
result[idx] = a[idx] + b[idx];
}
1.Dose each work item excute only once?
2. For vectorA (with n factors) plus vectorB(with n factors), must there be n work items to complete the addition.
3.Are the n work items in the same work group?
4.In what condition, the work items are in different work group?

5.I want to continue the latter part of this calculation,input vectorC which is in global memory to kernel which has the same function of F(X), what can I do? Use event or commandqueue or some else? How ?

That's all,please help me!

matrem
06-10-2010, 03:15 AM
1. Dose each work item excute only once?
Yes a work item (has an unique global id) execute once for an ndrange.

2. For vectorA (with n factors) plus vectorB(with n factors), must there be n work items to complete the addition.
Yes.

3.Are the n work items in the same work group?
The number of work group is ceil(global_size(0) / local_size(0)) * ceil(global_size(1) / local_size(1)) * ceil(global_size(2) / local_size(2))

you should read specs section 3.2

4.In what condition, the work items are in different work group?
see 3

5.I want to continue the latter part of this calculation,input vectorC which is in global memory to kernel which has the same function of F(X), what can I do? Use event or commandqueue or some else? How ?
You have to run another ndrange on the c buffer