ACE_Tuning

advertisement
ACE_Tuning.DOC
==============
1. Overview
----------This document describes how to make ACE executable files faster and
shorter.
The complete package consists of the following files:
o ACE_Tuning.doc:
o Test.b:
o Test_bas:
o
o
o
o
Test_bas_phx:
bas_phx:
bas_so_phx:
exe_timer.b:
o exe_timer:
This file.
Test source code.
Source compiled using the "bas2" script supplied
with ACE.
Source compiled with a new script discussed later.
New script for compiling ACE programs.
Another new script file.
Measures the execution time of a shell program
(ACE source code.)
The executable.
At least ACE 2.37 is required to run the scripts.
2. Files needed
--------------You need the following files which can all be found on the Aminet:
o PhxAss and PhxLnk:
o SuperOptimizer:
New optimizing assembler and linker.
A global peephole optimizer for ACE
3. Installation
--------------Just copy "PhxAss", "PhxLnk", ACE's "SuperOptimizer", "bas_so_phx", and
"bas_phx"" to the "ACE:bin" drawer.
4. Usage
-------As "bas_so_phx" is a shell script, it can only be run from the CLI.
1
Open a new CLI window and type in the following line:
Path ACE:bin add
(This ensures that all files can be run easily.)
2
Call the script like this:
bas_so_phx [ACE options] source [additional object file(s)]
(The script can be used like the "bas2" script supplied with ACE
2.37.)
3
The executable file has been built.
5. Preparing your source code
----------------------------PhxAss does not allow characters like '%' and '$' in "symbols". So you
must
not use them in your sub routine names. Use the STRING, SINGLE, ...
directives
instead. Notice that some header files will also need to be altered, for
instance "WBArgs.h".
Example:
Replace this code
DECLARE SUB Trim$(a$)
{... main program ...}
SUB Trim$(a$)
t$=""
STRING x SIZE 2
FOR q% = 1 TO LEN(a$)
x = MID$(a$,q%,1)
if ((ASC(x) AND 127) > 32) THEN
t$ = t$ + x
END IF
NEXT q%
Trim$ = t$
END SUB
by this code:
DECLARE SUB STRING Trim(a$)
<-- Changed
{... main program ...}
SUB STRING Trim(a$)
t$=""
STRING x SIZE 2
FOR q% = 1 TO LEN(a$)
x = MID$(a$,q%,1)
if ((ASC(x) AND 127) > 32) THEN
t$ = t$ + x
END IF
NEXT q%
Trim = t$
END SUB
<-- Changed
<-- Changed
6. Comparison with the "bas" script
----------------------------------I compiled the "test.b" sample source on my Amiga 4000/040 (25 MHz) and
got
the following results:
1
2
3
4
5
6
7
Script used
Executable file size in bytes
Execution time in ticks
bas
bas_phx
bas_snma
bas_so_snma
bas_sophxlnk
bas_so
bas_so_phx
3
2
2
2
2
3
2
44
36
50
51
44
45
38
328
860
868
864
864
324
856
(1 tick = 1/50 second.)
Notes
----1
2
3
4
5
6
7
Generic "bas2" script supplied with ACE
Uses Phx Assembler and Linker
Uses the SNMA assembler and Phx Linker
Uses ACE's SuperOptimizer (level 11), SNMA assembler, and Phx Linker
Uses ACE's SuperOptimizer (level 11) and Phx Linker
Uses ACE's SuperOptimizer (level 11)
Uses ACE's SuperOptimizer (level 11) and Phx Ass/Lnk
All tests were done with ACE's internal optimizations turned on and
using the newest SuperOptimizer available.
You see that the Phx Linker decreases the executable's size and that the
Phx Assembler makes the executable considerably faster. Genarally, the
resulting executable files are up to 25 % smaller and faster.
If you use ACE's SuperOptimizer in conjunction with the Phx Assembler,
the
executable will be significantly smaller, especially if you compile a
large
source file. However, the program will be a little bit slower in this
case.
I recommend to use the "bas_so_phx" script.
You might want to say that ACE executables compiled using the bas_phx
script
are still too slow (SAS C 6.5.0 runs the test program in <16 ticks
without
using register variables, for instance.) Consider Microsoft's commercial
Visual
Basic 4.0 for Windows 95 running on a 60 MHz Pentium processor (at about
three
times faster than my Amiga 4000.) It takess 27.5 ticks to run the sample
test
program!
7. Using the "exe_timer" utility
-------------------------------This program measures the execution time of a program. It has to be run
from a shell using a command line similar to this one:
exe_timer program
The execution time is calculated in ticks (1/50 second.)
8. Suggestions
-------------To make your executables even faster, replace "PhxAss" and "PhxLnk" by
another assembler / linker or use another optimizer.
9. Distribution
--------------This package may be freely distributed and used for any program you want
to
use it for.
10. Final note
-------------After had written the scripts, I noticed that the new AIDE 2.0 also uses
the
Phx Assembler and Linker. Use the new AIDE if you don't like script files
at all.
11. Author
---------Write suggestions or bug reports to:
Frank Reibold
Ottberger Weg 13
31737 Rinteln
GERMANY
Download