Thanks for your answer, but the result is same after I test according to your suggestion,and normally,the value of each elememt of indexTab should be different. but I write the code like this
the value of numV is 1875, It’s so weird.The value of indexTab[i] in local watch window is right, but it is wrong after I copy to host’s variable,and the value which is printed on the screen is also incorrect.
I guess you’ll need to provide a code that somebody else could compile and run to see the issue then. I built a simple code around what you have shown, and the issue was fixed when I made that change to printf.
Here is a worked example. If I compile with -DBROKEN (which uses your original code) the output is all zero. If I don’t compile with -DBROKEN (therefore using the fix) then the output is 0,1,2,3 i.e. the thread ID: