Skip to content

Commit 16b5e6e

Browse files
committed
No need to forward in Ptr::at(i)
Forwarding hurt performance a lot in bench-at, but I'm not sure why that is -- if anything it should be the opposite, since start(RA_FW(i)) is a nop when i is a temp.
1 parent c9cad45 commit 16b5e6e

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

ra/expr.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ struct Ptr final
361361
constexpr static bool keep(dim_t st, int z, int j) requires (is_constant<S>) { return st*step(z)==step(j); }
362362
constexpr bool keep(dim_t st, int z, int j) const requires (!is_constant<S>) { return st*step(z)==step(j); }
363363
constexpr void adv(rank_t k, dim_t d) { mov(step(k)*d); }
364-
constexpr decltype(*cp) at(auto && i) const { return *indexer(*this, cp, start(RA_FW(i))); } // iter's not view's
364+
constexpr decltype(*cp) at(auto const & i) const { return *indexer(*this, cp, start(i)); } // iter's not view's
365365
constexpr decltype(*cp) operator*() const { return *cp; }
366366
constexpr auto save() const { return cp; }
367367
constexpr void load(P p) { cp = p; }

test/genfrom.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ RA_CK(inside(i, len(k)), "Bad index iota [", i.n, " ", i.cp.i, " ", i.s, "] in l
1616
1717
TODO
1818
* [ ] optimize() applies to ops with general iota
19-
* [ ] Ptr is a slice (but being Slice and Iterator at the same time is trouble)
19+
* [ ] Ptr is a slice (but being slice and iterator at the same time is trouble).
20+
- [ ] There is conceptual confusion about view vs iterator overall. For example, view.at() and
21+
iter.at() behave differently (and ra::at(a, i) uses a.at). Maybe these should have different
22+
names, because he flexibility in view.at() can be expensive. Also, from(a ...) requires view a,
23+
but iotas are (currently) only iterators.
2024
* [ ] review '1-past is ok but 1-before is not' change in fromb.cc
2125
* [ ] index checks
2226
- [X] for scalar

0 commit comments

Comments
 (0)