Altera_Forum
Honored Contributor
8 years agoPass an array of structs as a buffer
Hi everyone. I am trying to pass an array of structs to the kernel using a buffer.
So what I have tried to do at the moment is:
dev_probConfig = (ProbConfig*)_aligned_malloc(N* sizeof(ProbConfig),64);
for (int i = 0; i < N; ++i)
{
memcpy(&dev_probConfig, h_probConfig, sizeof(ProbConfig));
}
But the second thread or work-item doesn't work. Actually even if I allocate two times the object and then I launch only 1 work item then it fails. If I set N to 1 and I launch it with 1 work item it works... I cannot explain what is going wrong. I have done data padding so the size of ProbConfig is 8192 bytes which is multiple of 64. In the kernel this is my modified pointer depending on the value of the id of the work item.
if(id>0)
w_probConfig = &probConfig;
Basically my work items are doing the exact same thing on the exact same data (that's why I need duplicates of structs) and I can't figure out why the second is not getting correct data. Thanks everyone.