Automatically determine number of cores