makhan

Passing structures to kernel

Discussion created by makhan on Jun 13, 2010
Latest reply on Jun 15, 2010 by Jawed
how to align?

Hi,

I wrote a simple implementation of Genetic Algorithm for GPU. It works fine as long as the only arguments I pass are float arrays, but as soon as I try to enclose it into a structure, everything breaks down and I'm getting memory access errors.

How am I supposed to align the following structure? I read about alignment in few places, but honestly I don't understand the idea.

struct __attribute__ ((aligned(16))) individual {
   float x[16];
   int num_of_dim;
   float fitness;
 };

In main function I'm passing individuals array.

Outcomes