count_cores function

A helper function to count the number of cores available on the current machine