automatically detect number of cores