cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

WTrei
Journeyman III

How to return self defined structs from kernel (with brook+)

First try causes segmentation fault

Hi all together!

 

I have a little problem to return a self definded struct from a kernel.

Code is relativ simple so here it comes:

 

------ test.br -------

typedef struct hugeInt_def
{
    uint4 a;
    uint4 b;
    uint4 c;
    uint4 d;
} hugeInt;

kernel hugeInt addHugeInt (hugeInt input1, hugeInt input2) {
return input1; // Just testing
}

kernel void gpu_test(hugeInt in1<>, hugeInt in2<>, out hugeInt out1<> {
out1 = addHugeInt(in1, in2);
}

------ test.br -------

Compiling this with brook fails

"wilke@wilke-desktop:~$ '/usr/local/atibrook/sdk/bin/brcc' -p CAL '-here my path-/test.br'
Segmentation fault"

How to fix this?

 

 

Edit: Used System is Ubuntu 9.04 (x32) with Kernel 2.6.28 on a Intel Core 2 Duo E8400, Radeon HD4850 (Driver 9.5 / 8.612) with Stream SDK 1.4 installed.

 

0 Likes
4 Replies
hagen
Journeyman III

I think the problem is with your subkernel addHugeInt.  Brook+ does not call functions.  Subkernels are inlined.

If you change "out1 = addHugeInt(in1, in2)" in kernel gpu_test to "out1 = in1", it should work.  Your compile problem has nothing to do with struct.

0 Likes

Well, ok I see my english was to bad to precise my question *g*

What you said was what I meant:

I want to return self defined structs from subkernels and this is ending up in Segmentation faults

0 Likes

This works OK in SKA:

kernel hugeInt addHugeInt (hugeInt input1, hugeInt input2) {

 hugeInt A ;

 A.a = input1.a + input2.a ;
 A.b = input1.b + input2.b ;
 A.c = input1.c + input2.c ;
 A.d = input1.d + input2.d ;

 return A ;
}

You might need to do:

 A.a.x = input1.a.x + input2.a.x ;
 A.a.y = input1.a.y + input2.a.y ;
 A.a.z = input1.a.z + input2.a.z ;
 A.a.w = input1.a.w + input2.a.w ;

in your source code, because of the strict type checking. Then the same for b, c and d. Also, obviously, you have to mess about with carry, which is a bit fiddly.

Jawed

0 Likes

Sorry I misunderstood.  It seems that subkernerl can only have a return value of one of the default types, not a defined struct.  What worked for Jawed didn't compile for me.

0 Likes