An illegal memory access was encountered

I had a problem with that error.
I’ve wrote a simple code and when I change Threads per Block to for example : 8,16,32,64,128,256 it doesn’t work but if change it to 1,2,4,512,1204… it works.
in addition, when the size of array increases for example greater than around 3*1024, it just work with Threads per block = 1
I got mixed up.
Please, help me.
Thanks (4.0 KB)

Please post code inline using forum tools, not as an attachment.

I found it.
The GPU on my system had a problem. in fact, there was a software issue.