From: Paolo Carlini <paolo.carlini@oracle.com>
To: Jason Merrill <jason@redhat.com>
Cc: gcc-patches List <gcc-patches@gcc.gnu.org>
Subject: Re: C++ PATCH to use hash tables for template specialization lookup
Date: Mon, 06 Jul 2009 13:19:00 -0000 [thread overview]
Message-ID: <4A51F1BA.4020301@oracle.com> (raw)
In-Reply-To: <4A51F06B.2080006@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 245 bytes --]
Hi,
> Sounds good, thanks.
For now, I'm collecting some data for the attached. When N grows (I
tried up to ~1000) the difference between patched / unpatched is
impressive, like O(N) vs O(N^2). Some numbers later...
Paolo.
////////////////////
[-- Attachment #2: memoizing2.cpp --]
[-- Type: text/x-c++src, Size: 1123 bytes --]
#if defined(__MWERKS__)
# pragma template_depth(2000)
#endif
#if defined(_MSC_VER)
# pragma warning(disable: 4307)
#endif
#if defined(__ICL)
# pragma warning(disable: 68)
#endif
#if !defined(N)
# error "N is not defined!"
#endif
typedef unsigned long ulong;
// re-arranged recursive branches
template< int i, int test > struct fibonacci
{
#ifndef DIFF
enum { v = ulong(fibonacci<i-2,test>::value) };
enum { value = ulong(v) + ulong(fibonacci<i-1,test>::value) };
#else
enum { value = ulong(fibonacci<i-1,test>::value) };
#endif
};
template< int test > struct fibonacci<0,test>
{
enum { value = 0 };
};
template< int test > struct fibonacci<1,test>
{
enum { value = 1 };
};
template< int n > struct test
: fibonacci<N,n>
{
};
int main()
{
return
ulong(test<0>::value)
+ ulong(test<1>::value)
+ ulong(test<2>::value)
+ ulong(test<3>::value)
+ ulong(test<4>::value)
+ ulong(test<5>::value)
+ ulong(test<6>::value)
+ ulong(test<7>::value)
+ ulong(test<8>::value)
+ ulong(test<9>::value)
;
}
next prev parent reply other threads:[~2009-07-06 12:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-02 17:29 Jason Merrill
2009-07-05 21:41 ` Paolo Carlini
2009-07-06 12:45 ` Jason Merrill
2009-07-06 13:19 ` Paolo Carlini [this message]
2009-07-06 18:47 ` Paolo Carlini
2009-07-06 18:58 ` Jason Merrill
2009-10-22 16:44 ` H.J. Lu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4A51F1BA.4020301@oracle.com \
--to=paolo.carlini@oracle.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jason@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).