Skip to content

Commit e8d005c

Browse files
committed
Merge ra::iter<> and ra::start into iter/iter<>
These do the same as x.iter(), no reason for different names. * ra/expr.hh (start<>): As stated. Elsewhere fix uses.
1 parent 60503e6 commit e8d005c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+503
-507
lines changed

TODO

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ Some of these aren't bugs in the sense that I expect to solve them, but more lik
169169
36. [ ]
170170
37. [ ]
171171
38. [ ] test/ra-9.cc: There's no reason to restart, since the Iterator methods are all static. So
172-
start(ra::Scalar) just fwds. But that means that Scalar::c maintain constness, so a const
172+
iter(ra::Scalar) just fwds. But that means that Scalar::c maintain constness, so a const
173173
overload is required for ScalarFlat::operator*.
174174
39. [ ]
175175
40. [ ]

bench/bench-at.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ int main(int argc, char * * argv)
3838
I(ra::all, 0) = map([&](auto && i) { return i%M; }, ra::_0 + (std::rand() & 1));
3939
I(ra::all, 1) = map([&](auto && i) { return i%N; }, ra::_0 + (std::rand() & 1));
4040

41-
int ref0 = sum(at(C, iter<1>(I))), val0 = 0;
41+
int ref0 = sum(at(C, ra::iter<1>(I))), val0 = 0;
4242
Benchmark bm { reps, 3 };
4343
auto report = [&](std::string const & stag, auto && bv)
4444
{
@@ -64,7 +64,7 @@ int main(int argc, char * * argv)
6464
}));
6565
report("at op + iter",
6666
bm.run([&]{
67-
val0 = sum(at(C, iter<1>(I)));
67+
val0 = sum(at(C, ra::iter<1>(I)));
6868
}));
6969
};
7070

@@ -95,7 +95,7 @@ int main(int argc, char * * argv)
9595
[[maybe_unused]] int const O = I.len(0);
9696
I(ra::all, 0) = map([&](auto && i) { return i%M; }, ra::_0 + (std::rand() & 1));
9797

98-
int ref0 = sum(at(C, iter<1>(I))), val0 = 0;
98+
int ref0 = sum(at(C, ra::iter<1>(I))), val0 = 0;
9999
Benchmark bm { reps, 3 };
100100
auto report = [&](std::string const & stag, auto && bv)
101101
{
@@ -112,7 +112,7 @@ int main(int argc, char * * argv)
112112
}));
113113
report("at op + iter",
114114
bm.run([&]{
115-
val0 = sum(at(C, iter<1>(I)));
115+
val0 = sum(at(C, ra::iter<1>(I)));
116116
}));
117117
};
118118

bench/bench-stencil1.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ struct f_stencil_explicit
5454
{
5555
Astencil.cp = A.data();
5656
Anext(I) = map([](auto && A) { return -2*A(1) + A(2) + A(0); },
57-
iter<1>(Astencil));
57+
ra::iter<1>(Astencil));
5858
std::swap(A.cp, Anext.cp);
5959
};
6060
};
@@ -65,7 +65,7 @@ struct f_stencil_arrayop
6565
THEOP
6666
{
6767
Astencil.cp = A.data();
68-
Anext(I) = map([](auto && s) { return sum(s*mask); }, iter<1>(Astencil));
68+
Anext(I) = map([](auto && s) { return sum(s*mask); }, ra::iter<1>(Astencil));
6969
std::swap(A.cp, Anext.cp);
7070
};
7171
};

bench/bench-stencil2.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ struct f_stencil_explicit
6666
Anext(I, J) = map([](auto && A) { return -4*A(1, 1)
6767
+ A(2, 1) + A(1, 2)
6868
+ A(0, 1) + A(1, 0); },
69-
iter<2>(Astencil));
69+
ra::iter<2>(Astencil));
7070
std::swap(A.cp, Anext.cp);
7171
};
7272
};
@@ -77,7 +77,7 @@ struct f_stencil_arrayop
7777
THEOP
7878
{
7979
Astencil.cp = A.data();
80-
Anext(I, J) = map([](auto && s) { return sum(s*mask); }, iter<2>(Astencil));
80+
Anext(I, J) = map([](auto && s) { return sum(s*mask); }, ra::iter<2>(Astencil));
8181
std::swap(A.cp, Anext.cp);
8282
};
8383
};

bench/bench-stencil3.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ struct f_stencil_explicit
7272
Anext(I, J, K) = map([](auto && A) { return -6*A(1, 1, 1)
7373
+ A(2, 1, 1) + A(1, 2, 1) + A(1, 1, 2)
7474
+ A(0, 1, 1) + A(1, 0, 1) + A(1, 1, 0); },
75-
iter<3>(Astencil));
75+
ra::iter<3>(Astencil));
7676
std::swap(A.cp, Anext.cp);
7777
};
7878
};
@@ -83,7 +83,7 @@ struct f_stencil_arrayop
8383
THEOP
8484
{
8585
Astencil.cp = A.data();
86-
Anext(I, J, K) = map([](auto && s) { return sum(s*mask); }, iter<3>(Astencil));
86+
Anext(I, J, K) = map([](auto && s) { return sum(s*mask); }, ra::iter<3>(Astencil));
8787
std::swap(A.cp, Anext.cp);
8888
};
8989
};

bench/bench-sum-cols.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ int main()
6060
bench("accumcols", m, n, reps,
6161
[](auto & c, auto const & a)
6262
{
63-
for_each([](auto & c, auto && a) { c += sum(a); }, c, iter<1>(a));
63+
for_each([](auto & c, auto && a) { c += sum(a); }, c, ra::iter<1>(a));
6464
});
6565
bench("wrank1", m, n, reps,
6666
[](auto & c, auto const & a)

bench/bench-sum-rows.cc

Lines changed: 62 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -19,75 +19,71 @@ int main()
1919
TestRecorder tr(cout);
2020
cout.precision(4);
2121

22-
auto bench =
23-
[&tr](char const * tag, int m, int n, int reps, auto && f)
24-
{
25-
ra::Big<real, 2> a({m, n}, ra::_0 - ra::_1);
26-
ra::Big<real, 1> ref({n}, 0);
27-
iter<1>(ref) += iter<1>(a)*reps;
28-
ra::Big<real, 1> c({n}, ra::none);
22+
auto bench = [&tr](char const * tag, int m, int n, int reps, auto && f){
23+
ra::Big<real, 2> a({m, n}, ra::_0 - ra::_1);
24+
ra::Big<real, 1> ref({n}, 0);
25+
ra::iter<1>(ref) += ra::iter<1>(a)*reps;
26+
ra::Big<real, 1> c({n}, ra::none);
2927

30-
auto bv = Benchmark().repeats(reps).runs(3)
31-
.once_f([&](auto && repeat) { c=0.; repeat([&]() { f(c, a); }); });
32-
tr.info(Benchmark::report(bv, m*n), " ", tag)
33-
.test_eq(ref, c);
34-
};
28+
auto bv = Benchmark().repeats(reps).runs(3)
29+
.once_f([&](auto && repeat) { c=0.; repeat([&]() { f(c, a); }); });
30+
tr.info(Benchmark::report(bv, m*n), " ", tag)
31+
.test_eq(ref, c);
32+
};
3533

36-
auto bench_all =
37-
[&](int m, int n, int reps)
38-
{
39-
tr.section(m, " x ", n, " times ", reps);
40-
bench("raw", m, n, reps,
41-
[](auto & c, auto const & a)
42-
{
43-
real const * __restrict__ ap = a.data();
44-
real * __restrict__ cp = c.data();
45-
ra::dim_t const m = a.len(0);
46-
ra::dim_t const n = a.len(1);
47-
for (ra::dim_t i=0; i!=m; ++i) {
48-
for (ra::dim_t j=0; j!=n; ++j) {
49-
cp[j] += ap[i*n+j];
50-
}
34+
auto bench_all = [&](int m, int n, int reps){
35+
tr.section(m, " x ", n, " times ", reps);
36+
bench("raw", m, n, reps,
37+
[](auto & c, auto const & a)
38+
{
39+
real const * __restrict__ ap = a.data();
40+
real * __restrict__ cp = c.data();
41+
ra::dim_t const m = a.len(0);
42+
ra::dim_t const n = a.len(1);
43+
for (ra::dim_t i=0; i!=m; ++i) {
44+
for (ra::dim_t j=0; j!=n; ++j) {
45+
cp[j] += ap[i*n+j];
5146
}
52-
});
53-
bench("sideways", m, n, reps,
54-
[](auto & c, auto const & a)
55-
{
56-
for (int j=0, jend=a.len(1); j<jend; ++j) {
57-
c(j) += sum(a(ra::all, j));
58-
}
59-
});
60-
bench("accumrows", m, n, reps,
61-
[](auto & c, auto const & a)
62-
{
63-
for_each([&c](auto && a) { c += a; }, iter<1>(a));
64-
});
65-
bench("wrank1", m, n, reps,
66-
[](auto & c, auto const & a)
67-
{
68-
for_each(ra::wrank<1, 1>([](auto & c, auto && a) { c += a; }), c, a);
69-
});
70-
bench("wrank2", m, n, reps,
71-
[](auto & c, auto const & a)
72-
{
73-
for_each(ra::wrank<1, 1>(ra::wrank<0, 0>([](auto & c, auto a) { c += a; })), c, a);
74-
});
75-
bench("accumscalar", m, n, reps,
76-
[](auto & c, auto const & a)
77-
{
78-
ra::scalar(c) += iter<1>(a);
79-
});
80-
bench("accumiter", m, n, reps,
81-
[](auto & c, auto const & a)
82-
{
83-
iter<1>(c) += iter<1>(a);
84-
});
85-
bench("frametransp", m, n, reps,
86-
[](auto & c, auto const & a)
87-
{
88-
c += transpose(a);
89-
});
90-
};
47+
}
48+
});
49+
bench("sideways", m, n, reps,
50+
[](auto & c, auto const & a)
51+
{
52+
for (int j=0, jend=a.len(1); j<jend; ++j) {
53+
c(j) += sum(a(ra::all, j));
54+
}
55+
});
56+
bench("accumrows", m, n, reps,
57+
[](auto & c, auto const & a)
58+
{
59+
for_each([&c](auto && a) { c += a; }, ra::iter<1>(a));
60+
});
61+
bench("wrank1", m, n, reps,
62+
[](auto & c, auto const & a)
63+
{
64+
for_each(ra::wrank<1, 1>([](auto & c, auto && a) { c += a; }), c, a);
65+
});
66+
bench("wrank2", m, n, reps,
67+
[](auto & c, auto const & a)
68+
{
69+
for_each(ra::wrank<1, 1>(ra::wrank<0, 0>([](auto & c, auto a) { c += a; })), c, a);
70+
});
71+
bench("accumscalar", m, n, reps,
72+
[](auto & c, auto const & a)
73+
{
74+
ra::scalar(c) += ra::iter<1>(a);
75+
});
76+
bench("accumiter", m, n, reps,
77+
[](auto & c, auto const & a)
78+
{
79+
ra::iter<1>(c) += ra::iter<1>(a);
80+
});
81+
bench("frametransp", m, n, reps,
82+
[](auto & c, auto const & a)
83+
{
84+
c += transpose(a);
85+
});
86+
};
9187

9288
bench_all(1, 1000000, 20);
9389
bench_all(10, 100000, 20);

config/config.guess

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,7 +1068,7 @@ EOF
10681068
exit ;;
10691069
i*86:UNIX_SV:4.2MP:2.*)
10701070
# Unixware is an offshoot of SVR4, but it has its own version
1071-
# number series starting with 2...
1071+
# number series itering with 2...
10721072
# I am not positive that other SVR4 systems won't match this,
10731073
# I just have to hope. -- rms.
10741074
# Use sysv4.2uw... so that sysv4* matches it.
@@ -1480,7 +1480,7 @@ exit 1
14801480

14811481
# Local variables:
14821482
# eval: (add-hook 'before-save-hook 'time-stamp)
1483-
# time-stamp-start: "timestamp='"
1483+
# time-stamp-iter: "timestamp='"
14841484
# time-stamp-format: "%:y-%02m-%02d"
14851485
# time-stamp-end: "'"
14861486
# End:

0 commit comments

Comments
 (0)