C# object into Kernel code best way to convert?

Hi,

We have a c# application for montecarlo simulation. During the simulation process, we loop through the collection of objects and use the value of the properties of the objects as the input of calculation.

In terms of coverting the c# simulation code into kernel code running on gpu, what will be the best way to convert the objects?

Translate them in to C structures or generate arrays of different properties values?

Thanks

Personally I would advise using seperate arrays rather than structs, but it depends on the situation of course.

Assume on the C# side you have an array of C# classes:

[codebox]class myClass{

public int varA{get;};

public char varB{get;};

}[/codebox]

You then pass an array of ints and an array of chars, rather than an array of structs with int and char members.

The reason for this is simply for structured and aligned memory accesses, especially when dealing with elements of possibly different sizes.

Takes abit of extra bookkeeping and increases code complexity, but I believe it would be more performant. There are exceptions however, like being able to read 4 bytes in a single read from global memory, which would take 4 times as long if read from 4 different locations in memory.

Personally I would advise using seperate arrays rather than structs, but it depends on the situation of course.

Assume on the C# side you have an array of C# classes:

[codebox]class myClass{

public int varA{get;};

public char varB{get;};

}[/codebox]

You then pass an array of ints and an array of chars, rather than an array of structs with int and char members.

The reason for this is simply for structured and aligned memory accesses, especially when dealing with elements of possibly different sizes.

Takes abit of extra bookkeeping and increases code complexity, but I believe it would be more performant. There are exceptions however, like being able to read 4 bytes in a single read from global memory, which would take 4 times as long if read from 4 different locations in memory.