sQLux v1.0 (The Xmas Turkey)

Discussion and advice about emulating the QL on other machines.
User avatar
polka
Trump Card
Posts: 191
Joined: Mon Mar 07, 2011 11:43 am

Re: sQLux v1.0 (The Xmas Turkey)

Post by polka »

Hi all !
As one of my two QLs is no longer booting and the other one is still confined in the Alps, I decided to fall back on emulators in Raspberry Pis. I have a Pi Zero W running an old raspian, that I use for QL emulation with uQLx (and also for a Ceres-Oberon 1984 workstation emulator which I like very much). But I decided to try also (at last) sQLux ! And I installed it following the excellent user guide from swensont.
On my Pi Zero W, it works... however, I find it terribly slow (and I mean TERRIBLY !).
So I tried also to install it on a faster Pi Zero W2 running Pi-OS (because it does not support raspian), and it works better, but still slower than uQLx on both machines.
This is the '.ini' file that I finally put together :

Code: Select all

SYSROM = MIN198.rom
ROMIM = TK232.rom
RAMTOP = 4096
PRINT = lpr
CPU_HOG = 0
FAST_STARTUP = 1
DEVICE = MDV1,/home/pi/Sinclair/qxl.win,qdos-fs
DEVICE = MDV2,/home/pi/Sinclair/qxl1.win,qdos-fs
DEVICE = MDV3,/home/pi/Sinclair/sqxlux.win,qdos-fs
DEVICE = MDV4,/home/pi/Sinclair/mdv4/,qdos-like
DEVICE = MDV5,/home/pi/Sinclair/mdv5/,qdos-like
DEVICE = MDV6,/home/pi/Sinclair/mdv6/,qdos-like
WIN_SIZE = 2x
FILTER = 0
FIXASPECT = 1
KBD = US
SOUND = 1
SPEED = 0.0
As you can see, I use no FILTER, because I chose to adopt WIN_SIZE = 2x (for crisper resolution and maybe some gain of speed compared with MAX or FULL screen). Because I noticed that what slows the emulation is essentialy the graphic screen management. How did I find it ? I usually estimate speeds of my Conway FORTH program that alternate two tasks : 1/ determine the living cells of the next generation (pure computing) and 2/ refresh the drawing (plotting into the display screen). With uQLx these two tasks take more or less very comparable times, whereas with sQLux the drawing task is much slower than the computing task.
May I ask if you find what I tell seems normal or (maybe I did something wrong) would it be possible to better it ?


May the FORTH be with you !
POLKa
User avatar
polka
Trump Card
Posts: 191
Joined: Mon Mar 07, 2011 11:43 am

Re: sQLux v1.0 (The Xmas Turkey)

Post by polka »

Here I show two screen shots of what I get on my Pis on a 1680x1050 display :
First with sQLux, 'WIN_SIZE = 2x' in the .ini file
sQLux.jpg
Then with uQLx, with the command 'xzoom -mag 2 3 -source 512x256'
uQLx.jpg
Both emulator windows are exactly the same (and circles are circles !), but on the uQLx screen shot you see also the original (small) window (with square pixels thus an ellipse instead of a circle).

Bye ! POLKa


May the FORTH be with you !
POLKa
Exile
ROM Dongle
Posts: 38
Joined: Sat Jan 15, 2022 8:55 pm

Re: sQLux v1.0 (The Xmas Turkey)

Post by Exile »

polka wrote:Hi all !

May I ask if you find what I tell seems normal or (maybe I did something wrong) would it be possible to better it ?
Hi polka - Would it be possible to share the Life program? We could then use it to profile the sQLux code to see where sQLux is spending its time when drawing the new generation of cells. I don't have a Pi zero but I could try it on a Pi 4


User avatar
XorA
Site Admin
Posts: 1357
Joined: Thu Jun 02, 2011 11:31 am
Location: Shotts, North Lanarkshire, Scotland, UK

Re: sQLux v1.0 (The Xmas Turkey)

Post by XorA »

Exile wrote:
polka wrote:Hi all !

May I ask if you find what I tell seems normal or (maybe I did something wrong) would it be possible to better it ?
Hi polka - Would it be possible to share the Life program? We could then use it to profile the sQLux code to see where sQLux is spending its time when drawing the new generation of cells. I don't have a Pi zero but I could try it on a Pi 4
Pi0 x performance is terrible but fixing that breaks every other platform. Running it in Pi0 without X is significantly faster.

SQLux is slower on heavy screen operations than uQlx because it made a decision for simplicity of code to convert every pixel when it is written!


User avatar
polka
Trump Card
Posts: 191
Joined: Mon Mar 07, 2011 11:43 am

Re: sQLux v1.0 (The Xmas Turkey)

Post by polka »

I shared my Conway program here :
viewtopic.php?f=3&t=215&p=1438&hilit=co ... orth#p1438
Tomorrow I will try to add a "word" (in the FORTH sense) to benchmark it with and without plotting.
To play with it, you will have to install first Digital Precision SuperForth. You can do it without waiting for my benchmark word and after LOAD_FILE the source just type "demo" or "joli" (lower case ! SuperForth is case sensitive)

BYE ! POLKa


May the FORTH be with you !
POLKa
User avatar
polka
Trump Card
Posts: 191
Joined: Mon Mar 07, 2011 11:43 am

Re: sQLux v1.0 (The Xmas Turkey)

Post by polka »

Here is a new version of my CONWAY_DPF file for superForth, sightly modified to add a word "bench" to compare runtimes with or without plotting :

Code: Select all

: .< 0 <# #S #> TYPE ;
: >< ( n,a,b --- [a<=n<=b] ) >R OVER <= SWAP R> <= AND ;

CR CR .( Conway's life in a )

   120 DUP .< .( x) DUP CONSTANT ww              ( world width )
   85 DUP . .( torus shaped world) DUP CONSTANT wh   ( height )

   * DUP 2/ CREATE wm ALLOT ( world map of nibbles 4bits/cell )

   2* CREATE ws HERE >R ALLOT HERE R> CONSTANT da CONSTANT ma

   VARIABLE ds VARIABLE ms ( DAD and MOM stack pointers )   HEX

   CREATE ss F0F , F0F0 , 70 , 7 , 7000 , 700 , 7070 , 707 ,
   CREATE ni A0A , 404 , 506 , 708 , 80A , B0C , D0D ,
   CREATE nr 0 , 101 , 101 , 303 , 100 , 0 , 200 ,  CR  DECIMAL

: sd ( color,x,y --- )
  384 * SWAP 4 + 2 /MOD 2* ROT +
  DUP >R 2 A@ OVER 2* ss + @ AND
  ROT DUP
  IF
    2* ROT + 2* ss + @ OR
  ELSE
    DROP SWAP DROP
  THEN
  DUP R@ 2 A!
  R> 128 + 2 A!
;

VARIABLE goal

: cs ( clear DAD and MOM stacks ) da ds ! ma ms ! ;
: >d ds @ !  2 ds +! ; ( DAD push : any first added next-door )
: >m -2 ms +! ms @ ! ; ( MOM push : any born/surviving/killed )
: <d ds @ da = IF -1 ELSE -2 ds +! ds @ @ THEN ;    ( DAD pop )
: <m ms @ ma = IF -1 ELSE ms @ @  2 ms +! THEN ;    ( MOM pop )

: xy> ( x,y --- m ) ww * + ;
: xy< ( m --- x,y ) ww /MOD ;

: n@ ( m --- n )
  2 /MOD wm + C@ SWAP
  IF
    16 /
  ELSE
    15 AND
  THEN ;

: n! ( n,m --- )
  2 /MOD wm + DUP >R C@ SWAP
  IF
    15 AND SWAP 16 * OR
  ELSE
    240 AND OR
  THEN
  R> C!
;

: dad
  BEGIN
    <m ( pops MOM )
    DUP -1 <>
  WHILE
    DUP n@ 2 8 ><
    IF
      2 -1 DO
        2 -1 DO
          DUP
          xy<
          I J ROT
          + wh MOD >R
          + ww MOD R>
          xy>
          DUP >R
          n@ DUP 4 <
          IF
            R@ >d
          THEN
          ni + C@
          R> n!
        LOOP
      LOOP
      DROP
    ELSE
      DUP n@ 1 =
      IF
        9 OVER n! >d
      ELSE
        DROP
      THEN
    THEN
  REPEAT
  DROP
;

: mom
  BEGIN
    <d ( pops DAD )
    DUP -1 <>
  WHILE
    DUP DUP n@
    nr + C@
    DUP ROT xy< 
  ( sd )
    goal @ IF sd ELSE DROP DROP DROP THEN 
    DUP
    IF
      OVER >m
    THEN
    SWAP n!
  REPEAT
  DROP
;

: LIFE
  BEGIN
     dad mom
     1 KEYROW 64 =
  UNTIL
;

: FLU
  CLS
  cs
  ww wh * 2/ 0
  DO
    0 I wm + C!
  LOOP
;
 
: LAY ( x,y --- )
  xy> DUP >m
  2 OVER n!
  2 SWAP xy< sd
;

.( Creating incrementally complex organisms )

VARIABLE components   
VARIABLE flag  0 flag !   
VARIABLE A_C

: S1 SWAP ;   : S7 NEGATE ;   : S2 NEGATE S1 ;   : S6 SWAP S7 ;
: S3 SWAP S2 ;   : S5 NEGATE S6 ;   : S4 NEGATE S3 ;     : SO ;

CREATE S ' SO , ' S1 , ' S2 , ' S3 , ' S4 , ' S5 , ' S6 , ' S7 ,

CREATE g8
          0 C, 1 C, 2 C, 3 C, 4 C, 5 C, 6 C, 7 C,
          1 C, 0 C, 7 C, 6 C, 5 C, 4 C, 3 C, 2 C,
          2 C, 3 C, 4 C, 5 C, 6 C, 7 C, 0 C, 1 C,
          3 C, 2 C, 1 C, 0 C, 7 C, 6 C, 5 C, 4 C,
          4 C, 5 C, 6 C, 7 C, 0 C, 1 C, 2 C, 3 C,
          5 C, 4 C, 3 C, 2 C, 1 C, 0 C, 7 C, 6 C,
          6 C, 7 C, 0 C, 1 C, 2 C, 3 C, 4 C, 5 C,
          7 C, 6 C, 5 C, 4 C, 3 C, 2 C, 1 C, 0 C,

: *g8 3 PICK 8 * + g8 + C@ ;

: bio+ 2- , C, C, C, 5 components @ +! ;

: ;BIO 0 flag ! ;

: c [ HERE A_C ! ]
  flag @
  IF
    A_C @ bio+
  ELSE
    DROP LAY
  THEN
;

: BIO:
  CREATE  HERE components ! 0 , -1 flag !
  DOES> flag @
  IF
    bio+
  ELSE 
    DUP @ OVER + 2+ SWAP 2+
    DO
      I 4 + C@
      I 3 + C@
      I 2 + C@
      *g8 >R
      2 PICK 2* S + @ EXECUTE
      3 PICK + SWAP
      4 PICK + SWAP R> I @ EXECUTE
    5 +LOOP
    DROP DROP DROP
  THEN
;

 BIO: g 0 0 0 c 1 0 0 c 2 0 0 c 2 1 0 c 1 2 0 c ;BIO
 BIO: r 0 0 0 c 1 0 0 c 1 1 0 c 2 1 0 c 0 2 0 c ;BIO
 BIO: b  0 20 6 g  4 12 4 g  8 18 6 r  9  8 1 g 14  7 1 r
 20  6 1 g 22 20 6 r 23 10 1 g 28  9 1 r 30  0 4 g 34 22 6 g
 38 14 4 g 39  3 1 g ;BIO : demo FLU 70 30 2 b LIFE ;

 BIO: l5 0 0 0 c 1 0 0 c 2 0 0 c 3 0 0 c 4 0 0 c ;BIO
 BIO: 7l5 0 0 0 l5 6 0 0 l5 12 0 0 l5 18 0 0 l5 24 0 0 l5
 30 0 0 l5 36 0 0 l5 ;BIO : joli FLU 37 42 0 7l5 LIFE ;

 BIO: m1 0 0 0 c 0 1 0 c 1 2 0 c 2 2 0 c 3 2 0 c ;BIO

: li 20 0 DO I 6 * 0 0 l5 LOOP ;
BIO: lin li ;BIO
: line FLU 0 42 0 lin ;
: ligne line LIFE ;
: alien FLU 70 30 2 b ;

: bench
  DUP goal ! TIME ROT 0
    DO
      dad mom
      1 KEYROW 64 =
      IF
        I 1+ . CR LEAVE
      THEN
    LOOP
  TIME D- D. CR
;

END_FILE
The word that does the plotting is the first after the table declarations : it is called "sd" and requires 3 parameters.
This word is only used once by the word "mom". I declared also a new variable called "goal" to be used with "bench".

Instead of executing "sd" unconditionally, "mom" tests "goal", and if zero, does not plot !

at the end, I added indeed the word "bench" and also two initial configuration of life called "line" and "alien" to measure with "bench" the runtimes with and without plotting. So, after starting superForth :

LOAD_FILE mdv2_conway_dpf (LOAD_FILE must be uppercase, superForth is case sensitive ; mdv2 just fo example)

Then first run without plotting :

line 0 bench

must be stopped after some time (try first a few seconds) with the space bar.
Apart the initial life nothing is plotted, but after stopping you will see the number <n> of generations passed and the time it took in seconds.

Then running again with <n> as parameter instead of zero :

line <n> bench

you just have to wait until it stops with the same number of generations passed WITH plotting. Ouput : the time it took. if you are impatient you may also stop it with the space bar.

Have fun !


May the FORTH be with you !
POLKa
Exile
ROM Dongle
Posts: 38
Joined: Sat Jan 15, 2022 8:55 pm

Re: sQLux v1.0 (The Xmas Turkey)

Post by Exile »

Thanks! This may be an opportunity for me to look at FORTH for the first time since 1984 ;-)


User avatar
XorA
Site Admin
Posts: 1357
Joined: Thu Jun 02, 2011 11:31 am
Location: Shotts, North Lanarkshire, Scotland, UK

Re: sQLux v1.0 (The Xmas Turkey)

Post by XorA »

With quite a bit of testing and some optimisations from Exile sQLux is now multi threaded, I have not had time to test on a slower platform like Pi0 v2 but on multi core systems like that it should show a good increase in speed of both CPU emulation and GFX rendering!


User avatar
XorA
Site Admin
Posts: 1357
Joined: Thu Jun 02, 2011 11:31 am
Location: Shotts, North Lanarkshire, Scotland, UK

Re: sQLux v1.0 (The Xmas Turkey)

Post by XorA »

The problem with Pi :-(

So as some will have noticed I started to use some C++ in sQLux which is newer than Debian Buster gcc allows. This meant upgrading my test Pi’s to Debian Bullseye version of Raspian. I have to concur with the Raspian forums opinion that the Pi foundation has dropped all software support of all Pi’s not Pi4. The situation is not good. Anyway here is the summary of how sQLux now performs on them

Pi0/Pi1 console ok, x11 unusable (pulseaudio is taking 100% CPU leaving no time for sQLux to execute)
Pi3/Pi0v2 console good, x11 ok (no OpenGL support so llvmpipe takes 100% cpu load on all cores drawing the window)

sQLux is now multi threaded to take advantage that almost all CPUs now have more than one core. So I am not expecting Pi0/Pi1 support to have any improvements in future. (they only have 1 core).

I have not tested Pi4 yet, but I have 3rd party reports that it is doing well!


User avatar
XorA
Site Admin
Posts: 1357
Joined: Thu Jun 02, 2011 11:31 am
Location: Shotts, North Lanarkshire, Scotland, UK

Re: sQLux v1.0 (The Xmas Turkey)

Post by XorA »

XorA wrote:The problem with Pi :-(

So as some will have noticed I started to use some C++ in sQLux which is newer than Debian Buster gcc allows. This meant upgrading my test Pi’s to Debian Bullseye version of Raspian. I have to concur with the Raspian forums opinion that the Pi foundation has dropped all software support of all Pi’s not Pi4. The situation is not good. Anyway here is the summary of how sQLux now performs on them

Pi0/Pi1 console ok, x11 unusable (pulseaudio is taking 100% CPU leaving no time for sQLux to execute)
Pi3/Pi0v2 console good, x11 ok (no OpenGL support so llvmpipe takes 100% cpu load on all cores drawing the window)

sQLux is now multi threaded to take advantage that almost all CPUs now have more than one core. So I am not expecting Pi0/Pi1 support to have any improvements in future. (they only have 1 core).

I have not tested Pi4 yet, but I have 3rd party reports that it is doing well!
Pi4 x11 excellent

also push a change that improves the situation on Pi0/Pi1 by completely disabling audio in SOUND = 0 in sqlux.ini (I think in reorg of code I had altered the semantics)


Post Reply