I am trying the tutorial programs for CPS using nim 2.0.8.
1. Program cpstut1.nim runs ok, but if if put the global code in proc main, I
get the error
/home/doug/nim-tdt/cps/hello2.nim(18) hello2
/home/doug/nim-tdt/cps/hello2.nim(15) main
SIGSEGV: Illegal storage access.
note that ack(3,14) generates 11452590817 calls to ack. Runs quite a bit faster
on 2.0.8 if --mm:refc is used.
ack(3,14) runs ok if d:release is used. So the question should be modified to
ask if there is a way to run the function without d:release or d:danger
this is a test
The Ackermann function is non primitive recursive (See the wikipedia article).
Is there any way to run ack(3,14) without using d:danger. Using
-d:nimCallDepthLimit does not work since the value must be a 16 bit int.
proc ack(m,n:int) : int =
if m == 0 :
return n+1
The following had been working recently on nim 2.0.2:
> `nimble install https://github.com/adokitkat/**bignum**`
This was supplied by @lscrd in Aug 2023 on the forum.
Recently this did not work, but the following did:
> `nimble install https://github.com/adokitkat/bignum`
which installs bignum
I am quite impressed with nico. I am mainly using it for graphics and animated
graphics ( I am not much of a gamer). In my first example with nico, I
programmed the Koch snowflake. It looks good, but would be better if I could
increase the line width. Is this possible with nico?
Regarding the slow speed of Python: If you use pypy you can get a speedup of
about 6x or more (which is still quite a bit slower than nim). Using the
classical fibonacci benchmark (no optimizations) the results for fib(45):
python 3.9.16: 170 seconds pypy7.3.9 : 10.7 seconds nim 1.6.10 : 1.6 sec
I am converting a PyGTK program to nim. The graphics work, but I am having a
problem with mouse processing.
I want to detect a mouse button press, determine which one of the 3 mouse
buttons was pressed, and get the x,y coordinates of the press. From the gtk3
samples and docs, it was not clear t
@shirleyquirk Thanks for the solution.
@shirleyquirk That fixed it. Thanks.
Solution using taskpool
nimble install taskpools
Run
my test program:
# fib(47) = 2971215073
# without threads: 5.491s. this program with threads: 0.650s
import
std/cpuinfo,
taskpools
const nthreads = 12 # 6 core system, 12
install taskpools
Run
my test program:
# fib(47) = 2971215073
# without threads: 5.491s. this program with threads: 0.650s
import
std/cpuinfo,
taskpools
const nthreads = 12 # 6 core system, 12 hyper threads
var tp = Taskpool.new(
install taskpools
Run
my test program:
# fib(47) = 2971215073
# without threads: 5.491s. this program with threads: 0.650s
import
std/cpuinfo,
taskpools
const nthreads = 12 # 6 core system, 12 hyper threads
var tp = Taskpool.new(
As a learning exercise in parallel computing, I would like to parallel compute
the classic definition of the Fibonacci sequence. I realize there are many fast
ways to compute the Fibonacci sequence, but I would like to use the classical
definition as an exercise.
If I try
import t
nim 2.0 RC1
nim2 c -d:release rho4.nim
import bignum # 0.4 latest version
...
/home/doug/.nimble/pkgs/gmp-0.2.5/gmp/pure.nim(19, 48) Error: invalid
indentation
Run
I had not seen pixiebook. If you google
pixie graphics tutorial
Run
then I believe there is not a reference to pixiebook. I will study pixiebook
and in about a week reply with what additional material I would like to see.
I have not found a tutorial. I think we need something more in depth than the
simple examples on Github treeform/pixie. References to more detailed examples
would also be helpful.
If I compile bigints with
nim c -d:release --passC:-flto --passL:-s --mm:arc rho1.nim
Run
I get improved timings of:
real1m24.066s
user1m24.060s
sys 0m0.000s
Run
@Stefan_Salewski Thanks for your thorough analysis. Using --mm:arc I get the
following timings using options -d:release -mm:arc
Main thread only:
real0m1.463s
user0m0.611s
sys 0m0.851s
Run
With one thread for proc sum:
real
* I have 6 physical cores
* All versions return the correct answer. I expected the version with a thread
for proc sum to be about the same elapsed time as the single thread main
version, but it isn't. Also the 2 thread version of proc sum is slower that
both of the others.
* I tried the 3 progra
@diesnoff I am not very conversant with Github. If you send me an email, I will
send you the code: doug at dougtelford.com
The timing on my problem using threads seems odd. The program with just the
main thread (listing below) does the following:
1. fills a large ref array with value 1 in the lower half and 2 in the upper
half.
2\. calls proc sum, which sums the values of the ref array. For compiling I use
``
> The timing on my problem using threads seems odd.
The program with just the main thread (listing below) does the following:
1. fills a large ref array with value 1 in the upper half and 2 in the lower
half.
2. calls proc sum, which sums the values of the ref array.
For compiling I use `
You are correct. The timings go up from
1.38 seconds to 3.32 seconds, which is tolerable for better readability.
The timing on my problem using threads seems odd. The program with just the
main thread (listing below) does the following:
1. fills a large ref array with value 1 in the lower half and 2 in the upper
half.
2\. calls proc sum, which sums the values of the ref array. For compiling I use
``
The timing on my problem using threads seems odd.
The program with just the main thread (listing below) does the following:
1. fills a large ref array with value 1 in the lower half and 2 in the upper
half.
2\. calls proc sum, which sums the values of the ref array. For compiling I use
``
The markandsweep GC option was copied from other runs where it did improve the
run time, but on the Pollard Rho it makes no difference.
I installed bigints and bignum from nimble. My understanding is that bigints
(the slower one) is entirely written in nim while bignum is a wrapper for gmp.
I have not tried bignumber.nim. It appears to be a work in progress. It does
not have gcd (which I need), although it is easy to write one.
So far I am enjoying nim. I have a personal benchmark that I try on each new
language that I try. It uses the Pollard Rho algorithm to find a factor or
2^257 - 1. I am using linux mint and a Ryzen 5600x cpu slightly overclocked
(Geekbench single core score of 1730).
For my nim runs I use:
`
30 matches
Mail list logo