Close

Fusion 4: it works

A project log for PEAC Pisano with End-Around Carry algorithm

Add X to Y and Y to X, says the song. And carry on.

yann-guidon-ygdesYann Guidon / YGDES 01/09/2022 at 10:580 Comments

So here is the (slightly edited) log of the first run with the new program:

$ cat pass.sh 
#!/bin/bash

# arguments :
# $1 = filename of source .p7k
# $2 = filename of destination .p7k

TMP_SRC="tmp_src.p7k"
TMP_DST="tmp_dst.p7k"
LC_ALL=C sort -z -k 1.1,1.5  $1 > $TMP_SRC
LC_ALL=C sort -z -k 1.6,1.10 $1 > $TMP_DST
./fusion U $TMP_SRC $TMP_DST $2


$ cat fuse03.sh
./pass.sh log.03.p7k log.03.pass1.p7k
./pass.sh log.03.pass1.p7k log.03.pass2.p7k
./pass.sh log.03.pass2.p7k log.03.pass3.p7k
./pass.sh log.03.pass3.p7k log.03.pass4.p7k
./pass.sh log.03.pass4.p7k log.03.pass5.p7k

$ . fuse03.sh
index=0 :  fuse
index=1 :  copy src
index=2 :  fuse
index=3 :  copy dst
index=4 :  fuse
index=5 :  nothing
index=6 :  nothing
index=7 :  nothing
 writing 5  

index=1 :  fuse
index=3 :  fuse
index=5 :  copy dst
index=6 :  nothing
index=7 :  nothing
 writing 3  

index=5 :  fuse
index=6 :  copy dst
index=7 :  nothing
 writing 2  

index=6 :  fuse
index=7 :  nothing
 writing 1  

index=7 :  LOOP FOUND: len=35 arcs=8 at 7
 writing 0  

I have to run more tests but it seems to work very nicely.

A better version:

$ cp log.03.p7k tmp.p7k

$ while [ -s tmp.p7k ]; do
>   ls -al tmp.p7k
>   ./pass.sh tmp.p7k tmp.p7k
> done
 208  9 janv. 12:16 tmp.p7k
 130  9 janv. 12:16 tmp.p7k
 78  9 janv. 12:16 tmp.p7k
 52  9 janv. 12:16 tmp.p7k
 26  9 janv. 12:16 tmp.p7k
 LOOP FOUND: len=35 arcs=8 at 7

The loop is ready for working with other sizes :-)

[yg]$ cat fuse.sh 

TMP="tmp.p7k"
TMP_SRC="tmp_src.p7k"
TMP_DST="tmp_dst.p7k"

cp log.05.p7k tmp.p7k

while [ -s $TMP ]; do
 # ls -al $TMP
  LC_ALL=C sort -z -k 1.1,1.5  $TMP > $TMP_SRC
  LC_ALL=C sort -z -k 1.6,1.10 $TMP > $TMP_DST
  ./fusion U $TMP_SRC $TMP_DST $TMP
done

[yg]$ ./fuse.sh 
 LOOP FOUND: len=21 arcs=1 at 5
 LOOP FOUND: len=21 arcs=1 at 10
 LOOP FOUND: len=21 arcs=1 at 15
 LOOP FOUND: len=21 arcs=1 at 30
 LOOP FOUND: len=21 arcs=2 at 25
 LOOP FOUND: len=84 arcs=4 at 21
 LOOP FOUND: len=84 arcs=3 at 22
 LOOP FOUND: len=84 arcs=5 at 28
 LOOP FOUND: len=84 arcs=8 at 29
 LOOP FOUND: len=84 arcs=6 at 31

I seem to be getting one half of the orbit numbers :

$ cp ../ref.p7k/log.06.p7k tmp.p7k
$ ./fuse.sh 
 LOOP FOUND: len=693 arcs=23 at 62
 LOOP FOUND: len=693 arcs=21 at 63
 LOOP FOUND: len=693 arcs=20 at 60

In the log 16. More orbits ! I found 6 orbits for w6 but only 3 are reported here.

This is explained by the fact that the new scanner scans the semi-arcs, that is : each semi-arc walks 2 arcs at the same time. So the number of loops/orbits must be doubled.

$ cp ../ref.p7k/log.07.p7k tmp.p7k; ./fuse.sh
 LOOP FOUND: len=45 arcs=1 at 79
 LOOP FOUND: len=234 arcs=2 at 110
 LOOP FOUND: len=234 arcs=2 at 121
 LOOP FOUND: len=390 arcs=6 at 114
 LOOP FOUND: len=234 arcs=7 at 99
 LOOP FOUND: len=1170 arcs=13 at 119
 LOOP FOUND: len=1170 arcs=20 at 126
 LOOP FOUND: len=1170 arcs=16 at 117
 LOOP FOUND: len=1170 arcs=15 at 122
 LOOP FOUND: len=1170 arcs=20 at 118
 LOOP FOUND: len=1170 arcs=26 at 127

w7: 22 orbits instead of 26.

$ cp ../ref.p7k/log.08.p7k tmp.p7k; ./fuse.sh |wc -l
167

w8 can find only 167 of the  estimated 572 orbits, all of length 115. But it doesn't matter since we're only interested in statespaces with only one couple of orbits.

$ cp ../ref.p7k/log.09.p7k tmp.p7k; ./fuse.sh |wc -l
53

w9 only shows orbits with 200, 260 and 2600 steps.

$ cp ../ref.p7k/log.10.p7k tmp.p7k; ./fuse.sh
 LOOP FOUND: len=524799 arcs=1024 at 1023

w10 looks perferct, as expected. 

$ cp ../ref.p7k/log.11.p7k tmp.p7k; ./fuse.sh
 LOOP FOUND: len=2922 arcs=5 at 1795
 LOOP FOUND: len=1046076 arcs=1038 at 2047
 LOOP FOUND: len=1046076 arcs=1005 at 2046

w11 finds only 6 orbits out of 8 but the lengths do not match 5844 or 179 (1046076 is correct though)

$ cp ../ref.p7k/log.12.p7k tmp.p7k; ./fuse.sh
 LOOP FOUND: len=71107 arcs=34 at 3894
 LOOP FOUND: len=71107 arcs=35 at 4071
 LOOP FOUND: len=2062103 arcs=1032 at 4093
 LOOP FOUND: len=2062103 arcs=986 at 4094
 LOOP FOUND: len=2062103 arcs=990 at 4095
 LOOP FOUND: len=2062103 arcs=1019 at 4086

 w12 finds 12 of the 14 orbits, and misses only a couple of 29-long ones.

$ cp ../ref.p7k/log.13.p7k tmp.p7k; ./fuse.sh|wc -l
130

w13 finds 130 of the 196 orbits, finding lengths of 103257 and 413028 instead of 4, 206514, 413028 (it seems that 206514 is the double of 103257)

Let's be crazy and count the passes:

$ for i in ../ref.p7k/log.*k; do echo -n "* $i : "; cp $i  tmp.p7k; ./fuse.sh; done
* ../ref.p7k/log.02.p7k :  4 passes
* ../ref.p7k/log.03.p7k :  5 passes
* ../ref.p7k/log.04.p7k :  9 passes
* ../ref.p7k/log.05.p7k :  5 passes
* ../ref.p7k/log.06.p7k :  9 passes
* ../ref.p7k/log.07.p7k :  9 passes
* ../ref.p7k/log.08.p7k :  4 passes
* ../ref.p7k/log.09.p7k :  9 passes
* ../ref.p7k/log.10.p7k :  25 passes
* ../ref.p7k/log.11.p7k :  23 passes
* ../ref.p7k/log.12.p7k :  28 passes
* ../ref.p7k/log.13.p7k :  19 passes
* ../ref.p7k/log.14.p7k :  32 passes
* ../ref.p7k/log.15.p7k :  12 passes
* ../ref.p7k/log.16.p7k :  37 passes
* ../ref.p7k/log.17.p7k :  28 passes
* ../ref.p7k/log.18.p7k :  31 passes
* ../ref.p7k/log.19.p7k :  28 passes
* ../ref.p7k/log.20.p7k :  30 passes
* ../ref.p7k/log.21.p7k :  47 passes
* ../ref.p7k/log.22.p7k :  53 passes
* ../ref.p7k/log.23.p7k :  61 passes
* ../ref.p7k/log.24.p7k :  51 passes
* ../ref.p7k/log.25.p7k :  54 passes

This is not monotonic...

The runtimes are very short for the widths below 20. They explode after that. The fusion step is pretty quick compared with the 2 sorts (this vindicates my approach). w25 took 3:21 minutes:

$ cp ../ref.p7k/log.25.p7k tmp.p7k
$ /usr/bin/time ./fuse.sh 
sort src
sort dst
fusion
 LOOP FOUND: len=19795484 arcs=1 at 17051949
 LOOP FOUND: len=19795484 arcs=1 at 20841271
 LOOP FOUND: len=26225834 arcs=1 at 21451665
 LOOP FOUND: len=178159356 arcs=1 at 23832841
 LOOP FOUND: len=19795484 arcs=1 at 24630593
 LOOP FOUND: len=19795484 arcs=1 at 28419915
 LOOP FOUND: len=19795484 arcs=1 at 32209237
sort src
sort dst
fusion
 LOOP FOUND: len=19795484 arcs=2 at 18946610
 LOOP FOUND: len=19795484 arcs=2 at 26525254
sort src
sort dst
fusion
 LOOP FOUND: len=19795484 arcs=3 at 22735932
 LOOP FOUND: len=52451668 arcs=3 at 25741998
 LOOP FOUND: len=26225834 arcs=3 at 28602220
 LOOP FOUND: len=52451668 arcs=3 at 32892553
sort src
sort dst
fusion
 LOOP FOUND: len=52451668 arcs=4 at 18591443
 LOOP FOUND: len=52451668 arcs=5 at 22881776
 LOOP FOUND: len=178159356 arcs=5 at 28918510
 LOOP FOUND: len=19795484 arcs=5 at 30314576
 LOOP FOUND: len=178159356 arcs=4 at 31411485
 LOOP FOUND: len=52451668 arcs=4 at 31462442
sort src
sort dst
fusion
 LOOP FOUND: len=178159356 arcs=6 at 29117948
 LOOP FOUND: len=178159356 arcs=6 at 30514014
 LOOP FOUND: len=178159356 arcs=8 at 31610923
 LOOP FOUND: len=178159356 arcs=6 at 32109518
 LOOP FOUND: len=236032506 arcs=8 at 32365670
 LOOP FOUND: len=236032506 arcs=7 at 32742015
sort src
sort dst
fusion
 LOOP FOUND: len=178159356 arcs=10 at 27721882
 LOOP FOUND: len=178159356 arcs=13 at 29716262
 LOOP FOUND: len=178159356 arcs=9 at 31810361
 LOOP FOUND: len=178159356 arcs=6 at 32009799
 LOOP FOUND: len=178159356 arcs=10 at 32807551
 LOOP FOUND: len=178159356 arcs=8 at 33206427
 LOOP FOUND: len=178159356 arcs=10 at 33405865
 LOOP FOUND: len=178159356 arcs=7 at 33505584
sort src
sort dst
fusion
 LOOP FOUND: len=178159356 arcs=19 at 25528064
 LOOP FOUND: len=178159356 arcs=9 at 28120758
 LOOP FOUND: len=236032506 arcs=13 at 30860290
 LOOP FOUND: len=236032506 arcs=17 at 31989325
 LOOP FOUND: len=178159356 arcs=18 at 32308956
 LOOP FOUND: len=178159356 arcs=8 at 32707832
 LOOP FOUND: len=178159356 arcs=15 at 32907270
 LOOP FOUND: len=236032506 arcs=21 at 33118360
 LOOP FOUND: len=178159356 arcs=14 at 33306146
 LOOP FOUND: len=472065012 arcs=13 at 33344167
sort src
sort dst
fusion
 LOOP FOUND: len=178159356 arcs=11 at 27422725
 LOOP FOUND: len=178159356 arcs=11 at 31112328
 LOOP FOUND: len=178159356 arcs=11 at 31311766
 LOOP FOUND: len=178159356 arcs=17 at 31511204
 LOOP FOUND: len=178159356 arcs=14 at 33006989
sort src
sort dst
fusion
 LOOP FOUND: len=178159356 arcs=10 at 30713452
 LOOP FOUND: len=472065012 arcs=30 at 31086097
 LOOP FOUND: len=472065012 arcs=24 at 32290401
 LOOP FOUND: len=178159356 arcs=17 at 32608113
 LOOP FOUND: len=472065012 arcs=27 at 32817284
 LOOP FOUND: len=472065012 arcs=27 at 32967822
 LOOP FOUND: len=472065012 arcs=24 at 33043091
 LOOP FOUND: len=472065012 arcs=32 at 33193629
 LOOP FOUND: len=472065012 arcs=40 at 33268898
 LOOP FOUND: len=472065012 arcs=28 at 33419436
sort src
sort dst
fusion
 LOOP FOUND: len=472065012 arcs=27 at 28677489
 LOOP FOUND: len=178159356 arcs=17 at 30813171
 LOOP FOUND: len=472065012 arcs=38 at 31311904
 LOOP FOUND: len=178159356 arcs=19 at 32408675
 LOOP FOUND: len=472065012 arcs=27 at 32440939
 LOOP FOUND: len=236032506 arcs=19 at 33494705
sort src
sort dst
fusion
sort src
sort dst
fusion
sort src
sort dst
fusion
sort src
sort dst
fusion
sort src
sort dst
fusion
sort src
sort dst
fusion
sort src
sort dst
fusion
 LOOP FOUND: len=3752787212 arcs=216 at 33391113
sort src
sort dst
fusion
 LOOP FOUND: len=3752787212 arcs=208 at 33511117
 LOOP FOUND: len=3752787212 arcs=211 at 33541118
sort src
sort dst
fusion
 LOOP FOUND: len=3752787212 arcs=260 at 33481116
sort src
sort dst
fusion
sort src
sort dst
fusion
 LOOP FOUND: len=3752787212 arcs=223 at 33451115
sort src
sort dst
fusion
sort src
sort dst
fusion
 LOOP FOUND: len=33775084908 arcs=1892 at 33549013
sort src
sort dst
fusion
 LOOP FOUND: len=33775084908 arcs=1904 at 33537960
 LOOP FOUND: len=33775084908 arcs=2203 at 33552171
sort src
sort dst
fusion
 LOOP FOUND: len=33775084908 arcs=2003 at 33544276
 LOOP FOUND: len=33775084908 arcs=2079 at 33547434
sort src
sort dst
fusion
 LOOP FOUND: len=33775084908 arcs=2020 at 33536381
sort src
sort dst
fusion
 LOOP FOUND: len=33775084908 arcs=1879 at 33484274
 LOOP FOUND: len=33775084908 arcs=2020 at 33531644
 LOOP FOUND: len=33775084908 arcs=2123 at 33553750
sort src
sort dst
fusion
sort src
sort dst
fusion
 LOOP FOUND: len=33775084908 arcs=2009 at 33487432
sort src
sort dst
fusion
sort src
sort dst
fusion
sort src
sort dst
fusion
sort src
sort dst
fusion
sort src
sort dst
fusion
sort src
sort dst
fusion
 LOOP FOUND: len=986983036756 arcs=58742 at 33554323
sort src
sort dst
fusion
 LOOP FOUND: len=986983036756 arcs=57394 at 33553715
sort src
sort dst
fusion
 LOOP FOUND: len=986983036756 arcs=59271 at 33552936
 LOOP FOUND: len=986983036756 arcs=59106 at 33553202
 LOOP FOUND: len=986983036756 arcs=59770 at 33553962
 LOOP FOUND: len=986983036756 arcs=58117 at 33554228
 LOOP FOUND: len=986983036756 arcs=60136 at 33554380
sort src
sort dst
fusion
 LOOP FOUND: len=986983036756 arcs=59015 at 33551853
 LOOP FOUND: len=986983036756 arcs=58325 at 33553829
 LOOP FOUND: len=986983036756 arcs=57865 at 33554000
 LOOP FOUND: len=986983036756 arcs=58377 at 33554171
 LOOP FOUND: len=986983036756 arcs=59788 at 33554285
 LOOP FOUND: len=986983036756 arcs=58043 at 33554304
 LOOP FOUND: len=986983036756 arcs=59610 at 33554418
sort src
sort dst
fusion
 LOOP FOUND: len=986983036756 arcs=57730 at 33553506
 LOOP FOUND: len=986983036756 arcs=59057 at 33554114
 LOOP FOUND: len=986983036756 arcs=58452 at 33554266
 LOOP FOUND: len=986983036756 arcs=57995 at 33554399
sort src
sort dst
fusion
 LOOP FOUND: len=986983036756 arcs=59284 at 33553392
 LOOP FOUND: len=986983036756 arcs=58351 at 33553468
 LOOP FOUND: len=986983036756 arcs=58905 at 33553943
 LOOP FOUND: len=986983036756 arcs=60273 at 33554190
sort src
sort dst
fusion
 LOOP FOUND: len=986983036756 arcs=57518 at 33553335
 LOOP FOUND: len=986983036756 arcs=59531 at 33554247
sort src
sort dst
fusion
 LOOP FOUND: len=986983036756 arcs=59168 at 33553886
 LOOP FOUND: len=986983036756 arcs=59579 at 33554152
sort src
sort dst
fusion
 LOOP FOUND: len=986983036756 arcs=59290 at 33553601
 LOOP FOUND: len=986983036756 arcs=58585 at 33553639
 LOOP FOUND: len=986983036756 arcs=58788 at 33554342
sort src
sort dst
fusion
 LOOP FOUND: len=8882847330804 arcs=529231 at 33554384
sort src
sort dst
fusion
 LOOP FOUND: len=8882847330804 arcs=529834 at 33554328
 LOOP FOUND: len=8882847330804 arcs=528831 at 33554334
 LOOP FOUND: len=8882847330804 arcs=529190 at 33554382
sort src
sort dst
fusion
 LOOP FOUND: len=8882847330804 arcs=529350 at 33554381
 LOOP FOUND: len=8882847330804 arcs=532532 at 33554385
 LOOP FOUND: len=8882847330804 arcs=531407 at 33554389
 LOOP FOUND: len=8882847330804 arcs=529846 at 33554391
 LOOP FOUND: len=8882847330804 arcs=530113 at 33554423
sort src
sort dst
fusion
 LOOP FOUND: len=8882847330804 arcs=527946 at 33554298
 LOOP FOUND: len=8882847330804 arcs=532155 at 33554300
 LOOP FOUND: len=8882847330804 arcs=530758 at 33554396
 LOOP FOUND: len=8882847330804 arcs=528028 at 33554410
 LOOP FOUND: len=8882847330804 arcs=531275 at 33554416
 LOOP FOUND: len=8882847330804 arcs=526611 at 33554420
 LOOP FOUND: len=8882847330804 arcs=529170 at 33554427
 LOOP FOUND: len=8882847330804 arcs=532392 at 33554431
sort src
sort dst
fusion
 LOOP FOUND: len=8882847330804 arcs=528830 at 33554219
 LOOP FOUND: len=8882847330804 arcs=529888 at 33554283
 LOOP FOUND: len=8882847330804 arcs=526382 at 33554330
 LOOP FOUND: len=8882847330804 arcs=528509 at 33554338
 LOOP FOUND: len=8882847330804 arcs=527469 at 33554353
 LOOP FOUND: len=8882847330804 arcs=528421 at 33554378
 LOOP FOUND: len=8882847330804 arcs=530706 at 33554407
 LOOP FOUND: len=8882847330804 arcs=529389 at 33554408
 LOOP FOUND: len=8882847330804 arcs=530892 at 33554415
 LOOP FOUND: len=8882847330804 arcs=529101 at 33554421
 LOOP FOUND: len=8882847330804 arcs=529751 at 33554422
 LOOP FOUND: len=8882847330804 arcs=531479 at 33554425
sort src
sort dst
fusion
 LOOP FOUND: len=8882847330804 arcs=529274 at 33554251
 LOOP FOUND: len=8882847330804 arcs=530351 at 33554258
 LOOP FOUND: len=8882847330804 arcs=530362 at 33554274
 LOOP FOUND: len=8882847330804 arcs=529354 at 33554303
 LOOP FOUND: len=8882847330804 arcs=527139 at 33554343
 LOOP FOUND: len=986983036756 arcs=58799 at 33554361
 LOOP FOUND: len=8882847330804 arcs=531352 at 33554366
 LOOP FOUND: len=8882847330804 arcs=528804 at 33554375
 LOOP FOUND: len=8882847330804 arcs=529109 at 33554393
 LOOP FOUND: len=8882847330804 arcs=527618 at 33554394
 LOOP FOUND: len=8882847330804 arcs=527423 at 33554395
 LOOP FOUND: len=8882847330804 arcs=529584 at 33554409
 LOOP FOUND: len=8882847330804 arcs=528920 at 33554413
 LOOP FOUND: len=8882847330804 arcs=529147 at 33554414
 LOOP FOUND: len=8882847330804 arcs=529119 at 33554424
 LOOP FOUND: len=8882847330804 arcs=528099 at 33554429
sort src
sort dst
fusion
 LOOP FOUND: len=8882847330804 arcs=530110 at 33554355
 LOOP FOUND: len=8882847330804 arcs=530052 at 33554368
 LOOP FOUND: len=8882847330804 arcs=530154 at 33554392
 LOOP FOUND: len=8882847330804 arcs=529041 at 33554397
 LOOP FOUND: len=8882847330804 arcs=532306 at 33554400
 LOOP FOUND: len=8882847330804 arcs=528006 at 33554401
sort src
sort dst
fusion
 LOOP FOUND: len=8882847330804 arcs=526779 at 33554294
 LOOP FOUND: len=8882847330804 arcs=530920 at 33554309
 LOOP FOUND: len=8882847330804 arcs=528471 at 33554336
 LOOP FOUND: len=8882847330804 arcs=530427 at 33554373
 LOOP FOUND: len=8882847330804 arcs=528923 at 33554402
 LOOP FOUND: len=8882847330804 arcs=529207 at 33554428
 LOOP FOUND: len=8882847330804 arcs=526784 at 33554430
sort src
sort dst
fusion
 LOOP FOUND: len=8882847330804 arcs=530015 at 33554268
 LOOP FOUND: len=8882847330804 arcs=529894 at 33554426
sort src
sort dst
fusion
sort src
sort dst
fusion
 LOOP FOUND: len=8882847330804 arcs=531307 at 33554376
 54 passes
333.11user 22.72system 3:21.06elapsed 176%CPU 

It's not particularly interesting but it gives a hint for the wider configurations.

And now, w26 !

The suspense was not great:

$ cp ../ref.p7k/log.26.p7k tmp.p7k
$ /usr/bin/time ./fuse.sh 
(......)
 LOOP FOUND: len=2251799847239679 arcs=67108864 at 67108863
 70 passes
744.97user 43.86system 7:35.98elapsed 172%CPU

So this is the final confirmation for w26 ! The only thing that it provides is that the runtime is "mostly doubled" from the previous run: 7:35 vs 3:21. This could be much faster since I use the older i7 with the spinning plates and I did not configure the swap file of sort. Anyway, this is going very well so far... And it took only 7 minutes to check the results of a computation that lasted 4 days...

Here are the sizes of the successive files:

1744830464
1163280898
814335548
585037336
427385062
315933592
235638806
176962318
133645772
101374338
58967662
77191868
58967662
34687822  

To compute the ratio of shrinkage:

$ last=1744830464; for i in  1163280898  814335548  585037336 427385062 315933592 235638806 176962318 133645772 101374338 77191868 58967662 34687822 ; do echo "$i : " $(( (last-i) / (last/100)  )); last=$i ; done1163280898 :  33
814335548 :  29
585037336 :  28
427385062 :  26
315933592 :  26
235638806 :  25
176962318 :  24
133645772 :  24
101374338 :  24
77191868 :  23
58967662 :  23
34687822 :  41

So yes, the ratio is approximately 25% as already supposed. It takes 2 passes to cut the size in half.

...

Sorting w32 should be about 100× longer, or about 12h. Pre-fusion is possible on partial results, I suppose, though I'll have to change the condition of termination for the main loop, which at this point checks if the result file is empty. I could compare the size of the input and output file...
______________________________________________________________

I'm not finished yet !

I was wondering about the structure of w24:

...
 LOOP FOUND: len=1340357111847 arcs=159675 at 16777118
 51 passes
138.07user 10.49system 1:33.16elapsed 159%CPU 

I found 105 pairs of orbits of equal lengths=1.340.357.111.847 so this is not too bad... but w26 is still better :-)

Discussions