cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

lxp121
Journeyman III

use il generated by brook+ in cal

write il is a very difficult things!

so i want use Brook+ to generate il code, and use it in cal.

but, here's the thing. the Brook+ use address virtualization, so i must give a "cb0[2]". what is that? is it the execution domain of kernel? or the domain of stream?

another question : if i have to gather stream in one kernel but with different domain (and this domain also different from domain of kernel), how does it works?

for example:

kernel void test(float a[], float b[], out float c[])

a,b,c and kernel have different domain. is this legal? how can the compiler know the difference?

0 Likes
4 Replies
gaurav_garg
Adept I

Hi lxp121,

 

If you look closely Brook+ generates two il shaders one with AT(address virtualization) and another on without AT. Using non-AT kernel should be straight forward. It doesn't generate any extra constants. Try compiling your shader with -k option. It will generate two .il file. The file without "_addr" should be used.

Using different domains on your input, output or kernel is allowed. Using domain on input or output is like passing a new stream to the kernel. Setting kernel domain is equaivalent to specifying a region of execution and has the same effect as in CAL. Consider this example -

kernel void test(float a[], float b[], out float c[])
{
    int id = instance().x; // Its value is decided by kernel execution specified
    c[id + 1] = a[0] + b[id + 2]; // Indexing for all the streams  start from (0,0) irrespective of their domain set at runtime.
}


// Set execution domain of kernel
test.domainOffset(uint4(1, 0, 0, 0));
test.domainSize(uint4(5, 1, 1, 1));

test(a.domain(5, 10), b.domain(15, 25), c.domain(8, 16));

 I haven't checked it but the affect of this kernel should be -

c[9 to 14] = a[5] + b[18 to 23];

 

Hope it helps.

0 Likes

your answer is impressive!

i will try this!

thanks!

0 Likes

Originally posted by: gaurav.garg Hi lxp121,

 

 

 

If you look closely Brook+ generates two il shaders one with AT(address virtualization) and another on without AT. Using non-AT kernel should be straight forward. It doesn't generate any extra constants. Try compiling your shader with -k option. It will generate two .il file. The file without "_addr" should be used.

 

Using different domains on your input, output or kernel is allowed. Using domain on input or output is like passing a new stream to the kernel. Setting kernel domain is equaivalent to specifying a region of execution and has the same effect as in CAL. Consider this example -

 

kernel void test(float a[], float b[], out float c[]) {     int id = instance().x; // Its value is decided by kernel execution specified     c[id + 1] = a[0] + b[id + 2]; // Indexing for all the streams  start from (0,0) irrespective of their domain set at runtime. } // Set execution domain of kernel test.domainOffset(uint4(1, 0, 0, 0)); test.domainSize(uint4(5, 1, 1, 1)); test(a.domain(5, 10), b.domain(15, 25), c.domain(8, 16));  I haven't checked it but the affect of this kernel should be - c[9 to 14] = a[5] + b[18 to 23];

 

 

 

 

Why not c[10 to 15]?

I don't understand kernel domain offset and size clearly. Could you explain it carefully?

0 Likes

Yes, you are right. It should be c[10 to 15].

Setting execution domain is like specifying a region of SIMD elements for which you want to invoke your kernel. Please take a look at samples\CPP\tutorials\ExecDomain.

0 Likes