Spad compiler bug?

6 views
Skip to first unread message

Grégory Vanuxem

unread,
Aug 26, 2024, 5:42:43 AM8/26/24
to fricas...@googlegroups.com
Hello folks,

In the process of coding convenience domains, Spad does not allow
default parameters, I encountered the following during
the compilation of a domain:
==================================================================
augmenting (NemoRealBall): (PatternMatchable (Integer))
(time taken in buildFunctor: 465137)
Time: 0.68 SEC.


Warnings:
[1] unknown Functor code (jl_eval_string NACB256=AcbField(256))


Cumulative Statistics for Constructor NemoComplexBall
Time: 0.86 seconds


>> System error:
Invalid index 256 for (SIMPLE-VECTOR 84), should be a non-negative
integer below 84.
=====================================================================

In fact, from tests, it should be below 85 here.

The offending piece of code is:
================================================================
Implementation ==> NemoAcbField(256) add
import from JuliaUtilityFunctions
================================================================

If I replace 256 by 2*64*2 or 2^8 the code is cleanly compiled. So I
wonder if this is a known bug (?) in the Spad compiler or if I need to
try to code a simpler example to reproduce it? The code requires other
categories/domains to be compiled but it is here:

https://github.com/gvanuxem/jlfricas/blob/master/src/algebra/jnball.spad

beginning at line 563. The strange thing here is that almost the same
code compiles for NemoRealBall. At the question, just in case, why not use
NemoComplexBall() == NemoAcbBall(256) the response is that a global
variable needs to be defined at domain load time in Julia and if I use
"NemoComplexBall() == NemoArbBall(256)", the variable will not be defined in
NemoAcbBall when using NemoComplexBall as a domain parameter
(Uni/Multi-VariatePolynomial for example).

So should I try to code a simpler example, or is it already a known
problem? If this is a problem of course, not an unsupported code.

- Greg

Waldek Hebisch

unread,
Aug 26, 2024, 9:48:24 AM8/26/24
to fricas...@googlegroups.com
On Mon, Aug 26, 2024 at 11:42:05AM +0200, Grégory Vanuxem wrote:
> Hello folks,
>
> In the process of coding convenience domains, Spad does not allow
> default parameters, I encountered the following during
> the compilation of a domain:
> ==================================================================
> augmenting (NemoRealBall): (PatternMatchable (Integer))
> (time taken in buildFunctor: 465137)
> Time: 0.68 SEC.
>
>
> Warnings:
> [1] unknown Functor code (jl_eval_string NACB256=AcbField(256))
>
>
> Cumulative Statistics for Constructor NemoComplexBall
> Time: 0.86 seconds
>
>
> >> System error:
> Invalid index 256 for (SIMPLE-VECTOR 84), should be a non-negative
> integer below 84.
> =====================================================================
>
> In fact, from tests, it should be below 85 here.
>
> The offending piece of code is:
> ================================================================
> Implementation ==> NemoAcbField(256) add
> import from JuliaUtilityFunctions
> ================================================================

I do not think that this code triggers error. As you noticed code
like this compiles fine, so something later caused trouble.

> If I replace 256 by 2*64*2 or 2^8 the code is cleanly compiled. So I
> wonder if this is a known bug (?) in the Spad compiler or if I need to
> try to code a simpler example to reproduce it?

This does not look like a known bug. Simpler example would help.
ATM it looks like confusion due to mechanizm used to evaluate
domain parameters, but to make progress I need a way to reprodice
this.

> The code requires other
> categories/domains to be compiled but it is here:
>
> https://github.com/gvanuxem/jlfricas/blob/master/src/algebra/jnball.spad
>
> beginning at line 563. The strange thing here is that almost the same
> code compiles for NemoRealBall. At the question, just in case, why not use
> NemoComplexBall() == NemoAcbBall(256) the response is that a global
> variable needs to be defined at domain load time in Julia and if I use
> "NemoComplexBall() == NemoArbBall(256)", the variable will not be defined in
> NemoAcbBall when using NemoComplexBall as a domain parameter
> (Uni/Multi-VariatePolynomial for example).

Hmm, if B has integer parameter, then

A() == B(256)

is supposed to work. If not, then this may be the same bug. Or maybe bug
in code somewhere else. In general

A() : Cat == B(256) add ...

works almost the same as 'A() == B(256)', except for three things:
- in the second 'Cat' is taken from the right hand side
- in the first there is extra code after 'add'
- in the first case resulting type is new (different from 'B(256)'),
in the second case typechecker considers A the same as B(256)'.
In particular initialization of B(256) should work the same in both
cases (and the same as you used B(256) in the interpeter). There
are known troubles when you pass fancy things to B, but integers
are simple.

Of course, there may be reasons to write code as you did. And it
is supposed to work.

--
Waldek Hebisch
Reply all
Reply to author
Forward
0 new messages