Hello,
I have data structures on the host side that looks like this. ( I show the relevant parts ). Why I need to have it like this is a long story but I think I need to keep this structure.
struct Bar {
double ind[NR_OF_INPUTS - 2];
int date;
int time;
};
struct Week {
int numBars;
struct Bar* bars;
};
struct ThreadWeeksHolder {
int nr_weeks_per_thread;
struct Week* week;
};
On the host side I then have a an array like this “ThreadWeeksHolder kernel_thread_weeks_holder[32];” Which is filled with data that is read from a file. Everything works fine so far. My problem comes when I try to get this data to the kernel and keep the structure layout. I want to be able to use the same structure on the kernel. This turned out to be way much more complicated then I first thought.
My plan was to try to build a structure on the host with the gpu-pointers received from cudaMalloc and then copy them over to the graphic card but I can’t really get it to work. The problem is that the pointers that I receive from cudaMalloc makes no sense on the host side if I try to dereference them so to speak.( which totally makes sense ). So for example if I have a line like this
cudaMalloc((void**)&kernel_thread_weeks_holder[1].week[2].bars, threadWeeksHolder[i].week[j].numBars*sizeof(struct Bar));
Then I have a pointer kernel_thread_weeks_holder[i].week[j].bars that points to the appropriate place in the GPU-memory. But after that I also will need a “relationship” between kernel_thread_weeks_holder[i].week and kernel_thread_weeks_holder[i].week[j].bars so to speak. But on the host things get messed up then for me. Hope you can understand what I mean and what my problem is.
Anyone have any suggestions or hints how I can solve this problem?