News for hackers. Stuff that matters.
Re:What's New in CPUs Since the 80s and How Does It Affect P... by bluetomcat on Monday January 12, 2015 @09:17AM (#8873935)
The constant widening of the SIMD registers is an interesting trend to watch. MMX started off as 64-bit, and now AVX-512 is 8 times that. With many cores and a couple of SIMD units in each core, aren't CPUs becoming ever more suitable to handle graphic workloads that were once reasonable only for GPUs?
Re:What's New in CPUs Since the 80s and How Does It Affect P... by vardump on Monday January 12, 2015 @09:27AM (#8873985)
GPUs are still about 5x ahead compared to CPUs. CPUs lack texture lookup hardware, that's the biggest catch right now. AVX2 gives gather support (one instruction, up to 8x independent loads to a single vector register), but currently on Haswell there's no performance benefit compared to doing the memory loads individually.

GPU memory (GDDR5) has also many times more bandwidth at expense of 10x higher latency compared to CPU.

Currently you put the workload that requires low latency on a CPU and embarrassingly parallel "non-branchy" workload on a GPU.

Both CPUs and GPUs gain about 20% performance per year per core. I'm no expert on CPU and GPU memory architectures, but both seem to be headed towards integrated 3D-stacked eDRAM memory. This can provide up to several TBps reasonably low latency bandwidth.

Re:What's New in CPUs Since the 80s and How Does It Affect P... by Symmetry on Monday January 12, 2015 @10:27AM (#8874326)
Everything vardump said is true, but additionally there's the consideration of what isn't there as well as what is there. By not having an out of order execution setup or a broad forwarding network a GPU core is able to be much smaller than a CPU core of equivalent throughput. By "core" here I mean something capable of independently issuing instructions and executing them, not calling each execution unit a "core" the way Nvidia does (though with SIMT that isn't as crazy as it might look at first). That means you can pack more cores on a chip and use less power for a given amount of work, since power consumption is roughly proportional to the number of transistors used. If we eventually start doing graphics on CPUs it will because we move to ray tracing or other sorts of algorithms that GPUs are bad at.
Re:What's New in CPUs Since the 80s and How Does It Affect P... by Symmetry on Monday January 12, 2015 @01:26PM (#8875511)
One more thing. GPUs don't have to worry about precise interrupts like if you try to load a piece of memory only to find that you have to page it in or such. If they're in a memory protected setup where that's even possible it'll be the CPU who has to deal with the mess, the GPU can just halt while that's taken care of.

This makes SIMT easy. SIMT is "Single Intstruction Multiple Threads" which is sort of like SIMD but better. You have an instruction come in which is distributed to multiple execution lanes each of which has a hopper of instructions it can draw from. Each lane then executes those instructions independently and if the lane notices that the instruction has been predicated out it just ignores it. Or maybe if one lane is behind it can give the instruction to its neighbor which isn't. THe fact that you don't have to be able to drop everything in a single cycle and pretend you were executing perfectly in order gives the hardware a lot of flexiblity, and all of this complexity is only O(n) with the number of executions instead of O(n^2) as with a typical OoO setup. The need to have precise exceptions involving SIMD instructions means that this isn't a simple thing for a regular CPU core to add to its SIMD units.

The fact that each lane is making decisions about when to execute the instructions it has been issued are why some people refer to the lanes as "cores". I don't, because what they're doing isn't any more complicated than the 8 reservation stations in a typical Tomasulo algorithm OoO CPU core would be doing even if they are smarter than a SIMD lane. With GPUs it makes more sense to break down "cores" by instruction issue, in which case a high end GPU would have dozens rather than thousands of cores.

Re:What's New in CPUs Since the 80s and How Does It Affect P... by vardump on Monday January 12, 2015 @03:01PM (#8876066)
I think GPUs do have faulting mechanisms, if that's what you meant by "precise interrupts". How else they bus master page memory over PCIe?

> Each lane then executes those instructions independently and if the lane notices that the instruction has been predicated out it just ignores it.

This is exactly what you do on CPUs as well. In SSE/AVX you often mask unwanted results instead of branching. Just like on GPUs. AVX has 8 lanes, 16 with Skylake.

Re:What's New in CPUs Since the 80s and How Does It Affect P... by Symmetry on Monday January 12, 2015 @03:33PM (#8876246)
Regarding faulting mechanisms, if you've got a discrete GPU on a PCI bus then it's a separate piece of silicon that handles the network protocol. The important point is that I don't believe that the GPU cores have to be able to halt execution and save their state at any instruction.

It's certainly true that SIMD instructions in CPUs have predication which saves you a lot of trouble. The difference is that if you have two instructions which are predicated in a disjoint way you can execute them both in the same cycle in a SIMT machine but you would have to spend one cycle for each instruction in a SIMD machine. You can look at Dylan16807's link for all the details.

Re:What's New in CPUs Since the 80s and How Does It Affect P... by tmurray on Monday January 12, 2015 @08:56PM (#8877684)
GPUs don't support precise exceptions. For example, you can't take a GPU program that contains a segfault, run it as a standard program (as in, not in a debug mode), and be presented with the exact instruction that generated the fault.
Re:What's New in CPUs Since the 80s and How Does It Affect P... by Dylan16807 on Monday January 12, 2015 @01:26PM (#8875512)
So I had to look up SIMT: http://yosefk.com/blog/simd-simt-smt-parallelism-in-nvidia-g...

Batches of execution units all run the same opcode (or skip it in if/else constructs) but each one has its own register set.

As opposed to SIMD's simple, single, massively-parallel vector instructions.

Re:What's New in CPUs Since the 80s and How Does It Affect P... by ANTSANTS on Monday January 12, 2015 @12:26PM (#8875083)
>If we eventually start doing graphics on CPUs it will because we move to ray tracing or other sorts of algorithms that GPUs are bad at.

Even for ray tracing, I think you'll get better results on a modern GPU. Each individual processing element may not be anywhere near as good at dealing with the constant branch prediction failures inherent in ray tracing algorithms as modern CPU cores are, but there are thousands of them for every CPU core you have, and millions of completely independent samples to compute in a raytraced image. But I suspect that by the time that realtime raytracting becomes viable, the HSA approach I outlined above will be viable as well, and that will be the way to go.

Re:What's New in CPUs Since the 80s and How Does It Affect P... by vardump on Monday January 12, 2015 @02:50PM (#8875991)
I usually call nvidia's SMX a core. Nvidia's warp/hw thread architecture is sure interesting, but one has to remember it's mostly to get around memory bottlenecks. All those contexts need also a lot of gates. GDDR5 has high throughput but has an order of magnitude higher latency.

Ray-tracing doesn't really buy much unless you're doing some specific subset of effects. Rasterization covers 99% of cases with higher efficiency.

Re:What's New in CPUs Since the 80s and How Does It Affect P... by ANTSANTS on Monday January 12, 2015 @12:18PM (#8875032)
I had a pretty big post going, but vardump and Symmetry conveyed the gist of what I was going for much more succinctly, so I'll summarize:[1]

GPU cores are tiny because the problems they deal with are "embarrassingly parallel", trivially solved by throwing more cores at the problem. You make the cores as simple as possible so you can have thousands of them on a chip. Modern GPUs don't even have SIMD units per core any more; both NVidia and AMD are completely scalar now. You'd think that graphics would be the perfect scenario for SIMD, since shaders spend so much time dealing with 3 and 4D vectors, transformation matrices, colors, and so on, but it worked out that the gain in throughput and instruction density per-core was outweighed by the power, heat, and die cost of having parts of those thousands of SIMD units sitting idle while working on data that doesn't take up a whole SIMD register. And because context switches are much rarer on GPUs than CPUs, they can have extremely deep pipelines that push compute efficiency even further, at the expense of context switch latency.

CPU cores are, if I may, "fuckhuge", because by and large they can't solve their problems by throwing more cores at them. They take on problems that are inherently serial and branch heavy, like compiling a program or optimally compressing a large file, and throw bigger cores at them (out-of-order execution, branch prediction, speculative execution, multiple ALUs per core, instruction schedulers that exploit the parallelism hidden in the serial instruction stream, large register files only visible to the microarchitecture, etc) while maintaining a fairly short pipeline so that branch prediction failures and context switches don't take too long to recover from. SIMD fits in well here, because the cost of bigger and bigger ALUs is pretty much insignificant compared to all the other hardware that goes into a high-end CPU core. It can be a pain to optimize for, but it's great for middle-ground tasks that need both heavy parallel and serial/branch-heavy computing resources with little latency between the two, like video compression.

So you can't make one as good at solving the tasks of the other without making it worse at the task it's already intended to do. They tried to do this with Larabee, which was, no exaggeration, a few hundred Pentiums on a chip. Very interesting, but unsuccessful in the market, because it was an expensive niche product that was worse than either a CPU or GPU for the majority of their respectful workloads. What's really interesting, however, is the direction that AMD is taking. Rather than pushing SIMD like Intel, they're trying with their "heterogeneous systems architecture" movement to break down the communication barrier between CPUs and GPUs so that sharing data between the two is as easy as passing a pointer. SIMD is still great on CPUs for dealing with higher level primitives like vectors, matrices, or image macroblocks, but I can easily see the aforementioned middle-ground shifting to CPU threads working in close concert with GPU worker threads, as opposed to the mostly hands-off, one way street common in i.e. 3D rendering today.

[1] On second thought, this didn't turn out to be much of a summary, did it?

Re:What's New in CPUs Since the 80s and How Does It Affect P... by Marat_Dukhan on Monday January 12, 2015 @03:56PM (#8876372)
>>Modern GPUs don't even have SIMD units per core any more; both NVidia and AMD are completely scalar now.

This is factually incorrect. Let me quote Vasily Volkov [1]: "Earlier GPUs had a 2-level SIMD architecture — an SIMD array of processors, each operating on 4-component vectors. Modern GPUs have a 1-level SIMD architecture — an SIMD array of scalar processors. Despite this change, it is the overall SIMD architecture that is important to understand."

[1] http://parlab.eecs.berkeley.edu/sites/all/parlab/files/LU,%2...

Re:What's New in CPUs Since the 80s and How Does It Affect P... by ANTSANTS on Monday January 12, 2015 @04:07PM (#8876418)
I'm aware of AMD's terminology here, and I disagree with it. They say "SIMD array of scalar processors" where "SIMT" makes much more logical sense to me. I believe the only reason that they maintain this "2-level vs. 1-level SIMD" distinction is because NVidia coined the term SIMT, so they refuse to use it due to marketing concerns/some possible trademark or other IP law liability/pride.

...and now I read your paper, and I need to eat humble pie, because it apparently predates NVidia's use of the term "SIMT." Apparently, even if it makes more logical sense, SIMT is the buzzword!

Either way, I think it's a stretch to say I'm "factually incorrect" just because I used different terminology. Whether you think of it as an "SIMD array of scalar processors", or (to use NVidia terminology) an "SIMT warp of scalar threads" the important thing here is that the execution units in the bundle with the shared instruction pointer operate on scalar values now, rather than 4-element vectors.

Re:What's New in CPUs Since the 80s and How Does It Affect P... by vardump on Monday January 12, 2015 @03:06PM (#8876105)
What GPU vendors call cores aren't. It's like calling hair brush pins as hair brushes.

I think something should be called "core" if it can branch instruction stream. Predication doesn't count. A single core can run multiple instruction streams (GPUs, Intel Hyperthreading).

Re:What's New in CPUs Since the 80s and How Does It Affect P... by ANTSANTS on Monday January 12, 2015 @03:20PM (#8876181)
> What GPU vendors call cores aren't. It's like calling hair brush pins as hair brushes.

I agree. In the past I posted a decent (if I do say so myself) introduction to hyper threading and SIMT here: https://news.ycombinator.com/item?id=8245360

I simplified and just said "core" in this post because it was getting a bit long in the tooth already.

Re:What's New in CPUs Since the 80s and How Does It Affect P... by im2w1l on Monday January 12, 2015 @01:28PM (#8875524)
You can compile different files in parallel. You can probably even compile a single file in parallel. Consider this: If you start reading in the middle of a source file, can you make sense of what you see, or is it incomprehensible garbage unless you start at the top?

The answer is that it mostly makes sense except you may be tricked by #defines for example. Thus you could probably "optimistically parse" small chunks of the source code, all in parallel, with the understanding that you may have to throw out some intermediate results in light of new understandings.

Re:What's New in CPUs Since the 80s and How Does It Affect P... by ANTSANTS on Monday January 12, 2015 @03:34PM (#8876253)
Yeah, of course there are tasks that can be executed with coarse-grained parallelism, that can take advantage of multiple threads. It's not embarrassingly parallel though like with graphics, where you have millions of pixels that can be shaded independently of all the other pixels in an image, per rendering pass. In an optimizing compiler, compiled functions are not independent of each other, because data flow analysis will affect code generation, so you can't just compile each function on a different thread and combine the results. At least on a per-file basis, compilation has an inherently serial bottleneck, and that's not considering that 1. not all languages have separate compilation and linking like the C family, and 2. even with whole program optimization disabled, the linking phase can be fairly complicated in modern linker, so you have yet another serial bottleneck. And if you're implementing an non-optimizing compiler, then even with the naive, completely serial compiler, the whole process won't take long enough for it to be worth going to this trouble.
Re:What's New in CPUs Since the 80s and How Does It Affect P... by seanmcdirmid on Monday January 12, 2015 @11:55PM (#8878225)
Glitch works this way. It will simply redo the tree when better data is available (via dependency tracing); so you can parse, type check various parts within and between files using what is essentially optimistic parallelism.

This is quite useful for non regular problems that are otherwise difficult to parallelize.

Re:What's New in CPUs Since the 80s and How Does It Affect P... by esmi on Monday January 12, 2015 @03:08PM (#8876118)
I'm not so sure this is true in general. If you believe chip works, it's definitely false for Apple's A8. http://www.anandtech.com/show/8562/chipworks-a8
Re:What's New in CPUs Since the 80s and How Does It Affect P... by ANTSANTS on Monday January 12, 2015 @04:33PM (#8876562)
I should have been clear, I'm talking about Intel and AMD's monster desktop and server-class CPUs here, not mobile. For that matter, mobile GPUs are very different from desktop/console/HPC-class GPUs as well.
Re:What's New in CPUs Since the 80s and How Does It Affect P... by mbell on Monday January 12, 2015 @11:57PM (#8878229)
From what I could gather from building and testing a new desktop a couple months ago AVX instruction loads will trip CPU voltage levels to increase over 'normal' and generate a ton of heat as a result, often throttling if you aren't using aftermarket cooling. I would guess that AVX has a long way to go in terms of power efficiency before you'll see any large use of it.