[libcxx] r185343 - Implement n3658 - Compile-time integer sequences

Marshall Clow mclow.lists at gmail.com
Wed Jul 3 12:23:15 PDT 2013

On Jul 2, 2013, at 3:39 PM, Richard Smith <richard at metafoo.co.uk> wrote:
> On Tue, Jul 2, 2013 at 7:56 AM, Howard Hinnant <hhinnant at apple.com> wrote:
>> On Jul 1, 2013, at 10:13 PM, Richard Smith <richard at metafoo.co.uk> wrote:
>>> On Mon, Jul 1, 2013 at 4:57 PM, Howard Hinnant <hhinnant at apple.com> wrote:
>>>> On Jul 1, 2013, at 6:17 PM, Howard Hinnant <hhinnant at apple.com> wrote:
>>>>> Inspired by your approach, I started from scratch and came up with the enclosed.  The compiler will run out of memory before it runs into the recursive template instantiation limit, and this works with far higher numbers.  It passes all the current intseq tests.
>>>> [ snip ]
>>> My algorithm is fixed up and attached. I upped the divisor to 8; that
>>> was the sweet spot in my testing. I also switched to performing the
>>> pack building in size_t and converting to the sequence's type at the
>>> end (and thus using explicit specializations rather than partial
>>> specializations); that made the size_t case about 35% faster, but the
>>> non-size_t cases about 40% slower (converting from
>>> integer_sequence<size_t, ...> to integer_sequence<T, ...> is now,
>>> remarkably, slower than building the integer_sequence<size_t, ...>).
>>> It's probably possible to tweak this to get the same performance for
>>> all T, but I've not yet found a trick for that.
>>> <mis.cc>
>> I copy/pasted this in and ran the unit tests and one of the tests caused clang to consume over a Gb of memory before I aborted the test.  I guessed that the test responsible for this was inputing a negative N.  So I renamed your __make_integer_sequence to __make_integer_sequence_unchecked, and put checking on top of it and tested again.  This is much faster than what I posted for very long sequences.  Looks like 10X faster.
>> I went through and macro-protected your suggestion and am posting it back here for review.

Committed as revision 185569 (with an additional visibility annotation)

-- Marshall

Marshall Clow     Idio Software   <mailto:mclow.lists at gmail.com>

A.D. 1517: Martin Luther nails his 95 Theses to the church door and is promptly moderated down to (-1, Flamebait).
        -- Yu Suzuki

More information about the cfe-commits mailing list