On Tue, Feb 16, 2021 at 03:36:33PM -0800, Tobias Neumann wrote:
>
> >
> > After using SPAD for a while now, I think I've come across a few
> > compiler issues, leading either to compilation failure or to programs that
> > crash ("system error").
> > In all cases I was able to circumvent them by rewriting the expression,
> > interchanging independent lines etc.
> > One "system error" was for example produced by using
> > monomial(1,0)$UnivariateTaylorSeries(Expression(Integer),'x,0)
> > in a longer expression and I was able to circumvent this by just using
> > 1$UnivariateTaylorSeries(Expression(Integer),'x,0)
> >
> > Ideally I should probably produce minimal working examples and put them on
> > the bugtracker,
> > but I think some of these just occur when the code is sufficiently
> > complex. I know that there is
> > little manpower to fix these things, but it might still be worth to
> > collect the issues?
I must admit that when I work on Spad code I often go with workaround
intead of trying to investigate and fix compiler bug. So if
do not produce examples I will understand. OTOH testcases are
useful. Even testcase for known problem may be quite useful,
as it may give new info.
> Things like this
> > make me a little nervous about investing development time. What happens
> > when I come across
> > something without a workaround or there is a very deep and subtle bug? I
> > know that in the end
> > this is my risk to take, but from your point of view, how concerned should
> > I be? FriCAS/Axiom
> > have been around for a while and used for hundreds of packages, so I'm
> > probably too concerned.
I do not think you should be very concerned. Many problems are visible
due to static typing and those show very early. And while not fast
bugs do get fixed.
> > Have there been thoughts or plans of porting the FriCAS SPAD code
> > completely to Aldor? As far
> > as I can tell Aldor is unmaintained, so this might not be a good idea in
> > the long run.
There were plans in early period of open source Axiom. AFAIK there are
no visible results. There would be some benefit if one could compile
algebra using Aldor. Relatively recently I did a little experiment
and it seems that there is a lot of use of few constructs that are valid
and perfectly good Spad but which are rejected by Aldor. IMO if one
seriously thinks about using Aldor to compile FriCAS algebra one
first needs to modify Aldor to accept those constructs. Also,
on files that I tried Aldor compiler was about 10 times slower than
Spad compiler. For me Spad compiler is slow and 10 times slowdown
would be step back.
> > The most problematic issue for me right now is that using ")compile
> > file.spad" multiple times
> > without ")clear all" in-between will completely break things. For example
> > something like:
> >
> > )co mypackage
> > test := sqrt(x)
> > subst(test, x=0)
> >
> > gives sqrt(0) as it should, but once I use )co mypackage again
> > it no longer substitutes x=0 and just returns sqrt(x). This then
> > completely breaks the functionality in the package.
> > A fix for this is to use ")clear all" in between, or to redefine test. Is
> > this "intended" or known behavior? I've had
> > similar issues before where ")clear completely" was necessary.
The issue was known, it has almost nothing to do with Spad compiler,
in particular the same should happen when using Aldor from FriCAS.
The core problem is that kernels are supposed to be unique.
Compilation has to invalidate existing domains, to make sure
that new code is used in all places. Kernels are stored in
separate domain called 'SortedCache', invalidating this domain
led to duplicate kernels and chaos. More precisely, there is
support for (at least somewhat) safely invalidating old kernels,
but it was not used. AFAICS attached patch solves your problem.
--
Waldek Hebisch
--
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/fricas-devel/20210218004101.GA39860%40math.uni.wroc.pl.
diff --git a/src/interp/clam.boot b/src/interp/clam.boot
index 58e32be1..d924bc6c 100644
--- a/src/interp/clam.boot
+++ b/src/interp/clam.boot
@@ -149,7 +149,14 @@ reportAndClearClams() ==
cacheStats()
clearClams()
+clear_sorted_caches() ==
+ scl := HGET($ConstructorCache, "SortedCache")
+ for [., ., :dom] in scl repeat
+ cc := compiledLookupCheck("clearCache", [$Void], dom)
+ SPADCALL(cc)
+
clearConstructorCaches() ==
+ clear_sorted_caches()
clearCategoryCaches()
CLRHASH $ConstructorCache
diff --git a/src/interp/daase.lisp b/src/interp/daase.lisp
index c97bef33..ea0a7af4 100644
--- a/src/interp/daase.lisp
+++ b/src/interp/daase.lisp
@@ -909,7 +909,8 @@ database.
(asharp file)
(setq file (|astran| (concatenate 'string (pathname-name file) ".asy")))
(localasy file object only make-database? noexpose))
- (CLRHASH |$ConstructorCache|))))
+ (|clearConstructorCaches|))
+))
(defun localasy (asy object only make-database? noexpose)
"given an alist from the asyfile and the objectfile update the database"
diff --git a/src/interp/i-syscmd.boot b/src/interp/i-syscmd.boot
index 91506c1c..c18af3d8 100644
--- a/src/interp/i-syscmd.boot
+++ b/src/interp/i-syscmd.boot
@@ -268,17 +268,11 @@ clearSpad2Cmd l ==
arg := selectOptionLC(first l,'(all completely scaches),NIL)
arg = 'all => clearCmdAll()
arg = 'completely => clearCmdCompletely()
- arg = 'scaches => clearCmdSortedCaches()
+ arg = 'scaches => clear_sorted_caches()
$clearExcept => clearCmdExcept(l)
clearCmdParts(l)
updateCurrentInterpreterFrame()
-clearCmdSortedCaches() ==
- $lookupDefaults: local := false
- for [.,.,:domain] in HGET($ConstructorCache,'SortedCache) repeat
- pair := compiledLookupCheck('clearCache,[$Void],domain)
- SPADCALL pair
-
clearCmdCompletely() ==
clearCmdAll()
$localExposureData := COPY_-SEQ $localExposureDataDefault
@@ -291,7 +285,7 @@ clearCmdCompletely() ==
NIL
clearCmdAll() ==
- clearCmdSortedCaches()
+ clear_sorted_caches()
------undo special variables------
$frameRecord := nil
$previousBindings := nil
@@ -1598,7 +1592,7 @@ restoreHistory(fn) ==
oldInternal := $useInternalHistoryTable
restoreHistory2(oldInternal, restfile, fn')
sayKeyedMsg("S2IH0025",[namestring(restfile)])
- clearCmdSortedCaches()
+ clear_sorted_caches()
nil
restoreHistory2(oldInternal, restfile, fn) ==