π
<-
Chat plein-écran
[^]

[Eng][help needed] Calculator benchmarks

:32tins: :32tinsktpb: :32tinsktpn: :32tinscas: :32tinstpkc: :32tinstpktpb: :32tinstp: :32tinscastp: :32tinscmc: :32tinscx: :32tinscxcas:

Re: [Eng][help needed] Calculator benchmarks

Unread postby Lionel Debroux » 13 Sep 2013, 12:47

Ultranaiveprimes benchmark with N=1000 and N=10000, for TI-68k/AMS/GCC4TI

1) File ultranaiveprimes.c

Code: Select all
// ultranaiveprimes.c: silly algorithm for finding primes

#define MIN_AMS 101
#define USE_TI89
#define USE_TI92P
#define USE_V200
#define USE_TI89T
#define NO_CALC_DETECT
#define OPTIMIZE_ROM_CALLS
#define RETURN_VALUE

#include <stdint.h>
#include <system.h>
#include <args.h>
#include <estack.h>
#include <intr.h>
#include <timath.h>

#define TIMER_START_VAL (100000UL)
#define N (10000)

void _main(void) {
    uint16_t j, k;
    short orig_rate = PRG_getRate();
    unsigned short orig_start = PRG_getStart();
    unsigned long val = 0;

    // Make the system timer an order of magnitude more precise;
    // NOTE: this code assumes a HW2+ TI-68k, i.e. anything since 1999.
    PRG_setRate(1); // Increment counter at a rate of 2^19/2^9 Hz
    PRG_setStart(0xCE); // Trigger the interrupt every 257 - 0xCE = 51 increments ~ 20.07 Hz.

    // The PRG_getStart() above effectively waited for the interrupt to trigger, so we don't need another wait.
    /*OSRegisterTimer(USER_TIMER, 1);
    while (!OSTimerExpired(USER_TIMER));
    OSFreeTimer(USER_TIMER);*/
    OSRegisterTimer(USER_TIMER, TIMER_START_VAL);

    // Main loop :)
    for (k = 3; k < N; k++) {
        for (j = 2; j < k - 1; j++) {
            if (k % j == 0) {
                j = k - 1; // so we exit from the inner for
            }
        }
    }

    // Retrieve timer value.
    val = TIMER_START_VAL - OSTimerCurVal(USER_TIMER);
    OSFreeTimer(USER_TIMER);

    // Push arguments onto the RPN stack: clean arguments up, then create a list.
    while (GetArgType (top_estack) != END_TAG) {
        top_estack = next_expression_index (top_estack);
    }
    top_estack--;
    push_longint(val);

    // Restore old system state.
    PRG_setRate(orig_rate);
    PRG_setStart(orig_start);
}


2) Compiler invocation

Code: Select all
tigcc -v -O3 -Wall -W -mpcrel --optimize-code --cut-ranges --reorder-sections --remove-unused --merge-constants -fmerge-all-constants -Wa,--all-relocs -Wa,-l -fverbose-asm -save-temps -o unprimes ultranaiveprimes.c


3) Results on 89T HW4 AMS 3.10 patched with tiosmod+amspatch
:
* N=1000: 25, 25, i.e. about 1"25.
* N=10000: 1918, 1919, i.e. ~1'35"6.
Membre de la TI-Chess Team.
Co-mainteneur de GCC4TI (documentation en ligne de GCC4TI), TIEmu et TILP.
User avatar
Lionel DebrouxSuper Modo
Niveau 14: CI (Calculateur de l'Infini)
Niveau 14: CI (Calculateur de l'Infini)
Level up: 8.7%
 
Posts: 6655
Joined: 23 Dec 2009, 00:00
Location: France
Gender: Male
Calculator(s):
Class: -
GitHub: debrouxl

Re: [Eng][help needed] Calculator benchmarks

Unread postby pier4r » 13 Sep 2013, 16:07

Thanks a lot! Now i'm porting the last bit of information about the savage benchmark (or at least what i found), then i'll report your results!

About the slow down of the Casio C program, i agree, in fact flyingfisch is working on it.
User avatar
pier4r
Niveau 3: MH (Membre Habitué)
Niveau 3: MH (Membre Habitué)
Level up: 36%
 
Posts: 15
Joined: 11 Sep 2013, 16:12
Gender: Not specified
Calculator(s):

Re: [Eng][help needed] Calculator benchmarks

Unread postby pier4r » 13 Sep 2013, 19:12

Added. Now really i'm corious about nspire and nspire CX (if their cpu is different).
User avatar
pier4r
Niveau 3: MH (Membre Habitué)
Niveau 3: MH (Membre Habitué)
Level up: 36%
 
Posts: 15
Joined: 11 Sep 2013, 16:12
Gender: Not specified
Calculator(s):

Re: [Eng][help needed] Calculator benchmarks

Unread postby Lionel Debroux » 13 Sep 2013, 20:05

The Nspire Clickpad/Touchpad on the one side, and the Nspire CX / CM on the other side, are indeed different. Their clock speed settings depend on the OS version, but the default value is higher for CX/CM than for the Clickpad/Touchpad, and overclocked CX/CM can reach higher clock speeds than Clickpad/Touchpad.
Membre de la TI-Chess Team.
Co-mainteneur de GCC4TI (documentation en ligne de GCC4TI), TIEmu et TILP.
User avatar
Lionel DebrouxSuper Modo
Niveau 14: CI (Calculateur de l'Infini)
Niveau 14: CI (Calculateur de l'Infini)
Level up: 8.7%
 
Posts: 6655
Joined: 23 Dec 2009, 00:00
Location: France
Gender: Male
Calculator(s):
Class: -
GitHub: debrouxl

Re: [Eng][help needed] Calculator benchmarks

Unread postby pier4r » 13 Sep 2013, 20:17

Oh, i don't know that. So i'll wait for their results (by you or by another volunteer).

PS: i don't have the TI here, but when i get it, i'll install your chess program. using the calculator also for relax seems good.
User avatar
pier4r
Niveau 3: MH (Membre Habitué)
Niveau 3: MH (Membre Habitué)
Level up: 36%
 
Posts: 15
Joined: 11 Sep 2013, 16:12
Gender: Not specified
Calculator(s):

Re: [Eng][help needed] Calculator benchmarks

Unread postby pier4r » 15 Sep 2013, 21:42

I still have the hope for a volunteer with a ti-nspire!
User avatar
pier4r
Niveau 3: MH (Membre Habitué)
Niveau 3: MH (Membre Habitué)
Level up: 36%
 
Posts: 15
Joined: 11 Sep 2013, 16:12
Gender: Not specified
Calculator(s):

Re: [Eng][help needed] Calculator benchmarks

Unread postby Adriweb » 15 Sep 2013, 21:43

I guess I can help with Nspire-Lua :

Ultra Naive Prime :
Code: Select all
local timerStart = timer.getMilliSecCounter()
local n = 100
for k = 3, n do
  for j = 2, k-1 do
    if k%j==0 then break end
  end
end

print("n = " .. n, (timer.getMilliSecCounter()-timerStart)/1000 .. ' s.')


I'll report that tomorrow morning as I don't have my CX with me right now.
(It'll be on a CX CAS with OS 3.2.3, no overclock (default 133 MHz)).
Maybe on a not-overclock 3.1.0.392 CX CAS too.
User avatar
AdriwebAdmin
Niveau 16: CC2 (Commandeur des Calculatrices)
Niveau 16: CC2 (Commandeur des Calculatrices)
Level up: 57%
 
Posts: 13307
Images: 1093
Joined: 01 Jun 2007, 00:00
Location: France
Gender: Male
Calculator(s):
Class: (ingénieur)
Twitter: adriweb
GitHub: adriweb

Re: [Eng][help needed] Calculator benchmarks

Unread postby Adriweb » 15 Sep 2013, 22:23

Codes (one trivial and one optimized version) for Nspire-Lua
Savage
benchmark :
Code: Select all
-- Non-optimized version :

local timerStart = timer.getMilliSecCounter()
local a = 0
for i = 1, 2500 do
    a = math.tan(math.atan(math.exp(math.log(math.sqrt(a*a))))) + 1
end
print("non-optimized", "n = 2500", " a = " .. a, (timer.getMilliSecCounter()-timerStart)/1000 .. ' s.')


-- Optimized version :

local timerStart = timer.getMilliSecCounter()
local a = 0
-- localizing the functions speeds up the calculations in the loop.
local tan, atan, exp, log, sqrt = math.tan, math.atan, math.exp, math.log, math.sqrt
for i = 1, 2500 do
    a = tan(atan(exp(log(sqrt(a*a))))) + 1
end
print("  optimized  ", "n = 2500", " a = " .. a, (timer.getMilliSecCounter()-timerStart)/1000 .. ' s.')
User avatar
AdriwebAdmin
Niveau 16: CC2 (Commandeur des Calculatrices)
Niveau 16: CC2 (Commandeur des Calculatrices)
Level up: 57%
 
Posts: 13307
Images: 1093
Joined: 01 Jun 2007, 00:00
Location: France
Gender: Male
Calculator(s):
Class: (ingénieur)
Twitter: adriweb
GitHub: adriweb

Re: [Eng][help needed] Calculator benchmarks

Unread postby Adriweb » 16 Sep 2013, 16:29

Okay, here are the results for Lua on the TI-Nspire CX CAS, not overclocked (default 133 MHz), OS 3.2.3 :

Image

The rest is coming later - Savage is talking a really long time, apparently...

Edit : savage-optimized takes 698.06 seconds for n=100... wut ?

Full code for all 3 :
Code: Select all
-- Some Benchmarks
-- Adrien "Adriweb" Bertrand
-- Sept. 15, 2013

outputs = {}
output = function(...) table.insert(outputs, table.concat({...}, " ; ")) end


-----------------------
-- Ultra Naive Prime --
-----------------------

function unp()
    for _,theN in pairs({100, 1000, 10000}) do
        local timerStart = timer.getMilliSecCounter()
        local n = theN
        for k = 3, n do
          for j = 2, k-1 do
            if k%j==0 then break end
          end
        end
        output("Ultra Naive Prime", "n = " .. n, (timer.getMilliSecCounter()-timerStart)/1000 .. ' s.')
    end
    output ""
end

------------
-- Savage --
------------

function savage_unopti()
    -- Unoptimized version :
    local timerStart = timer.getMilliSecCounter()
    local a = 0
    for i = 1, 2500 do
        a = math.tan(math.atan(math.exp(math.log(math.sqrt(a*a))))) + 1
    end
    output("Savage ", " unoptimized  ", "n = 2500", " a = " .. a, (timer.getMilliSecCounter()-timerStart)/1000 .. ' s.')
end

function savage_opti()
    -- Optimized version :
    local timerStart = timer.getMilliSecCounter()
    local a = 0
    -- localizing the functions speeds up the calculations in the loop.
    local tan, atan, exp, log, sqrt = math.tan, math.atan, math.exp, math.log, math.sqrt
    for i = 1, 2500 do
        a = tan(atan(exp(log(sqrt(a*a))))) + 1
    end
    output("Savage ", "   optimized   ", "n = 2500", " a = " .. a, (timer.getMilliSecCounter()-timerStart)/1000 .. ' s.')
end

function on.charIn(ch)
    pcall(({p=unp, u=savage_unopti, o=savage_opti})[ch])
    platform.window:invalidate()
end

function on.escapeKey()
    outputs = {}
    platform.window:invalidate()
end

function on.paint(gc)
    gc:setFont("sansserif", "r", 8)
    for i,v in ipairs(outputs) do
        gc:drawString(v, 5, 20*(i-1)+10, "top")
    end
end
User avatar
AdriwebAdmin
Niveau 16: CC2 (Commandeur des Calculatrices)
Niveau 16: CC2 (Commandeur des Calculatrices)
Level up: 57%
 
Posts: 13307
Images: 1093
Joined: 01 Jun 2007, 00:00
Location: France
Gender: Male
Calculator(s):
Class: (ingénieur)
Twitter: adriweb
GitHub: adriweb

Re: [Eng][help needed] Calculator benchmarks

Unread postby pier4r » 16 Sep 2013, 22:58

Thanks really a lot! Hopefully I will report those tomorrow.
User avatar
pier4r
Niveau 3: MH (Membre Habitué)
Niveau 3: MH (Membre Habitué)
Level up: 36%
 
Posts: 15
Joined: 11 Sep 2013, 16:12
Gender: Not specified
Calculator(s):

PreviousNext

Return to Problèmes divers / Aide débutants

Who is online

Users browsing this forum: No registered users and 12 guests

-
Search
-
Social
-
Featured topics
Comparaisons des meilleurs prix pour acheter sa calculatrice !
Découvre les nouvelles fonctionnalités en Python de l'OS 5.2 pour les Nspire CX II
Découvre les nouvelles fonctionnalités en Python de l'OS 5.5 pour la 83PCE/84+C-T Python Edition
Omega, le fork étendant les capacités de ta NumWorks, même en mode examen !
1234
-
Donations / Premium
For more contests, prizes, reviews, helping us pay the server and domains...
Donate
Discover the the advantages of a donor account !
JoinRejoignez the donors and/or premium!les donateurs et/ou premium !


Partner and ad
Notre partenaire Jarrety Calculatrices à acheter chez Calcuso
-
Stats.
507 utilisateurs:
>479 invités
>21 membres
>7 robots
Record simultané (sur 6 mois):
6892 utilisateurs (le 07/06/2017)

-
Other interesting websites
Texas Instruments Education
Global | France
 (English / Français)
Banque de programmes TI
ticalc.org
 (English)
La communauté TI-82
tout82.free.fr
 (Français)