3 ms·
We're at a crossroads in CPU design. The hardware guys implement heuristics to make ordinary code work "pretty good", with cache lines and multiple layered cach
by JoeAltmaier 11y ago
We're at a crossroads in CPU design. The hardware guys implement heuristics to make ordinary code work "pretty good", with cache lines and multiple layered caches and register calculus and stalling pipelines.
Then compiler folks reverse-engineer all that to get "really good" performance. But they can't make one code for every model of CPU because this stuff changes with each release.
How about, CPU leaves these decisions up to the compiler? Flatten and simplify, and make (allow) compiler writers to know exactly what's going on, and even control it!
- Veedrac 11y agoI'm not sure what you're suggesting. Software prefetching? Software branch prediction? Those sound like pretty poor ideas if that is indeed what you mean - a lot of time will be spent emulating something that hardware does really well.
- JoeAltmaier 11y agoE.g. the Mill architecture, which has no register-collision issues at all. At the cost of the compiler keeping track of the address of results as they pass through the mill. And hardware doesn't do it well at all, at least not in the super-optimization cases discussed in the OP. They're working hard to reverse-engineer around the hardware; which is at least as hard as the compiler programming caches and pipelines explicitely.
- kllrnohj 11y agoMill has two issues: 1) It doesn't exist. Theory is irrelevant, build an actual chip and run some actual software on it and then let's talk. 2) VLIW of 33 operations? Ain't no way in hell they are keeping that fed. Not happening. AMD couldn't keep a VLIW of 5 fed on their GPUs. They dropped to VLIW4, then switched to a RISC SIMD approach. And that's with a compiler that only has to deal with a very constrained grammar that almost never encounters branches. Which is about as far from general purpose workloads as you can get.
- Veedrac 11y agoIssue #1 is a big deal, but they've never said otherwise. Issue #2 is less of a reason to worry. The 33 instructions is an upper limit, and will likely be a lot lower on most implementations. They also don't expect, nor need, it to be saturated. Further, their instruction set is much more amiable to parallelism than normal instruction sets because * Their instructions have special values (NaN and NaR) that enable extra parallelism. * Their instructions avoid side effects that prevent parallelism. This includes not just condition codes, but effectively the whole belt mechanism. * Their instructions can move data across themselves horizontally (under certain phase boundaries), so certain data dependencies are allowed inside an instruction. In essence, you're running at three-to-five times the clock rate but each clock is only allowed to run a given subset of instructions. There's an example they give where the whole of a vectorized strcpy iteration is done in one instruction, with no set-up or tear-down needed. This is of course a best-case scenario, in that every technique they have is in use simultaneously, but all of the techniques they give are generally applicable and (relatively speaking) simple for compilers to use.
- JoeAltmaier 11y agoHere's another: http://www.technologyreview.com/news/539416/startup-attempts-to-reinvent-the-cpu-to-make-computers-less-power-hungry/ http://www.technologyreview.com/news/539416/startup-attempts...
- Veedrac 11y ago> At the cost of the compiler keeping track of the address of results as they pass through the mill. The compiler already does this. Traditional architectures then require you to use these results to make a register mapping, which is then basically (kind-of) undone in hardware with register renaming. The Mill (kind'a) just doesn't do these two steps. > And hardware doesn't do it well at all It really does, though. Compiler-aided prefetch, even if magically perfect, wouldn't even help here since the problem is in the data layout.
- kllrnohj 11y agoThat is not at all how compilers & cpu engineers work together. Compilers are not reverse-engineering the CPU, and different CPUs do not behave that radically different to make this non-portable. The biggest issue by far are the languages themselves. Java, for example, is inherently anti-CPU-friendly by design. You can't get flattened objects, almost everything is done via reference instead of value, etc... This was done for other tradeoffs, but the majority of languages in use were not built for raw CPU throughput.