Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Multi cores processor and register

  1. Jul 12, 2016 #1
    Dear PF Forum,
    I have a question (after many questions) about multi cores processor.
    Does multi cores processor has multi set of register?
    Supposed an Intel xeon processor has 4 cores.
    Does it processor have 4 EAX register?
    E4 BX, 4 ECX, etc?

    Thank you very much.
  2. jcsd
  3. Jul 12, 2016 #2


    Staff: Mentor

  4. Jul 12, 2016 #3
    Wow, thank you thank you very much @jedishrfu.
  5. Jul 12, 2016 #4
    And also they don't share register, but they share RAM. So I think there's some locking mechanism. Or if there isn't, then it does not matter. As long as each process (OS managed) works in their own address range.
  6. Jul 12, 2016 #5
    Dear PF Forum,
    But I still have questions regarding multi processing.
    So, in 4 multi cores computer there are four set of registers.
    What about multithreading?
    Supposed in 1 core processor there are 2 threads.
    1. So still, there are two set of registrs but only 1, say, ALU?
    2. And there is no need of pushs and pops instructions between processes unlike OS multitasking?
    Thank you very much.
  7. Jul 14, 2016 #6


    Staff: Mentor

    Are you asking about a processor with a single core? If so, the processor has a single set of registers and a single ALU. To change from one process to another, a context switch has to happen with state for the first process saved (i.e., the state of the registers).

    I haven't dug into this much lately, but I believe what I said above is accurate. If it isn't, I'm sure someone will jump in with corrections.
  8. Jul 14, 2016 #7
    Oh, hi @Mark44
    Thanks for your answer.
    I'm asking about a processor with a single core with hyperthreading facility.
    So, if the processor has two sets of register there's no need to save the first process state.
    I already read that
    It's explained there that for a processor with hyperthreading facility there are really two sets of register.
    So when the processor executes long instruction like jmp, conditional jumps, loop, loopnz, call, ret, int, iret but not mul or div I think (please correct me if I'm mistaken), then there's some delay in one of its pipe, so the processor just switches to the other pipeline and executes the instructions in there. And because there are two sets of registers, there's no need for the OS to push general purpose registers. It saves time.
    So, in hyperthreading the processor has 1, say, ALU but two sets of register.
    And in multicores processors, each core has its own set of register.
    So a processor with 5 multicores has 5 register.
    For a processor with 5 multicores with hyperthreading it has 10 sets of register.
    I've read all the article online but never find the definite answer about the number of register, which I have suspected.
    And thanks for your other answer, but I can't respond it now. I'm still reading the links.
  9. Jul 14, 2016 #8
    I think hyper-threading is a technology that mainly deals with virtual cores while multicore is termed to denote a processor with multiple physical cores. The former has a fixed number of register set in a physical core which is cloned and doubled in number when the technology is enabled (half for each virtual core). Today modern CPUs also include hyper-threading capability to power up their uses in multi-tasking applications.
  10. Jul 14, 2016 #9
    Yes. Virtual vs physical. Or as the reference says, logical vs physical. Logical means that the OS will see that the computer has two processors.
    What about the latter? I read that both have doubled sets of register.
    Cloned? What do you mean by cloned? The processor sets the values of both register equal? I think not.
    It's not like cloned database, right?
    The reason that I ask PF about this issue is that, all these years I thought that the advertisement which said that a computer had two cores or four cores was just a marketing ploy. I thought that the computer just double or quadruple the clock speed so it seemed that the computer run four times faster. Of course this can't beat a computer with a real 4 cores. No saving/loading register state. I just didn't give it much thought.
    But lately my office is going to purchase some server and in its advertisement it says that it has several cores. Since it's not a $300 computer, almost ten thousands dollars, so why not dig into this matter deeper. :smile:
    Thanks @Pepper Mint :smile:
  11. Jul 15, 2016 #10
    When your computer boots, the OS will know how many cores your processor supports so that it can run the same number of threads concurrently. So if your PC doesn't have CPU supported Hyper-Threading technology enabled in its BIOS settings, I don't think the logical core number is twice more than the physical one. Also, the assumption that one core has only one ALU I think is not true, because (1) all modern CPUs include SIMD instructions to help execute the same task at multiple data points, which speeds up the CPU's performance a lot and (2) as said earlier, ALUs of virtual cores should also be counted.
  12. Jul 15, 2016 #11
    Perhaps ALU is not the correct word. What I mean is this in hyperthreading case.
    The difference between hyperthreading and multi core.
    Hyperthreading: Only one instruction is executed at a time against one register. But there's no need to save/load register state.
    Multicore: two instructions are executed against two registers. So, no need to save/load register state either.
    Multitasking: Only one instruction is executed at a time against one register. But there's only 1 register, so there's a need to save/load register state between process.
  13. Jul 15, 2016 #12
    Each core has it's own register as well as cache. If you have multiple threads on the same core, you only have one set of registers, but it's fine because only one thread is running at a time. Splitting a process up into multiple threads on a single core doesn't make much sense unless there is a lot of IO wait.
  14. Jul 15, 2016 #13
    Yes, it can. While one core has only one register it can do multitasking, but there's a lot of pushes and pops.
    For efficiency, I think each should only have two sets registers.
    My theory is this.
    While the core executes
    - jmp
    - conditional jump
    - loop, loopnz
    - call, ret,
    - int, iret
    Then there's a "long" time for the processor to wait for the next instruction. And this wait time is used for the core to execute the other instructions in another pipe.
    There are two pipes in each core and there are two register. Is that so?
  15. Jul 15, 2016 #14
    Remember how a pipeline works, there is a lot of prediction happening. When a jmp is starting to be executed, the processor has already started executing the next couple of statements. In a conditional jump, it makes assumptions on the condition (called branch prediction) so there is actually almost no wait time in a jump for loading the next statements. Modern processors are executing like 20 commands at a time all the time. If they predict wrong, they backtrack. Something like 70% of the processor is actually dedicated to recovering in the situation when the prediction was wrong and making sure writes and reads happen in the correct order.
  16. Jul 15, 2016 #15


    User Avatar
    Gold Member

    You can also get a performance increase when one thread uses one part of the processor for example the multiply unit and the other is adding then both instructions can execute at once. You get a higher percentage of your transistors computing at the same time. This will be best taken advantage of when the OS knows about the hyper-threading capabilities.

  17. Jul 16, 2016 #16
    But the 1 processor can only process 1 instruction at a time. The processor has two pipeline as I read. So, the processor can only process instructions from 1 pipe at a time. But if the instruction is a long instruction that has to erase the pipe and the processor has to read the next instruction from the memory then the processor process the instructions in the other pipe, while the bus if fetching the next instruction from the pipe.
    I can't imagine two threads work together to achieve a single goal.
    Perhaps something like this.
    10: mov AX,10; processed by thread A in processor A
    20: mov BX,20; processed by thread B, in processor B. Both processes are executed simultaneously.
    30: add AX,BX; processed by thread A, because line 10 and 20 can be done simultaneously. This I can't imagine.
  18. Jul 16, 2016 #17


    User Avatar
    Gold Member

    A single thread of operation is executed in one thread. So your example will be done on one thread. However each instruction is broken down into many smaller pieces on modern processors. Then they get rearranged to best use the available resources. In your three line example you might never get 10 or 20 into any register. The microcode could optimize out the intervening movement of data.

    Then another thread on the same core could be doing something similar but multiply in the third line. Both the add and the multiply may be executed at the exact same time. Modern processors contain lots of frequently idle resources. MT was invented to try to use up some of that slack.

Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted