User avatar
davidcoton
Posts: 4243
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK

Re: Tatami Pi Fun.

Sat Nov 30, 2019 10:17 pm

ejolson wrote:
Sat Nov 30, 2019 10:12 pm
To save the most money I've decided to drive my car with the engine turned off, which is surprisingly similar to using the PET emulator.
Does that mean that Fido has to pedal harder?
Signature retired

Heater
Posts: 13866
Joined: Tue Jul 17, 2012 3:02 pm

Re: Tatami Pi Fun.

Sun Dec 01, 2019 5:41 am

Something has gone horribly wrong here.

I translated prune.c to rust. Or at least I thought I did. Being tired and lazy I made all the variables i64. And this happened on my x86-64 PC:

Code: Select all

$ /usr/bin/time cargo run --release
    Finished release [optimized] target(s) in 0.03s
     Running `target/release/tatami_rust`
T(85765680)=200
6576.56user 0.26system 1:49:54elapsed 99%CPU (0avgtext+0avgdata 9176maxresident)k
0inputs+0outputs (0major+334minor)pagefaults 0swaps
Yes, 1 hour 49 minutes to run the original problem! With the values of fnum, Pnum and smax of prune.c

I don't see what I translated incorrectly. If I had made mistake I would expect to get a totally wrong answer.

Grrr...
Memory in C++ is a leaky abstraction .

jahboater
Posts: 4826
Joined: Wed Feb 04, 2015 6:38 pm

Re: Tatami Pi Fun.

Sun Dec 01, 2019 8:05 am

The resident memory usage is much larger with more page faults?
Not enough to be swapping I would have thought.
prune.c uses:

Code: Select all

T(85765680)=200
2.54user 0.00system 0:02.54elapsed 100%CPU (0avgtext+0avgdata 1640maxresident)k
0inputs+0outputs (0major+137minor)pagefaults 0swaps

Heater
Posts: 13866
Joined: Tue Jul 17, 2012 3:02 pm

Re: Tatami Pi Fun.

Sun Dec 01, 2019 12:11 pm

Thanks for that reference timing jahboater.

Thinking I may have been over tired and done something dumb last night I ran it again this morning:

Code: Select all

$ /usr/bin/time target/release/tatami_rust
T(85765680)=200
6284.73user 0.15system 1:44:46elapsed 99%CPU (0avgtext+0avgdata 1172maxresident)k
0inputs+0outputs (0major+335minor)pagefaults 0swaps
Sure enough, 1.75 hours !

That was using the prune.c constants: PNUM = 40000, SMAX = 100_000_000_000, FNUM = 20

Using the old limited.c constants things are a little different:

Code: Select all

$ /usr/bin/time target/release/tatami_rust
T(85765680)=200
1.18user 0.03system 0:01.21elapsed 100%CPU (0avgtext+0avgdata 868maxresident)k
0inputs+0outputs (0major+255minor)pagefaults 0swaps
Edit: Which about half the speed of my previous result on x86-64!

As I was watching task manger occasionally during that long run I did not see CPU usage get into 20% and memory usage was pretty small. Very strange.
Memory in C++ is a leaky abstraction .

ejolson
Posts: 3798
Joined: Tue Mar 18, 2014 11:47 am

Re: Tatami Pi Fun.

Sun Dec 01, 2019 4:16 pm

Though having twice as many feet, Fido refused to pedal. After sitting in the motionless car for some time, I realised that a PET emulator was, in fact, much faster. As invention is the mother of necessity, I came up with a plan.

With a sigh I turned to Fido and asked, if the car doesn't move, how can we go get dog treats? Upon hearing this, the head of marketing and transportation began to pedal at warp speed. In retrospect this may have been a mistake, because
  • The traffic lights were out due to the wind and snow.
  • The dog treats turned out to be more expensive than petrol.
Fortunately, Fido soon switched out of warp mode and we returned safely.
Heater wrote:
Sun Dec 01, 2019 12:11 pm
Thinking I may have been over tired and done something dumb last night I ran it again this morning
Try doing a diff between limited.c and prune.c, then comparing that to a diff between the two rusty programs.

Since returning the dog developer has been busy eating treats while typing at the Pi 4B. I asked, what are you doing? But there was no reply. Either Fido is in the flow or just acting grumpy. I glanced discreetly at the screen and noticed a modified recipe for chow mei fun in one window and a modified version of prune.c in the other. This made me a bit worried, so I took a closer look.

Fido was adding logarithms--or possibly dogarithms--to the tatami code. I suspect this is an advanced technique to obtain better parallel scaling, not unlike how the store had increased the price of dog treats so the coming holiday discounts will look better.
Last edited by ejolson on Mon Dec 02, 2019 2:31 am, edited 2 times in total.

jcyr
Posts: 483
Joined: Sun Apr 23, 2017 1:31 pm
Location: Atlanta

Re: Tatami Pi Fun.

Sun Dec 01, 2019 5:02 pm

Rust written OS only a few months away

https://www.theregister.co.uk/2019/11/2 ... lfhosting/
It's um...uh...well it's kinda like...and it's got a bit of...

jahboater
Posts: 4826
Joined: Wed Feb 04, 2015 6:38 pm

Re: Tatami Pi Fun.

Sun Dec 01, 2019 5:51 pm

jcyr wrote:
Sun Dec 01, 2019 5:02 pm
Rust written OS only a few months away

https://www.theregister.co.uk/2019/11/2 ... lfhosting/
I'll be impressed if Redox has absolutely no "unsafe" sections and is written entirely in Rust.

ejolson
Posts: 3798
Joined: Tue Mar 18, 2014 11:47 am

Re: Tatami Pi Fun.

Sun Dec 01, 2019 6:44 pm

jahboater wrote:
Sun Dec 01, 2019 5:51 pm
jcyr wrote:
Sun Dec 01, 2019 5:02 pm
Rust written OS only a few months away

https://www.theregister.co.uk/2019/11/2 ... lfhosting/
I'll be impressed if Redox has absolutely no "unsafe" sections and is written entirely in Rust.
I'm more impressed by the statement
Tim Anderson wrote: It also has an innovative philosophy which adapts the "everything is a file" idea in Unix to become "everything is a URL".
and how that might affect security.

The canine coder was taking a break from eating dog treats, so I asked for a second opinion. After reading the article Fido said, a URL simply makes the location of something explicit in its name. As an example, "D:\MORE\TATAMI" is the same idea. Judging from how predictable device names have become popular in Linux, it appears humans have no interest in abstractions. The head of marketing went on, dogs on the other paw... look a port to the Raspberry Pi is underway.

I read the end of the article and noted that indeed a port seemed in progress. At the same time, if it had taken Linus more than four years to make Linux self hosting, by then the licensing dispute over BSD would have been cleared up.

Heater
Posts: 13866
Joined: Tue Jul 17, 2012 3:02 pm

Re: Tatami Pi Fun.

Sun Dec 01, 2019 7:53 pm

@ejolson,
Try doing a diff between limited.c and prune.c, then comparing that to a diff between the two rusty programs.
Been there, done that. When every line has changed it's hard to tell what is what. I do wish people would use git if they are going to publish different, ever changing, versions of their code.

On the other hand... I was busy playing with modules in Rust, so that I could put different versions into the same program for comparison. So diffing that was a nightmare.

@jcyr
Rust written OS only a few months away
Excellent!

@jahboater
I'll be impressed if Redox has absolutely no "unsafe" sections and is written entirely in Rust.
You will only be impressed by the impossible then. Your life will be sad with disappointment.

When the memory safety rules of Rust meet hardware all bets are off. It's a bit like trying to play cricket when the opposing team turns up with hand grenades!

Anyway, the whole point of "unsafe" is to identify those that play by the rules as opposed to those that do not. Hopefully only a small part of the code base. Typically one percent.

And of course there are those operating things that one needs to do that require all kind of strange machine instructions that we cannot expect a high level language compiler to support.

On the other hand, you raise a good point. Why should hardware get to use hand grenades? It should be designed to be as safe as the systems we are trying to build on top of it.

@ejolson
I'm more impressed by the statement....and how that might affect security.
Think about this:

If you are running Linux, say Debian, every file of that OS no doubt came from a URL somewhere. Likely it is updated from URL's from time to time.

Similarly, my Windows 10 machine is totally a download from a URL from Microsoft. It updates itself from URLs, from God knows where.

It's time to face the fact that we are not masters of our kingdoms using our own private stuff. Rather we are using the produce of other humans all over the world.

Unless you created it yourself every file on your machine came from a URL.

If we face that reality then the question is "Who do we trust?"
Memory in C++ is a leaky abstraction .

Heater
Posts: 13866
Joined: Tue Jul 17, 2012 3:02 pm

Re: Tatami Pi Fun.

Sun Dec 01, 2019 9:28 pm

Yay, I have a result on my Pi3 B, as 64 bit executable:

Code: Select all

$ cargo build --release
...
$ time target/release/tatami_rust
Pr40000=479909
T(63405342000)=1000
real    38m13.679s
user    38m13.231s
sys     0m0.049s
Which I think is at least correct.

Everything is i64 in this code. Might be worth tweaking that...
Memory in C++ is a leaky abstraction .

jcyr
Posts: 483
Joined: Sun Apr 23, 2017 1:31 pm
Location: Atlanta

Re: Tatami Pi Fun.

Sun Dec 01, 2019 10:07 pm

Heater wrote:
Sun Dec 01, 2019 9:28 pm
Everything is i64 in this code. Might be worth tweaking that...
Most variable don't need to be 64 bits. As you've noticed for this particular case, 64 bit Pi is much better than 32 bit Pi.

Code: Select all

#include <iostream>

const uint64_t smax = 100000000000ULL;
const uint32_t Pnum = 40000;
const uint32_t fnum = 20;

typedef struct
{
    uint64_t s;
    uint32_t fmax, i, p[fnum];
    uint8_t n[fnum];
} factors;

factors x;
uint32_t Pn, Tisn, in;
uint64_t P[Pnum], smin;
uint8_t z[fnum];

bool tfree(uint64_t k, uint64_t  l)
{
    uint64_t n = l / k;
    uint64_t lmin = (k + 1) * n + 2;
    uint64_t lmax = (k - 1) * (n + 1) - 2;
    return lmin <= l && l <= lmax;
}

bool isprime(uint64_t p)
{
    uint32_t i;
    for (i = 1; i < in; i++)
    {
        if (!(p % P[i]))
            return 0;
    }
    for (i = in; P[i] * P[i] <= p; i++)
    {
        if (!(p % P[i]))
            return 0;
    }
    in = i - 1;
    return 1;
}

void doinit()
{
    uint32_t i, p;
    uint64_t r;
    smin = smax;
    P[0] = 2;
    P[1] = 3;
    Pn = 2, in = 1;
    for (p = 5; Pn < Pnum; p += 2)
    {
        if (isprime(p))
            P[Pn++] = p;
    }
    if (p <= smax / p + 1)
    {
        std::cout << "The maximum prime " << p << " is too small!" << std::endl;
        exit(1);
    }
    r = 1;
    for (i = 0; i < fnum - 1; i++)
    {
        if (P[i] > smax / r + 1)
            return;
        r *= P[i];
    }
    std::cout << "Distinct primes " << fnum << " in factorisation too few!" << std::endl;
    exit(2);
}

uint64_t ppow(uint64_t p, uint32_t n)
{
    uint64_t r;
    if (!n)
        return 1;
    r = 1;
    for (;;)
    {
        if (n & 1)
            r *= p;
        n >>= 1;
        if (!n)
            return r;
        p *= p;
    }
}

uint32_t sigma()
{
    uint32_t i;
    uint32_t r = x.n[0];
    for (i = 1; i <= x.fmax; i++)
        r *= x.n[i] + 1;
    return r;
}

uint32_t T()
{
    uint32_t r, w;
    for (w = 0; w < fnum; w++)
        z[w] = 0;
    r = 0;
    for (;;)
    {
        uint32_t i;
        uint64_t k, l;
        for (i = 0; i <= x.fmax; i++)
        {
            if (z[i] < x.n[i])
            {
                z[i]++;
                break;
            }
            z[i] = 0;
        }
        if (i > x.fmax)
            break;
        k = 1;
        l = 1;
        for (i = 0; i <= x.fmax; i++)
        {
            k *= ppow(x.p[i], z[i]);
            l *= ppow(x.p[i], x.n[i] - z[i]);
        }
        if (k <= l)
            r += tfree(k, l) ? 1 : 0;
    }
    return r;
}

void Twork()
{
    uint64_t s, pmax;
    uint32_t fmax, i, p, r;
    s = x.s;
    r = sigma();
    if (r >= Tisn)
    {
        r = T();
        if (r == Tisn && s < smin)
            smin = s;
    }
    i = x.i;
    fmax = x.fmax;
    pmax = smin / s + 1;
    p = (uint32_t)P[i];
    if (p <= pmax)
    {
        x.n[fmax]++;
        x.s = s * p;
        Twork();
        x.n[fmax]--;
    }
    fmax++;
    x.n[fmax] = 1;
    for (i++; i < Pnum; i++)
    {
        p = (uint32_t)P[i];
        if (p > pmax)
            break;
        x.p[fmax] = p;
        x.s = s * p;
        x.i = i;
        x.fmax = fmax;
        Twork();
    }
    x.n[fmax] = 0;
}

uint64_t Tinv(uint32_t n)
{
    Tisn = n;
    x.p[0] = uint32_t(P[0]);
    x.n[0] = 1;
    x.i = 0;
    x.s = 2;
    x.fmax = 0;
    Twork();
    return smin < smax ? smin : -1;
}

int main()
{
    uint32_t n = 1000;
    doinit();
    std::cout << "T(" << Tinv(n) << ")=" << n << std::endl;
    return 0;
}
What I'd really like is a native 64 bit Raspbian. 64 bit Ubuntu for Pi4 works quite well (with the 4 Gig fix patch), but the Gnome desktop is a bit of a pig on the Pi.
It's um...uh...well it's kinda like...and it's got a bit of...

Heater
Posts: 13866
Joined: Tue Jul 17, 2012 3:02 pm

Re: Tatami Pi Fun.

Sun Dec 01, 2019 11:04 pm

jcyr,
Most variable don't need to be 64 bits.
Of course.
As you've noticed for this particular case, 64 bit Pi is much better than 32 bit Pi.
It's not clear to me that I have noticed any such thing.

Last time I had comparable results 64 bits on the Pi was only about 30% faster than 32. Hardly worth shouting about.

However, I'm all for a 64 bit system on the Pi. This prune.c for example gives totally the wrong result when compiled and run on regular 32 bit Raspbian.

But hey, that is an undefined behavior of C in play there.
Memory in C++ is a leaky abstraction .

Heater
Posts: 13866
Joined: Tue Jul 17, 2012 3:02 pm

Re: Tatami Pi Fun.

Sun Dec 01, 2019 11:29 pm

Speaking of which. We have been living with C/C++ for so many decades we start to think it actually makes sense. Well no, it has made us crazy.

Get this typical example:

Code: Select all

$ gcc -Wall -O3 -o prune prune.c
prune.c: In function ‘doinit’:
prune.c:16:14: warning: overflow in conversion from ‘long long int’ to ‘long int’ changes value from ‘100000000000’ to ‘1215752192’ [-Woverflow]
 #define smax 100000000000l
              ^~~~~~~~~~~~~
prune.c:49:10: note: in expansion of macro ‘smax’
     smin=smax;
          ^~~~
On what planet weird alien planet is that a "warning"?

It's a frikken error. Fair and square. No two ways about it. The program will not give the correct result.

This is absurd.
Memory in C++ is a leaky abstraction .

jcyr
Posts: 483
Joined: Sun Apr 23, 2017 1:31 pm
Location: Atlanta

Re: Tatami Pi Fun.

Sun Dec 01, 2019 11:56 pm

Heater wrote:
Sun Dec 01, 2019 11:29 pm
Speaking of which. We have been living with C/C++ for so many decades we start to think it actually makes sense. Well no, it has made us crazy.

Get this typical example:

Code: Select all

$ gcc -Wall -O3 -o prune prune.c
prune.c: In function ‘doinit’:
prune.c:16:14: warning: overflow in conversion from ‘long long int’ to ‘long int’ changes value from ‘100000000000’ to ‘1215752192’ [-Woverflow]
 #define smax 100000000000l
              ^~~~~~~~~~~~~
prune.c:49:10: note: in expansion of macro ‘smax’
     smin=smax;
          ^~~~
On what planet weird alien planet is that a "warning"?

It's a frikken error. Fair and square. No two ways about it. The program will not give the correct result.

This is absurd.
What? A bug in a compiler! Unthinkable.

I wasn't following closely and thought you had commented earlier of your better results on 64-bit debian. Due to prune's required use of 64 bit ints for large Tatamis, I get about 8 minutes vs. 14 minutes for T(x)=1000 for 64 bit nspawn vs. 32 bit on PI4.
It's um...uh...well it's kinda like...and it's got a bit of...

ejolson
Posts: 3798
Joined: Tue Mar 18, 2014 11:47 am

Re: Tatami Pi Fun.

Mon Dec 02, 2019 12:02 am

Heater wrote:
Sun Dec 01, 2019 7:53 pm
@ejolson,
Try doing a diff between limited.c and prune.c, then comparing that to a diff between the two rusty programs.
Been there, done that. When every line has changed it's hard to tell what is what. I do wish people would use git if they are going to publish different, ever changing, versions of their code.
I compared the version of limited.c available at

http://fractal.math.unr.edu/~ejolson/pi ... /limited.c

to the version of wheel.c at

https://www.raspberrypi.org/forums/view ... 5#p1571059

to the version of prune.c at

https://www.raspberrypi.org/forums/view ... 5#p1573830

and obtained

Code: Select all

$ diff limited.c wheel.c 
1c1
< /*  limited.c -- Compute T(s) from Project Euler Problem 256
---
> /*  wheel.c -- Compute T(s) from Project Euler Problem 256
5c5,6
<     Avoid computing T(s) when s doesn't have enough factors.  */
---
>     Avoid computing T(s) when s doesn't have enough factors.
>     More sensible computation of prime table at startup.  */
21c22
< static int Pn,Tisn;
---
> static int Pn,Tisn,in;
35c36
<     for(i=0;i<Pn;i++){
---
>     for(i=1;i<in;i++){
37a39,42
>     for(i=in;P[i]*P[i]<=p;i++){
>         if(!(p%P[i])) return 0;
>     }
>     in=i-1;
44,45c49,50
<     P[0]=2; Pn=1;
<     for(p=3;Pn<Pnum;p++){
---
>     P[0]=2; P[1]=3; Pn=2, in=1;
>     for(p=5;Pn<Pnum;p+=2){
and then

Code: Select all

$ diff wheel.c prune.c
1,2c1,2
< /*  wheel.c -- Compute T(s) from Project Euler Problem 256
<     Written November 9, 2019 by Eric Olson in K&R C for PDP-11
---
> /*  prune.c -- Compute T(s) from Project Euler Problem 256
>     Written November 28, 2019 by Eric Olson in K&R C for PDP-11
6c6,7
<     More sensible computation of prime table at startup.  */
---
>     More sensible computation of prime table at startup.
>     Don't check larger values of s than already found.  */
15,17c16,18
< #define smax 100000000l
< #define Pnum 1300
< #define fnum 10
---
> #define smax 100000000000l
> #define Pnum 40000
> #define fnum 20
48c49
<     smin=smax+2;
---
>     smin=smax;
116c117
<     pmax=smax/s+1;
---
>     pmax=smin/s+1;
141c142
<     int n=200;
---
>     int n=1000;
142a144
>     printf("Pr(%d)=%ld\n",Pnum,P[Pnum-1]);
From what I call tell, these files diff pretty cleanly and only a few lines of code were touched in each case.

I now have a program from Fido which runs as

Code: Select all

$ OMP_STACKSIZE=4M time ./queue-openmp 
Pr(40000)=479909
T(63405342000)=1000
Lc=374
312.93user 0.05system 0:30.23elapsed 1035%CPU (0avgtext+0avgdata 151540maxresident)k
0inputs+0outputs (0major+37706minor)pagefaults 0swaps
on the Threadripper. Unfortunately, the source code didn't pass my review due to the use of dogarithms, malloc without free and the need to specify a 4MB stack size for each thread. It should also run on the Raspberry Pi. I've returned it for further revision.

jcyr
Posts: 483
Joined: Sun Apr 23, 2017 1:31 pm
Location: Atlanta

Re: Tatami Pi Fun.

Mon Dec 02, 2019 3:10 am

ejolson wrote:
Mon Dec 02, 2019 12:02 am
I now have a program from Fido which runs as

Code: Select all

$ OMP_STACKSIZE=4M time ./queue-openmp 
Pr(40000)=479909
T(63405342000)=1000
Lc=374
312.93user 0.05system 0:30.23elapsed 1035%CPU (0avgtext+0avgdata 151540maxresident)k
0inputs+0outputs (0major+37706minor)pagefaults 0swaps
Spot would be very interested in seeing Fido's OMP implementation.
It's um...uh...well it's kinda like...and it's got a bit of...

ejolson
Posts: 3798
Joined: Tue Mar 18, 2014 11:47 am

Re: Tatami Pi Fun.

Mon Dec 02, 2019 3:45 am

jcyr wrote:
Mon Dec 02, 2019 3:10 am
ejolson wrote:
Mon Dec 02, 2019 12:02 am
I now have a program from Fido which runs as

Code: Select all

$ OMP_STACKSIZE=4M time ./queue-openmp 
Pr(40000)=479909
T(63405342000)=1000
Lc=374
312.93user 0.05system 0:30.23elapsed 1035%CPU (0avgtext+0avgdata 151540maxresident)k
0inputs+0outputs (0major+37706minor)pagefaults 0swaps
Spot would be very interested in seeing Fido's OMP implementation.
Sounds good. As soon as the revisions are done I'll post the code.

Heater
Posts: 13866
Joined: Tue Jul 17, 2012 3:02 pm

Re: Tatami Pi Fun.

Mon Dec 02, 2019 10:06 am

This is not looking so good on the Pi:

On the x86-64 PC:

Code: Select all

$ time target/release/tatami_rust
Pr40000=479909
T(63405342000)=1000
real    5m58.546s
user    5m57.922s
sys     0m0.000s
$ time ./prune
Pr(40000)=479909
T(63405342000)=1000
real    4m48.525s
user    4m48.109s
sys     0m0.016s
On the Pi 3 B:

Code: Select all

$ time target/release/tatami_rust
Pr40000=479909
T(63405342000)=1000
real    38m22.279s
user    38m21.607s
sys     0m0.061s
$ time ./prune
Pr(40000)=479909
T(63405342000)=1000
real    21m54.700s
user    21m54.538s
sys     0m0.029s
Last edited by Heater on Mon Dec 02, 2019 6:58 pm, edited 1 time in total.
Memory in C++ is a leaky abstraction .

ejolson
Posts: 3798
Joined: Tue Mar 18, 2014 11:47 am

Re: Tatami Pi Fun.

Mon Dec 02, 2019 3:37 pm

Heater wrote:
Mon Dec 02, 2019 10:06 am
This is not looking so good on the Pi:

On the x86-64 PC:

Code: Select all

$ time target/release/tatami_rust
Pr40000=479909
T(63405342000)=1000
real    5m58.546s
user    5m57.922s
sys     0m0.000s
$ time ./prune
Pr(40000)=479909
T(63405342000)=1000
real    4m48.525s
user    4m48.109s
sys     0m0.016s
On the Pi 3 B:

Code: Select all

$ time target/release/tatami_rust
Pr40000=479909
T(63405342000)=1000
real    38m22.279s
user    38m21.607s
sys     0m0.061s
Pr(40000)=479909
T(63405342000)=1000
$ time ./prune
real    21m54.700s
user    21m54.538s
sys     0m0.029s
Let's see, for the PC

4.81/5.98=0.805

and for the Pi 3B

21.91/38.37=0.571

It appears that rust causes a 19.5 to 42.9 percent slowdown, a fact I can confirm with my car. I wonder how much of the difference is related to the in-order execution pipeline of the Cortex-A54 not being able to hide the cost of array-bounds range checking. Maybe the loss due to all those runtime checks would not be so dear on the 4B.

Heater
Posts: 13866
Joined: Tue Jul 17, 2012 3:02 pm

Re: Tatami Pi Fun.

Mon Dec 02, 2019 7:05 pm

There in lies a whole rabbit hole of investigation. The whole warren in fact.

Firstly we are not comparing like with like yet. My Rust code does everything as i64 just now.

Then there is the whole issue of LLVM vs GCC code generation.

That's before we even think about what performance differences the language itself might impose.

Hopefully I will find some time to look in to that. And maybe I will be allowed a Pi 4 for Christmas.

Meanwhile...Do I get a cabbage?
Memory in C++ is a leaky abstraction .

User avatar
davidcoton
Posts: 4243
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK

Re: Tatami Pi Fun.

Mon Dec 02, 2019 9:21 pm

Heater wrote:
Mon Dec 02, 2019 7:05 pm
Meanwhile...Do I get a cabbage?
Maybe a dog treat -- if Fido hasn't polished off the lot.
Signature retired

ejolson
Posts: 3798
Joined: Tue Mar 18, 2014 11:47 am

Re: Tatami Pi Fun.

Mon Dec 02, 2019 11:13 pm

Heater wrote:
Mon Dec 02, 2019 7:05 pm
Meanwhile...Do I get a cabbage?
Maybe it is time to make a new chart showing where things are. To do this I would need your latest code for solving T(s)=200. After that, what do you think about making a new T(s)=1000 chart?

For those who are following along, if you have improved, translated or written your own program to solve the T(s)=200 challenge, I'd be happy to include the results. I see there is a C++ version already posted here. Are there any programs I've missed between the transition from the previous thread to this one?

From my point of view, code written in Go, Haskell, Kotlin or Swift is interesting as well as programs which employ different algorithms or exhibit the use of novel techniques and language features. In particular, meta-programming, parallel programming and mixed language submissions are just fine. Any program that has been organized and carefully commented for literate clarity would likely lead to a greater understanding of what makes a suitable first programming language for beginners. As this is not a war, any language is welcome. However, to be forum friendly and included in the chart, the code must run on the Raspberry Pi.

Heater
Posts: 13866
Joined: Tue Jul 17, 2012 3:02 pm

Re: Tatami Pi Fun.

Tue Dec 03, 2019 12:16 am

ejolson,
Maybe it is time to make a new chart showing where things are.
I'm all for it.
To do this I would need your latest code for solving T(s)=200.
I'm on the case. Might take a day or two...
After that, what do you think about making a new T(s)=1000 chart?
Of course.
Any program that has been organized and carefully commented for literate clarity would likely lead to a greater understanding of what makes a suitable first programming language for beginners.
Cough.
Memory in C++ is a leaky abstraction .

jcyr
Posts: 483
Joined: Sun Apr 23, 2017 1:31 pm
Location: Atlanta

Re: Tatami Pi Fun.

Tue Dec 03, 2019 4:33 am

ejolson wrote:
Mon Dec 02, 2019 11:13 pm
Any program that has been organized and carefully commented for literate clarity would likely lead to a greater understanding of what makes a suitable first programming language for beginners.
Not sure I understand the point of translating the same few algorithms (which rely on the same underlying principles) to different programing languages? Fun for a while, but quickly gets old...

The Tatami problem is not a programming problem. It's more a mathematics or logic problem. The notion that something complicated can be made easily understood with a few comments, or many for that matter, seems a little far fetched and well beyond the scope of what beginners need. A beginner would focus on the syntax and semantics of a language, not the complexities of combinatorial algorithms.

Unless of course the only point is accumulating cabbages.
It's um...uh...well it's kinda like...and it's got a bit of...

Heater
Posts: 13866
Joined: Tue Jul 17, 2012 3:02 pm

Re: Tatami Pi Fun.

Tue Dec 03, 2019 7:06 am

jcyr,
Not sure I understand the point of translating the same few algorithms (which rely on the same underlying principles) to different programming languages? Fun for a while, but quickly gets old...
Not much point at all really. I have some excuses for wasting my time on it though. I have been learning Rust. In that respect I am a beginner. They claim it is a "systems programming language" that can be used where one might use C or C++. What better way to explore that claim than implementing something like ejolson's C solution in Rust? In my latest iteration of the solution I have been getting to grips with Rust's module system, which turns out to be not entirely obvious. I have also introduced some variable life time annotations, again a new concept and not entirely obvious to use. In short it's a learning exercise.
The Tatami problem is not a programming problem. It's more a mathematics or logic problem. The notion that something complicated can be made easily understood with a few comments, or many for that matter, seems a little far fetched and well beyond the scope of what beginners need. A beginner would focus on the syntax and semantics of a language, not the complexities of combinatorial algorithms.
I'm inclined to agree. Unlike our previous challenges this Tatami thing is not very accessible for mere mortals. Not me anyway.
Unless of course the only point is accumulating cabbages.
That is in fact the entire point of this thread :)
Memory in C++ is a leaky abstraction .

Return to “General programming discussion”