orc-lang / orc

Orc programming language implementation
https://orc.csres.utexas.edu/
BSD 3-Clause "New" or "Revised" License
40 stars 3 forks source link

mysterious token limit #31

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Run the following program with N=17 works but N=18 does not. It hangs at
token 262143 (or more accurately seems to go into an infinite loop). Why?

------ START PROGRAM
val N = 18
site println = orc.lib.str.Println
site (-) = orc.lib.math.Sub
site (*) = orc.lib.math.Mult
site (+) = orc.lib.math.Add

def threads(0, id) = println("stop " + id) >> stop
def threads(n, id) = println("fork " + id) >>
  ( threads(n-1, id*2) | threads(n-1, id*2+1) )

threads(N, 1) ; signal
------ END PROGRAM

Original issue reported on code.google.com by adrianqu...@gmail.com on 22 Apr 2009 at 1:54

GoogleCodeExporter commented 9 years ago

Original comment by adrianqu...@gmail.com on 22 Apr 2009 at 1:54

GoogleCodeExporter commented 9 years ago
More data; the following program works (on booze.cs.utexas.edu) with N=18, but 
not N=19.

val N = 18
site (-) = orc.lib.math.Sub

def threads(0) = stop
def threads(n) = n-1 >n'> ( threads(n') | threads(n') )

threads(18) ; signal

Original comment by adrianqu...@gmail.com on 22 Apr 2009 at 3:06

GoogleCodeExporter commented 9 years ago
After much investigation I'm pretty sure that there's nothing wrong with the
interpreter except that it's slow. The apparent "infinite loop" is just the 
result of
the fact that we evaluate tokens breadth-first, so at the deeper levels of the 
tree,
the interpreter has to iterate through the hundreds of thousands of threads 
several
times before any of them make visible progress. It looks like nothing is 
happening
but if you let the program run long enough it makes progress.

Original comment by adrianqu...@gmail.com on 22 Apr 2009 at 11:15