0

I have an Early 2011 Quad Core i7 Mac. Due to hyperthreading, a lot of programs report 8 "cores". If I were to write a program that executes in parallel, could I kick off 8 instances of this program or just 4?

I get I can start as many threads as I want, but would I be seeing 4 or 8 instances of the program execute in parallel?

David
  • 9,854
Tyler DeWitt
  • 243
  • 3
  • 9

1 Answers1

2

The Intel Core i7 processor has 4 physical cores, but each core has the ability to input up to 2 Threads at a time, showing 8 Threads total to the operating system in the form of "available logical CPU's."

In reality, a single core can only handle one thread at a time, but it has special queueing / timing / scheduling mechanisms to allow 2 threads to be at different stages of the "pipeline" at the same time. This enables the CPU to finish 2 threads sooner than it would if it were to only handle one at a time. Because both threads are sharing the same pipeline, the performance benefit will obviously not be 2x. Most tests peg the benefit anywhere between 10% and 50% depending on the type of instructions being executed.

In answer to your question, if you start 4, 8 or 16 instances of your program, they would all be "running," but instructions for each would be queued up depending on how many available THREADS are available. Once you move beyond the number of available PHYSICAL CORES (e.g. 5 or more), the performance will reduce because any threads beyond the base 4 will be sharing a physical CPU core.

Finally, once you hit the limit of the available CPU threading capability (exceed 8 threads), the OS will then start scheduling / queueing instructions to wait until the ones in the pipeline are done. Ideally you want to avoid going over the available threads because it could have negative performance impacts and bottleneck the system.

Joshua
  • 4,402