<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:st1="urn:schemas-microsoft-com:office:smarttags" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
 name="PersonName"/>
<!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
<style>
<!--
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:Arial;
        color:windowtext;}
@page Section1
        {size:612.0pt 792.0pt;
        margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.Section1
        {page:Section1;}
-->
</style>

</head>

<body lang=FR-CA link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>Hi!<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>I would like to share with members of the simh
community some little improvements to obtain an executable code of simh that
runs faster.  My personnal results gave me an improvement of passing from 17.2
VUPS to 25.0 VUPS on the same machine – about 45% execution speed
improvement.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>First, I did optimise the gcc command line in the
makefile, to permit to the compiler to use the newer instructions from the host
machine’s CPU.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>By default, GCC targets as a machine architecture a
486 type CPU (of course, in the intel world.  This argument cannot be used for
a AMD cpu, but GCC supports various –march arguments, this supports AMD64
instructions, with the proper parameter).<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>But that default does not permit the use of MMX
instructions!, so I did various simulator performance tests while varying the –march
parameter of GCC.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>The best results were attained by specifying –march=pentium2,
and also –mfpmath=387  (so floating point instructions are executed in
machine code instead of by floating point emulation).<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>I believe those two parameters are almost universally
supported, as Pentium I class machines are now quite obsolete, especially for
running a simh instance.  Those parameters did improve execution performance by
10% on my setup, with is hosted by a 2.4GHz quad core CPU, that has 4MB of
cache per core, 1066MHz FSB speed, running knoppix linux 5.1 as the host OS.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>Another parameter I did change on the GCC command
line was to replace the Optimisation level (set to 2) –O2<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>To the level 9.  (-O9)  This also gave me some
performance improvements.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>The complete line defining CC in my modified makefile
is:<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>CC = gcc -march=pentium2  -mfpmath=387 -std=c99 -O9
-U__STRICT_ANSI__ -g -lm -lrt $(OS_CCDEFS) -I .<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>(also, note the adding of –lrt, to make use of
the real time library, and thus eliminates a compile error).<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>After that, I did compile simh to include the
profiling code (by adding –pg on the gcc command line).  After studying
the profiling, I saw that the functions that reads and writes to RAM and ROM
are the ones that are executed 50% of the time.  Since calling a function adds
the overhead of pushing and popping all registers of the host CPU, this slows
down significantly the running of the simulator.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>How can we get rid of this execution overhead?  And at
the same time keeping the structure and modularity of the source code?<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>The solution is: by declaring those functions as
inline!<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>So, I did modify the file vax_cpu.c like this:<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>inline extern int32 Read (uint32 va, int32 lnt, int32
acc);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>inline extern void Write (uint32 va, int32 val, int32
lnt, int32 acc);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>inline extern int32 ReadB (uint32 pa);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>inline extern void WriteB (uint32 pa, int32 val);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>inline extern int32 ReadLP (uint32 pa);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>inline extern int32 Test (uint32 va, int32 acc, int32
*status);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>(I just added the statement inline in front of the
declaration of those 6 functions), and on the front of those functions.)<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>The diff between my modified vax_cpu.c and the
official one in simh37-3.zip gives:<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>353,358c353,358<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>< extern int32 Read (uint32 va, int32 lnt, int32
acc);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>< extern void Write (uint32 va, int32 val, int32
lnt, int32 acc);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>< extern int32 ReadB (uint32 pa);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>< extern void WriteB (uint32 pa, int32 val);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>< extern int32 ReadLP (uint32 pa);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>< extern int32 Test (uint32 va, int32 acc, int32
*status);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>---<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>> inline extern int32 Read (uint32 va, int32 lnt,
int32 acc);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>> inline extern void Write (uint32 va, int32 val,
int32 lnt, int32 acc);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>> inline extern int32 ReadB (uint32 pa);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>> inline extern void WriteB (uint32 pa, int32
val);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>> inline extern int32 ReadLP (uint32 pa);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>> inline extern int32 Test (uint32 va, int32 acc,
int32 *status);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>379c379<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>< int32 get_istr (int32 lnt, int32 acc);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>---<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>> inline int32 get_istr (int32 lnt, int32 acc);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>2922c2922<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>< int32 get_istr (int32 lnt, int32 acc)<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>---<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>> inline int32 get_istr (int32 lnt, int32 acc)<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>You will notice the adding of the various inline
statements.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>This resulted in about 35% speed improvement!  Some
more profiling and inlining can be done, but I did not push that track further.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>One thing to say, is that declaring inline a function
gets the executable code recopied at every place this function is called.  This
makes the executable code of the function not reusable, but eliminated the
overhead of the function call.  The net result is that the size of the
executable code of SIMH passed from about 800KB to 1.4MB, on the intel CPU
architecture.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>To benefit of this speed improvement, you need to use
a host machine that can cache all of this executable code in the Level 2 cache
of the host CPU.  Since an intel quad core has 4MB L2 cache, this is not a
problem in my setup, but it can be for those who own CPUs with 1MB L2 cache.  <o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>Also, just to give a little glimpse of my setup, I am
running 6 instances of simh-vax that forms two VMS clusters, <o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>Running VMS 5.5-2.  and sharing about 30 disks total,
with an INGRES VMS database and an ORACLE VMS client to an external ORACLE
server.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>Those 6 instances are running on two desktops (3
instances of simh per desktop), each having a quad core CPU with 3 ethernet
cards.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>This is the output of a show cluster from the main
cluster (5 instances of simh):<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span lang=EN-CA
style='font-size:8.0pt;font-family:"Courier New"'>View of Cluster from system
ID 1042  node: REGIE           11-JAN-2008 14:10:33<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span lang=EN-CA
style='font-size:8.0pt;font-family:"Courier New"'>+-------------------+---------+<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span lang=EN-CA
style='font-size:8.0pt;font-family:"Courier New"'>|      SYSTEMS      | MEMBERS
|<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span lang=EN-CA
style='font-size:8.0pt;font-family:"Courier New"'>+--------+----------+---------+<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span lang=EN-CA
style='font-size:8.0pt;font-family:"Courier New"'>|  NODE  | SOFTWARE |  STATUS
|<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span lang=EN-CA
style='font-size:8.0pt;font-family:"Courier New"'>+--------+----------+---------+<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span lang=EN-CA
style='font-size:8.0pt;font-family:"Courier New"'>| REGIE  | VMS V5.5 | MEMBER 
|<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span lang=EN-CA
style='font-size:8.0pt;font-family:"Courier New"'>| EXTRA  | VMS V5.5 | MEMBER 
|<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span lang=EN-CA
style='font-size:8.0pt;font-family:"Courier New"'>| AGENT  | VMS V5.5 | MEMBER 
|<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span lang=EN-CA
style='font-size:8.0pt;font-family:"Courier New"'>| LIVRE  | VMS V5.5 | MEMBER 
|<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span lang=EN-CA
style='font-size:8.0pt;font-family:"Courier New"'>| CYCLE  | VMS V5.5 | MEMBER 
|<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span lang=EN-CA
style='font-size:8.0pt;font-family:"Courier New"'>+--------+----------+---------+<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>All of this to say that I praise the authors of the
very good code that was written for simh!<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>I would also appreciate any ideas to further improve
execution speed of simh.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'>Very best regards,<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-CA style='font-size:
10.0pt;font-family:Arial'><br>
<st1:PersonName ProductID="Francois Boucher" w:st="on">Francois Boucher</st1:PersonName>
ing.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Université du Québec à Montréal.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>

</div>

</body>

</html>