From: Raffaele V. <raf...@un...> - 2011-11-27 02:38:29
|
Dear All, I use rule lists to define a set of variables. In a particularly heavy computation with long rule lists I get the following message: +++ Error stack overflow: Cont? (Y or N) I found in internet very limited information about enlarging the stack memory size in reduce, so I'm asking your help to understand what I can do. Raffaele Vitolo. |
From: Arthur N. <ac...@ca...> - 2011-11-27 09:44:40
|
On Sun, 27 Nov 2011, Raffaele Vitolo wrote: > Dear All, > > I use rule lists to define a set of variables. In a particularly heavy > computation with long rule lists I get the following message: > > +++ Error stack overflow: > Cont? (Y or N) > > I found in internet very limited information about enlarging the stack > memory size in reduce, so I'm asking your help to understand what I can do. > > Raffaele Vitolo. > >From the formt of the error message I am taking it that this is the CSL-based version, so my answer supposes that. With CSL there are two stacks used. One is entirely under control of CSL itself and is a stack of Lisp data-structures. There is provision for extending that using the "-K" command-line option. I will use this moment as an opportunity to explain that I have recently been trying to put in some work on the CSL documentation, and when you fetch from subversion these days you will find that csl/cslbase/csl.pdf is the work in progress on that - but under its section on command line options it mentions this case. I believe however that the issue you have run into is not this internal "lisp stack" so at this stage using "-K" will not help you. There is the regular stack that the C code that implements CSL uses. Here I need to check what operating system you are using since that matters! On Windows the stack size gets fixed and bound in at the moment you like an application. If you look in csl/cslbase/csl.c around line 1430 you will find me reading it via use of GetModuleHandle and the best recipes I could find. And if you when you configure csl you go "--with-csl --enable-debug" then you see it prints a message on startup saying how big a stack it found. As best I understand at present to have a larger stack I would need to adjust the Makefile and pass extra options to the linker, and I feel that no fixed different size would really be a LOT better than where we are now. On Linux/Unix/MacOSX I hope to be able to read the stack size as set by the "ulimit" command in bash and whatever applies if you are using a different shell. Go "ulimit -a" in bash to see where you are. If a user has set ulimit to "unlimited" then I default to allowing 4 Mbytes - because unlimited will really not be what it says and actually overflowing leads to corruption and abrupt disaster. So on *some* systems ulimit -a examine existing size ulimit -s 8192 make stack bigger ulimit -a check it has grown may help. Now there is a separate issue as to whether it is good that Reduce recurses ridiculously deep in the particular cases you have in hand, so if you can provide a reasonably compact example that leads to stack overflow then please send it to me so I can at least wonder if there is an easy way to reduce Reduce's use of stack in that instance. Note also that CSL and PSL may have different sets of optimisations in theor compilers as regards stack usage. I believe that PSL (by having FULL control of its compilation) can handle tail recursion better than CSL (that relies on an underlying C compiler) in some cases. But I also hope that the advantage there is not 100% one-sided. So try both the CSL and PSL version as a way to try to get the biggets possible calculation completed as well as sending us a test case to see if we can make a proper enhancement! Arthur |
From: Raffaele V. <raf...@un...> - 2011-11-28 01:36:50
|
Dear Arthur, On 11/27/2011 10:44 AM, Arthur Norman wrote: > On Sun, 27 Nov 2011, Raffaele Vitolo wrote: >> Dear All, >> >> I use rule lists to define a set of variables. In a particularly heavy >> computation with long rule lists I get the following message: >> >> +++ Error stack overflow: >> Cont? (Y or N) >> >> I found in internet very limited information about enlarging the stack >> memory size in reduce, so I'm asking your help to understand what I >> can do. >> >> Raffaele Vitolo. >> > > From the formt of the error message I am taking it that this is the > CSL-based version, so my answer supposes that. Yes! > I believe however that the issue you have run into is not this internal > "lisp stack" so at this stage using "-K" will not help you. There is the > regular stack that the C code that implements CSL uses. Here I need to > check what operating system you are using since that matters! I'm using Ubuntu 11.04 on a multiprocessor server, and this is the output of `uname -a' : vitolo@sophus:~/computations$ uname -a Linux sophus 2.6.38-8-server #42-Ubuntu SMP Mon Apr 11 03:49:04 UTC 2011 x86_64\ x86_64 x86_64 GNU/Linux > On Linux/Unix/MacOSX I hope to be able to read the stack size as set by > the "ulimit" command in bash and whatever applies if you are using a > different shell. Go "ulimit -a" in bash to see where you are. If a user > has set ulimit to "unlimited" then I default to allowing 4 Mbytes - > because unlimited will really not be what it says and actually > overflowing leads to corruption and abrupt disaster. > > So on *some* systems > ulimit -a examine existing size > ulimit -s 8192 make stack bigger > ulimit -a check it has grown > may help. The default value of the stack size in a bash shell in my machine is exactly 8192. Coming to computations, I tried the following memory enlargements on the same computation that generated the error, and got exactly the same error at the same point: 1 - enlarged the stack size with ulimit -s 819200 and PSL reduce; got `unable to allocate 33d8000 33b7000 ***** Heap space low' 2 - the same with CSL reduce; got `+++ Error stack overflow:' 3 - enlarged the heap size with redcsl -K4096; got `+++ Error stack overflow:' 4 - enlarged both stack size and heap size with a combination of 2 and 3; got `+++ Error stack overflow:' The only thing that worked was running `redcsl -K4096/10'; according with your documentation (thanks a lot for having written it!), this amounts at enlarging the number of `CSL pages of Lisp stack', whatever this means. This number 10 came out of nothing and I'd like very much to know how to guess it and how to pass it to redcsl without the need to pass the heap size, in view of the fact that heap size is dynamically allocated. > Now there is a separate issue as to whether it is good that Reduce > recurses ridiculously deep in the particular cases you have in hand, so > if you can provide a reasonably compact example that leads to stack > overflow then please send it to me so I can at least wonder if there is > an easy way to reduce Reduce's use of stack in that instance. Well, I'm trying to solve the following problem. I have a system of algebraic equations of the form a=f(a,b,c,d,e,..) b=g(a,b,c,d,e,..) c=h(a,b,c,d,e,..) I'd like to solve it for a,b,c. I know by mathematical results that the solution exists and is unique. Indeed, I obtain it when the number of equations and variables of type a,b,c is small (<=400). In order to obtain it, I use rule lists in this way: I create a list {a=f(...),b=...,c=...} then I issue the commands a1:=a where rulelist; b1:=b where rulelist; c1:=c where rulelist; This works although slowly, because I guess that it amounts at recomputing rules each time. But when I tried something more complicated I failed as I told you above. I also tried let rules , but I guess that they are reevaluated each time that the quantities a1, etc.. are required, and this makes everything unbearably slow. Now I'm thinking about changing the above mechanism to an iterative substitution. I'm sorry if the problem might look trivial for you but I'm relatively new to symbolics! Thanks for your help, Raffaele. |
From: Andrey G. G. <A.G...@in...> - 2011-12-09 06:15:08
|
Hello *, I've checked out reduce-algebra 1528. In trunk, I do ./configure --with-csl make The only output I get is /bin/sh scripts/make.sh Current machine tag is i686-pc-linux-gnu host=i686-pc-linux-gnu os=unknown and make exits. I suppose $os should be linux-gnu, right? grozin@elrond ~/reduce-1528/trunk $ uname -a Linux elrond 2.6.36-gentoo-r1 #1 SMP PREEMPT Wed Nov 24 22:00:12 NOVT 2010 i686 Pentium(R) Dual-Core CPU E5300 @ 2.60GHz GenuineIntel GNU/Linux grozin@elrond ~/reduce-1528/trunk $ lsb_release -d Description: Gentoo Base System release 2.1 grozin@elrond ~/reduce-1528/trunk $ lsb_release -r Release: 2.1 Even if I add *Gentoo*) vendor="gentoo" ;; to the list of known vendors, this does not help. Then I have vendor=gentoo, version=2.1, and hence os=gentoo2.1. And there is no *-gentoo2.1 in cslbuild. Also, there are no cslbuild/*-fedora*, etc., there is only cslbuild/i686-pc-linux-gnu. Therefore, scripts/make.sh will also fail on debian, ubuntu, fedora, suse, and all other linux distros known to the mankind. So, what's the real purpose of scripts/findos.sh? Should $os be linux-gnu for all linuxen? Or there should be some extra directories in cslbuild? In reduce-20110414, after ./configure --with-csl make I see /bin/sh scripts/make.sh Current machine tag is i686-pc-linux-gnu About to build in cslbuild/i686-pc-linux-gnu and make proceeds to build the csl reduce. So, this is a post-20110414 breakage. diff of scripts/make.sh in 20110414 and the current svn is --- scripts/make.sh 2010-10-23 16:41:13.000000000 +0700 +++ /home/grozin/reduce-1528/trunk/scripts/make.sh 2011-12-09 11:12:18.000000000 +0700 @@ -47,2 +47,3 @@ host=`scripts/findhost.sh $host` +os=`scripts/findos.sh` @@ -76,3 +77,7 @@ -for l in cslbuild/*-*-* pslbuild/*-*-* +echo host=${host} os=${os} + +rc=0 + +for l in cslbuild/*-${os}* pslbuild/*${host}* do (plus some harmless rc stuff). So, now, instead of cslbuild/*-*-* we use only cslbuild/*-${os}*, and this change breaks the build. By the way, I'm the maintainer of the reduce package in Gentoo linux. Currently, it's at the version 20110414; but if this problems will not be fixed before the next release, I'll be unable to package it. Best wishes, Andrey |
From: Andrey G. G. <A.G...@in...> - 2011-12-09 06:15:34
|
Hello *, You can use psl reduce from a nice graphical interface in GNU TeXmacs. To do so, you have to change the script name reduce -> redpsl in 2 places: /usr/share/TeXmacs/plugins/reduce/progs/init-reduce.scm /usr/libexec/TeXmacs/bin/tm_reduce and to include the lines lisp << if getenv("TEXMACS_REDUCE_PATH") then load tmprint >> $ into your ~/.reducerc. This does not work with csl reduce: even after loading tmprint, csl reduce does not change its prompt in such a way that TeXmacs recognizes it as a prompt. In support/smacros.red, there is symbolic smacro procedure texmacsp; if getenv "TEXMACS_REDUCE_PATH" then t; and it is used in support/cslrend.red (and in lpdo/lpdo.red). But it seems to have (currently?) no effect. Is there any way to redefine the prompt in csl reduce? Andrey |
From: Andrey G. G. <A.G...@in...> - 2011-12-09 07:06:08
|
Hello *, For many years, I used psl reduce, and inserted input_case nil$ as the first line of each script (I prefer x and X to be two distinct variables). But csl reduce does not understand input_case. Any chance of implementing it in csl reduce? Andrey |
From: Rainer S. <rai...@gm...> - 2011-12-12 17:24:46
|
On Fri, 9 Dec 2011 at 14:06 +0700, Andrey G. Grozin wrote: > Hello *, > > For many years, I used psl reduce, and inserted > > input_case nil$ > > as the first line of each script (I prefer x and X to be two distinct > variables). But csl reduce does not understand input_case. Any chance of > implementing it in csl reduce? CSL has the lower switch. I believe off lower; does what you want in CSL REDUCE. I agree that this is something which should be done in the same way in both SPL and CSL REDUCE. Rainer |
From: Andrey G. G. <A.G...@in...> - 2011-12-09 08:17:30
|
OK, after changing for l in cslbuild/*-${os}* pslbuild/*${host}* back to for l in cslbuild/*-*-* pslbuild/*${host}* in scripts/make.sh, I've successfully build csl reduce. Currently, we (Gentoo) cannot support psl reduce, because it requires internet connection at ./configure time. From BUILDING, I understood that it is possible to build psl reduce from the sources in the tarball. How to do this? If I'll be able to build it, I'll include also psl reduce into the Gentoo package. A little suggestion: why not add the lines cd generic/libreduce make cd ../qreduce ln -s ../libreduce/*/RedPy.so . cd ../redfront make make install-csl install-psl cd ../.. to rebuild.sh? (in order not to forget to do these steps). Andrey |
From: Andrey G. G. <A.G...@in...> - 2011-12-09 08:58:02
Attachments:
32bit.patch
|
Hello *, In order to use qreduce on 32-bit linux, the attached patch is needed (many thanks to Thomas Sturm). However, qreduce does not display nice forms of results for ps (the package tps) and fps (the package fps). Andrey |
From: Andrey G. G. <A.G...@in...> - 2011-12-09 09:17:13
|
The last question for today. One of Gentoo users having an amd64 machine tried to compile csl reduce (it was 20101007), but got a lot of compilation errors in generated .c files. Can csl reduce be built on 64-bit linux? (I don't have the necessary hardware to check this myself). Andrey |
From: Rainer S. <rai...@gm...> - 2011-12-12 20:58:58
|
On Fri, 9 Dec 2011 at 16:17 +0700, Andrey G. Grozin wrote: > The last question for today. One of Gentoo users having an amd64 machine > tried to compile csl reduce (it was 20101007), but got a lot of > compilation errors in generated .c files. Can csl reduce be built on > 64-bit linux? (I don't have the necessary hardware to check this myself). Yes, Csl Reduce can be built on 64-bit linux. I have just built the current svn trunk on 64-bit ubuntu 11.10. I'm not entirely sure whether there was a problem with the 20101007 release; if the problem persist with the current trunk, we'd appreciate more information. Rainer |