Commit 8e7b0765 authored by Hans-Nikolai Viessmann's avatar Hans-Nikolai Viessmann
Browse files

Merge branch 'sbs-full-MOWLs-support' into 'develop'

completely rejigged the AUD WL code generation to properly support MOWLs

See merge request !183
parents d0f9fcb7 6cc8bc11
Showing with 748 additions and 359 deletions
+748 -359
This diff is collapsed.
This diff is collapsed.
// test AUD genarray WL with default elements only.
// SAC_TEST|include common.mk
// SAC_TEST|SAC2C_FLAGS += -v0 -noprelude
// SAC_TEST|CALL_SAC2C := $(SAC2C) $(SAC2C_FLAGS)
// SAC_TEST|all: <file-name-we>
// SAC_TEST|<tab>$(CHECK_RETURN_STATUS) $< 3
noinline
int[.] hide( int x)
{
if (_eq_SxS_(x, 1))
res = [3];
else
res = [3,3];
return res;
}
noinline
int consume( int[*] a)
{
return _sel_VxA_([0],_shape_A_ (a));
}
int main()
{
shp = hide (1);
a = with {
} : genarray( shp, 1);
// should return 3
return consume (a);
}
// test AUD fold WL with 2 operators
// SAC_TEST|include common.mk
// SAC_TEST|SAC2C_FLAGS += -v0 -noprelude
// SAC_TEST|CALL_SAC2C := $(SAC2C) $(SAC2C_FLAGS)
// SAC_TEST|all: <file-name-we>
// SAC_TEST|<tab>$(CHECK_RETURN_STATUS) $< 24
noinline
int[*] hide( int x, int[*] a)
{
if (_eq_SxS_(x, 1))
res = [7];
else
res = a;
return res;
}
noinline
int consume( int[*] a)
{
return ( _eq_SxS_ (_dim_A_(a), 0) ? a : hide (0, _sel_VxA_([0], _shape_A_(a))));
}
noinline
int[*] add ( int[*] a, int[*] b)
{ return _add_SxS_ ( a, _sel_VxA_([0], b)); }
int main()
{
shp = hide (1, 0);
a,b = with {
(_mul_SxV_(0,shp) <= iv < shp step _add_SxV_(4, _mul_SxV_(0,shp))
width _add_SxV_(2, _mul_SxV_(0,shp))) : (iv,iv);
} : (fold( add, 2), fold( add, 2));
// the correct answer is 24!
return consume (add( a, [b]));
}
// test AUD genarray WL with foldfix!
// SAC_TEST|include common.mk
// SAC_TEST|SAC2C_FLAGS += -v0 -noprelude
// SAC_TEST|CALL_SAC2C := $(SAC2C) $(SAC2C_FLAGS)
// SAC_TEST|all: <file-name-we>
// SAC_TEST|<tab>$(CHECK_RETURN_STATUS) $< 1
noinline
int[*] hide( int x, int[*] a)
{
if (_eq_SxS_(x, 1))
res = [4];
else
res = a;
return res;
}
noinline
int consume( int[*] a)
{
return ( _eq_SxS_ (_dim_A_(a), 0) ? a : hide (0, _sel_VxA_([0], _shape_A_(a))));
}
noinline
int[*] add ( int[*] a, int[*] b)
{ return _add_SxS_ ( a, _sel_VxA_([0], b)); }
int main()
{
shp = hide (1, 0);
a = with {
(_mul_SxV_(0,shp) <= iv < shp) : iv;
} : foldfix( add, 0, 1);
// the correct answer is 1 and not 6!
return consume (a);
}
// test AUD genarray WL with 2 operators
// SAC_TEST|include common.mk
// SAC_TEST|SAC2C_FLAGS += -v0 -noprelude
// SAC_TEST|CALL_SAC2C := $(SAC2C) $(SAC2C_FLAGS)
// SAC_TEST|all: <file-name-we>
// SAC_TEST|<tab>$(CHECK_RETURN_STATUS) $< 64
noinline
int[.] hide( int x)
{
if (_eq_SxS_(x, 1))
res = [7];
else
res = [3,3];
return res;
}
noinline
int consume( int[*] a, int[*] b)
{
return _add_SxS_ ( _sel_VxA_([0],(a)),
_add_SxS_ ( _sel_VxA_([2],(a)),
_add_SxS_ ( _sel_VxA_([0],(b)),
_sel_VxA_([2],(b)))));
}
int main()
{
shp = hide (1);
a,b = with {
(_mul_SxV_(0,shp) <= iv < shp step _add_SxV_(4, _mul_SxV_(0,shp))
width _add_SxV_(2, _mul_SxV_(0,shp))) : (21, 42);
} : (genarray (shp, 0),
genarray (shp, 1));
// should return 64!
return consume (a,b);
}
// test AUD modarray WL with two operators
// SAC_TEST|include common.mk
// SAC_TEST|SAC2C_FLAGS += -v0 -noprelude
// SAC_TEST|CALL_SAC2C := $(SAC2C) $(SAC2C_FLAGS)
// SAC_TEST|all: <file-name-we>
// SAC_TEST|<tab>$(CHECK_RETURN_STATUS) $< 93
noinline
int[*] hide( int x, int[*] a)
{
if (_eq_SxS_(x, 1))
res = 42;
else
res = a;
return res;
}
noinline
int consume( int[*] a, int[*] b)
{
return _add_SxS_ ( _sel_VxA_([4],(a)),
_add_SxS_ ( _sel_VxA_([5],(a)),
_add_SxS_ ( _sel_VxA_([8],(a)),
_add_SxS_ ( _sel_VxA_([4],(b)),
_add_SxS_ ( _sel_VxA_([5],(b)),
_sel_VxA_([8],(b)))))));
}
int main()
{
a = hide (0, [1,2,3,4,5,6,7,8,9]);
shp = hide (0, [6]);
a,b = with {
(_mul_SxV_(0,shp) <= iv < shp step _add_SxV_(4, _mul_SxV_(0,shp))) : (21,42);
} : (modarray(a), modarray(a));
// should return (21+6+9+42+6+9) = 93!
return consume (a,b);
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment