Post Reply 
N-Queens results on Casio calculators
07-22-2024, 08:03 PM (This post was last modified: 07-25-2024 05:45 PM by CalcLoverHK.)
Post: #1
N-Queens results on Casio calculators
Hey, I just registered here to share my results of N-Queens benchmark so far.

Long story short, I did a research on how much performance GCC can achieve in floating-point and integer arithmetic, and compared that to the Renesas SHC compiler which is used by Casio C SDK. The Whetstone and Dhrystone tests concluded that GCC is theoretically faster than SHC in both areas.

Reference: https://www.planet-casio.com/Fr/forums/t...piler.html

To further confirm the performance uplift, I tried to port C.Basic FX 2.47-β2 to GCC with the help of Lephenixnoir, and run N-Queens C.Basic program under Integer Mode. Here are the results I got:

fx-9860G Slim (Default): 0.639s
fx-9860G Slim (Ftune F5 OC): 0.233s
fx-9860GII-2 SD (Default): 0.539s
fx-9860GII-2 SD (Ftune2 F5 OC): 0.0768s

All of them are faster than the current best of their own category.

I also did benchmark on fxSDK/gint + GCC:

C / Unstructured
fx-9860G Slim (-Os): 0.002306s
fx-9860G Slim (-O2): 0.002264s
fx-9860G Slim (-O3/-Ofast): 0.002040s
fx-9860GII-2 SD (-Os): 0.001827s
fx-9860GII-2 SD (-O2): 0.001960s
fx-9860GII-2 SD (-O3/-Ofast): 0.002010s

fx-9860GII-2 SD (-Os, Ftune2 F5 OC): 0.000227s

C / Structured
fx-9860G Slim (-Os): 0.002870s
fx-9860G Slim (-O2): 0.002062s
fx-9860G Slim (-O3/-Ofast): 0.001996s
fx-9860GII-2 SD (-Os): 0.002498s
fx-9860GII-2 SD (-O2): 0.001873s
fx-9860GII-2 SD (-O3/-Ofast): 0.002028s

fx-9860G Slim (-O3/-Ofast, Ftune F5 OC): 0.000555s

MyCalcs profile
Find all posts by this user
Quote this message in a reply
07-23-2024, 06:11 AM
Post: #2
RE: N-Queens results on Casio calculators
(07-22-2024 08:03 PM)CalcLoverHK Wrote:  Hey, I just registered here to share my results of N-Queens benchmark so far.

This benchmark?

https://www.hpmuseum.org/cgi-sys/cgiwrap...i?read=700

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
07-23-2024, 08:56 AM
Post: #3
RE: N-Queens results on Casio calculators
(07-23-2024 06:11 AM)toml_12953 Wrote:  
(07-22-2024 08:03 PM)CalcLoverHK Wrote:  Hey, I just registered here to share my results of N-Queens benchmark so far.

This benchmark?

https://www.hpmuseum.org/cgi-sys/cgiwrap...i?read=700

Yes, though with a bit of modification on `printf("%d", s)` as I replaced it with gint's dprint() function.

MyCalcs profile
Find all posts by this user
Quote this message in a reply
07-24-2024, 08:47 PM
Post: #4
RE: N-Queens results on Casio calculators
(07-22-2024 08:03 PM)CalcLoverHK Wrote:  Hey, I just registered here to share my results of N-Queens benchmark so far.

Some nice improvements and especially the C.BASIC result of the fx-9860GII-2 SD (Ftune2 F5 OC) is impressive.

Thank you for the test results.

Calculator Benchmark
Find all posts by this user
Quote this message in a reply
07-25-2024, 07:09 PM (This post was last modified: 07-25-2024 07:12 PM by CalcLoverHK.)
Post: #5
RE: N-Queens results on Casio calculators
(07-24-2024 08:47 PM)xerxes Wrote:  
(07-22-2024 08:03 PM)CalcLoverHK Wrote:  Hey, I just registered here to share my results of N-Queens benchmark so far.

Some nice improvements and especially the C.BASIC result of the fx-9860GII-2 SD (Ftune2 F5 OC) is impressive.

Thank you for the test results.

Thanks for uploading my results, though I have a question on some of those on the benchmark thread: I tried to replicate the record of "C.BASIC 2.38 / Integer Mode / Fast Mode x7.0" using my fx-9860GII-2 SD, and so I assumed that fx-9750GII-2 was running under the Ftune2 F5 preset at the time of benchmarking, but it turned out my test result is actually faster (0.0939s) than this one (0.122s). Same for the C.BASIC 2.38 / Integer Mode record, where fx-9750GII-2 completes in 0.857s and mine only needs 0.661s even at default speed. Both calculators have the same CPU and so in theory they should have similar results.

By the way, for SH3 assembly version my fx-9860GII-2 SD takes 0.00136s at default and 0.000169s under F5 OC.

MyCalcs profile
Find all posts by this user
Quote this message in a reply
07-25-2024, 08:41 PM
Post: #6
RE: N-Queens results on Casio calculators
(07-25-2024 07:09 PM)CalcLoverHK Wrote:  Both calculators have the same CPU and so in theory they should have similar results.

Yes, in fact the C.BASIC results of the fx-9750GII-2 are too slow. An incorrect test code may have been used. I've removed them.
Thanks for your help, making the list more accurate.

Calculator Benchmark
Find all posts by this user
Quote this message in a reply
08-14-2024, 10:23 AM (This post was last modified: 08-14-2024 03:48 PM by Hlib.)
Post: #7
RE: N-Queens results on Casio calculators
A few comments about the "8-queens benchmark" program for CASIO calculators, a variant with Goto and Lbl. It is necessary to delete the useless Deg (or Rad) command and swap the two operators. The speed of calculations will not change at all, but the program code will look better.
Code:

8➝R : R➝Dim A
0➝S : 0➝X
Lbl 0 : X=R⇒Goto 4
Isz X : R➝A[X]
Lbl 1 : Isz S : X➝Y
Lbl 2 : Dsz Y : A[X]-A[Y]➝T
Y=0⇒Goto 0 : T=0⇒Goto 3
(X-Y)≠Abs T⇒Goto 2
Lbl 3 : Dsz A[X] : Goto 1
Dsz X : Goto 3
Lbl 4 : S
Note that in CBASIC, the (X-Y)≠Abs T⇒Goto 2 command must have parentheses. Sentaro21 (the author of CBASIC) pointed out a long time ago that parentheses here provide compilation of elementary arithmetic expressions.
Here are the results for comparison.
FX-9860GII-2, integer mode (CBASIC ver.2.45):
t=0.661_sec without parentheses
t=0.481_sec with parentheses (×1.4 times faster).
Find all posts by this user
Quote this message in a reply
08-16-2024, 12:06 AM
Post: #8
RE: N-Queens results on Casio calculators
(08-14-2024 10:23 AM)Hlib Wrote:  Note that in CBASIC, the (X-Y)≠Abs T⇒Goto 2 command must have parentheses. Sentaro21 (the author of CBASIC) pointed out a long time ago that parentheses here provide compilation of elementary arithmetic expressions.

I'm amazed about the speed difference with parentheses. Some languages ​​do indeed have special characteristics that are not known to everyone.
Can you please also test the FX-9860GII-2 with Ftune2 F5? I'll retest the FX-9860G with parentheses in the next days.

Calculator Benchmark
Find all posts by this user
Quote this message in a reply
08-16-2024, 03:22 PM
Post: #9
RE: N-Queens results on Casio calculators
(08-16-2024 12:06 AM)xerxes Wrote:  Can you please also test the FX-9860GII-2 with Ftune2 F5? I'll retest the FX-9860G with parentheses in the next days.
I have never used Ftune, so I cannot provide you with these results.
Here is the fastest 8-queens benchmark version adapted exclusively for CBASIC:
Code:

8➝R : R➝Dim A
0➝S : 0➝X
Lbl 0 : X=R⇒Goto 5
Isz X : R➝A[X]
Lbl 1 : Isz S : X➝Y
Lbl 2 : Dsz Y
A[X]-A[Y]➝T⇒Goto 3
Y=0⇒Goto 0 : Goto 4
Lbl 3 : (X-Y)≠Abs T⇒Goto 2
Lbl 4 : Dsz A[X] : Goto 1
Dsz X : Goto 4
Lbl 5 : S
FX-9860GII-2, integer mode (CBASIC ver.2.45):
t=0.398_sec at 29.5_MHz.
Find all posts by this user
Quote this message in a reply
08-17-2024, 02:18 AM
Post: #10
RE: N-Queens results on Casio calculators
(08-16-2024 03:22 PM)Hlib Wrote:  Here is the fastest 8-queens benchmark version adapted exclusively for CBASIC:

Very nice. I'll update the list soon with your code.

Calculator Benchmark
Find all posts by this user
Quote this message in a reply
08-20-2024, 10:42 PM
Post: #11
RE: N-Queens results on Casio calculators
I've updated the list with the new C.BASIC test code from Hlib and removed the previous results.
Now we have the FX-9860G SD with SH-3 and the FX-9860GII-2 with SH-4 CPU:

Code:
FX-9860G SD  @ 29.5 MHz: 0.489 sec

FX-9860GII-2 @ 29.5 MHz: 0.398 sec

FX-9860G SD  @ 118  MHz: 0.170 sec

FX-9860GII-2 @ 236  MHz: 0.0568 sec

Calculator Benchmark
Find all posts by this user
Quote this message in a reply
08-21-2024, 03:49 AM
Post: #12
RE: N-Queens results on Casio calculators
(08-20-2024 10:42 PM)xerxes Wrote:  I've updated the list with the new C.BASIC test code from Hlib and removed the previous results.
Now we have the FX-9860G SD with SH-3 and the FX-9860GII-2 with SH-4 CPU:

Code:
FX-9860G SD  @ 29.5 MHz: 0.489 sec

FX-9860GII-2 @ 29.5 MHz: 0.398 sec

FX-9860G SD  @ 118  MHz: 0.170 sec

FX-9860GII-2 @ 236  MHz: 0.0568 sec
Please excuse my ignorance but how do you time the execution with such accuracy ?
Find all posts by this user
Quote this message in a reply
08-21-2024, 06:38 PM
Post: #13
RE: N-Queens results on Casio calculators
(08-21-2024 03:49 AM)nickapos Wrote:  
(08-20-2024 10:42 PM)xerxes Wrote:  I've updated the list with the new C.BASIC test code from Hlib and removed the previous results.
Now we have the FX-9860G SD with SH-3 and the FX-9860GII-2 with SH-4 CPU:

Code:
FX-9860G SD  @ 29.5 MHz: 0.489 sec

FX-9860GII-2 @ 29.5 MHz: 0.398 sec

FX-9860G SD  @ 118  MHz: 0.170 sec

FX-9860GII-2 @ 236  MHz: 0.0568 sec
Please excuse my ignorance but how do you time the execution with such accuracy ?

CBASIC has a real-time clock included.
To initialize it, set Ticks to 0 at the beginning of your program, then when your program ends, print Ticks. The resolution is 1/128 sec.

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
08-21-2024, 11:02 PM
Post: #14
RE: N-Queens results on Casio calculators
(08-21-2024 03:49 AM)nickapos Wrote:  Please excuse my ignorance but how do you time the execution with such accuracy ?

As toml_12953 stated, C.BASIC offers the Ticks command. For more accuracy I use an outer loop for fast and very fast devices and languages.

Calculator Benchmark
Find all posts by this user
Quote this message in a reply
08-23-2024, 08:59 AM (This post was last modified: 08-23-2024 09:23 AM by Hlib.)
Post: #15
RE: N-Queens results on Casio calculators
I offer you a faster CASIO-BASIC(structured) program. It does not look as neat as MicroPython code, but it allows you to get an increase in speed in the range of 17 ... 28% for some CASIO models.
This code is not suitable for CBASIC, as well as for calculators from the old generation (e.g. FX-7450G+/9700GE/9750G+).

Code:

8➝R : {R,1}->Dim Mat A
0->S : 0->X : 1->Z
While Z=0 Or X<>R
  If Z
    Then Isz X : R->L
      Else Dsz X : Mat A[X,1]-1->L
        If X=0
          Then Break
        IfEnd
  IfEnd
  For L->Y To 1 Step -1
    For 1->Z To X-1
    Y-Mat A[Z,1]->T
      If T=0 Or X-Z=Abs T
        Then 0->Z : Break
      IfEnd
    Next : Isz S
      If Z
        Then Y->Mat A[X,1] : Break
      IfEnd
  Next
WhileEnd
S

t=22.5_sec vs 29_sec, FX-9750GII (SH3, OS 2.0), +22% increase in speed.
t=42_sec vs 58.7_sec, FX-9860GII-2 (SH4, OS 2.09), +28%, without USB.
t=103_sec (1:43) vs 125_sec (2:05), AFX-2.0+, GRAPH-100+, +17%.

I don`t use lists in the above models because with the list-type variables the results are not stable. The more lists are defined in these calculators, the lower the speed of operations with list items.
A standard algorithm was used.
S=876, result is Mat A=[[8][4][1][3][6][2][7][5]]
Find all posts by this user
Quote this message in a reply
08-24-2024, 02:41 PM
Post: #16
RE: N-Queens results on Casio calculators
Thank you for your offer and effort. Please allow me to leave the test code of these calculators unchanged,
because that would mean that we have to do the same or similar changes of the algorithm for comparability on
other machines too. The test algorithm is deliberately chosen to be very simple, to be executable on almost all
programmable calculators in the same or as similar as possible way. I know, there are some exceptions in the list.

(08-23-2024 08:59 AM)Hlib Wrote:  I don`t use lists in the above models because with the list-type variables the results are not stable. The more lists are defined in these calculators, the lower the speed of operations with list items.

This is the reason, why I've also used a matrix in the test code.

Calculator Benchmark
Find all posts by this user
Quote this message in a reply
08-24-2024, 06:18 PM (This post was last modified: 08-24-2024 06:23 PM by Hlib.)
Post: #17
RE: N-Queens results on Casio calculators
@ Xerxes
Quote:... Please allow me to leave the test code of these calculators unchanged, because that would mean that we have to do the same or similar changes of the algorithm for comparability on other machines too.
The test algorithm is deliberately chosen to be very simple, to be executable on almost all programmable calculators in the same or as similar as possible way. ...
You misunderstood me.
When I said "is not suitable", it only meant the fact that structured code shows a lower speed in CBASIC and in FX-9750G+(CFX-9850GB+ etc.) than unstructured code.
In fact, the new (and fastest) structured program fixes the compatibility issue that is present in the old benchmark for FX-2.0+, FX-9860G, FX-9860GII, FX-CG50. The old structured code does not run in FX-9750G+(CFX-9850GB+ etc.) and causes the message Syntax ERROR because nested structures While do not work in these models.
Now the new program runs fine in FX-9750G+ (CFX-9850GB+ etc.) and does not cause an error message.
Also, the above-corrected unstructured code is still executed on the models for which it was intended, and even the calculation time remains the same. The old code with kludge Deg or Rad looks a bit inelegant.
Find all posts by this user
Quote this message in a reply
08-24-2024, 09:25 PM
Post: #18
RE: N-Queens results on Casio calculators
(08-24-2024 06:18 PM)Hlib Wrote:  You misunderstood me.

Sorry for the misunderstanding.

Calculator Benchmark
Find all posts by this user
Quote this message in a reply
08-25-2024, 10:38 AM
Post: #19
RE: N-Queens results on Casio calculators
(08-21-2024 11:02 PM)xerxes Wrote:  As toml_12953 stated, C.BASIC offers the Ticks command. For more accuracy I use an outer loop for fast and very fast devices and languages.

C.Basic also has a setting called `Exec TimeDsp` that displays the total execution time at the end of a program.

That being said, I noticed Hlib didn't use the latest version of C.Basic which includes the change in compiler (SHC➝GCC). With C.Basic v2.50-β1, the results are now:

Code:
FX-9860G Slim  @ 29.5 MHz: 0.383 sec
FX-9860GII-2 SD @ 29.5 MHz: 0.309 sec
FX-9860G Slim  @ 118  MHz: 0.141 sec
FX-9860GII-2 SD @ 236  MHz: 0.0433 sec

MyCalcs profile
Find all posts by this user
Quote this message in a reply
08-26-2024, 06:05 AM
Post: #20
RE: N-Queens results on Casio calculators
(08-25-2024 10:38 AM)CalcLoverHK Wrote:  the results are now:

Code:
FX-9860G Slim  @ 29.5 MHz: 0.383 sec
FX-9860GII-2 SD @ 29.5 MHz: 0.309 sec
FX-9860G Slim  @ 118  MHz: 0.141 sec
FX-9860GII-2 SD @ 236  MHz: 0.0433 sec

Thank you for testing. Hlibs test code for C.BASIC is very well done.

Calculator Benchmark
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 2 Guest(s)