Does the number of threads increase the CPU execution time?

429 views

I was doing an exercise in C of matrix multiplication using threads and I realized that as I increased the number of threads the same happened with the CPU time. My computer has 2 cores, each of which can run two threads (Intel Hyper-Threading), but why exactly does this happen?

In: Technology

5 Answers

Anonymous 0 Comments

Dividing up a task so it can use multiple threads is not free. So you need to do som extra stuff to split it apart and collect the result.
If the matrix you multiply is small the overhead can be greater then the time you gain by doing the calculation in parallel. So splitting it up can increase the time

Try it with large matrices and you will likely se a decrease in time.

Hyperthreading is sharing the same core for two threads. You can get a bit of extra preformence if there is a lot of waiting for data from memory. So going from 2 to 4 threads likely only increase preformence if the matrix size is larger then the CPU cache size.

You are viewing 1 out of 5 answers, click here to view all answers.