sac2c issueshttps://gitlab.sac-home.org/sac-group/sac2c/-/issues2023-11-23T11:28:49Zhttps://gitlab.sac-home.org/sac-group/sac2c/-/issues/2346Phase memrt fails2023-11-23T11:28:49ZThomas KoopmanPhase memrt failsCompiled with `sac2c -t cuda`, fails in phase memrt, node prf.
Version
```
sac2c 1.3.3-MijasCosta-1079-g648dba-dirty
build-type: DEBUG
built-by: "thomas" at 2023-10-11T13:56:05
```
dirty only because I added extra debug prints.
```
...Compiled with `sac2c -t cuda`, fails in phase memrt, node prf.
Version
```
sac2c 1.3.3-MijasCosta-1079-g648dba-dirty
build-type: DEBUG
built-by: "thomas" at 2023-10-11T13:56:05
```
dirty only because I added extra debug prints.
```
#define N 32
inline
double[*] coarse2fine (double[*] z)
{
// return {iv -> z[(iv - 1) / 2] | [1, 1, 1] <= iv < 2 * shape(z) step [2, 2, 2] };
new_shp = _mul_SxV_(2, _shape_A_(z));
return with {
([1, 1, 1] <= iv < new_shp step [2, 2, 2]):
_sel_VxA_(_div_VxS_(_sub_VxV_(iv,
[1, 1, 1]),
2),
z);
}: genarray(new_shp, 0d);
}
inline
double[*] fine2coarse(double[*] r)
{
// return {iv -> r[2 * iv + 1] | iv < shape(r) / 2};
new_shp = _div_VxV_(_shape_A_(r), [2, 2, 2]);
return with {
([0, 0, 0] <= iv < new_shp):
_sel_VxA_(
_add_VxV_(_mul_SxV_(2, iv),
[1, 1, 1]),
r);
}: genarray(new_shp, 0d);
}
/* This specialization must be here for the error to occur.
specialization must also be at least 16. */
specialize double[16,16,16] M (double[16,16,16] r);
double[.,.,.] M (double[.,.,.] r)
{
rs = fine2coarse(r);
zs = M (rs);
z = coarse2fine(zs);
return z;
}
double[4,4,4] M (double[4,4,4] r)
{
return r;
}
double MG (double[N,N,N] v, double[N,N,N] u)
{
/* Must be at least 4 for the error to occur. */
// for (i = 1; i < 4; i++) {
// r = v - u;
// u = u + M(r);
// }
// return u[0, 0, 0];
for (i = 1; _le_SxS_(i, 4); i = _add_SxS_(i, 1)) {
r = with {
(. <= iv <= .): _sub_SxS_(_sel_VxA_(iv, v),
_sel_VxA_(iv, u));
}: genarray(_shape_A_(v), 0d);
Mr = M(r);
u = with {
(. <= iv <= .): _add_SxS_(_sel_VxA_(iv, u),
_sel_VxA_(iv, Mr));
}: genarray(_shape_A_(u), 0d);
}
return _sel_VxA_([0, 0, 0], u);
}
int main()
{
u = with {
([0, 0, 0] <= iv <= [N, N, N]): 2d;
}: genarray([N, N, N], 0d);
v = u;
r = MG (v, u);
return _toi_S_(r);
}
```Hans-Nikolai ViessmannHans-Nikolai Viessmannhttps://gitlab.sac-home.org/sac-group/sac2c/-/issues/2345Trouble with compilation and installation2023-09-18T15:07:50ZTroels HenriksenTrouble with compilation and installationI am very pleasantly surprised to see that SAC is now FOSS (or has been for a year), and to celebrate I am trying to compile it myself. I am following the instructions [in the README](https://gitlab.sac-home.org/sac-group/sac2c/-/blob/d...I am very pleasantly surprised to see that SAC is now FOSS (or has been for a year), and to celebrate I am trying to compile it myself. I am following the instructions [in the README](https://gitlab.sac-home.org/sac-group/sac2c/-/blob/develop/README.md). First I tried the *quick and dirty* version (`make`), but I didn't understand the significance of the `build_r` and `build_p` directories that were produced. Neither of them contained a `sac2c` binary. Then I went with *the long way*, which also worked, but again no `sac2c`. I then did a `make install` inside my `build/` directory, and that did indeed construct a `sac2c` binary in my chosen installation prefix (in my case, `$HOME/sac`). Is this right? I'm surprised because the documentation says "no install is needed".https://gitlab.sac-home.org/sac-group/sac2c/-/issues/2342Sac2c segfault with apex UTTakeDrop2023-11-08T14:47:51ZHolden HooverSac2c segfault with apex UTTakeDropWhen compiling the apex UnitTest, UTTakeDrop, sac2c produces a segfault on my system and on my server, however, it does not produce a segfault for Bob on his system. I don't think it is a memory issue, since I have over 60Gb free while i...When compiling the apex UnitTest, UTTakeDrop, sac2c produces a segfault on my system and on my server, however, it does not produce a segfault for Bob on his system. I don't think it is a memory issue, since I have over 60Gb free while it is compiling, and sac2c never uses more than 5Gb or 10Gb while compiling UTTakeDrop, so it is not reaching any memory limit.
This should be fairly easy to reproduce within the docker image I have created via `docker run -it -v $(pwd):/app registry.bkaw.ca/spacequacker/sacstdlib:latest bash`, running this within some junk directory which contains UTTakeDrop.sac, which is attached.
My sac2c version is the following:
sac2c 1.3.3-MijasCosta-1079-g648dba
build-type: DEBUG
built-by: "spacequacker" at 2023-07-19T19:42:08
BugReport is [attached](/uploads/32e753fd3d090701b28f521186c725a3/UTTakeDrop.sacbugreport). The up-to-date sac source file is [here](/uploads/2752823ccddf8930bc97414d747f52c9/UTTakeDrop.sac). [Dockerfile](/uploads/b2a1d22e3b86dcba2526880326c3d21b/Dockerfile) For some additional background information, the apex issue is [here](https://gitlab.com/bernecky/apex/-/issues/10).https://gitlab.sac-home.org/sac-group/sac2c/-/issues/2341-mt N slowdown as N increases2023-07-18T20:56:16ZRobert Bernecky-mt N slowdown as N increasesquer invokes a Lehmer RNG. Oddly enough, it runs slower with more threads.
```
sac2c crud.sac -O3
apex@medusa:/tmp/crud$ time a.out;
before quer
after quer
1642668640
real 0m0.245s
user 0m0.233s
sys 0m0.012s
apex@medusa:/tmp...quer invokes a Lehmer RNG. Oddly enough, it runs slower with more threads.
```
sac2c crud.sac -O3
apex@medusa:/tmp/crud$ time a.out;
before quer
after quer
1642668640
real 0m0.245s
user 0m0.233s
sys 0m0.012s
apex@medusa:/tmp/crud$ sac2c crud.sac -O3 -target mt_pth
apex@medusa:/tmp/crud$ time a.out -mt 1
before quer
after quer
1642668640
real 0m0.325s
user 0m0.313s
sys 0m0.012s
apex@medusa:/tmp/crud$ time a.out -mt 2
before quer
after quer
1642668640
real 0m6.456s
user 0m12.890s
sys 0m0.016s
apex@medusa:/tmp/crud$ time a.out -mt 3
before quer
after quer
1642668640
real 0m7.410s
user 0m22.197s
sys 0m0.020s
apex@medusa:/tmp/crud$ time a.out -mt 4
before quer
after quer
1642668640
real 0m9.427s
user 0m37.685s
sys 0m0.008s
```
Here is the code:
```
cat crud.sac
// Compiled by APEX Version: FIXME!! 2023-07-17 17:10:54.312
use Array: all;
use StdIO: all;
use Numerical: all;
use String: {tochar};
inline int, int querXII(int y, int QUADio, int[*] QUADrl)
{ // Monadic query (roll) - scalar
inty = toi(y);
if (inty <= 0) print(tochar("roll domain error"));
Q = firstel(QUADrl);
Qrl = Lehmer(Q);
z = (tod(Qrl) * tod(inty)) / tod(2147483647);
return(toi(z) + QUADio, Qrl);
}
inline double sacmod(double x, double y)
{ // SAC _aplmod_ for doubles
if ( 0.0 == y) {
t = 1.0;
} else {
t = y;
}
t2 = floor(x/t);
z = x - (y*t2);
return(z);
}
inline int[.], int querIII(int x, int y, int QUADio, int[*] QUADrl)
{ // Dyadic query (deal) - scalar
// This allocates an array of shape y. If this
// causes you memory grief, use the algorithm in workspace 42 query,
// or use smaller y!
intx = toi(x);
inty = toi(y);
shpz = toi(x);
z = iota (inty);
for( i=0; i<intx; i++) {
// Interchange z[i] with z[i + ? y - i]
rand, QUADrl = querXII(inty -i, 0, QUADrl);
c = i + rand;
if ( c < shpz) {
tmp = z[[c]];
z[[c]] = z[[i]];
z[[i]] = tmp;
}
}
z = take([intx], z);
return(z + QUADio, QUADrl);
}
inline int Lehmer(int qrl)
{ // Lehmer's random number generator
// CACM 1966-06, p. 432
val = tod(qrl)*16807.0;
z = toi(sacmod(val, 2147483647.0));
return(z);
}
inline int firstel( int[*] arg)
{ // First element of any array
zxrho = prod(shape(arg));
ravely = reshape([zxrho], arg);
z = take([1], ravely);
return(z[0]);
}
int main()
{
n_0=( 5000000);
QUADrl_0 = [16807, 0];
show("before quer");
A_48,QUADrl_1=querIII(n_0,n_0,0,QUADrl_0);
show("after quer");
show(sum(A_48));
return(0);
}
```
Thunderstorm is here, so I am powering down...https://gitlab.sac-home.org/sac-group/sac2c/-/issues/2339-d treecheck breaks in scyc2023-05-14T21:22:00ZRobert Bernecky-d treecheck breaks in scycI suspect almost any compile will break here.
It may be trival to fix, but I would like to know what scyc is intended to do,
and why it runs here. uglf was executed earlier, so functions are no
longer "grouped".
```
scyc : Typ...I suspect almost any compile will break here.
It may be trival to fix, but I would like to know what scyc is intended to do,
and why it runs here. uglf was executed earlier, so functions are no
longer "grouped".
```
scyc : Type stabilization cycle
tup : Applying type upgrade (fun based)
etv : Eliminating Type Variables (fun based)
ebt : Eliminating Bottom Types (fun based)
cf : Applying constant folding (fun based)
vp : Propagating variables (fun based)
dfc : Applying function call dispatch (fun based)
lof : Lifting optimization flags
```
```
**** Type stabilization cycle pass: 1
****** Optimizing regular function:
****** sacprelude_d::sel( int[.], ulonglong[*]): ...
Applying type upgrade ...
-> Running syntax tree checks
Internal compiler error
Assertion "NODE_TYPE( arg_node)== N_module || global.local_funs_grouped" failed at /home/sac/sac2c/build_d/src/libsac2c/check.c:47 -- If run fun-based, special funs must be grouped.
Please file a bug at: https://gitlab.sac-home.org/sac-group/sac2c/-/issues
apex@medusa:~/apexgit/Ancillary/benchmks/UnitTests/UTIndexSet/crud$ sac2c fundef.sac -d treecheck -chkfreq 4 -v4
sac2c -V
sac2c 1.3.3-MijasCosta-1068-g43af
build-type: DEBUG
built-by: "sac" at 2023-05-11T18:37:11
```
```
// fundef.sac
bool[*] id( bool[*] y)
{ return(y);
}
int main()
{
cond = [true,true];
c = _sel_VxA_([0],cond);
if (c) {
z = 42;
} else {
z = 666;
}
z = _sub_SxS_(42,z);
return(z);
}
```https://gitlab.sac-home.org/sac-group/sac2c/-/issues/2336Type inference phase does not terminate2023-05-03T19:52:14ZThomas KoopmanType inference phase does not terminatePhase 6 "Running type inference system ..." does not terminate, or takes at least 45 minutes. When removing either the print(ia) statement or specializations, the compiler does terminate, (and uses 10GB of RAM).
Run with 1.3.3-MijasCos...Phase 6 "Running type inference system ..." does not terminate, or takes at least 45 minutes. When removing either the print(ia) statement or specializations, the compiler does terminate, (and uses 10GB of RAM).
Run with 1.3.3-MijasCosta-1059-ge32fa.
```
#define M1B 200
#define K1B 40
#define N1B 1250
#define M2B 10
#define K2B 1
#define N2B 1
#define M3B 5
#define K3B 250
#define N3B 8
use Array:all;
use StdIO:all;
inline
int[.] even (int[.] a)
{
return { [i] -> a[i*2] | [i] < (shape(a)+1)/2 };
}
inline
int[.] odd (int[.] b)
{
return { [i] -> b[i*2 + 1] | [i] < (shape(b)+1)/2 };
}
inline
int[.] merge (int[.] a, int[.] b)
{
return { [i] -> a[i/2] | [0] <= [i] < shape(a)*2 step [2];
[i] -> b[i/2] | [1] <= [i] < shape(b)*2 step [2]};
}
#define ASZS M1B, K1B, M2B, K2B, M3B, K3B
#define BSZS K1B, N1B, K2B, N2B, K3B, N3B
#define CSZS M1B, N1B, M2B, N2B, M3B, N3B
specialize double[.,.,.,.,.,.]
mmy(double[ASZS] a, int[0] ia, int[6] sha,
double[BSZS] b, int[0] ib, int[6] shb,
double[CSZS] c, int[0] ic, int[6] shc);
specialize double[.,.,.,.]
mmy(double[ASZS] a, int[2] ia, int[4] sha,
double[BSZS] b, int[2] ib, int[4] shb,
double[CSZS] c, int[2] ic, int[4] shc);
specialize double[.,.]
mmy(double[ASZS] a, int[4] ia, int[2] sha,
double[BSZS] b, int[4] ib, int[2] shb,
double[CSZS] c, int[4] ic, int[2] shc);
inline double[*]
mmy (double[ASZS] a, int[.] ia, int[.] sha,
double[BSZS] b, int[.] ib, int[.] shb,
double[CSZS] c, int[.] ic, int[.] shc)
{
return {[i,j] -> with {
([0] <= [l] < [sha[1]]): mmy (a, (ia ++ [i,l]), drop([2], sha),
b, (ib ++ [l,j]), drop([2], shb),
c, (ic ++ [i,j]), drop([2], shc));
}: fold(+, genarray(merge(even(drop([2], sha)),
odd(drop([2], shb))),
0d))
| [i,j] < [sha[0], shb[1]]};
}
inline double[.,.]
mmy (double[ASZS] a, int[.] ia, int[2] sha,
double[BSZS] b, int[.] ib, int[2] shb,
double[CSZS] c, int[.] ic, int[2] shc)
{
print(ia);
return genarray(shc, 0d);
}
int main()
{
a = reshape([M1B, M2B, M3B, K1B, K2B, K3B], tod(iota(M1B * M2B * M3B * K1B * K2B * K3B)));
b = reshape([K1B, K2B, K3B, N1B, N2B, N3B], tod(iota(K1B * K2B * K3B * N1B * N2B * N3B)));
c = reshape([M1B, M2B, M3B, N1B, N2B, N3B], tod(iota(M1B * M2B * M3B * N1B * N2B * N3B)));
c = mmy(a, [], shape(a), b, [], shape(b), c, [], shape(c));
return toi(sum(c));
}
```https://gitlab.sac-home.org/sac-group/sac2c/-/issues/2334-noinl does not play well with -t mt_pth2023-04-26T16:48:09ZRobert Bernecky-noinl does not play well with -t mt_pthI am trying to get the wheels back onto APEX/sac2c (See Issue #2233). I tried -noinl, which is okay
as a workaround for the apex unit tests, BUT that appears to break -mt-pth:
```
apex@medusa:~/apexgit/Ancillary/benchmks/UnitTests/testi...I am trying to get the wheels back onto APEX/sac2c (See Issue #2233). I tried -noinl, which is okay
as a workaround for the apex unit tests, BUT that appears to break -mt-pth:
```
apex@medusa:~/apexgit/Ancillary/benchmks/UnitTests/testindx/crud$ ls
a.out a.out.c a.out.i a.out.o host testindx.sac testindx.unittest.sac tree
apex@medusa:~/apexgit/Ancillary/benchmks/UnitTests/testindx/crud$ sac2c testindx.sac -t mt_pth
apex@medusa:~/apexgit/Ancillary/benchmks/UnitTests/testindx/crud$ sac2c testindx.unittest.sac -t mt_pth
apex@medusa:~/apexgit/Ancillary/benchmks/UnitTests/testindx/crud$ a.out -mt 3
5.00002e+11
0
apex@medusa:~/apexgit/Ancillary/benchmks/UnitTests/testindx/crud$ a.out -mt 1
5.00002e+11
0
apex@medusa:~/apexgit/Ancillary/benchmks/UnitTests/testindx/crud$ sac2c testindx.sac -t mt_pth -noinl
apex@medusa:~/apexgit/Ancillary/benchmks/UnitTests/testindx/crud$ sac2c testindx.unittest.sac -t mt_pth -noinl
apex@medusa:~/apexgit/Ancillary/benchmks/UnitTests/testindx/crud$ a.out -mt 1
a.out: /tmp/SAC_e5IFN5/fun1.c:16477: SACf_testindx_CLArray__sel__i_1__i_X: Assertion `SAC_MT_globally_single && "An ST/SEQ small-arena call in the MT/XT context!!"' failed.
Aborted (core dumped)
apex@medusa:~/apexgit/Ancillary/benchmks/UnitTests/testindx/crud$ a.out -mt 2
a.out: /tmp/SAC_e5IFN5/fun1.c:16477: SACf_testindx_CLArray__sel__i_1__i_X: Assertion `SAC_MT_globally_single && "An ST/SEQ small-arena call in the MT/XT context!!"' failed.
a.out: /tmp/SAC_e5IFN5/fun1.c:16477: SACf_testindx_CLArray__sel__i_1__i_X: Assertion `SAC_MT_globally_single && "An ST/SEQ small-arena call in the MT/XT context!!"' failed.
Aborted (core dumped)
sac2c -V
sac2c 1.3.3-MijasCosta-1047-g0c4a5
build-type: RELEASE
built-by: "sac" at 2023-02-15T14:35:41
```
I note that 4 out of 60 apex unit tests break when compiled with -noinl -t mt_pth,
[testindx.unittest.sac](/uploads/94a8d09e471459ad6572d40d709d8a56/testindx.unittest.sac)
[testindx.sac](/uploads/f28edab741e3e41735bcf789cb62590c/testindx.sac)
I tried the test with -noinl.
That avoids this crash, but results in 4 failures for -t mt_pth that look similar to #1135.https://gitlab.sac-home.org/sac-group/sac2c/-/issues/2333module compilation problem with function specialisation2024-02-15T17:29:23ZRobert Berneckymodule compilation problem with function specialisationI just ran into the following runtime crash with type coercion:
```
apex@medusa:~/apexgit/Ancillary/benchmks/UnitTests/UTThornReal/crud$ sac2c UTThornReal.sac
apex@medusa:~/apexgit/Ancillary/benchmks/UnitTests/UTThornReal/crud$ sac2c UT...I just ran into the following runtime crash with type coercion:
```
apex@medusa:~/apexgit/Ancillary/benchmks/UnitTests/UTThornReal/crud$ sac2c UTThornReal.sac
apex@medusa:~/apexgit/Ancillary/benchmks/UnitTests/UTThornReal/crud$ sac2c UTThornReal.unittest.sac
a.out;eapex@medusa:~/apexgit/Ancillary/benchmks/UnitTests/UTThornReal/crud$ a.out;echo $?
___[] SACp_pinl_4385_z
*** SAC runtime error
*** //home/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
```
My naive expectation is that the coercion would be allowed if the argument, at runtime, is a vector.
The argument is, I believe, a vector, yet the coercion fails.
What am I missing here? I am going to try to come up with a simpler example of the failure that
does not drag in ArrayFormat.Sven-Bodo ScholzSven-Bodo Scholzhttps://gitlab.sac-home.org/sac-group/sac2c/-/issues/2332Potentially faster PRF aplmod definition2023-04-30T16:16:10ZMichiel VerloopPotentially faster PRF aplmod definitionWhile looking at `prf.h`, I stumbled across the following definition for aplmod, which contains some oddities:
```
#define SIGNUM(x) ((0 == (x)) ? 0 : (0 < (x)) ? 1 : -1)
#define FLRDIV(arg1, arg2) ...While looking at `prf.h`, I stumbled across the following definition for aplmod, which contains some oddities:
```
#define SIGNUM(x) ((0 == (x)) ? 0 : (0 < (x)) ? 1 : -1)
#define FLRDIV(arg1, arg2) \
((0 == (arg2)) ? (arg1) : (arg1) - ((arg2) * ((arg1) / (arg2))))
#define SAC_ND_PRF_APLMOD(arg1, arg2) \
(((0 != FLRDIV (arg1, arg2)) && ((SIGNUM (arg1) != SIGNUM (arg2)))) \
? FLRDIV (arg1, arg2) + (arg2) \
: FLRDIV (arg1, arg2))
```
As far as I can tell `FLRDIV` is just the remainder, except it allows for 0 values. It should not be called FLRDIV as it implies floor division, which it is not.
It could also be defined in a more concise manner: `#define FLRDIV(arg1, arg2) ((0 == (arg2)) ? (arg1) : (arg1) % (arg2))`
Looking at the other definitions, they don't seem efficient, but admittedly I'm out of my depth here. It could very well be that they are further optimized somewhere or that my cost model is wrong.
Just to get the discussion going, would any of these definitions be more efficient?
This version of SIGNUM avoids branching
```
#define SIGNUM(x) (((x) > 0) - ((x) < 0))
```
This version of APLMOD replaces the use of the signum inequality, instead using a `xor` and a `lt`. It views 0 as positive.
```
#define SAC_ND_PRF_APLMOD(arg1, arg2) \
(((0 != FLRDIV (arg1, arg2)) && (((arg1) ^ (arg2)) < 0)) \
? FLRDIV (arg1, arg2) + (arg2) \
: FLRDIV (arg1, arg2))
```
This version of APLMOD does the same but also eliminates branching at the cost of an addition and multiplication.
```
#define SAC_ND_PRF_APLMOD(arg1, arg2) \
(FLRDIV (arg1, arg2)) \
+ (arg2) * ( (0 != FLRDIV ((arg1), (arg2))) && (((arg1) ^ (arg2)) < 0) )
```
@thomas You were working on optimizations like this, right? Could you give some insight into the cost of these functions? Would they be worth changing?https://gitlab.sac-home.org/sac-group/sac2c/-/issues/2331Compiler crashes in multiple result with fold2023-04-11T14:10:04ZMart LubbersCompiler crashes in multiple result with foldWhile experimenting with fold/with expressions I encountered a compiler crash.
- using sac2c 1.3.3-MijasCosta-1047-g0c4a5
- built 2023-02-05T05:27:58.
- by user on host runner-qbwxddwq-project-39-concurrent-0.
- The compiler was called...While experimenting with fold/with expressions I encountered a compiler crash.
- using sac2c 1.3.3-MijasCosta-1047-g0c4a5
- built 2023-02-05T05:27:58.
- by user on host runner-qbwxddwq-project-39-concurrent-0.
- The compiler was called by `sac2c bonk.sac`.
```
* The compiler crashed in
* phase: pre (Preprocessing SAC program)
* sub phase: mgwl (Handling multi-generator with-loops)
```
Contents of `bonk.sac`
```
use Array: all;
int main()
{
a, b = with
{ ([0] <= iv <= [0]) : 1;
([1] <= iv <= [1]) : 1;
} : fold(+, 0);
return 0;
}
```https://gitlab.sac-home.org/sac-group/sac2c/-/issues/2329Compiler doesn't terminate for a specific small program2023-04-03T18:16:19ZMart LubbersCompiler doesn't terminate for a specific small programAfter over 6 minutes, the compiler crashes with some memory error:
```
malloc(): invalid size (unsorted)
/bin/bash: line 1: 46062 Aborted sac2c lim.sac
real 6m47.740s
user 6m47.561s
sys 0m0.161s
shell returned...After over 6 minutes, the compiler crashes with some memory error:
```
malloc(): invalid size (unsorted)
/bin/bash: line 1: 46062 Aborted sac2c lim.sac
real 6m47.740s
user 6m47.561s
sys 0m0.161s
shell returned 134
```
The culprit is this program (note that the loop version works fine, only the recursive version makes the compiler crash:
```
use StdIO: all;
use Array: all;
int[*] dup(int[*]a)
{
return reshape(shape(a)++shape(a), a);
}
int[*] bonkrec(int i, int[*] a)
{
if (i == 0) {
res = a;
} else {
res = bonkrec(i-1, dup(a));
}
return res;
}
int[*] bonkloop(int i, int[*] a)
{
res = a;
for (j = 0; j<i; j++) {
res = dup(res);
}
return res;
}
int main()
{
// results in a 32D array with one element 4
print(bonkloop(5, [4]));
// same but the compiler never terminates
print(bonkrec(5, [4]));
return 0;
}
```https://gitlab.sac-home.org/sac-group/sac2c/-/issues/2328Internal compiler error of COzipCvUByteAbs during Stdlib build of ArrayArith2023-02-26T21:58:04ZHans-Nikolai ViessmannInternal compiler error of COzipCvUByteAbs during Stdlib build of ArrayArithAfter !217 SAC package building fails in building Stdlib `ArrayArith` module (output in https://gitlab.sac-home.org/sac-group/build-sac-pkgs/-/pipelines/1512, but its not very clear whats going on), issuing the following error:
```
Inter...After !217 SAC package building fails in building Stdlib `ArrayArith` module (output in https://gitlab.sac-home.org/sac-group/build-sac-pkgs/-/pipelines/1512, but its not very clear whats going on), issuing the following error:
```
Internal compiler error
Program reached impossible state at /home/hans/git/sac/sac2c/src/libsac2c/constants/zipcv.c:260 -- COzipCvUByteAbs called !
```
This error **ONLY** happens when we build Stdlib using `-DFULLTYPES=ON`, which is why this has neither affected this repo's MR pipelines or the Stdlib Github actions...Sven-Bodo ScholzSven-Bodo Scholzhttps://gitlab.sac-home.org/sac-group/sac2c/-/issues/2324WLUR causing a loss in type precision? Yet another instance of the AUDGZ-prob...2023-01-25T17:18:58ZMichiel VerloopWLUR causing a loss in type precision? Yet another instance of the AUDGZ-problem!Compiling the below program with `sac2c -maxspec 0 -noinl` causes a compiler error:
```
use Array: {tof, toi, sel};
int main()
{
grid = {iv -> tof([0]) | iv < [1] };
return toi(grid[0, 0]);
}
```
The error:
```
Internal compil...Compiling the below program with `sac2c -maxspec 0 -noinl` causes a compiler error:
```
use Array: {tof, toi, sel};
int main()
{
grid = {iv -> tof([0]) | iv < [1] };
return toi(grid[0, 0]);
}
```
The error:
```
Internal compiler error
Program reached impossible state at /home/username/sac2c/src/libsac2c/typecheck/elim_alpha_types.c:435 -- new element type `float[*]' of array `_wlur_25' does not match old type `float[+]' on the left hand side
Please file a bug at: https://gitlab.sac-home.org/sac-group/sac2c/-/issues
```
The error is not triggered when `tof()` is removed or computed `tof()` over the entire grid.
`-maxspec 0 -noinl` might seem like an oddly specific combination, but it's very effective at compiling a project quickly at the cost of runtime performance, making it excellent for debugging purposes.
Output of `sac2c -V`:
```
sac2c 1.3.3-MijasCosta-1040-g893498
build-type: DEBUG
built-by: "username" at 2023-01-25T15:48:20
```https://gitlab.sac-home.org/sac-group/sac2c/-/issues/2319WLF bug - weird out-of-bound-access error message2022-11-05T17:39:21ZSven-Bodo ScholzWLF bug - weird out-of-bound-access error messageout-of-bound error in WLF. Using sac2c `sac2c 1.3.3-MijasCosta-1004-ge257a-dirty build-type: DEBUG` the following program:
```
int + (int a, int b) {return _add_SxS_ (a, b); }
int main()
{
a = with {} : genarray ([5,10], 0);
c ...out-of-bound error in WLF. Using sac2c `sac2c 1.3.3-MijasCosta-1004-ge257a-dirty build-type: DEBUG` the following program:
```
int + (int a, int b) {return _add_SxS_ (a, b); }
int main()
{
a = with {} : genarray ([5,10], 0);
c = with {} : genarray([10,10], 0);
new = with {
( [0,0] <= [i,j] < [5,5]) : with { ([0] <= [k] < [10]): _sel_VxA_ ([i,k], a);
} : fold (+,0);
} : genarray ([5,5], 0);
c = with {
( [5,0] <= iv < [10,5] ) : _sel_VxA_ (_sub_VxV_( iv , [5,0]), new) ;
} : modarray (c);
return _sel_VxA_ ([5,2], c);
}
```
yields:
```
-sbs-SvenBodosAir2-> sac2c-d WLFbug.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 ...
./WLFbug.sac:9:87: abort:
Array access to a out of range in dimension 1
Compilation failed while Running SAC optimizations.
```https://gitlab.sac-home.org/sac-group/sac2c/-/issues/2315WLUR does not work for mo-fold-wl2022-10-01T18:10:39ZSven-Bodo ScholzWLUR does not work for mo-fold-wlif we compile
```
int + ( int a, int b)
{
return _add_SxS_(a, b);
}
int main ()
{
v = [1,2,3,4,5,6,7,8,9,10,11,12];
a, b = with {
([0] <= iv < [3]) : (1,2);
} : (fold( +, 0),
fold(...if we compile
```
int + ( int a, int b)
{
return _add_SxS_(a, b);
}
int main ()
{
v = [1,2,3,4,5,6,7,8,9,10,11,12];
a, b = with {
([0] <= iv < [3]) : (1,2);
} : (fold( +, 0),
fold( +, 0));
return _add_SxS_(a,b);
}
```
with
```
sac2c 1.3.3-MijasCosta-926-gec84e9
build-type: RELEASE
built-by: "sbs" at 2022-06-20T17:38:42
```
we get an error
```
Internal compiler error
Assertion "F_accu_found" failed at /Volumes/Users/sbs/sac2c/src/libsac2c/stdopt/SSAWLUnroll.c:214 -- No F_accu found!
Please file a bug at: https://gitlab.sac-home.org/sac-group/sac2c/-/issues
```
which goes away as soon as we compile with `-noWLIR`
.Sven-Bodo ScholzSven-Bodo Scholzhttps://gitlab.sac-home.org/sac-group/sac2c/-/issues/2313semantics of abs() does not check against overflows2022-03-29T15:57:45ZRobert Berneckysemantics of abs() does not check against overflowsI have been chasing problems with array formatting in apex. I narrowed it down to this just now:
```
sac2c_d -V
sac2c 1.3.3-MijasCosta-799-gb7a97
build-type: DEBUG
built-by: "sac" at 2022-03-23T09:54:38
```
```
// after -bopt:cyc:tup...I have been chasing problems with array formatting in apex. I narrowed it down to this just now:
```
sac2c_d -V
sac2c 1.3.3-MijasCosta-799-gb7a97
build-type: DEBUG
built-by: "sac" at 2022-03-23T09:54:38
```
```
// after -bopt:cyc:tup:1, the result of abs(v) is AKV. This is awesome.
// after -bopt:cyc:tup:1, the value of abs(v) is negative. This is awful.
use Array:all;
int main()
{
v = -2147483648;
StdIO::print(v);
StdIO::print( abs(v));
return(0);
}
```
NB. The value of v is critical here.https://gitlab.sac-home.org/sac-group/sac2c/-/issues/2312negative upper bound check on WLs wrong!2022-03-23T09:42:15ZSven-Bodo Scholznegative upper bound check on WLs wrong!The following is legal SaC but ICC (`-check c`) triggers an error:
```
int main()
{
a = with {
( [0] <= iv < [ _neg_S_(5)]) : 42;
} : genarray( [12], 0);
return _sel_VxA_([3], a);
}
```
ICC needs to be adjusted ...The following is legal SaC but ICC (`-check c`) triggers an error:
```
int main()
{
a = with {
( [0] <= iv < [ _neg_S_(5)]) : 42;
} : genarray( [12], 0);
return _sel_VxA_([3], a);
}
```
ICC needs to be adjusted accordingly and we should check with all WL-operators whether all possible transformation passes can deal properly with non-standard partitions....https://gitlab.sac-home.org/sac-group/sac2c/-/issues/2311Improve jupyter docs2022-03-21T21:40:34ZSpencer BlivenImprove jupyter docsI'm a new SaC user. After going to the home page the first thing I did was open the jupyter notebook and start copying code from the home page and the tutorial. This fails for reasons that I'm sure are obvious to seasoned SaC developers ...I'm a new SaC user. After going to the home page the first thing I did was open the jupyter notebook and start copying code from the home page and the tutorial. This fails for reasons that I'm sure are obvious to seasoned SaC developers but it was frustrating to get many compile errors before I started figuring SaC out.
Would it be possible to add a page explaining the rules behind jupyter? Or even better, add a jupyter version of the tutorial as an example.
Some of the dumb things that threw me:
- When to use semicolons. Why does `print(1);` compile but `1+1;` does not?
- Why do side effects from previous cells occur during execution?
- Why can't I create a main function? All the tutorial examples are wrapped in main() so they can't be trivially copy-pasted to jupyter.
- When do cells get compiled?https://gitlab.sac-home.org/sac-group/sac2c/-/issues/2305Parallel slowdown in Livermore Loops2022-11-20T12:08:54ZRobert BerneckyParallel slowdown in Livermore Loops-mt_pth results in serious slowdown!
This happens on a number of the Livermore Loops tests. This is typical:
```
sac@medusa:~/sac/benchmarks/LivermoreLoopsCtest/loop04$ sac2c loop04.sac -O3 -target seq -o out.seq
sac@medusa:~/sac/bench...-mt_pth results in serious slowdown!
This happens on a number of the Livermore Loops tests. This is typical:
```
sac@medusa:~/sac/benchmarks/LivermoreLoopsCtest/loop04$ sac2c loop04.sac -O3 -target seq -o out.seq
sac@medusa:~/sac/benchmarks/LivermoreLoopsCtest/loop04$ sac2c loop04.sac -O3 -target mt_pth -o out.mt
sac@medusa:~/sac/benchmarks/LivermoreLoopsCtest/loop04$ time out.seq < loop04.inp ;echo $?
Running Loop4_NAIVE
Number of repetitions: 20000000
Vector length : 1001
Upper limit (n) : 35
Element [5] of the result is: -0.073587732613706644, WANT is: -0.0735877326136999965
x[5] - WANT is -6.64746035994312479e-15
WANT - x[5] is 6.64746035994312479e-15
Wall Clock Time spent : 0.199 secs
Computer Performance achieved : 2.407 GFlops/s
real 0m0.201s
user 0m0.201s
sys 0m0.000s
0
sac@medusa:~/sac/benchmarks/LivermoreLoopsCtest/loop04$ time out.mt -mt 1 < loop04.inp ;echo $?
Running Loop4_NAIVE
Number of repetitions: 20000000
Vector length : 1001
Upper limit (n) : 35
Element [5] of the result is: -0.073587732613706644, WANT is: -0.0735877326136999965
x[5] - WANT is -6.64746035994312479e-15
WANT - x[5] is 6.64746035994312479e-15
Wall Clock Time spent : 1.322 secs
Computer Performance achieved : 0.363 GFlops/s
real 0m1.324s
user 0m1.324s
sys 0m0.000s
0
sac@medusa:~/sac/benchmarks/LivermoreLoopsCtest/loop04$ time out.mt -mt 2 < loop04.inp ;echo $?
Running Loop4_NAIVE
Number of repetitions: 20000000
Vector length : 1001
Upper limit (n) : 35
Element [5] of the result is: -0.073587732613706644, WANT is: -0.0735877326136999965
x[5] - WANT is -6.64746035994312479e-15
WANT - x[5] is 6.64746035994312479e-15
Wall Clock Time spent : 69.401 secs
Computer Performance achieved : 0.007 GFlops/s
real 1m9.403s
user 2m18.799s
sys 0m0.004s
0
sac@medusa:~/sac/benchmarks/LivermoreLoopsCtest/loop04$ sac2c -V
sac2c 1.3.3-MijasCosta-774-g4dc6e2
build-type: RELEASE
built-by: "sac" at 2022-02-24T15:43:37
```
Running -mt 2 shows two threads running at 100% (system monitor), so I am guessing that there is some
kind of locking problem going on.https://gitlab.sac-home.org/sac-group/sac2c/-/issues/2301Confusion about gettime()2022-03-01T14:56:25ZRobert BerneckyConfusion about gettime()
```
sac@medusa:~/sac/benchmarks/LivermoreLoops/loop01$ sac2c -V
sac2c 1.3.3-MijasCosta-774-g4dc6e2
build-type: RELEASE
built-by: "sac" at 2022-02-24T14:24:00
sac@medusa:~/sac/benchmarks/LivermoreLoops/loop01$ sac2c loop01.sac
sac@medus...
```
sac@medusa:~/sac/benchmarks/LivermoreLoops/loop01$ sac2c -V
sac2c 1.3.3-MijasCosta-774-g4dc6e2
build-type: RELEASE
built-by: "sac" at 2022-02-24T14:24:00
sac@medusa:~/sac/benchmarks/LivermoreLoops/loop01$ sac2c loop01.sac
sac@medusa:~/sac/benchmarks/LivermoreLoops/loop01$ time a.out < loop01.inp
Running Loop1_APL2
Number of repetitions: 1000000
Vector length : 1001
Upper limit (n) : 990
*** SAC runtime error
*** When the stdlib was compiled for this architecture neither clock_gettime( CLOCK_REALTIME, x) nor
host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, x) were found
```
I ran into this before. Rebuilt Stdlib, and it thinks we have a clock:
```
* Configuration state:
* - realtime clock: 1
* - mach clock:
```
I had this happen several days ago, and found that rebuilding sac2c and Stdlib "fixed" it.
I will rebuild things again, and see what I get.