unsymmetric performance of type conversion

Hi, all!

I found that type conversion from int to char is generally slower than from char to int. Anyone knows why?

I don’t know about conversion speed… in fact I’d be surprised if there was a difference, and if there was, that it’d be significant.

However, there is a big common gotcha when dealing with char speeds. If you have an array of them in shared memory, you often access them like s[threadIdx.x] +=1; or some other kind of array index. This is much slower than when accessing an integer array. The reason is shared memory bank conflicts. Threads 0, 1, 2, and 3 are each reading sequential bytes… which all lie on the same word and therefore are all on the same bank. So you have 16 threads reading from 4 banks… bank conflict! So the memory access for both read and write will be four times slower than you expect.
This is not inherent with char access, just common. for example s[4*threadIdx.x]+=1; has no bank conflicts.