/* $cfa is the result of building this configuration: ../cfa-cc/configure --with-target-hosts=host:nodebug CXX=g++- ~/u++ is my own download of uC++ 7.0.0 $cfa -xc experiment.koad -DIMPL_CFA_MIKE_OLD -o perfexp-cfa-mike-old -nodebug -O2 $cfa -xc experiment.koad -DIMPL_CFA_MIKE_NEW -o perfexp-cfa-mike-new -nodebug -O2 $cfa -xc experiment.koad -DIMPL_CFA_MIKE_POC -o perfexp-cfa-mike-poc -nodebug -O2 $cfa -xc experiment.koad -DIMPL_CFA_COLBY -o perfexp-cfa-colby -nodebug -O2 $cfa -xc experiment.koad -DIMPL_CFA_THIERRY_SUB -o perfexp-cfa-thierry-sub -nodebug -O2 g++ -xc++ experiment.koad -DIMPL_STL -DNDEBUG -o perfexp-stlgpp -O2 ~/u++/u++-7.0.0/bin/u++ experiment.cpp -DIMPL_UPP -DNDEBUG -o perfexp-uppupp -O2 O2 O2-ltd O3-ltd perfexp-cfa-mike-old 2.50 2.55 perfexp-cfa-mike-new 2.18 2.15 perfexp-cfa-mike-poc 1.74 1.71 perfexp-cfa-colby 2.90 2.84 3.09 perfexp-cfa-thierry-sub 1.85 perfexp-stlgpp 4.57 4.72 perfexp-uppupp 2.09 1.94 1.91 O2-ltd is -fno-tree-pre -fno-gcse (An earlier draft of mike-new didn't work without disabling those optimizations; we probably don't care about that anymore.) */ #include #include #if defined IMPL_STL #include struct S { volatile int f[64]; }; #elif defined IMPL_UPP #include #include struct S : public uSeqable { volatile int f[64]; }; #elif defined IMPL_CFA_MIKE_OLD #include "mike-old.hfa" struct S { int f[64]; // FIXME: make "is volatile" consistent; given bug #TBD DLISTED_MGD_IMPL_IN(S) }; DLISTED_MGD_IMPL_OUT(S) #elif defined IMPL_CFA_MIKE_POC #include "mike-proto-list.hfa" struct S { int f[64]; // FIXME: make "is volatile" consistent; given bug #TBD inline dlink(S); }; P9_EMBEDDED( S, dlink(S) ) #elif defined IMPL_CFA_MIKE_NEW #include struct S { int f[64]; // FIXME: make "is volatile" consistent; given bug #TBD inline dlink(S); }; P9_EMBEDDED( S, dlink(S) ) #elif defined IMPL_CFA_COLBY #include struct S { inline Seqable; int f[64]; // FIXME: make "is volatile" consistent; given bug #TBD }; static inline S *& Back( S * n ) { return (S *)Back( (Seqable *)n ); } static inline S *& Next( S * n ) { return (S *)Next( (Colable *)n ); } #elif defined IMPL_CFA_THIERRY_SUB #include "thierry-subqueue-old-rip.hfa" typedef $thread S; #else #error bad impl #endif #define Repeat( op ) for ( volatile unsigned int i = 0; i < NoOfNodes; i += 1 ) { op; } int main() { enum { NoOfNodes = 1000, Times = 100000 }; // Times supposed to be 100000 S s[NoOfNodes]; clock_t start, end; const char * impl = 0; #define STATS #define REPORT do { \ double elapsed = ((double) (end - start)) / CLOCKS_PER_SEC; \ printf("%s %f sec\n", impl, elapsed); \ STATS \ } while(0); #if defined IMPL_STL do { std::list lst; start = clock(); for ( volatile unsigned int t = 0; t < Times; t += 1 ) { Repeat( lst.push_back( &s[i] ) ); Repeat( lst.pop_front() ); } end = clock(); impl = "STL list, pointer"; REPORT } while (0); #elif defined IMPL_UPP do { uSequence lst; start = clock(); for ( volatile unsigned int t = 0; t < Times; t += 1 ) { Repeat( lst.addTail( &s[i] ) ); Repeat( lst.dropHead() ); } end = clock(); impl = "u++ intrusive list"; REPORT } while (0); #elif defined IMPL_CFA_MIKE_OLD do { dlist(S, S) lst; start = clock(); for ( volatile unsigned int t = 0; t < Times; t += 1 ) { Repeat( insert_last( lst, s[i] ) ); Repeat( remove( lst`first ) ); } end = clock(); impl = "cfa mike-old intrusive list"; REPORT } while (0); #elif defined IMPL_CFA_MIKE_POC do { dlist(S) lst; start = clock(); for ( volatile unsigned int t = 0; t < Times; t += 1 ) { Repeat( insert_last( lst, s[i] ) ); Repeat( remove_first( lst ) ); } end = clock(); impl = "cfa mike-poc intrusive list"; REPORT } while (0); #elif defined IMPL_CFA_MIKE_NEW do { dlist(S) lst; start = clock(); for ( volatile unsigned int t = 0; t < Times; t += 1 ) { Repeat( insert_last( lst, s[i] ) ); Repeat( remove( lst`first ) ); } end = clock(); impl = "cfa mike-new intrusive list"; REPORT } while (0); #elif defined IMPL_CFA_COLBY do { Sequence(S) lst; start = clock(); for ( volatile unsigned int t = 0; t < Times; t += 1 ) { Repeat( addHead( lst, s[i] ) ); Repeat( dropTail( lst ) ); } end = clock(); impl = "cfa colby intrusive list"; REPORT } while (0); #elif defined IMPL_CFA_THIERRY_SUB do { __intrusive_lane_t lst; start = clock(); for ( volatile unsigned int t = 0; t < Times; t += 1 ) { Repeat( push( lst, &s[i] ) ); Repeat( pop( lst ) ); } end = clock(); impl = "cfa thierry subqueue intrusive list"; REPORT } while (0); #endif }