GET STARTED

GET INVOLVED

Authorization Required

Not a member? Register Now

I try to build a simple OpenCL program for a lesson I have. I've done a little search but I haven't figured out yet how to procceed. So my problem is this:

I want to have 2 functions in the device, one kernel that calls the other one that is not kernel. The thing is I want to pass pointer arguments, but I read that this is not possible.

[code]__kernel void kernel_func(__global double *startpt, __global double *endpt) {

//something with startpt

normal_func(endpt);

}

double normal_func(double *endpt){

for(i = 0; i < 8; i++) endpt[i] = 1;

}

[/code]

Also, I would prefer to have endpt as private to each thread and in the end of kernel_func perform a reduction by minimum to some of the values of endpt and return to device the endpt of one thread.

Any help would be appreciated. Even links.

Edit: Problem Solved!

I try to build a simple OpenCL program for a lesson I have. I've done a little search but I haven't figured out yet how to procceed. So my problem is this:

I want to have 2 functions in the device, one kernel that calls the other one that is not kernel. The thing is I want to pass pointer arguments, but I read that this is not possible.

Also, I would prefer to have endpt as private to each thread and in the end of kernel_func perform a reduction by minimum to some of the values of endpt and return to device the endpt of one thread.

Any help would be appreciated. Even links.

Edit: Problem Solved!

I'am also interested in this problem.

Can you please tell us what was the solution in your case?

Thanks!

I'am also interested in this problem.

Can you please tell us what was the solution in your case?

Thanks!

I needed a matrix multiplication with float4, so I wrote a short function, that should take

the matrix:

[code]

float4 mult_mat_vec(const float4 *mat, const float4 vec)

{

float4 res;

res.x = dot(mat[0], vec);

res.y = dot(mat[1], vec);

res.z = dot(mat[2], vec);

res.w = dot(mat[3], vec);

return res;

}

[/code]

The problem was, that the matrix was in [font="Courier New"]__global[/font] space. But as all my matrices were

I simply modified the function header to look like:

[code]float4 mult_mat_vec(__global const float4 *mat, const float4 vec)

{

float4 res;

res.x = dot(mat[0], vec);

res.y = dot(mat[1], vec);

res.z = dot(mat[2], vec);

res.w = dot(mat[3], vec);

return res;

}[/code]

And the compiler stopped complaining.

I guess you simply have to use the same memory space qualifier as in the kernel to pass the argument.

What I did not try, was to pass an offset pointer (like [font="Courier New"]mult_mat_vec(mat_array + 4, vec)[/font]).

I needed a matrix multiplication with float4, so I wrote a short function, that should take

the matrix:

The problem was, that the matrix was in __global space. But as all my matrices were

I simply modified the function header to look like:

And the compiler stopped complaining.

I guess you simply have to use the same memory space qualifier as in the kernel to pass the argument.

What I did not try, was to pass an offset pointer (like mult_mat_vec(mat_array + 4, vec)).

Indeed, it seems the address space qualifier often solves the problem.

However, it's not yet very clear to me what the default address space is when talking about pointers as function parameters. I'll check the documentation once again.

Indeed, it seems the address space qualifier often solves the problem.

However, it's not yet very clear to me what the default address space is when talking about pointers as function parameters. I'll check the documentation once again.