Index of /misc/pentium-switch

[ICO]NameLast modifiedSizeDescription

[PARENTDIR]Parent Directory  -  
[TXT]case1.c1995-12-21 19:25 564  
[   ]test11995-12-21 19:25 676  
[   ]case1.S1995-12-21 19:25 826  
[   ]table.gz1995-12-21 19:39 6.9K 
[   ]graph.ps.gz1995-12-21 19:25 8.1K 
[   ]switch-on-pentium1995-12-08 18:26 9.4K 

The Pentium processor exhibits interesting behaviour for code that gcc
(and probably other compilers) produce for the switch statement.

switch-on-pentium contains some postings about this effect

table.gz contains some timings for various arrangements of the swicth.
	a line like
	11.48   00001099        0000109c

	means that the code ends at 1099 (i.e., the first byte after
	the code resides there, the jump table starts at 109c, and
	this arrangement takes 11.48s (or an average 22.96 CPU cycles
	(11.48 bus cycles) per switch).
graph.ps.gz displays the data from table graphically. The diameter of
	the circles is proportional to the time taken for the
	arrangement.
case1.c is the benchmark in C code (measuring 100,000,000 switches)
case1.S is the modified gcc assembly output (66,666,660 switches)
test1	is a script that produced table on my P133

You can find a description of a cache organization that has this
problem at http://www.amd.com/K6/k6docs/k6ds/cache.htm#332732. The
Pentium and the K6 apparently behave in the same way in this respect.
The P6 (Pentium Pro, Pentium II, Pentium III, Celeron, Xeon) and the
Athlon apparently do not have this problem (unless the data is
written).  The various 486s, and the Cyrix 6x86 and 6x86MX (aka M-II)
do not have this problem because they have a unified cache.

- anton
--
M. Anton Ertl                    Some things have to be seen to be believed
anton@mips.complang.tuwien.ac.at Most things have to be believed to be seen
http://www.complang.tuwien.ac.at/anton/home.html