I have a following program, and when I compile it, I get an error like “error: identifier “__T20” is undefined”. Similar code can be compiled for CPU. Any advices?
struct Vec
{
float x, y, z;
Vec( float x_ = 0, float y_ = 0, float z_ = 0 )
{
x = x_;
y = y_;
z = z_;
}
};
Thanks for reporting this. I’ve filed a bug report. As a workaround, try making an array of char large enough to hold the number of Vecs you want, and reinterpret_cast the array to Vec *.
This code compiles on my system:
[codebox]
struct Vec
{
float x, y, z;
Vec( float x_ = 0, float y_ = 0, float z_ = 0 )
{
x = x_;
y = y_;
z = z_;
}
};
global void kernel(void)
{
//Vec t[10];
char temp[10 * sizeof(Vec)];
Vec t = reinterpret_cast<Vec>(temp);
return;
}
int main()
{
dim3 block( 16, 16 );
dim3 grid( 1, 1 );
kernel <<< grid, block>>> ();
return 0;
}
[/codebox]
Of course with this approach, you’ll have to explicitly initialize each element of the array.