Code to run on CPU is compiling but not working properly