cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

Mikey
Journeyman III

Function arguments

Hi. Can I somehow declare a function that takes first argument as global or as private? For example:

kernel void k1(global read_only uint *string, constant read_only uint *offset) {

size_t gid = get_global_id(0);

f(string + offset[gid]);

}

 

And another kernel:

kernel void k2() {

uint string[5];

// fill

f(string);

}

0 Likes
4 Replies
jcpalmer
Adept I

Check the last intro video, 2nd topic from top.  You cannot specify private for kernel arguments.  All work items share one copy of args.

0 Likes

thats not true.you can ommit address qualifier for non pointer arguments which will be by default be __private.

__kernel k(__global float *a, float b)//b is __private

 

0 Likes
Mikey
Journeyman III

jcpalmer: thanks for reply but you misunderstood me. I don't want private argument for kernel but for function that isn't kernel. When I declare f like this:

void f(global const uint * const param);

I can't use it with kernel k2. When I declare it this way:

void f(const uint * const param);

...it works with k2 but not k1.

 

Now my f() is quiet big and having two nearly the same functions really slows down compilation.

 

0 Likes

yes you can declare function which take __global pointer. only what you cant is assing from one address qualifier to another.

0 Likes