Problem looping over kernel

I’m trying to loop over my kernel a few times ( max 5 times) but I run into problems. To clarify what I mean to avoid misunderstandings; Im launching the kernel a few times. I don’t mean that I use loops on the actual kernel ( which I do but that does not matter here. So some pseudocode can look like this:


for (int i=0; i<loops; i++)

mykernelkernel<<<blocks, threads>>>(parameter1, parameter2, parameter3, dynamicParameter[i], …)[/codebox]

For each loop of the kernel a certain input datafile in used. That is basically what differs the different launches of the kernel, so the dynamicParameter[i] refers to input data file i. I malloc memory for all data and copy it to to the memory before I enter the loop , so I have an array of pointers to this input data on the graphic card. So far so good.

My problem is that only the first iteration and hence the first execution of the kernel produces correct results. If I set loops=2 and use 2 copies of the same data both those runs should produce the same result, which they dont. The first iteration produces the expected result but the second one produces weird results. I’ve tried looking for errors but can’t find any and I started to wonder if there is needed to do some “reseting” of the gpu between the different launches of the kernel? Do I have to reset something to get the kernel to produce correct result all iterations? Or is more likely related to some programming error done by me?