All depends on if the value you are putting into each array element can be derived from the threadIdx
if it can’t and there are only a few values then Bloodhunt’s code using thread 0 is way to go
but if it can then using multiple threads working in parrallel, as nachovall did, will do it faster.