July 29, 2009

The Frankfurt C++ Meeting

Hi everyone,

from July 13th to July 18th I attended the Meeting taking place in Frankfurt, Germany. Due to the European venue and probably also the general economic conjuncture, the total number of attendees was rather low, around 50 people overall.

The most dramatic event of the week took place on Monday, when Bjarne Stroustrup gave a presentation titled "Concept alternatives", summarizing all the various options for Concepts in the next standard, in the light of the recent discussions and concerns raised in the ISO reflector and elsewhere. For a lightweight introduction, with references, I would suggest:

http://www.ddj.com/cpp/218600111

or, directly, rather readable overall:

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2906.pdf

In short, over the last months, some people - first Howard Hinnant, and then Bjarne himself and then many other - began doubting that the current specifications of the Concepts features, as already voted in the Draft, were optimal from the usability point of view, that is from the point of view of the mythical "Joe Coder". In particular explicit concepts, thus the need for a large number of Concept maps, appeared pervasive in such central features of the library like the iterator hierarchy. Fixing those problems seems in principle possible (see Bjarne' paper above for some interesting sketches) but requires an highly-non-trivial redesign of large parts of the core specifications, not something that can be done at a late stage of the development toward the next Standard.

After much additional discussion, eventually July 13th the attendees voted to "decouple" Concepts from the Standard, thus effectively removing everything having to do with Concepts from it, and try this way to honor the schedule of a Standard ready by 2011 if not before 2010 as initially hoped. Note this move will require by itself a lot of work, because the Draft must be reverted to the pre-Concepts state, many fixes to DRs included, which were rather easy thanks to Concepts, which must be now re-opened and attacked in a case by case way.

After that kind of shock, the rest of the week proceeded in relatively dull way, with separate working groups, as usual (core, evolution, library) processing DRs, in a rather aggressive way, much more aggressive than other times, in my experience, in particular vs issues to be closed as NAD / Future (2-3 issues of mine also fall in that category, including DR 585 and DR 760) and many issues corresponding to comments from national bodies (which *must* be addressed to release the Standard). That kind of attitude is necessary, if we want to get the new Standard out of the door.

It's probably worth mentioning, however, a rather serious problems involving some uses of rvalue references (i.e., the new && syntax) vs exception safety, see this paper for an introduction:

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2855.html

(at the meeting, Dave Abrahams gave a nice general presentation on Thursday, which is not publicly available yet, I'll try to get ahold of it). As you can see, the problem is pretty serious, essentially implies that it's very hard achieve exception safety in very common uses of mixes of moves and copies. Luckily, a fix is possible, and elegant, along the lines explained by Bjarne in:

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2904.pdf

which, as you can see, attacks the real underlying issue with automatically generated move and copy constructors. The detailed wording for this solution will be scrutinized by the Evolution working group at the next meeting, but it looks like we have a neat way forward.

One remaining discussion I want to mention is the one turning around the following paper, again presented by Bjarne at the meeting:

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2913.pdf

where it's explained that the design pursued by GCC (libstdc++-v3) as regards the iterators of the standard container is the best one, performance-wise and from other more theoretical points of view, to be preferred to the one used by, e.g., Dinkumware (thus Microsoft). At the meeting, people decided not to enforce for C++1x the design used by GCC thus forcing an unexpected ABI-break in this area, but the moral "winner" is clear.

What else... During the meeting, as usual I have been able to approach many colleagues and share experiences about implementing various parts of the library and of the core C++1x facilities too, i.e, with Jason Merrill (Red Hat) we discussed a few g++ issues at the interface with the library resolved during the meeting. To Walter Brown (Fermilab) I pointed out a few minor issues, hopefully editorial, in the current specifications for (on which, as you remember, I have been working the last weeks. Interestingly, Sylvain Pion (INRIA), is using the "parallel-mode" provided libstdc++-v3 and is also studying "transactional memory" (e.g., he is following the GCC effort in this area, focused on implementing the Intel ABI, and would like to test it for parallel insertions in the "STL" tree structures). With Alan Talbot we discussed the new simplified specifications for std::pair, and we commented that adjusting the new allocator model to not use Concepts, will not be a trivial task for Pablo Halpern. Too many to mention...

For now, thanks for the attention!
Paolo.

June 18, 2009

Hi everyone!

... this is my first post on my first blog, thus please be patient in case something goes wrong, the formatting is a bit off and the like...

That said, my name is Paolo Carlini and I live in Viterbo, close to Rome. I belong to the team led by Elena Zannoni, working mainly on GCC (http://gcc.gnu.org) and in particular its runtime C++ library which I co-maintain. I'm also representing Oracle at the ISO WG21 Meetings and, as part of that effort, I'm rather focused on implementing for the first time features which are being standardized or which must be fixed according to the resolutions of official DRs.

In particular, in this first post I wanted to tell you something about the ongoing work to implement the new, forthcoming C++ Standard, so called, in GCC, C++0x, but actually due for 2010 or 2011 in the worst case. For reference, you can find the last draft here http://http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2857.pdf, freely available: the library is described in chapters 17-30, a large fraction of the document, as you can see...

The last weeks I have been specifically implementing features in the <random> header (section 26.5), on which we have already some practical experience, dating back to the implementation of TR1 (http://http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1836.pdf), which already included a rather useful <tr1/random> header. However, after a couple of years of on the field testing, also in big labs carrying out large "Montecarlo" simulations (e.g., Fermilab), it appeared obvious that both the user interfaces had to be improved and more distributions and generators added. That explains the rather large effort necessary now to deliver also the C++0x versions of those facilities to the GCC users.

Thanks also to some code donated by an independent contributor (Ed Smith-Rowland) all the interfaces are already in place in the mainline (would be GCC 4.5x) library and many distributions are apparently working well, but a lot of work remains to be done, in particular auditing the various algorithms and making sure they are still optimal in the light of the most recent literature. Just as an example, two weeks ago I replaced a rather convoluted solution for the Gamma distribution described in Devroye' treatise (http://http://cg.scs.carleton.ca/~luc/rnbookindex.html) with a faster and simpler one due to Marsaglia and Tsang (you can find it described also in the third edition of Numerical Recipes (http://www.nr.com): I suspect the same could/should be done also in a couple of other cases. There are also more ambitious possibilities, like investigating the use of parallel algorithms.

I know for sure that random numbers are often used in many different application areas and generators written in many different languages, thus I thought it could make sense to ask the feedback of the community about this specific task. Please have a look to the code already in the mainline GCC compiler - I would suggest using SVN (http://http://gcc.gnu.org/svn.html) for that - compare it to the code you are already using for random number generation and management, see if there is something the future GCC 4.5 could do better, faster, or more accurately in the light of your experience. Any help would be really welcome!

soon...
Paolo

About

My Profile

Top Tags

Categories

Powered by
Movable Type and Oracle