This project is read-only.

Struct is not properly unpacked?

Dec 19, 2011 at 6:16 PM

I have a struct with a struct in it, with a field named DevP. When indexing this DevP, the generated .cu code naively uses DevPLen1 and DevPLen2, without defining them! Like this: soundField.DevP[num * DevPLen1 * DevPLen2 + ...]

Is this a bug? :/

Dec 20, 2011 at 1:46 PM

Can you supply your source code?

Jan 17, 2012 at 12:30 PM

Nick, sorry I should've, but had no time -_-. Maybe I'll get the chance later :) -ola

Jan 18, 2012 at 9:57 PM
Edited Jan 18, 2012 at 10:11 PM

This sounds like something I had ran across.

I think what happened was I was passing an array to the constructor for a struct like this...

C#

private int[] _intArray;
public MyStruct(int[] myarray) {
    _intArray = myarray;
}
public int GetArrayLength() {
    return _intArray.Length;
}

Then after translation it would look something like this in C

int* _intArray;
public MyStruct(int* myarray, int myarrayLen0) {
    _intArray = myarray;
}
public int GetArrayLength() {
    return myarrayLen0;
}

Notice it didn't automatically declare and set a variable for the length, but I was able to do it myself by writing the code something like this (I cant remember exact syntax)

C#

private int* _intArray;
private int myarrayLen0;
public MyStruct(int* myarray, int myArrayLen0) {
    _intArray = myarray;
    _myarrayLen0 = myarrayLen0;
}
public int GetArrayLength() {
    return _myarrayLen0;
}

EDIT: note this is obviously not a solution because I'm pretty sure its not going to automatically copy that pointer correctly to the device, just showing an instance that may describe whats going wrong for you

Jan 23, 2012 at 8:12 AM

This is a rare situation but a bug nevertheless!