sac2c issueshttps://gitlab.sac-home.org/sac-group/sac2c/-/issues2023-01-23T17:16:03Zhttps://gitlab.sac-home.org/sac-group/sac2c/-/issues/2323mem:LRO bug; aliasing in recursive loop call has been overlooked2023-01-23T17:16:03ZSven-Bodo Scholzmem:LRO bug; aliasing in recursive loop call has been overlookedWhen compiling
```
int main()
{
def_chunk = with {} : genarray ([20], 0);
aa = def_chunk;
bb = def_chunk;
b,c = with {
( . <= iv < .) {
aa = def_chunk;
bb = def_chunk;
...When compiling
```
int main()
{
def_chunk = with {} : genarray ([20], 0);
aa = def_chunk;
bb = def_chunk;
b,c = with {
( . <= iv < .) {
aa = def_chunk;
bb = def_chunk;
for (i=0; _lt_SxS_(i,4); i = _add_SxS_(i,1)) {
bb = with {
([2] <= ov <[19]) : _sel_VxA_(ov, aa) ;
} : modarray (bb);
tmp = aa;
aa = bb;
bb = tmp;
}
} : (aa, bb);
} : (genarray ([2], def_chunk),
genarray ([2], def_chunk));
return _sel_VxA_([0,0], b);
}
```
with
```
sac2c 1.3.3-MijasCosta-1036-g3a2ed
build-type: RELEASE
built-by: "sbs" at 2023-01-18T10:04:41
```
even when using `-noemrl -noEMRCI -noEMRCF`
produces
```
-sbs-SvenBodosAir2-> ./a.out
a.out(18695,0x7ff84562d8c0) malloc: *** error for object 0x600003178000: pointer being freed was not allocated
a.out(18695,0x7ff84562d8c0) malloc: *** set a breakpoint in malloc_error_break to debug
Abort
```Sven-Bodo ScholzSven-Bodo Scholzhttps://gitlab.sac-home.org/sac-group/sac2c/-/issues/2322weird Type upgrade problem2023-01-17T20:24:35ZSven-Bodo Scholzweird Type upgrade problemWhen I compile
```
inline
int[10,10] myrotate (int[2] counts, int[10,10] A)
{
for( i=0; _lt_SxS_(i,2); i=_add_SxS_(i,1) ) {
count = _sel_VxA_([i],counts);
slice_shp = _modarray_AxVxS_([10,10], [i], count);
A = with {
...When I compile
```
inline
int[10,10] myrotate (int[2] counts, int[10,10] A)
{
for( i=0; _lt_SxS_(i,2); i=_add_SxS_(i,1) ) {
count = _sel_VxA_([i],counts);
slice_shp = _modarray_AxVxS_([10,10], [i], count);
A = with {
( [0,0] <= iv < slice_shp ) : _sel_VxA_( _add_VxV_(_sub_VxV_([10,10],slice_shp),iv) , A);
} : modarray( A );
}
return(A);
}
int main()
{
x = with {} : genarray([10, 10], 0);
a = with {
([0,0]<= iv <[4,4]) : myrotate ( iv, x);
} : genarray( [4,4], x);
return _sel_VxA_([0,0,1,2], a);
}
```
using
```
sac2c 1.3.3-MijasCosta-1032-gff7ec
build-type: RELEASE
built-by: "sbs" at 2023-01-16T20:34:58
```
(can be experiences using -noprelude)
then I get
```
Internal compiler error
Assertion "cviv[i] < cvshp[i]" failed at /Volumes/Users/sbs/sac2c/src/libsac2c/constants/constants_struc_ops.c:1275 -- Index error: iv[1] >= shp[1]
Please file a bug at: https://gitlab.sac-home.org/sac-group/sac2c/-/issues
```Sven-Bodo ScholzSven-Bodo Scholzhttps://gitlab.sac-home.org/sac-group/sac2c/-/issues/2321EMRL bug2023-01-23T17:16:27ZSven-Bodo ScholzEMRL bugThe following example:
```
use Array: all;
use StdIO: all;
#define N 20
#define BS 10
noinline
float[N] stencil_1D_fix (float[3] weights, int n, float[N] v)
{
for (i=0; i<n; i++) {
v = { iv -> sum (weights * tile ([3], iv-...The following example:
```
use Array: all;
use StdIO: all;
#define N 20
#define BS 10
noinline
float[N] stencil_1D_fix (float[3] weights, int n, float[N] v)
{
for (i=0; i<n; i++) {
v = { iv -> sum (weights * tile ([3], iv-1, v)) | [1] <= iv < [N-1];
iv -> v[iv] };
}
return v;
}
int main()
{
a = genarray( [N], 0f);
a[10] = 10f;
print (a);
b = stencil_1D_fix ([0.25f,0.5f,0.25f], 10, a);
print (b);
print (a);
return 0;
}
```
when compiled with
```
sac2c 1.3.3-MijasCosta-1032-gff7ec
build-type: RELEASE
built-by: "sbs" at 2023-01-16T16:50:26
```
using no flags, yields the erroneous result:
```
-sbs-n142121-> ./a.out
Dimension: 1
Shape : < 20>
<0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 10.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 >
Dimension: 1
Shape : < 20>
<0.000000 0.000191 0.001812 0.010872 0.046206 0.147858 0.369644 0.739288 1.201344 1.601791 1.761971 1.601791 1.201344 0.739288 0.369644 0.147858 0.046206 0.010872 0.001802 0.000000 >
Dimension: 1
Shape : < 20>
<0.000000 0.000191 0.001812 0.010872 0.046206 0.147858 0.369644 0.739288 1.201344 1.601791 1.761971 1.601791 1.201344 0.739288 0.369644 0.147858 0.046206 0.010872 0.001802 0.000000 >
```
When compiled with `-noEMRL`, we get the correct result:
```
-sbs-n142121-> ./a.out
Dimension: 1
Shape : < 20>
<0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 10.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 >
Dimension: 1
Shape : < 20>
<0.000000 0.000191 0.001812 0.010872 0.046206 0.147858 0.369644 0.739288 1.201344 1.601791 1.761971 1.601791 1.201344 0.739288 0.369644 0.147858 0.046206 0.010872 0.001802 0.000000 >
Dimension: 1
Shape : < 20>
<0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 10.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 >
```Hans-Nikolai ViessmannHans-Nikolai Viessmannhttps://gitlab.sac-home.org/sac-group/sac2c/-/issues/2320Building a C mt-pth library and running it only makes use of one thread2022-12-21T10:10:19ZRowan GoemansBuilding a C mt-pth library and running it only makes use of one threadCreating an `mt_pth` C library and calling it results in the following warning:
```
*** SAC runtime warning
*** In Sum__sum1: there was no hive attached to the calling thread!
Created a temporary hive of one. The warning will not be...Creating an `mt_pth` C library and calling it results in the following warning:
```
*** SAC runtime warning
*** In Sum__sum1: there was no hive attached to the calling thread!
Created a temporary hive of one. The warning will not be repeated for this function.
```
Looking into the process with `ps -T -p <pid>` shows only a single running thread.
I have created a tiny reproducer [here](https://gitlab.sac-home.org/RowanG/sac-from-c-mt-pth-one-thread/-/tree/master). Run `build.sh` to build the code and run it.https://gitlab.sac-home.org/sac-group/sac2c/-/issues/2318SCCF bug on prf _take_SxV_2022-11-05T12:41:08ZSven-Bodo ScholzSCCF bug on prf _take_SxV_Using sac2c `sac2c 1.3.3-MijasCosta-1001-gb33d6 build-type: DEBUG`
when run with `-check tc -v3 -#d,CF`
on the following program:
```
int main()
{
return _reshape_VxA_ (_take_SxV_ (0, []), 42);
}
```
crashes in SCCF with:
```
** 9: ...Using sac2c `sac2c 1.3.3-MijasCosta-1001-gb33d6 build-type: DEBUG`
when run with `-check tc -v3 -#d,CF`
on the following program:
```
int main()
{
return _reshape_VxA_ (_take_SxV_ (0, []), 42);
}
```
crashes in SCCF with:
```
** 9: Enhancing with-loops ...
**** Introducing explicit accumulators ...
**** Adding default partitions ...
**** Applying constant folding ...
CFfundef: CF: traversing body of (fundef) main
CFlet: CF: Looking at LHS: _flat_4
CFlet: CF: Looking at LHS: _flat_3
CFarray: CF: CFarray looking at _flat_3
CFlet: CF: Looking at LHS: _flat_2
CFlet: CF: Looking at LHS: _flat_1
CFprf: CF: evaluating prf _take_SxV_
CFprf: CF: trying SCS...
CFprf: CF: not applicable
CFprf: CF: trying SCCF...
OOOOOOOPS, your program crashed the compiler 8-((
```https://gitlab.sac-home.org/sac-group/sac2c/-/issues/2317dynamic TYPE_ERROR code generation bug2022-11-04T21:44:53ZSven-Bodo Scholzdynamic TYPE_ERROR code generation bugThe attached program [TEbug.sac](/uploads/7b8c54e458c4e098460725f8e25c6887/TEbug.sac), when compiled with `sac2c TEbug.sac` using `sac2c 1.3.3-MijasCosta-1001-gb33d6` yields erroneous C code:
```
/Volumes/Users/sbs/Dropbox/BodoSac/escien...The attached program [TEbug.sac](/uploads/7b8c54e458c4e098460725f8e25c6887/TEbug.sac), when compiled with `sac2c TEbug.sac` using `sac2c 1.3.3-MijasCosta-1001-gb33d6` yields erroneous C code:
```
/Volumes/Users/sbs/Dropbox/BodoSac/escience/microHH/a.out.c:2986:22: warning: missing terminating '"' character [-Winvalid-pp-token]
SAC_TYPE_ERROR("./TYBUG.sac:10: error:
^
/Volumes/Users/sbs/Dropbox/BodoSac/escience/microHH/a.out.c:2988:1: warning: missing terminating '"' character [-Winvalid-pp-token]
")
^
/Volumes/Users/sbs/Dropbox/BodoSac/escience/microHH/a.out.c:2986:7: error: unterminated function-like macro invocation
SAC_TYPE_ERROR("./TYBUG.sac:10: error:
^
/Volumes/Users/sbs/sac2c/build_p/include/runtime/essentials_h/errors.h:23:9: note: macro 'SAC_TYPE_ERROR' defined here
#define SAC_TYPE_ERROR(message) SAC_RuntimeError (message);
^
2 warnings and 1 error generated.
Abort:
```
The offending code contains newlines instead of \n's:
```
SAC_TYPE_ERROR("./TYBUG.sac:10: error:
lower bound of with loop should be an integer vector; type found: int
")
```
I suspect that this broke during the error messaging revamp....Michiel VerloopMichiel Verloophttps://gitlab.sac-home.org/sac-group/sac2c/-/issues/2316WLSIMP leads to wrong results; bug in SCSisRelationalOnDyadicFn2022-10-31T13:53:18ZSven-Bodo ScholzWLSIMP leads to wrong results; bug in SCSisRelationalOnDyadicFnWhen compiling and running the following code using `sac2c WLSIMP-bug.sac ; ./a.out ; echo $?` we obtain `11`.
When using `sac2c WLSIMP-bug.sac -noWLSIMP; ./a.out ; echo $?` we obtain the correct `42`.
I use the latest release compiler ...When compiling and running the following code using `sac2c WLSIMP-bug.sac ; ./a.out ; echo $?` we obtain `11`.
When using `sac2c WLSIMP-bug.sac -noWLSIMP; ./a.out ; echo $?` we obtain the correct `42`.
I use the latest release compiler `sac2c 1.3.3-MijasCosta-926-gec84e9`.
```
noinline
int[12,10] interp2x (int[12,10] phi, int[2] boundary_sizes)
{
// if the following line is inserted, the bug disappears!
// boundary_sizes = [1,1];
return with {
(boundary_sizes <= iv < _sub_VxV_( [12,10], boundary_sizes) ) : _sel_VxA_ (iv,interp2x (phi)) ;
} : modarray (phi);
}
inline
int[11,9] interp2x (int[12,10] phi)
{
return with {
( . <= [i,j] <= .) : 42;
} : genarray ([11,9], 0);
}
int main()
{
v = with {
([0,0] <= [i,j] <[12,10]) : _add_SxS_(_mul_SxS_(i,10),j);
} : genarray ( [12,10], 0);
v2 = interp2x (v, [1,1]);
// return value should be 42, not 11!
return (_sel_VxA_([1,1], v2));
}
```https://gitlab.sac-home.org/sac-group/sac2c/-/issues/2314Problem triggering rtspec2022-05-20T13:02:16ZThomas KoopmanProblem triggering rtspecI have a problem compiling the compiler on Ubuntu 22.04, giving the following error
```
/tmp/SAC_2Ha0OL/fun1.c: In function ‘SACwf_counter__init_theCounter__SACt_counter__counter’:
/tmp/SAC_2Ha0OL/fun1.c:134:5: warning: implicit declara...I have a problem compiling the compiler on Ubuntu 22.04, giving the following error
```
/tmp/SAC_2Ha0OL/fun1.c: In function ‘SACwf_counter__init_theCounter__SACt_counter__counter’:
/tmp/SAC_2Ha0OL/fun1.c:134:5: warning: implicit declaration of function ‘SAC_WE_DECL_REG_FLAG’ [-Wimplicit-function-declaration]
134 | SAC_WE_DECL_REG_FLAG()
| ^~~~~~~~~~~~~~~~~~~~
/tmp/SAC_2Ha0OL/fun1.c:134:27: error: expected ‘;’ before ‘SAC_WE_DECL_REG_OBJ’
134 | SAC_WE_DECL_REG_FLAG()
| ^
| ;
135 | SAC_WE_DECL_REG_OBJ()
| ~~~~~~~~~~~~~~~~~~~
/tmp/SAC_2Ha0OL/fun1.c:170:1: warning: implicit declaration of function ‘SAC_WE_FUN_DEF_END2’ [-Wimplicit-function-declaration]
170 | SAC_WE_FUN_DEF_END2()
| ^~~~~~~~~~~~~~~~~~~
/tmp/SAC_2Ha0OL/fun1.c:170:22: error: expected ‘;’ before ‘void’
170 | SAC_WE_FUN_DEF_END2()
| ^
| ;
/tmp/SAC_2Ha0OL/fun1.c:472:1: error: expected declaration or statement at end of input
472 | SAC_ND_FUN_DEF_END2()
| ^
```
The RTSPEC is off, and the RTSPECmode is simple.https://gitlab.sac-home.org/sac-group/sac2c/-/issues/2310var is used before its value is set, related MMV2022-06-13T21:38:44ZHans-Nikolai Viessmannvar is used before its value is set, related MMVI've been having a go today getting a instrumentation tool called Score_P (https://www.vi-hps.org/projects/score-p) working with sac2c compiled CUDA code and ran into a funny problem.
With the following example (based on matmul from dem...I've been having a go today getting a instrumentation tool called Score_P (https://www.vi-hps.org/projects/score-p) working with sac2c compiled CUDA code and ran into a funny problem.
With the following example (based on matmul from demos):
```sac
#ifndef SIZE1
#define SIZE1 1000
#endif
#ifndef SIZE2
#define SIZE2 1000
#endif
#ifndef SIZE3
#define SIZE3 1000
#endif
inline double[+] genarray (int[.] shp, double def)
{
return with {} : genarray (shp, def);
}
inline int[.] shape(double[*] a) { return _shape_A_ (a); }
inline int[*] sel( int[.] idx, int[*] array)
{
new_shape = _drop_SxV_( _sel_VxA_( [0], _shape_A_(idx)),
_shape_A_(array));
res = with {
( . <= iv <= . ) {
new_idx = _cat_VxV_( idx, iv);
} : _sel_VxA_(new_idx, array);
} : genarray( new_shape, 0);
return( res);
}
inline double[*] sel( int[.] idx, double[*] array)
{
new_shape = _drop_SxV_( _sel_VxA_( [0], _shape_A_(idx)),
_shape_A_(array));
res = with {
( . <= iv <= . ) {
new_idx = _cat_VxV_( idx, iv);
} : _sel_VxA_(new_idx, array);
} : genarray( new_shape, 0d);
return( res);
}
inline double[*] sel(int shp, double[*] a) { return sel([shp], a); }
inline int[*] sel(int shp, int[*] a) { return sel([shp], a); }
inline bool <(int a, int b) { return _lt_SxS_ (a,b); }
inline bool <=(int a, int b) { return _le_SxS_ (a,b); }
inline double *(double a, double b) { return _mul_SxS_ (a, b); }
inline double[+] *(double[+] a, double[+] b)
{
return with {
(_mul_SxV_ (0, _shape_A_ (a)) <= iv < _shape_A_(a))
: _sel_VxA_ (iv, a) * _sel_VxA_ (iv, b);
} : modarray (a);
}
inline double +(double a, double b) { return _add_SxS_ (a, b); }
inline double[+] +(double[+] a, double[+] b)
{
return with {
(_mul_SxV_ (0, _shape_A_ (a)) <= iv < _shape_A_(a))
: _sel_VxA_ (iv, a) + _sel_VxA_ (iv, b);
} : modarray (a);
}
/** set this to noinline to get rid of the error **/
inline double[*] sum (double[+] a)
{
return with {
( _mul_SxV_(0, _shape_A_(a)) <= iv < _shape_A_(a) )
: _sel_VxA_(iv, a);
} : fold( +, 0.0d);
}
inline double[+] reverse( double[+] arr_a)
{
maxidx0 = _sub_SxS_( _sel_VxA_( [0], _shape_A_( arr_a)), 1);
res = with {
( [0] <= iv = [i] <= [maxidx0] ) : arr_a[[_sub_SxS_(maxidx0, i)]];
} : modarray( arr_a );
return( res);
}
inline int[+] reverse( int[+] arr_a)
{
maxidx0 = _sub_SxS_( _sel_VxA_( [0], _shape_A_( arr_a)), 1);
res = with {
( [0] <= iv = [i] <= [maxidx0] ) : arr_a[[_sub_SxS_(maxidx0, i)]];
} : modarray( arr_a );
return( res);
}
double[+] transpose( double[+] arr_a)
{
res = with {
( . <= iv <= . ) : arr_a[ reverse( iv)];
} : genarray( reverse( _shape_A_( arr_a)), 1.0);
return( res);
}
double[.,.] matmul( double[SIZE1,SIZE2] A, double[SIZE2,SIZE3] B)
{
BT = transpose( B);
C = with {
//#pragma wlcomp BvL0( [32,32], Default)
( . <= [i,j] <= .) : sum( A[[i]] * BT[[j]]);
}: genarray( [ shape(A)[[0]], shape(B)[[1]] ], 1.0);
return( C);
}
int main()
{
A = genarray( [SIZE1,SIZE2], 1.0);
B = genarray( [SIZE2,SIZE3], 2.0);
C = matmul( A, B);
StdIO::printf( "C[0,0] = %f\n", C[0,0]);
return 0;
}
```
I get the following error message:
```sh
/tmp/sac-what/ci.out.cu(1562): warning #549-D: variable "SACp_pinl_818__flat_19" is used before its value is set
...
```
It is coming from the matmul function...
If we look at the code at phase 20 (PC), we get this for the matmul function:
```c
void _MAIN::SACf__MAIN__matmul__d_1000_1000__d_1000_1000( double[1000,1000] { ,NN } , double[1000,1000] SACl_A { ,NN } , double[1000,1000] SACl_B { ,NN } )
{
double SACp_emal_3476__pinl_1299__flat_82 { , NN } = 1.0;
int SACp_emal_3474__ivesli_3316 { , NN, USAGE: 2 } ;
double SACp_emal_3473__pinl_1304__flat_22 { , NN, USAGE: 3 } ;
double[1000,1000] SACp_emal_3472_BT { , NN, USAGE: 2 } ;
double SACp_emal_3471__pinl_818__flat_19 { , NN } = 0.0;
... // vardecs omitted
double{0.0...} SACp_pinl_818__flat_19 { , NN } ;
int SACp_pinl_878__eat_172 { , NN, USAGE: 1 } ;
int[1] SACp_pinl_876_iv { , NN } ;
double SACp_flat_126 { , NN, USAGE: 4 } ;
int SACl_j { , NN, USAGE: 1 } ;
int SACl_i { , NN, USAGE: 1 } ;
int[2] SACp_flat_125 { , NN } ;
... // some code is omitted here
SACp_emal_3457_C = with2 (SACp_flat_125=[SACl_i, SACl_j] (IDXS:SACp_wlidx_3288_C))
/********** operators: **********/
op_0 =
{
_inc_rc_( SACp_emal_3471__pinl_818__flat_19, 1); // XXX
SACp_emal_3466__ivesli_3311 = _alloc_( 1, 0, [:int]);
SACp_emal_3466__ivesli_3311 = _idxs2offset_( [ 1000, 1000 ], SACl_j, SACp_emal_3470__iveras_3429);
SACp_emal_3465__ivesli_3306 = _alloc_( 1, 0, [:int]);
SACp_emal_3465__ivesli_3306 = _idxs2offset_( [ 1000, 1000 ], SACl_i, SACp_emal_3469__iveras_3430);
SACp_pinl_878__eat_172 = _alloc_( 1, 0, [:int]);
SACp_flat_126 = with2 (SACp_pinl_876_iv=[SACp_pinl_878__eat_172])
/********** operators: **********/
op_0 =
{
SACp_flat_126 = _accu_( SACp_pinl_876_iv, SACp_pinl_818__flat_19); // XXX WTF?!
SACp_emal_3464__ivesli_3313 = _alloc_( 1, 0, [:int]);
SACp_emal_3464__ivesli_3313 = _idxs2offset_( [ 1000, 1000 ], SACp_emal_3468__iveras_3431, SACp_pinl_878__eat_172);
SACp_emal_3463__ivesli_3314 = _alloc_( 1, 0, [:int]);
SACp_emal_3463__ivesli_3314 = _add_SxS_( SACp_emal_3466__ivesli_3311, SACp_emal_3464__ivesli_3313);
SACp_emal_3462__pinl_821__flat_22__SSA7_1 = _alloc_( 1, 0, [:int]);
SACp_emal_3462__pinl_821__flat_22__SSA7_1 = _idx_sel_( SACp_emal_3463__ivesli_3314, SACp_emal_3472_BT);
_free_( SACp_emal_3463__ivesli_3314);
SACp_emal_3464__ivesli_3313 = _add_SxS_( SACp_emal_3465__ivesli_3306, SACp_emal_3464__ivesli_3313);
SACp_emal_3460__pinl_839__flat_22__SSA5_2 = _alloc_( 1, 0, [:int]);
SACp_emal_3460__pinl_839__flat_22__SSA5_2 = _idx_sel_( SACp_emal_3464__ivesli_3313, SACl_A);
_free_( SACp_emal_3464__ivesli_3313);
SACp_emal_3462__pinl_821__flat_22__SSA7_1 = _mul_SxS_( SACp_emal_3462__pinl_821__flat_22__SSA7_1, SACp_emal_3460__pinl_839__flat_22__SSA5_2);
_free_( SACp_emal_3460__pinl_839__flat_22__SSA5_2);
SACp_emal_3462__pinl_821__flat_22__SSA7_1 = _add_SxS_( SACp_emal_3462__pinl_821__flat_22__SSA7_1, SACp_flat_126);
_dec_rc_( SACp_flat_126, 1);
SACp_ufiv_3433__pinl_881__flat_38 = _unshare_( SACp_emal_3462__pinl_821__flat_22__SSA7_1, SACp_pinl_876_iv);
SACp_flat_126 = SACp_ufiv_3433__pinl_881__flat_38;
} : SACp_flat_126 ;
/********** segment 0: **********
* index domain: [ 0 ] -> [ 1000 ]
* bv: [ 1 ], [ 1 ], [ 1 ]
* ubv: [ 1 ]
* sv: [ 1 ]
* homsv: [ 1 ]
*/
(0 -> 1000), step0[0] 1
(0 --> 1): op_0
/********** conexpr: **********/
fold( _MAIN::SACf__MAIN___PL__d__d(), SACp_emal_3471__pinl_818__flat_19);
_free_( SACp_pinl_878__eat_172);
_free_( SACp_emal_3465__ivesli_3306);
_free_( SACp_emal_3466__ivesli_3311);
SACp_flat_126 = _wl_assign_( SACp_flat_126, SACp_emal_3457_C, SACp_flat_125, SACp_wlidx_3288_C);
_dec_rc_( SACp_flat_126, 1);
} : SACp_flat_126 ;
/********** segment 0: **********
* index domain: [ 0, 0 ] -> [ 1000, 1000 ]
* bv: [ 1, 1 ], [ 1, 1 ], [ 1, 1 ]
* ubv: [ 1, 1 ]
* sv: [ 1, 1 ]
* homsv: [ 1, 1 ]
*/
(0 -> 1000), step0[0] 1
(0 --> 1):
(0 -> 1000), step0[1] 1
(0 --> 1): op_0
/********** conexpr: **********/
genarray( [ 1000, 1000 ], SACp_emal_3476__pinl_1299__flat_82, SACp_emal_3457_C, IDX(SACp_wlidx_3288_C));
_free_( SACp_emal_3476__pinl_1299__flat_82);
_free_( SACp_emal_3472_BT);
_free_( SACl_i);
_free_( SACl_j);
_free_( SACp_emal_3471__pinl_818__flat_19);
_free_( SACp_wlidx_3288_C);
_free_( SACp_emal_3470__iveras_3429);
_free_( SACp_emal_3469__iveras_3430);
_free_( SACp_emal_3468__iveras_3431);
_dec_rc_( SACl_A, 1);
return( SACp_emal_3457_C);
}
```
Notice that we have two `*pinl_818__flat_19` variables declared, **but** only one of them is actually initialised. Also **note** that in the with2 (fold operation) the accumulator is using `_pinl_818__flat_19`... this is where our error message is coming from. If we step through the optimisation in PC we find that before MMV, we have the following in the function:
```c
_emal_3471__pinl_818__flat_19 = _alloc_( 1, 0, [:int]);
_pinl_818__flat_19 = _fill_( 0.0, _emal_3471__pinl_818__flat_19);
```
After MMV, the `_fill_()` is gone, instead all references of `_pinl_818__flat_19` are replaced with `_emal_3471__pinl_818__flat_19` **except** in the accumulator in the with2.
Initially I thought this was specific to the CUDA backend, but a this happens with **ALL BACKENDS** for the given example!!!
A quick solution is to traverse the 2nd argument of the `prf_accu`, but I'm unsure if this is the correct thing to do generally....
It's really funny that only NVCC actually issues a message about this, GCC/CLANG make no noise (I wonder if we are disabling some warning :scream:).Hans-Nikolai ViessmannHans-Nikolai Viessmannhttps://gitlab.sac-home.org/sac-group/sac2c/-/issues/2309type checker run-time error on character arrays2022-03-06T15:26:23ZRobert Berneckytype checker run-time error on character arrays```
cat UTThornReal.sac
module UTThornReal;
export {UTThornReal_testXXI};
use Array: all;
use ArrayFormat: all;
use StdIO:{show};
inline int UTThornReal_testXXI()
{
A_48=format( -2.5);
show(A_48);
return(1);
}
apex@medusa:/tmp/cr...```
cat UTThornReal.sac
module UTThornReal;
export {UTThornReal_testXXI};
use Array: all;
use ArrayFormat: all;
use StdIO:{show};
inline int UTThornReal_testXXI()
{
A_48=format( -2.5);
show(A_48);
return(1);
}
apex@medusa:/tmp/crud/XX$ cat UTThornReal.unittest.sac
use UTThornReal: all;
int main()
{
z = UTThornReal_testXXI();
return(z);
}
apex@medusa:/tmp/crud/XX$ sac2c UTThornReal.sac
apex@medusa:/tmp/crud/XX$ sac2c UTThornReal.unittest.sac
apex@medusa:/tmp/crud/XX$ a.out
___[] SACp_pinl_4385_z
*** SAC runtime error
*** //primarypool/dshome/apex/apexgit/Ancillary/benchmks/UnitTests/UTThornReal/src/UTThornReal.sac:385
Can not assign unsigned char[+] SACp_pinl_4385_z to unsigned char[.] SACp_pinl_4173_A_61 type mismatch
```
```
sac2c -V
sac2c 1.3.3-MijasCosta-782-g8e7b0
build-type: RELEASE
built-by: "sac" at 2022-03-01T09:11:54
```https://gitlab.sac-home.org/sac-group/sac2c/-/issues/2308empty error message triggered by wrong conformity check when using -ecc2022-03-09T14:05:01ZRobert Berneckyempty error message triggered by wrong conformity check when using -ecc```
**** Optimization cycle pass: 3
****** Optimizing regular function:
****** _MAIN::main( hidden, hidden, hidden): ...
Applying common subexpression elimination ...
Determine candidate functions for inlin...```
**** Optimization cycle pass: 3
****** Optimizing regular function:
****** _MAIN::main( hidden, hidden, hidden): ...
Applying common subexpression elimination ...
Determine candidate functions for inlining ...
Inferring loop invariant variables ...
Applying type upgrade ...
Eliminating Type Variables ...
Eliminating Bottom Types ...
compilation failed while Running SAC optimizations.
apex@medusa:/tmp/crud$ sac2c_d UTCompress.sac -ecc -v4
cat UTCompress.sac
use Array: all;
use ArrayFormat: all;
use StdIO : all;
inline int[+] slBII(bool x, int[+] y)
{ // Boolean scalar compress non-scalar
sy = shape(y);
zs = sy;
zs[dim(y)-1] = toi(x) * zs[dim(y)-1];
z = take(zs, y);
z = (true == x) ? y : genarray(drop([-1],sy)++[0],0);
return(z);
}
// inline int UTCompress_testXXI()
int main()
{
TEN=genarray([2, 3, 4],66);
A_141=genarray([2, 3, 0],false);
A_142=slBII(false, TEN);
show(A_142);
return(0);
}
apex@medusa:/tmp/crud$ sac2c -V
sac2c 1.3.3-MijasCosta-782-g8e7b0
build-type: RELEASE
built-by: "sac" at 2022-03-01T09:11:54
```Robert BerneckyRobert Berneckyhttps://gitlab.sac-home.org/sac-group/sac2c/-/issues/2307-doemrci gives different (wrong) result from -noemrci in LivermoreLoop loop082022-06-16T15:53:00ZRobert Bernecky-doemrci gives different (wrong) result from -noemrci in LivermoreLoop loop08The various variants of loop08 break in different ways.
In the following, an exit code of 0 means success, and 1 means failure.
Here is one example:
```
sac@medusa:~/sac/benchmarks/LivermoreLoopsCtest/build$ sac2c_d ../loop08/loop08.sa...The various variants of loop08 break in different ways.
In the following, an exit code of 0 means success, and 1 means failure.
Here is one example:
```
sac@medusa:~/sac/benchmarks/LivermoreLoopsCtest/build$ sac2c_d ../loop08/loop08.sac -DVARIANT=APL -doemrci -O3 -v0
sac@medusa:~/sac/benchmarks/LivermoreLoopsCtest/build$ time a.out -mt 0 1000000; echo $?
Running Loop8_APL
Number of repetitions: 1000000
Iteration space size : 100
Element [1] of the result is: 81.5; should be 156
Wall Clock Time spent : 17.770 secs
Computer Performance achieved : 0.401 GFlops/s
real 0m17.772s
user 0m17.771s
sys 0m0.000s
1
sac@medusa:~/sac/benchmarks/LivermoreLoopsCtest/build$ sac2c_d ../loop08/loop08.sac -DVARIANT=APL -noemrci -O3 -v0
sac@medusa:~/sac/benchmarks/LivermoreLoopsCtest/build$ time a.out -mt 0 1000000; echo $?
Running Loop8_APL
Number of repetitions: 1000000
Iteration space size : 100
sac2c_d -VElement [1] of the result is: 156; should be 156
Wall Clock Time spent : 17.656 secs
Computer Performance achieved : 0.404 GFlops/s
real 0m17.658s
user 0m17.656s
sys 0m0.000s
0
sac@medusa:~/sac/benchmarks/LivermoreLoopsCtest/build$ sac2c_d -V
sac2c 1.3.3-MijasCosta-782-g8e7b0
build-type: DEBUG
built-by: "sac" at 2022-03-01T09:10:39
```Hans-Nikolai ViessmannHans-Nikolai Viessmannhttps://gitlab.sac-home.org/sac-group/sac2c/-/issues/2306parser and modules seems broken2022-02-27T20:44:13ZSven-Bodo Scholzparser and modules seems brokenI try this
```
use StdIO: all;
noinline
Termfile::Termfile foo( Termfile::Termfile f)
{
fprintf ( f, "hello\n");
return f;
}
int main()
{
TermFile::stdin = foo( TermFile::stdin);
return 0;
}
```
on
```
-sbs-Bodos-IMac->...I try this
```
use StdIO: all;
noinline
Termfile::Termfile foo( Termfile::Termfile f)
{
fprintf ( f, "hello\n");
return f;
}
int main()
{
TermFile::stdin = foo( TermFile::stdin);
return 0;
}
```
on
```
-sbs-Bodos-IMac-> sac2c-d -V
sac2c 1.3.3-MijasCosta-778-gd0f9f
build-type: DEBUG
built-by: "sbs" at 2022-02-27T18:09:33
```
and I get
```
sac2c-d simple.sac
** 1: Loading SAC program ...
./simple.sac:4:11: error:
=> cannot load module `Termfile'!
./simple.sac:4:1: error:
=> type expected, `Termfile' found
./simple.sac:15:1: error:
=> function body or semicolon expected
abort: Failed to construct a syntax tree for `simple.sac'
compilation failed while Loading SAC program, 3 error(s).
```
I guess the problem is that StdIO already brings Termfile.....
but that error message does not make any sense, does it?Hans-Nikolai ViessmannHans-Nikolai Viessmannhttps://gitlab.sac-home.org/sac-group/sac2c/-/issues/2304WLUR and foldfix2023-05-09T15:04:48ZSven-Bodo ScholzWLUR and foldfixWLUR is not foldfix aware....
```
noinline
int[*] add ( int[*] a, int[*] b)
{ return _add_SxS_ ( a, _sel_VxA_([0], b)); }
int main()
{
shp = [4];
a = with {
(_mul_SxV_(0,shp) <= iv < shp) : iv;
} : foldfix( a...WLUR is not foldfix aware....
```
noinline
int[*] add ( int[*] a, int[*] b)
{ return _add_SxS_ ( a, _sel_VxA_([0], b)); }
int main()
{
shp = [4];
a = with {
(_mul_SxV_(0,shp) <= iv < shp) : iv;
} : foldfix( add, 0, 1);
// should return 1 and *not* 6!
return a;
}
```
with
```
sac2c -V
sac2c 1.3.3-MijasCosta-771-g499e7
build-type: RELEASE
built-by: "sbs" at 2022-02-20T11:53:21
```
behaves like this:
```
sac2c error3.sac -noWLUR -noprelude
warning: With-Loop unrolling (WLUR) was disabled using the command line. However, unrolling of single-trip with-loops is required for code generation. Therefore, WLUR will be re-enabled with the maximum number of
warning: unrolling steps set to 1.
-sbs-Bodos-IMac-> ./a.out ; echo $?
1
-sbs-Bodos-IMac-> sac2c error3.sac -noprelude
-sbs-Bodos-IMac-> ./a.out ; echo $?
6
```https://gitlab.sac-home.org/sac-group/sac2c/-/issues/2303resolving global objects bug2022-03-01T21:01:26ZSven-Bodo Scholzresolving global objects bugThe following code
```
int main()
{
shp = [1];
with {
(_mul_SxV_(0,shp) <= iv < shp) {StdIO::print(iv); } : StdIO::stdin;
} : propagate(StdIO::stdin) ;
return 0;
}
```
crashes
```
sac2c -V
sac2c 1.3.3-Mija...The following code
```
int main()
{
shp = [1];
with {
(_mul_SxV_(0,shp) <= iv < shp) {StdIO::print(iv); } : StdIO::stdin;
} : propagate(StdIO::stdin) ;
return 0;
}
```
crashes
```
sac2c -V
sac2c 1.3.3-MijasCosta-771-g499e7
build-type: RELEASE
built-by: "sbs" at 2022-02-20T11:53:21
```
in he debug version with v4, we learn:
```
** 5: Converting to static single assignment form ...
**** Inserting variable declarations ...
**** Converting type decls into type conversions ...
**** Creating wrapper functions ...
**** Running global object analysis ...
**** Generating global object initialiser ...
**** Resolving global objects ...
TRAVERSE ERROR: node of type 94:N_globobj found where 32:N_id was expected!
OOOOOOOPS, your program crashed the compiler 8-((
```https://gitlab.sac-home.org/sac-group/sac2c/-/issues/2302parser does not support void with-loops2022-05-04T13:30:04ZSven-Bodo Scholzparser does not support void with-loopsThe following program is rejected:
```
int main()
{
with {
( [0] <= iv < [15]) { StdIO::print(iv); } : void;
} : void;
return 0;
}
```
when compiling with
```
sac2c 1.3.3-MijasCosta-771-g499e7
build-type: RELE...The following program is rejected:
```
int main()
{
with {
( [0] <= iv < [15]) { StdIO::print(iv); } : void;
} : void;
return 0;
}
```
when compiling with
```
sac2c 1.3.3-MijasCosta-771-g499e7
build-type: RELEASE
built-by: "sbs" at 2022-02-20T11:53:21
```
we get:
```
./error.sac:4:53: error:
=> expression expected
abort: Failed to construct a syntax tree for `error.sac'
compilation failed while Loading SAC program, 1 error(s).
```Artem ShinkarovArtem Shinkarovhttps://gitlab.sac-home.org/sac-group/sac2c/-/issues/2300Debug version of sac2c no longer prints details, by default.2022-02-24T19:49:57ZRobert BerneckyDebug version of sac2c no longer prints details, by default.```
sac2c_d UTReplicate.unittest.sac
** 1: Loading SAC program ...
** 2: Preprocessing SAC program ...
** 3: Running module system ...
** 4: Simplifying source code ...
** 5: Converting to static single assignment form ...
** 6: ...```
sac2c_d UTReplicate.unittest.sac
** 1: Loading SAC program ...
** 2: Preprocessing SAC program ...
** 3: Running module system ...
** 4: Simplifying source code ...
** 5: Converting to static single assignment form ...
** 6: Running type inference system ...
** 7: Processing exports ...
** 8: Preparing for code optimization ...
** 9: Enhancing with-loops ...
** 10: Running SAC optimizations ...
** 11: Automatic parallelisation for GPUs skipped.
** 12: Transforming with-loop representation ...
** 13: Running 3rd generation multithreading skipped.
** 14: Introducing task parallelization skipped.
** 15: Introducing memory management instructions ...
** 16: Introduce profiling instruction ...
** 17: Preparing for distributed memory execution skipped.
** 18: Converting from static single assignment form ...
** 19: Running automatic parallelisation skipped.
** 20: Preparing C code generation ...
** 21: Generating Code ...
** 22: Creating binary code ...
** 23: Profiling report skipped.
```
```
sac2c_d -V
sac2c 1.3.3-MijasCosta-774-g4dc6e2
build-type: DEBUG
built-by: "sac" at 2022-02-24T14:22:23
```https://gitlab.sac-home.org/sac-group/sac2c/-/issues/2298Code generation for Multi-Operator WL initialisation problem2022-02-28T20:40:01ZSven-Bodo ScholzCode generation for Multi-Operator WL initialisation problemThe following code, when compiled with `-noprelude` using
```
-sbs-Bodos-IMac-> sac2c -V
sac2c 1.3.3-MijasCosta-771-g499e7
build-type: RELEASE
built-by: "sbs" at 2022-02-20T11:53:21
```
```
int[*], int[*] scanP( int[*] a)
{
shp = _...The following code, when compiled with `-noprelude` using
```
-sbs-Bodos-IMac-> sac2c -V
sac2c 1.3.3-MijasCosta-771-g499e7
build-type: RELEASE
built-by: "sbs" at 2022-02-20T11:53:21
```
```
int[*], int[*] scanP( int[*] a)
{
shp = _shape_A_(a);
a, tots = with {
(_mul_SxV_(0,shp) <= iv < shp) : (0,1);
} : ( genarray( shp, 32), genarray( shp, 0));
return (a,tots);
}
noinline
int[*] hide( int x)
{
return (_eq_SxS_( x, 0) ? 0 : [1,1] );
}
int main()
{
a = hide ( 42);
b,c = scanP (a);
return c;
}
```
leads to an uninitialised wlidx variable:
```
-sbs-Bodos-IMac-> sac2c new_error.sac
/Volumes/Users/sbs/Dropbox/BodoSac/scan/a.out.c:1491:24: warning: variable 'SACp_wlidx_2109_c' is uninitialized when used here [-Wuninitialized]
{ SACp_emal_2243_c[SACp_wlidx_2109_c] = SACp_emal_2249__pinl_79__flat_6; };
^~~~~~~~~~~~~~~~~
/Volumes/Users/sbs/Dropbox/BodoSac/scan/a.out.c:1301:26: note: initialize the variable 'SACp_wlidx_2109_c' to silence this warning
int SACp_wlidx_2109_c;
^
= 0
1 warning generated.
```https://gitlab.sac-home.org/sac-group/sac2c/-/issues/2297Livermore loops kills sa2c when compiling with -DVARIANT=APL2022-02-24T19:16:03ZRobert BerneckyLivermore loops kills sa2c when compiling with -DVARIANT=APL```
~/sac/benchmarks/LivermoreLoops/loop08$ sac2c loop08.sac -DVARIANT=APL
/home/sac/sac/BASE/Stdlib/src/structures/ArrayTransform.xsac 423 error: SSATid: Variable _emrl_21653_emr_lifted used without definition
/home/sac/sac/BASE/Stdlib...```
~/sac/benchmarks/LivermoreLoops/loop08$ sac2c loop08.sac -DVARIANT=APL
/home/sac/sac/BASE/Stdlib/src/structures/ArrayTransform.xsac 423 error: SSATid: Variable _emrl_21653_emr_lifted used without definition
/home/sac/sac/BASE/Stdlib/src/structures/ArrayTransform.xsac 423 error: SSATid: Variable _emrl_21654_emr_lifted used without definition
/home/sac/sac/BASE/Stdlib/src/structures/ArrayTransform.xsac 423 error: SSATid: Variable _emrl_21655_emr_lifted used without definition
/home/sac/sac/BASE/Stdlib/src/structures/ArrayTransform.xsac 423 error: SSATid: Variable _emrl_21656_emr_lifted used without definition
/home/sac/sac/BASE/Stdlib/src/structures/ArrayTransform.xsac 423 error: SSATid: Variable _emrl_21657_emr_lifted used without definition
/home/sac/sac/BASE/Stdlib/src/structures/ArrayTransform.xsac 423 error: SSATid: Variable _emrl_21658_emr_lifted used without definition
/home/sac/sac/BASE/Stdlib/src/structures/ArrayTransform.xsac 423 error: SSATid: Variable _emrl_21659_emr_lifted used without definition
/home/sac/sac/BASE/Stdlib/src/structures/ArrayTransform.xsac 423 error: SSATid: Variable _emrl_21661_emr_lifted used without definition
/home/sac/sac/BASE/Stdlib/src/structures/ArrayTransform.xsac 423 error: SSATid: Variable _emrl_21663_emr_lifted used without definition
compilation failed while Transforming with-loop representation, 9 error(s).
```
```
sac@medusa:~/sac/benchmarks/LivermoreLoops/loop08$ sac2c -V
sac2c 1.3.3-MijasCosta-771-g499e7
build-type: RELEASE
built-by: "sac" at 2022-02-22T17:12:53
```Hans-Nikolai ViessmannHans-Nikolai Viessmannhttps://gitlab.sac-home.org/sac-group/sac2c/-/issues/2295testing when two files are needed2022-03-05T07:43:12ZSven-Bodo Scholztesting when two files are neededI need a class and a program to produce the error. It seems creating a suitable test is not quite possible, is it?I need a class and a program to produce the error. It seems creating a suitable test is not quite possible, is it?Artem ShinkarovArtem Shinkarov