I am trying to learn about concurrency and to do so I have been writing some programs. I have noticed, as I expected, that wall time does generally decrease when adding threads. However, I have also noticed that CPU time increases as the number of parallel tasks I run increases.
Is it because when there's only a single thread the compiler behind the scenes optimizes the code so to use more than one core (if possible)? This is the only explanation I came up with. Can anyone help me?
EDIT: the machine I use has multiple cores (4 to be precise)