I am learning the concept of threads in c/c++. I was trying the examples for
the dot product of two vectors cited in Pthreads Overview.
I ran both the serial and the thread version of the code and I found that the
serial version was faster than the thread version. I thought it should be the
opposite.
I am running on a single CPU.
The code that link to has a few issues that you need to keep in mind:
a = (double*) malloc (NUMTHRDS*VECLEN*sizeof(double));—NUMTHRDSis set to four andVECLEN100 in the code). Therefore, the parallel program is doing four times the amount of work, but with four threads, so the naive assumption is that the serial and parallel programs will have the same run time.