News for hackers. Stuff that matters.
Re:Epiphany-V: A 1024-core 64-bit RISC processor by sqeaky on Wednesday October 05, 2016 @03:25PM (#12646942)
yellowapple said:

> human assembly optimization is unlikely to be better than a modern compiler

You said:

> Most developers can't beat LLVM

Then you pointed out some specific examples where a human can be a compiler.

Seem like you two agree, then you go and call what he is a saying "a myth". I think I need some clarification.

Prior to this my understanding was that if the developer provides the compiler good information with type, const, avoids pointer aliasing and in general makes the code easy to optimize that the compiler can do much better than most humans most of the time, but of course a domain expert willing to expend a huge amount of time with all the knowledge the compiler would have can beat the compiler. It just seems that beating the compiler is rarely cost (time, money, people, etc...) efficient.

Is my understanding close in your opinion?

Re:Epiphany-V: A 1024-core 64-bit RISC processor by wolf550e on Wednesday October 05, 2016 @06:22PM (#12648476)
Making C compilers for different architectures output great code from same source is really hard. e.g. "const" is not used by optimizers because it can be cast away. Interpreters, compression routines, etc. can always be sped up using assembly.

If what your program does can be sped up using vector registers/instructions (e.g. DSP, image and video processing) then you want to do that because x4 and x8 speedups are common. Current autovectorisers are not very good. If it is not the most trivial example like "sum of contiguous array of floats", you'll want to write SIMD assembly or intrinsics or use something like Halide. In practice projects end up using nasm/yasm or creating a fancy macro assembler in a high level language.

The choice to use assembly is economics, and it's all a matter of degree. How much performance is left on the table by the compiler? How many C lines of code take up 50% of the cpu time in your program? How rare is the person who is able to write fast assembly/SIMD code? How long does it takes to write correct and fast assembly/SIMD code for only the hot function for 4 different platforms (e.g. in-order ARM, Apple A10, AMD Jaguar, Haswell)?

If you think "25%, 100k LoC, very rare, man-years" then you conclude it's not worth it. If you think "x8, 20 lines, only as rare as any other good senior engineer, 50 hours" then you conclude it's stupid to not do the inner loop in assembly.

What are the numbers in practice? I don't know. In practice, all the products that have won in their market and can be sped up using SIMD have hand coded assembly or use something like Halide and none of them think the compiler is good enough.

Re:Epiphany-V: A 1024-core 64-bit RISC processor by jmgao on Wednesday October 05, 2016 @11:02PM (#12649917)
> Making C compilers for different architectures output great code from same source is really hard. e.g. "const" is not used by optimizers because it can be cast away.

const most certainly is used by optimizers: https://godbolt.org/g/kLmGr4

The willingness of C compilers to (ab)use undefined behavior for optimization is one of the main criticisms against it.

Re:Epiphany-V: A 1024-core 64-bit RISC processor by beached_whale on Thursday October 06, 2016 @09:35AM (#12652285)
Check out the cppcon 2016 presentation by Jason Turner and watch how eager the compiler optimizes away code when const is enabled on values. Cool presentation too, and uses Godbolt's tool https://www.youtube.com/watch?v=zBkNBP00wJE
Re:Epiphany-V: A 1024-core 64-bit RISC processor by flamedoge on Thursday October 06, 2016 @12:45AM (#12650317)
I think the argument is not against unwillingness, but when and how.