CPS problems in Nim 2.0.8

2024-07-07 Thread DougT
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.

Problem with a highly recursive function

2024-07-07 Thread DougT
note that ack(3,14) generates 11452590817 calls to ack. Runs quite a bit faster on 2.0.8 if --mm:refc is used.

Problem with a highly recursive function

2024-07-06 Thread DougT
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

Highly recursive function problem

2024-07-06 Thread DougT
this is a test

Problem with a highly recursive function

2024-07-06 Thread DougT
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

bignum note

2024-02-03 Thread DougT
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

nico graphics line width

2023-02-20 Thread DougT
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?

Nim vs the 6 languages I learned before it

2023-02-20 Thread DougT
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

Question on GTK3 mouse processing

2023-02-19 Thread DougT
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

Question about taskpools

2022-12-28 Thread DougT
@shirleyquirk Thanks for the solution.

nim 2.0 RC1 taskpools error

2022-12-28 Thread DougT
@shirleyquirk That fixed it. Thanks.

Parallel Fibonacci

2022-12-28 Thread DougT
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

nim 2.0 RC1 taskpools error

2022-12-28 Thread DougT
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(

Question about taskpools

2022-12-28 Thread DougT
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(

Parallel Fibonacci

2022-12-27 Thread DougT
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 version 2.0 RC1

2022-12-23 Thread DougT
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

Tutorial for nim pixie graphics?

2022-12-19 Thread DougT
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.

Tutorial for nim pixie graphics?

2022-12-19 Thread DougT
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.

BigNum and BigInt timings on the Pollard Rho algorithm

2022-12-15 Thread DougT
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

Odd timings for threads

2022-12-15 Thread DougT
@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

Odd timings for threads

2022-12-15 Thread DougT
* 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

BigNum and BigInt timings on the Pollard Rho algorithm

2022-12-15 Thread DougT
@diesnoff I am not very conversant with Github. If you send me an email, I will send you the code: doug at dougtelford.com

Odd timings for threads

2022-12-15 Thread DougT
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 ``

Strange timings for threads

2022-12-15 Thread DougT
> 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 `

BigNum and BigInt timings on the Pollard Rho algorithm

2022-12-15 Thread DougT
You are correct. The timings go up from 1.38 seconds to 3.32 seconds, which is tolerable for better readability.

Strange thread timings

2022-12-15 Thread DougT
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 ``

Odd timings using threads

2022-12-15 Thread DougT
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 ``

BigNum and BigInt timings on the Pollard Rho algorithm

2022-12-14 Thread DougT
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.

BigNum and BigInt timings on the Pollard Rho algorithm

2022-12-13 Thread DougT
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.

BigNum and BigInt timings on the Pollard Rho algorithm

2022-12-13 Thread DougT
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: `