News for hackers. Stuff that matters.
Re:The Itanic Has Sunk by xorcist on Friday July 30, 2021 @04:48AM (#28005862)
What types of languages do you see would enable more efficient VLIW compilers?

From my limited perspective, I find C one of the easier languages to write optimizing compilers for, and would therefore expect optimizing compilers to be the most efficient there. 40 years of collective experience of optimizing for C-like languages also helps of course.

Or is it the lack of explicit parallelism in the language that is limiting? Somehow I suspect the limited uptake of better suited languages to be a sign that they aren't very helpful most of the time, and most of the parallel operations people do is more like serving a lot of individually sequential transactions per second, which is something C and unix is pretty good at.

Re:The Itanic Has Sunk by chalst on Friday July 30, 2021 @07:17AM (#28006738)
C is hard to optimise. Graydon Hoare gave a nice introductory compilers talk that went into some of the reasons why

http://venge.net/graydon/talks/CompilerTalk-2019.pdf

Re:The Itanic Has Sunk by throwaway81523 on Friday July 30, 2021 @05:39AM (#28006190)
One well known obstacle to optimizing C is the difficulty of alias analysis. It's easier to do that for languages that don't have C's unrestricted pointers.
Re:The Itanic Has Sunk by jonathrg on Friday July 30, 2021 @06:16AM (#28006402)
Doesn't the restrict keyword solve this?
Re:The Itanic Has Sunk by tjalfi on Friday July 30, 2021 @09:53AM (#28007963)
The paper Why Programmer-specified Aliasing is a Bad Idea[0] evaluated the effectiveness of restrict in 2004. They found that adding optimal restrict annotations provided only a minor performance improvement, on average less than 1% across the SPEC2000 benchmarks.

[0] http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.94....

Re:The Itanic Has Sunk by dralley on Saturday July 31, 2021 @06:35PM (#28022087)
How much of this is because nobody puts effort into these optimizations?

The Rust compiler has repeatedly found critical bugs in LLVM's restrict / noalias support, bugs that would impact C / C++ as well if any real-world C / C++ programs actually used it.

If compilers produce straight-up broken code in these situations, I can only imagine they're not putting a lot of effort into these optimization strategies.

Re:The Itanic Has Sunk by tjalfi on Sunday August 01, 2021 @01:27PM (#28028121)
> How much of this is because nobody puts effort into these optimizations?

restrict is rare in C and C++ but common in Fortran; array parameters in Fortran aren't allowed to alias. Intel and IBM both have great Fortran compilers so I would expect their C and C++ compilers to have good support for restrict.

Re:The Itanic Has Sunk by user-the-name on Friday July 30, 2021 @06:50AM (#28006587)
I don't think anyone has ever used the restrict keyword, or understood what it does.
Re:The Itanic Has Sunk by jonathrg on Friday July 30, 2021 @08:25AM (#28007197)
What? I use it whenever I have a function that takes two or more pointers if I know they can't refer to overlapping memory. And it's part of the signature for memcpy since C99
Re:The Itanic Has Sunk by IshKebab on Friday July 30, 2021 @08:50AM (#28007379)
When he said "anyone" he meant "almost anyone". You're an outlier if you use `restrict` regularly.

I checked on grep.app, there are 10k results for `restrict` for C code, compared to 700k for `struct` (I know they're not directly comparable but that gives an idea.

Re:The Itanic Has Sunk by jonathrg on Friday July 30, 2021 @09:36AM (#28007792)
That seems like about the right proportion to me - struct solves a much more common problem than restrict does. And to be fair, it is a lesser known feature. But user-the-name is implying that restrict is somehow difficult to use or understand, which I don't agree with at all.
Re:The Itanic Has Sunk by icedchai on Friday July 30, 2021 @11:03AM (#28008757)
That probably explains it. In many shops, C may as well have stopped at C89.

I've been working with C since the early 90's. I've never seen any code use restrict.

Re:The Itanic Has Sunk by enjoy-your-stay on Friday July 30, 2021 @05:22PM (#28012530)
Also large chunks of libc use it as well, e.g. the printf family of functions.
Re:The Itanic Has Sunk by moonbug on Friday July 30, 2021 @08:07AM (#28007066)
derp.
Re:The Itanic Has Sunk by pantulis on Friday July 30, 2021 @05:53AM (#28006273)
So Rust comes to mind, right? Anything else?
Re:The Itanic Has Sunk by rwmj on Friday July 30, 2021 @06:21AM (#28006434)
FORTRAN or any language with lots of arrays and matrices.
Re:The Itanic Has Sunk by jabl on Friday July 30, 2021 @09:49AM (#28007931)
I suspect if you want a HW architecture for running array operations you'll end up with something like a vector machine (e.g. ARM SVE(2) ) or a GPU rather than a VLIW CPU?
Re:The Itanic Has Sunk by marcosdumay on Friday July 30, 2021 @11:31AM (#28009060)
VLIW is basically a more flexible kind of vector machine.
Re:The Itanic Has Sunk by jabl on Friday July 30, 2021 @01:08PM (#28010053)
And a traditional scalar architecture is more flexible still. The trick is to pick the correct set of tradeoffs for the targeted applications. I claim that for most array style workloads vector/GPU architectures are flexible enough, and offer better perf/watt and perf/chip area.
Re:The Itanic Has Sunk by Semaphor on Friday July 30, 2021 @08:08AM (#28007071)
So, APL?
Re:The Itanic Has Sunk by rwmj on Friday July 30, 2021 @12:53PM (#28009903)
Absolutely yes that would make sense (or more likely the modern "derivatives" like J & K)
Re:The Itanic Has Sunk by jiggawatts on Friday July 30, 2021 @06:20AM (#28006419)
C is very "pointer heavy", and much code involves chasing linked lists and the like. This tends not to suit VLIW well.

Modern languages like Rust tend to produce more instructions for the same high-level logic, but those instructions are easier to schedule for superscalar CPUs. It typically ends up as a bit of a wash on CISC processors, but could be better than C/C++ on VLIW.

I guess we'll never know now...

Re:The Itanic Has Sunk by secondcoming on Friday July 30, 2021 @01:55PM (#28010528)
C is pointer heavy if you write pointer heavy code
Re:The Itanic Has Sunk by lmm on Saturday July 31, 2021 @02:48AM (#28015937)
> What types of languages do you see would enable more efficient VLIW compilers?

I was thinking of languages where dependencies are more explicit and the idea of a global evaluation order isn't there in the first place. I'd be very interested to see a reduceron-style effort that implemented graph-reduction evaluation on a VLIW processor.

> Somehow I suspect the limited uptake of better suited languages to be a sign that they aren't very helpful most of the time, and most of the parallel operations people do is more like serving a lot of individually sequential transactions per second, which is something C and unix is pretty good at.

Heh, that was the idea that those barrel-processor SPARCs were designed around. But they weren't so successful in the market either in the end.

Re:The Itanic Has Sunk by TickleSteve on Friday July 30, 2021 @06:39AM (#28006523)
The TMS320C6678 (C66x architecture) DSPs still use VLIW and work pretty well. Like most DSPs, they're typically programmed using C, for which TI supplies optimised libraries for processor-intensive operations. IIRC, the compiler itself was fairly standard.