1212#include < string>
1313#include < cstdlib>
1414#include " ra/test.hh"
15+ #include " test/mpdebug.hh"
1516
1617using std::cout, std::endl, std::flush, ra::TestRecorder, ra::Benchmark;
1718using real = double ;
1819using ra::dim_t ;
1920
21+ ra::TestRecorder tr (cout);
22+
2023// FIXME bigd/bigd & bigs/bigd at loop
2124
2225int main (int argc, char * * argv)
2326{
2427 int reps = argc>1 ? std::stoi (argv[1 ]) : 10000 ;
2528 std::println (cout, " reps = {}" , reps);
26- ra::TestRecorder tr (cout);
2729 tr.section (" rank 2" );
2830 {
29- auto test2 = [&tr ](auto && C, auto && I, int reps, std::string tag)
31+ auto test2 = [](auto && C, auto && I, int reps, std::string tag)
3032 {
3133 if (" warmup" !=tag) tr.section (tag);
3234 int M = C.len (0 );
@@ -86,11 +88,11 @@ int main(int argc, char * * argv)
8688 }
8789 tr.section (" rank 1" );
8890 {
89- auto test1 = [&tr ](auto && C, auto && I, int reps, std::string tag)
91+ auto test1 = [](auto && C, auto && I, int reps, std::string tag)
9092 {
9193 if (" warmup" !=tag) tr.section (tag);
92- int M = C.len (0 );
93- int O = I.len (0 );
94+ int const M = C.len (0 );
95+ [[maybe_unused]] int const O = I.len (0 );
9496 I (ra::all, 0 ) = map ([&](auto && i) { return i%M; }, ra::_0 + (std::rand () & 1 ));
9597
9698 int ref0 = sum (at (C, iter<1 >(I))), val0 = 0 ;
@@ -114,14 +116,14 @@ int main(int argc, char * * argv)
114116 }));
115117 };
116118
117- // especially Ptr, if it differs from ViewSmall/ViewBig
118- auto iotaa = ra::iota (100 , 1 , 4 );
119- ra::Big<int , 1 > bigsa ({100 }, 4 *ra::_0);
120- ra::Big<int > bigda ({100 }, 4 *ra::_0);
121- ra::Small<int , 100 > smola = 4 *ra::_0;
122- ra::Big<int , 2 > bigsi ({100 , 1 }, ra::none);
123- ra::Big<int > bigdi ({100 , 1 }, ra::none);
124- ra::Small<int , 100 , 1 > smoli;
119+ auto iotav = ra::ii ({ 100 }); // view.at(i) rank depends on i's size. That can be var rank which is a lot slower.
120+ auto iotai = ra::iota (100 ); // iter.at(i) requires i's size to be iter's rank.
121+ [[maybe_unused]] ra::Big<int , 1 > bigsa ({100 }, 4 *ra::_0);
122+ [[maybe_unused]] ra::Big<int > bigda ({100 }, 4 *ra::_0);
123+ [[maybe_unused]] ra::Small<int , 100 > smola = 4 *ra::_0;
124+ [[maybe_unused]] ra::Big<int , 2 > bigsi ({100 , 1 }, ra::none);
125+ [[maybe_unused]] ra::Big<int > bigdi ({100 , 1 }, ra::none);
126+ [[maybe_unused]] ra::Small<int , 100 , 1 > smoli;
125127 test1 (smola, smoli, reps, " warmup" );
126128 test1 (smola, smoli, reps, " small/small" );
127129 test1 (bigsa, smoli, reps, " bigs/small" );
@@ -132,9 +134,12 @@ int main(int argc, char * * argv)
132134 test1 (smola, bigdi, reps, " small/bigd" );
133135 test1 (bigsa, bigdi, reps, " bigs/bigd" );
134136 test1 (bigda, bigdi, reps, " bigd/bigd" );
135- test1 (iotaa, smoli, reps, " iota/small" );
136- test1 (iotaa, bigsi, reps, " iota/bigs" );
137- test1 (iotaa, bigdi, reps, " iota/bigd" );
137+ test1 (iotav, smoli, reps, " iotv/small" );
138+ test1 (iotav, bigsi, reps, " iotv/bigs" );
139+ test1 (iotav, bigdi, reps, " iotv/bigd" );
140+ test1 (iotai, smoli, reps, " ioti/small" );
141+ test1 (iotai, bigsi, reps, " ioti/bigs" );
142+ test1 (iotai, bigdi, reps, " ioti/bigd" );
138143 }
139144 return tr.summary ();
140145}
0 commit comments