GCC is C++17 Complete
gcc.gnu.org
gcc.gnu.org
I love seeing free compilers get advanced features years ahead of proprietary compilers like MSVC and Intel Studio.
https://blogs.msdn.microsoft.com/vcblog/2016/01/22/vs-2015-u...
If you need portable C code, forget about all that stuff. Forget about a lot of things since some compilers are truly atrocious.
I think it's long since fallen into disrepair/bitrot, but it could probably be revived if there was enough demand.
* - again, I'm guessing - I've been out of the c++ game for a few years...
It is great to see that things have changed.
http://en.cppreference.com/w/cpp/compiler_support
And the embedded ones like TI are even behind those.
> The Visual C++ Team is excited to announce that the compiler in Visual Studio 2017 RC will feature a mode much closer to ISO C++ standards conformance than any time in its history. This represents a major milestone in our journey to full ISO C++ conformance. The mode is available now as an opt-in via the /permissive- switch but will one day become the default mode for the Visual C++ compiler.
I'm really excited about having MS right up at the front of the pack with GCC and Clang.
I respect the progress Microsoft is making, both in the long term (since the dark ages in which they didn't care about standards) and in the short term (a genuine C++17 implementation effort), but their progress is still slower than the competition.
I love the work being done by the clang and gcc teams, but I still stick with Intel's C++ compiler for many things due to its far better support for automatic vectorization among other things.
"Because the final ISO C++1z standard is still evolving, GCC's support is experimental. No attempt will be made to maintain backward compatibility with implementations of C++1z features that do not reflect the final standard"
Also that page only tracks pure language features, standard library conformance for libstdc++ is tracked elsewhere, although the standard library is equally part of the language.
The status for libstdc++ is here:
https://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#...
which in fact shows a few missing features.
https://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#...
I share your enthusiasm tho. It will probably introduce parallel code into everyday C++ projects faster then new special purpose parallel programming primitives will.
I'm still eagerly waiting for the Concurrency TS to be merged. As it is, without 'then', std::future is pretty useless.
What do you do not want are explicit uses of 'future::then' and the required manual CPS transform. Instead you want a wait-for-{any,all} future operations.
[1] For a long time libstdc++ lacked regex support, but people could get them from boost and mostly didn't care.
[2] Stephan T. Lavavej, not the library :)
Do they have a lot of very active contributors that communicate to efficiently split the work, or do they have a small but very dedicated group of people who spend the bulk of their time on implementing these features?
Regardless, kudos.
Regardless, it's great to see C++ compilers incorporating latest standard features. For comparison, check JavaScript standards implementation in browsers (not sure if it's a fair comparison).
https://gcc.gnu.org/projects/cxx-status.html#tses
http://www.open-std.org/Jtc1/sc22/wg21/docs/papers/2015/n451...
Instead, it's more akin to something like the "synchronized" method and block attribute in Java, where the compiler transparently acquires and releases a mutex. Except in Java the mutex is on a particular object, whereas in C++ it'll be on a per-block hidden global mutex.
For small enough blocks, and if the stars are aligned just right (i.e. regarding alignment, cache-line locality, etc), the compiler might be able to optimize away the mutex in favor of a series of LL/SC, CAS, etc statements. But then, so could the JVM for synchronized methods.
It basically makes multi-threading easier, but won't automagically make it possible to build lock-less data structures, except that maybe the compilers will be smart enough to optimize something as simple as a singly-linked list construct into atomic instructions.
This approach to "transactional memory" was mostly fleshed out years ago in proofs-of-concepts by Intel, GCC, etc developers. And the approach has driven Intel's design of their "transactional memory" instructions, which basically move aspects of traditional synchronization approaches (speculative mutex acquisition, dirty flags) into the microcode.
It really is transactional memory and it is meant to be implemented using hardware acceleration like that available in recent server class x86, power and sparc CPUs.
GCC, I belive, supports both a pure software based implemenation and an hibrid one.
Here are some good links which explain how TSX works and how Intel might have accomplished it.
http://www.realworldtech.com/haswell-tm/
http://www.realworldtech.com/haswell-tm-alt/
TL;DR: one way or another they're piggy-backing on the mechanisms needed to maintain x86's strong cache coherency. Fundamentally it's just speculative operations on a small amount of data--if conflicts are detected, or if you manipulate more than a couple of cache lines (because the processor will only be able to track and buffer a very limited number of cache lines for conflicting operations during the pendency of the transaction), the code generated by the compiler will either take a lock or loop.So, yes, it will make much existing code faster. But it's not going to provide the ability to develop highly-concurrent lock-free data structures. If there's any serious contention (i.e. more than 2 or 3 threads), or your transactional blocks access more than a few words of shared state, the transaction will invariably abort. Which is why all software transactional implementations, including recent ones which make use of TSX, are typically _slower_ than similar lock-based approaches in real-world scenarios.
STM-light is still conceptually elegant from the programmer's perspective, but deep down there's much less magic then you'd think. That's because it's _very_ expensive to track conflicts in a fine-grained manner in hardware. LL/SC operations were proven in the 1980s to be universal primitives that could be used to implement arbitrarily complex lock-free, wait-free algorithms. And chips like ARM and POWER have LL/SC opcodes. But they're pale shadows of the constructs studied in the 1980s because trying to actually implement them in hardware is just too costly. So TSX, while cool and useful, is something of a hack (and I mean that in both the positive and pejorative senses).
The real speed gains from Intel's new architectural support come from hardware lock elison, and doubtless both GCC and LLVM will lean heavily on this as it'll be easier to work with. Like with VLIW and then auto-vectorization, don't put too much stock in promises that compilers will be able to transform typical application code into a form that's suitable for use by the specialized hardware instructions. Like with AVX2, for example, to really make good use of TSX programmers will still need to meticulously organize their data structures and code flow, and will need to be mindful of the hardware constraints from the very outset. And in most cases they'll be far better off using intrinsics or assembly in the critical sections of their code.
I totally agree that TSX works best with specialized data structures. But it's powerful enough that you can, for example, malloc() or free() a block of memory inside a transaction.
http://www.gsd.inesc-id.pt/~salaa/wttm2015/html/abstracts/Hasenplaugh.pdf
it's the opposite. The maximum reliable transaction write capacity if contiguous and well-aligned is small on POWER (63 cache lines) and high with TSX (400 lines). TSX is using L1 cache to buffer writes, and so the number of concurrent transactions only scales with cores. Whereas POWER uses a per-thread buffer which can scale linearly with the number of hardware threads (8 threads per CPU, 80 in their test).So if I'm understanding this correctly, TSX has better capacity but poor concurrency, and POWER has poor capacity but better concurrency.
That's very cool.
I assume xbegin is a memory barrier. But is it a full fence like mfence or lock prefix?
I see a lot of benchmarks using TSX for locking, but one of the nicer features of lock compxchg or lock xchg is they carried an implicit mfence this was nice because it forced reads/writes before the instructions to be completed.
I know xbegin/xend do _more_ then an mfence for reads/writes within the RTM region but do they provide fencing for instructions _after_ their execution?
xacquire/xrelease can be used as modifiers to existing lock prefixed RMW instructions which are already full barriers, giving them optimistic locking capabilities.
But not for load/stores. If you load/store from data within an RTM region (after _xend()) you have no atomic protections.
For C++17 the biggest features are structured binding, which is the first step toward pattern matching, and deduction of template parameters for class types.
Other features like fold expressions are realy meant for library writers.
The standard library did get variant and optional whixh arw pretty cool.
Variant and optional would be really useful if only I could use them. One day, one day...
(ps doesn't stop me writing using these new features at home on other projects)
From Xcode, I have the choice between "-std=c++14" and "-std=gnu++14" and I am not sure which I should choose ...
The gnu bit means "add as small number of extensions". None of them are that strange.
Breaking legacy code without access to the original authors makes maintaining that code extremely difficult. Can you rewrite all of the "inline" instances in a 1M line C++ program without side-effects such as performance loss? When the lead programmer requires C++17 for their spiffy new code, are you the person who has to rewrite the "broken legacy code"? Does your IDE know all of the standards?
They should change the language name each time, such as "Alpha", "Beta", "Gamma", etc. so you can say that you "know" the "Beta" language. As it is I don't know anyone who can seriously claim to know "C++".
"C++ Standard" is an oxymoron.
Or, as is very common, they are not sure and it you will know that they don't know enough C++, or are in danger of writing C++ like it was C.
If someone says "I play the guitar" and you ask "acoustic, electric? hollow bodied?" and they don't know, you'd be surprised.
If someone says "I own a Volkswagen Golf" and you asked what mark (4, 5, 6 or 7) and they didn't know, you'd assume they knew nothing about they car or didn't have to replace any parts on it, even simple things like windscreen wipers as they'd have bought the wrong ones.
It's the same with C++ - the spec makes a huge difference so we should probably all be aware of what we're writing.
cppreference[1] (which, granted, is not authoritative) does not document any changes in inline semantics in C++14.
Having said that, C++17 was a minor update (much to Stroustrup's displeasure) and I can heartily recommend this book.
It was Meyer's last book as he is now retired (but will happily reply to emails; I love that about the C++ community - I've emailed Sutter, Stroustrup and Meyers and they will all reply).
Fun example: a customer of mine initialized a variable within a loop and that resulting program just didn't work as expected (which it did with the same code on my desktop with gcc). As soon as he moved the variable out of the loop the program worked as expected.
Also, for the extremely low cost parts (small AVRs, PIC etc) the margins on the parts is very low which doesn't fund a lot of software development. And hardware companies often don't have much software development resource.
Modules eventually, more than 20 years later, might be a better solution.
And they got rebuffed by people that never managed to ship a working implementation. Standard committees yay!
At a time where GCC was still catching up, MSVC was in the dark ages and clang still not existent, EDG used to be the standard compliant C++ front end. It is still the front end for a lot of proprietary compilers (Intel, MSVC intellisense, Comeau) and I hear it is a very high quality codebase.
What is common practice to do that now-a-days? Is that with modules (but I'm not sure if that is a standard yet, I could be mistaken).
In that case, skip to c++14 immediately and try your best to use as much from it as possible as that will erradicate a bunch of unpleasancies you've become accustomed to. Really it's almost like a new language (and yes that comes with it's pros and cons) compared to pre-c++11. Once I realized that I've tried keeping the mindset 'first check if c++14 added something for dealing with this, before writing any code' for nearly everything I write (in practice: search, land on cppreference.com and/or stackoverflow.com, read). In the beginning that costs time but I'm pretty confident I gained that back already because the knowledge it gives you enables to write better code, faster.
Many things have become easier, or in some case much, much easier, to do since ++11. And some things that were previously nearly impossible are now intuitive and fluent.
Or write a cheatsheet (multiple pages) for C++11 onward, taking care to detail example cases of each new item or construct or keyword.
You'll know no end of idiosyncrasies in no time.
Remember, that was ~6 years ago and that's a long time. If we're still writing C++2003 and haven't fully looked into C++11 and beyond or learned swathes of it (like many many many of my colleagues and C++ devs I meet, some of whom call it C++0x), that means they're working to a spec 14 years old (C++2003). 14 years old is a teenager.
(I acknowledge that many high level projects use too much CSS)
Further more, that page is responsive! and doesn't require 5mb of JavaScript and a high pref cpu to work.
Its actually terrible to read on a wide monitor. If you were to give the content a max-width with some gutters its easier for your eyes to follow the lines. I always start reading a line that I just read! I'm talking about adding less than 10 lines of CSS, nothin major.