How to properly pass Structs data to CUDA kernels (C++)
First time using CUDA. I am working on a P-System simulation in C++ and need to compute some strings operation on GPU (such as if's, comparisons, replacements). Because of this, I ended up wrapping the data in these structs because I couldn't come up with a better way to pass data to Kernels (since strings, vectors and so on aren't allowed on device code):
struct GPURule {
char conditions\[MAX\_CONDITIONS\]\[MAX\_STRING\_SIZE\];
char result\[MAX\_RESULTS\]\[MAX\_STRING\_SIZE\];
char destination\[MAX\_STRING\_SIZE\];
int numConditions;
int numResults;
};
struct GPUObject {
char strings\[MAX\_STRINGS\_PER\_OBJECT\]\[MAX\_STRING\_SIZE\];
int numStrings;
};
struct GPUMembrane {
char ID\[MAX\_STRING\_SIZE\];
GPUObject objects\[MAX\_OBJECTS\];
GPURule rules\[MAX\_RULES\];
int numObjects;
int numRules;
};
Beside me not being sure if this is the proper way, I get a stack overflow while converting my data to these structs because of the arrays fixed-size. I was considering using pointers and allocating memory on the heap but I think this would make my life harder when working on the Kernel.
Any advice on how to correctly handle my data is appreciated.