> @jzakiya: The limit is at one billion now.
+1!!
@jyapayne: Not sure, I like it to error out. Warning doesn't seem
right for what is ultimately a batch process. @jzakiya: The limit is at one
billion now.
Araq, maybe it would be more appropriate to have this as a warning instead of
stopping compilation completely? Something like "Warning: Compiler has been
through 1_000_000_000 iterations, compile time code might be in an infinite
loop"
OK, I set `MaxLoopIterations* = 1_000_000_000` (1 Billion) in
`~/nim-0.18.0/compiler/vmdef.nim` and rebuilt doing `./koch boot -d:release`
and was able to compile P17.
I think this value is way more reasonable, because as stated previously, on
modern machines (or really any system with
Such a limit would probably be around a few seconds, rather than a fixed number
of iterations, because that's where most people start to suspect that their
computation is either too long or stuck in an infinite loop.
Then the limit would depend on the used CPU. Bad idea IMO.
> Why not add a flag to set/disable the iteration limit like he wants? I'm sure
> that as the user base grows, more people are going to hit the limit and get
> annoyed.
Because I am curious whether it can be supported out of the box by a
"reasonable" limit first.
Why not add a flag to set/disable the iteration limit like he wants? I'm sure
that as the user base grows, more people are going to hit the limit and get
annoyed.
> Do I need to recompile|rebuild Nim to make the change?
Yup. `koch boot -d:release` creates the modified compiler if you have an
installation where `koch boot` works (pick the "installation from source"
route:
Compiling again for P17, with 0.18.0 and 0.17.2, the error messages point to
`gcd` function in both cases:
# 0.18.0 error message
generating parameters for P17
stack trace: (most recent call last)
twinprimes_ssozp17par5d3.nim(87)
twinprimes_ssozp17par5d3.nim(65)
One (last?) trick to reduce the number of iterations.
I changed this:
var residues: seq[int] = @[]
var pc = 1
while pc < modpg: (pc += 2; if gcd(modpg, pc) == 1: residues.add(pc))
let rescnt = residues.len
to this:
var residues:
OK, **I finally got it to compile with the original iteration count** , but
man, did I have to jump through hoops to do it.
To reduce the number of loops, instead of doing `brute force trial-and-error`
to test each residue against the others to find its inverse, I found the code
here
I started changing the `MaxLoopIterations* = 1500_000 # max iterations of all
loops` line in `compiler/vmdef.nim` in increments of 1 million, until it was
20M, recompiling after each change, and still got error. Then I went up in 100M
increments until 1 trillion, and still got error.
Do I need
> I'm also reached this limit before, but avoided it by simplifying
> compile-time code.
Alright, I take it back.
BTW `let` instead of `const` for computed lookup tables is also an option.
I'm also reached this limit before, but avoided it by simplifying compile-time
code. You may try to find a way to reduce number of function calls per loop
iteration to fit the limit.
1. It is perfectly feasible to write a Nim program that outputs an array
literal as a string. The compiler supports this out of the box with
`staticExec` and its caching mechanism. No need for Ruby.
2. You're the first person on earth that did run into this limit of Nim's VM,
afaict anyway.
> I could use Ruby to create all the parameters and dump them into a file too,
> which would be easier.
You could, couldn't you? It does sound better than doing this:
> displayed to terminal, copied, pasted into an editor, line formatted, copied,
> then pasted the formatted array values into
I could use Ruby to create all the parameters and dump them into a file too,
which would be easier.
**I Don 't want to jump through extra HOOPs because the Nim compiler is
deficient!!**
I don't have to do this in C++.
The compiler should work for the human, not the other way around.
As a temporary workaround, couldn't you just take your existing Nim function,
use it to generate your stuff at runtime, then dump it into a .nim file?
I raised this issue regarding 0.17.2 but it still persists in 0.18.0.
I want to generate some system constants at compile time.
I need to generate some constant arrays of numbers for a (selectable) prime
generator (PG).
When the array size gets past some (?) value the compiler quits with this
20 matches
Mail list logo