Skip to content

Commit 826afe2

Browse files
committed
update for arm
1 parent 98fa97f commit 826afe2

24 files changed

+202
-182
lines changed

source/mir/algorithm/iteration.d

Lines changed: 44 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ module mir.algorithm.iteration;
5454

5555
import mir.functional: naryFun;
5656
import mir.internal.utility;
57-
import mir.math.common: optmath;
57+
import mir.math.common: fmamath;
5858
import mir.ndslice.field: BitField;
5959
import mir.ndslice.internal;
6060
import mir.ndslice.iterator: FieldIterator, RetroIterator;
@@ -101,7 +101,7 @@ version(mir_test) unittest
101101

102102
}
103103

104-
@optmath:
104+
@fmamath:
105105

106106
/+
107107
Bitslice representation for accelerated bitwise algorithm.
@@ -130,7 +130,7 @@ private struct BitSliceAccelerator(Field, I = typeof(Field.init[size_t.init]))
130130
/// tail length
131131
int tailLength;
132132

133-
@optmath:
133+
@fmamath:
134134

135135
this(Slice!(FieldIterator!(BitField!(Field, I))) slice)
136136
{
@@ -458,6 +458,7 @@ scope const:
458458

459459
sizediff_t nBitsToCount(size_t count)
460460
{
461+
pragma(inline, false);
461462
size_t ret;
462463
if (count == 0)
463464
return count;
@@ -557,6 +558,22 @@ sizediff_t nBitsToCount(Field, I)(Slice!(RetroIterator!(FieldIterator!(BitField!
557558
return BitSliceAccelerator!(Field, I)(bitSlice.retro).retroNBitsToCount(count);
558559
}
559560

561+
/++
562+
Сount bits starting from the end until set bit count is reached. Works with ndslices created with $(REF bitwise, mir,ndslice,topology), $(REF bitSlice, mir,ndslice,allocation).
563+
Returns: bit count if set bit count is reached or `-1` otherwise.
564+
+/
565+
sizediff_t retroNBitsToCount(Field, I)(Slice!(FieldIterator!(BitField!(Field, I))) bitSlice, size_t count)
566+
{
567+
return BitSliceAccelerator!(Field, I)(bitSlice).retroNBitsToCount(count);
568+
}
569+
570+
///ditto
571+
sizediff_t retroNBitsToCount(Field, I)(Slice!(RetroIterator!(FieldIterator!(BitField!(Field, I)))) bitSlice, size_t count)
572+
{
573+
import mir.ndslice.topology: retro;
574+
return BitSliceAccelerator!(Field, I)(bitSlice.retro).nBitsToCount(count);
575+
}
576+
560577
///
561578
version(mir_test)
562579
pure unittest
@@ -604,7 +621,7 @@ package(mir) template allFlattened(args...)
604621
static if (args.length)
605622
{
606623
alias arg = args[0];
607-
@optmath @property allFlattenedMod()()
624+
@fmamath @property allFlattenedMod()()
608625
{
609626
import mir.ndslice.topology: flattened;
610627
return flattened(arg);
@@ -661,11 +678,11 @@ version(Mir_disable_inlining_in_reduce)
661678

662679
private template nonInlinedNaryFun(alias fun)
663680
{
664-
import mir.math.common : optmath;
681+
import mir.math.common : fmamath;
665682
static if (is(typeof(fun) : string))
666683
{
667684
/// Specialization for string lambdas
668-
@optmath auto ref nonInlinedNaryFun(Args...)(auto ref Args args)
685+
@fmamath auto ref nonInlinedNaryFun(Args...)(auto ref Args args)
669686
if (args.length <= 26)
670687
{
671688
pragma(inline,false);
@@ -675,7 +692,7 @@ version(Mir_disable_inlining_in_reduce)
675692
}
676693
else static if (is(typeof(fun.opCall) == function))
677694
{
678-
@optmath auto ref nonInlinedNaryFun(Args...)(auto ref Args args)
695+
@fmamath auto ref nonInlinedNaryFun(Args...)(auto ref Args args)
679696
if (is(typeof(fun.opCall(args))))
680697
{
681698
pragma(inline,false);
@@ -684,7 +701,7 @@ version(Mir_disable_inlining_in_reduce)
684701
}
685702
else
686703
{
687-
@optmath auto ref nonInlinedNaryFun(Args...)(auto ref Args args)
704+
@fmamath auto ref nonInlinedNaryFun(Args...)(auto ref Args args)
688705
if (is(typeof(fun(args))))
689706
{
690707
pragma(inline,false);
@@ -745,7 +762,7 @@ template reduce(alias fun)
745762
Returns:
746763
the accumulated `result`
747764
+/
748-
@optmath auto reduce(S, Slices...)(S seed, Slices slices)
765+
@fmamath auto reduce(S, Slices...)(S seed, Slices slices)
749766
if (Slices.length)
750767
{
751768
static if (Slices.length > 1)
@@ -768,7 +785,7 @@ template reduce(alias fun)
768785
}
769786
else version(Mir_disable_inlining_in_reduce)
770787
//As above, but with inlining disabled.
771-
@optmath auto reduce(S, Slices...)(S seed, Slices slices)
788+
@fmamath auto reduce(S, Slices...)(S seed, Slices slices)
772789
if (Slices.length)
773790
{
774791
static if (Slices.length > 1)
@@ -849,9 +866,9 @@ version(mir_test) unittest
849866
import std.numeric : dotProduct;
850867
import mir.ndslice.allocation : slice;
851868
import mir.ndslice.topology : as, iota, zip, universal;
852-
import mir.math.common : optmath;
869+
import mir.math.common : fmamath;
853870

854-
static @optmath T fmuladd(T, Z)(const T a, Z z)
871+
static @fmamath T fmuladd(T, Z)(const T a, Z z)
855872
{
856873
return a + z.a * z.b;
857874
}
@@ -879,9 +896,9 @@ unittest
879896
{
880897
import mir.ndslice.allocation : slice;
881898
import mir.ndslice.topology : as, iota;
882-
import mir.math.common : optmath;
899+
import mir.math.common : fmamath;
883900

884-
static @optmath T fun(T)(const T a, ref T b)
901+
static @fmamath T fun(T)(const T a, ref T b)
885902
{
886903
return a + b++;
887904
}
@@ -1018,7 +1035,7 @@ template eachOnBorder(alias fun)
10181035
Params:
10191036
slices = One or more slices.
10201037
+/
1021-
@optmath void eachOnBorder(Slices...)(Slices slices)
1038+
@fmamath void eachOnBorder(Slices...)(Slices slices)
10221039
if (allSatisfy!(isSlice, Slices))
10231040
{
10241041
import mir.ndslice.traits: isContiguousSlice;
@@ -1117,7 +1134,7 @@ template each(alias fun)
11171134
Params:
11181135
slices = One or more slices, ranges, and arrays.
11191136
+/
1120-
@optmath auto each(Slices...)(Slices slices)
1137+
@fmamath auto each(Slices...)(Slices slices)
11211138
if (Slices.length && !is(Slices[0] : Chequer))
11221139
{
11231140
static if (Slices.length > 1)
@@ -1141,7 +1158,7 @@ template each(alias fun)
11411158
color = $(LREF Chequer).
11421159
slices = One or more slices.
11431160
+/
1144-
@optmath auto each(Slices...)(Chequer color, Slices slices)
1161+
@fmamath auto each(Slices...)(Chequer color, Slices slices)
11451162
if (Slices.length && allSatisfy!(isSlice, Slices))
11461163
{
11471164
static if (Slices.length > 1)
@@ -1546,7 +1563,7 @@ template minmaxPos(alias pred = "a < b")
15461563
Returns:
15471564
2 subslices with minimal and maximal `first` elements.
15481565
+/
1549-
@optmath Slice!(Iterator, N, kind == Contiguous && N > 1 ? Canonical : kind)[2]
1566+
@fmamath Slice!(Iterator, N, kind == Contiguous && N > 1 ? Canonical : kind)[2]
15501567
minmaxPos(Iterator, size_t N, SliceKind kind)(Slice!(Iterator, N, kind) slice)
15511568
{
15521569
typeof(return) pret;
@@ -1622,7 +1639,7 @@ template minmaxIndex(alias pred = "a < b")
16221639
Returns:
16231640
Subslice with minimal (maximal) `first` element.
16241641
+/
1625-
@optmath size_t[N][2] minmaxIndex(Iterator, size_t N, SliceKind kind)(Slice!(Iterator, N, kind) slice)
1642+
@fmamath size_t[N][2] minmaxIndex(Iterator, size_t N, SliceKind kind)(Slice!(Iterator, N, kind) slice)
16261643
{
16271644
typeof(return) pret = size_t.max;
16281645
if (!slice.anyEmpty)
@@ -1691,7 +1708,7 @@ template minPos(alias pred = "a < b")
16911708
Multidimensional backward index such that element is minimal(maximal).
16921709
Backward index equals zeros, if slice is empty.
16931710
+/
1694-
@optmath Slice!(Iterator, N, kind == Contiguous && N > 1 ? Canonical : kind)
1711+
@fmamath Slice!(Iterator, N, kind == Contiguous && N > 1 ? Canonical : kind)
16951712
minPos(Iterator, size_t N, SliceKind kind)(Slice!(Iterator, N, kind) slice)
16961713
{
16971714
typeof(return) ret;
@@ -1766,7 +1783,7 @@ template minIndex(alias pred = "a < b")
17661783
Multidimensional index such that element is minimal(maximal).
17671784
Index elements equal to `size_t.max`, if slice is empty.
17681785
+/
1769-
@optmath size_t[N] minIndex(Iterator, size_t N, SliceKind kind)(Slice!(Iterator, N, kind) slice)
1786+
@fmamath size_t[N] minIndex(Iterator, size_t N, SliceKind kind)(Slice!(Iterator, N, kind) slice)
17701787
{
17711788
size_t[N] ret = size_t.max;
17721789
if (!slice.anyEmpty)
@@ -1922,7 +1939,7 @@ template findIndex(alias pred)
19221939
Constraints:
19231940
All slices must have the same shape.
19241941
+/
1925-
@optmath Select!(DimensionCount!(Slices[0]) > 1, size_t[DimensionCount!(Slices[0])], size_t) findIndex(Slices...)(Slices slices)
1942+
@fmamath Select!(DimensionCount!(Slices[0]) > 1, size_t[DimensionCount!(Slices[0])], size_t) findIndex(Slices...)(Slices slices)
19261943
if (Slices.length)
19271944
{
19281945
static if (Slices.length > 1)
@@ -2018,7 +2035,7 @@ template find(alias pred)
20182035
Constraints:
20192036
All slices must have the same shape.
20202037
+/
2021-
@optmath Select!(DimensionCount!(Slices[0]) > 1, size_t[DimensionCount!(Slices[0])], size_t) find(Slices...)(Slices slices)
2038+
@fmamath Select!(DimensionCount!(Slices[0]) > 1, size_t[DimensionCount!(Slices[0])], size_t) find(Slices...)(Slices slices)
20222039
if (Slices.length && allSatisfy!(hasShape, Slices))
20232040
{
20242041
static if (Slices.length > 1)
@@ -2197,7 +2214,7 @@ template any(alias pred = "a")
21972214
Constraints:
21982215
All slices must have the same shape.
21992216
+/
2200-
@optmath bool any(Slices...)(Slices slices)
2217+
@fmamath bool any(Slices...)(Slices slices)
22012218
if ((Slices.length == 1 || !__traits(isSame, pred, "a")) && Slices.length)
22022219
{
22032220
static if (Slices.length > 1)
@@ -2357,7 +2374,7 @@ template all(alias pred = "a")
23572374
Constraints:
23582375
All slices must have the same shape.
23592376
+/
2360-
@optmath bool all(Slices...)(Slices slices)
2377+
@fmamath bool all(Slices...)(Slices slices)
23612378
if ((Slices.length == 1 || !__traits(isSame, pred, "a")) && Slices.length)
23622379
{
23632380
static if (Slices.length > 1)
@@ -2487,7 +2504,7 @@ template count(alias fun)
24872504
Constraints:
24882505
All slices must have the same shape.
24892506
+/
2490-
@optmath size_t count(Slices...)(Slices slices)
2507+
@fmamath size_t count(Slices...)(Slices slices)
24912508
if (Slices.length)
24922509
{
24932510
static if (Slices.length > 1)
@@ -4308,7 +4325,7 @@ template fold(alias fun)
43084325
Returns:
43094326
the accumulated result
43104327
+/
4311-
@optmath auto fold(Slice, S)(scope Slice slice, S seed)
4328+
@fmamath auto fold(Slice, S)(scope Slice slice, S seed)
43124329
{
43134330
import core.lifetime: move;
43144331
return reduce!fun(seed, slice.move);

source/mir/date.d

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4209,12 +4209,12 @@ version(unittest)
42094209
auto testYearsAD = [1, 4, 1000, 1999, 2000, 2012];
42104210

42114211
// I'd use a Tuple, but I get forward reference errors if I try.
4212-
struct MonthDay
4212+
static struct MonthDay
42134213
{
42144214
Month month;
42154215
short day;
42164216

4217-
this(int m, short d)
4217+
this(int m, short d) @safe
42184218
{
42194219
month = cast(Month) m;
42204220
day = d;

0 commit comments

Comments
 (0)