Omnimaga: The Coders Of Tomorrow
Welcome, Guest. Please login or register.
 
Omnimaga: The Coders Of Tomorrow
22 May, 2013, 04:06:29 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   home   news downloads projects tutorials misc forums rules new posts irc about Login Register  
+-OmnomIRC

You must Register, be logged in and have at least 40 posts to use this shout-box! If it still doesn't show up afterward, it might be that OmnomIRC is disabled for your group or under maintenance.

Note: You can also use an IRC client like mIRC, X-Chat or Mibbit to connect to an EFnet server and #omnimaga.

Pages: 1 ... 4 5 [6] 7 8   Go Down
  Print  
Author Topic: The Optimization Compilation -  (Read 10212 times) Bookmark and Share
0 Members and 1 Guest are viewing this topic.
Quigibo
The Executioner
LV11 Super Veteran (Next: 3000)
***********
Offline Offline

Gender: Male
Last Login: Yesterday at 02:03:21
Date Registered: 22 January, 2010, 05:02:37
Location: Los Angeles
Posts: 2022


Total Post Ratings: +1019

View Profile
« Reply #75 on: 07 February, 2011, 04:09:55 »
+1

Its not an auto-optimization, but it is a significant one.

To have a loop with a conditional at the end saves 3 bytes from a loop with conditional checking at the beginning. For instance:

1
2
3
Repeat getKey(15)
...code...
End

Can become:

1
2
3
While 1
...code...
EndIf getKey(15)

You can't do this with every loop since a lot of them need to check before entering the loop, but with situations like this example, it probobly doesn't matter.  The EndIf can actually be used on any loop structure though, including do loops, while loops, repeat loops, and for loops.  A do loop, which is also new, is just a "While 1" or "Repeat 0" which automatically get optimized to not do the check at all since they always loop.
« Last Edit: 07 February, 2011, 04:10:51 by Quigibo » Logged

___Axe_Parser___
Today the calculator, tomorrow the world!
ztrumpet
The Rarely Active One
LV13 Extreme Addict (Next: 9001)
*************
Offline Offline

Gender: Male
Last Login: Today at 03:10:30
Date Registered: 08 November, 2009, 21:10:12
Location: Michigan
Posts: 5687


Total Post Ratings: +360

View Profile
« Reply #76 on: 07 February, 2011, 04:38:46 »
0

Cool!  I love post test loops! Grin
Logged

squidgetx
Food.
Coder Of Tomorrow
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: Yesterday at 18:24:17
Date Registered: 30 May, 2010, 19:54:18
Location: eating somewhere
Posts: 1831


Topic starter
Total Post Ratings: +476

View Profile
« Reply #77 on: 13 February, 2011, 23:29:44 »
+1

Pixel Testing

Pixel testing can be a mean and nasty cycle stealer from many programs. But never fear, it can be optimized...a lot. Remember that we have access to the screen buffer in L6.

If you are pixel testing a constant pixel, like pxl-Test(20,20), you can more than halve the speed of this command with the following optimization:

1
{20*12+L6+2}^^r e4
This optimization relies on the fact that the numbers can basically be pre-computed: use the following formula to derive the numbers you should use:

1
{Y*12+L6+(X/8)}e(X^8)
So for another example, the command pxl-Test(8,1) becomes {12+L6}e1.

The speed gain from this is so great that you can even still save (although not as much) even with a variable Y value. How you treat the constant X value remains the same as before, but simply substitute in your variable Y value in the above code. So for example, pxl-Test(31,Y) becomes {Y*12+L6+3}e7.

Edit: here are the numbers if anyone wants them
pxl-Test is 53 bytes, ~237 cycles, plus 66 to call. Then we have to load two constants, adding 20 cycles. Let's make a conservative estimate and say 320 cycles.
{} is 14 cycles. Loading a constant into it is 10 cycles. The fastest bit-check is e7 which is 20 cycles, while the slowest is e2 which is 49 cycles. So we're in the range of 44-73 cycles, less than a third of pxl-Test() O.o

For variable Y, pxl-Test(Y,constant) is about 326 cycles. Now, loading a var is 16 cycles, *12 is 52, plus a constant is 21 cycles. The speed of this is 123-152 cycles, still more than twice as fast.

I suspect that variable X and Y with this method is about the same speed as regular pxl-testing.
« Last Edit: 15 February, 2011, 14:19:19 by squidgetx » Logged

Read my webcomic! | My SoundCloud
Projects:

Check out the demo now!- Current progress: battle engine and stuff
Proud author of: Cuberunner | SpaceDash | The Psyche | XXEdit | AxeSynth | StickNinja | Gravity Guy | Embers:Phoenix | Zombie Gun
Axe: Need help optimizing?
User of Axe | zStart | TokenIDE | CalcGS | MirageOS
NinjaKnight
LV2 Member (Next: 40)
**
Offline Offline

Gender: Male
Last Login: 16 March, 2011, 02:51:36
Date Registered: 03 February, 2011, 22:31:56
Location: Everywhere.
Posts: 20

Total Post Ratings: +2

View Profile
« Reply #78 on: 14 February, 2011, 05:17:33 »
0

Is using Rect( to draw straight horizontal/vertical lines faster than Line( ?
Logged

Ninja vs. Chuck Norris == n/0. Both end with the world blowing up.

"We could use up two eternities in learning all that is to be learned about our own world and the thousands of nations that have arisen and flourished and vanished from it. Mathematics alone would occupy me eight million years."
-Mark Twain
Runer112
Anti-Riot Squad
LV10 31337 u53r (Next: 2000)
*
Online Online

Gender: Male
Last Login: Today at 04:01:15
Date Registered: 02 July, 2009, 06:38:05
Posts: 1679


Total Post Ratings: +492

View Profile
« Reply #79 on: 14 February, 2011, 06:59:10 »
+1

If you are pixel testing a constant pixel, like pxl-Test(20,20), you can more than halve the speed of this command with the following optimization:

1
{20*12+L6+2}e4

Remember, storing or recalling two-byte values at a constant address is always smaller and faster than storing or recalling one-byte values!

1
{20*12+L₆+2}ʳe4


Is using Rect( to draw straight horizontal/vertical lines faster than Line( ?

Definitely. Here are the results I got for vertical lines. Also note the 3 bytes saved in the Rect() arguments with some nice hl "abuses." Tongue
  • Line(A,0,A,63): ~6132 cycles
  • Rect(A,0,+1,-2): ~3354 cycles

The results are even more profound for horizontal lines. Also, 1 byte saved in the Rect() arguments.
  • Line(0,A,95,A): 9809 cycles
  • Rect(0,A,-1,+2): 2579 cycles

But if you really want a blazingly fast horizontal line drawer in pure Axe, use the following. It has a check to make sure that the y-value is valid, and if so, the whole process of calling the routine, checking the y-value, and drawing the line takes only 497 cycles. You would call it with something like Ysub(HL). Also, note the trick employed to check that the y-value is less than 64. That saves a few bytes and cycles over a normal comparison by utilizing the fact that we want a value precisely in the 6-bit range. By simply resetting these 6 bits and leaving any other bits unchanged, any 6-bit values will become zero and any out of range values will become nonzero, resulting in easy checking.

1
2
3
4
5
6
7
Lbl HL
  →r₆
  ReturnIf and b11000000
  ᴇFFFF→{r₆*12+L₆}ʳ
  Fill(,10)
Return
« Last Edit: 14 February, 2011, 08:32:16 by Runer112 » Logged
NinjaKnight
LV2 Member (Next: 40)
**
Offline Offline

Gender: Male
Last Login: 16 March, 2011, 02:51:36
Date Registered: 03 February, 2011, 22:31:56
Location: Everywhere.
Posts: 20

Total Post Ratings: +2

View Profile
« Reply #80 on: 15 February, 2011, 05:28:17 »
0

 shocked That's a saving of OVER 9000 CYCLES!
Logged

Ninja vs. Chuck Norris == n/0. Both end with the world blowing up.

"We could use up two eternities in learning all that is to be learned about our own world and the thousands of nations that have arisen and flourished and vanished from it. Mathematics alone would occupy me eight million years."
-Mark Twain
squidgetx
Food.
Coder Of Tomorrow
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: Yesterday at 18:24:17
Date Registered: 30 May, 2010, 19:54:18
Location: eating somewhere
Posts: 1831


Topic starter
Total Post Ratings: +476

View Profile
« Reply #81 on: 16 February, 2011, 14:19:08 »
0

Here's something really cool I found out yesterday:
DispGraphr  is faster than DispGraph. By more than 10000 cycles, too. It varies from calc to calc, but on mine its a full 15000 cycles faster O.o This means that if you're making a monochrome game, and you're not using the backbuffer....(at the cost of around 15 bytes or so) you can make a
saving of OVER 9000 CYCLES!
« Last Edit: 16 February, 2011, 14:19:27 by squidgetx » Logged

Read my webcomic! | My SoundCloud
Projects:

Check out the demo now!- Current progress: battle engine and stuff
Proud author of: Cuberunner | SpaceDash | The Psyche | XXEdit | AxeSynth | StickNinja | Gravity Guy | Embers:Phoenix | Zombie Gun
Axe: Need help optimizing?
User of Axe | zStart | TokenIDE | CalcGS | MirageOS
Deep Thought
So much to do, so much time, so little motivation
Administrator
LV13 Extreme Addict (Next: 9001)
*
Offline Offline

Gender: Male
Last Login: 19 May, 2013, 19:18:47
Date Registered: 19 May, 2009, 08:00:00
Location: The Universe
Posts: 7813


Total Post Ratings: +706

View Profile WWW
« Reply #82 on: 16 February, 2011, 16:26:08 »
0

Here's something really cool I found out yesterday:
DispGraphr  is faster than DispGraph. By more than 10000 cycles, too. It varies from calc to calc, but on mine its a full 15000 cycles faster O.o This means that if you're making a monochrome game, and you're not using the backbuffer....(at the cost of around 15 bytes or so) you can make a
saving of OVER 9000 CYCLES!

Wait ... what? How did that work O.o
Logged




Happybobjr
James Oldiges
LV11 Super Veteran (Next: 3000)
***********
Offline Offline

Gender: Male
Last Login: Today at 01:59:20
Date Registered: 01 June, 2010, 00:52:05
Location: IN, United States
Posts: 2273


Total Post Ratings: +100

View Profile
« Reply #83 on: 16 February, 2011, 17:01:25 »
0

Here's something really cool I found out yesterday:
DispGraphr  is faster than DispGraph. By more than 10000 cycles, too. It varies from calc to calc, but on mine its a full 15000 cycles faster O.o This means that if you're making a monochrome game, and you're not using the backbuffer....(at the cost of around 15 bytes or so) you can make a
saving of OVER 9000 CYCLES!

how? that's weird
Logged

School: East Central High School

Axe: 1.0.0
TI-84 +SE  ||| OS: 2.53 MP (patched) ||| Version: "M"
TI-Nspire    |||  Non-Cas |||  OS: 1.1 |||  Build: Old  |||  84+ keypad.   Being lent out
____________________________________________________________
Runer112
Anti-Riot Squad
LV10 31337 u53r (Next: 2000)
*
Online Online

Gender: Male
Last Login: Today at 04:01:15
Date Registered: 02 July, 2009, 06:38:05
Posts: 1679


Total Post Ratings: +492

View Profile
« Reply #84 on: 16 February, 2011, 20:21:46 »
0

I see you've been reading up on my Commands documentation, eh squidgetx? Yeah, that's an interesting thing I discovered when speed testing the display commands. On calculators like mine with the old, "good" screen drivers, the screen driver delay seems to be pretty low and constant from calculator to calculator. DispGraph could run just as fast or faster than DispGraphr on these calculators. However, due to inconsistencies with the screen drivers in newer units, the routine may run too fast for the driver on some calculators, causing display problems, so Quigibo had to add a portion of code to pause the routine until the driver says it is ready. However, this pause itself adds some overhead time, making the routine slower.

Quigibo, the DispGraphr routine doesn't have any throttling system in place, yet no problems have been reported with it on newer calculators. Could you just remove the throttling system from the DispGraph routine and add one or two time-wasting instructions to make each loop iteration take as many cycles as each DispGraphr loop iteration?


EDIT: Hmm I don't know if Quigibo reads this thread and would see that, so I'm probably going to post that in a major thread he reads or send him a message about that.
« Last Edit: 16 February, 2011, 20:26:24 by Runer112 » Logged
Deep Thought
So much to do, so much time, so little motivation
Administrator
LV13 Extreme Addict (Next: 9001)
*
Offline Offline

Gender: Male
Last Login: 19 May, 2013, 19:18:47
Date Registered: 19 May, 2009, 08:00:00
Location: The Universe
Posts: 7813


Total Post Ratings: +706

View Profile WWW
« Reply #85 on: 16 February, 2011, 22:36:14 »
0

Weird, so basically DispGraphr has less of a delay than DispGraph, but it still works fine?

EDIT: Quigibo seems to read this occasionally (see the first post on this page). But posting in the Features Wishlist or something else would be a good idea, too, especially now that this thread is no longer in the Axe project subforum.
« Last Edit: 16 February, 2011, 22:37:37 by Deep Thought » Logged




squidgetx
Food.
Coder Of Tomorrow
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: Yesterday at 18:24:17
Date Registered: 30 May, 2010, 19:54:18
Location: eating somewhere
Posts: 1831


Topic starter
Total Post Ratings: +476

View Profile
« Reply #86 on: 22 February, 2011, 23:03:28 »
0

Quote
A quick and small way to determine the sign of a value (better than >>0) is

1
EXP//32768
. It will return -1 if the value is negative, and 0 if the value is 0 or positive

Also added how Text(30*256+20):Text("Text") is much smaller than Text(20,30,"Text")

Credits to Runer112.
« Last Edit: 22 February, 2011, 23:04:10 by squidgetx » Logged

Read my webcomic! | My SoundCloud
Projects:

Check out the demo now!- Current progress: battle engine and stuff
Proud author of: Cuberunner | SpaceDash | The Psyche | XXEdit | AxeSynth | StickNinja | Gravity Guy | Embers:Phoenix | Zombie Gun
Axe: Need help optimizing?
User of Axe | zStart | TokenIDE | CalcGS | MirageOS
Freyaday
The One And Only Serial Time Killing Catboy-Loli-Ballerino
LV10 31337 u53r (Next: 2000)
**********
Offline Offline

Gender: Male
Last Login: Yesterday at 23:49:45
Date Registered: 24 February, 2011, 17:10:56
Location: ¿¿¿
Posts: 1888


Total Post Ratings: +110

View Profile WWW
« Reply #87 on: 07 March, 2011, 07:43:26 »
0

I'd like to point out that DispGraphr is not faster than DispGraph, it just uses less cycles. How can this be? DispGraphr requires a 6MHz clock, because the screen requires a ~10microsec delay between successive inputs, otherwise the screen displays random garbage. DispGraphr is faster than that @ Full speed, necessitating the slowdown. DispGraph, however, uses TI's own method to prevent this, an altermate display routine with the necessary delay built in.
Logged

In other news, Frey continues kicking unprecedented levels of ass.
Proud member of LF#N--Lolis For #9678B6 Names


Beware the Bitulator! ,.,./`My Artwork!
Runer112
Anti-Riot Squad
LV10 31337 u53r (Next: 2000)
*
Online Online

Gender: Male
Last Login: Today at 04:01:15
Date Registered: 02 July, 2009, 06:38:05
Posts: 1679


Total Post Ratings: +492

View Profile
« Reply #88 on: 07 March, 2011, 07:54:32 »
0

What do you mean DispGraphr is not faster? Using fewer cycles at the same clock speed pretty much defines it as being faster. Although the actual byte retrieval, calculations, and outputting to the screen take more cycles, it doesn't have the safety checks built-in that DispGraph does, which slow the DispGraph routine down to being slower than the DispGraphr routine.
« Last Edit: 07 March, 2011, 08:00:43 by Runer112 » Logged
Freyaday
The One And Only Serial Time Killing Catboy-Loli-Ballerino
LV10 31337 u53r (Next: 2000)
**********
Offline Offline

Gender: Male
Last Login: Yesterday at 23:49:45
Date Registered: 24 February, 2011, 17:10:56
Location: ¿¿¿
Posts: 1888


Total Post Ratings: +110

View Profile WWW
« Reply #89 on: 07 March, 2011, 08:42:40 »
0

I'm trying to explain that the two commands are of roughly equal speed when the use of the Full and Normal commands are taken into account, and constantly switching between the two clock speeds so as not to slow down the rest of the program probably isn't what the compatability mode was meant for. Add to that the time of having to store to both buffers, and the advantages of DispGraphr kinda get negated.
That said, if the program is intended for a 6MHz calc, then use r.
« Last Edit: 07 March, 2011, 08:46:12 by Freyaday » Logged

In other news, Frey continues kicking unprecedented levels of ass.
Proud member of LF#N--Lolis For #9678B6 Names


Beware the Bitulator! ,.,./`My Artwork!
Pages: 1 ... 4 5 [6] 7 8   Go Up
  Print  
 
Jump to:  

Powered by EzPortal
Powered by MySQL Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Powered by PHP
Page created in 0.402 seconds with 30 queries.
Skin by DJ Omnimaga edited from SMF default theme with the help of tr1p1ea.
All programs, games and songs avaliable on this website are property of their respective owners.
Best viewed in Opera, Firefox, Chrome and Safari with a resolution of 1024x768 or above.