Does the number of threads increase the CPU execution time?

425 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

You’re paying a cost for allocating the kernel resources and scheduling the threads. If you’re naive about your implementation, threads can end up costing you more than they can save, if there’s concurrency to even be had in the first place. Matrix multiplication can be parallelized, but there are lower level implementation details you’re going to want to do first. Maybe the Intel compiler ($$$) will generate SSE instructions, but typically you’ll have to use intrinsics yourself to explicitly generate those instructions. This is instruction level parallelization. After you do that, then you’ll want to consider thread level parallelization to utilize all your cores. Don’t be too impressed with hyperthreading – this is a technology to use underutilized pipeline paths to squeeze in a few extra work units, but you’re going to have already saturated your SSE pipelines, so you won’t see any hyperthreading anyway. Thread level parallelism has to pay for the cost of the threads, amortized them over time. This means it’s only worth while if your datasets are large enough, otherwise, you could have computed your results faster than it takes to get your threads setup.

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