sac2c issueshttps://gitlab.sac-home.org/sac-group/sac2c/-/issues2024-03-11T09:15:20Zhttps://gitlab.sac-home.org/sac-group/sac2c/-/issues/2394TCcountArgs internal compiler error2024-03-11T09:15:20ZThomas KoopmanTCcountArgs internal compiler errorFollowing program fails with `Assertion "TCcountArgs (FUNDEF_ARGS (fundef)) == TYgetProductSize (arg_ts)" failed at /home/thomas/repos/sac2c/src/libsac2c/typecheck/specialize.c:321 -- UpdateFixSignature called with incompatible no of arg...Following program fails with `Assertion "TCcountArgs (FUNDEF_ARGS (fundef)) == TYgetProductSize (arg_ts)" failed at /home/thomas/repos/sac2c/src/libsac2c/typecheck/specialize.c:321 -- UpdateFixSignature called with incompatible no of arguments!`
When removing the unused `softmax(float[m] x)`, the error does not occur, so probably something to do with function overloading.
```
use StdIO: all;
inline
float max(float a, float b)
{
return _ge_SxS_(a, b) ? a : b;
}
inline
float maximum(float[m] x)
{
return with {
([0] <= iv < [m]): _sel_VxA_(iv, x);
}: fold(max, _sel_VxA_([0], x));
}
inline
float[m] maximum(float[m, n] x)
{
return {iv -> _sel_VxA_([0], _sel_VxA_(iv, x))};
}
inline
float[m] softmax(float[m] x)
{
return x;
}
inline
float[m, n] softmax(float[m, n] x)
{
m = maximum(x);
print(_shape_A_(m));
return x;
}
int main()
{
m = 1000;
x = {iv -> 1f | iv < [m]};
StdIO::print(softmax(x));
return _toi_S_(_sel_VxA_([0], softmax(x)));
}
```https://gitlab.sac-home.org/sac-group/sac2c/-/issues/2391Non-negativity constraint for type patterns2024-03-08T10:44:22ZJordy AalderingNon-negativity constraint for type patterns```
foo(int[o:oshp,i:ishp] a, int o)
```
In this example we need to ensure that `o` is not negative.
I suspect this is currently not enforced, and probably something horrible happens if `o` is negative.```
foo(int[o:oshp,i:ishp] a, int o)
```
In this example we need to ensure that `o` is not negative.
I suspect this is currently not enforced, and probably something horrible happens if `o` is negative.Jordy AalderingJordy Aalderinghttps://gitlab.sac-home.org/sac-group/sac2c/-/issues/2375-noINL and -check c lead to internal compiler error `Assertion "(actual_cls !...2024-03-03T10:26:17ZSven-Bodo Scholz-noINL and -check c lead to internal compiler error `Assertion "(actual_cls != C_scl) && (formal_cls != C_scl)" failed`When compiling
```
use Array: all;
int[n:shp] myrotate ( int[n] rv, int[n:shp] a)
{
return { iv -> a[mod(iv - rv, shp)] | iv < shp};
}
int main ()
{
res = myrotate( [], 42);
return res;
}
```
with
`sac2c -noINL -check c` we...When compiling
```
use Array: all;
int[n:shp] myrotate ( int[n] rv, int[n:shp] a)
{
return { iv -> a[mod(iv - rv, shp)] | iv < shp};
}
int main ()
{
res = myrotate( [], 42);
return res;
}
```
with
`sac2c -noINL -check c` we get
```
** 20: Preparing C code generation ...
Internal compiler error
Assertion "(actual_cls != C_scl) && (formal_cls != C_scl)" failed at /Volumes/Users/sbs/sac2c/src/libsac2c/precompile/typeconv_precompile.c:409 -- Conversion from or to scalar encountered!
Please file a bug at: https://gitlab.sac-home.org/sac-group/sac2c/-/issues
```
using
```
sac2c 1.3.3-MijasCosta-1154-gc82ba
build-type: RELEASE
built-by: "sbs" at 2024-02-05T10:48:28
```Jordy AalderingJordy Aalderinghttps://gitlab.sac-home.org/sac-group/sac2c/-/issues/2381Assertion "(actual_cls != C_scl) && (formal_cls != C_scl)" fails2024-03-03T10:26:09ZThomas KoopmanAssertion "(actual_cls != C_scl) && (formal_cls != C_scl)" failsNot so minimal example
```
use MathArray: all;
use Structures: all;
use StdIO: all;
#define CATEGORIES 10
#define TRAIN_SIZE 60000
inline
float[n:shpi] rsum(int m, float[m:shpo,n:shpi] x)
{
return {iv -> sum({jv -> x[jv++iv] | jv < ...Not so minimal example
```
use MathArray: all;
use Structures: all;
use StdIO: all;
#define CATEGORIES 10
#define TRAIN_SIZE 60000
inline
float[n:shpi] rsum(int m, float[m:shpo,n:shpi] x)
{
return {iv -> sum({jv -> x[jv++iv] | jv < shpo}) | iv < shpi};
}
noinline
float[m:mshp,n:oshp,b:bshp] MultiConv(float[n:ishp,b:bshp] in,
float[m:mshp,n:wshp] weights,
float[m:mshp] bias)
| all(oshp == ishp - wshp + 1)
{
x = {iv -> Convolve(in, weights[iv]) + bias[iv] | iv < mshp};
print(shape(x));
return x;
}
noinline
float[n:oshp,b:bshp] Convolve(float[n:ishp,b:bshp] in, float[n:wshp] weights)
{
oshp = ishp - wshp + 1;
return {iv -> rsum(n, {jv -> weights[jv] * in[iv + jv]}) | iv < oshp};
}
inline
float average( float[*] array)
{
return sum( array) / tof( prod( shape( array)));
}
inline
float[*] AveragePool( float[*] in, int[.] filter)
//
// assert( dim(in) >= shape(filter)[0] )
// assert( shape(out) == shape(in)/filter )
//
{
ones = genarray( [dim( in)], 1);
filter = drop( shape( filter), ones) ++ filter;
shp = shape( in) / filter;
/*
* out = { iv -> average( { ov -> in[iv+ov] | ov < filter})
* | iv < shp};
*/
out = with {
(. <= iv <= .) : average( with {
(. <= ov <= .) : in[iv*filter+ov];
} : genarray( filter, 0f));
} : genarray( shp, 0f);
return out;
}
inline
float[*] BackAveragePool( float[*] d_out, int[.] filter )
{
ones = genarray( [dim( d_out)], 1);
filter = drop( shape( filter), ones) ++ filter;
shp = shape( d_out) * filter;
d_in = with {
(. <= iv <=.) : d_out[iv/filter] / tof( prod( filter));
} : genarray( shp, 0f);
return d_in;
}
inline
float[*] BackWeights2( float[*] d_out, float[*] weights, float[*] in)
{
return with {
( . <= ov <= .) :
with {
(0*shape( d_out) <= iv < shape( d_out)) : in[ iv+ov] * d_out[iv];
} : fold( +, 0f );
} : genarray( shape( weights), 0f);
}
float[*], float[*], float[*]
BackMultiConv( float[*] d_out, float[*] weights, float[*] in, float[*] bias)
{
shp_act_map = take( -[dim(in)], shape(weights));
shp_maps = drop( -[dim(in)], shape(weights));
d_in = with {
( . <= iv <= .) :
with {
(0*shp_maps <= ov < shp_maps) {
lb = max( 0*shp_act_map, iv - take( -[dim(in)], shape(d_out)) + 1);
ub = min( shp_act_map, iv+1 );
} : with {
( lb <= ov2 < ub) : weights[ov ++ ov2] * d_out[ov ++ (iv-ov2)];
} : fold( +, 0f);
} : fold( +, 0f);
} : genarray( shape(in), 0f);
d_weights = with {
(. <= iv <= .) : BackWeights2( d_out[iv], weights[iv], in);
} : genarray( shp_maps, genarray( take( -[dim(in)], shape(weights)), 0f));
d_bias = with {
(. <= iv <= .) : sum( d_out[iv]);
} : genarray( shp_maps, 0f);
return ( d_in, d_weights, d_bias);
}
inline
float[*] BackLogistic( float[*] d_out, float[*] out)
{
return d_out * out * (1f - out);
}
inline
float[6,5,5], float[6], float[12,6,5,5], float[12], float[CATEGORIES,12,1,4,4], float[CATEGORIES], float
TrainZhang( float[28,28] in, float[6,5,5] k1, float[6] b1,
float[12,6,5,5] k2, float[12] b2,
float[CATEGORIES,12,1,4,4] fc, float[CATEGORIES] b,
float[CATEGORIES,1,1,1,1] target)
{
float[6,24,24] c1, d_c1;
float[6,12,12] s1, d_s1;
float[12,1,8,8] c2, d_c2;
float[12,1,4,4] s2, d_s2;
float[CATEGORIES,1,1,1,1] out, d_out;
c1 = MultiConv( in, k1, b1 );
s1 = AveragePool( c1, [2,2]);
c2 = MultiConv( s1, k2, b2);
s2 = AveragePool( c2, [2,2]);
out = MultiConv( s2, fc, b);
d_out = out - target;
error = 0f;
d_s2, d_fc, d_b = BackMultiConv( BackLogistic( d_out, out), fc, s2, b);
d_c2 = BackAveragePool( d_s2, [2,2]);
d_s1, d_k2, d_b2 = BackMultiConv( BackLogistic( d_c2, c2), k2, s1, b2);
d_c1 = BackAveragePool( d_s1, [2,2]);
_, d_k1, d_b1 = BackMultiConv( BackLogistic( d_c1, c1), k1, in, b1);
return ( d_k1, d_b1, d_k2, d_b2, d_fc, d_b, error);
}
int main()
{
batchsize = 100;
k1 = genarray( [6,5,5], 1f/25f);
b1 = genarray( [6], 1f/6f);
k2 = genarray( [12,6,5,5], 1f/150f);
b2 = genarray( [12], 1f/12f);
fc = genarray( [CATEGORIES,12,1,4,4], 1f/192f);
b = genarray( [CATEGORIES], 1f/tof(CATEGORIES));
training_images = genarray([TRAIN_SIZE,28,28], 0f);
training_labels = genarray([TRAIN_SIZE], 3);
error = 0d;
delta_k1, delta_b1, delta_k2, delta_b2, delta_fc, delta_b, berr =
with {
([0] <= iv < [batchsize]) {
in = training_images[iv];
target = genarray([CATEGORIES,1,1,1,1], 0f);
target[[training_labels[iv],0,0,0,0]] = 1f;
d_k1, d_b1, d_k2, d_b2, d_fc, d_b, err =
TrainZhang(in, k1, b1, k2, b2, fc, b, target);
}: (d_k1, d_b1, d_k2, d_b2, d_fc, d_b, err);
}: (fold(+, 0f * k1),
fold(+, 0f * b1),
fold(+, 0f * k2),
fold(+, 0f * b2),
fold(+, 0f * fc),
fold(+, 0f * b),
fold(+, 0f));
k1 = k1 - delta_k1;
b1 = b1 - delta_b1;
k2 = k2 - delta_k2;
b2 = b2 - delta_b2;
fc = fc - delta_fc;
b = b - delta_b;
error += tod(berr);
print(k1);
return 0;
}
```
using
```
sac2c 1.3.3-MijasCosta-1153-g14eb
build-type: DEBUG
built-by: "thomas" at 2024-02-12T12:49:22
```
with `check -c`https://gitlab.sac-home.org/sac-group/sac2c/-/issues/2376Guards are skipped by pattern matching2024-02-22T07:21:30ZJordy AalderingGuards are skipped by pattern matchingIn the following example, we would want a type pattern error.
```
int div (int x, int y) | _neq_SxS_ (y, 0)
{
return _div_SxS_ (x, y);
}
int main()
{
return div (4, 0);
}
```
However, pattern matching skips guards, instead res...In the following example, we would want a type pattern error.
```
int div (int x, int y) | _neq_SxS_ (y, 0)
{
return _div_SxS_ (x, y);
}
int main()
{
return div (4, 0);
}
```
However, pattern matching skips guards, instead resulting in `SCSprf_div_XxS: Division by zero encountered`
We should not skip over guards, so that the error message(s) can be generated by type patterns instead.Jordy AalderingJordy Aalderinghttps://gitlab.sac-home.org/sac-group/sac2c/-/issues/2380check tc false positive2024-02-14T10:10:58ZThomas Koopmancheck tc false positiveThe following program gives `Type pattern error in application of averageOuter: feature `d:shp' in return value does not match feature `shp' in arrayCompilation failed while Running SAC optimizations`. I think the program is correct howe...The following program gives `Type pattern error in application of averageOuter: feature `d:shp' in return value does not match feature `shp' in arrayCompilation failed while Running SAC optimizations`. I think the program is correct however. It should average `batchsize` many copies of `k1`.
```
use Array: all;
inline
float[d:shp] averageOuter(float[n,d:shp] array)
{
return {iv -> sum({[i] -> array[[i]++iv] | [i] < [n]}) | iv < shp};
}
int main()
{
batchsize = 100;
k1 = with {}: genarray([6, 5, 5], 1f / 25f);
/* [batchsize, 6, 5, 5] */
bd_k1 = {iv -> k1 | iv < [batchsize]};
k1 = averageOuter(bd_k1);
return _toi_S_(_sel_VxA_([0, 0, 0], k1));
}
```
Compiled with arguments `-check tc`
```
sac2c 1.3.3-MijasCosta-1153-g14eb
build-type: DEBUG
built-by: "thomas" at 2024-02-12T12:49:22
```https://gitlab.sac-home.org/sac-group/sac2c/-/issues/2372WLMP crashes on sequence of WL nested inside another WL2024-02-13T09:43:02ZSven-Bodo ScholzWLMP crashes on sequence of WL nested inside another WLThe following example:
```
int main()
{
inpp = with {
([0] <= iv < [20] ) { i = with {
([0] <= jv < iv) : 42;
(iv <= jv < [10]) : 24;
...The following example:
```
int main()
{
inpp = with {
([0] <= iv < [20] ) { i = with {
([0] <= jv < iv) : 42;
(iv <= jv < [10]) : 24;
} : genarray([10], 0); } : i;
} : genarray([20], [0,0,0,0,0,0,0,0,0,0]);
return _sel_VxA_([0, 0], inpp);
}
```
OOOPSES in WLMP.
With noSRP and no SOP, it works fine....Sven-Bodo ScholzSven-Bodo Scholzhttps://gitlab.sac-home.org/sac-group/sac2c/-/issues/2378check c problem ICM undefined!2024-02-10T17:06:10ZSven-Bodo Scholzcheck c problem ICM undefined!When compiling
```
noinline
int[*] myReshape (int[.] shp, int[*] data)
{
return _reshape_VxA_(shp, data);
}
int main() {
x = myReshape ([1], 42);
return _sel_VxA_([0], x);
}
```
with `sac2c -check c`
we get
```
** 22: Cr...When compiling
```
noinline
int[*] myReshape (int[.] shp, int[*] data)
{
return _reshape_VxA_(shp, data);
}
int main() {
x = myReshape ([1], 42);
return _sel_VxA_([0], x);
}
```
with `sac2c -check c`
we get
```
** 22: Creating binary code ...
/Volumes/Users/sbs/Dropbox/BodoSac/ruben/a.out.c:1476:265: error: use of undeclared identifier '_ICM_IS_UNDEFINED_'
SAC_RuntimeWarningLoc ("./bug1.sac", 4, 12, "Arrays `" "SACp_emal_6042__idc_1216""' with shape %s ""And `" "SACl_data""' with shape %s ""do not adhere to prod matches prod shape constraint", SAC_PrintShape (SACp_emal_6042__idc_1216__desc), SAC_PrintShape (_ICM_IS_UNDEFINED_));
^
1 error generated.
```
One can also use `-noprelude` alongside....
Without `-check c` it compiles and runs fine.
When inlining it also runs fine.Jordy AalderingJordy Aalderinghttps://gitlab.sac-home.org/sac-group/sac2c/-/issues/2374Type patterns does incorrect dimension computation2024-02-05T09:44:39ZThomas KoopmanType patterns does incorrect dimension computation```
sac2c 1.3.3-MijasCosta-1143-g21fdd4
build-type: DEBUG
built-by: "thomas" at 2024-01-30T10:37:51
```
Following program throws runtime error `*** Type pattern error in application of MultiConv: feature \`b:bshp' in return value does n...```
sac2c 1.3.3-MijasCosta-1143-g21fdd4
build-type: DEBUG
built-by: "thomas" at 2024-01-30T10:37:51
```
Following program throws runtime error `*** Type pattern error in application of MultiConv: feature \`b:bshp' in return value does not match feature \`b' in in`
```
use StdIO: all;
use Array: all;
noinline
float[m:mshp,n:oshp,b:bshp] MultiConv(float[n:ishp,b:bshp] in,
float[m:mshp,n:wshp] weights,
float[m:mshp] bias)
| all(oshp == ishp - wshp + 1)
{
printf("m = %d, n = %d, b = %d\n", m, n, b);
x = {iv -> Convolve(in, weights[iv]) + bias[iv] | iv < mshp};
print(shape(x));
return x;
}
noinline
float[n:oshp,b:bshp] Convolve(float[n:ishp,b:bshp] in, float[n:wshp] weights)
{
oshp = ishp - wshp + 1;
// return {iv -> rsum(n, {jv -> weights[jv] * in[iv + jv]}) | iv < oshp};
return {iv -> sum({jv -> weights[jv] * in[iv + jv]}) | iv < oshp};
}
int main()
{
in = genarray([28, 28], 0f);
weights = genarray([6, 5, 5], 0f);
bias = genarray([6], 0f);
print(MultiConv(in, weights, bias));
return 0;
}
```
Generated guard shows
```
_rtpf_0_pred = ( _eq_SxS_( b, _sub_SxS_( _dim_A_( _rtpf_1_ret), _sub_SxS_( m, n))) ? _rtpf_0_pred : _guard_error_( _|_ /* Type pattern error in application of MultiConv: feature `b:bshp' in return value does not match feature `b' in in */) );
```
or in other words checks that `b == dim(out) - (m - n)` while it should be `b == dim(out) - (m + n)`.Jordy AalderingJordy Aalderinghttps://gitlab.sac-home.org/sac-group/sac2c/-/issues/2373UAR crashes when called in WL2024-02-01T14:47:43ZSven-Bodo ScholzUAR crashes when called in WLTrying
```
noinline
int foo( int a, int b)
{ return a; }
int main()
{
return _sel_VxA_( [0], { [i] -> foo(i,i) | [i] < [10] });
}
```
crashes in code generation with
```
** 21: Generating Code ...
**** Tag preparation ...
****...Trying
```
noinline
int foo( int a, int b)
{ return a; }
int main()
{
return _sel_VxA_( [0], { [i] -> foo(i,i) | [i] < [10] });
}
```
crashes in code generation with
```
** 21: Generating Code ...
**** Tag preparation ...
**** Creating intermediate code macros ...
TRAVERSE ERROR: node of type 0:undefined found where 58:N_avis was expected!
```
when using debug compiler -v4Jordy AalderingJordy Aalderinghttps://gitlab.sac-home.org/sac-group/sac2c/-/issues/2371Assertion in WLUTfindArrayForBound fails2024-01-30T16:02:43ZThomas KoopmanAssertion in WLUTfindArrayForBound fails# sac2c version
```
sac2c 1.3.3-MijasCosta-1137-gcc26d
build-type: DEBUG
built-by: "thomas" at 2024-01-29T11:23:03
```
No flags. With `check tc` it does compile, and runs without errors!
# Program
```
inline
int[d:shp] -(int[d:shp] a...# sac2c version
```
sac2c 1.3.3-MijasCosta-1137-gcc26d
build-type: DEBUG
built-by: "thomas" at 2024-01-29T11:23:03
```
No flags. With `check tc` it does compile, and runs without errors!
# Program
```
inline
int[d:shp] -(int[d:shp] a, int[d:shp] b)
{
return {iv -> _sub_SxS_(_sel_VxA_(iv, a),
_sel_VxA_(iv, b))};
}
inline
int[d:shp] +(int[d:shp] a, int[d:shp] b)
{
return {iv -> _add_SxS_(_sel_VxA_(iv, a),
_sel_VxA_(iv, b))};
}
inline
double[d:mn] backslide(int[d] i, double[d:n1] y, int[d] mn)
| all(i < 1 + mn - n1)
{
return {iv -> 0d | iv < i;
iv -> _sel_VxA_(iv - i, y) | i <= iv < n1 + i;
iv -> 0d | n1 + i <= iv < mn};
}
int main()
{
w = {iv -> 42d | iv < [5, 5]};
inpp = {[x1, x2] -> backslide([x1, x2], with {}: genarray([24, 24], 0d), [28, 28])
| [x1, x2] < [5, 5]};
return _toi_S_(_sel_VxA_([0, 0, 0, 0], inpp));
}
```
# error
```
Assertion "res == NULL || NODE_TYPE (res) == N_array" failed at /home/thomas/repos/sac2c/src/libsac2c/arrayopt/with_loop_utilities.c:289 -- Array conversion failed!
```Thomas KoopmanThomas Koopmanhttps://gitlab.sac-home.org/sac-group/sac2c/-/issues/2370Tensor Comprehension with dot as upper bound crashes in Type Inference2024-01-28T13:00:30ZThomas KoopmanTensor Comprehension with dot as upper bound crashes in Type InferenceCompiler commit cc26dcec
The following program crashes at the type inference stage.
```
int +(int a, int b)
{
return _add_SxS_(a, b);
}
int +(int[*] a, int b)
{
return {iv -> _sel_VxA_(iv, a) + b};
}
/* double[m + n] backslide(i...Compiler commit cc26dcec
The following program crashes at the type inference stage.
```
int +(int a, int b)
{
return _add_SxS_(a, b);
}
int +(int[*] a, int b)
{
return {iv -> _sel_VxA_(iv, a) + b};
}
/* double[m + n] backslide(int i, double[n + 1] x) | (i < m) */
#define backslide(i, x) \
{iv -> 0d | iv < [i]; \
iv -> _sel_VxA_([iv + i], x) | [i] <= iv < _shape_A_(x) + [i]; \
iv -> 0d | [_shape_A_(x) + i] <= iv < .}
int main()
{
double[11000] x; /* m + n is illegal */
n = 10000;
m = 1000;
n1 = n + 1;
y = with {}: genarray([m], 0d);
x = backslide(_div_SxS_(m, 2), y);
return 0;
}
```Sven-Bodo ScholzSven-Bodo Scholzhttps://gitlab.sac-home.org/sac-group/sac2c/-/issues/2369Multi-operator fold loop puts accumulators in wrong order2024-01-26T09:05:37ZThomas KoopmanMulti-operator fold loop puts accumulators in wrong order# Compiler
```
sac2c 1.3.3-MijasCosta-1135-g4b472
build-type: DEBUG
built-by: "thomas" at 2024-01-24T13:04:00
```
No flags
# Test
The following program creates three constant arrays of length `1000` with values 1, 5, 13 respectively....# Compiler
```
sac2c 1.3.3-MijasCosta-1135-g4b472
build-type: DEBUG
built-by: "thomas" at 2024-01-24T13:04:00
```
No flags
# Test
The following program creates three constant arrays of length `1000` with values 1, 5, 13 respectively. These are then summed with a multi-operator with-loop and the results are printed. It should print `1000, 5000, 13000`, but it prints `7000, 5000, 7000`.
```
#define N 1000
int add(int a, int b)
{
return _add_SxS_(a, b);
}
noinline
int, int, int sum(int[N] eren, int[N] mikasa, int[N] reiner)
{
eren_res, mikasa_res, reiner_res =
with {
([0] <= iv < [N]) {
eren_term = _sel_VxA_(iv, eren);
mikasa_term = _sel_VxA_(iv, mikasa);
reiner_term = _sel_VxA_(iv, reiner);
}: (eren_term, mikasa_term, reiner_term);
}: (fold(add, 0), fold(add, 0), fold(add, 0));
return (eren_res, mikasa_res, reiner_res);
}
int main()
{
eren = with {}: genarray([N], 1);
mikasa = with {}: genarray([N], 5);
reiner = with {}: genarray([N], 13);
eren_sum, mikasa_sum, reiner_sum = sum(eren, mikasa, reiner);
StdIO::printf("%d, %d, %d\n", eren_sum, mikasa_sum, reiner_sum);
return 0;
}
```
# Investigation
The optimized code looks as follows. We see that the accumulators `_ea_150_reiner_res, _ea_148_mikasa_res, _ea_146_eren_res` are in reverse order. This means that the first and third sum get alternating terms from the first and third arrays, which explains the `7000 = 1 * 1000 / 2 + 13 * 1000 / 2`.
```
int, int, int _MAIN::sum( int[1000] eren { ,NN } , int[1000] mikasa { ,NN } , int[1000] reiner { ,NN } )
/*
* sum :: ---
*/
{
int _ivesli_2673 { , NN } ;
int _ea_151_reiner_term { , NN } ;
int _ea_150_reiner_res { , NN } ;
int _ea_149_mikasa_term { , NN } ;
int _ea_148_mikasa_res { , NN } ;
int _ea_147_eren_term { , NN } ;
int _ea_146_eren_res { , NN } ;
int _eat_74 { , NN } ;
int reiner_res { , NN } ;
int mikasa_res { , NN } ;
int eren_res { , NN } ;
int reiner_term { , NN } ;
int mikasa_term { , NN } ;
int eren_term { , NN } ;
int[1] iv { , NN } ;
int{0} _flat_16 { , NN } ;
_flat_16 = 0;
eren_res, mikasa_res, reiner_res = with /** FOLDABLE (all gen's const) **/
/** REFERENCED: 3 (total num refs) **/
{
/* Partn */
([ 0 ] <= iv=[_eat_74] < [ 1000 ] genwidth [ 1000 ])
{
_ea_150_reiner_res, _ea_148_mikasa_res, _ea_146_eren_res = _accu_( iv, _flat_16, _flat_16, _flat_16);
_ivesli_2673 = _idxs2offset_( [ 1000 ], _eat_74);
eren_term = _idx_sel_( _ivesli_2673, eren);
mikasa_term = _idx_sel_( _ivesli_2673, mikasa);
reiner_term = _idx_sel_( _ivesli_2673, reiner);
_ea_151_reiner_term = _add_SxS_( _ea_150_reiner_res, reiner_term);
_ea_149_mikasa_term = _add_SxS_( _ea_148_mikasa_res, mikasa_term);
_ea_147_eren_term = _add_SxS_( _ea_146_eren_res, eren_term);
} : _ea_147_eren_term, _ea_149_mikasa_term, _ea_151_reiner_term ;
} :
fold( _MAIN::add(), _flat_16),
fold( _MAIN::add(), _flat_16),
fold( _MAIN::add(), _flat_16);
return( eren_res, mikasa_res, reiner_res);
}
```Thomas KoopmanThomas Koopmanhttps://gitlab.sac-home.org/sac-group/sac2c/-/issues/2365scanner parser erroneous warning about type pattern in class / typedef2023-12-13T12:15:47ZSven-Bodo Scholzscanner parser erroneous warning about type pattern in class / typedefWith the latest compiler
```
sac2c -V
sac2c 1.3.3-MijasCosta-1125-g8ae1e
build-type: RELEASE
built-by: "sbs" at 2023-12-08T19:40:06
```
the following class:
```
class error;
classtype int[1];
```
triggers the following warning:
```
-sb...With the latest compiler
```
sac2c -V
sac2c 1.3.3-MijasCosta-1125-g8ae1e
build-type: RELEASE
built-by: "sbs" at 2023-12-08T19:40:06
```
the following class:
```
class error;
classtype int[1];
```
triggers the following warning:
```
-sbs-n142230-> sac2c error.sac
error.sac:1:1: warning:
Type patterns are currently not supported for type definitions. Ignoring all type variables.
```Jordy AalderingJordy Aalderinghttps://gitlab.sac-home.org/sac-group/sac2c/-/issues/2360Type Pattern return variable segfault2023-12-05T10:42:56ZSven-Bodo ScholzType Pattern return variable segfaultThe following program OOOPses:
```
use Array: all;
double[m,2] Graham (double[n,2] P)
{
return P;
}
int main () {
P = tod (reshape ([10,2], iota(20)));
StdIO::print ( Graham(P) );
return 0;
}
```
when trying to compil...The following program OOOPses:
```
use Array: all;
double[m,2] Graham (double[n,2] P)
{
return P;
}
int main () {
P = tod (reshape ([10,2], iota(20)));
StdIO::print ( Graham(P) );
return 0;
}
```
when trying to compile with
```
sac2c -V
sac2c 1.3.3-MijasCosta-1121-g254711
build-type: RELEASE
built-by: "sbs" at 2023-12-04T16:12:57
```
using `-check c`.
If you replace the `m` in the return pattern, live is good again....Jordy AalderingJordy Aalderinghttps://gitlab.sac-home.org/sac-group/sac2c/-/issues/2359UAR fails2023-12-02T14:51:18ZSven-Bodo ScholzUAR failsConsider this:
```
noinline
int[10] foo ( int[10] g)
{
return with {}: genarray( _shape_A_(g), 0);
}
int main()
{
a = foo ([1,2,3,4,5,6,7,8,9,0]);
StdIO::print(a);
return 0;
}
```
Using `sac2c 1.3.3-MijasCosta-1119-g05...Consider this:
```
noinline
int[10] foo ( int[10] g)
{
return with {}: genarray( _shape_A_(g), 0);
}
int main()
{
a = foo ([1,2,3,4,5,6,7,8,9,0]);
StdIO::print(a);
return 0;
}
```
Using `sac2c 1.3.3-MijasCosta-1119-g05899` in debug version using `-v4`
we get:
```
** 21: Generating Code ...
**** Tag preparation ...
**** Creating intermediate code macros ...
TRAVERSE ERROR: node of type 0:undefined found where 58:N_avis was expected!
OOOOOOOPS, your program crashed the compiler 8-((
Please, submit the bug report online at
https://gitlab.sac-home.org/sac-group/sac2c/-/issues.
For your convenience, the compiler has pre-fabricated a bug report
in the file "./jordysdelight.sacbugreport" !
Besides some infos concerning the compiler version and its
usage it contains the specified source file.
If you want to send that bug report to us, you may simply type
mail bugs@sac-home.org < jordysdelight.sacbugreport
If you decide to file a bug on our bug-tracker, please go to
https://gitlab.sac-home.org/sac-group/sac2c/-/issues.
When filing a bug report, please copy/paste the initial comment section of
the bug report into the plain text comment section of the bug-tracker, and add
the whole bug report file as an attachment.
Abort
```Jordy AalderingJordy Aalderinghttps://gitlab.sac-home.org/sac-group/sac2c/-/issues/2358SRP fails for divisors greater than 22023-11-29T19:20:26ZMichiel VerloopSRP fails for divisors greater than 2The below program has different behaviours for `-dosrp` and `-nosrp` (both with `-maxwlmp 3`)
```
use Array: all;
use Math: all;
use StdIO: all;
noinline
int[.] test ()
{
return {[i] -> mod(i + 2, 3) | [i] < [10]};
}
int main()
{
...The below program has different behaviours for `-dosrp` and `-nosrp` (both with `-maxwlmp 3`)
```
use Array: all;
use Math: all;
use StdIO: all;
noinline
int[.] test ()
{
return {[i] -> mod(i + 2, 3) | [i] < [10]};
}
int main()
{
print(test());
return 0;
}
```
```
>>> sac2c_p -maxwlmp 5 test.sac -dosrp && ./a.out
Dimension: 1
Shape : < 25>
< 2 3 0 0 0 2 3 0 0 0 2 3 0 0 0 2 3 0 0 0 2 3 0 0 0 >
```
```
>>> sac2c_p -maxwlmp 5 test.sac -nosrp && ./a.out
Dimension: 1
Shape : < 25>
< 2 3 4 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 0 1 >
```
This behaviour is caused by `SRPlowerBoundRec` in `wl_modulo_partitioning.c`. It's supposed to recursively compute the new bounds, but instead it computes the base case + a single recursive step. As a consequence, all partitions after the second are equal to the second, and nothing is computed for the values meant to be covered by the other partitions.Michiel VerloopMichiel Verloophttps://gitlab.sac-home.org/sac-group/sac2c/-/issues/2357Type pattern with constraint on argument types not working2023-11-29T15:06:08ZSven-Bodo ScholzType pattern with constraint on argument types not workingIf I try this example:
```
use Array: all;
int[m] foo ( int[n] v, int[m] w) | ( n == 2 * m)
{
return { iv -> v[iv*2] + w[iv] | iv < [m]};
}
int main () {
a = foo( [1,2,3], [1,2]);
return _sel_VxA_([1], a);
}
```
using
``...If I try this example:
```
use Array: all;
int[m] foo ( int[n] v, int[m] w) | ( n == 2 * m)
{
return { iv -> v[iv*2] + w[iv] | iv < [m]};
}
int main () {
a = foo( [1,2,3], [1,2]);
return _sel_VxA_([1], a);
}
```
using
```
sac2c 1.3.3-MijasCosta-1115-g81576
build-type: RELEASE
built-by: "sbs" at 2023-11-29T11:50:22
```
with `sac2c -check c -b2:rtpf` we obtain:
```
/****************************************************************************
* _rtpf_2_post_foo(...) [ body ]
****************************************************************************/
inline
bool _rtpf_2_post_foo( int[.] v { ,NN } , int[.] w { ,NN } , int[.] _rtpf_1_ret { ,NN } )
/*
* _rtpf_2_post_foo :: ---
*/
{
_rtpf_0_pred = true;
n = _sel_VxA_( [ 0 ], _shape_A_( v));
m = _sel_VxA_( [ 0 ], _shape_A_( w));
_rtpf_0_pred = ( _eq_SxS_( m, _sel_VxA_( [ 0 ], _shape_A_( _rtpf_1_ret))) ? _rtpf_0_pred : _type_error_( _|_) );
return( _rtpf_0_pred);
}
/****************************************************************************
* _rtpf_3_impl_foo(...) [ body ]
****************************************************************************/
int[.] _rtpf_3_impl_foo( int[.] v { ,NN } , int[.] w { ,NN } )
/*
* _rtpf_3_impl_foo :: ---
*/
{
n = _sel_VxA_( [ 0 ], _shape_A_( v));
m = _sel_VxA_( [ 0 ], _shape_A_( w));
return( { iv -> ( sel( ( iv *2) , v) +sel( iv, w) ) | (NULL) <= ? < [ m ] });
}
/****************************************************************************
* foo(...) [ body ]
****************************************************************************/
inline
int[.] foo( int[.] v { ,NN } , int[.] w { ,NN } )
/*
* foo :: ---
*/
{
_rtpf_5_res = _rtpf_3_impl_foo( v, w) ;
_rtpf_4_pred = _rtpf_2_post_foo( v, w, _rtpf_5_res) ;
_rtpf_5_res = _guard_( _rtpf_5_res, _rtpf_4_pred);
return( _rtpf_5_res);
}
```
Note here the missing pre-check!Jordy AalderingJordy Aalderinghttps://gitlab.sac-home.org/sac-group/sac2c/-/issues/2349Type mismatch in EMRL for cuda backend2023-11-26T06:21:37ZThomas KoopmanType mismatch in EMRL for cuda backend# Compiler
Branch hotfix-2344 from sbs fork, commit bfb9547bba8cc14af96d641acb39051ca2d973ce
Flags `-t cuda -check c`.
# Code
```
noinline
double[.] hide(double[.] x)
{
return x;
}
inline
double[32, 256] rollback(double[32, 256] R...# Compiler
Branch hotfix-2344 from sbs fork, commit bfb9547bba8cc14af96d641acb39051ca2d973ce
Flags `-t cuda -check c`.
# Code
```
noinline
double[.] hide(double[.] x)
{
return x;
}
inline
double[32, 256] rollback(double[32, 256] ResultE)
{
V = {[i, j] -> _mul_SxS_(3d, _sel_VxA_([i, j], ResultE))
| [i, j] < [32, 256]};
U = {[j, i] -> _mul_SxS_(2d, _sel_VxA_([i, j], ResultE))
| [j, i] < [256, 32]};
ResultE = {[i] -> hide({[j] -> _sub_SxS_(_sel_VxA_([j, i], U),
_sel_VxA_([i, j], V))})
};
return ResultE;
}
inline
double value(double strike)
{
ResultE = with {}: genarray([32, 256], strike);
for (t = 254; _ge_SxS_(t, 0); t = _sub_SxS_(t, 1)) {
ResultE = rollback(ResultE);
}
return _sel_VxA_([10, 10], ResultE);
}
int main()
{
result = {[i] -> value(_div_SxS_(_tod_S_(i), 1000.0))
| [i] < [OUTER]};
return _toi_S_(_sel_VxA_([0], result));
}
```
# Problem
In 1000 runs, it gives error
`Can not assign double[32,256] SACp_emrl_6253_emr_lifted to double[256,32] SACp_pinl_7130__emrl_6250_emr_tmp type mismatch` twice, and segfault 998 times.Hans-Nikolai ViessmannHans-Nikolai Viessmannhttps://gitlab.sac-home.org/sac-group/sac2c/-/issues/2352Wrong error message on TypePattern2023-11-21T21:22:15ZSven-Bodo ScholzWrong error message on TypePatternI just tried this:
```
int[m] shuffle (int[m] a, int m, int[m] dscrm)
{
return a;
}
int main () {
a = with {} : genarray ([10], 0);
return _sel_VxA_([1], shuffle (a, 3, a));
}
```
Note that the problem lies in using `m` fo...I just tried this:
```
int[m] shuffle (int[m] a, int m, int[m] dscrm)
{
return a;
}
int main () {
a = with {} : genarray ([10], 0);
return _sel_VxA_([1], shuffle (a, 3, a));
}
```
Note that the problem lies in using `m` for the second argument! However, the error that I get when compiling
with `sac2c -check tc` using
```
-sbs-n142230-> sac2c -V
sac2c 1.3.3-MijasCosta-1095-gc60dbe
build-type: RELEASE
built-by: "sbs" at 2023-11-16T15:20:03
```
is:
```-sbs-n142230-> sac2c error.sac -check tc
Warning:
Option -check c implies option -ecc.
Insertion of explicit conformity checks has been enabled.
Type pattern error in definition of shuffle: feature `m' in dscrm does not match `m' in a.
```
This seems wrong in many ways:
- are you using CTIerror? I would have expected something prefixed with `Error:`
- I would also have expected to get a line number....
- the reported uses of m in fact are correct as they do match!Jordy AalderingJordy Aaldering