Thread Machine Gun

Besides hard-to-predict branches and high memory latency, server applications on MP systems also get slowed down by high latency network communication and cache coherency (keeping all the data coherent across the different caches; read more here).

To summarize, the challenges and problems that server CPUs face are:
  1. Memory latency, load to load dependencies
  2. Branch misprediction
  3. Cache Coherency overhead
  4. Keeping Power consumption low
  5. Latency of the Network subsystem
So, how did Les Kohn, Dr. Marc Trembley, Poonacha Kongetira, Kathirgamar Aingaran and other engineers at SUN attack these problems? Let us take deeper look at Niagara or the UltraSparc T1.

Memory latency is by far the worst problem, causing a typical server CPU to be idle for 75% of the time. So, this is the first problem that the SUN/Afara engineers attacked.

The 8 cores of the 64 bit T1 can process 8 instructions per cycle, each of a different thread, so you might think that it is a just a massive multi-core CPU. However, the register file of each core keeps track of 4 different active threads contexts. This means that 4 threads are "kept alive" all the time by storing the contents of the General Purpose Registers (GPR), the different status registers and the instruction pointer register (which points to the instruction that should be executed next). Each core has a register file of no less than 640 64-bit registers, 5.7 KB big. That is pretty big for a register file, but it can be accessed in 1 cycle.

Each core has only one pipeline. During every cycle, each core switches between the 4 different active threads contexts that share a pipeline. So at each clock cycle, a different thread is scheduled on the pipeline in a round robin order; to put it more violently: it is a machine gun with threads instead of bullets.

In a conventional CPU, such a switch between two threads would cause a context switch where the contents of the different registers are copied to the L1-cache, and this would result in many wasted CPU cycles when switching from one thread to another thread. However, thanks to the large register file which keeps all information in the registers and Special Thread Select Logic, a context switch doesn't require any wasted CPU cycles. The CPU can switch between the 4 active threads without any penalty, without losing a cycle. This is called Fine Grained Multi-threading or FMT.


Fig 3: The SUN T1 Pipeline. Source:SUN [1].

This Gatling gun of 4 shooting threads per core solves both the branch and the memory latency problem. If a thread issues a load, it takes 3 cycles to get the data from the 8 KB L1-cache. If the 4 threads are active, the thread that issued the load will not be active for 3 cycles anyway, as the other 3 threads get their one cycle. By the time that the first thread is ready to make use of the load of data, the load is finished. If the load takes longer, because it has to access the L2-cache or the memory, the thread is simply skipped, and one of the other 3 threads gets its timeslot until the load is finished.

If a branch is encountered, no branch prediction is performed: it would only waste power and transistors. No, the condition on which the branch is based is simply resolved. The CPU doesn't have to guess anymore. The pipeline is not stalled because other threads are switched in while the branch is resolved. So, instead of accelerating the little bit of compute time (10-15%) that there is, the long wait periods (memory latencies, branches) of each thread is overlapped with the compute time of 3 other threads.


Fig 4: Fine Grained Chip Multi-threading in action. Source:SUN.

The result is a win-win situation: the overall throughput increases, as 4 threads get done in a little bit more time than what it would take to perform one thread on a conventional CPU. In other words, the throughput increases significantly. Secondly, the single issue pipeline is used much more efficiently: SUN claims that the pipeline is used 70 to 85% of the time.

So, one core gets an IPC of about 0.7, which is very roughly twice as good as a big 3-way superscalar CPU with branch prediction and big OOO buffers would do, and it takes less chip logic to accomplish.
Index The 8 little cores that could
Comments Locked

49 Comments

View All Comments

  • Betwon - Thursday, December 29, 2005 - link

    Why? Really?

    quote:

    only one FPU is available for the 8 cores, and each FP instruction takes no less than 40 cycles.


    It shows that the performance of FP apps is very very poor!!!
    We can't believe it.

    It is terrible for many FP apps.

    Now, we know that the new CPU is only for the integer/32-thread-parallel-well apps.
  • JarredWalton - Friday, December 30, 2005 - link

    How many FP instructions do you think a high-end web server runs? Try to think outside the box for a minute, rather than comparing it to HPC-oriented chips. Itanium wastes more than 80% of it's potential when running many database loads, and it does better than some of the other alternatives. Spending lots of die space on OOO logic and long pipelines isn't always the best solution, especially if you can guarantee that most code will have many threads. Quit thinking Half-Life and other games for a minute and try to shift to the big iron server world.
  • Betwon - Friday, December 30, 2005 - link

    Only one FP unit? not less than 40 cycles latency?

    If it is true:

    The new CPU will be slower than P3@450MHz in the area of FP apps.
  • Brian23 - Friday, December 30, 2005 - link

    who cares. That's not what it's designed to do. The only reason that it has the floating point core is for the rare occation when a FP op is needed.
  • Betwon - Friday, December 30, 2005 - link

    It means that this new CPU does not fit for the FP apps. Maybe a old CPU(10 years old) can beat it.

    Now, we know that the apps-area of this new CPU is very very spec...

    It is too difficult to find apps(2-thread-paralle-well or more) for P4, how to find the apps(32-thread-paralle-well) easily?
  • thesix - Friday, December 30, 2005 - link

    Betwon,

    You seem to be confused with the concept of multi-threading v.s. multi-tasking.

    You do NOT need to find an app that runs 32 parallel threads in one process.
    You can simple run 32 _instances_ of that app, for example,
    or, run 32 different apps even if everyone of them is single-threaded.
    A typical server environment is just like that.

    When we talk about Chip Multi-Threading (CMT), it's the _hardware_ thread, which is a totally different concept than software thread. Once hardward thread represents the capability of running one computing task, it does care where this task comes from the same app/process or not.

    A perfect example is the Apache webserver, IIRC, at least in version 1.x.y (which is still the most popular version), the apache http server process is single-threaded. A new process is forked for each (or a group of) new http request. The more hardware threads you have, the more requests you can handle in parallel. Of course, the faster each hardward thread (or core, or cpu) is, the more requests it can handle in a given amount of time, but not in parallel.

    It is also true that _most_ database out there doesn't use _any_ floatpoint computation.

    So, if you think about it, the market for T1 type of CPU/server is not a small one.

    The bottom line is, T1 excels at througput/Watt and througput/chip.
    It's a well kown fact that it sucks at single-task or floatpoint computation.
  • Betwon - Friday, December 30, 2005 - link

    NO!

    You seem to be confused with the concept of SMT v.s. CMT.

    It is very low efficient, if T1 only use CMT but not use SMT.

    T1 have no branch prediction and one_inst_issue/core, very very poor FP performacne.
    The only explain about how to improve the efficiency(very poor) is to use SMT to hide the latency(by branch miss/cache miss ect.)

    But it has only 8KB L1(which will be used by 4 threads), the cache miss will increase. It is possible to become worst.
  • thesix - Friday, December 30, 2005 - link

    Explain to me the conceptual difference between SMT and CMT?
    All you have said is the (component) _implementation_ difference between T1 and POWER in achieving hardware threading.

    Since you appear to know this topic quite well, why the ignorant comment like this:
    "It is too difficult to find apps(2-thread-paralle-well or more) for P4, how to find the apps(32-thread-paralle-well) easily?"
    and kept screaming about the lack of floatpoint performance?

    I simply don't understand why you're so upset.
  • Betwon - Friday, December 30, 2005 - link

    My english has some problem.
    I think that T1 use both CMT and SMT.
    SMT -- one core with four threads
    CMT -- one CPU with eight cores

    If without SMT, cores of T1 will be very poor efficient (because of the stall's latency caused by branch miss/cache miss).

    The very very poor FP performance of T1 is the truth.
    We have to remind ourselves that it is only a integer CPU. It's FP performance is too terrible.
  • fitten - Sunday, January 1, 2006 - link

    There is no "reminding" anyone of the poor FPU performance. The thing was never designed to be strong in FPU (quite obviously). It has "enough" FPU so that it doesn't have to do software emulation and that's it. So... going on and on about FPU performance is a useless argument here. Sun (nor anyone talking about the T1s) has ever said that it would be good at FPU perforamnce because it wasn't designed to be.

    This CPU was designed for servers. Servers typically have high cache miss rates anyway because of a number of things (streaming any kind of I/O doesn't have much data locality advantages). Server processes also typically have lots of I/O stalls. When a context stalls, each core has multiple other contexts to chose from in order to keep running.

    So, I think the points you are trying to stress are quite obvious from the design of the CPU and the types of loads it was designed to handle. Yes, poor FPU performance obvious from having very limited (and slow) FPU resources. Yes, if you aren't running lots of threads the machine is inefficient because the thing is designed to take advantage of server type threads where there will be lots of I/O stalling and if there is nothing else to run while waiting on the I/O requests to finish, it sits idle (much like any other machine). Yes, in-order execution and the lack of branch prediction will not mask any stalls the instruction stream will generate (which is OK because the design of the CPU actually counts on these stalls to happen so that lots of nice SMT can happen).

    It sounds like you are in violent agreement with everyone :)

Log in

Don't have an account? Sign up now