Code works for 1000x1000. Returns 0 for 10000x10000 on this machine. Tested the same code on a Tesla K20c. Getting correct results for 10000x10000 case