Does the number of threads increase the CPU execution time?

426 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

Did you make the same observation when you went from 1 to 2 threads, or just from 2 to 4 threads?

Going from 2 to 4, this would be expected. Because hyperthreading just allows two threads to use the same computing units at the same time. This can be more efficient when one thread stalls out – for example when it has to wait for some data to be read from memory before it can continue. Without hyperthreading, the core would be twiddling its thumbs for a few clock cycles. With hyperthreading, the other thread can take over full time until the other thread can resume working.

So if your code is running without any stalling issues, hyperthreading doesn’t give you any performance benefits.

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