add serial verison and make the number of threads in the pthreads version equal to the number of available cores