Skip to content

Commit cd5dc4b

Browse files
committed
Rename RA_DO_CHECK to RA_CHECK
This follows RA_OPT_... and so on. Internally rename RA_CHECK and RA_FWD to RA_CK and RA_FW respectively.
1 parent 31102a1 commit cd5dc4b

26 files changed

+399
-402
lines changed

.github/workflows/gcc14-no-sanitize.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
matrix:
1515
cxxflags: ['"-O3 -fno-sanitize=all -std=c++23 -DRA_OPT_SMALLVECTOR=0"',
1616
'"-O3 -fno-sanitize=all -std=c++23 -DRA_OPT_SMALLVECTOR=1"',
17-
'"-O3 -fno-sanitize=all -DRA_DO_CHECK=0 -DNDEBUG -std=c++23"']
17+
'"-O3 -fno-sanitize=all -DRA_CHECK=0 -DNDEBUG -std=c++23"']
1818
steps:
1919
- uses: actions/checkout@v4
2020
- name: update

.github/workflows/gcc14.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
matrix:
1515
cxxflags: ['"-O3 -std=c++23 -DRA_OPT_SMALLVECTOR=0"',
1616
'"-O3 -std=c++23 -DRA_OPT_SMALLVECTOR=1"',
17-
'"-O3 -DRA_DO_CHECK=0 -DNDEBUG -std=c++23"']
17+
'"-O3 -DRA_CHECK=0 -DNDEBUG -std=c++23"']
1818
steps:
1919
- uses: actions/checkout@v4
2020
- name: update

TODO

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ Some of these aren't bugs in the sense that I expect to solve them, but more lik
147147
5. [ ]
148148
6. [ ]
149149
7. [ ]
150-
8. [X] test/operators.cc: Some simple expressions with scalars fail in VALUE(). The patch in ra.hh
150+
8. [X] test/operators.cc: Some simple expressions with scalars fail in VAL(). The patch in ra.hh
151151
triggers the address sanitizer in test/ra-9.cc.
152152
9. [ ] test/ra-6.cc: ra::Ptr doesn't hold copies. This enables restarting (see [ra39]), so
153153
ra::ptr(temp) must only be used as temp. Really forbidding auto ll = ra::ptr(lvalue) would also
@@ -170,7 +170,7 @@ Some of these aren't bugs in the sense that I expect to solve them, but more lik
170170
(and ravel constructors also).
171171
17. [ ] assert() is used in some cases for runtime conditions that aren't ra::'s fault. This is
172172
bad because if RA_ASSERT is defined to throw, the caller probably expects to be able to handle
173-
the error. On the other hand if RA_DO_CHECK is 0, we shouldn't continue. But ofc we do in
173+
the error. On the other hand if RA_CHECK is 0, we shouldn't continue. But ofc we do in
174174
index checks etc. So is this different?
175175
18. [ ]
176176
19. [ ]

bench/bench-gemm.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ void
2525
gemm1(auto && a, auto && b, auto & c)
2626
{
2727
for_each(ra::wrank<1, 2, 1>(ra::wrank<0, 1, 1>([](auto && a, auto && b, auto & c) { ra::maybe_fma(a, b, c); })),
28-
RA_FWD(a), RA_FWD(b), RA_FWD(c));
28+
RA_FW(a), RA_FW(b), RA_FW(c));
2929
}
3030
void
3131
gemm2(auto && a, auto && b, auto & c)

bench/bench-stencil1.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ constexpr ra::Small<real, 3> mask = { 1, -2, 1 };
2525
#define THEOP template <class A_, class Anext_, class Astencil_> __attribute__((noinline)) \
2626
auto operator()(A_ & A, Anext_ & Anext, Astencil_ & Astencil)
2727

28-
// sensitive to RA_DO_CHECK.
28+
// sensitive to RA_CHECK.
2929
struct f_raw
3030
{
3131
THEOP
@@ -37,7 +37,7 @@ struct f_raw
3737
};
3838
};
3939

40-
// about as fast as f_raw, but no stencil. Insensitive to RA_DO_CHECK.
40+
// about as fast as f_raw, but no stencil. Insensitive to RA_CHECK.
4141
struct f_slices
4242
{
4343
THEOP
@@ -47,7 +47,7 @@ struct f_slices
4747
};
4848
};
4949

50-
// with stencil, about as fast as f_raw. Sensitive to RA_DO_CHECK.
50+
// with stencil, about as fast as f_raw. Sensitive to RA_CHECK.
5151
struct f_stencil_explicit
5252
{
5353
THEOP

bench/bench-stencil2.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ constexpr ra::Small<real, 3, 3> mask = { 0, 1, 0,
2929
#define THEOP template <class A_, class Anext_, class Astencil_> __attribute__((noinline)) \
3030
auto operator()(A_ & A, Anext_ & Anext, Astencil_ & Astencil)
3131

32-
// sensitive to RA_DO_CHECK.
32+
// sensitive to RA_CHECK.
3333
struct f_raw
3434
{
3535
THEOP
@@ -45,7 +45,7 @@ struct f_raw
4545
};
4646
};
4747

48-
// about as fast as f_raw, but no stencil. Insensitive to RA_DO_CHECK.
48+
// about as fast as f_raw, but no stencil. Insensitive to RA_CHECK.
4949
struct f_slices
5050
{
5151
THEOP
@@ -57,7 +57,7 @@ struct f_slices
5757
};
5858
};
5959

60-
// with stencil, about as fast as f_raw. Sensitive to RA_DO_CHECK.
60+
// with stencil, about as fast as f_raw. Sensitive to RA_CHECK.
6161
struct f_stencil_explicit
6262
{
6363
THEOP

bench/bench-stencil3.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ constexpr ra::Small<real, 3, 3, 3> mask = { 0, 0, 0, 0, 1, 0, 0, 0, 0,
3333
#define THEOP template <class A_, class Anext_, class Astencil_> __attribute__((noinline)) \
3434
auto operator()(A_ & A, Anext_ & Anext, Astencil_ & Astencil)
3535

36-
// sensitive to RA_DO_CHECK.
36+
// sensitive to RA_CHECK.
3737
struct f_raw
3838
{
3939
THEOP
@@ -51,7 +51,7 @@ struct f_raw
5151
};
5252
};
5353

54-
// about as fast as f_raw, but no stencil. Insensitive to RA_DO_CHECK.
54+
// about as fast as f_raw, but no stencil. Insensitive to RA_CHECK.
5555
struct f_slices
5656
{
5757
THEOP
@@ -63,7 +63,7 @@ struct f_slices
6363
};
6464
};
6565

66-
// with stencil, about as fast as f_raw. Sensitive to RA_DO_CHECK.
66+
// with stencil, about as fast as f_raw. Sensitive to RA_CHECK.
6767
struct f_stencil_explicit
6868
{
6969
THEOP

box/genfrom.cc

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@
88
// later version.
99

1010
// Atm view(i ...) only beats i of rank ≤1 and only when all i are beatable. This is a sandbox for a version that beats any combination of scalar or view<Seq> of any rank, and only returns an expr for the unbeatable subscripts.
11-
// There is an additional issue that eg A2(i1) (indicating ranks) returns a nested expression, that is, a rank-1 expr where each element is a rank-1 view. We'd prefer if the result was rank 2 and not nested, iow, the value type of the result should always be the same as that of A.
11+
// There is an additional issue that eg A2(unbeatable-i1) (indicating ranks) returns a nested expression, that is, a rank-1 expr where each element is a rank-1 view. It should instead be rank 2 and not nested, iow, the value type of the result should always be the same as that of A.
12+
// 1) Need to split the static and the dynamic parts so some/most of the routine can be used for Small or Big
13+
// 2) Need to find a way to use len like in Ptr-based iota.
1214

1315
#include "ra/test.hh"
14-
#include <iomanip>
15-
#include <chrono>
16-
#include <span>
1716

1817
using std::cout, std::endl, std::flush;
1918

@@ -25,6 +24,25 @@ constexpr auto ii(dim_t (&&s)[rank])
2524
return ViewBig<Seq<dim_t>, rank>(s, Seq<dim_t>{0});
2625
}
2726

27+
template <std::integral auto ... i>
28+
constexpr auto ii(ra::ilist_t<i ...>)
29+
{
30+
return ViewSmall<Seq<dim_t>, ra::ic_t<ra::default_dims(std::array<ra::dim_t, sizeof...(i)>{i...})>>(Seq<dim_t>{0});
31+
}
32+
33+
template <class A> concept is_iota_static = requires (A a)
34+
{
35+
[]<class I, class Dimv>(ViewSmall<Seq<I>, Dimv> const &){}(a);
36+
requires UNB!=ra::size(a); // exclude UNB from beating to let B=A(... i ...) use B's len. FIXME
37+
};
38+
39+
template <class A> concept is_iota_dynamic = requires (A a)
40+
{
41+
[]<class I, rank_t RANK>(ViewBig<Seq<I>, RANK> const &){}(a);
42+
};
43+
44+
template <class A> concept is_iota_any = is_iota_dynamic<A> || is_iota_static<A>;
45+
2846
template <class A, class ... I>
2947
constexpr auto
3048
genfrom(A && a, I && ... i)
@@ -39,6 +57,6 @@ int main()
3957
{
4058
ra::TestRecorder tr(std::cout);
4159
cout << ra::ii({3, 4}) << endl;
60+
cout << ra::ii(ra::ilist<3, 4>) << endl;
4261
return tr.summary();
4362
}
44-
x

docs/index.html

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/ra-ra.texi

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ The following @code{#define}s affect the behavior of @code{ra::}.
314314

315315
@itemize
316316
@c FIXME The flag should only apply to dynamic checks.
317-
@item @code{RA_DO_CHECK} (default 1)
317+
@item @code{RA_CHECK} (default 1)
318318

319319
If 1, check shape agreement (e.g. @code{Big<int, 1> @{2, 3@} + Big<int, 1> @{1, 2, 3@}}) and random array accesses (e.g. @code{Small<int, 2> a = 0; int i = 10; a[i] = 0;}). See @ref{Error handling}.
320320

@@ -1761,26 +1761,26 @@ Runtime error handling in @code{ra::} is controlled by two macros.
17611761
@itemize
17621762
@item @code{RA_ASSERT(cond, ...)} ---
17631763
check that @code{cond} evaluates to true in the @code{ra::} namespace. The other arguments are informative.
1764-
@item @code{RA_DO_CHECK} ---
1764+
@item @code{RA_CHECK} ---
17651765
must have one of the values 0, 1, or 2.
17661766
@end itemize
17671767

17681768
They work as follows:
17691769

17701770
@itemize
1771-
@item If @code{RA_DO_CHECK} is 0, runtime checks are skipped.
1772-
@item If @code{RA_DO_CHECK} is not 0, runtime checks are done.
1771+
@item If @code{RA_CHECK} is 0, runtime checks are skipped.
1772+
@item If @code{RA_CHECK} is not 0, runtime checks are done.
17731773
@itemize
17741774
@item If @code{RA_ASSERT} is defined, using @code{RA_ASSERT}.
1775-
@item If @code{RA_ASSERT} isn't defined, the method depends on the value of @code{RA_DO_CHECK}. The two options are 1 (plain @code{assert}) and 2 (prints the informative arguments and aborts). Other values are an error.
1775+
@item If @code{RA_ASSERT} isn't defined, the method depends on the value of @code{RA_CHECK}. The two options are 1 (plain @code{assert}) and 2 (prints the informative arguments and aborts). Other values are an error.
17761776
@end itemize
17771777
@end itemize
17781778

1779-
@code{ra::} contains uses of @code{assert} for checking invariants or for sanity checks that are separate from uses of @code{RA_ASSERT}. Those can be disabled in the usual way with @option{-DNDEBUG}, but note that @option{-DNDEBUG} will also disable any @code{assert}s that are a result of @code{RA_DO_CHECK=1}.
1779+
@code{ra::} contains uses of @code{assert} for checking invariants or for sanity checks that are separate from uses of @code{RA_ASSERT}. Those can be disabled in the usual way with @option{-DNDEBUG}, but note that @option{-DNDEBUG} will also disable any @code{assert}s that are a result of @code{RA_CHECK=1}.
17801780

1781-
The performance cost of the runtime checks depends on the program. Without custom @code{RA_ASSERT}, @code{RA_DO_CHECK=1} usually has an acceptable cost, but @code{RA_DO_CHECK=2} is usually more expensive, because having the arguments around to print can prevent optimization. The default is @code{RA_DO_CHECK=1}.
1781+
The performance cost of the runtime checks depends on the program. Without custom @code{RA_ASSERT}, @code{RA_CHECK=1} usually has an acceptable cost, but @code{RA_CHECK=2} is usually more expensive, because having the arguments around to print can prevent optimization. The default is @code{RA_CHECK=1}.
17821782

1783-
The following example shows how errors might be reported depending on @code{RA_DO_CHECK}.
1783+
The following example shows how errors might be reported depending on @code{RA_CHECK}.
17841784

17851785
@cartouche
17861786
@verbatim
@@ -1792,11 +1792,11 @@ cout << (a+b) << endl;
17921792

17931793
@c FIXME we'd get 'Bad shapes (-1922222222 3)' on sum(a+b) bc of the check only at top strategy. Improve that.
17941794
@itemize
1795-
@item @code{RA_DO_CHECK=2}
1795+
@item @code{RA_CHECK=2}
17961796
@verbatim
17971797
*** ra::./ra/expr.hh:436,13 (check()) Bad shapes (10 3)(40 3). ***
17981798
@end verbatim
1799-
@item @code{RA_DO_CHECK=1}
1799+
@item @code{RA_CHECK=1}
18001800
@verbatim
18011801
agreement: ./ra/expr.hh:436: constexpr void ra::Match<std::tuple<_Ts ...>, std::tuple<std::integral_constant<int, I>...> >::validate() const [with P = {ra::Cell<int, const ra::
18021802
SmallArray<ra::Dim, std::tuple<std::integral_constant<int, 2> >, std::tuple<std::integral_constant<int, 1> >, std::tuple<ra::Dim, ra::Dim> >&, std::integral_constant<int, 0> >,
@@ -1924,7 +1924,7 @@ Item 1
19241924
Item 2
19251925
@end enumerate
19261926

1927-
@section The cost of @code{RA_DO_CHECK}
1927+
@section The cost of @code{RA_CHECK}
19281928

19291929
FIXME
19301930

0 commit comments

Comments
 (0)