179
FB4-Elektrotechnik und Informatik RST Labor Benchmark SPARC vs. x86 Raphael Schlameuß (100753) Axel Schmidt (94416) 15. Januar 2007 betreut durch Prof. Dr. Thomas Risse

Benchmark SPARC vs. x86 - · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

Embed Size (px)

Citation preview

Page 1: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

FB4-Elektrotechnik und Informatik

RST Labor

Benchmark

SPARC vs. x86

Raphael Schlameuß (100753)

Axel Schmidt (94416)

15. Januar 2007

betreut durch

Prof. Dr. Thomas Risse

Page 2: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

Inhaltsverzeichnis

1 Einleitung 4

2 Projektziel 5

3 Grundlagen 6

3.1 Sun UltraSPARC IIi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63.1.1 Prozessor Sun UltraSPARC IIi . . . . . . . . . . . . . . . . . . . . . . . . . 63.1.2 Architektur UltraSPARC IIi . . . . . . . . . . . . . . . . . . . . . . . . . . 73.1.3 Prozessor Pipeline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83.1.4 Load/Store Unit (LSU) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103.1.5 Prefetch and Dispatch Unit (PDU) . . . . . . . . . . . . . . . . . . . . . . . 103.1.6 Integer Execution Unit (IEU) . . . . . . . . . . . . . . . . . . . . . . . . . . 103.1.7 Floating-Point Unit (FPU) . . . . . . . . . . . . . . . . . . . . . . . . . . . 103.1.8 Graphics Unit (GRU) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113.1.9 Caches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113.1.10 IO Memory Management Unit (IOM) . . . . . . . . . . . . . . . . . . . . . 123.1.11 PCI Bus Module (PBM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123.1.12 Memory Controller Unit (MCU) . . . . . . . . . . . . . . . . . . . . . . . . 143.1.13 Memory Management Unit (MMU) . . . . . . . . . . . . . . . . . . . . . . 15

3.2 Intel x86 Pentium II . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173.2.1 Prozessor Intel Pentium II . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173.2.2 Mikro-Architektur . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173.2.3 Prozessor-Pipeline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173.2.4 Fetch/Decode-Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183.2.5 Dispatch/Execute-Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193.2.6 Floating Point Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213.2.7 MMX Execution Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213.2.8 Retire-Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223.2.9 Bus-Interface-Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233.2.10 Caches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233.2.11 Write Buffers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

3.3 Betriebssystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253.4 Benchmarkprogramme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

3.4.1 Whetstone . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263.4.2 Dhrystone . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273.4.3 LINPACK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

Version 1.1 2

Page 3: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

Inhaltsverzeichnis

3.4.4 LLCbench . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

4 Realisierung 33

4.1 Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334.1.1 SPARC Rechner . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334.1.2 x86 Rechner . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

4.2 Installation Betriebssystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344.3 Installation benotigter Programme . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

4.3.1 ccache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404.3.2 gcc-4.0.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404.3.3 Librarys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404.3.4 Whetstone . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414.3.5 Dhrystone . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424.3.6 1000s/100d . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434.3.7 LLCbench . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

5 Erwartete Ergebnisse 47

6 Versuchsdurchfuhrung und Auswertung 48

6.1 Compiler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 486.1.1 Maschinenunabhangige Optimierung . . . . . . . . . . . . . . . . . . . . . . 486.1.2 Maschinenspezifische Optimierung . . . . . . . . . . . . . . . . . . . . . . . 486.1.3 Unterschiede gcc-3.4.5 und gcc-4.0.2 . . . . . . . . . . . . . . . . . . . . . . 49

6.2 Whetstone und Dhrystone . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 496.3 1000s und 1000d . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 556.4 BLASBench . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 576.5 CacheBench . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64

7 Zusammenfassung 69

Literaturverzeichnis 71

8 Anhang 73

8.1 Kernel-Config x86 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 738.2 Kernel-Config SPARC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 808.3 Source-Code Whetstone-Benchmark . . . . . . . . . . . . . . . . . . . . . . . . . . 85

8.3.1 whetstone.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 858.4 Source-Code Dhrystone-Benchmark . . . . . . . . . . . . . . . . . . . . . . . . . . . 94

8.4.1 dhry.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 948.4.2 dhry 1.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1038.4.3 dhry 2.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111

8.5 Source-Code 1000s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1158.5.1 1000s.f . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115

8.6 Source-Code LLCBench . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1318.6.1 LLCBench . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1318.6.2 BlasBench . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1398.6.3 CacheBench . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159

Version 1.1 3

Page 4: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

1 Einleitung

In der angewandten Informatik ist der Benchmark eine standardisierte Metrik, nach derdie komplexe Leistung zweier vergleichbarer Programme oder Computer anhand einerAnzahl einzelner Maße objektiv gemessen wird und diese nach bestimmten Kriterienverglichen und bewertet werden.1

Benchmarking ist ein schwieriges Thema, vor allem im Bereich der Informatik, daher wird in diesemProjekt versucht, den objektiven Leistungsvergleich zweier vollig unterschiedlicher Prozessorsyste-me zu erreichen. Die durchgefuhrten Benchmarks sind Hardware bezogen und vergleichbar mit dentraditionellen Benchmarks, z.B. SPEC, da Massenspeicher und Grafikleistung nicht mit einbezogenwerden.

Um geeignete Benchmarks durchfuhren zu konnen, ist die richtige Auswahl des Betriebssystemssowie die eingesetzten Benchmark-Programme besonders wichtig.

1Zitat aus Wikipedia, Quelle: http://de.wikipedia.org/wiki/Benchmark

Version 1.1 4

Page 5: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

2 Projektziel

Ziel dieses Projektes ist der moglichst objektive Vergleich zweier Computersysteme mit ungefahrgleicher Peripherie aber mit unterschiedlichen Prozessor-Architekturen.

Dieser Vergleich wird mit Hilfe von Benchmark-Programmen gefertigt, die frei erhaltlich (OpenSource) und Plattform unabhangig sind.

Um dieses Ziel zu erreichen, muss speziell der Einsatz von unterschiedlichen Betriebssystemen, derVor- und Nachteil von Compilern und deren Unterstutzung von Prozessor-Architekturen (spezielleFeatures) diskutiert werden.

Die Hauptkomponente eines Rechnersystems ist dabei der Prozessor. Deswegen werden speziellBenchmark-Programme eingesetzt, die die Leistung des Prozessors ermitteln. Es ist nicht vorgese-hen, die Leistung des Gesamtsystems zu bestimmen.

Version 1.1 5

Page 6: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

3 Grundlagen

Nachfolgend werden die einzelnen in den Benchmarks verwendeten Architekturen, speziell die Pro-zessoren und deren Funktionsweisen und Spezifikationen naher erlautert.

3.1 Sun UltraSPARC IIi

3.1.1 Prozessor Sun UltraSPARC IIi

Der Sun UltraSPARC IIi Prozessor basiert auf der Sun SPARC-Architektur in Version V9 undist ein RISC-Prozessor. 1995 wurde die ursprungliche 32-Bit-Architektur auf 64-Bit erweitert undunter dem Namen UltraSPARC vermarktet. Diese Architektur hat neben zusatzlichen Einheiteneine tiefere Pipeline und einige einfache SIMD-Befehle (Visual Instruction Set VIS). Der Ultrasparc-Standard hat bisher vier Hauptversionen, die derzeit aktuelle Version ist UltraSPARC T1.

Abbildung 3.1: Sun SPARC Familie

Herausragende Eigenschaften der Architektur ist ein Registerfile, das ursprunglich aus 128 32-Bit-Registern bestand. Die CPU kann nur auf einen Teil davon, normalerweise 32, direkt zugreifen.24 davon sieht die CPU in einem Fenster, das per Software verschoben werden kann. Dadurchkonnen Argumente und Ergebnisse von Unterprogrammen ohne Umkopieren von Registern durchVerschieben des Fensters ubergeben werden1.

1siehe auch Quelle: http://www.weblearn.hs-bremen.de/risse/RST/docs/RST.pdf Abschnitt 3.2

Version 1.1 6

Page 7: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

3.1 Sun UltraSPARC IIi

Die Fließkommaeinheit kann 32 32-Bit-Register mit einfacher Genauigkeit, 16 64-Bit-Register mitdoppelter Genauigkeit oder 8 128-Bit-Register mit vierfacher Genauigkeit verwenden2.

3.1.2 Architektur UltraSPARC IIi

(SUN97) Nachfolgend ist zur Ubersicht ein Blockdiagramm des UltraSPARC IIi Prozessors mitden einzelnen Komponenten dargestellt:

• PCI Interfaceunabhangig vom Prozessor, mit 132 MHz. intern und 66 MHz, oder 33 MHz. extern getaktet

• PCI Bus Modul (PBM)die komplette Logik zur Ansteuerung des PCI Bus ist in die CPU integriert

• PCI I/O Memory Management Unit (IOM)mit 16 Eintrage fur eingehende I/O

• External (E-Cache) cache control unit (ECU)fur die Ansteuerung von bis zu 2048 kByte L2-Caches

• Memory controller unit (MCU)sie steuert das 144 Bit breite DRAM System und das UPA64S Interface

• 16-Kilobyte instruction cache (I-Cache)

• 16-Kilobyte data cache (D-Cache)

• Prefetch, branch und dispatch Unit (PDU)sie beinhaltet die grouping logic und den instruction buffer

• je ein Instruction- und Data Translation-Lookaside Buffer (TLB) mit 64 Eintragen

• je eine Integer Execution Unit (ECU), Floating Point Unit (FPU) und Graphics Unit (GRU)

• Load buffer und Store buffer Unit (LSU)

2siehe auch Quelle: http://www.computerbase.de/lexikon/Sun_SPARC

Version 1.1 7

Page 8: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

3.1 Sun UltraSPARC IIi

Abbildung 3.2: Blockdiagramm Prozessor Ultra Sparc IIi

3.1.3 Prozessor Pipeline

(SUN97) Der Ultra Sparc IIi Prozessor besitzt eine 9 stufige Pipeline. Die meisten Befehle durch-laufen die Pipeline exakt in 9 Stufen. Nachfolgend ist die Pipeline vereinfacht dargestellt:

Abbildung 3.3: Blockdiagramm 9-stufige Pipeline (vereinfacht)

Um die Symmetrie der Pipeline zu gewahrleisten sind bei der Integer Pipeline zusatzlich 3 Stufen(N1, N2, N3) hinzugefugt worden. Durch die Symmetrie der Integer- und Floating-Point Pipelineist es nicht notwendig eine eigenstandige Floating-Point Queue zu integrieren; zusatzlich wird dieSynchronisation und die Ausnahmebehandlung (z.B. Traps oder Fehler) der Pipeline vereinfacht.

• Stufe 1: Fetch (F) Stufe

• Stufe 2: Decode (D) Stufe

Version 1.1 8

Page 9: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

3.1 Sun UltraSPARC IIi

• Stufe 3: Grouping (G) Stufe

• Stufe 4: Integer Execution (E) StufeHier findet die Berechnung der beiden Integer ALUs statt. Die Daten werden aus dem IntegerRegister File gelesen, die Berechnung findet statt und das Ergebnis kann anderen Instruktio-nen mittels einem Bypass im nachsten Takt zur Verfugung gestellt werden. Parallel werdendie virtuellen Speicher Adressen fur Speicherzugriffe sowie die branch prediction (mit derALU) berechnet.

Stufe 4: FGU3 Register (R) StufeIn dieser Stufe wird auf die Floating-Point Register zugegriffen und die zu bearbeitendeInstruktion wird weiter dekodiert. Die FGU Control Unit nutzt dabei die fur die Instruktionzugehorigen Bypass.

• Stufe 5: Cache Access (C) StufeDie in der E-Stufe berechnete virtuelle Adresse wird gleichzeitig an das Tag-RAM und an dieMMU gesendet. Die MMU bestimmt die physikalische Adresse, wahrend das Tag-RAM fest-stellt, ob ein ein Cache-Hit oder Cache-Miss (bei einer Load/Store-Operation) im D-Cachevorliegt. Bei einem Load-Befehl wird auf das Daten-Array zugegriffen, um die Daten, abhan-gig von der Instruktion, der Pipeline so schnell wie moglich zur Verfugung zu stellen. DasErgebnis der branch prediction wird zur PDU (Prefetch and Dispatch Unit) gesendet. DiePDU uberpruft, ob die Vorhersage korrekt ist. Bei falscher Vorhersage werden die fruherenInstruktionen in der Pipeline zuruckgesetzt und das korrekte Ergebnis geladen.

Stufe 5: FGU X1 StufeFloating-Point- und Grafikbefehle werden ausgefuhrt. Fur Befehle, die in einem Takt ausge-fuhrt werden, endet die Execution Phase.

• Stufe 6: N1 StufeIn dieser Stufe werden D-Cache (miss/hit) oder TLB (miss/hit) erkannt. Bei einem Loadmiss aus dem D-Cache wird der Datensatz in den Load-Buffer geladen; bei einem TLB misswird ein Trap ausgelost und die Adresse uber eine separate Softwareroutine bestimmt.Bei einem Store-Befehl wird die physikalische Adresse an den Store Buffer gesendet.

Stufe 6: FGU X2 StufeWeitere Abarbeitung der meisten Befehle.

• Stufe 7: N2 StufeDie meisten Floating-Point Instruktionen sind hier beendet. Die Daten konnen nach dieserStufe mittels Bypass anderen Stufen zur Verfugung gestellt oder in den Store Buffer ubertra-gen werden. Alle Daten, die in der N1 Stufe in den Store Buffer ubertragen wurden, werdenuber den Store Buffer weiter abgearbeitet.

Stufe 7: FGU X3 StufeWeitere Abarbeitung der meisten Befehle.

3Floating-Point und Graphics Unit

Version 1.1 9

Page 10: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

3.1 Sun UltraSPARC IIi

• Stufe 8: N3 StufeIn dieser Stufe werden nur Traps behandelt.

• Stufe 9: Write (W) Stufe

3.1.4 Load/Store Unit (LSU)

(SUN97) Die Load- und Store Unit ist verantwortlich fur das Generieren der virtuellen Adressenfur alle Load und Stores, fur den Zugriff auf den Daten Cache und das Entkoppeln der Store undLoads durch die Load und Store Buffer.Es kann nur ein Load oder ein Store pro Takt abgearbeitet werden.

3.1.5 Prefetch and Dispatch Unit (PDU)

(SUN97) Die PDU ladt bis zu 12 Instruktionen in den Instruction Buffer und stellt die Befehleder Pipeline bereit. Die Instruktionen (und abhangige Daten) konnen aus allen Speicherhierarchien(I-Cache, D-Cache und Hauptspeicher) geladen werden.Die Abarbeitung von conditional branches (branch prediction4) ist in Hardware implementiert,basierend auf einer 2 Bit History der Sprunge.

3.1.6 Integer Execution Unit (IEU)

(SUN97) Die Integer Execution Unit (IEU) beinhaltet folgende Komponenten:

• zwei arithmetic logical units (ALU)

• einen multi-cycle integer Multiplier

• einen multi-cycle integer Divider

• acht register windows

• vier Satze von globalen Registern (normal, alternate, MMU and interrupt)

• ein Trap Register

Als besonderes unterstutzt der UltraSPARC IIi Prozessor einen Trap Level mehr, als in der SPARCVersion 9 Spezifikation vorgesehen.

3.1.7 Floating-Point Unit (FPU)

(SUN97) Durch die Aufteilung der beiden Execution Units in der Floating-Point-Unit ist der Ul-traSPARC IIi in der Lage, zwei Floating-Point Instruktionen pro Takt auszufuhren. Die Quelldatenund Ergebnisse werden in einem Register-File (32 Eintrage) gespeichert, wobei jeder Eintrag 32-bitoder 64-bit groß sein kann.

Die meisten Floating-Point-Operationen sind komplett pipelined (eine Ausgabe pro Takt), besitzeneine Latenzzeit von drei und werden nicht von der Prazision der Operanden beeinflusst (gleiche

4siehe auch http://www.weblearn.hs-bremen.de/risse/RST/docs/RST.pdf Abschnitt 5.4

Version 1.1 10

Page 11: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

3.1 Sun UltraSPARC IIi

Latenzzeit fur einfache oder doppelte Prazision).Als einzige Ausnahme werden die Divide- oder Wurzeloperationen dagegen nicht in der Pipelineausgefuhrt. Sie dauern 12 Takte (einfache Prazision) oder 22 Takte (doppelte Prazision).

3.1.8 Graphics Unit (GRU)

(SUN97) Mit dem UltraSPARC IIi Prozessor wurden spezielle Befehle fur die Audio, Video undGrafikbearbeitung eingefuhrt. Sun nennt diese speziellen Befehle VIS (VIS Instruction Set). DieseBefehle unterstutzen hardwaremaßig die Bearbeitung von 2D und 3D Images und Videos. Zusatzlichsind Befehle fur die Komprimierung von Images, Befehle fur die Audio-Bearbeitung und Befehlefur optimierte Speicherzugriffe vorhanden.

3.1.9 Caches

(SUN97) Nachfolgend werden I-Cache, D-Cache, E-Cache und die External Cache Control Unit(ECU) beschrieben.

Instruction Cache (I-cache)

Der Instruction Cache ist 16 KByte groß und in zwei Sets mit jeweils 32 Byte Blocken assoziativunterteilt.

Data Cache (D-cache)

Der Ultra Sparc IIi Prozessor besitzt einen 16 KByte großen direct mapped L1-Cache, organisiertin 512 Lines mit jeweils zwei 16 Byte Blocken. Der Cache kann per Software auf write-throughnon-allocating Cache umgeschaltet werden. Bei einem Cache miss werden automatisch 16 Bytesaus dem Speicher gelesen.

E-Cache (L2-Cache)

Der UltraSPARC IIi Prozessor kann 256 kByte bis 2048 kByte direct-mapped, allocating und wri-teback L2-Cache verwalten. Die Cache-Line Große betragt dabei 64 Bytes.

Der L2-Cache kann dabei im Pipelined Mode oder Register-Latched Mode betrieben werden:

1. 2-2-2 (Pipelined) modeIn dieser Konfiguration wird auf den E-Cache mit halbem Prozessortakt zugegriffen.Das 2-2-2 bedeutet dabei:2 zwei Takte um die Adresse zu senden2 zwei Takte fur den Zugriff auf das SRAM array2 zwei benotigte Takte, um das Ergebnis aus dem E-Cache zuruckzugeben

2. 2-2 (Register-Latched) modeIn dieser Konfiguration wird ebenfalls auf den E-Cache mit halbem Prozessortakt zugegriffen.Das 2-2 bedeutet dabei:

Version 1.1 11

Page 12: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

3.1 Sun UltraSPARC IIi

2 zwei Takte um die Adresse zu senden2 zwei Takte fur den Zugriff und Ruckgabe des Wertes aus dem E-Cache

Der Vorteil des Register Latched Modes ist ein schneller Zugriff auf den Cache Speicher, sofern derL2-Cache schnell genug ist.

Die Betriebsart des E-Caches ist abhangig von dem verwendetem CPU-Modul (Cache-Mode ist festverdrahtet), da es dem Hersteller der CPU-Module uberlassen ist, welche Art von Cache-Bausteineneingesetzt werden.

External Cache Control Unit (ECU)

Die External Cache Control Unit ist fur die komplette Kommunikation mit dem L2-Cache zustan-dig:

• I-Cache und D-Cache misses:

– Data CacheBei einem Load miss aus dem L2-Cache werden zwei aufeinander folgende 8 Bytes(also 16 Bytes) in den Data Cache geladen. Schreiben in den L2-Cache erfolgt mittelswritethrough und ist komplett pipelined.

– Instruction Cache:Bei einem miss eines Instruction Prefetch werden vier aufeinander folgende 8 Bytes ausdem L2-Cache gelesen und in den Instruction Cache gespeichert.

• DMA:Die ECU unterstutzt den DMA Transfer zwischen dem L2-Cache und dem Hauptspeicher.

• Block Load / Block Store:Die ECU ermoglicht mit Block Load- und Store das Ubertragen von 64 Byte Daten aus demHauptspeicher oder L2-Cache in die Floating Point Register der CPU.

3.1.10 IO Memory Management Unit (IOM)

(SUN97) Bei einem Lese- oder Schreibzugriff auf ein PCI Device muss die IO Memory ManagementUnit die 32-bit DVMA (Direct Virtual Memory Access) Adressen auf 34-bit physikalische Adressenumwandeln; sie benutzt dabei einen voll assoziativen TLB (Translation Lookaside Buffer) mit 16Eintragen. Ist der Eintrag im TLB nicht enthalten, wird eine Anfrage an den TSB (TranslationStorage Buffer), der im Speicher liegt, durchgefuhrt.

3.1.11 PCI Bus Module (PBM)

(SUN97) Das PCI Bus Module steuert den 32-Bit PCI Bus und ist fur 16, 32 oder 64-byte Trans-fers optimiert. Das Bus-Protokoll nutzt die PCI Bus Spezifikation 2.1 und unterstutzt bis zu 4 PCIBus Master. Der Bus unterstutzt Taktraten bis zu 66 MHz, typischerweise lauft der PCI Bus auf

Version 1.1 12

Page 13: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

3.1 Sun UltraSPARC IIi

33MHz oder 66 MHz.

Der Zugriff von der CPU auf den PCI Adressraum ist nicht cacheable, koharent DMA wird aberunterstutzt, das bedeutet, dass alle Schreib- und Leseoperationen zwischen Speicher und DMAdirekt aufeinander (zusammenhangend) erfolgen.

In Abbildung 3.4 ist der PCI Daten Pfad als Blockdiagramm dargestellt:

Abbildung 3.4: Blockdiagramm PCI Daten Pfad

Version 1.1 13

Page 14: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

3.1 Sun UltraSPARC IIi

3.1.12 Memory Controller Unit (MCU)

(SUN97) Alle Transaktionen in den Hauptspeicher oder zu dem UPA64S Bus werden von der MCUgesteuert. Die Taktrate fur den UPA64S Bus betragt 1/3 des Prozessortaktes, wahrend die Taktratedes Speichers frei programmierbar ist. Typische Taktraten fur den Speicher sind dabei 1/3, 1/4oder 1/5 des Prozessortaktes.Transceiver sind uber einen 64 Bit breiten Datenbus an den Prozessor angebunden, wahrend derHauptspeicher uber einen 128 Bit breiten Datenbus angebunden ist. Der Prozessor ist somit in derLage, doppelt so schnell auf den Speicher zuzugreifen, indem die Transceiver die Speicherbankegeeignet schalten.

Abbildung 3.5: Blockdiagramm

Version 1.1 14

Page 15: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

3.1 Sun UltraSPARC IIi

3.1.13 Memory Management Unit (MMU)

(SUN97) Der Ultra SparcIIi Prozessor unterstutzt vier Page Sizes: 8 kB, 64 kB, 512 Kb und 4 MB.In Abbildung 3.6 sind alle vier moglichen Adressumsetzungen dargestellt:

Abbildung 3.6: Virtuelle zu physikalische Address Translation fur alle Seitengroßen

Der Sun Ultra SparcIIi Prozessor kann nur 44-Bit virtuellen Adressraum verwalten. Dieser virtuelleAdressraum wird im unteren Bereich (Bits 45..64 fest auf 0) und im oberen Bereich (Bits 45..64fest auf 1) des 64-Bit virtuellen Adressraums angelegt. Mit dieser Methode wird doppelt so vielvirtueller Speicher adressiert, als normalerweise mit nur 44-Bit moglich sind (siehe Abbildung 3.7).

Durch diese Form der Adressierung ergibt sich in der Mitte des 64-Bit virtuellen Adressraums einBereich, der als Out of Range, also als ungultig, markiert ist. Fur die Adressierung des physikali-schen Speichers erfolgt eine Adressumsetzung von einer 64-Bit virtuellen Adresse auf eine 41-Bitphysikalische Adresse. Wahrend jedes Prozessortaktes findet eine virtuelle zu physikalische Adres-sumsetzung fur den Instruktionenspeicher und dem Datenspeicher statt.

Version 1.1 15

Page 16: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

3.1 Sun UltraSPARC IIi

Abbildung 3.7: Virtuelle Speicheraufteilung

Die Software oder das Betriebssystem greift auf den Speicher uber eine Software Translation Tablezu, die im Speicher liegt. Fur den schnelleren Zugriff auf die Software Translation Table existierenauf dem Prozessor Hardware Translation Lookaside Buffers (iTLB und dTLB). Der iTLB wird furInstruktionen verwendet und der dTLB fur Daten. Beide Buffers arbeiten als unabhangige Cachesund sind in jeweils in 64 Lines aufgeteilt. Die Translation Lookaside Buffers konnen maximal 34-Bitphysikalischem Speicher (2 Gigabyte) adressieren.

Als Interface zwischen der Software Translation Table und den Hardware Translation Tables aufdem Prozessor agiert der Translation Storage Buffer (TSB), der wie ein direct-mapped cache ar-beitet.Das nachfolgende Bild 3.8 zeigt die Kommunikation zwischen der TSB, der TLB und dem iTLBsowie dem dTLB:

Abbildung 3.8: Interaktion TSB, TLB und iTLB / dTLB

Version 1.1 16

Page 17: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

3.2 Intel x86 Pentium II

3.2 Intel x86 Pentium II

3.2.1 Prozessor Intel Pentium II

(JS05) (CL06) Der Intel Pentium II basiert auf der x86-Architektur und gehort zu der Intel P6-Familie. Aufgrund der komplexen Mikroarchitektur und des riesigen Befehlssatzes gehort dieserProzessor zu der CISC-Architektur. Zu der Intel P6-Familie gehoren weitere Prozessoren, die auchzeitlich nach dem Pentium II entwickelt worden sind.

Year Type Transistors(x1000)

Technology Clock(MHz)

Issue Word format

L1 cache L2 cache

1995 PentiumPro 5500 0.35 150-200 3 32-bit 2 x 8kB 256kB /512kB

1997 PentiumPro 5500 0.35 200 3 32-bit 2 x 8kB 1MB

1998 Intel Cele-ron

7500 0.25 266-300 3 32-bit 2 x 16kB -

1998 Intel Cele-ron

19000 0.25 300-333 3 32-bit 2 x 16kB 128kB

1997 Pentium II 7000 0.25 233-450 3 32-bit 2 x 16kB 256kB /512kB

1998 Pentium IIMobile

7000 0.25 300 3 32-bit 2 x 16kB 256kB /512kB

1998 Pentium IIXeon

7000 0.25 400-450 3 32-bit 2 x 16kB 512kB /1MB

1999 Pentium IIXeon

7000 0.25 450 3 32-bit 2 x 16kB 512kB /2MB

1999 Pentium III 8200 0.25 450-1000 3 32-bit 2 x 16kB 512kB

1999 Pentium IIIXeon

8200 0.25 500-1000 3 32-bit 2 x 16kB 512kB

Tabelle 3.1: Intel P6-Familie

Die Prozessoren der P6-Familie sind abwarts kompatibel mit den Vorgangerversionen und erfor-dern deshalb keine Anpassung der Binaries, dies zieht naturlich auch veraltete Umsetzungen in derMikroarchitektur nach, so dass die neuen Prozessoren nur Erweiterungen darstellen. Die Moglich-keit zur Benutzung von Intel-Binaries auf allen Intel-Prozessoren ist naturlich fur Entwickler einVorteil, die Software muss nicht auf jeden Prozessor angepasst werden.

3.2.2 Mikro-Architektur

(INT05-2) Die Architektur des Intel Pentium II-Prozessors ist eine dreistufige (Fetch/Decode-,Dispatch/Execute- und Retire-Einheit) superskalare Mikro-Architektur.

3.2.3 Prozessor-Pipeline

(INT05-2) Die PII Prozessor-Pipeline besteht aus 12 In-Order und 2 Out-Of-Order Stufen und istim Vergleich 33% schneller als bei dem PI, welches eine hohere Taktrate ermoglicht. Die Besonder-heit der PII-Pipeline ist der sogenannte Instruction-Pool, der es der Execute-Einheit ermoglicht,eine bessere Ubersicht uber den Instruktionsfluss zu haben, so dass ein effizienteres Schedulingstattfinden kann. Um dies zu ermoglichen, muss die Fetch/Decode-Einheit eine bessere Programm-flussvorhersage treffen. Die Trennung der Execute/Dispatch- von der Retire-Einheit erlaubt eineAusfuhrung der Programmteile in (fast) beliebiger Reihenfolge. Die Retire-Einheit schreibt die Er-gebnisse jeden Befehls in der richtigen (Original-) Reihenfolge zuruck.

Version 1.1 17

Page 18: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

3.2 Intel x86 Pentium II

Abbildung 3.9: Mikroarchitektur des Pentium II

3.2.4 Fetch/Decode-Unit

(INT05-2) Die Fetch/Decode-Einheit holt die Instruktionen der Reihe nach aus dem Instructions-Cache und dekodiert jede Instruktion in eine Folge von Mikro-Operationen (µops).

Die Bausteine der Fetch/Decode-Einheit sind ein Instruction-Cache (L1), drei Instruction-Decoder,weitere Register und eine Ablaufsteuerung.

Der L1-Cache hat eine Große von 2x16kB (jeweils 16kB fur Daten und Instruktionen) welcher voneiner weiteren Einheit (Next IP) durch den Instruction Cache-Index unterstutzt wird. Der Instruc-tion Cache Index generiert seine Daten aus dem Branch Target Buffer (BTB), Trap/Interrupt-Status und fehlerhaften Sprungvorhersagen der Integer-Ausfuhrungseinheit.

Je nach Index des Instruction Cache-Index werden die zwei nachfolgenden Cache-Lines geladenund zu 16 Byte-Paketen in den Instruction Decoder geschrieben. Dabei werden die geladenenBytes passend fur die drei Instruction Decoder justiert. Zudem werden der Anfang und das Endeeiner Intel Architecture Instruktion (IA-Instruction) markiert.

Im folgenden werden die drei Instruction Decoder mit dem Datenstrom versorgt. Die InstructionDecoder suchen und dekodieren die IA-Instruktionen und liefern triadische µops (zwei Quell-, ein

Version 1.1 18

Page 19: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

3.2 Intel x86 Pentium II

Abbildung 3.10: Prozessor-Pipeline des Pentium II

Zielfelder) zuruck.

Die meisten IA-Instruktionen werden in eine Mikro-Operation (µop) dekodiert, andere Instruktio-nen in bis zu 4 µops und wenige Instruktionen benotigen einen Microcode, der von dem MicrocodeInstruction Sequencer abgearbeitet wird. Dieser Microcode besteht aus einfachen aufeinanderfol-genden µops. Nach der Dekodierung werden die µops zum Register Alias Table (RAT) geleitet.

Der RAT konvertiert die logischen Register-Referenzen in physikalische Register-Referenzen undfugt jeder µop Statusinformationen an. Nun werden die µops in dem Instruction Pool zwischen-gespeichert. Der Instruction Pool ist als Array von Content Addressable Memory, dem ReOrderBuffer (ROB), implementiert.

3.2.5 Dispatch/Execute-Unit

(INT05-2) Die nachste Stufe der Pipeline ist die Dispatch/Execute-Einheit. Die Verarbeitung kannin anderer Reihenfolge stattfinden, als mit der Fetch/Decode-Einheit eingelesen bzw. dekodiertwurden. Datenabhangigkeiten und die Verfugbarkeit der benotigten Ressourcen werden dabei be-rucksichtigt. Das Ergebnis dieser Einheit wird in dem Instruction-Pool zwischengespeichert, bevores von der nachfolgenden Stufe benotigt wird. Die Ergebnisse dieser Einheit werden auch speculati-ve executions genannt, da die Ausfuhrung der Mikro-Operationen im voraus (spekulativ) geschieht.

Die Dispatch/Execute-Einheit holt sich die µops entsprechend des Status aus dem Instruction Pool.Besagt der Status einer µop, dass alle Operanden verfugbar sind, wird gepruft, ob alle benotigtenRessourcen fur die Ausfuhrung ebenfalls verfugbar sind. Ist das der Fall, wird diese µop von dem

Version 1.1 19

Page 20: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

3.2 Intel x86 Pentium II

Abbildung 3.11: Fetch/Decode-Unit des Pentium II

Instruction Pool in die Reservation Station verschoben und der zustandigen Execute-Einheit uber-geben. Das Ergebnis der ausgefuhrten µop wird wieder im Instruction Pool zwischengespeichert.

Die Reservation Station besitzt funf Ports zu den einzelnen Ressourcen wie den MMX-, Fließkomma-, Sprung und Integer-Ausfuhrungseinheiten sowie den Load- und Store-Einheiten. Diese Ressour-cen konnen parallel genutzt werden und somit konnen 5 µops bei optimaler Verteilung (3 µops imDurchschnitt) pro Takt ausgefuhrt werden.

Der Algorithmus zur Verteilung der µops auf die Ausfuhrungseinheiten ist fur die Performancebesonder wichtig, um eine annahernd optimale Verteilung zu erreichen. Wenn pro Takt nur eineµop den Status zur Ausfuhrung erhalt, braucht keine Entscheidung gefallt werden, welche weiterenµops fur die freien Ausfuhrungseinheiten genutzt werden. Bei mehreren µops mit dem Status zurAusfuhrung werden die µops mit dem Pseudo-FIFO Scheduling Algorithmus in eine Reihenfolgegebracht, die eine Ausfuhrung dieser µops aufeinanderfolgend ermoglicht.

Viele der µops sind Sprung-Anweisungen, welche meistens durch den Branch Target Buffer (BTB)richtig vorhergesagt worden sind. Sprungoperationen werden bei der Vorhersage mit der Folge-adresse und der vorhergesagten Sprungadresse versehen, so dass bei der Ausfuhrung diese Adres-sen miteinander vergleichen werden. Stimmen diese Adressen uberein, kann die Ausfuhrung allerµops zwischen dieser µop und dem nachsten Sprung zugelassen werden. Ist das nicht der Fall,also stimmen die Folgeadresse und die vorhergesagte Adresse nicht uberein, werden alle folgendenµops von der Jump Execution Einheit (JEU) aus dem Instruction Pool geloscht und dem BTB dierichtige Sprungadresse ubermittelt. Die Pipeline wird mit der neuen Adresse fortgesetzt und derInstruction Pool gefullt.

Ein Beispiel zeigt die Abarbeitung von vier Instruktionen (Pseudocode):

r1 <= mem [r0] /* Instruktion 1 */

r2 <= r1 + r2 /* Instruktion 2 */

r5 <= r5 + 1 /* Instruktion 3 */

r6 <= r6 - r3 /* Instruktion 4 */

Version 1.1 20

Page 21: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

3.2 Intel x86 Pentium II

Abbildung 3.12: Dispatch/Execute-Unit des Pentium II

Die erste Instruktion des Beispiels ladt den Inhalt einer Speicherzelle in r1, erzeugt damit einen Ca-che Miss. Um die Daten aus dem Speicher zu holen, mussten andere Prozesse auf das Bus-Interfacewarten, bis der Inhalt der Speicherzelle zuruckgegeben und die nachste Instruktion abgearbeitetwerden kann. Um dies zu vermeiden, benutzt der PII den Instruction Pool und fuhrt die nachstenunabhangigen Instruktionen aus, welche in diesem Beispiel die 3. und 4. Instruktion sind, da die2. Instruktion von der 1. Instruktion abhangig ist. Nun werden die beiden Instruktionen (3. und4.) Out-Of-Order ausgefuhrt und deren Ergebnisse zuruck in den Instruction Pool geschrieben, umnachfolgend von der Retire-Unit In-Order abgeschlossen zu werden.

Der Cache Miss der ersten Instruktion dauert mehrere Zyklen, bis die angeforderten Daten ver-fugbar sind, wahrend dieser Zeit werden die nachsten 20-30 Instruktionen in den Instruktion Poolgelesen und bei Daten- und Sprungunabhangigkeit zur Dispatch/Execute-Unit geleitet.

3.2.6 Floating Point Unit

(INT05-2) Die Floating Point Unit auch, x87 FPU genannt, stellt hochperformante Gleitpunkt-Arithmetik zur Verfugung. Die 8 Datenregister der FPU, sind 80-Bit breit. Die Daten werden indem Double Extended Precision Floating Point-Format verarbeitet (siehe auch Abbildung 3.13).

Die einfachen FPU-Operationen, wie z.B. FADD und FMUL, werden in zwei Takten abgearbeitetund wieder im Instruction Pool zwischengespeichert.

3.2.7 MMX Execution Unit

(INT05-2) (INT05-3) Die MMX-Technologie stellt 57 neue Instruktionen, 4 neue Datentypen und

Version 1.1 21

Page 22: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

3.2 Intel x86 Pentium II

Abbildung 3.13: Gleitpunkt-Datentypen

8 64-Bit MMX-Register (MM0..MM7) fur den Anwender zur Verfugung. Anwendungen, wie Kom-primieren und Dekomprimieren von Dateien, grafisches Bearbeiten von Bildern oder komplexeDateikonvertierungen profitieren von diesen Instruktionen. So konnen z. B. grafische Bearbeitun-gen mit nur einer Instruktion anstatt von acht aufeinander folgenden Instruktionen ausgefuhrtwerden. Diese Art der Verarbeitung von Instruktionen und Daten wird Single Instruction MultipleData, kurz SIMD genannt.

3.2.8 Retire-Unit

(INT05-2) Die Retire-Einheit fugt die speculative executions in der benotigten Reihenfolge undzum richtigen Zeitpunkt wieder zusammen.

Abbildung 3.14: Retire-Unit des Pentium II

Der Status der µops im Instruction Pool wird von der Retire-Einheit auf bereits Ausgefuhrt gepruft.Wird eine µop gefunden, wird sie aus dem Instruction Pool geloscht und in der Reservation Stationzwischengespeichert. Die µops werden nun in die richtige Reihenfolge (die Reihenfolge vor derFetch/Decode-Einheit) gebracht und in das Retirement Register File (RRF) geschrieben, dabeikonnen maximal drei µops pro Takt bearbeitet werden.

Version 1.1 22

Page 23: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

3.2 Intel x86 Pentium II

Diese Einheit muss auch im Falle eines Interrupts, Traps, Fehlers oder fehlerhaften Sprungvorher-sage die Reihenfolge der µops einhalten.

3.2.9 Bus-Interface-Unit

(INT05-2) Diese Einheit verbindet die vorhergehenden Einheiten mit dem ubrigen System. DieBus-Interface-Einheit kommuniziert uber 4 Kanale direkt mit dem L2-Cache und kontrolliert denTransaktionsbus zum Arbeitsspeicher. Auf diesem Bus wird das MESI-Protokoll zum Abgleichender Caches benutzt.

Abbildung 3.15: Bus-Interface-Unit des Pentium II

Bei dem PII gibt es die Load- und Store-Einheiten, um Speicherzugriffe zu ermoglichen. Bei Load-Operationen mussen nur die Speicheradresse, die Lange der Daten und das Zielregister angegebenwerden, deshalb reicht eine µop fur diese Operation aus.

Die Store-Operation benotigt die Speicheradresse, die Datenlange und die Daten selbst. Deshalbwerden Store-Operationen in zwei µops durchgefuhrt. Die erste µop zum Generieren der Zieladresse,die zweite µop zum Generieren der Daten (Adresse). Bei der Retire-Einheit mussen diese µops

wieder kombiniert und geschrieben werden.

Store-Operationen werden von der Dispatch-Einheit nur dann gelesen, wenn alle Operanden undDaten bereitstehen und sich keine andere Store-Operationen in der Reservation Station befinden.Die Operationen werden immer in der Original-Reihenfolge gelesen und nicht spekulativ ausge-fuhrt, da diese Operation nicht ohne viel Aufwand ruckgangig zu machen ist. Der Memory OrderBuffer (MOB) ubernimmt die Aufgaben, die mehrfachen Store-Operationen zwischenzuspeichernund freizugeben, wenn keine weitere Store-Operation verarbeitet wird. Der MOB verhalt sich wiedie Reservation Station und der ROB.

3.2.10 Caches

(INT05-2) Der On-Chip Cache des Pentium II besteht aus je 16kB 4-Wege Assoziativ-Cache mitCache-Lines von 32 Bytes fur Instruktionen und Daten. Die Caches verwenden Write-Back undeinen Pseudo-LRU Ersetzungsalgorithmus. Der Cache ist in 8 Cachebanke mit jeweils 4-Byte-Grenzen aufgeteilt. Dabei kann der Daten-Cache des Pentium II von einer Load- und einer Store-Instruktion gleichzeitig benutzt werden, solange auf verschiedene Cache-Banke zugegriffen wird.

Version 1.1 23

Page 24: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

3.2 Intel x86 Pentium II

3.2.11 Write Buffers

(INT05-2) Dem Pentium II mit MMX-Technologie stehen vier Schreibpuffer zur Verfugung (zweimehr als bei Pentium Prozessoren ohne MMX). Zugriffe auf die Schreibpuffer konnen von jederPipelinestufe aus erfolgen.

Version 1.1 24

Page 25: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

3.3 Betriebssystem

3.3 Betriebssystem

Voraussetzung fur das Durchfuhren von Benchmarks ist die Auswahl eines geeigneten Betriebssys-tems. Dieses muss einige wichtige Kriterien erfullen:

• Das Betriebssystem muss frei erhaltlich sein

• Das Betriebssystem muss auf zwei Plattformen laufen

• Das Betriebssystem muss fur beide Prozessor-Architekturen gleichermaßen optimiert sein

• Geeignete Benchmarksoftware muss Verfugbar sein

Bei Projektstart 2005 standen folgende Betriebssystemgruppen zur Verfugung:

• Microsoft Windows

• Sun Solaris

• Linux (z.B. Suse, Debian, Ubuntu, FreeBSD, Gentoo)

Microsoft Windows ist das meist verbreitete Betriebssystem. Anhand der Kriterien fallt MicrosoftWindows heraus, da das Betriebssystem weder frei erhaltlich ist, noch auf der Sun UltraS-PARC lauffahig und weder schlank noch optimierbar ist.

Sun Solaris in der Version 10 (aktueller Stand 2005/2006) ist frei erhaltlich und auf beiden Test-systemen lauffahig. Da das Betriebssystem auf den Rechnern nur Binarys installiert, ist nichtnachvollziehbar, wie und ob das Betriebssystem fur die Prozessor-Architekturen optimiert ist.Ein weiteres Problem besteht in der Verfugbarkeit geeigneter Compiler, um die einzusetzen-den Benchmark-Programme optimal zu kompilieren. Fur die SPARC-Prozessoren existiertein spezieller C-Compiler, der nicht fur den x86-Prozessoren verfugbar ist. Eine weitere Hur-de ist das Fehlen eines geeigneten Fortran-Compilers.Diese Grunde sprechen gegen den Einsatz von Sun Solaris als Betriebssystem.

Debian erfullt alle der oben genannten Voraussetzungen, jedoch ist das Betriebssystem ebenfallsschon vorkompiliert. Bei Debian sind die Pakete nicht der Prozessor-Architektur optimal an-gepasst, deswegen kam Debian nicht zum Einsatz.

Gentoo Linux erfullt alle Kriterien. Das Betriebssystem ermoglicht eine stage1 Installation, welchedas Betriebssystem mit Hilfe von Flags optimal fur die Prozessor-Architekturen kompiliert(Compiler-Flags). Ein weiterer großer Vorteil besteht in der Verfugbarkeit der Pakete, die alsSource Code zur Verfugung stehen und ebenfalls mit den optimalen Flags kompiliert werden.Alle Pakete, die zum Einsatz kommen, existieren fur beide Prozessor-Architekturen in glei-chen Versionen, dies hat den Vorteil, dass nur noch die Prozessor-Architektur und der Com-piler den Benchmark beeinflussen.Der einzige Unterschied des Betriebssystems auf beiden zu testenden Plattformen besteht inder Kernel-Konfiguration. Fur den Intel Pentium II Prozessor muss ein 32-Bit Kernel kompi-liert werden, wahrend bei dem Sun UltraSPARC IIi Prozessor ein 64-Bit Kernel kompiliert

Version 1.1 25

Page 26: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

3.4 Benchmarkprogramme

und genutzt wird. Es ist nicht moglich (und macht auch keine Sinn) einen 32-Bit Kernel fureine 64-Bit Architektur nutzen zu wollen, da unter anderem die 64-Bit Register dann nichtvoll genutzt werden.

3.4 Benchmarkprogramme

Nachfolgend werden kurz die Funktionen der benutzten Benchmarkprogramme erlautert.

3.4.1 Whetstone

(AB97) Der Whetstone-Benchmark wurde in den 60er Jahren von Brian Wichmann (NationalPhysical Laboratory, England) zum Test eines ALGOL60-Compilers entwickelt. Eine brauchbareImplementierung wurde erst 1972 von Harold Curnow in FORTRAN umgesetzt.

Der Aufbau des Benchmarks setzt sich aus 12 Modulen (N1 bis N12) zusammen, die nachein-ander aufgerufen und inklusive aller Zuweisungen gemessen werden. Der im Versuch verwendeteWhetstone-Benchmark5 (V1.2) wurde 1998 von Rich Painter an die Programmiersprache C ange-passt.

Durch die sehr geringe Anzahl Operationen kann der Benchmark vollstandig in den L1-Cache derCPU geladen werden. Der Vorteil ergibt sich aus der Geschwindigkeit des L1-Caches, im Resultatwird das ubrige System nicht durch den Benchmark abgedeckt.

Die Anweisungen der einzelnen Module konnen anteilig in Integer- und Gleitpunkt-Operationensowie Funktionsaufrufe aufgeteilt werden:

Modul Anteil Art der Anweisungen

N1 0% Arithmetik von Variablen (double-precision add, sub)

N2 0,54% Arithmetik von Vektoren (double-precision add, sub)

N3 0,63% Arithmetik von Vektoren (double-precision add, sub, mit Funktionsaufruf)

N4 15,53% Bedingte Sprunge (Integer-Vergleiche)

N5 0% nicht verwendet

N6 9,45% Integer Arithmetik (add, sub, mul)

N7 1,44% Trigonometrische Funktionen (double-precision sin, cos, atan und sub,mul, div)

N8 40,48% Funktionsaufruf (byref, byval)

N9 27,74% Funktionsaufruf (Vektor-Zuweisung)

N10 0% Integer Arithmetik von Variablen (add, sub)

N11 4,19% Trigonometrische Funktionen (double-precision log, exp, sqrt und div)

N12 0% nicht verwendet

Tabelle 3.2: Module des Whetstone-Benchmarks

5Der Original Source Code ist im Anhang 8 zu finden.

Version 1.1 26

Page 27: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

3.4 Benchmarkprogramme

Der nachfolgende Pseudocode verdeutlicht die Zeitmessung, den eigentlichen Benchmark.

timer start

calculate module-iterations

while loop-iterations < maxloops

do

module 1

[..]

module 11

loop

timer stop

Als Ergebnis gibt der Whetstone-Benchmark einen Wert zuruck, der die Anzahl der Instruktionenzuruckgibt. Dieser Wert wird in MWIPS oder auch (double-precision) MIPS angegeben (million(whetstone-)instructions per second).

3.4.2 Dhrystone

(RW88) Der Dhrystone-Benchmark wurde 1984 von Reinhold Weicker in der ProgrammiersprecheADA entwickelt. Nur 4 Jahre spater wurde eine uberarbeitete Version (Version 2, in C geschrieben)veroffentlicht. Der im Versuch verwendete Dhrystone-Benchmark6 der Version 2.1 enthalt einigePatches die kleinere Mangel der Vorgangerversion beheben.

Der Ablauf des Dhrystone-Benchmarks lasst sich zusammenfassend in die Art der Operationen zer-legen. Die Tabelle 3.3 zeigt eine Ubersicht der verwendeten Operationen. Eine genaue Erlauterungder einzelnen Operationstypen, der verwendeten Operatoren, Datentypen und Lokalitaten ist inder Headerdatei dhry.h des Benchmarks zu finden.

Operation Anteil Instruktionen

Zuweisungen 51,0% Variable=Variable, Variable=Konstante, Varia-ble=Funktion()

Kontrollstrukturen 32,4% boolsche Ausdrucke, for, while, break u. a.

Funktionsaufrufe 16,7% call Funktion(), Bibliotheksaufrufe

Tabelle 3.3: Verwendete Arten der Operationen im Dhrystone-Benchmark

Der folgende Pseudocode verdeutlich auch hier die Zeitmessung des Dhrystone-Benchmarks.

timer start

for all number_of_runs

run tests

next

timer stop

Der Ruckgabewert des Dhrystone-Benchmarks wird in Dhrystones pro Sekunde ausgedruckt. DerWert fur jeden Durchlauf bewegt sich zwischen 400.000 und 900.000 Dhrystones/s oder auchInteger-MIPS (million (integer-)instructions per second).6Der Original Source Code ist im Anhang 8 zu finden.

Version 1.1 27

Page 28: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

3.4 Benchmarkprogramme

3.4.3 LINPACK

(JD84) Linpack ist eine Sammlung von Funktionen zum Analysieren und Losen von linearen Glei-chungssystemen. Der originale und im Versuch genutzte Source Code wurde in den 70er Jahrenvon Jack Dongarra entwickelt und mehrfach verbessert. Der Source Code ist komplett in Fortranverfasst und wird vom F77-Compiler der GCC (bis Version 3.4.x) problemlos ubersetzt. Linpacknutzt die von BLAS bereitgestellten Funktionen zur einfachen Berechnung von Vektor- und Ma-trixoperationen.

BLAS

(JD05) In BLAS - Basic Linear Algebra Subprograms - sind einfache Funktionen zur Berechnungvon Vektor- und Matrixoperationen zusammengestellt. Die BLAS-Routinen sind in 3 Stufen ein-geteilt:

• Level 1 - Skalar-, Vektor- und Vektor-Vektor-Operationen

• Level 2 - Matrix-Vektor-Operationen

• Level 3 - Matrix-Matrix-Operationen

Die von den Benchmarkprogrammen genutzten Subroutinen der BLAS Bibliothek werden in Ta-belle 3.4 kurz zusammengefasst und erlautert. Jede Subroutine ist jeweils mit single und doubleGenauigkeit aufgefuhrt.

Subroutine Level Funktion

daxpy/saxpy 1 skaliert Vektor mit einer Konstanten plus Vektor (y = a*x + y)

ddot/sdot 1 Skalarprodukt eines Vektors

dscal/sscal 1 skaliert einen Vektor mit einer Konstanten (x = a*x)

idamax/isamax 1 sucht den Index des Elements mit maximalem Absolutwert(Pivot-Element)

dgemv/sgemv 2 y = alpha*A*x + beta*y; Skalar alpha, beta; Vektor x, y; mn-Matrix A

dgemm/sgemm 3 C = alpha*op(A)*op(B) + beta*C; Skalar alpha, beta; MatrixA, B, C;

Tabelle 3.4: Subroutinen aus BLAS

1000s und 1000d

(JD92) Im folgenden werden die im Benchmark verwendeten Subroutinen beschrieben. Die Pro-gramme 1000s und 1000d7 verwenden sehr ahnliche Routinen, lediglich die Gleitpunktgenauigkeitvon single (32-bit) und double (64-bit) ist unterschiedlich. Die verwendeten Subroutinen (aus LIN-PACK) werden namentlich mit xGEFA und xGESL bezeichnet, weitere Routinen sind xGEMV und

7Der vollstandige Quelltext der Programme 1000s und 1000d ist im Anhang zu finden

Version 1.1 28

Page 29: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

3.4 Benchmarkprogramme

xGEMM, wobei das x durch jeweils single S und double D ersetzt wird. Die letzten beiden Subrouti-nen werden nicht in den Programmen 1000s und 1000d verwendet, dafur aber in LLCBench. Somitwerden fur jede Genauigkeit zwei Routinen verwendet, insgesamt also vier Routinen aus LINPACK.

Der Ablauf des ersten Benchmark-Programmes wird anhand des Pseudocodes von 1000s deutlichgemacht. Hier lasst sich die Messung der Rechenzeit fur den gesamten Ablauf gut erkennen:

timer1 start

call sgefa

timer1 stop

timer2 start

call sgesl

timer2 stop

time = timer1 + timer2

SGEFA Die Beschreibung der folgenden Subroutinen beschrankt sich auf die single-Genauigkeit,da die double-Genauigkeit nur Unterschiede des Datentyps besitzt.

Die erste Subroutine, verwendet in 1000s, setzt sich namentlich aus S fur single (reelle Matrix), GEfur allgemeine Matrix (general matrix) und FA fur Faktorisierung durch das Gausche Eliminations-verfahren mit Pivotisierung zusammen. Nachfolgend ist der Pseudo-Code aufgefuhrt:

for all matrix width

call isamax // pivot

call sscal // x = a*x

for all matrix height

call saxpy // y = a*x + y

next

next

SGESL Die zweite Subroutine beschrankt sich auf das Losen der Gleichungssysteme (Ax = b), diemit der ersten Subroutine faktorisiert worden sind. Nachfolgend ist der Pseudo-Code aufgefuhrt:

for all vector length

call saxpy // l*y = b

next

for all vector length

call saxpy // u*x = y

next

Version 1.1 29

Page 30: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

3.4 Benchmarkprogramme

MFLOPS Die Zeitmessung der Routinen SGEFA und SGESL liefern Werte gemessen in MFLOPS(million floating-point operations per second) zuruck. Im Gegensatz zu den MIPS werden bei denMFLOPS keine Instruktionen sondern Operationen gemessen, da eine Operation aus mehrerenInstruktionen bestehen kann, was sich wiederum auf die Ausfuhrungsdauer der Gleitpunktopera-tionen auswirkt. So dauert bei der MIPS R10000 eine Gleitpunkt-Addition nur 3 Zyklen, aber eineGleitpunkt-Division dauert 67 Zyklen. Aus diesem Grund werden die normalisierten MFLOPS zurGewichtung der Instruktionen wie folgt verwendet.

Operation Gewichtung

Addition und Multiplikation 1

Division und Wurzeloperation 4

Exponentialfunktion und trigon. Funktion 8

Tabelle 3.5: Subroutinen aus BLAS

3.4.4 LLCbench

(PM06) Fur die Bestimmung der Performance der Speicherzugriffe auf die Cache-Bereiche derProzessoren (L1 sowie L2), wird die LLCbench Suite genutzt. Diese Suite ist eine Zusammenstellungvon einzelnen LowLevel Benchmarkprogrammen und besteht aus:

• CacheBenchCacheBench testet den vorhanden L1- und L2-Cache der Prozessoren.

• BlasBenchBlasbench testet die BLAS-Library des Systems in Relation zu Speicherzugriffen.

• MPBenchMPBench testet wichtige MPI-Funktionen. Da MPBench fur Multiprozessorarchitekturenentwickelt wurde, kommt dieser Benchmark fur diese beiden Systeme nicht zum Einsatz.

Die Software Suite wurde im November 1998 von P. J. Mucci, K. London und J. Thurman entwi-ckelt.

BlasBench

BlasBench nutzt 3 Routinen der BLAS-Library in double- und single Prazision (xAXPY, xD-GEMV, xDGEMM). Diese Funktionen sind in Abschnitt 3.4 erlautert.Die Messung der Ausfuhrungszeit ist im folgendem Pseudo-Code dargestellt:

for i=1 to 10000 // Parameter -i = 10000

flushall // L1-Cache leeren

timer start

do_saxpy // Berechnung von SAXPY

timer stop

Version 1.1 30

Page 31: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

3.4 Benchmarkprogramme

do_saxpy()

{

for e=1 to (-e) // Parameter -e = 1

call saxpy // BLAS-Library/SAXPY

}

Aus dem Pseudo-Code ist ersichtlich, dass nur die Zeit der Berechnungen (xAXPY, xDGEMV,xDGEMM) gemessen wird. Zusatzlich kommt ein geringer Overhead fur das einmalige Durchlaufender Schleife und Zuweisung (Parameter -e = 1) hinzu.

CacheBench

CacheBench stellt 6 Testfunktionen zur Verfugung. Jede Testfunktion greift wiederholt auf Datenverschieden langer Vektoren zu. Dabei wird die Zeit fur eine bestimmte Anzahl von Iterationen furjede Vektorlange festgehalten. Das Produkt der Iterationen mit der Vektorlange ergibt dann dieGroße des Datensatzes.

Cache Read bestimmt die Lesebandbreite der Cachespeicher bei variabler Vektorlange. Wichtighierbei ist, dass der Compiler den Source Code optimiert; also erfolgt die Bestimmung derLesebandbreite mittels vom Compiler optimierter Schleifen.

Nachfolgend ist der Pseudo-Code aufgefuhrt:

for all vector length

timer start

for iteration count

for I = 0 to vector length

register += memory[I]

timer stop

Cache Write bestimmt die Schreibbandbreite der Cachespeicher bei variabler Vektorlange. Wich-tig hierbei ist, dass der Compiler den Source Code optimiert; also erfolgt die Bestimmungder Schreibbandbreite mittels vom Compiler optimierter Schleifen.

Nachfolgend ist der Pseudo-Code aufgefuhrt:

for all vector length

timer start

for iteration count

for I = 0 to vector length

memory[I] = register++

timer stop

Cache read/modfiy/write bestimmt die Lese/Schreib Bandbreite der Cachespeicher bei variablerVektorlange. Wichtig hierbei ist, dass der Compiler den Source Code optimiert; also erfolgtdie Bestimmung der Lese/Schreib Bandbreite mittels vom Compiler optimierter Schleifen.

Nachfolgend ist der Pseudo-Code aufgefuhrt:

Version 1.1 31

Page 32: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

3.4 Benchmarkprogramme

for all vector length

timer start

for iteration count

for I = 0 to vector length

memory[I]++

timer stop

Hand Tuned Versionen von Cache read, Cache write, Cache read/modfiy/writeDiese Funktionen sind Hand-optimiert und zeigen, wie gut der Compiler die Benchmarkfunk-tionen beim Compilieren optimiert hat.

Bei der Handoptimierung wurden folgende Regeln der Optimierung beachtet:

• Jede Schleife referenziert 8 Memory-Elemente statt einem (Degree Eight Unrolling)

• Jede Operation ist unabhangig von den vorherigen 7 Operationen (Dependency Analy-sis)

• Register sind Speicherstellen zugewiesen und werden so oft wie moglich benutzt (RegisterRe-Use)

Version 1.1 32

Page 33: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

4 Realisierung

4.1 Hardware

Die Hardware fur das Sun-System ist als Komplettsystem vorhanden. Um gleiche Testbedingungenund damit vergleichbare Ergebnisse zu erzielen, wurde die Hardware fur den x86 Rechner angepasst.

4.1.1 SPARC Rechner

Der Aufbau des Sun-Rechners besteht aus folgenden Komponenten:

• Sun Mainboard mit Sabre-Chipsatz, 33/66 MHz PCI-Bus, 90 MHz UPA64S Bus

• 360 MHz 64Bit-CPU mit 16 KByte Instruction- und Datacache sowie 256 KByte L2-Cache(180 MHz Bustakt)

• 2x 128 MB Edo JEDEC DIMM 90MHz Bustakt

• MDMA-IDE-Controller, max. 16,7 MB/s Ubertragungsrate

• 40 GB HDD, 7200 U/min, 1863 KB Cache

• CD-Rom Laufwerk 32fach

• Grafikkarte ATI 3D Rage Pro PCI, 4 MB SGRAM Grafikspeicher

• 10/100 MBit Netzwerkkarte, Type: HappyMeal

4.1.2 x86 Rechner

Fur den Aufbau des x86-Rechners wurden folgende Komponenten zusammengestellt:

• Mainboard ASUS P3B-F mit Intel 440BX-Chipsatz, 33/66 MHz PCI-Bus, AGP Bus

• 350 MHz Pentium II 32Bit-CPU mit 16 KByte Instruction- und Datacache sowie 256 KByteL2-Cache (200 MHz Bustakt)

• 2x 128 MB SDRAM, 100 MHz Bustakt

• UDMA33-IDE-Controller, max. 33 MB/s Ubertragungsrate

• 40GB HDD, 7200 U/min, 1719 KB Cache

• CD-Rom Laufwerk 32fach

• Grafikkarte ATI 3D Rage Pro AGP, 8 MB Grafikspeicher

• 10/100 Netzwerkkarte, Type: Realtek 8139

Version 1.1 33

Page 34: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

4.2 Installation Betriebssystem

4.2 Installation Betriebssystem

(GENTOO) Voraussetzung fur die Installation des Betriebssystems ist eine vorhandene Verbindungin das Internet und ein lokaler DHCP-Server.

1. Herunterladen und Brennen der Universal Installation-CD:

x86:ftp://sunsite.informatik.rwth-aachen.de/pub/Linux/gentoo/releases/x86/2005.1/installcd/install-x86-minimal-2005.1.iso

SPARC:ftp://sunsite.informatik.rwth-aachen.de/pub/Linux/gentoo/releases/sparc/2005.1/sparc64/installcd/install-sparc64-minimal-2005.1.iso

2. Booten des Systems:

wenn boot: erscheintboot: <RETURN> druckenwenn das Bild umspringt:ALT+F1 druckendeutsche Tastatur auswahlenwarten bis das System hochgefahren ist, es erscheint:livecd root

3. Vorbereitung der Festplatte:Die Festplatten werden mit dem Tool fdisk eingerichtet. Die Aufteilung der Platte fur beideRechnersysteme sieht folgendermaßen aus:

• boot /dev/hda1 mit 32 MB, Filesystem ext2

• swap /dev/hda2 mit 512 MB, Filesystem swap

• root /dev/hda3 mit 39,5 GB, Filesystem reiserfs

4. Formatieren der Festplatte:

mkfs.ext2 /dev/hda1

mkswap /dev/hda2

mkfs.reiserfs /dev/hda3

5. Aktivieren der Filesysteme:

swapon /dev/hda2

mount /dev/hda3 /mnt/gentoo/

mkdir /mnt/gentoo/boot

mount /dev/hda1 /mnt/gentoo/boot

cd /mnt/gentoo

6. Datum setzen:

date MMDDhhmmYYYY

Version 1.1 34

Page 35: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

4.2 Installation Betriebssystem

7. Herunterladen der Tools (z.B. Compiler):

x86: Dateigroße 13 MByte:

wget ftp://sunsite.informatik.rwth-aachen.de/pub/Linux/gentoo/releases/

x86/2005.1/stages/x86/stage1-x86-2005.1.tar.bz2

SPARC: Dateigroße 20 MByte:

wget ftp://sunsite.informatik.rwth-aachen.de/pub/Linux/gentoo/releases/

sparc/2005.1/sparc64/stages/stage1-sparc64-2005.1.tar.bz2

8. Entpacken der Tools:

x86:

tar -xvjpf stage1-x86-2005.1.tar.bz2

SPARC:

tar -xvjpf stage1-sparc64-2005.1.tar.bz2

9. Anpassen der Flags (USE Flags, CFLAGS und CXXFLAGS):Editieren der Datei /mnt/gentoo/etc/make.conf mit dem Editor nano.

x86:

/mnt/gentoo/etc/make.conf

# These settings were set by the catalyst build script that automatically

# built this stage

# Please consult /etc/make.conf.example for a more detailed example

CFLAGS="-O2 -march=pentium2 -mmmx -pipe -fomit-frame-pointer"

CHOST="i686-pc-linux-gnu"

CXXFLAGS="${CFLAGS}"

MAKEOPTS="-j2"

FEATURES="ccache distcc"

CCACHE_SIZE="2G"

CCACHE_DIR="/root/.ccache"

ACCEPT_KEYWORDS="~x86"

USE="-gnome -gtk -ipv6 -nptl -nptlonly -qt -kde -X"

SPARC:

# These settings were set by the catalyst build script that automatically

Version 1.1 35

Page 36: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

4.2 Installation Betriebssystem

# built this stage

# Please consult /etc/make.conf.example for a more detailed example

CFLAGS="-O2 -mcpu=ultrasparc -mvis -pipe -fomit-frame-pointer"

CHOST="sparc-unknown-linux-gnu"

CXXFLAGS="${CFLAGS}"

MAKEOPTS="-j2"

FEATURES="ccache"

CCACHE_SIZE="2G"

CCACHE_DIR="/root/.ccache"

ACCEPT_KEYWORDS="~sparc"

USE="-gnome -gtk -ipv6 -opengl -xv -qt"

10. Betreten der Umgebung Gentoo:

mount -t proc none /mnt/gentoo/proc

cp /etc/resolv.conf /mnt/gentoo/etc/

chroot /mnt/gentoo /bin/bash

env-update

source /etc/profile

11. Download Portage Tree:

emerge --sync

Dieser Vorgang dauert mit einer 1 MBit-DSL-Leitung ca. 45 Minuten pro System.

12. Erstellen des minimalen Systems:

cd /usr/portage

scripts/bootstrap.sh

Das Kompilieren dauert ca. 8 Stunden pro System.

13. Erstellen des kompletten Systems:

emerge -eN system

Das Kompilieren dauert ca. 18 Stunden pro System.

14. Installation benotigter Tools:

emerge syslog-ng vixie-cron gentoo-sources dhcpcd reiserfsprogs

15. Installation benotigter Dienste:

Version 1.1 36

Page 37: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

4.2 Installation Betriebssystem

rc-update add syslog-ng default

rc-update add vixie-cron default

rc-update add hdparm default

rc-update add net.eth0 default

rc-update add sshd default

16. Konfiguration des Kernels:Die Kernel-Konfigurationen fur beide Architekturen befinden sich im Anhang.

cd /usr/src/linux

make menuconfig

make && make modules_install

x86:

cp arch/i386/boot/bzImage /boot/kernel-2.6.13-r5

SPARC:

cp arch/sparc64/boot/image /boot/kernel-2.6.13-r5

17. Bearbeiten der /etc/fstab:

/etc/fstab

# /etc/fstab: static file system information.

#

# noatime turns off atimes for increased performance (atimes normally

# aren’t needed; notail increases performance of ReiserFS (at the

# expense of storage efficiency). It’s safe to drop the noatime

# options if you want and to switch between notail / tail freely.

#

# See the manpage fstab(5) for more information.

#

# <fs> <mountpoint> <type> <opts> <dump/pass>

# NOTE: If your BOOT partition is ReiserFS, add the notail option to

# opts.

/dev/hda1 /boot ext2 noauto,noatime 1 2

/dev/hda3 / reiserfs noatime 0 0

/dev/hda2 none swap sw 0 0

/dev/hdc /mnt/cdrom iso9660 noauto,ro 0 0

#/dev/fd0 /mnt/floppy auto noauto 0 0

Version 1.1 37

Page 38: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

4.2 Installation Betriebssystem

# NOTE: The next line is critical for boot!

proc /proc proc defaults 0 0

# glibc 2.2 and above expects tmpfs to be mounted at /dev/shm for

# POSIX shared memory (shm_open, shm_unlink).

# (tmpfs is a dynamically expandable/shrinkable ramdisk, and will

# use almost no memory if not populated with files)

shm /dev/shm tmpfs nodev,nosuid,noexec 0 0

18. Konfiguration des Bootloaders:

x86:

emerge lilo

Editieren der Datei /etc/lilo.conf wie folgt:

/etc/lilo.conf

# Boot partition (= root partition)

boot=/dev/hda

# Wait 15 seconds before booting the default section

timeout=150

default=Gentoo

image = /boot/kernel-2.6.13-r5

root = /dev/hda3

label = Gentoo

read-only

/sbin/lilo

SPARC:

emerge silo

/etc/silo.conf

# Boot partition (= root partition)

partition = 1

# Root partition

root = /dev/hda3

# Wait 15 seconds before booting the default section

timeout = 150

image = /boot/kernel-2.6.13-r5

label = linux

Version 1.1 38

Page 39: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

4.2 Installation Betriebssystem

/sbin/silo

19. Konfiguration des Netzwerkes:In der Datei /etc/conf.d/net ist folgendes einzutragen:

Datei: /etc/conf.d/net

# This blank configuration will automatically use DHCP for any net.*

# scripts in /etc/init.d. To create a more complete configuration,

# please review /etc/conf.d/net.example and save your configuration

# in /etc/conf.d/net (this file).

config_eth0=( "dhcp" )

dhcp_eth0="nontp"

20. Konfiguration der Tastatur:Editieren der Datei /etc/conf.d/keymaps.

# /etc/conf.d/keymaps

# Use KEYMAP to specify the default console keymap. There is a complete tree

# of keymaps in /usr/share/keymaps to choose from.

KEYMAP="de"

# Should we first load the ’windowkeys’ console keymap? Most x86 users will

# say "yes" here. Note that non-x86 users should leave it as "no".

SET_WINDOWKEYS="no"

# The maps to load for extended keyboards. Most users will leave this as is.

EXTENDED_KEYMAPS=""

#EXTENDED_KEYMAPS="backspace keypad euro"

# Tell dumpkeys(1) to interpret character action codes to be

# from the specified character set.

# This only matters if you set UNICODE="yes" in /etc/rc.conf.

# For a list of valid sets, run ‘dumpkeys --help‘

DUMPKEYS_CHARSET=""

21. Abschließen der Installation:Abschließend wird das root Paßwort vergeben und evtl. weitere Benutzer angelegt.

Version 1.1 39

Page 40: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

4.3 Installation benotigter Programme

passwd

useradd -m -G <groups> <username>

passwd <username>

22. Neustart des System:

cd /

umount /mnt/gentoo/proc

umount /mnt/gentoo/boot

umount /mnt/gentoo

reboot

4.3 Installation benotigter Programme

Nachfolgend wird die Installation aller zusatzlich benotigten Programme ausfuhrlich erlautert.

4.3.1 ccache

ccache ist ein Compiler-Cache, der fur mehrfaches Kompilieren einer Quelle die bereits kompi-lierten Binardateien vorhalt und entsprechend zuruck liefert. Die Nutzung dieses Programms be-schleunigte im praktischen Versuch das Kompilieren von u. a. lapack-atlas, lam-mpi, Whetstone,Dhrystone, 1000s, 1000d und LLCbench, da diese zu Testzwecken mehrmals kompiliert wurden.Die Installation erfolgte auf beiden Rechnern mit

emerge dev-util/ccache

4.3.2 gcc-4.0.2

Um eventuelle Vor- und Nachteile des C-Compilers festzustellen, wurde zusatzlich der Compiler gccin der Version 4.0.2 auf beiden Systemen installiert. Die Installation erfolgte auf beiden Rechnernmit

emerge sys-devel/gcc-4.0.2

4.3.3 Librarys

Fur die Benchmarks werden diverse Routinen aus den Librarys BLAS, BLAS-ATLAS und LIN-PACK benotigt. Die Librarys wurden auf beiden Systemen mit folgendem Befehl installiert:

emerge lapack-atlas

emerge lam-mpi

Version 1.1 40

Page 41: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

4.3 Installation benotigter Programme

4.3.4 Whetstone

Das Benchmarkprogramm Whetstone wird folgendermaßen installiert:

• Herunterladen des Source Codes:

x86/SPARC: Dateigroße 409 Bytes:

wget http://www.netlib.org/benchmark/whetstonec -o whetdc.c

• Kompilieren des Source Codes (nicht optimiert und gcc-3.4.5):

x86:

gcc whetdc.c -o whetdc_3.4.5_no_opt -lblas -march=pentium2 -v

SPARC:

gcc whetdc.c -o whetdc_3.4.5_no_opt -lblas -mcpu=ultrasparc -mvis -v

• Kompilieren des Source Codes (nicht optimiert und gcc-4.0.2):

x86:

gcc-config i686-pc-linux-gnu-4.0.2

source /etc/profile

gcc whetdc.c -o whetdc_4.0.2_no_opt -lblas -march=pentium2 -v

gcc-config i686-pc-linux-gnu-3.4.5

source /etc/profile

SPARC:

gcc-config sparc-unknown-linux-gnu-4.0.2

source /etc/profile

gcc whetdc.c -o whetdc_4.0.2_no_opt -lblas -mcpu=ultrasparc -mvis -v

sparc-unknown-linux-gnu-3.4.5

source /etc/profile

• Kompilieren des Source Codes (optimiert und gcc-3.4.5):

x86:

gcc whetdc.c -o whetdc_3.4.5_opt -lblas -march=pentium2 -O3 -v

SPARC:

gcc whetdc.c -o whetdc_3.4.5_opt -lblas -mcpu=ultrasparc -mvis -O3 -v

• Kompilieren des Source Codes (optimiert und gcc-4.0.2):

x86:

Version 1.1 41

Page 42: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

4.3 Installation benotigter Programme

gcc-config i686-pc-linux-gnu-4.0.2

source /etc/profile

gcc whetdc.c -o whetdc_4.0.2_opt -lblas -march=pentium2 -O3 -v

gcc-config i686-pc-linux-gnu-3.4.5

source /etc/profile

SPARC:

gcc-config sparc-unknown-linux-gnu-4.0.2

source /etc/profile

gcc whetdc.c -o whetdc_4.0.2_opt -lblas -mcpu=ultrasparc -mvis -O3 -v

sparc-unknown-linux-gnu-3.4.5

source /etc/profile

4.3.5 Dhrystone

Das Benchmarkprogramm Dhrystone wird folgendermaßen installiert:

• Herunterladen des Source Codes:

x86/SPARC: Dateigroße 72 KBytes:

wget http://www.netlib.org/benchmark/dhry-c -o dhry-c.c

• Entpacken des Source Codes von Dhrystone:

sh dhry-c

• Kompilieren des Source Codes (nicht optimiert und gcc-3.4.5):

x86:

gcc dhry_1.c dhry_2.c -o dhry_3.4.5_no_opt -DTIME -fno-builtin

-march=pentium2 -v

SPARC:

gcc dhry_1.c dhry_2.c -o dhry_3.4.5_no_opt -DTIME -fno-builtin

-mcpu=ultrasparc -mvis -v

• Kompilieren des Source Codes (nicht optimiert und gcc-4.0.2):

x86:

gcc-config i686-pc-linux-gnu-4.0.2

source /etc/profile

gcc dhry_1.c dhry_2.c -o dhry_4.0.2_no_opt -DTIME -fno-builtin

-march=pentium2 -v

gcc-config i686-pc-linux-gnu-3.4.5

source /etc/profile

Version 1.1 42

Page 43: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

4.3 Installation benotigter Programme

SPARC:

gcc-config sparc-unknown-linux-gnu-4.0.2

source /etc/profile

gcc dhry_1.c dhry_2.c -o dhry_4.0.2_no_opt -DTIME -fno-builtin

-mcpu=ultrasparc -mvis -v

sparc-unknown-linux-gnu-3.4.5

source /etc/profile

• Kompilieren des Source Codes (optimiert und gcc-3.4.5):

x86:

gcc dhry_1.c dhry_2.c -o dhry_3.4.5_opt -DTIME -fno-builtin

-march=pentium2 -v -O3

SPARC:

gcc dhry_1.c dhry_2.c -o dhry_3.4.5_opt -DTIME -fno-builtin

-mcpu=ultrasparc -mvis -v -O3

• Kompilieren des Source Codes (optimiert und gcc-4.0.2):

x86:

gcc-config i686-pc-linux-gnu-4.0.2

source /etc/profile

gcc dhry_1.c dhry_2.c -o dhry_4.0.2_opt -DTIME -fno-builtin

-march=pentium2 -v -O3

gcc-config i686-pc-linux-gnu-3.4.5

source /etc/profile

SPARC:

gcc-config sparc-unknown-linux-gnu-4.0.2

source /etc/profile

gcc dhry_1.c dhry_2.c -o dhry_4.0.2_opt -DTIME -fno-builtin

-mcpu=ultrasparc -mvis -v -O3

sparc-unknown-linux-gnu-3.4.5

source /etc/profile

4.3.6 1000s/100d

Das Benchmarkprogramm 1000s/1000d wird folgendermaßen installiert:

• Herunterladen des Source Codes 1000s:

x86/SPARC: Dateigroße 20 KBytes:

wget http://www.netlib.org/benchmark/1000s -o 1000s.f

Version 1.1 43

Page 44: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

4.3 Installation benotigter Programme

• Herunterladen des Source Codes 1000d:

x86/SPARC: Dateigroße 22 KBytes:

wget http://www.netlib.org/benchmark/1000d -o 1000d.f

• Kompilieren des Source Codes 1000s (nicht optimiert und gcc-3.4.5):

x86:

f77 1000s.f -o 1000s_3.4.5_no_opt -march=pentium2 -v

SPARC:

f77 1000s.f -o 1000s_3.4.5_no_opt -mcpu=ultrasparc -mvis -v

• Kompilieren des Source Codes 1000s (optimiert und gcc-3.4.5):

x86:

f77 1000s.f -o 1000s_3.4.5_opt -march=pentium2 -v -O3

SPARC:

f77 1000s.f -o 1000s_3.4.5_opt -mcpu=ultrasparc -mvis -v -O3

• Kompilieren des Source Codes 1000d (nicht optimiert und gcc-3.4.5):

x86:

f77 1000d.f -o 1000d_3.4.5_no_opt -march=pentium2 -v

SPARC:

f77 1000d.f -o 1000d_3.4.5_no_opt -mcpu=ultrasparc -mvis -v

• Kompilieren des Source Codes 1000d (optimiert und gcc-3.4.5):

x86:

f77 1000d.f -o 1000d_3.4.5_opt -march=pentium2 -v -O3

SPARC:

f77 1000d.f -o 1000d_3.4.5_opt -mcpu=ultrasparc -mvis -v -O3

4.3.7 LLCbench

Das Benchmarkprogramm LLCbench wird folgendermaßen installiert:

• Herunterladen des Source Codes:

x86/SPARC: Dateigroße 850 KBytes:

Version 1.1 44

Page 45: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

4.3 Installation benotigter Programme

wget http://icl.cs.utk.edu/projects/llcbench/llcbench.tar.gz

• Entpacken des Source Codes:

gzip -dc llcbench.tar.gz | tar xvf -

• Konfiguration:

x86:

make linux-lam

Editieren der Datei sys.def1 wie folgt:

# Blasbench values

BB_CC = gcc

BB_F77 = g77

BB_LD = g77

BB_CFLAGS = -O3 -Wall -DREGISTER -DINLINE -march=pentium2

BB_LDFLAGS = $(BB_CFLAGS)

BB_LIBS = -lblas -lrt

# Cachebench values

CB_CC = $(BB_CC)

CB_CFLAGS = -O -Wall -march=pentium2

CB_LDFLAGS = $(CB_CFLAGS)

CB_LIBS = -lrt

SPARC:

make linux-lam

Editieren der Datei sys.def wie folgt:

# Blasbench values

BB_CC = gcc

BB_F77 = g77

BB_LD = g77

BB_CFLAGS = -O3 -Wall -DREGISTER -DINLINE -mcpu=ultrasparc -mvis

BB_LDFLAGS = $(BB_CFLAGS)

BB_LIBS = -lblas -lrt

1Vollstandige Konfiguration: siehe Anhang

Version 1.1 45

Page 46: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

4.3 Installation benotigter Programme

# Cachebench values

CB_CC = $(BB_CC)

CB_CFLAGS = -O -Wall -mcpu=ultrasparc -mvis

CB_LDFLAGS = $(CB_CFLAGS)

CB_LIBS = -lrt

• Kompilieren des Source Codes (Single precision fur CacheBench):

make blas-bench

make cache-bench

• Anpassen der Konfiguration (Double precision fur CacheBench):

Andern des Datentypes SINGLE auf DOUBLE in der Datei user.def in dem Abschnitt Ca-cheBench Config wie folgt:

#### Cachebench Config

# Datatype used for each memory reference.

# Legal values are DOUBLE, CHAR, INT, FLOAT

CB_Datatype = DOUBLE

• Kompilieren des Source Codes (Double precision fur CacheBench):

cd cachebench

cp cachebench cachebench_single

make clean cache-bench

cp cachebench cachebench_double

Version 1.1 46

Page 47: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

5 Erwartete Ergebnisse

Die Hardware der Architekturen unterscheidet sich, daher werden enstprechend unterschiedlicheErgebnisse erwartet. Die L1-Cache-Große ist bei beiden Architekuren zwar identisch, der L2-Cacheallerdings bei dem x86 doppelt so groß. Daher wird erwartet, dass in allen Benchmarks, die Da-tengroßen von 256kB uberschreiten, der x86 in den Bereichen zwischen 256kB und 512kB besserabschneidet. Unterhalb 256kB und im L1-Cache-Bereich bis 16kB sollten beide Architekturen inetwa gleiche Werte liefern.

Die Messungen fur die Benchmarks mit Integer-Operationen (Dhrystone) sollte aufgrund der dop-pelten Anzahl Integer-Units der SPARC gegenuber dem x86 besser ausfallen.

Der x86 verfugt uber 80-Bit breite Register fur die Gleitpunktarithmetik, daher ist zu erwarten,dass die single- und double-precision in etwa selbe Ergebnisse1 liefert.

Die double-precision wird hohere Cache-Durchsatze bei den Cache-Benchmarks erzielen, da dieDatendurchsatze der doppelten Menge gegenuber der single-precision entsprechen.

1Die Ausfuhrung der Konvertierungsbefehle (FLD, FST, FILD, FIST) verursacht zusatzliche Zeitkosten.

Version 1.1 47

Page 48: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

6 Versuchsdurchfuhrung und Auswertung

6.1 Compiler

6.1.1 Maschinenunabhangige Optimierung

(GCC-2) Die allgemeine Optimierung des Programmcodes werden uber Compiler-Flags, wie bei dermaschinenspezifischen Optimierung, bestimmt. Diese Optimierung wird in funf Stufen eingeteiltund zusammengefasst. Die einzelnen Optimierungen sind in (GCC-2) ausfuhrlich beschrieben undwerden hier nur auszugsweise dargestellt:

• -O oder -O1: Optimize; Der Compiler versucht die Codegroße und Ausfuhrungszeit des Pro-gramms zu reduzieren ohne die Kompilierungszeit zu verlangern.

• -O2: Optimize even more; Der Compiler wendet fast alle Optimierungen auf den SourceCode an, die sich nur wenig auf das Geschwindigkeits-Großen-Verhaltnis des Programmcodesauswirken. Es werden alle Optimierungen der vorhergehenden Stufe zusatzlich angewendet.

• -O3: Optimize yet more; Zusatzlich zu den vorhergehenden Stufen werden Loop-Unrollingund Function-Inlining angewendet.

• -Os: Optimize for size; Der Compiler wendet alle Optimierungen von -O2 an, die nurwenig Vergroßerung des Programmcodes nach sich ziehen.

• -O0: Do not optimize; Der Compiler wendet keine Optimierungen auf den Source Code an.

6.1.2 Maschinenspezifische Optimierung

(GCC-1) Die maschinenspezifischen Flags konfigurieren den Compiler so, dass Besonderheiten derArchitektur (z.B. Functional Units, Befehlssatz, etc.) berucksichtigt werden. Die meisten maschi-nenspezifischen Optimierungen sind vom Compiler als Standard eingestellt. Nachfolgend werdennur die speziellen maschinenspezifischen Compiler-Flags fur SPARC und x86 erlautert. Die weite-ren Flags werden in (GCC-1) ausfuhrlich beschrieben.

Compiler-Flags fur SPARC:

• -mcpu=ultrasparc: Der Source Code wird mit dem V9-Befehlssatz (64-Bit Integer- undGleitpunkt-MOV-Befehle, Gleitpunkt-Register und bedingte MOV-Befehle), Registersatz undScheduling Parameter kompiliert. Zusatzlich wird der Programmcode fur den Sun UltraS-PARC I/II Prozessor optimiert.

• -mvis: Der Compiler nutzt das UltraSPARC Visual Instruction Set.

Version 1.1 48

Page 49: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

6.2 Whetstone und Dhrystone

Compiler-Flags fur x86:

• -march=pentium2: Der Source Code wird mit dem Befehlssatz des Pentium II, Registersatzund Scheduling Parameter kompiliert.

• -mmmx: Der Compiler nutzt Befehle und Register der MMX-Erweiterung.

6.1.3 Unterschiede gcc-3.4.5 und gcc-4.0.2

(GCC-3) Der Compiler gcc nutzt in der Version 4.0.2 ein komplett anderes Framework zur Code-optimierung, als in der Version 3.4.5. Die einzelnen Unterschiede (bzgl. der Optimierung) zwischenden Versionen sind daher nur durch Disassemblierung des Programmcodes nachvollziehbar. Durchdas neue Framework (gcc-4.0.2) ist nicht zwingend gewahrleistet, dass der Programmcode besseroptimiert ist als mit der Version gcc-3.4.5.

6.2 Whetstone und Dhrystone

Der Whetstone-Benchmark wird mit dem Argument 100000,der Dhrystone-Benchmark mit demArgument 10000000 fur die Anzahl der Iterationen aufgerufen. Das Benchmark-Script benchmark.shdurchlauft alle Benchmarks funf mal, um Messabweichungen durch Mittelwertbildung der Ergeb-nisse auszugleichen.

Script benchmark-stone.sh :

#!/bin/sh

i=1

while [ $i -le 5 ] # Schleife 5x durchlaufen

do

#whetstone

./whetdc_3.4.5_no_opt 100000 >> result_whetdc_3.4.5_no_opt.dat

./whetdc_4.0.2_no_opt 100000 >> result_whetdc_4.0.2_no_opt.dat

./whetdc_3.4.5_opt 100000 >> result_whetdc_3.4.5_no_opt.dat

./whetdc_4.0.2_opt 100000 >> result_whetdc_4.0.2_no_opt.dat

#dhrystone

./dhry_3.4.5_no_opt 10000000 >> result_dhry_3.4.5_no_opt.dat

./dhry_4.0.2_no_opt 10000000 >> result_dhry_4.0.2_no_opt.dat

./dhry_3.4.5_opt 10000000 >> result_dhry_3.4.5_no_opt.dat

./dhry_4.0.2_opt 10000000 >> result_dhry_2.0.2_no_opt.dat

i=‘expr $i + 1‘

done

Aufruf:

sh benchmark-stone.sh

Version 1.1 49

Page 50: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

6.2 Whetstone und Dhrystone

Die Ergebnisse fur die Benchmarks Whetstone und Dhrystone, mit gcc-3.4.5 kompiliert, sind aufder Abbildung 6.1 fur x86- und SPARC-Architektur dargestellt.

Abbildung 6.1: Ergebnisse Whetstone und Dhrystone mit gcc-3.4.5

Der Whetstone-Benchmark erreicht bei der SPARC-Architektur weniger MIPS als bei der x86-Architektur, was auf den geringeren Cache-Durchsatz (hier noch vermutet, mit CacheBench be-wiesen) und einer weniger guten Optimierung des Source Codes zuruckzufuhren ist.Die in den Abbildungen dargestellten Werte fur den Dhrystone-Benchmark sind in x1000 Dhrysto-nes/Sekunde angegeben und erreichen mit der SPARC-Architektur deutlich mehr Dhrystones/s alsbei der x86-Architektur. Dies konnte durch die hohere Anzahl der Integer-Units bei der SPARC-Architektur (SPARC = 4, x86 = 2) beeinflusst worden sein.

Um unterschiedliche Optimierungen durch den Compiler fur die einzelnen Architekturen beweisenzu konnen, wurden die Benchmarks Whetstone und Dhrystone mit dem Compiler gcc-4.0.2 erneutkompiliert und ausgefuhrt.

Version 1.1 50

Page 51: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

6.2 Whetstone und Dhrystone

Die folgenden Ergebnisse auf den Abbildungen 6.2 und 6.3 zeigen deutlich, dass die Optimierungendurch den neuen Compiler (gcc-4.0.2) fur beide Architekturen unterschiedlich ausfallen:

x86: Beide Benchmarks erzielen durch den neuen Compiler eine Beschleunigung um etwa 7%. Hierist deutlich sichtbar, dass der Compiler gcc in unterschiedlichen Versionen den Source Codefur den x86 in etwa gleich gut optimiert:Nur der Benchmark Whetstone (kompiliert mit gcc-4.0.2 ohne Optimierung) ist schlechterals der mit gcc-3.4.5 kompiliert. Dies konnte an dem neuen Framework bei der gcc-4.0.2 (wiein Abschnitt 6.1.3 beschrieben) liegen.

Abbildung 6.2: Ergebnisse x86 Whetstone und Dhrystone

Version 1.1 51

Page 52: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

6.2 Whetstone und Dhrystone

SPARC: Bei der SPARC-Architektur ist das Ergebnis unterschiedlich. Der Whetstone-Benchmarkfallt um 41,2% hoher aus als mit der gcc-3.4.5 Version, wahrend der Dhrystone-Benchmarkum 8,4% langsamer ausfallt.Offenbar ist fur die SPARC-Architektur noch Optimierungspotential mit dem Compiler gccvorhanden.Wie in Abschnitt 6.1.3 beschrieben, ist mit der gcc-4.0.2 Version ein komplett neues Fra-mework erstellt worden. Dieses Framework bewirkt anscheinend einen systematischen Fehlerbei dem Benchmark Dhrystone, da beide Benchmarkergebnisse (mit und ohne Optimierung)jeweils um fast gleich, namlich 8,4%, langsamer ausfallen.

Abbildung 6.3: Ergebnisse SPARC Whetstone und Dhrystone

Version 1.1 52

Page 53: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

6.2 Whetstone und Dhrystone

Nachfolgend sind noch einmal die beiden Benchmarkprogramme Whetstone und Dhrystone (mitgcc-4.0.2 kompiliert) der beiden Architekturen in Abbildung 6.4 dargestellt.Der Leistungsunterschied betragt bei dem Whetstone-Benchmark zwischen den beiden Architektu-ren nur wenige MIPS, wahrend der Dhrystone-Benchmark die schlechtere Optimierung des SourceCodes bei der SPARC-Architektur gegenuber der x86-Architektur verdeutlicht.

Abbildung 6.4: Ergebnisse Whetstone und Dhrystone mit gcc-4.0.2

Version 1.1 53

Page 54: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

6.2 Whetstone und Dhrystone

Die Abbildung 6.5 zeigt zusammenfassend die Beschleunigungsfaktoren des alten Compilers (gcc-3.4.5) gegenuber des neuen Compilers (gcc-4.0.2) fur die optimierten und nicht optimierten SourceCodes der Whetstone- und Dhrystone-Benchmarks.

Abbildung 6.5: Beschleunigungsfaktoren Whetstone und Dhrystone

Version 1.1 54

Page 55: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

6.3 1000s und 1000d

6.3 1000s und 1000d

Mit den Benchmarks 1000s und 1000d werden die single- und double-precision Rechenge-schwindigkeiten in MFLOPS gemessen. Wie auch bei den Whet- und Dhrystone-Benchmarks wer-den die Source Codes von 1000s und 1000d einmal mit und ohne Compiler-Optimierung kompiliert.Dabei wird der Compiler gcc-3.4.5 verwendet.

Das folgende Benchmark-Script fuhrt die Benchmarks 1000s und 1000d nacheinander mit jeweilsCompiler-Optimierten und nicht optimierten Binaries aus. Die Ergebnisse werden in ASCII-Dateiengeschrieben.

Script benchmark-1000.sh :

#!/bin/sh

./1000s_3.4.5_no_opt >> result_1000s_3.4.5_no_opt.dat

./1000s_3.4.5_opt >> result_1000s_3.4.5_opt.dat

./1000d_3.4.5_no_opt >> result_1000s_3.4.5_no_opt.dat

./1000d_3.4.5_opt >> result_1000s_3.4.5_opt.dat

Aufruf:

sh benchmark-1000.sh

Die Ergebnisse der single- (32-Bit) und double-precision (64-Bit) Berechnungen sind in Abbildung6.6 dargestellt.

Version 1.1 55

Page 56: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

6.3 1000s und 1000d

In der Abbildung 6.6 ist erkennbar, dass die SPARC-Architektur schneller in single-precision rech-net als die x86-Architektur. Im Gegensatz dazu rechnet die x86-Architektur mit double-precisionschneller als die SPARC-Architektur.Hier wird spekuliert, dass das unterschiedliche Ergebnis an dem L1- und L2-Cache liegen konnte.Weitere Ergebnisse in Bezug auf die Cache-Geschwindigkeiten sollen die folgenden Benchmarks,BLASBench und CacheBench, liefern.

Abbildung 6.6: Ergebnisse 1000s und 1000d

Version 1.1 56

Page 57: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

6.4 BLASBench

6.4 BLASBench

Das Benchmarkprogramm BLASBench bestimmt mit den Routinen xAXPY, xGEMV, xGEMM in single-

und double-precision fur verschiedene Vektorgroßen den Datendurchsatz. Bis zu einer Vektor-große von 256 KByte (SPARC) oder 512 KByte (x86) ist zu erwarten, dass die Daten fur dieBerechnungen vorwiegend in und aus den L1-Cache bzw. L2-Cache geschrieben und gelesen wer-den.

Die einzelnen Messungen werden nacheinander mit folgendem Script durchgefuhrt. Die Ergebnissewerden in ASCII-Dateien geschrieben.

Script blasbench.sh :

#!/bin/sh

# Messung in double

./vblasbench -m20 -x0 -e1 -i10000 -c > result_blasbench_3.4.5_double.dat

# Messung in single

./vblasbench -m20 -x0 -e1 -i10000 -c -s > result_blasbench_3.4.5_single.dat

Parameter:

• -m20: Maximale Vektorgroße 220 Bytes

• -x0: Anzahl der Messpunkte zwischen den Vektorlangen

• -e1: Anzahl Durchlaufe (1 Durchlauf = -i Iterationen) pro Vektorlange

• -i10000: Anzahl der Iterationen pro Vektorlange

• -c: Konstante Anzahl Iterationen pro Vektorlange

• -s: Single-precision (keinen Parameter fur double-precision)

Aufruf:

# sh blasbench.sh

Version 1.1 57

Page 58: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

6.4 BLASBench

Nachfolgend ist das Ergebnis der Messung von SAXPY dargestellt. Wie in der Grafik ersichtlich,ist die Performance des x86 uber samtliche Vektorlangen bedeutend hoher als bei der SPARC.Der Benchmark bricht bei dem x86 das erste mal nach 16 KByte Vektorlange und das zweite malbei 512 KByte Vektorlange ein. Dies ist auch so zu erwarten, da der x86 einen 16 KByte großenL1-Cache und einen 512 KByte großen L2-Cache besitzt.Da die Bandbreite der SPARC fast durchweg konstant bleibt, konnte man spekulieren, dass derCompiler den Source Code fur die Benutzung des L1-Cache nicht optimal kompiliert.

Abbildung 6.7: Ergebnis BLASBench SAXPY

Version 1.1 58

Page 59: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

6.4 BLASBench

Nachfolgend ist das Ergebnis der Messung von SGEMV dargestellt. Wie in der Grafik ersichtlich,ist die Performance beider Prozessoren bis zu einer Vektorgroße von 16 KByte annahernd gleich.Danach fallt die SPARC von der Performance her sehr viel starker ab als bei dem x86.Der Grund dafur konnte ebenfalls, wie oben schon erwahnt, der schlechtere Zugriff auf den L1-Cache der SPARC sein.

Abbildung 6.8: Ergebnis BLASBench SGEMV

Version 1.1 59

Page 60: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

6.4 BLASBench

Die nachfolgende Grafik zeigt das Ergebnis des BLASBench SGEMM. Das Ergebnis ist ahnlichder beiden vorherigen Ergebnissen, jedenfalls bis zu einer Vektorlange von 16 KByte betrachtet.Ab 16 KByte ist die Perfomance der SPARC bedeutend hoher als bei dem x86. Dies ist hierbesonders auffallig, da bei den vorherigen Ergebnissen gerade die SPARC eingebrochen ist. Hierfureine Losung zu finden ware hoch spekulativ, deshalb bleibt das Ergebnis unkommentiert.

Abbildung 6.9: Ergebnis BLASBench SGEMM

Version 1.1 60

Page 61: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

6.4 BLASBench

Nachfolgend ist das Ergebnis der Messung von DAXPY dargestellt. Die Perfomance des x86 isthoher als bei der SPARC, wobei der Performanceunterschied zwischen der SPARC und dem x86bei den verschiedenen Vektorlangen ungefahr gleich bleibt.

Abbildung 6.10: Ergebnis BLASBench DAXPY

Version 1.1 61

Page 62: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

6.4 BLASBench

Nachfolgend ist das Ergebnis der Messung von DGEMV dargestellt. Die Perfomance des x86 isthoher als bei der SPARC, wobei der Performanceunterschied zwischen der SPARC und dem x86bei den verschiedenen Vektorlangen ungefahr gleich bleibt.

Abbildung 6.11: Ergebnis BLASBench DGEMV

Version 1.1 62

Page 63: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

6.4 BLASBench

Nachfolgend ist das Ergebnis der Messung von DGEMM dargestellt. Die Perfomance des x86 isthoher als bei der SPARC, wobei der Performanceunterschied zwischen der SPARC und dem x86bei den verschiedenen Vektorlangen ungefahr gleich bleibt.

Abbildung 6.12: Ergebnis BLASBench DGEMM

Version 1.1 63

Page 64: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

6.5 CacheBench

6.5 CacheBench

Das Benchmarkprogramm BLASBench bestimmt mit den Routinen read/modify/write, read

und write, in single- und double-precision fur verschiedene Vektorgroßen den Datendurch-satz. Hierbei wird hauptsachlich der Datendurchsatz des L1- und L2-Cache bestimmt.Die Dauer der einzelnen Messungen betragt 10 Sekunden (-d10) fur jede Vektorlange und wer-den nacheinander mit folgendem Script durchgefuhrt. Die Ergebnisse werden in ASCII-Dateiengeschrieben.

Script cachebench.sh :

#!/bin/sh

# Messung in single

# read

./cachebench_single -m20 -x0 -e1 -d10 -r >> result_cachbench_3.4.5_single.dat

# write

./cachebench_single -m20 -x0 -e1 -d10 -w >> result_cachbench_3.4.5_single.dat

# read modify write

./cachebench_single -m20 -x0 -e1 -d10 -b >> result_cachbench_3.4.5_single.dat

# hand tuned read

./cachebench_single -m20 -x0 -e1 -d10 -tr >> result_cachbench_3.4.5_single.dat

# hand tuned write

./cachebench_single -m20 -x0 -e1 -d10 -tw >> result_cachbench_3.4.5_single.dat

# hand tuned read modify write

./cachebench_single -m20 -x0 -e1 -d10 -tb >> result_cachbench_3.4.5_single.dat

# Messung in double

# read

./cachebench_double -m20 -x0 -e1 -d10 -r >> result_cachbench_3.4.5_double.dat

# write

./cachebench_double -m20 -x0 -e1 -d10 -w >> result_cachbench_3.4.5_double.dat

# read modify write

./cachebench_double -m20 -x0 -e1 -d10 -b >> result_cachbench_3.4.5_double.dat

# hand tuned read

./cachebench_double -m20 -x0 -e1 -d10 -tr >> result_cachbench_3.4.5_double.dat

# hand tuned write

./cachebench_double -m20 -x0 -e1 -d10 -tw >> result_cachbench_3.4.5_double.dat

# hand tuned read modify write

./cachebench_double -m20 -x0 -e1 -d10 -tb >> result_cachbench_3.4.5_double.dat

Parameter:

• -m20: Maximale Vektorgroße 220 Bytes

• -x0: Anzahl der Messpunkte zwischen den Vektorlangen

• -e1: Anzahl Durchlaufe pro Vektorlange

Version 1.1 64

Page 65: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

6.5 CacheBench

• -d10: Berechnungszeit pro Vektorlange

• -r: Read

• -w: Write

• -b: Read/modify/write

• -tr/-tw/-tb: Jeweils handtuned-Version

Aufruf:

# sh cachebench.sh

Die Messergebnisse variierten bei den einzelnen Messungen sehr stark. Die Ursachen fur dieseSchwankungen konnten leider nicht ermittelt werden. Deswegen sind die nachfolgenden Ergebnissenicht weiter kommentiert, aber der Vollstandigkeit halber mit aufgefuhrt.

Abbildung 6.13: Ergebnis CacheBench read single vs. double

Version 1.1 65

Page 66: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

6.5 CacheBench

Abbildung 6.14: Ergebnis CacheBench write single vs. double

Abbildung 6.15: Ergebnis CacheBench read/modify/write single vs. double

Version 1.1 66

Page 67: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

6.5 CacheBench

Abbildung 6.16: Ergebnis CacheBench handtuned read single vs. double

Abbildung 6.17: Ergebnis CacheBench handtuned write single vs. double

Version 1.1 67

Page 68: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

6.5 CacheBench

Abbildung 6.18: Ergebnis CacheBench handtuned read/modify/write single vs. double

Version 1.1 68

Page 69: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

7 Zusammenfassung

Abschließend sind die Ergebnisse der einzelnen Benchmarks zusammengefasst. Die Abbildung 7.1zeigt die Ubersicht der verwendeten Benchmarks und die entsprechenden Ergebnisse mit den fol-genden Tendenzen:

++ bedeutend schneller gegenuber der anderen Architektur

+ etwas schneller gegenuber der anderen Architektur

• etwa gleiche Geschwindigkeit

- etwas langsamer gegenuber der anderen Architektur

-- bedeutend langsamer gegenuber der anderen Architektur

Abbildung 7.1: Zusammenfassung Benchmarkergebnisse

Anhand der Gewichtung in der Tabelle konnte man sagen, dass die SPARC-Architektur bei Whet-stone und Dhrystone bessere Ergebnisse als die x86-Architektur liefert und alle anderen Bench-markergebnisse von der x86-Architektur dominiert wurden.Es ist leider nicht eindeutig geklart, welche Architektur schneller ist. Eine globale Aussage kannaus den folgenden Grunden nicht getroffen werden:

• Trotz der Versuche, die Source Codes optimal zu kompilieren, ist das Ergebnis sehr unter-schiedlich ausgefallen. Je nach Compiler-Version wurden die Benchmarkprogramme gut oderweniger gut optimiert, was sich in den Benchmarkergebnissen eindeutig widerspiegelt.

Version 1.1 69

Page 70: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

7 Zusammenfassung

• Eine unterschiedliche Gewichtung der Rechenroutinen in den Benchmarkprogrammen kanndie eine oder die andere Architektur benach- oder bevorteilen.

• Benchmarks allgemein sind zu leicht beeinflussbar, man denke dabei an die moglichen Opti-mierungsgrade der Compiler; also ist eine ausfuhrbare Datei als Benchmarkprogramm volligungeeignet, da nicht nachvollziehbar ist, fur welches System oder CPU dieser Benchmarkoptimiert wurde.

Version 1.1 70

Page 71: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

Literaturverzeichnis

[SUN97] UltraSPARC-IIi - Users Manualhttp://www.sun.com/processors/manuals/805-0087.pdf, 13.01.2007

[INT05-1] IA32 Architecture Software Developer’s Manualhttp://www.intel.com/design/pentiumii/manuals/243190.htm, 26.02.2006

[INT05-2] Pentium II Processor Developer’s Manualhttp://support.intel.com/design/pentiumii/manuals/243502.htm, 26.02.2006

[INT05-3] Intel Architecture MMX Technology in Business Applicationshttp://support.intel.com/design/pentiumii/papers/243367.htm, 26.02.2006

[CL06] Pentium II - Implementationhttp://www.sandpile.org/impl/p2.htm, 26.02.2006

[JS05] Intel P6-Familiehttp://csd.ijs.si/courses/processor/Chapter4/sld104.htm, 13.01.2007

[JD05] BLAS - Basic Linear Algebra Subprogramshttp://www.netlib.org/blas/, 18.03.2006

[JD84] LINPACK / LAPACKhttp://www.netlib.org/linpack/, 18.03.2006http://www.netlib.org/lapack/, 18.03.2006

[JD92] LINPACK 1000x1000 Benchmarkhttp://www.netlib.org/benchmark/1000s, 18.03.2006http://www.netlib.org/benchmark/1000d, 18.03.2006

[PM06] LLCbench - Low Level Architectural Characterization Benchmarkhttp://icl.cs.utk.edu/projects/llcbench/, 22.03.2006

[GCC-1] GCC - GNU Compiler Collectionhttp://gcc.gnu.org/, 22.03.2006gcc-3.4.5:http://gcc.gnu.org/onlinedocs/gcc-3.4.5/gcc/i386-and-x86_002d64-Options.

html, 22.03.2006http://gcc.gnu.org/onlinedocs/gcc-3.4.5/gcc/SPARC-Options.html, 22.03.2006gcc-4.0.2:http://gcc.gnu.org/onlinedocs/gcc-4.0.2/gcc/i386-and-x86_002d64-Options.

html, 22.03.2006

Version 1.1 71

Page 72: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

Literaturverzeichnis

http://gcc.gnu.org/onlinedocs/gcc-4.0.2/gcc/SPARC-Options.html, 22.03.2006

[GCC-2] GCC - Compiler-Optimierungenhttp://gcc.gnu.org/onlinedocs/gcc-3.4.5/gcc/Optimize-Options.html#

Optimize-Options, 14.01.2007http://gcc.gnu.org/onlinedocs/gcc-4.0.2/gcc/Optimize-Options.html#

Optimize-Options, 14.01.2007

[GCC-3] GCC - Compiler-Versionen und Optimierungenhttp://gcc.gnu.org/gcc-3.4/changes.html, 14.01.2007http://gcc.gnu.org/gcc-4.0/changes.html, 14.01.2007

[GENTOO] Gentoo - Gentoo Linux Handbookhttp://www.gentoo.org/doc/en/handbook/handbook-x86.xml, 17.03.2006http://www.gentoo.org/doc/en/handbook/handbook-sparc.xml, 17.03.2006

[AB97] Whetstone-Benchmarkhttp://www.tux.org/~balsa/linux/benchmarking/articles/html/Article1d-3.

html, 17.03.2006

[RW88] Dhrystone-Benchmarkhttp://performance.netlib.org/performance/html/dhrystone.intro.html,13.01.2007 http://performance.netlib.org/benchmark/dhry-c, 13.01.2007

Version 1.1 72

Page 73: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8 Anhang

8.1 Kernel-Config x86

x86# cat /usr/src/linux/.config:

CONFIG_X86=y

CONFIG_MMU=y

CONFIG_UID16=y

CONFIG_GENERIC_ISA_DMA=y

CONFIG_GENERIC_IOMAP=y

CONFIG_EXPERIMENTAL=y

CONFIG_CLEAN_COMPILE=y

CONFIG_BROKEN_ON_SMP=y

CONFIG_LOCK_KERNEL=y

CONFIG_INIT_ENV_ARG_LIMIT=32

CONFIG_LOCALVERSION=""

CONFIG_SWAP=y

CONFIG_SYSVIPC=y

CONFIG_POSIX_MQUEUE=y

CONFIG_SYSCTL=y

CONFIG_AUDIT=y

CONFIG_AUDITSYSCALL=y

CONFIG_HOTPLUG=y

CONFIG_KOBJECT_UEVENT=y

CONFIG_KALLSYMS=y

CONFIG_PRINTK=y

CONFIG_BUG=y

CONFIG_BASE_FULL=y

CONFIG_FUTEX=y

CONFIG_EPOLL=y

CONFIG_SHMEM=y

CONFIG_CC_ALIGN_FUNCTIONS=0

CONFIG_CC_ALIGN_LABELS=0

CONFIG_CC_ALIGN_LOOPS=0

CONFIG_CC_ALIGN_JUMPS=0

CONFIG_BASE_SMALL=0

CONFIG_MODULES=y

CONFIG_MODULE_UNLOAD=y

Version 1.1 73

Page 74: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.1 Kernel-Config x86

CONFIG_OBSOLETE_MODPARM=y

CONFIG_KMOD=y

CONFIG_X86_PC=y

CONFIG_MPENTIUMII=y

CONFIG_X86_CMPXCHG=y

CONFIG_X86_XADD=y

CONFIG_X86_L1_CACHE_SHIFT=5

CONFIG_RWSEM_XCHGADD_ALGORITHM=y

CONFIG_GENERIC_CALIBRATE_DELAY=y

CONFIG_X86_WP_WORKS_OK=y

CONFIG_X86_INVLPG=y

CONFIG_X86_BSWAP=y

CONFIG_X86_POPAD_OK=y

CONFIG_X86_GOOD_APIC=y

CONFIG_X86_INTEL_USERCOPY=y

CONFIG_X86_USE_PPRO_CHECKSUM=y

CONFIG_PREEMPT=y

CONFIG_PREEMPT_BKL=y

CONFIG_X86_TSC=y

CONFIG_X86_MCE=y

CONFIG_NOHIGHMEM=y

CONFIG_SELECT_MEMORY_MODEL=y

CONFIG_FLATMEM_MANUAL=y

CONFIG_FLATMEM=y

CONFIG_FLAT_NODE_MEM_MAP=y

CONFIG_MTRR=y

CONFIG_HAVE_DEC_LOCK=y

CONFIG_SECCOMP=y

CONFIG_HZ_250=y

CONFIG_HZ=250

CONFIG_PHYSICAL_START=0x100000

CONFIG_PM=y

CONFIG_SOFTWARE_SUSPEND=y

CONFIG_PM_STD_PARTITION=""

CONFIG_ACPI=y

CONFIG_ACPI_BOOT=y

CONFIG_ACPI_INTERPRETER=y

CONFIG_ACPI_SLEEP=y

CONFIG_ACPI_SLEEP_PROC_FS=y

CONFIG_ACPI_AC=y

CONFIG_ACPI_BATTERY=y

CONFIG_ACPI_BUTTON=y

CONFIG_ACPI_VIDEO=m

CONFIG_ACPI_FAN=y

CONFIG_ACPI_PROCESSOR=y

Version 1.1 74

Page 75: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.1 Kernel-Config x86

CONFIG_ACPI_THERMAL=y

CONFIG_ACPI_IBM=m

CONFIG_ACPI_BLACKLIST_YEAR=0

CONFIG_ACPI_BUS=y

CONFIG_ACPI_EC=y

CONFIG_ACPI_POWER=y

CONFIG_ACPI_PCI=y

CONFIG_ACPI_SYSTEM=y

CONFIG_PCI=y

CONFIG_PCI_GOANY=y

CONFIG_PCI_BIOS=y

CONFIG_PCI_DIRECT=y

CONFIG_PCI_MMCONFIG=y

CONFIG_PCI_LEGACY_PROC=y

CONFIG_PCI_NAMES=y

CONFIG_ISA_DMA_API=y

CONFIG_ISA=y

CONFIG_BINFMT_ELF=y

CONFIG_BINFMT_AOUT=y

CONFIG_BINFMT_MISC=y

CONFIG_NET=y

CONFIG_PACKET=y

CONFIG_UNIX=y

CONFIG_INET=y

CONFIG_IP_MULTICAST=y

CONFIG_IP_FIB_HASH=y

CONFIG_IP_TCPDIAG=y

CONFIG_TCP_CONG_BIC=y

CONFIG_NETFILTER=y

CONFIG_IP_NF_CONNTRACK=y

CONFIG_IP_NF_QUEUE=y

CONFIG_IP_NF_IPTABLES=y

CONFIG_IP_NF_MATCH_LIMIT=y

CONFIG_IP_NF_MATCH_IPRANGE=y

CONFIG_IP_NF_MATCH_MAC=y

CONFIG_IP_NF_MATCH_PKTTYPE=y

CONFIG_IP_NF_MATCH_MARK=y

CONFIG_IP_NF_MATCH_MULTIPORT=y

CONFIG_IP_NF_MATCH_TOS=y

CONFIG_IP_NF_MATCH_RECENT=y

CONFIG_IP_NF_MATCH_ECN=y

CONFIG_IP_NF_MATCH_DSCP=y

CONFIG_IP_NF_MATCH_AH_ESP=y

CONFIG_IP_NF_MATCH_LENGTH=y

CONFIG_IP_NF_MATCH_TTL=y

Version 1.1 75

Page 76: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.1 Kernel-Config x86

CONFIG_IP_NF_MATCH_TCPMSS=y

CONFIG_IP_NF_MATCH_HELPER=y

CONFIG_IP_NF_MATCH_STATE=y

CONFIG_IP_NF_MATCH_CONNTRACK=y

CONFIG_IP_NF_MATCH_OWNER=y

CONFIG_IP_NF_FILTER=y

CONFIG_IP_NF_TARGET_REJECT=y

CONFIG_IP_NF_TARGET_LOG=y

CONFIG_IP_NF_TARGET_ULOG=y

CONFIG_IP_NF_TARGET_TCPMSS=y

CONFIG_IP_NF_NAT=y

CONFIG_IP_NF_NAT_NEEDED=y

CONFIG_IP_NF_TARGET_MASQUERADE=y

CONFIG_IP_NF_TARGET_REDIRECT=y

CONFIG_IP_NF_TARGET_NETMAP=y

CONFIG_IP_NF_TARGET_SAME=y

CONFIG_IP_NF_MANGLE=y

CONFIG_IP_NF_TARGET_TOS=y

CONFIG_IP_NF_TARGET_ECN=y

CONFIG_IP_NF_TARGET_DSCP=y

CONFIG_IP_NF_TARGET_MARK=y

CONFIG_IP_NF_TARGET_CLASSIFY=y

CONFIG_IP_NF_RAW=m

CONFIG_IP_NF_TARGET_NOTRACK=m

CONFIG_IP_NF_ARPTABLES=y

CONFIG_IP_NF_ARPFILTER=y

CONFIG_IP_NF_ARP_MANGLE=y

CONFIG_STANDALONE=y

CONFIG_PREVENT_FIRMWARE_BUILD=y

CONFIG_FW_LOADER=m

CONFIG_PARPORT=y

CONFIG_PARPORT_PC=y

CONFIG_PNP=y

CONFIG_PNPACPI=y

CONFIG_BLK_DEV_FD=y

CONFIG_BLK_DEV_RAM_COUNT=16

CONFIG_INITRAMFS_SOURCE=""

CONFIG_LBD=y

CONFIG_IOSCHED_NOOP=y

CONFIG_IOSCHED_AS=y

CONFIG_IOSCHED_DEADLINE=y

CONFIG_IOSCHED_CFQ=y

CONFIG_IDE=y

CONFIG_BLK_DEV_IDE=y

CONFIG_BLK_DEV_IDEDISK=y

Version 1.1 76

Page 77: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.1 Kernel-Config x86

CONFIG_IDEDISK_MULTI_MODE=y

CONFIG_BLK_DEV_IDECD=y

CONFIG_IDE_GENERIC=y

CONFIG_BLK_DEV_IDEPCI=y

CONFIG_IDEPCI_SHARE_IRQ=y

CONFIG_BLK_DEV_GENERIC=y

CONFIG_BLK_DEV_IDEDMA_PCI=y

CONFIG_IDEDMA_PCI_AUTO=y

CONFIG_BLK_DEV_PIIX=y

CONFIG_BLK_DEV_IDEDMA=y

CONFIG_IDEDMA_AUTO=y

CONFIG_SCSI=y

CONFIG_SCSI_DPT_I2O=m

CONFIG_SCSI_SATA=y

CONFIG_SCSI_ATA_PIIX=y

CONFIG_SCSI_SATA_SX4=m

CONFIG_SCSI_SATA_SIS=m

CONFIG_SCSI_IPR=m

CONFIG_SCSI_QLA2XXX=y

CONFIG_NETDEVICES=y

CONFIG_DUMMY=m

CONFIG_TUN=m

CONFIG_NET_ETHERNET=y

CONFIG_MII=y

CONFIG_NET_PCI=y

CONFIG_8139TOO=y

CONFIG_8139TOO_PIO=y

CONFIG_INPUT=y

CONFIG_INPUT_MOUSEDEV=y

CONFIG_INPUT_MOUSEDEV_PSAUX=y

CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024

CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768

CONFIG_INPUT_KEYBOARD=y

CONFIG_KEYBOARD_ATKBD=y

CONFIG_INPUT_MOUSE=y

CONFIG_MOUSE_PS2=y

CONFIG_SERIO=y

CONFIG_SERIO_I8042=y

CONFIG_SERIO_LIBPS2=y

CONFIG_VT=y

CONFIG_VT_CONSOLE=y

CONFIG_HW_CONSOLE=y

CONFIG_SERIAL_8250=y

CONFIG_SERIAL_8250_NR_UARTS=4

CONFIG_SERIAL_CORE=y

Version 1.1 77

Page 78: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.1 Kernel-Config x86

CONFIG_UNIX98_PTYS=y

CONFIG_LEGACY_PTYS=y

CONFIG_LEGACY_PTY_COUNT=256

CONFIG_PRINTER=y

CONFIG_AGP=y

CONFIG_AGP_INTEL=y

CONFIG_VGA_CONSOLE=y

CONFIG_DUMMY_CONSOLE=y

CONFIG_SPEAKUP_DEFAULT="none"

CONFIG_USB_ARCH_HAS_HCD=y

CONFIG_USB_ARCH_HAS_OHCI=y

CONFIG_EXT2_FS=y

CONFIG_EXT3_FS=y

CONFIG_EXT3_FS_XATTR=y

CONFIG_JBD=y

CONFIG_FS_MBCACHE=y

CONFIG_REISERFS_FS=y

CONFIG_INOTIFY=y

CONFIG_DNOTIFY=y

CONFIG_AUTOFS4_FS=y

CONFIG_ISO9660_FS=y

CONFIG_JOLIET=y

CONFIG_UDF_FS=y

CONFIG_UDF_NLS=y

CONFIG_FAT_FS=y

CONFIG_MSDOS_FS=y

CONFIG_VFAT_FS=y

CONFIG_FAT_DEFAULT_CODEPAGE=437

CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"

CONFIG_PROC_FS=y

CONFIG_PROC_KCORE=y

CONFIG_SYSFS=y

CONFIG_TMPFS=y

CONFIG_RAMFS=y

CONFIG_NFS_FS=y

CONFIG_NFSD=y

CONFIG_NFSD_TCP=y

CONFIG_LOCKD=y

CONFIG_EXPORTFS=y

CONFIG_NFS_COMMON=y

CONFIG_SUNRPC=y

CONFIG_MSDOS_PARTITION=y

CONFIG_NLS=y

CONFIG_NLS_DEFAULT="iso8859-1"

CONFIG_NLS_CODEPAGE_437=y

Version 1.1 78

Page 79: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.1 Kernel-Config x86

CONFIG_NLS_ISO8859_1=y

CONFIG_PROFILING=y

CONFIG_OPROFILE=y

CONFIG_LOG_BUF_SHIFT=14

CONFIG_DEBUG_BUGVERBOSE=y

CONFIG_EARLY_PRINTK=y

CONFIG_CRC32=y

CONFIG_LIBCRC32C=m

CONFIG_GENERIC_HARDIRQS=y

CONFIG_GENERIC_IRQ_PROBE=y

CONFIG_X86_BIOS_REBOOT=y

CONFIG_PC=y

Version 1.1 79

Page 80: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.2 Kernel-Config SPARC

8.2 Kernel-Config SPARC

sun# cat /usr/src/linux/.config:

CONFIG_SPARC64=y

CONFIG_64BIT=y

CONFIG_MMU=y

CONFIG_GENERIC_ISA_DMA=y

CONFIG_TIME_INTERPOLATION=y

CONFIG_EXPERIMENTAL=y

CONFIG_CLEAN_COMPILE=y

CONFIG_BROKEN_ON_SMP=y

CONFIG_INIT_ENV_ARG_LIMIT=32

CONFIG_LOCALVERSION=""

CONFIG_SWAP=y

CONFIG_SYSVIPC=y

CONFIG_POSIX_MQUEUE=y

CONFIG_SYSCTL=y

CONFIG_HOTPLUG=y

CONFIG_KOBJECT_UEVENT=y

CONFIG_KALLSYMS=y

CONFIG_PRINTK=y

CONFIG_BUG=y

CONFIG_BASE_FULL=y

CONFIG_FUTEX=y

CONFIG_EPOLL=y

CONFIG_SHMEM=y

CONFIG_CC_ALIGN_FUNCTIONS=0

CONFIG_CC_ALIGN_LABELS=0

CONFIG_CC_ALIGN_LOOPS=0

CONFIG_CC_ALIGN_JUMPS=0

CONFIG_BASE_SMALL=0

CONFIG_MODULES=y

CONFIG_MODULE_UNLOAD=y

CONFIG_OBSOLETE_MODPARM=y

CONFIG_KMOD=y

CONFIG_SYSVIPC_COMPAT=y

CONFIG_SPARC64_PAGE_SIZE_8KB=y

CONFIG_SECCOMP=y

CONFIG_HZ_250=y

CONFIG_HZ=250

CONFIG_GENERIC_CALIBRATE_DELAY=y

CONFIG_HUGETLB_PAGE_SIZE_4MB=y

CONFIG_RWSEM_XCHGADD_ALGORITHM=y

CONFIG_SELECT_MEMORY_MODEL=y

Version 1.1 80

Page 81: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.2 Kernel-Config SPARC

CONFIG_FLATMEM_MANUAL=y

CONFIG_FLATMEM=y

CONFIG_FLAT_NODE_MEM_MAP=y

CONFIG_SBUS=y

CONFIG_SUN_AUXIO=y

CONFIG_SUN_IO=y

CONFIG_PCI=y

CONFIG_PCI_DOMAINS=y

CONFIG_BINFMT_ELF=y

CONFIG_SPARC32_COMPAT=y

CONFIG_COMPAT=y

CONFIG_UID16=y

CONFIG_BINFMT_ELF32=y

CONFIG_NET=y

CONFIG_PACKET=y

CONFIG_PACKET_MMAP=y

CONFIG_UNIX=y

CONFIG_INET=y

CONFIG_IP_FIB_HASH=y

CONFIG_TCP_CONG_BIC=y

CONFIG_IP_SCTP=m

CONFIG_SCTP_HMAC_MD5=y

CONFIG_STANDALONE=y

CONFIG_FW_LOADER=m

CONFIG_BLK_DEV_LOOP=m

CONFIG_BLK_DEV_RAM_COUNT=16

CONFIG_INITRAMFS_SOURCE=""

CONFIG_IOSCHED_NOOP=y

CONFIG_IOSCHED_AS=y

CONFIG_IOSCHED_DEADLINE=y

CONFIG_IOSCHED_CFQ=y

CONFIG_IDE=y

CONFIG_BLK_DEV_IDE=y

CONFIG_BLK_DEV_IDEDISK=y

CONFIG_BLK_DEV_IDECD=y

CONFIG_IDE_GENERIC=y

CONFIG_BLK_DEV_IDEPCI=y

CONFIG_BLK_DEV_IDEDMA_PCI=y

CONFIG_IDEDMA_PCI_AUTO=y

CONFIG_IDEDMA_ONLYDISK=y

CONFIG_BLK_DEV_CMD64X=y

CONFIG_BLK_DEV_IDEDMA=y

CONFIG_IDEDMA_AUTO=y

CONFIG_SCSI=m

CONFIG_SCSI_QLA2XXX=m

Version 1.1 81

Page 82: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.2 Kernel-Config SPARC

CONFIG_NETDEVICES=y

CONFIG_NET_ETHERNET=y

CONFIG_MII=m

CONFIG_SUNLANCE=y

CONFIG_HAPPYMEAL=y

CONFIG_NET_TULIP=y

CONFIG_DE2104X=m

CONFIG_TULIP=m

CONFIG_TULIP_NAPI=y

CONFIG_TULIP_NAPI_HW_MITIGATION=y

CONFIG_DE4X5=m

CONFIG_WINBOND_840=m

CONFIG_INPUT=y

CONFIG_INPUT_MOUSEDEV=y

CONFIG_INPUT_MOUSEDEV_PSAUX=y

CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024

CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768

CONFIG_INPUT_EVDEV=y

CONFIG_INPUT_KEYBOARD=y

CONFIG_KEYBOARD_SUNKBD=y

CONFIG_INPUT_MOUSE=y

CONFIG_MOUSE_PS2=y

CONFIG_MOUSE_SERIAL=y

CONFIG_INPUT_MISC=y

CONFIG_SERIO=y

CONFIG_SERIO_I8042=y

CONFIG_SERIO_PCIPS2=y

CONFIG_SERIO_LIBPS2=y

CONFIG_VT=y

CONFIG_VT_CONSOLE=y

CONFIG_HW_CONSOLE=y

CONFIG_SERIAL_SUNCORE=y

CONFIG_SERIAL_SUNZILOG=y

CONFIG_SERIAL_SUNZILOG_CONSOLE=y

CONFIG_SERIAL_SUNSU=y

CONFIG_SERIAL_SUNSU_CONSOLE=y

CONFIG_SERIAL_SUNSAB=m

CONFIG_SERIAL_CORE=y

CONFIG_SERIAL_CORE_CONSOLE=y

CONFIG_UNIX98_PTYS=y

CONFIG_LEGACY_PTYS=y

CONFIG_LEGACY_PTY_COUNT=256

CONFIG_RTC=y

CONFIG_SUN_MOSTEK_RTC=y

CONFIG_ENVCTRL=m

Version 1.1 82

Page 83: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.2 Kernel-Config SPARC

CONFIG_DRM=y

CONFIG_DRM_R128=y

CONFIG_FB=y

CONFIG_FB_CFB_FILLRECT=y

CONFIG_FB_CFB_COPYAREA=y

CONFIG_FB_CFB_IMAGEBLIT=y

CONFIG_FB_SOFT_CURSOR=y

CONFIG_FB_MODE_HELPERS=y

CONFIG_FB_ATY128=y

CONFIG_FB_ATY=y

CONFIG_FB_ATY_CT=y

CONFIG_FB_PCI=y

CONFIG_PROM_CONSOLE=y

CONFIG_DUMMY_CONSOLE=y

CONFIG_FRAMEBUFFER_CONSOLE=y

CONFIG_FONTS=y

CONFIG_FONT_SUN8x16=y

CONFIG_FONT_SUN12x22=y

CONFIG_SPEAKUP_DEFAULT="none"

CONFIG_USB_ARCH_HAS_HCD=y

CONFIG_USB_ARCH_HAS_OHCI=y

CONFIG_SUN_OPENPROMIO=y

CONFIG_OBP_FLASH=y

CONFIG_EXT2_FS=y

CONFIG_EXT2_FS_XATTR=y

CONFIG_EXT2_FS_POSIX_ACL=y

CONFIG_EXT2_FS_SECURITY=y

CONFIG_EXT3_FS=y

CONFIG_EXT3_FS_XATTR=y

CONFIG_EXT3_FS_POSIX_ACL=y

CONFIG_EXT3_FS_SECURITY=y

CONFIG_JBD=y

CONFIG_FS_MBCACHE=y

CONFIG_REISERFS_FS=y

CONFIG_FS_POSIX_ACL=y

CONFIG_XFS_FS=m

CONFIG_XFS_QUOTA=y

CONFIG_XFS_SECURITY=y

CONFIG_XFS_POSIX_ACL=y

CONFIG_QUOTACTL=y

CONFIG_DNOTIFY=y

CONFIG_AUTOFS4_FS=y

CONFIG_ISO9660_FS=m

CONFIG_JOLIET=y

CONFIG_UDF_FS=m

Version 1.1 83

Page 84: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.2 Kernel-Config SPARC

CONFIG_UDF_NLS=y

CONFIG_FAT_FS=m

CONFIG_VFAT_FS=m

CONFIG_FAT_DEFAULT_CODEPAGE=437

CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"

CONFIG_PROC_FS=y

CONFIG_PROC_KCORE=y

CONFIG_SYSFS=y

CONFIG_DEVPTS_FS_XATTR=y

CONFIG_TMPFS=y

CONFIG_TMPFS_XATTR=y

CONFIG_TMPFS_SECURITY=y

CONFIG_HUGETLBFS=y

CONFIG_HUGETLB_PAGE=y

CONFIG_RAMFS=y

CONFIG_SUN_OPENPROMFS=y

CONFIG_MSDOS_PARTITION=y

CONFIG_SUN_PARTITION=y

CONFIG_NLS=y

CONFIG_NLS_DEFAULT="iso8859-1"

CONFIG_NLS_CODEPAGE_850=y

CONFIG_NLS_ISO8859_1=y

CONFIG_LOG_BUF_SHIFT=14

CONFIG_DEBUG_BUGVERBOSE=y

CONFIG_CRYPTO=y

CONFIG_CRYPTO_HMAC=y

CONFIG_CRYPTO_MD5=y

CONFIG_CRYPTO_DEFLATE=y

CONFIG_CRC_CCITT=m

CONFIG_CRC32=y

CONFIG_LIBCRC32C=m

CONFIG_ZLIB_INFLATE=y

CONFIG_ZLIB_DEFLATE=y

Version 1.1 84

Page 85: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.3 Source-Code Whetstone-Benchmark

8.3 Source-Code Whetstone-Benchmark

Quelle: http://www.netlib.org/benchmark/whetstone.c

8.3.1 whetstone.c

# cat whetstone/whetstone.c:

/∗∗ C Converted Whetstone Double Prec i s ion Benchmark

∗ Version 1.2 22 March 1998

∗∗ ( c ) Copyright 1998 Painter Engineering , Inc .

∗ Al l Right s Reserved .

∗∗ Permission i s granted to use , dup l i c a t e , and

∗ pu b l i s h t h i s t e x t and program as long as i t

∗ i n c l u d e s t h i s e n t i r e comment b l o c k and l im i t e d

∗ r i g h t s r e f e r ence .

∗∗ Converted by Rich Painter , Painter Engineering , Inc . based on the

∗ www. n e t l i b . org benchmark/whets toned ve r s i on ob ta ined 16 March 1998.

∗∗ A nove l approach was used here to keep the l ook and f e e l o f the

∗ FORTRAN ver s i on . A l t e r i n g the FORTRAN−based array ind i ce s ,

∗ s t a r t i n g at e lement 1 , to s t a r t a t e lement 0 f o r C, would r e qu i r e

∗ numerous changes , i n c l ud in g decrementing the v a r i a b l e i n d i c e s by 1 .

∗ Instead , the array E1 [ ] was dec l a r ed 1 element l a r g e r in C. This

∗ a l l ow s the FORTRAN index range to func t i on wi thout any l i t e r a l or

∗ v a r i a b l e i n d i c e s changes . The array element E1 [ 0 ] i s s imply never

∗ used and does not a l t e r the benchmark r e s u l t s .

∗∗ The major FORTRAN comment b l o c k s were r e t a ined to minimize

∗ d i f f e r e n c e s between ve r s i on s . Modules N5 and N12 , l i k e in the

∗ FORTRAN vers ion , have been e l im ina t ed here .

∗∗ An op t i ona l command−l i n e argument has been prov ided [−c ] to

∗ o f f e r cont inuous r e p e t i t i o n o f the en t i r e benchmark .

∗ An op t i ona l argument f o r s e t t i n g an a l t e r n a t e LOOP count i s a l s o

∗ prov ided . Define PRINTOUT to cause the POUT() func t i on to p r i n t

∗ ou tpu t s at var ious s t a g e s . Fina l t iming measurements shou ld be

∗ made with the PRINTOUT undef ined .

∗∗ Quest ions and comments may be d i r e c t e d to the author at

∗ r . pa in ter@ieee . org

∗//∗C∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗C Benchmark #2 −− Double Prec i s ion Whetstone (A001)

Version 1.1 85

Page 86: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.3 Source-Code Whetstone-Benchmark

C

C o This i s a REAL∗8 ve r s i on o f

C the Whetstone benchmark program .

C

C o DO−l oop semant ics are ANSI−66 compat ib l e .

C

C o Fina l measurements are to be made wi th a l l

C WRITE sta tements and FORMAT st t ement s removed .

C

C∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗/

/∗ s tandard C l i b r a r y headers r e qu i r ed ∗/#include <s t d l i b . h>

#include <s t d i o . h>

#include <s t r i n g . h>

#include <math . h>

/∗ the f o l l ow i n g i s op t i ona l depending on the t iming func t i on used ∗/#include <time . h>

/∗ map the FORTRAN math func t ions , e t c . to the C ve r s i on s ∗/#define DSIN s in

#define DCOS cos

#define DATAN atan

#define DLOG log

#define DEXP exp

#define DSQRT sqr t

#define IF i f

/∗ f unc t i on pro t o t ype s ∗/void POUT( long N, long J , long K, double X1 , double X2 , double X3 , double X4 ) ;

void PA(double E [ ] ) ;

void P0(void ) ;

void P3(double X, double Y, double ∗Z ) ;

#define USAGE ”usage : whetdc [−c ] [ l oops ]\n”

/∗COMMON T,T1 ,T2 ,E1(4) , J ,K,L

∗/double T,T1 ,T2 , E1 [ 5 ] ;

int J ,K,L ;

int

main ( int argc , char ∗argv [ ] )

{/∗ used in the FORTRAN ver s i on ∗/long I ;

long N1 , N2 , N3 , N4 , N6 , N7 , N8 , N9 , N10 , N11 ;

Version 1.1 86

Page 87: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.3 Source-Code Whetstone-Benchmark

double X1 ,X2 ,X3 ,X4 ,X,Y,Z ;

long LOOP;

int I I , JJ ;

/∗ added f o r t h i s v e r s i on ∗/long l o op s t a r t ;

long s t a r t s e c , f i n i s e c ;

f loat KIPS ;

int cont inuous ;

l o op s t a r t = 1000 ; /∗ see the note about LOOP below ∗/cont inuous = 0 ;

I I = 1 ; /∗ s t a r t a t the f i r s t arg ( temp use o f I I here ) ∗/while ( I I < argc ) {

i f ( strncmp ( argv [ I I ] , ”−c ” , 2) == 0 | | argv [ I I ] [ 0 ] == ’ c ’ ) {cont inuous = 1 ;

} else i f ( a t o l ( argv [ I I ] ) > 0) {l o op s t a r t = a t o l ( argv [ I I ] ) ;

} else {f p r i n t f ( s tde r r , USAGE) ;

return ( 1 ) ;

}I I++;

}

LCONT:

/∗C

C Sta r t benchmark t iming at t h i s po in t .

C

∗/s t a r t s e c = time ( 0 ) ;

/∗C

C The ac tua l benchmark s t a r t s here .

C

∗/T = .499975 ;

T1 = 0 .50025 ;

T2 = 2 . 0 ;

/∗C

C With loopcount LOOP=10, one m i l l i o n Whetstone i n s t r u c t i o n s

C w i l l be executed in EACH MAJOR LOOP. .A MAJOR LOOP IS EXECUTED

C ’ I I ’ TIMES TO INCREASE WALL−CLOCK TIMING ACCURACY.

C

LOOP = 1000;

Version 1.1 87

Page 88: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.3 Source-Code Whetstone-Benchmark

∗/LOOP = loop s t a r t ;

I I = 1 ;

JJ = 1 ;

IILOOP :

N1 = 0 ;

N2 = 12 ∗ LOOP;

N3 = 14 ∗ LOOP;

N4 = 345 ∗ LOOP;

N6 = 210 ∗ LOOP;

N7 = 32 ∗ LOOP;

N8 = 899 ∗ LOOP;

N9 = 616 ∗ LOOP;

N10 = 0 ;

N11 = 93 ∗ LOOP;

/∗C

C Module 1 : Simple i d e n t i f i e r s

C

∗/X1 = 1 . 0 ;

X2 = −1.0;

X3 = −1.0;

X4 = −1.0;

for ( I = 1 ; I <= N1 ; I++) {X1 = (X1 + X2 + X3 − X4) ∗ T;

X2 = (X1 + X2 − X3 + X4) ∗ T;

X3 = (X1 − X2 + X3 + X4) ∗ T;

X4 = (−X1+ X2 + X3 + X4) ∗ T;

}#ifdef PRINTOUT

IF ( JJ==I I )POUT(N1 ,N1 ,N1 ,X1 ,X2 ,X3 ,X4 ) ;

#endif

/∗C

C Module 2 : Array e lements

C

∗/E1 [ 1 ] = 1 . 0 ;

E1 [ 2 ] = −1.0;

E1 [ 3 ] = −1.0;

E1 [ 4 ] = −1.0;

for ( I = 1 ; I <= N2 ; I++) {E1 [ 1 ] = ( E1 [ 1 ] + E1 [ 2 ] + E1 [ 3 ] − E1 [ 4 ] ) ∗ T;

Version 1.1 88

Page 89: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.3 Source-Code Whetstone-Benchmark

E1 [ 2 ] = ( E1 [ 1 ] + E1 [ 2 ] − E1 [ 3 ] + E1 [ 4 ] ) ∗ T;

E1 [ 3 ] = ( E1 [ 1 ] − E1 [ 2 ] + E1 [ 3 ] + E1 [ 4 ] ) ∗ T;

E1 [ 4 ] = (−E1 [ 1 ] + E1 [ 2 ] + E1 [ 3 ] + E1 [ 4 ] ) ∗ T;

}

#ifdef PRINTOUT

IF ( JJ==I I )POUT(N2 ,N3 ,N2 , E1 [ 1 ] , E1 [ 2 ] , E1 [ 3 ] , E1 [ 4 ] ) ;

#endif

/∗C

C Module 3 : Array as parameter

C

∗/for ( I = 1 ; I <= N3 ; I++)

PA(E1 ) ;

#ifdef PRINTOUT

IF ( JJ==I I )POUT(N3 ,N2 ,N2 , E1 [ 1 ] , E1 [ 2 ] , E1 [ 3 ] , E1 [ 4 ] ) ;

#endif

/∗C

C Module 4 : Cond i t iona l jumps

C

∗/J = 1 ;

for ( I = 1 ; I <= N4 ; I++) {i f ( J == 1)

J = 2 ;

else

J = 3 ;

i f ( J > 2)

J = 0 ;

else

J = 1 ;

i f ( J < 1)

J = 1 ;

else

J = 0 ;

}

#ifdef PRINTOUT

IF ( JJ==I I )POUT(N4 , J , J ,X1 ,X2 ,X3 ,X4 ) ;

#endif

/∗

Version 1.1 89

Page 90: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.3 Source-Code Whetstone-Benchmark

C

C Module 5 : Omitted

C Module 6 : In t e g e r a r i t hme t i c

C

∗/

J = 1 ;

K = 2 ;

L = 3 ;

for ( I = 1 ; I <= N6 ; I++) {J = J ∗ (K−J ) ∗ (L−K) ;

K = L ∗ K − (L−J ) ∗ K;

L = (L−K) ∗ (K+J ) ;

E1 [L−1] = J + K + L ;

E1 [K−1] = J ∗ K ∗ L ;

}

#ifdef PRINTOUT

IF ( JJ==I I )POUT(N6 , J ,K, E1 [ 1 ] , E1 [ 2 ] , E1 [ 3 ] , E1 [ 4 ] ) ;

#endif

/∗C

C Module 7 : Trigonometric f unc t i on s

C

∗/X = 0 . 5 ;

Y = 0 . 5 ;

for ( I = 1 ; I <= N7 ; I++) {X = T ∗ DATAN(T2∗DSIN(X)∗DCOS(X)/(DCOS(X+Y)+DCOS(X−Y) −1 .0 ) ) ;

Y = T ∗ DATAN(T2∗DSIN(Y)∗DCOS(Y)/(DCOS(X+Y)+DCOS(X−Y) −1 .0 ) ) ;

}

#ifdef PRINTOUT

IF ( JJ==I I )POUT(N7 , J ,K,X,X,Y,Y) ;

#endif

/∗C

C Module 8 : Procedure c a l l s

C

∗/X = 1 . 0 ;

Y = 1 . 0 ;

Z = 1 . 0 ;

for ( I = 1 ; I <= N8 ; I++)

Version 1.1 90

Page 91: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.3 Source-Code Whetstone-Benchmark

P3(X,Y,&Z ) ;

#ifdef PRINTOUT

IF ( JJ==I I )POUT(N8 , J ,K,X,Y,Z , Z ) ;

#endif

/∗C

C Module 9 : Array r e f e r en c e s

C

∗/J = 1 ;

K = 2 ;

L = 3 ;

E1 [ 1 ] = 1 . 0 ;

E1 [ 2 ] = 2 . 0 ;

E1 [ 3 ] = 3 . 0 ;

for ( I = 1 ; I <= N9 ; I++)

P0 ( ) ;

#ifdef PRINTOUT

IF ( JJ==I I )POUT(N9 , J ,K, E1 [ 1 ] , E1 [ 2 ] , E1 [ 3 ] , E1 [ 4 ] ) ;

#endif

/∗C

C Module 10: In t e g e r a r i t hme t i c

C

∗/J = 2 ;

K = 3 ;

for ( I = 1 ; I <= N10 ; I++) {J = J + K;

K = J + K;

J = K − J ;

K = K − J − J ;

}

#ifdef PRINTOUT

IF ( JJ==I I )POUT(N10 , J ,K,X1 ,X2 ,X3 ,X4 ) ;

#endif

/∗C

C Module 11: Standard f unc t i on s

C

∗/

Version 1.1 91

Page 92: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.3 Source-Code Whetstone-Benchmark

X = 0 . 7 5 ;

for ( I = 1 ; I <= N11 ; I++)

X = DSQRT(DEXP(DLOG(X)/T1 ) ) ;

#ifdef PRINTOUT

IF ( JJ==I I )POUT(N11 , J ,K,X,X,X,X) ;

#endif

/∗C

C THIS IS THE END OF THE MAJOR LOOP.

C

∗/i f (++JJ <= I I )

goto IILOOP ;

/∗C

C Stop benchmark t iming at t h i s po in t .

C

∗/f i n i s e c = time ( 0 ) ;

/∗C−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−C Performance in Whetstone KIP ’ s per second i s g i ven by

C

C (100∗LOOP∗ I I )/TIME

C

C where TIME i s in seconds .

C−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−∗/

p r i n t f ( ”\n” ) ;

i f ( f i n i s e c −s t a r t s e c <= 0) {p r i n t f ( ” I n s u f f i c i e n t durat ion− I n c r e a s e the LOOP count\n” ) ;

return ( 1 ) ;

}

p r i n t f ( ”Loops : %ld , I t e r a t i o n s : %d , Duration : %ld sec .\n” ,

LOOP, I I , f i n i s e c −s t a r t s e c ) ;

KIPS = (100 .0∗LOOP∗ I I )/ ( f loat ) ( f i n i s e c −s t a r t s e c ) ;

i f (KIPS >= 1000 .0 )

p r i n t f ( ”C Converted Double P r e c i s i on Whetstones : %.1 f MIPS\n” , KIPS/1000 . 0 ) ;

else

p r i n t f ( ”C Converted Double P r e c i s i on Whetstones : %.1 f KIPS\n” , KIPS ) ;

i f ( cont inuous )

Version 1.1 92

Page 93: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.3 Source-Code Whetstone-Benchmark

goto LCONT;

return ( 0 ) ;

}

void

PA(double E [ ] )

{J = 0 ;

L10 :

E [ 1 ] = ( E [ 1 ] + E [ 2 ] + E [ 3 ] − E [ 4 ] ) ∗ T;

E [ 2 ] = ( E [ 1 ] + E [ 2 ] − E [ 3 ] + E [ 4 ] ) ∗ T;

E [ 3 ] = ( E [ 1 ] − E [ 2 ] + E [ 3 ] + E [ 4 ] ) ∗ T;

E [ 4 ] = (−E [ 1 ] + E [ 2 ] + E [ 3 ] + E [ 4 ] ) / T2 ;

J += 1 ;

i f ( J < 6)

goto L10 ;

}

void

P0(void )

{E1 [ J ] = E1 [K] ;

E1 [K] = E1 [L ] ;

E1 [L ] = E1 [ J ] ;

}

void

P3(double X, double Y, double ∗Z)

{double X1 , Y1 ;

X1 = X;

Y1 = Y;

X1 = T ∗ (X1 + Y1 ) ;

Y1 = T ∗ (X1 + Y1 ) ;

∗Z = (X1 + Y1) / T2 ;

}

#ifdef PRINTOUT

void

POUT( long N, long J , long K, double X1 , double X2 , double X3 , double X4)

{p r i n t f ( ”%7ld %7ld %7ld %12.4 e %12.4 e %12.4 e %12.4 e\n” ,

N, J , K, X1 , X2 , X3 , X4 ) ;

}#endif

Version 1.1 93

Page 94: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.4 Source-Code Dhrystone-Benchmark

8.4 Source-Code Dhrystone-Benchmark

Quelle: http://www.netlib.org/benchmark/dhry-c

8.4.1 dhry.h

# cat dhrystone/dhry.h:

/∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗ ”DHRYSTONE” Benchmark Program

∗ −−−−−−−−−−−−−−−−−−−−−−−−−−−−−∗∗ Version : C, Version 2.1

∗∗ F i l e : dhry . h ( par t 1 o f 3)

∗∗ Date : May 25 , 1988

∗∗ Author : Reinhold P. Weicker

∗ Siemens AG, AUT E 51

∗ Post fach 3220

∗ 8520 Erlangen

∗ Germany (West )

∗ Phone : [+49]−9131−7−20330

∗ (8−17 Centra l European Time)

∗ Usenet : . . ! mcsun ! unido ! e s t e vax ! we icker

∗∗ Orig ina l Version ( in Ada) pub l i s h e d in

∗ ”Communications o f the ACM” vo l . 27 . , no . 10 (Oct . 1984) ,

∗ pp . 1013 − 1030 , t o g e t h e r wi th the s t a t i s t i c s

∗ on which the d i s t r i b u t i o n o f s ta tements e t c . i s based .

∗∗ In t h i s C vers ion , the f o l l ow i n g C l i b r a r y f unc t i on s are used :

∗ − s t rcpy , strcmp ( i n s i d e the measurement loop )

∗ − p r i n t f , s can f ( ou t s i d e the measurement loop )

∗ In add i t ion , Berke ley UNIX system c a l l s ”t imes ( ) ” or ”time ( ) ”

∗ are used f o r execu t i on time measurement . For measurements

∗ on other systems , t h e s e c a l l s have to be changed .

∗∗ Co l l e c t i on o f Resu l t s :

∗ Reinhold Weicker ( address see above ) and

∗∗ Rick Richardson

∗ PC Research . Inc .

∗ 94 Apple Orchard Drive

∗ Tinton Fa l l s , NJ 07724

∗ Phone : (201) 389−8963 (9−17 EST)

Version 1.1 94

Page 95: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.4 Source-Code Dhrystone-Benchmark

∗ Usenet : . . . ! uunet ! pcra t ! r i c k

∗∗ Please send r e s u l t s to Rick Richardson and/or Reinhold Weicker .

∗ Complete in format ion shou ld be g iven on hardware and so f tware used .

∗ Hardware in format ion in c l ud e s : Machine type , CPU, type and s i z e

∗ o f caches ; f o r microprocessors : c l o c k frequency , memory speed

∗ (number o f wai t s t a t e s ) .

∗ Sof tware in format ion in c l ud e s : Compiler ( and runtime l i b r a r y )

∗ manufacturer and vers ion , compi la t ion swi tches , OS ver s i on .

∗ The Operating System ver s i on may g i v e an i nd i c a t i on about the

∗ compi ler ; Dhrystone i t s e l f performs no OS c a l l s in the measurement loop .

∗∗ The complete output generated by the program shou ld be mai led

∗ such t ha t at l e a s t some checks f o r co r r e c tn e s s can be made .

∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗ His tory : This ve r s i on C/2.1 has been made f o r two reasons :

∗∗ 1) There i s an obv ious need f o r a common C ver s i on o f

∗ Dhrystone , s ince C i s at pre sen t the most popu lar system

∗ programming language f o r the c l a s s o f p roce s so r s

∗ ( microcomputers , minicomputers ) where Dhrystone i s used most .

∗ There shou ld be , as f a r as po s s i b l e , on ly one C ver s i on o f

∗ Dhrystone such t ha t r e s u l t s can be compared wi thout

∗ r e s t r i c t i o n s . In the past , the C ve r s i on s d i s t r i b u t e d

∗ by Rick Richardson ( Version 1 .1 ) and by Reinhold Weicker

∗ had sma l l ( though not s i g n i f i c a n t ) d i f f e r e n c e s .

∗∗ 2) As f a r as i t i s p o s s i b l e w i thout changes to the Dhrystone

∗ s t a t i s t i c s , op t im i z ing compi l e r s shou ld be prevented from

∗ removing s i g n i f i c a n t s ta tements .

∗∗ This C ver s i on has been deve loped in coopera t ion wi th

∗ Rick Richardson ( Tinton Fa l l s , NJ) , i t i n co rpora t e s many

∗ i d ea s from the ”Version 1 .1” d i s t r i b u t e d p r e v i o u s l y by

∗ him over the UNIX network Usenet .

∗ I a l s o thank Chaim Benedelac ( Nat iona l Semiconductor ) ,

∗ David D i t z e l (SUN) , Earl K i l l i a n and John Mashey (MIPS) ,

∗ Alan Smith and Rafae l Saavedra−Barrera (UC at Berke ley )

∗ f o r t h e i r he l p wi th comments on e a r l i e r v e r s i on s o f the

∗ benchmark .

∗∗ Changes : In the i n i t i a l i z a t i o n part , t h i s v e r s i on f o l l ow s most ly

∗ Rick Richardson ’ s v e r s i on d i s t r i b u t e d v ia Usenet , not the

∗ ve r s i on d i s t r i b u t e d e a r l i e r v ia f l o ppy d i s k by Reinhold Weicker .

∗ As a concess ion to o l d e r compi lers , names have been made

∗ unique w i th in the f i r s t 8 charac t e r s .

∗ In s i d e the measurement loop , t h i s v e r s i on f o l l ow s the

Version 1.1 95

Page 96: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.4 Source-Code Dhrystone-Benchmark

∗ ve r s i on p r e v i o u s l y d i s t r i b u t e d by Reinhold Weicker .

∗∗ At s e v e r a l p l a c e s in the benchmark , code has been added ,

∗ but w i th in the measurement loop only in branches t ha t

∗ are not executed . The i n t en t i on i s t ha t op t imi z ing compi l e r s

∗ shou ld be prevented from moving code out o f the measurement

∗ loop , or from removing code a l t o g e t h e r . Since the s ta tements

∗ t h a t are executed w i th in the measurement loop have NOT been

∗ changed , the numbers d e f i n i n g the ”Dhrystone d i s t r i b u t i o n ”

∗ ( d i s t r i b u t i o n o f s tatements , operand type s and l o c a l i t y )

∗ s t i l l ho ld . Except f o r s o p h i s t i c a t e d op t imi z ing compi lers ,

∗ execu t ion t imes f o r t h i s v e r s i on shou ld be the same as

∗ f o r prev ious v e r s i on s .

∗∗ Since i t has proven d i f f i c u l t to s u b t r a c t the time f o r the

∗ measurement loop overhead in a co r r e c t way , the loop check

∗ has been made a par t o f the benchmark . This does have

∗ an impact − though a very minor one − on the d i s t r i b u t i o n

∗ s t a t i s t i c s which have been updated f o r t h i s v e r s i on .

∗∗ Al l changes w i th in the measurement loop are de s c r i b ed

∗ and d i s cu s s ed in the companion paper ”Rat iona le f o r

∗ Dhrystone ve r s i on 2”.

∗∗ Because o f the s e l f −imposed l im i t a t i o n t ha t the order and

∗ d i s t r i b u t i o n o f the executed s ta tements shou ld not be

∗ changed , t h e r e are s t i l l cases where op t imi z ing compi l e r s

∗ may not genera te code f o r some s ta tements . To a c e r t a i n

∗ degree , t h i s i s unavo idab l e f o r sma l l s y n t h e t i c benchmarks .

∗ Users o f the benchmark are adv i sed to check code l i s t i n g s

∗ whether code i s generated f o r a l l s ta tements o f Dhrystone .

∗∗ Version 2.1 i s i d e n t i c a l to ve r s i on 2.0 d i s t r i b u t e d v ia

∗ the UNIX network Usenet in March 1988 excep t t ha t i t c o r r e c t s

∗ some minor d e f i c i e n c i e s t ha t were found by users o f v e r s i on 2 . 0 .

∗ The only change wi th in the measurement loop i s t ha t a

∗ non−executed ” e l s e ” par t was added to the ” i f ” s ta tement in

∗ Func 3 , and a non−executed ” e l s e ” par t removed from Proc 3 .

∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗ Def ines : The f o l l ow i n g ”Def ines ” are p o s s i b l e :

∗ −DREG=r e g i s t e r ( d e f a u l t : Not de f ined )

∗ As an approximation to what an average C programmer

∗ might do , the ” r e g i s t e r ” s t o rage c l a s s i s app l i e d

∗ ( i f enab led by −DREG=r e g i s t e r )

∗ − f o r l o c a l v a r i a b l e s , i f they are used ( dynamica l l y )

∗ f i v e or more t imes

∗ − f o r parameters i f they are used ( dynamica l l y )

Version 1.1 96

Page 97: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.4 Source-Code Dhrystone-Benchmark

∗ s i x or more t imes

∗ Note t ha t an opt imal ” r e g i s t e r ” s t r a t e g y i s

∗ compi ler−dependent , and t ha t ” r e g i s t e r ” d e c l a r a t i o n s

∗ do not n e c e s s a r i l y l ead to f a s t e r execu t ion .

∗ −DNOSTRUCTASSIGN ( d e f a u l t : Not de f ined )

∗ Define i f the C compi ler does not suppor t

∗ assignment o f s t r u c t u r e s .

∗ −DNOENUMS ( d e f a u l t : Not de f ined )

∗ Define i f the C compi ler does not suppor t

∗ enumeration type s .

∗ −DTIMES ( d e f a u l t )

∗ −DTIME

∗ The ”t imes ” func t i on o f UNIX ( re tu rn ing process t imes )

∗ or the ”time ” func t i on ( re tu rn ing wa l l c l o c k time )

∗ i s used f o r measurement .

∗ For s i n g l e user machines , ”time ( ) ” i s adequate . For

∗ mult i−user machines where you cannot g e t s i n g l e−user

∗ access , use the ”t imes ( ) ” func t i on . I f you have

∗ ne i ther , use a stopwatch in the dead o f n i gh t .

∗ ”p r i n t f ”s are prov ided marking the po in t s ”S t a r t Timer ”

∗ and ”Stop Timer ”. DO NOT use the UNIX ”time (1 )”

∗ command , as t h i s w i l l measure the t o t a l time to

∗ run t h i s program , which w i l l ( e r roneous l y ) in c l ude

∗ the time to a l l o c a t e s t o rage ( mal loc ) and to perform

∗ the i n i t i a l i z a t i o n .

∗ −DHZ=nnn

∗ In Berke ley UNIX, the func t i on ”t imes ” re turns proces s

∗ t ime in 1/HZ seconds , wi th HZ = 60 fo r most systems .

∗ CHECK YOUR SYSTEM DESCRIPTION BEFORE YOU JUST APPLY

∗ A VALUE.

∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗ Compilat ion model and measurement (IMPORTANT) :

∗∗ This C ver s i on o f Dhrystone c on s i s t s o f t h r e e f i l e s :

∗ − dhry . h ( t h i s f i l e , con ta in ing g l o b a l d e f i n i t i o n s and comments )

∗ − dhry 1 . c ( con ta in ing the code corresponding to Ada package Pack 1 )

∗ − dhry 2 . c ( con ta in ing the code corresponding to Ada package Pack 2 )

∗∗ The f o l l ow i n g ”ground r u l e s ” app ly f o r measurements :

∗ − Separate compi la t ion

∗ − No procedure merging

∗ − Otherwise , compi ler op t im i za t i on s are a l l owed but shou ld be i nd i c a t e d

∗ − Defau l t r e s u l t s are those wi thout r e g i s t e r d e c l a r a t i o n s

∗ See the companion paper ”Rat iona le f o r Dhrystone Version 2” f o r a more

∗ d e t a i l e d d i s c u s s i on o f t h e s e ground r u l e s .

∗∗ For 16−Bit p roce s so r s ( e . g . 80186 , 80286) , t imes f o r a l l compi la t ion

Version 1.1 97

Page 98: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.4 Source-Code Dhrystone-Benchmark

∗ models (” sma l l ” , ”medium”, ” l a r g e ” e t c . ) shou ld be g iven i f p o s s i b l e ,

∗ t o g e t h e r wi th a d e f i n i t i o n o f t h e s e models f o r the compi ler system used .

∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗ Dhrystone (C ver s i on ) s t a t i s t i c s :

∗∗ [Comment from the f i r s t d i s t r i b u t i o n , updated f o r ve r s i on 2 .

∗ Note t ha t because o f language d i f f e r en c e s , the numbers are s l i g h t l y

∗ d i f f e r e n t from the Ada ver s i on . ]

∗∗ The f o l l ow i n g program conta ins s ta tements o f a h igh l e v e l programming

∗ l anguage ( here : C) in a d i s t r i b u t i o n cons idered r e p r e s e n t a t i v e :

∗∗ ass ignments 52 (51 .0 %)

∗ con t r o l s ta tements 33 (32 .4 %)

∗ procedure , f unc t i on c a l l s 17 (16 .7 %)

∗∗ 103 s ta tements are dynamica l l y executed . The program i s ba lanced wi th

∗ r e s p e c t to the t h r e e a spec t s :

∗∗ − s ta tement type

∗ − operand type

∗ − operand l o c a l i t y

∗ operand g l o ba l , l o c a l , parameter , or cons tant .

∗∗ The combination o f t h e s e t h r e e a spec t s i s ba lanced only approx imate ly .

∗∗ 1 . Statement Type :

∗ −−−−−−−−−−−−−−−−− number

∗∗ V1 = V2 9

∗ ( i n c l . V1 = F ( . . )

∗ V = Constant 12

∗ Assignment , 7

∗ with array element

∗ Assignment , 6

∗ with record component

∗ −−∗ 34 34

∗∗ X = Y + | −|”&&”|”|” Z 5

∗ X = Y +|−|”==” Constant 6

∗ X = X +|− 1 3

∗ X = Y ∗ |/ Z 2

∗ X = Expression , 1

∗ two opera tor s

∗ X = Expression , 1

∗ t h r e e opera tor s

Version 1.1 98

Page 99: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.4 Source-Code Dhrystone-Benchmark

∗ −−∗ 18 18

∗∗ i f . . . . 14

∗ with ” e l s e ” 7

∗ wi thout ” e l s e ” 7

∗ executed 3

∗ not executed 4

∗ f o r . . . 7 | counted every time

∗ whi l e . . . 4 | the loop cond i t i on

∗ do . . . wh i l e 1 | i s e va l ua t ed

∗ sw i t ch . . . 1

∗ break 1

∗ d e c l a r a t i on wi th 1

∗ i n i t i a l i z a t i o n

∗ −−∗ 34 34

∗∗ P ( . . . ) procedure c a l l 11

∗ user procedure 10

∗ l i b r a r y procedure 1

∗ X = F ( . . . )

∗ f unc t i on c a l l 6

∗ user func t i on 5

∗ l i b r a r y func t i on 1

∗ −−∗ 17 17

∗ −−−∗ 103

∗∗ The average number o f parameters in procedure or func t i on c a l l s

∗ i s 1 .82 ( not count ing the func t i on va l ue s as im p l i c i t parameters ) .

∗∗∗ 2 . Operators

∗ −−−−−−−−−−−−∗ number approximate

∗ percentage

∗∗ Ari thmet ic 32 50.8

∗∗ + 21 33.3

∗ − 7 11.1

∗ ∗ 3 4.8

∗ / ( i n t d i v ) 1 1.6

∗∗ Comparison 27 42.8

∗∗ == 9 14.3

Version 1.1 99

Page 100: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.4 Source-Code Dhrystone-Benchmark

∗ /= 4 6.3

∗ > 1 1.6

∗ < 3 4.8

∗ >= 1 1.6

∗ <= 9 14.3

∗∗ Logic 4 6.3

∗∗ && (AND−THEN) 1 1.6

∗ | (OR) 1 1.6

∗ ! (NOT) 2 3.2

∗∗ −− −−−−−∗ 63 100.1

∗∗∗ 3 . Operand Type ( counted once per operand re f e r ence ) :

∗ −−−−−−−−−−−−−−−∗ number approximate

∗ percentage

∗∗ In t e g e r 175 72.3 %

∗ Character 45 18.6 %

∗ Pointer 12 5.0 %

∗ Str ing30 6 2.5 %

∗ Array 2 0.8 %

∗ Record 2 0.8 %

∗ −−− −−−−−−−∗ 242 100.0 %

∗∗ When the re i s an access path l e ad in g to the f i n a l operand ( e . g . a record

∗ component ) , on ly the f i n a l data type on the access path i s counted .

∗∗∗ 4 . Operand Loca l i t y :

∗ −−−−−−−−−−−−−−−−−−−∗ number approximate

∗ percentage

∗∗ l o c a l v a r i a b l e 114 47.1 %

∗ g l o b a l v a r i a b l e 22 9.1 %

∗ parameter 45 18.6 %

∗ va lue 23 9.5 %

∗ r e f e r ence 22 9.1 %

∗ f unc t i on r e s u l t 6 2 .5 %

∗ cons tant 55 22.7 %

∗ −−− −−−−−−−∗ 242 100.0 %

Version 1.1 100

Page 101: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.4 Source-Code Dhrystone-Benchmark

∗∗ The program does not compute anyth ing meaningful , but i t i s s y n t a c t i c a l l y

∗ and s eman t i c a l l y c o r r e c t . A l l v a r i a b l e s have a va lue as s i gned to them

∗ b e f o r e they are used as a source operand .

∗∗ There has been no e x p l i c i t e f f o r t to account f o r the e f f e c t s o f a

∗ cache , or to ba lance the use o f long or shor t d i sp lacement s f o r code or

∗ data .

∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗/

/∗ Compiler and system dependent d e f i n i t i o n s : ∗/

#ifndef TIME

#define TIMES

#endif

/∗ Use t imes (2) time func t i on un l e s s ∗//∗ e x p l i c i t l y de f ined o therw i s e ∗/

#ifdef TIMES

#include <sys / types . h>

#include <sys / t imes . h>

/∗ f o r ”t imes ” ∗/#endif

#define Mic secs Per Second 1000000.0

/∗ Berke ley UNIX C re turns process t imes in seconds /HZ ∗/

#ifdef NOSTRUCTASSIGN

#define s t r u c t a s s i g n (d , s ) memcpy(&(d ) , &(s ) , s izeof (d ) )

#else

#define s t r u c t a s s i g n (d , s ) d = s

#endif

#i fde f NOENUM

#define Ident 1 0

#define Ident 2 1

#define Ident 3 2

#define Ident 4 3

#define Ident 5 4

typedef int Enumeration ;

#else

typedef enum { Ident 1 , Ident 2 , Ident 3 , Ident 4 , Ident 5 }Enumeration ;

#endif

/∗ f o r boo lean and enumeration type s in Ada , Pascal ∗/

/∗ General d e f i n i t i o n s : ∗/

Version 1.1 101

Page 102: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.4 Source-Code Dhrystone-Benchmark

#include <s t d i o . h>

/∗ f o r s t rcpy , strcmp ∗/

#define Null 0

/∗ Value o f a Nul l po in t e r ∗/#define t rue 1

#define f a l s e 0

typedef int One Thirty ;

typedef int One Fifty ;

typedef char Cap i t a l Le t t e r ;

typedef int Boolean ;

typedef char Str 30 [ 3 1 ] ;

typedef int Arr 1 Dim [ 5 0 ] ;

typedef int Arr 2 Dim [ 5 0 ] [ 5 0 ] ;

typedef struct record

{struct record ∗Ptr Comp ;

Enumeration Discr ;

union {struct {

Enumeration Enum Comp ;

int Int Comp ;

char Str Comp [ 3 1 ] ;

} var 1 ;

struct {Enumeration E Comp 2 ;

char Str 2 Comp [ 3 1 ] ;

} var 2 ;

struct {char Ch 1 Comp ;

char Ch 2 Comp ;

} var 3 ;

} var i ant ;

} Rec Type , ∗Rec Pointer ;

Version 1.1 102

Page 103: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.4 Source-Code Dhrystone-Benchmark

8.4.2 dhry 1.c

# cat dhrystone/dhry_1.c:

/∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗ ”DHRYSTONE” Benchmark Program

∗ −−−−−−−−−−−−−−−−−−−−−−−−−−−−−∗∗ Version : C, Version 2.1

∗∗ F i l e : dhry 1 . c ( par t 2 o f 3)

∗∗ Date : May 25 , 1988

∗∗ Author : Reinhold P. Weicker

∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗/

#include ”dhry . h”

/∗ Globa l Var iab l e s : ∗/

Rec Pointer Ptr Glob ,

Next Ptr Glob ;

int Int Glob ;

Boolean Bool Glob ;

char Ch 1 Glob ,

Ch 2 Glob ;

int Arr 1 Glob [ 5 0 ] ;

int Arr 2 Glob [ 5 0 ] [ 5 0 ] ;

extern char ∗malloc ( ) ;

Enumeration Func 1 ( ) ;

/∗ forward d e c l a r a t i on necessary s ince Enumeration may not s imply be i n t ∗/

#ifndef REG

Boolean Reg = f a l s e ;

#define REG

/∗ REG becomes de f ined as empty ∗//∗ i . e . no r e g i s t e r v a r i a b l e s ∗/

#else

Boolean Reg = true ;

#endif

/∗ v a r i a b l e s f o r time measurement : ∗/

Version 1.1 103

Page 104: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.4 Source-Code Dhrystone-Benchmark

#ifdef TIMES

struct tms t ime in f o ;

extern int t imes ( ) ;

/∗ see l i b r a r y func t i on ”t imes ” ∗/#define Too Small Time 120

/∗ Measurements shou ld l a s t a t l e a s t about 2 seconds ∗/#endif

#i fde f TIME

extern long time ( ) ;

/∗ see l i b r a r y func t i on ”time ” ∗/#define Too Small Time 2

/∗ Measurements shou ld l a s t a t l e a s t 2 seconds ∗/#endif

long Begin Time ,

End Time ,

User Time ;

f loat Microseconds ,

Dhrystones Per Second ;

/∗ end o f v a r i a b l e s f o r time measurement ∗/

main ( )

/∗∗∗∗∗/

/∗ main program , corresponds to procedures ∗//∗ Main and Proc 0 in the Ada ver s i on ∗/

{One Fifty Int 1 Loc ;

REG One Fifty Int 2 Loc ;

One Fifty Int 3 Loc ;

REG char Ch Index ;

Enumeration Enum Loc ;

St r 30 Str 1 Loc ;

St r 30 Str 2 Loc ;

REG int Run Index ;

REG int Number Of Runs ;

/∗ I n i t i a l i z a t i o n s ∗/

Next Ptr Glob = ( Rec Pointer ) mal loc ( s izeof (Rec Type ) ) ;

Ptr Glob = ( Rec Pointer ) mal loc ( s izeof (Rec Type ) ) ;

Ptr Glob−>Ptr Comp = Next Ptr Glob ;

Ptr Glob−>Discr = Ident 1 ;

Ptr Glob−>var i ant . var 1 .Enum Comp = Ident 3 ;

Ptr Glob−>var i ant . var 1 . Int Comp = 40 ;

s t r cpy ( Ptr Glob−>var i ant . var 1 . Str Comp ,

Version 1.1 104

Page 105: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.4 Source-Code Dhrystone-Benchmark

”DHRYSTONE PROGRAM, SOME STRING” ) ;

s t r cpy ( Str 1 Loc , ”DHRYSTONE PROGRAM, 1 ’ST STRING” ) ;

Arr 2 Glob [ 8 ] [ 7 ] = 10 ;

/∗ Was miss ing in pub l i s h e d program . Without t h i s statement , ∗//∗ Arr 2 Glob [ 8 ] [ 7 ] would have an undef ined va lue . ∗//∗ Warning : With 16−Bit p roce s so r s and Number Of Runs > 32000 , ∗//∗ ove r f l ow may occur f o r t h i s array element . ∗/

p r i n t f ( ”\n” ) ;

p r i n t f ( ”Dhrystone Benchmark , Vers ion 2 .1 ( Language : C)\n” ) ;

p r i n t f ( ”\n” ) ;

i f (Reg )

{p r i n t f ( ”Program compiled with ’ r e g i s t e r ’ a t t r i bu t e \n” ) ;

p r i n t f ( ”\n” ) ;

}else

{p r i n t f ( ”Program compiled without ’ r e g i s t e r ’ a t t r i bu t e \n” ) ;

p r i n t f ( ”\n” ) ;

}p r i n t f ( ”Please g ive the number o f runs through the benchmark : ” ) ;

{int n ;

s can f ( ”%d” , &n ) ;

Number Of Runs = n ;

}p r i n t f ( ”\n” ) ;

p r i n t f ( ”Execution s t a r t s , %d runs through Dhrystone\n” , Number Of Runs ) ;

/∗ ∗∗∗∗∗∗∗∗∗∗∗∗∗ ∗//∗ S ta r t t imer ∗//∗ ∗∗∗∗∗∗∗∗∗∗∗∗∗ ∗/

#ifdef TIMES

times (& t ime in f o ) ;

Begin Time = ( long ) t ime in f o . tms utime ;

#endif

#i fde f TIME

Begin Time = time ( ( long ∗) 0 ) ;

#endif

for ( Run Index = 1 ; Run Index <= Number Of Runs ; ++Run Index )

{

Proc 5 ( ) ;

Proc 4 ( ) ;

Version 1.1 105

Page 106: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.4 Source-Code Dhrystone-Benchmark

/∗ Ch 1 Glob == ’A ’ , Ch 2 Glob == ’B ’ , Bool Glob == true ∗/Int 1 Loc = 2 ;

Int 2 Loc = 3 ;

s t r cpy ( Str 2 Loc , ”DHRYSTONE PROGRAM, 2 ’ND STRING” ) ;

Enum Loc = Ident 2 ;

Bool Glob = ! Func 2 ( Str 1 Loc , Str 2 Loc ) ;

/∗ Bool Glob == 1 ∗/while ( Int 1 Loc < Int 2 Loc ) /∗ l oop body executed once ∗/{

Int 3 Loc = 5 ∗ Int 1 Loc − Int 2 Loc ;

/∗ In t 3 Loc == 7 ∗/Proc 7 ( Int 1 Loc , Int 2 Loc , &Int 3 Loc ) ;

/∗ In t 3 Loc == 7 ∗/Int 1 Loc += 1 ;

} /∗ whi l e ∗//∗ In t 1 Loc == 3 , In t 2 Loc == 3 , In t 3 Loc == 7 ∗/

Proc 8 ( Arr 1 Glob , Arr 2 Glob , Int 1 Loc , Int 3 Loc ) ;

/∗ In t Glob == 5 ∗/Proc 1 ( Ptr Glob ) ;

for ( Ch Index = ’A ’ ; Ch Index <= Ch 2 Glob ; ++Ch Index )

/∗ l oop body executed tw ice ∗/{

i f (Enum Loc == Func 1 ( Ch Index , ’C ’ ) )

/∗ then , not execu ted ∗/{Proc 6 ( Ident 1 , &Enum Loc ) ;

s t r cpy ( Str 2 Loc , ”DHRYSTONE PROGRAM, 3 ’RD STRING” ) ;

Int 2 Loc = Run Index ;

Int Glob = Run Index ;

}}

/∗ In t 1 Loc == 3 , In t 2 Loc == 3 , In t 3 Loc == 7 ∗/Int 2 Loc = Int 2 Loc ∗ Int 1 Loc ;

Int 1 Loc = Int 2 Loc / Int 3 Loc ;

Int 2 Loc = 7 ∗ ( Int 2 Loc − Int 3 Loc ) − Int 1 Loc ;

/∗ In t 1 Loc == 1 , In t 2 Loc == 13 , In t 3 Loc == 7 ∗/Proc 2 (&Int 1 Loc ) ;

/∗ In t 1 Loc == 5 ∗/

} /∗ l oop ” f o r Run Index ” ∗/

/∗ ∗∗∗∗∗∗∗∗∗∗∗∗ ∗//∗ Stop t imer ∗//∗ ∗∗∗∗∗∗∗∗∗∗∗∗ ∗/

#ifdef TIMES

times (& t ime in f o ) ;

End Time = ( long ) t ime in f o . tms utime ;

#endif

Version 1.1 106

Page 107: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.4 Source-Code Dhrystone-Benchmark

#ifdef TIME

End Time = time ( ( long ∗) 0 ) ;

#endif

p r i n t f ( ”Execution ends\n” ) ;

p r i n t f ( ”\n” ) ;

p r i n t f ( ”Fina l va lue s o f the v a r i a b l e s used in the benchmark :\n” ) ;

p r i n t f ( ”\n” ) ;

p r i n t f ( ”Int Glob : %d\n” , Int Glob ) ;

p r i n t f ( ” should be : %d\n” , 5 ) ;

p r i n t f ( ”Bool Glob : %d\n” , Bool Glob ) ;

p r i n t f ( ” should be : %d\n” , 1 ) ;

p r i n t f ( ”Ch 1 Glob : %c\n” , Ch 1 Glob ) ;

p r i n t f ( ” should be : %c\n” , ’A ’ ) ;

p r i n t f ( ”Ch 2 Glob : %c\n” , Ch 2 Glob ) ;

p r i n t f ( ” should be : %c\n” , ’B ’ ) ;

p r i n t f ( ”Arr 1 Glob [ 8 ] : %d\n” , Arr 1 Glob [ 8 ] ) ;

p r i n t f ( ” should be : %d\n” , 7 ) ;

p r i n t f ( ”Arr 2 Glob [ 8 ] [ 7 ] : %d\n” , Arr 2 Glob [ 8 ] [ 7 ] ) ;

p r i n t f ( ” should be : Number Of Runs + 10\n” ) ;

p r i n t f ( ”Ptr Glob−>\n” ) ;

p r i n t f ( ” Ptr Comp : %d\n” , ( int ) Ptr Glob−>Ptr Comp ) ;

p r i n t f ( ” should be : ( implementation−dependent )\n” ) ;

p r i n t f ( ” Discr : %d\n” , Ptr Glob−>Discr ) ;

p r i n t f ( ” should be : %d\n” , 0 ) ;

p r i n t f ( ” Enum Comp : %d\n” , Ptr Glob−>var i ant . var 1 .Enum Comp ) ;

p r i n t f ( ” should be : %d\n” , 2 ) ;

p r i n t f ( ” Int Comp : %d\n” , Ptr Glob−>var i ant . var 1 . Int Comp ) ;

p r i n t f ( ” should be : %d\n” , 1 7 ) ;

p r i n t f ( ” Str Comp : %s \n” , Ptr Glob−>var i ant . var 1 . Str Comp ) ;

p r i n t f ( ” should be : DHRYSTONE PROGRAM, SOME STRING\n” ) ;

p r i n t f ( ”Next Ptr Glob−>\n” ) ;

p r i n t f ( ” Ptr Comp : %d\n” , ( int ) Next Ptr Glob−>Ptr Comp ) ;

p r i n t f ( ” should be : ( implementation−dependent ) , same as above\n” ) ;

p r i n t f ( ” Discr : %d\n” , Next Ptr Glob−>Discr ) ;

p r i n t f ( ” should be : %d\n” , 0 ) ;

p r i n t f ( ” Enum Comp : %d\n” , Next Ptr Glob−>var i ant . var 1 .Enum Comp ) ;

p r i n t f ( ” should be : %d\n” , 1 ) ;

p r i n t f ( ” Int Comp : %d\n” , Next Ptr Glob−>var i ant . var 1 . Int Comp ) ;

p r i n t f ( ” should be : %d\n” , 1 8 ) ;

p r i n t f ( ” Str Comp : %s \n” ,

Next Ptr Glob−>var i ant . var 1 . Str Comp ) ;

p r i n t f ( ” should be : DHRYSTONE PROGRAM, SOME STRING\n” ) ;

p r i n t f ( ”Int 1 Loc : %d\n” , Int 1 Loc ) ;

p r i n t f ( ” should be : %d\n” , 5 ) ;

p r i n t f ( ”Int 2 Loc : %d\n” , Int 2 Loc ) ;

p r i n t f ( ” should be : %d\n” , 1 3 ) ;

p r i n t f ( ”Int 3 Loc : %d\n” , Int 3 Loc ) ;

p r i n t f ( ” should be : %d\n” , 7 ) ;

Version 1.1 107

Page 108: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.4 Source-Code Dhrystone-Benchmark

p r i n t f ( ”Enum Loc : %d\n” , Enum Loc ) ;

p r i n t f ( ” should be : %d\n” , 1 ) ;

p r i n t f ( ”Str 1 Loc : %s \n” , Str 1 Loc ) ;

p r i n t f ( ” should be : DHRYSTONE PROGRAM, 1 ’ST STRING\n” ) ;

p r i n t f ( ”Str 2 Loc : %s \n” , Str 2 Loc ) ;

p r i n t f ( ” should be : DHRYSTONE PROGRAM, 2 ’ND STRING\n” ) ;

p r i n t f ( ”\n” ) ;

User Time = End Time − Begin Time ;

i f ( User Time < Too Small Time )

{p r i n t f ( ”Measured time too smal l to obta in meaningful r e s u l t s \n” ) ;

p r i n t f ( ”Please i n c r e a s e number o f runs \n” ) ;

p r i n t f ( ”\n” ) ;

}else

{#ifdef TIME

Microseconds = ( f loat ) User Time ∗ Mic secs Per Second

/ ( f loat ) Number Of Runs ;

Dhrystones Per Second = ( f loat ) Number Of Runs / ( f loat ) User Time ;

#else

Microseconds = ( f loat ) User Time ∗ Mic secs Per Second

/ ( ( f loat ) HZ ∗ ( ( f loat ) Number Of Runs ) ) ;

Dhrystones Per Second = ( ( f loat ) HZ ∗ ( f loat ) Number Of Runs )

/ ( f loat ) User Time ;

#endif

p r i n t f ( ”Microseconds f o r one run through Dhrystone : ” ) ;

p r i n t f ( ”%6.1 f \n” , Microseconds ) ;

p r i n t f ( ”Dhrystones per Second : ” ) ;

p r i n t f ( ”%6.1 f \n” , Dhrystones Per Second ) ;

p r i n t f ( ”\n” ) ;

}

}

Proc 1 ( Ptr Val Par )

/∗ ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗ ∗/

REG Rec Pointer Ptr Val Par ;

/∗ executed once ∗/{

REG Rec Pointer Next Record = Ptr Val Par−>Ptr Comp ;

/∗ == Ptr Glob Next ∗//∗ Local v a r i a b l e , i n i t i a l i z e d wi th Ptr Val Par−>Ptr Comp , ∗//∗ corresponds to ”rename” in Ada , ”wi th ” in Pascal ∗/

Version 1.1 108

Page 109: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.4 Source-Code Dhrystone-Benchmark

s t r u c t a s s i g n (∗Ptr Val Par−>Ptr Comp , ∗Ptr Glob ) ;

Ptr Val Par−>var i ant . var 1 . Int Comp = 5 ;

Next Record−>var i ant . var 1 . Int Comp

= Ptr Val Par−>var i ant . var 1 . Int Comp ;

Next Record−>Ptr Comp = Ptr Val Par−>Ptr Comp ;

Proc 3 (&Next Record−>Ptr Comp ) ;

/∗ Ptr Val Par−>Ptr Comp−>Ptr Comp

== Ptr Glob−>Ptr Comp ∗/i f ( Next Record−>Discr == Ident 1 )

/∗ then , executed ∗/{

Next Record−>var i ant . var 1 . Int Comp = 6 ;

Proc 6 ( Ptr Val Par−>var i ant . var 1 .Enum Comp,

&Next Record−>var i ant . var 1 .Enum Comp ) ;

Next Record−>Ptr Comp = Ptr Glob−>Ptr Comp ;

Proc 7 ( Next Record−>var i ant . var 1 . Int Comp , 10 ,

&Next Record−>var i ant . var 1 . Int Comp ) ;

}else /∗ not executed ∗/

s t r u c t a s s i g n (∗Ptr Val Par , ∗Ptr Val Par−>Ptr Comp ) ;

} /∗ Proc 1 ∗/

Proc 2 ( Int Par Ref )

/∗ ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗ ∗//∗ executed once ∗//∗ ∗ Int Par Ref == 1 , becomes 4 ∗/

One Fifty ∗ Int Par Ref ;

{One Fifty Int Loc ;

Enumeration Enum Loc ;

Int Loc = ∗ Int Par Ref + 10 ;

do /∗ executed once ∗/i f ( Ch 1 Glob == ’A ’ )

/∗ then , executed ∗/{

Int Loc −= 1 ;

∗ Int Par Ref = Int Loc − Int Glob ;

Enum Loc = Ident 1 ;

} /∗ i f ∗/while (Enum Loc != Ident 1 ) ; /∗ t rue ∗/

} /∗ Proc 2 ∗/

Proc 3 ( Ptr Ref Par )

/∗ ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗ ∗//∗ executed once ∗/

Version 1.1 109

Page 110: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.4 Source-Code Dhrystone-Benchmark

/∗ Ptr Ref Par becomes Ptr Glob ∗/

Rec Pointer ∗Ptr Ref Par ;

{i f ( Ptr Glob != Null )

/∗ then , executed ∗/∗Ptr Ref Par = Ptr Glob−>Ptr Comp ;

Proc 7 (10 , Int Glob , &Ptr Glob−>var i ant . var 1 . Int Comp ) ;

} /∗ Proc 3 ∗/

Proc 4 ( ) /∗ wi thout parameters ∗//∗∗∗∗∗∗∗/

/∗ executed once ∗/{

Boolean Bool Loc ;

Bool Loc = Ch 1 Glob == ’A ’ ;

Bool Glob = Bool Loc | Bool Glob ;

Ch 2 Glob = ’B ’ ;

} /∗ Proc 4 ∗/

Proc 5 ( ) /∗ wi thout parameters ∗//∗∗∗∗∗∗∗/

/∗ executed once ∗/{

Ch 1 Glob = ’A ’ ;

Bool Glob = f a l s e ;

} /∗ Proc 5 ∗/

/∗ Procedure f o r the assignment o f s t r u c t u r e s , ∗//∗ i f t he C compi ler doesn ’ t suppor t t h i s f e a t u r e ∗/

#ifdef NOSTRUCTASSIGN

memcpy (d , s , l )

register char ∗d ;

register char ∗ s ;

register int l ;

{while ( l−−) ∗d++ = ∗ s++;

}#endif

Version 1.1 110

Page 111: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.4 Source-Code Dhrystone-Benchmark

8.4.3 dhry 2.c

# cat dhrystone/dhry_2.c:

/∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗ ”DHRYSTONE” Benchmark Program

∗ −−−−−−−−−−−−−−−−−−−−−−−−−−−−−∗∗ Version : C, Version 2.1

∗∗ F i l e : dhry 2 . c ( par t 3 o f 3)

∗∗ Date : May 25 , 1988

∗∗ Author : Reinhold P. Weicker

∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗/

#include ”dhry . h”

#ifndef REG

#define REG

/∗ REG becomes de f ined as empty ∗//∗ i . e . no r e g i s t e r v a r i a b l e s ∗/

#endif

extern int Int Glob ;

extern char Ch 1 Glob ;

Proc 6 (Enum Val Par , Enum Ref Par )

/∗ ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗ ∗//∗ executed once ∗//∗ Enum Val Par == Ident 3 , Enum Ref Par becomes Iden t 2 ∗/

Enumeration Enum Val Par ;

Enumeration ∗Enum Ref Par ;

{∗Enum Ref Par = Enum Val Par ;

i f ( ! Func 3 (Enum Val Par ) )

/∗ then , not execu ted ∗/∗Enum Ref Par = Ident 4 ;

switch (Enum Val Par )

{case Ident 1 :

∗Enum Ref Par = Ident 1 ;

Version 1.1 111

Page 112: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.4 Source-Code Dhrystone-Benchmark

break ;

case Ident 2 :

i f ( Int Glob > 100)

/∗ then ∗/∗Enum Ref Par = Ident 1 ;

else ∗Enum Ref Par = Ident 4 ;

break ;

case Ident 3 : /∗ executed ∗/∗Enum Ref Par = Ident 2 ;

break ;

case Ident 4 : break ;

case Ident 5 :

∗Enum Ref Par = Ident 3 ;

break ;

} /∗ sw i t ch ∗/} /∗ Proc 6 ∗/

Proc 7 ( Int 1 Par Val , Int 2 Par Val , Int Par Ref )

/∗ ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗ ∗//∗ executed th r ee t imes ∗//∗ f i r s t c a l l : In t 1 Par Val == 2 , In t 2 Par Val == 3 , ∗//∗ Int Par Ref becomes 7 ∗//∗ second c a l l : In t 1 Par Val == 10 , In t 2 Par Val == 5 , ∗//∗ Int Par Ref becomes 17 ∗//∗ t h i r d c a l l : In t 1 Par Val == 6 , In t 2 Par Val == 10 , ∗//∗ Int Par Ref becomes 18 ∗/

One Fifty Int 1 Par Val ;

One Fifty Int 2 Par Val ;

One Fifty ∗ Int Par Ref ;

{One Fifty Int Loc ;

Int Loc = Int 1 Par Val + 2 ;

∗ Int Par Ref = Int 2 Par Val + Int Loc ;

} /∗ Proc 7 ∗/

Proc 8 ( Arr 1 Par Ref , Arr 2 Par Ref , Int 1 Par Val , Int 2 Par Val )

/∗ ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗ ∗//∗ executed once ∗//∗ In t Par Val 1 == 3 ∗//∗ In t Par Val 2 == 7 ∗/

Arr 1 Dim Arr 1 Par Ref ;

Arr 2 Dim Arr 2 Par Ref ;

int Int 1 Par Val ;

int Int 2 Par Val ;

{REG One Fifty Int Index ;

Version 1.1 112

Page 113: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.4 Source-Code Dhrystone-Benchmark

REG One Fifty Int Loc ;

Int Loc = Int 1 Par Val + 5 ;

Arr 1 Par Ref [ Int Loc ] = Int 2 Par Val ;

Arr 1 Par Ref [ Int Loc +1] = Arr 1 Par Ref [ Int Loc ] ;

Arr 1 Par Ref [ Int Loc +30] = Int Loc ;

for ( Int Index = Int Loc ; Int Index <= Int Loc +1; ++Int Index )

Arr 2 Par Ref [ Int Loc ] [ Int Index ] = Int Loc ;

Arr 2 Par Ref [ Int Loc ] [ Int Loc −1] += 1 ;

Arr 2 Par Ref [ Int Loc +20] [ Int Loc ] = Arr 1 Par Ref [ Int Loc ] ;

Int Glob = 5 ;

} /∗ Proc 8 ∗/

Enumeration Func 1 ( Ch 1 Par Val , Ch 2 Par Val )

/∗ ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗ ∗//∗ executed th r ee t imes ∗//∗ f i r s t c a l l : Ch 1 Par Val == ’H ’ , Ch 2 Par Val == ’R’ ∗//∗ second c a l l : Ch 1 Par Val == ’A ’ , Ch 2 Par Val == ’C ’ ∗//∗ t h i r d c a l l : Ch 1 Par Val == ’B ’ , Ch 2 Par Val == ’C ’ ∗/

Cap i t a l Le t t e r Ch 1 Par Val ;

Cap i t a l Le t t e r Ch 2 Par Val ;

{Cap i t a l Le t t e r Ch 1 Loc ;

Cap i t a l Le t t e r Ch 2 Loc ;

Ch 1 Loc = Ch 1 Par Val ;

Ch 2 Loc = Ch 1 Loc ;

i f ( Ch 2 Loc != Ch 2 Par Val )

/∗ then , executed ∗/return ( Ident 1 ) ;

else /∗ not executed ∗/{

Ch 1 Glob = Ch 1 Loc ;

return ( Ident 2 ) ;

}} /∗ Func 1 ∗/

Boolean Func 2 ( Str 1 Par Ref , St r 2 Par Ref )

/∗ ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗ ∗//∗ executed once ∗//∗ Str 1 Par Ref == ”DHRYSTONE PROGRAM, 1 ’ST STRING” ∗//∗ Str 2 Par Ref == ”DHRYSTONE PROGRAM, 2 ’ND STRING” ∗/

Str 30 Str 1 Par Ref ;

St r 30 Str 2 Par Ref ;

{

Version 1.1 113

Page 114: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.4 Source-Code Dhrystone-Benchmark

REG One Thirty Int Loc ;

Cap i t a l Le t t e r Ch Loc ;

Int Loc = 2 ;

while ( Int Loc <= 2) /∗ l oop body executed once ∗/i f ( Func 1 ( Str 1 Par Ref [ Int Loc ] ,

St r 2 Par Ref [ Int Loc +1]) == Ident 1 )

/∗ then , executed ∗/{

Ch Loc = ’A ’ ;

Int Loc += 1 ;

} /∗ i f , wh i l e ∗/i f (Ch Loc >= ’W’ && Ch Loc < ’Z ’ )

/∗ then , not execu ted ∗/Int Loc = 7 ;

i f (Ch Loc == ’R ’ )

/∗ then , not execu ted ∗/return ( t rue ) ;

else /∗ executed ∗/{

i f ( strcmp ( Str 1 Par Ref , St r 2 Par Ref ) > 0)

/∗ then , not execu ted ∗/{

Int Loc += 7 ;

Int Glob = Int Loc ;

return ( t rue ) ;

}else /∗ executed ∗/

return ( f a l s e ) ;

} /∗ i f Ch Loc ∗/} /∗ Func 2 ∗/

Boolean Func 3 (Enum Par Val )

/∗ ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗ ∗//∗ executed once ∗//∗ Enum Par Val == Iden t 3 ∗/

Enumeration Enum Par Val ;

{Enumeration Enum Loc ;

Enum Loc = Enum Par Val ;

i f (Enum Loc == Ident 3 )

/∗ then , executed ∗/return ( t rue ) ;

else /∗ not executed ∗/return ( f a l s e ) ;

} /∗ Func 3 ∗/

Version 1.1 114

Page 115: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.5 Source-Code 1000s

8.5 Source-Code 1000s

Quelle: http://www.netlib.org/benchmark/1000s

8.5.1 1000s.f

# cut 1000s.f

real a (1001 ,1000) , b (1000) , x (1000)

real time (6 ) , cray , ops , t o ta l , norma , normx

real r e s id , re s idn , eps , eps lon

integer i pv t (1000)

lda = 1001

c

c t h i s program was updated on 10/12/92 to co r r e c t a

c problem with the random number genera tor . The prev ious

c random number genera tor had a shor t per iod and produced

c s i n gu l a r matr ices o c c a s i o na l l y .

c

n = 1000

cray = .056

write ( 6 , 1 )

1 format ( ’ P lease send the r e s u l t s o f t h i s run to : ’ / /

$ ’ Jack J . Dongarra ’ /

$ ’ Computer Sc i ence Department ’ /

$ ’ Un ive r s i ty o f Tennessee ’ /

$ ’ Knoxvi l le , Tennessee 37996−1300 ’//

$ ’ Fax : 615−974−8296 ’//

$ ’ I n t e rn e t : dongarra@cs . utk . edu ’ / )

ops = (2 . 0 d0∗ f l o a t (n )∗∗3)/3 . 0 d0 + 2 .0 d0∗ f l o a t (n)∗∗2

c

ca l l matgen (a , lda , n , b , norma)

c ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗c ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗c you shou ld r ep l a c e the c a l l to s g e f a and s g e s l

c by c a l l s to your l i n e a r equat ion s o l v e r .

c ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗c ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗

t1 = second ( )

ca l l s g e f a ( a , lda , n , ipvt , i n f o )

time (1 ) = second ( ) − t1

t1 = second ( )

ca l l s g e s l ( a , lda , n , ipvt , b , 0 )

time (2 ) = second ( ) − t1

t o t a l = time (1 ) + time (2)

c ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗c ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗c

c compute a r e s i d u a l to v e r i f y r e s u l t s .

Version 1.1 115

Page 116: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.5 Source-Code 1000s

c

do 10 i = 1 ,n

x ( i ) = b( i )

10 continue

ca l l matgen (a , lda , n , b , norma)

do 20 i = 1 ,n

b( i ) = −b( i )

20 continue

ca l l smxpy(n , b , n , lda , x , a )

r e s i d = 0 .0

normx = 0 .0

do 30 i = 1 ,n

r e s i d = amax1( r e s id , abs (b( i ) ) )

normx = amax1( normx , abs (x ( i ) ) )

30 continue

eps = eps lon ( 1 . 0 )

r e s i dn = r e s i d /( n∗norma∗normx∗ eps )

write (6 , 40 )

40 format ( ’ norm . r e s i d r e s i d machep ’ ,

$ ’ x (1 ) x (n ) ’ )

write (6 , 50 ) res idn , r e s id , eps , x ( 1 ) , x (n)

50 format (1 p5e16 . 8 )

c

write (6 , 60 ) n

60 format (// ’ t imes are reported f o r matr i ce s o f order ’ , i 5 )

write (6 , 70 )

70 format (6x , ’ f a c to r ’ , 5 x , ’ so lve ’ , 6 x , ’ t o ta l ’ , 5 x , ’ mflops ’ , 7 x , ’ unit ’ ,

$ 6x , ’ r a t i o ’ )

c

time (3 ) = t o t a l

time (4 ) = ops / (1 . 0 e6∗ t o t a l )

time (5 ) = 2 .0 e0/ time (4)

time (6 ) = t o t a l / cray

write (6 , 80 ) lda

80 format ( ’ t imes f o r array with l ead ing dimension of ’ , i 4 )

write (6 ,110) ( time ( i ) , i =1 ,6)

110 format (6(1 pe11 . 3 ) )

write ( 6 ,∗ ) ’ end o f t e s t s −− t h i s v e r s i on dated 10/12/92 ’

c

stop

end

subroutine matgen (a , lda , n , b , norma)

integer lda , n , i , j , i n i t (4 )

real a ( lda , 1 ) , b ( 1 ) , norma , ran

c

i n i t (1 ) = 1

i n i t (2 ) = 2

i n i t (3 ) = 3

i n i t (4 ) = 1325

Version 1.1 116

Page 117: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.5 Source-Code 1000s

norma = 0 .0

do 30 j = 1 ,n

do 20 i = 1 ,n

a ( i , j ) = ran ( i n i t ) − . 5

norma = amax1( abs ( a ( i , j ) ) , norma)

20 continue

30 continue

do 35 i = 1 ,n

b( i ) = 0 .0

35 continue

do 50 j = 1 ,n

do 40 i = 1 ,n

b( i ) = b( i ) + a ( i , j )

40 continue

50 continue

return

end

subroutine s g e f a ( a , lda , n , ipvt , i n f o )

integer lda , n , ipvt ( 1 ) , i n f o

real a ( lda , 1 )

c

c s g e f a f a c t o r s a r e a l matrix by gauss ian e l im ina t i on .

c

c s g e f a i s u s u a l l y c a l l e d by dgeco , but i t can be c a l l e d

c d i r e c t l y wi th a sav ing in time i f rcond i s not needed .

c ( time f o r dgeco ) = (1 + 9/n)∗( time f o r s g e f a ) .

c

c on entry

c

c a r e a l ( lda , n)

c the matrix to be f a c t o r e d .

c

c l da i n t e g e r

c the l e ad in g dimension o f the array a .

c

c n i n t e g e r

c the order o f the matrix a .

c

c on re turn

c

c a an upper t r i a n g u l a r matrix and the mu l t i p l i e r s

c which were used to ob ta in i t .

c the f a c t o r i z a t i o n can be wr i t t en a = l ∗u where

c l i s a product o f permutat ion and un i t lower

c t r i a n g u l a r matr ices and u i s upper t r i a n g u l a r .

c

c i p v t i n t e g e r (n)

c an i n t e g e r v e c t o r o f p i v o t i n d i c e s .

c

Version 1.1 117

Page 118: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.5 Source-Code 1000s

c i n f o i n t e g e r

c = 0 normal va lue .

c = k i f u( k , k ) . eq . 0 .0 . t h i s i s not an error

c cond i t i on f o r t h i s subrout ine , but i t does

c i n d i c a t e t ha t s g e s l or dged i w i l l d i v i d e by zero

c i f c a l l e d . use rcond in dgeco f o r a r e l i a b l e

c i n d i c a t i on o f s i n g u l a r i t y .

c

c l i npac k . t h i s v e r s i on dated 08/14/78 .

c c l e v e moler , u n i v e r s i t y o f new mexico , argonne na t i ona l l a b .

c

c sub rou t ine s and func t i on s

c

c b l a s saxpy , s s ca l , isamax

c

c i n t e r n a l v a r i a b l e s

c

real t

integer isamax , j , k , kp1 , l , nm1

c

c

c gauss ian e l im ina t i on wi th p a r t i a l p i v o t i n g

c

i n f o = 0

nm1 = n − 1

i f (nm1 . l t . 1) go to 70

do 60 k = 1 , nm1

kp1 = k + 1

c

c f i nd l = p i v o t index

c

l = isamax (n−k+1,a (k , k ) , 1 ) + k − 1

ipvt (k ) = l

c

c zero p i v o t imp l i e s t h i s column a l ready t r i a n g u l a r i z e d

c

i f ( a ( l , k ) . eq . 0 . 0 e0 ) go to 40

c

c in t e rchange i f necessary

c

i f ( l . eq . k ) go to 10

t = a ( l , k )

a ( l , k ) = a (k , k )

a (k , k ) = t

10 continue

c

c compute mu l t i p l i e r s

c

t = −1.0 e0/a (k , k )

Version 1.1 118

Page 119: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.5 Source-Code 1000s

ca l l s s c a l (n−k , t , a ( k+1,k ) , 1 )

c

c row e l im ina t i on with column index ing

c

do 30 j = kp1 , n

t = a ( l , j )

i f ( l . eq . k ) go to 20

a ( l , j ) = a (k , j )

a (k , j ) = t

20 continue

ca l l saxpy (n−k , t , a ( k+1,k ) , 1 , a ( k+1, j ) , 1 )

30 continue

go to 50

40 continue

i n f o = k

50 continue

60 continue

70 continue

i pv t (n) = n

i f ( a (n , n) . eq . 0 . 0 e0 ) i n f o = n

return

end

subroutine s g e s l ( a , lda , n , ipvt , b , job )

integer lda , n , ipvt ( 1 ) , job

real a ( lda , 1 ) , b (1 )

c

c s g e s l s o l v e s the r e a l system

c a ∗ x = b or t rans (a ) ∗ x = b

c us ing the f a c t o r s computed by dgeco or s g e f a .

c

c on entry

c

c a r e a l ( lda , n)

c the output from dgeco or s g e f a .

c

c l da i n t e g e r

c the l e ad in g dimension o f the array a .

c

c n i n t e g e r

c the order o f the matrix a .

c

c i p v t i n t e g e r (n)

c the p i v o t v e c t o r from dgeco or s g e f a .

c

c b r e a l (n)

c the r i g h t hand s i d e vec t o r .

c

c job i n t e g e r

c = 0 to s o l v e a∗x = b ,

Version 1.1 119

Page 120: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.5 Source-Code 1000s

c = nonzero to s o l v e t rans (a )∗ x = b where

c t rans (a ) i s the t ranspose .

c

c on re turn

c

c b the s o l u t i o n vec t o r x .

c

c error cond i t i on

c

c a d i v i s i o n by zero w i l l occur i f the input f a c t o r conta ins a

c zero on the d iagona l . t e c h n i c a l l y t h i s i n d i c a t e s s i n g u l a r i t y

c but i t i s o f t en caused by improper arguments or improper

c s e t t i n g o f l da . i t w i l l not occur i f the sub rou t ine s are

c c a l l e d c o r r e c t l y and i f dgeco has s e t rcond . g t . 0 .0

c or s g e f a has s e t i n f o . eq . 0 .

c

c to compute in v e r s e (a ) ∗ c where c i s a matrix

c wi th p columns

c c a l l dgeco (a , lda , n , i pv t , rcond , z )

c i f ( rcond i s too sma l l ) go to . . .

c do 10 j = 1 , p

c c a l l s g e s l (a , lda , n , i pv t , c (1 , j ) ,0 )

c 10 cont inue

c

c l i npac k . t h i s v e r s i on dated 08/14/78 .

c c l e v e moler , u n i v e r s i t y o f new mexico , argonne na t i ona l l a b .

c

c sub rou t ine s and func t i on s

c

c b l a s saxpy , sdo t

c

c i n t e r n a l v a r i a b l e s

c

real sdot , t

integer k , kb , l , nm1

c

nm1 = n − 1

i f ( job . ne . 0) go to 50

c

c job = 0 , s o l v e a ∗ x = b

c f i r s t s o l v e l ∗y = b

c

i f (nm1 . l t . 1) go to 30

do 20 k = 1 , nm1

l = ipvt (k )

t = b( l )

i f ( l . eq . k ) go to 10

b( l ) = b(k )

b(k ) = t

Version 1.1 120

Page 121: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.5 Source-Code 1000s

10 continue

ca l l saxpy (n−k , t , a ( k+1,k ) , 1 , b(k+1) ,1)

20 continue

30 continue

c

c now so l v e u∗x = y

c

do 40 kb = 1 , n

k = n + 1 − kb

b(k ) = b(k )/ a (k , k )

t = −b(k )

ca l l saxpy (k−1, t , a (1 , k ) , 1 , b ( 1 ) , 1 )

40 continue

go to 100

50 continue

c

c job = nonzero , s o l v e t rans (a ) ∗ x = b

c f i r s t s o l v e t rans (u)∗ y = b

c

do 60 k = 1 , n

t = sdot (k−1,a (1 , k ) , 1 , b ( 1 ) , 1 )

b(k ) = (b(k ) − t )/ a (k , k )

60 continue

c

c now so l v e t rans ( l )∗ x = y

c

i f (nm1 . l t . 1) go to 90

do 80 kb = 1 , nm1

k = n − kb

b(k ) = b(k ) + sdot (n−k , a (k+1,k ) , 1 , b (k+1) ,1)

l = ipvt (k )

i f ( l . eq . k ) go to 70

t = b( l )

b( l ) = b(k )

b(k ) = t

70 continue

80 continue

90 continue

100 continue

return

end

subroutine saxpy (n , da , dx , incx , dy , incy )

c

c cons tant t imes a vec t o r p l u s a vec t o r .

c uses un ro l l e d l oops f o r increments equa l to one .

c jack dongarra , l inpack , 3/11/78.

c

real dx (1 ) , dy (1 ) , da

integer i , incx , incy , ix , iy ,m,mp1 , n

Version 1.1 121

Page 122: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.5 Source-Code 1000s

c

i f (n . l e . 0 ) return

i f ( da . eq . 0 . 0 e0 ) return

i f ( incx . eq . 1 . and . incy . eq . 1 ) go to 20

c

c code f o r unequal increments or equa l increments

c not equa l to 1

c

i x = 1

iy = 1

i f ( incx . l t . 0 ) i x = (−n+1)∗ incx + 1

i f ( incy . l t . 0 ) i y = (−n+1)∗ incy + 1

do 10 i = 1 ,n

dy ( iy ) = dy ( iy ) + da∗dx ( ix )

ix = ix + incx

iy = iy + incy

10 continue

return

c

c code f o r both increments equa l to 1

c

c

c c lean−up loop

c

20 m = mod(n , 4 )

i f ( m . eq . 0 ) go to 40

do 30 i = 1 ,m

dy ( i ) = dy ( i ) + da∗dx ( i )

30 continue

i f ( n . l t . 4 ) return

40 mp1 = m + 1

do 50 i = mp1, n , 4

dy ( i ) = dy ( i ) + da∗dx ( i )

dy ( i + 1) = dy ( i + 1) + da∗dx ( i + 1)

dy ( i + 2) = dy ( i + 2) + da∗dx ( i + 2)

dy ( i + 3) = dy ( i + 3) + da∗dx ( i + 3)

50 continue

return

end

real function sdot (n , dx , incx , dy , incy )

c

c forms the dot product o f two v e c t o r s .

c uses un ro l l e d l oops f o r increments equa l to one .

c jack dongarra , l inpack , 3/11/78.

c

real dx (1 ) , dy (1 ) , dtemp

integer i , incx , incy , ix , iy ,m,mp1 , n

c

sdot = 0 .0 e0

Version 1.1 122

Page 123: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.5 Source-Code 1000s

dtemp = 0.0 e0

i f (n . l e . 0 ) return

i f ( incx . eq . 1 . and . incy . eq . 1 ) go to 20

c

c code f o r unequal increments or equa l increments

c not equa l to 1

c

i x = 1

iy = 1

i f ( incx . l t . 0 ) i x = (−n+1)∗ incx + 1

i f ( incy . l t . 0 ) i y = (−n+1)∗ incy + 1

do 10 i = 1 ,n

dtemp = dtemp + dx( ix )∗dy ( iy )

ix = ix + incx

iy = iy + incy

10 continue

sdot = dtemp

return

c

c code f o r both increments equa l to 1

c

c

c c lean−up loop

c

20 m = mod(n , 5 )

i f ( m . eq . 0 ) go to 40

do 30 i = 1 ,m

dtemp = dtemp + dx( i )∗dy ( i )

30 continue

i f ( n . l t . 5 ) go to 60

40 mp1 = m + 1

do 50 i = mp1, n , 5

dtemp = dtemp + dx( i )∗dy ( i ) + dx ( i + 1)∗dy ( i + 1) +

∗ dx ( i + 2)∗dy ( i + 2) + dx ( i + 3)∗dy ( i + 3) + dx ( i + 4)∗dy ( i + 4)

50 continue

60 sdot = dtemp

return

end

subroutine s s c a l (n , da , dx , incx )

c

c s c a l e s a vec t o r by a cons tant .

c uses un ro l l e d l oops f o r increment equa l to one .

c jack dongarra , l inpack , 3/11/78.

c

real da , dx (1 )

integer i , incx ,m,mp1 , n , nincx

c

i f (n . l e . 0 ) return

i f ( incx . eq . 1 ) go to 20

Version 1.1 123

Page 124: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.5 Source-Code 1000s

c

c code f o r increment not equa l to 1

c

nincx = n∗ incx

do 10 i = 1 , nincx , incx

dx ( i ) = da∗dx ( i )

10 continue

return

c

c code f o r increment equa l to 1

c

c

c c lean−up loop

c

20 m = mod(n , 5 )

i f ( m . eq . 0 ) go to 40

do 30 i = 1 ,m

dx ( i ) = da∗dx ( i )

30 continue

i f ( n . l t . 5 ) return

40 mp1 = m + 1

do 50 i = mp1, n , 5

dx ( i ) = da∗dx ( i )

dx ( i + 1) = da∗dx ( i + 1)

dx ( i + 2) = da∗dx ( i + 2)

dx ( i + 3) = da∗dx ( i + 3)

dx ( i + 4) = da∗dx ( i + 4)

50 continue

return

end

integer function isamax (n , dx , incx )

c

c f i n d s the index o f e lement having max . a b s o l u t e va lue .

c j ack dongarra , l inpack , 3/11/78.

c

real dx (1 ) , dmax

integer i , incx , ix , n

c

isamax = 0

i f ( n . l t . 1 ) return

isamax = 1

i f (n . eq . 1 ) return

i f ( incx . eq . 1 ) go to 20

c

c code f o r increment not equa l to 1

c

i x = 1

dmax = abs (dx ( 1 ) )

ix = ix + incx

Version 1.1 124

Page 125: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.5 Source-Code 1000s

do 10 i = 2 ,n

i f ( abs (dx ( ix ) ) . l e . dmax) go to 5

isamax = i

dmax = abs (dx ( ix ) )

5 ix = ix + incx

10 continue

return

c

c code f o r increment equa l to 1

c

20 dmax = abs (dx ( 1 ) )

do 30 i = 2 ,n

i f ( abs (dx ( i ) ) . l e . dmax) go to 30

isamax = i

dmax = abs (dx ( i ) )

30 continue

return

end

REAL FUNCTION EPSLON (X)

REAL X

C

C ESTIMATE UNIT ROUNDOFF IN QUANTITIES OF SIZE X.

C

REAL A,B,C,EPS

C

C THIS PROGRAM SHOULD FUNCTION PROPERLY ON ALL SYSTEMS

C SATISFYING THE FOLLOWING TWO ASSUMPTIONS,

C 1. THE BASE USED IN REPRESENTING FLOATING POINT

C NUMBERS IS NOT A POWER OF THREE.

C 2. THE QUANTITY A IN STATEMENT 10 IS REPRESENTED TO

C THE ACCURACY USED IN FLOATING POINT VARIABLES

C THAT ARE STORED IN MEMORY.

C THE STATEMENT NUMBER 10 AND THE GO TO 10 ARE INTENDED TO

C FORCE OPTIMIZING COMPILERS TO GENERATE CODE SATISFYING

C ASSUMPTION 2.

C UNDER THESE ASSUMPTIONS, IT SHOULD BE TRUE THAT,

C A IS NOT EXACTLY EQUAL TO FOUR−THIRDS,

C B HAS A ZERO FOR ITS LAST BIT OR DIGIT ,

C C IS NOT EXACTLY EQUAL TO ONE,

C EPS MEASURES THE SEPARATION OF 1.0 FROM

C THE NEXT LARGER FLOATING POINT NUMBER.

C THE DEVELOPERS OF EISPACK WOULD APPRECIATE BEING INFORMED

C ABOUT ANY SYSTEMS WHERE THESE ASSUMPTIONS DO NOT HOLD.

C

C ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗C THIS ROUTINE IS ONE OF THE AUXILIARY ROUTINES USED BY EISPACK I I I

C TO AVOID MACHINE DEPENDENCIES.

C ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗C

Version 1.1 125

Page 126: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.5 Source-Code 1000s

C THIS VERSION DATED 4/6/83.

C

A = 4.0E0/3 .0E0

10 B = A − 1 .0E0

C = B + B + B

EPS = ABS(C−1.0E0)

IF (EPS .EQ. 0 .0E0) GO TO 10

EPSLON = EPS∗ABS(X)

RETURN

END

SUBROUTINE MM (A, LDA, N1 , N3 , B, LDB, N2 , C, LDC)

REAL A(LDA, ∗ ) , B(LDB, ∗ ) , C(LDC, ∗ )

C

C PURPOSE:

C MULTIPLY MATRIX B TIMES MATRIX C AND STORE THE RESULT IN MATRIX A.

C

C PARAMETERS:

C

C A REAL(LDA,N3) , MATRIX OF N1 ROWS AND N3 COLUMNS

C

C LDA INTEGER, LEADING DIMENSION OF ARRAY A

C

C N1 INTEGER, NUMBER OF ROWS IN MATRICES A AND B

C

C N3 INTEGER, NUMBER OF COLUMNS IN MATRICES A AND C

C

C B REAL(LDB,N2) , MATRIX OF N1 ROWS AND N2 COLUMNS

C

C LDB INTEGER, LEADING DIMENSION OF ARRAY B

C

C N2 INTEGER, NUMBER OF COLUMNS IN MATRIX B, AND NUMBER OF ROWS IN

C MATRIX C

C

C C REAL(LDC,N3) , MATRIX OF N2 ROWS AND N3 COLUMNS

C

C LDC INTEGER, LEADING DIMENSION OF ARRAY C

C

C −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−C

DO 20 J = 1 , N3

DO 10 I = 1 , N1

A( I , J ) = 0 .0

10 CONTINUE

CALL SMXPY (N2 ,A(1 , J ) ,N1 ,LDB,C(1 , J ) ,B)

20 CONTINUE

C

RETURN

END

SUBROUTINE SMXPY (N1 , Y, N2 , LDM, X, M)

Version 1.1 126

Page 127: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.5 Source-Code 1000s

REAL Y(∗ ) , X(∗ ) , M(LDM, ∗ )

C

C PURPOSE:

C MULTIPLY MATRIX M TIMES VECTOR X AND ADD THE RESULT TO VECTOR Y.

C

C PARAMETERS:

C

C N1 INTEGER, NUMBER OF ELEMENTS IN VECTOR Y, AND NUMBER OF ROWS IN

C MATRIX M

C

C Y REAL(N1) , VECTOR OF LENGTH N1 TO WHICH IS ADDED THE PRODUCT M∗XC

C N2 INTEGER, NUMBER OF ELEMENTS IN VECTOR X, AND NUMBER OF COLUMNS

C IN MATRIX M

C

C LDM INTEGER, LEADING DIMENSION OF ARRAY M

C

C X REAL(N2) , VECTOR OF LENGTH N2

C

C M REAL(LDM,N2) , MATRIX OF N1 ROWS AND N2 COLUMNS

C

C −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−C

C CLEANUP ODD VECTOR

C

J = MOD(N2 , 2 )

IF ( J .GE. 1) THEN

DO 10 I = 1 , N1

Y( I ) = (Y( I ) ) + X(J )∗M( I , J )

10 CONTINUE

ENDIF

C

C CLEANUP ODD GROUP OF TWO VECTORS

C

J = MOD(N2 , 4 )

IF ( J .GE. 2) THEN

DO 20 I = 1 , N1

Y( I ) = ( (Y( I ) )

$ + X(J−1)∗M( I , J−1)) + X(J )∗M( I , J )

20 CONTINUE

ENDIF

C

C CLEANUP ODD GROUP OF FOUR VECTORS

C

J = MOD(N2 , 8 )

IF ( J .GE. 4) THEN

DO 30 I = 1 , N1

Y( I ) = ( ( ( (Y( I ) )

$ + X(J−3)∗M( I , J−3)) + X(J−2)∗M( I , J−2))

Version 1.1 127

Page 128: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.5 Source-Code 1000s

$ + X(J−1)∗M( I , J−1)) + X(J ) ∗M( I , J )

30 CONTINUE

ENDIF

C

C CLEANUP ODD GROUP OF EIGHT VECTORS

C

J = MOD(N2, 1 6 )

IF ( J .GE. 8) THEN

DO 40 I = 1 , N1

Y( I ) = ( ( ( ( ( ( ( (Y( I ) )

$ + X(J−7)∗M( I , J−7)) + X(J−6)∗M( I , J−6))

$ + X(J−5)∗M( I , J−5)) + X(J−4)∗M( I , J−4))

$ + X(J−3)∗M( I , J−3)) + X(J−2)∗M( I , J−2))

$ + X(J−1)∗M( I , J−1)) + X(J ) ∗M( I , J )

40 CONTINUE

ENDIF

C

C MAIN LOOP − GROUPS OF SIXTEEN VECTORS

C

JMIN = J+16

DO 60 J = JMIN, N2 , 16

DO 50 I = 1 , N1

Y( I ) = ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( (Y( I ) )

$ + X(J−15)∗M( I , J−15)) + X(J−14)∗M( I , J−14))

$ + X(J−13)∗M( I , J−13)) + X(J−12)∗M( I , J−12))

$ + X(J−11)∗M( I , J−11)) + X(J−10)∗M( I , J−10))

$ + X(J− 9)∗M( I , J− 9) ) + X(J− 8)∗M( I , J− 8) )

$ + X(J− 7)∗M( I , J− 7) ) + X(J− 6)∗M( I , J− 6) )

$ + X(J− 5)∗M( I , J− 5) ) + X(J− 4)∗M( I , J− 4) )

$ + X(J− 3)∗M( I , J− 3) ) + X(J− 2)∗M( I , J− 2) )

$ + X(J− 1)∗M( I , J− 1) ) + X(J ) ∗M( I , J )

50 CONTINUE

60 CONTINUE

RETURN

END

REAL FUNCTION RAN( ISEED )

∗∗ modi f ied from the LAPACK au x i l i a r y rou t ine 10/12/92 JD

∗ −− LAPACK au x i l i a r y rou t ine ( ve r s i on 1 .0 ) −−∗ Univ . o f Tennessee , Univ . o f Ca l i f o rn i a Berke ley , NAG Ltd . ,

∗ Courant I n s t i t u t e , Argonne Nat iona l Lab , and Rice Un i v e r s i t y

∗ February 29 , 1992

∗∗ . . Array Arguments . .

INTEGER ISEED( 4 )

∗ . .

∗∗ Purpose

∗ =======

Version 1.1 128

Page 129: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.5 Source-Code 1000s

∗∗ SLARAN re turns a random rea l number from a uniform (0 ,1)

∗ d i s t r i b u t i o n .

∗∗ Arguments

∗ =========

∗∗ ISEED ( input / output ) INTEGER array , dimension (4)

∗ On entry , the seed o f the random number genera tor ; the array

∗ e lements must be between 0 and 4095 , and ISEED(4) must be

∗ odd .

∗ On ex i t , the seed i s updated .

∗∗ Further De t a i l s

∗ ===============

∗∗ This rou t ine uses a mu l t i p l i c a t i v e cong ruen t i a l method wi th modulus

∗ 2∗∗48 and mu l t i p l i e r 33952834046453 ( see G. S . Fishman ,

∗ ’ Mu l t i p l i c a t i v e cong ruen t i a l random number genera tor s wi th modulus

∗ 2∗∗ b : an exhau s t i v e ana l y s i s f o r b = 32 and a p a r t i a l a n a l y s i s f o r

∗ b = 48 ’ , Math . Comp. 189 , pp 331−344, 1990) .

∗∗ 48− b i t i n t e g e r s are s t o r ed in 4 i n t e g e r array e lements wi th 12 b i t s

∗ per element . Hence the rou t ine i s p o r t a b l e across machines wi th

∗ i n t e g e r s o f 32 b i t s or more .

∗∗ . . Parameters . .

INTEGER M1, M2, M3, M4

PARAMETER ( M1 = 494 , M2 = 322 , M3 = 2508 , M4 = 2549 )

REAL ONE

PARAMETER ( ONE = 1.0E+0 )

INTEGER IPW2

REAL R

PARAMETER ( IPW2 = 4096 , R = ONE / IPW2 )

∗ . .

∗ . . Local Sca l a r s . .

INTEGER IT1 , IT2 , IT3 , IT4

∗ . .

∗ . . I n t r i n s i c Functions . .

INTRINSIC MOD, REAL

∗ . .

∗ . . Execu tab l e Statements . .

∗∗ mu l t i p l y the seed by the mu l t i p l i e r modulo 2∗∗48

∗IT4 = ISEED( 4 )∗M4

IT3 = IT4 / IPW2

IT4 = IT4 − IPW2∗IT3

IT3 = IT3 + ISEED( 3 )∗M4 + ISEED( 4 )∗M3

Version 1.1 129

Page 130: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.5 Source-Code 1000s

IT2 = IT3 / IPW2

IT3 = IT3 − IPW2∗IT2

IT2 = IT2 + ISEED( 2 )∗M4 + ISEED( 3 )∗M3 + ISEED( 4 )∗M2

IT1 = IT2 / IPW2

IT2 = IT2 − IPW2∗IT1

IT1 = IT1 + ISEED( 1 )∗M4 + ISEED( 2 )∗M3 + ISEED( 3 )∗M2 +

$ ISEED( 4 )∗M1

IT1 = MOD( IT1 , IPW2 )

∗∗ re turn updated seed

∗ISEED( 1 ) = IT1

ISEED( 2 ) = IT2

ISEED( 3 ) = IT3

ISEED( 4 ) = IT4

∗∗ conver t 48− b i t i n t e g e r to a r e a l number in the i n t e r v a l (0 ,1)

∗RAN = R∗( REAL( IT1 )+R∗( REAL( IT2 )+R∗( REAL( IT3 )+R∗

$ ( REAL( IT4 ) ) ) ) )

RETURN

∗∗ End of RAN

∗END

Version 1.1 130

Page 131: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

8.6 Source-Code LLCBench

Quelle: http://icl.cs.utk.edu/projects/llcbench/llcbench.tar.gz

8.6.1 LLCBench

user.def

#cut user.def

# This f i l e conta in the common machine−independent op t i ons f o r the s u i t e . #

###########################################################################

# Pre f i x o f the output f i l e s produced by each benchmark

# i f t h i s f a i l s , r e p l a c e i t wi th a r e gu l a r name !

Resu l t P r e f i x := $ ( s h e l l hostname)−$ ( s h e l l uname −m)

#### Blasbench Config

# The number o f t e s t s which are averaged t o g e t h e r f o r each r e s u l t

# Remember the cache i s not f l u s h e d between i t e r a t i o n s , on ly between t e s t s i z e s

BB Ite rat ions = 1

# The number o f t imes each t e s t i s run

BB RepeatCount = 1

# Log base 2 o f the maximum problem s i z e t e s t e d in b y t e s

BB Memsize = 20

# The number o f t e s t s i z e s measured between powers o f two

BB Resolution = 0

# This v a r i a b l e s e t s the AXPY mem s i z e , keep i t sma l l to have the p l o t s l ook nice .

BB AXPY Memsize = 20

# This v a r i a b l e s e t s the name o f the BLAS implementat ion

BB Prefix = Reference

#BB Prefix = I n t e l MKL

#BB Prefix = IBM ESSL

#### Cachebench Config

# Datatype used f o r each memory r e f e r ence .

# Legal va l u e s are DOUBLE, CHAR, INT, FLOAT

CB Datatype = FLOAT

# The number o f seconds each t e s t runs .

CB SecondsPerIterat ion = 10

Version 1.1 131

Page 132: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

# The number o f t imes each t e s t i s run .

CB RepeatCount = 1

# Log base 2 o f the maximum problem s i z e t e s t e d in b y t e s

CB Memsize = 20

# The number o f t e s t s i z e s measured between powers o f two

CB Resolution = 2

#### MPbench s t u f f

# The number o f t e s t s which are averaged t o g e t h e r f o r each r e s u l t

# Remember the cache i s not f l u s h e d between i t e r a t i o n s , on ly repea ted

# t e s t s

MP Iterat ions = 5000

# The number o f t a s k s used by the MPI c o l l e c t i v e rou t i n e s

MP Tasks = 2

# The number o f t imes each t e s t i s run .

MP RepeatCount = 1

# Log base 2 o f the maximum message s i z e t e s t e d in b y t e s

MP Memsize = 24

# The number o f t e s t s i z e s measured between powers o f two

MP Resolution = 2

# The f i l e con ta in ing the na t i v e MPI h o s t f i l e i f necessary / de s i r e d

# For example , MPICH users might use

#

# Line f o r VMI2/MVICH

# MP Host f i le = −h f $ (HOME)/ machines

# Line f o r MPICH/MPICH2/MVAPICH

# MP Host f i le = −mach ine f i l e $ (HOME)/ machines

Version 1.1 132

Page 133: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

x86: sys.def -> conf/sys.linux-lam

x86# cat sys.def

# Linux−lam sys . de f

# Blasbench va l ue s

BB CC = gcc

BB F77 = g fo r t r an

BB LD = g fo r t r an

BB CFLAGS = −O3 −Wall −DREGISTER −DINLINE −march=pentium2 −v

BB LDFLAGS = $ (BB CFLAGS)

BB LIBS = − l b l a s − l r t

# Cachebench va l ue s

CB CC = $ (BB CC)

CB CFLAGS = −O3 −Wall −v −march=pentium2

CB LDFLAGS = $ (CB CFLAGS)

CB LIBS = − l r t

# MPbench va l u e s

MP MPI CC = mpicc

MP CFLAGS = $ (BB CFLAGS)

MP LIBS = − l r t

MPIRUNCMD = mpirun

MPIRUNOPTS = −w −O −c2c

MPIRUNPROCS = −c

MPIRUNPOSTOPTS = mpi bench −−

Version 1.1 133

Page 134: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

sun: sys.def -> conf/sys.linux-lam

sun# cat sys.def

# Linux−lam sys . de f

# Blasbench va l ue s

BB CC = gcc

BB F77 = g fo r t r an

BB LD = g fo r t r an

BB CFLAGS = −O3 −Wall −DREGISTER −DINLINE −mvis −mcpu=u l t r a spa r c −v

BB LDFLAGS = $ (BB CFLAGS)

BB LIBS = − l b l a s − l r t

# Cachebench va l ue s

CB CC = $ (BB CC)

CB CFLAGS = −O3 −Wall −v −mcpu=u l t r a spa r c −mvis

CB LDFLAGS = $ (CB CFLAGS)

CB LIBS = − l r t

# MPbench va l u e s

MP MPI CC = mpicc

MP CFLAGS = $ (BB CFLAGS)

MP LIBS = − l r t

MPIRUNCMD = mpirun

MPIRUNOPTS = −w −O −c2c

MPIRUNPROCS = −c

MPIRUNPOSTOPTS = mpi bench −−

Version 1.1 134

Page 135: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

llcbench.h

# cut llcbench.h

/∗ Proto types ∗/

extern void f l u s h a l l ( int ) ;

extern void t ime r s t a r t (void ) ;

extern void t imer s top (void ) ;

extern double t ime r e l ap s ed (void ) ;

/∗ Macros ∗/

#define FLUSHALL( a ) i f ( ! no f lu sh ) f l u s h a l l ( a )

#define TIMER START t ime r s t a r t ( )

#define TIMER STOP t imer s top ( )

#define TIMER ELAPSED t imer e l ap s ed ( )

#ifdef INLINE

#undef INLINE

#define INLINE i n l i n e

#else

#define INLINE

#endif

#i fde f REGISTER

#undef REGISTER

#define REGISTER register

#else

#define REGISTER

#endif

#i fde f DEBUG

#define DBG(a ) a ;

#else

#define DBG(a )

#endif

Version 1.1 135

Page 136: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

flushall.c

# cut flushall.c

#include <s t d i o . h>

#include <s t d l i b . h>

#include <memory . h>

#define MAX MEM TO FLUSH 1<<24

void f l u s h a l l ( int yes )

{stat ic char ∗ bu f f e r = NULL;

stat ic char va l = 1 ;

i f ( yes )

{i f ( bu f f e r == NULL)

{bu f f e r = (char ∗) mal loc (MAX MEM TO FLUSH∗ s izeof (char ) ) ;

i f ( bu f f e r == NULL)

{f p r i n t f ( s tde r r , ” f l u s h a l l . c : mal loc o f %d bytes f a i l e d .\n” ,MAX MEM TO FLUSH) ;

e x i t ( 1 ) ;

}}

memset ( bu f f e r , va l++,MAX MEM TO FLUSH) ;

}else

{i f ( bu f f e r )

{f r e e ( bu f f e r ) ;

bu f f e r = NULL;

}}

}

Version 1.1 136

Page 137: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

timer.c

# cut timer.c

#include <s t d i o . h>

#include <time . h>

#include <sys / time . h>

#include <sys / types . h>

#include ” l l cb ench . h”

stat ic double t1 , t2 ;

void t ime r s t a r t (void )

{#i f de f ined (USE GETTIMEOFDAY)

{struct t imeval t s ;

gett imeofday(&ts , ( struct t imezone ∗ ) 0 ) ;

t1 = (double ) t s . t v s e c ∗1000000000.0 + (double ) t s . tv usec ∗1000 . 0 ;

}#else

{struct t imespec t s ;

c l o ck ge t t ime (CLOCK REALTIME,& t s ) ;

t1 = (double ) t s . t v s e c ∗1000000000.0 + (double ) t s . tv nsec ;

}#endif

DBG( p r i n t f ( ”START %f \n” , t1 ) )

}

void t imer s top (void )

{#i f de f ined (USE GETTIMEOFDAY)

{struct t imeval t s ;

gett imeofday(&ts , ( struct t imezone ∗ ) 0 ) ;

t2 = (double ) t s . t v s e c ∗1000000000.0 + (double ) t s . tv usec ∗1000 . 0 ;

}#else

{struct t imespec t s ;

c l o ck ge t t ime (CLOCK REALTIME,& t s ) ;

t2 = (double ) t s . t v s e c ∗1000000000.0 + (double ) t s . tv nsec ;

}#endif

DBG( p r i n t f ( ”STOP %f \n” , t2 ) )

}

double t ime r e l ap s ed (void )

Version 1.1 137

Page 138: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

{i f ( t2−t1 <= 0 . 0 )

{f p r i n t f ( s tde r r , ”Warning ! The t imer i s not p r e c i s e enough . Consider i n c r e a s i n g \nthe i t e r a t i o n count or changing the t imer in t imer . c\n” ) ;

return ( 0 . 0 ) ;

}return ( ( t2−t1 ) / 1 0 0 0 . 0 ) ;

}

Version 1.1 138

Page 139: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

8.6.2 BlasBench

bb.c

# cut bb.c

#include <s t d l i b . h>

#include <s t d i o . h>

#include <sys / types . h>

#include <sys / time . h>

#include <sys / t imes . h>

#include <time . h>

#include <a s s e r t . h>

#include <uni s td . h>

#include <memory . h>

#include <s t r i n g . h>

#include <math . h>

#include ” l l cb ench . h”

#ifdef T3E

#include <f o r t r an . h>

#define sgemv HGEMV

#define dgemv SGEMV

#define saxpy HAXPY

#define daxpy SAXPY

#define sgemm HGEMM

#define dgemm SGEMM

#define f oo f oo fn

#else

#define f oo &fooc

#ifdef NO UNDERSCORE

#define sgemv sgemv

#define dgemv dgemv

#define saxpy saxpy

#define daxpy daxpy

#define sgemm sgemm

#define dgemm dgemm

#endif

#endif

/∗ DEFAULT SETTINGS ∗/

#ifdef DEBUG

#define CACHE MIN BITS (8) /∗ 1<<b i t s i s lower bound ∗/#define CACHE MAX BITS (8) /∗ 1<<b i t s i s upper bound ∗/#define ITERATIONS (1)

#define LOWEST ITERATION COUNT (1)

#define RESOLUTION (1)

#define REPEAT COUNT (1)

#else

Version 1.1 139

Page 140: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

#define CACHE MIN BITS (8) /∗ 1<<b i t s i s lower bound ∗/#define CACHE MAX BITS (24) /∗ 1<<b i t s i s upper bound ∗/#define ITERATIONS (100000)

#define LOWEST ITERATION COUNT (1)

#define RESOLUTION (2)

#define REPEAT COUNT (2)

#endif

#define VECTORVECTOR (1<<0)

#define VECTORMATRIX (1<<1)

#define MATRIXMATRIX (1<<2)

#define NOCALIBRATE (1<<3)

#define SINGLEPRECISION (1<<4)

#define CONSTANTITERATIONS (1<<5)

#define OPSPSECPMREF (1<<6)

#define HOLDLDA (1<<7)

#define REPORTDIMS (1<<8)

/∗ MACROS ∗/

#define ARRAY(x , i , j ,m) ∗( x+(( i ∗m)+ j ) )

#ifdef REGISTER

#undef REGISTER

#define REGISTER register

#else

#define REGISTER

#endif

#i fde f INLINE

#undef INLINE

#define INLINE i n l i n e

#else

#define INLINE

#endif

#i fde f DEBUG

#define DBG(a ) a ;

#else

#define DBG(a )

#endif

#define CACHE MIN (1<<CACHE MIN BITS)

#define CACHE MAX (1<<CACHE MAX BITS)

#define DOUBLE NS(x ) ( (double ) x )∗1 . 0 e9

/∗ EXTERNALS ∗/

extern char ∗ optarg ;

Version 1.1 140

Page 141: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

/∗ INTERNALS ∗/

stat ic f loat f a lpha = 1 . 0 , f be ta = 1 . 0 ;

stat ic double dalpha = 1 . 0 , dbeta = 1 . 0 ;

stat ic int type = 0 ;

stat ic char f ooc = ’n ’ ;

stat ic int s t r i d e = 1 ;

stat ic int no f lu sh = 0 ;

stat ic int ∗ s i z e s , t ime s l o t s , logmemsize = CACHE MAX BITS, memsize = 1<<CACHE MAX BITS, repeat count = −1, r e s o l u t i o n = RESOLUTION;

stat ic double ∗ t , ∗bws , ∗ percents , ∗ opssmref ;

#ifdef T3E

stat ic f c d f oo fn ;

#endif

#i f de f ined ( ia64 )

#else

/∗ Entry po in t s to f o o l f o r t r an l i n k e r s . . . ∗/#ifdef l i n u x

int MAIN ( )

#endif

#i f de f ined ( hppa ) | | de f ined ( HPUX SOURCE)

int main ( )

#endif

#i f de f ined ( l i n u x ) | | de f ined ( hppa )

{#i f de f ined ( l i n u x ) && de f ined ( GNUC )

/∗ Subrout ine ∗/ int s s t op ( ) ;

s s t op ( ”” , 0L ) ;

#endif

return ( 0 ) ;

}#endif

#endif

void compute stats ( int i , int j , double r e f cn t , double datum size , double opcnt ,

double tmicrosec , int i t e r a t i o n s , int s i z e , int maxsize , int dim , int maxdim)

{double bytecnt = r e f c n t ∗datum size ;

/∗ Compute NS per memory r e f e r ence . ∗/

i f ( tmic rosec > 0 . 0 )

{ARRAY( t , i , j , r epeat count ) = ( tmic rosec ∗1000 .0)/ r e f c n t ;

/∗ Compute MFlops/ sec ∗/

ARRAY( opssmref , i , j , r epeat count ) = opcnt / tmic rosec ;

Version 1.1 141

Page 142: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

/∗ Compute MB/ sec ∗/

ARRAY(bws , i , j , r epeat count ) = ( ( ( bytecnt ) / ( 1024 . 0∗1024 . 0 ) ) / tmic rosec ) ∗ 1 .0E6 ;

}

i f ( i == 0)

{i f ( j == 0)

{ ARRAY( percents , i , j , r epeat count ) = 100 . 0 ; }else

{ARRAY( percents , i , j , r epeat count ) = 100 .0 ∗

ARRAY( t , i , j , r epeat count ) /

ARRAY( t , i , j −1, r epeat count ) ;

}}

else

{i f ( j == 0)

{ARRAY( percents , i , j , r epeat count ) = 100 .0 ∗

ARRAY( t , i , j , r epeat count ) /

ARRAY( t , i −1, repeat count −1, r epeat count ) ;

}else

{ARRAY( percents , i , j , r epeat count ) = 100 .0 ∗

ARRAY( t , i , j , r epeat count ) /

ARRAY( t , i , j −1, r epeat count ) ;

}}

i f ( i s a t t y ( 1 ) )

{i f ( type & HOLDLDA)

{i f ( type & REPORTDIMS)

p r i n t f ( ”%d\ t%d\ t%2.2 f \ t%d\ t%5.2 f \ t%5.2 f \ t%5.2 f \ t%5.2 f \n” ,

maxdim ,

dim ,

(double ) ( ( double )dim/(double )maxdim)∗100 . 0 ,

i t e r a t i o n s ,

ARRAY( t , i , j , r epeat count ) ,

ARRAY( percents , i , j , r epeat count ) ,

ARRAY( opssmref , i , j , r epeat count ) ,

ARRAY(bws , i , j , r epeat count ) ) ;

else

p r i n t f ( ”%d\ t%d\ t%2.2 f \ t%d\ t%5.2 f \ t%5.2 f \ t%5.2 f \ t%5.2 f \n” ,

Version 1.1 142

Page 143: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

maxsize ,

s i z e ,

(double ) ( ( double ) s i z e /(double ) maxsize )∗100 . 0 ,

i t e r a t i o n s ,

ARRAY( t , i , j , r epeat count ) ,

ARRAY( percents , i , j , r epeat count ) ,

ARRAY( opssmref , i , j , r epeat count ) ,

ARRAY(bws , i , j , r epeat count ) ) ;

}else

{i f ( type & REPORTDIMS)

p r i n t f ( ”%d\ t%d\ t%2.2 f \ t%d\ t%5.2 f \ t%5.2 f \ t%5.2 f \ t%5.2 f \n” ,

maxdim ,

dim ,

(double ) ( ( double )dim/(double )maxdim)∗100 . 0 ,

i t e r a t i o n s ,

ARRAY( t , i , j , r epeat count ) ,

ARRAY( percents , i , j , r epeat count ) ,

ARRAY( opssmref , i , j , r epeat count ) ,

ARRAY(bws , i , j , r epeat count ) ) ;

else

p r i n t f ( ”%d\ t%d\ t%2.2 f \ t%d\ t%5.2 f \ t%5.2 f \ t%5.2 f \ t%5.2 f \n” ,

s i z e s [ i ] ,

s i z e ,

(double ) ( ( double ) s i z e /(double ) s i z e s [ i ] ) ∗ 1 0 0 . 0 ,

i t e r a t i o n s ,

ARRAY( t , i , j , r epeat count ) ,

ARRAY( percents , i , j , r epeat count ) ,

ARRAY( opssmref , i , j , r epeat count ) ,

ARRAY(bws , i , j , r epeat count ) ) ;

}}

else

{i f ( type & OPSPSECPMREF)

{i f ( type & REPORTDIMS)

p r i n t f ( ”%d %f \n” , dim , ARRAY( opssmref , i , j , r epeat count ) ) ;

else

p r i n t f ( ”%d %f \n” , s i z e s [ i ] , ARRAY( opssmref , i , j , r epeat count ) ) ;

}else

{i f ( type & REPORTDIMS)

p r i n t f ( ”%d %f \n” , dim , ARRAY(bws , i , j , r epeat count ) ) ;

else

p r i n t f ( ”%d %f \n” , s i z e s [ i ] , ARRAY(bws , i , j , r epeat count ) ) ;

}

Version 1.1 143

Page 144: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

}}

int compute axpy dimension ( int maxmem, int da ta s i z e )

{return (maxmem/(2 .0∗ da ta s i z e ) ) ;

}

int compute gemv dimension ( int maxmem, int da ta s i z e )

{double r t ;

r t = ( 4 . 0∗ ( double )maxmem/(double ) da t a s i z e ) + 4 . 0 ;

r t = sq r t ( r t ) − 2 . 0 ;

r t = r t / 2 ;

/∗ DBG( p r i n t f (”DIM i s now %d\n” , dim ) ) ;

wh i l e ( ( ( dim∗dim)+dim+dim) < maxmem/ da t a s i z e )

{dim++;

DBG( p r i n t f (”DIM i s now %d\n” , dim ) ) ;

}whi l e ( ( ( dim∗dim)+dim+dim) > maxmem/ da t a s i z e )

{dim−−;

DBG( p r i n t f (”DIM i s now %d\n” , dim ) ) ;

}p r i n t f (”% f %d\n” , rt , ( i n t ) r t ) ; ∗/return ( ( int ) r t ) ;

}

int compute gemm dimension ( int maxmem, int da ta s i z e )

{int dim ;

dim = ( int ) s q r t ( (double ) (maxmem/( da t a s i z e ∗ 3 ) ) ) ;

return (dim ) ;

}

INLINE void do saxpy ( f loat ∗x , f loat ∗y , int i t e r a t i o n s , int ∗ l im i t )

{REGISTER int i = 0 ;

extern int saxpy ( ) ;

for ( ; i<i t e r a t i o n s ; i++)

{saxpy ( l im i t ,& fa lpha , x,& s t r i d e , y,& s t r i d e ) ;

Version 1.1 144

Page 145: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

}}

INLINE void do daxpy (double ∗x , double ∗y , int i t e r a t i o n s , int ∗ l im i t )

{REGISTER int i = 0 ;

extern int daxpy ( ) ;

for ( ; i<i t e r a t i o n s ; i++)

{daxpy ( l im i t ,&dalpha , x,& s t r i d e , y,& s t r i d e ) ;

}}

INLINE void do sgemv ( f loat ∗a , f loat ∗x , f loat ∗y , int i t e r a t i o n s , int ∗ l im i t , int ∗ lda )

{REGISTER int i = 0 ;

extern int sgemv ( ) ;

for ( ; i<i t e r a t i o n s ; i++)

{sgemv ( foo , l im i t , l im i t ,& fa lpha , a , lda , x,& s t r i d e ,& fbeta , y,& s t r i d e ) ;

}}

INLINE void do dgemv (double ∗a , double ∗x , double ∗y , int i t e r a t i o n s , int ∗ l im i t , int ∗ lda )

{REGISTER int i = 0 ;

extern int dgemv ( ) ;

for ( ; i<i t e r a t i o n s ; i++)

{dgemv ( foo , l im i t , l im i t ,&dalpha , a , lda , x,& s t r i d e ,&dbeta , y,& s t r i d e ) ;

}}

INLINE void do sgemm( f loat ∗a , f loat ∗b , f loat ∗c , int i t e r a t i o n s , int ∗ l im i t , int ∗ lda )

{REGISTER int i = 0 ;

extern int sgemm ( ) ;

for ( ; i<i t e r a t i o n s ; i++)

{sgemm ( foo , foo , l im i t , l im i t , l im i t ,& fa lpha , a , lda , b , lda ,& fbeta , c , lda ) ;

}}

INLINE void do dgemm(double ∗a , double ∗b , double ∗c , int i t e r a t i o n s , int ∗ l im i t , int ∗ lda )

{

Version 1.1 145

Page 146: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

REGISTER int i = 0 ;

extern int dgemm ( ) ;

for ( ; i<i t e r a t i o n s ; i++)

{dgemm ( foo , foo , l im i t , l im i t , l im i t ,&dalpha , a , lda , b , lda ,&dbeta , c , lda ) ;

}}

void i n i t a l l f l t (REGISTER f loat ∗x , REGISTER int number )

{REGISTER int i ;

for ( i =0; i<number ; i++)

{x [ i ] = 1 . 0 ;

}}

void i n i t a l l d b l (REGISTER double ∗x , REGISTER int number )

{REGISTER int i ;

for ( i =0; i<number ; i++)

{x [ i ] = 1 . 0 ;

}}

int usage ( int argc , char ∗∗argv , int ∗ i t e r a t i o n s , int ∗ r e a l i t e r a t i o n s )

{int c ;

int e r r f l g = 0 ;

∗ i t e r a t i o n s = ∗ r e a l i t e r a t i o n s = ITERATIONS;

while ( ( c = getopt ( argc , argv , ”hm: x : e : i : b : ovatscldN ”) ) != −1)

switch ( c ) {case ’ h ’ :

e r r f l g ++;

break ;

case ’m’ :

i f ( ( ( logmemsize = a t o i ( optarg ) ) < 0) | | ( logmemsize <= CACHE MIN BITS) )

e r r f l g ++;

memsize = 1<<logmemsize ;

break ;

case ’ v ’ :

i f ( type & (VECTORVECTOR|VECTORMATRIX|MATRIXMATRIX) )

i f ( ( i s a t t y ( 1 ) ) == 0)

Version 1.1 146

Page 147: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

e r r f l g ++;

type |= VECTORVECTOR;

break ;

case ’ a ’ :

i f ( type & (VECTORVECTOR|VECTORMATRIX|MATRIXMATRIX) )

i f ( ( i s a t t y ( 1 ) ) == 0)

e r r f l g ++;

type |= VECTORMATRIX;

break ;

case ’ t ’ :

i f ( type & (VECTORVECTOR|VECTORMATRIX|MATRIXMATRIX) )

i f ( ( i s a t t y ( 1 ) ) == 0)

e r r f l g ++;

type |= MATRIXMATRIX;

break ;

case ’ s ’ :

#ifdef T3E

e r r f l g ++;

#else

type |= SINGLEPRECISION;

#endif

break ;

case ’ o ’ :

type |= OPSPSECPMREF;

break ;

case ’ d ’ :

type |= REPORTDIMS;

break ;

case ’ l ’ :

type |= HOLDLDA;

break ;

case ’ x ’ :

i f ( ( r e s o l u t i o n = a to i ( optarg ) ) < 0)

e r r f l g ++;

r e s o l u t i o n++; /∗ Correct f o r my usage ∗/break ;

case ’ e ’ :

i f ( ( r epeat count = a to i ( optarg ) ) < 0)

e r r f l g ++;

break ;

case ’ i ’ :

i f ( (∗ i t e r a t i o n s = ∗ r e a l i t e r a t i o n s = a t o i ( optarg ) ) < 0)

e r r f l g ++;

break ;

case ’ c ’ :

type |= CONSTANTITERATIONS;

break ;

case ’N ’ :

no f lu sh = 1 ;

Version 1.1 147

Page 148: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

break ;

case ’ ? ’ :

e r r f l g ++;

break ; }

i f ( r epeat count == −1)

{i f ( i s a t t y ( 1 ) )

repeat count = REPEAT COUNT;

else

r epeat count = 1 ;

}

i f ( ( type & (VECTORVECTOR|VECTORMATRIX|MATRIXMATRIX) ) == 0)

{i f ( i s a t t y ( 1 ) )

{type |= VECTORVECTOR|VECTORMATRIX|MATRIXMATRIX;

}else

type |= MATRIXMATRIX;

}

i f ( e r r f l g )

{f p r i n t f ( s tde r r , ”Usage : %s [−vatsco −x # −m # −e # − i #]\n” , argv [ 0 ] ) ;

f p r i n t f ( s tde r r , ”\ t −v AXPY dot product benchmark\n” ) ;

f p r i n t f ( s tde r r , ”\ t −a GEMV matrix−vec tor mult ip ly benchmark\n” ) ;

f p r i n t f ( s tde r r , ”\ t −t GEMM matrix−matrix mult ip ly benchmark\n” ) ;

#ifndef T3E

f p r i n t f ( s tde r r , ”\ t −s Use s i n g l e p r e c i s i o n f l o a t i n g po int data\n” ) ;

#endif

f p r i n t f ( s tde r r , ”\ t −c Use constant number o f i t e r a t i o n s \n” ) ;

f p r i n t f ( s tde r r , ”\ t −o Report Mflops / sec in s t ead o f MB/ sec \n” ) ;

f p r i n t f ( s tde r r , ”\ t −e Repeat count per problem s i z e \n” ) ;

f p r i n t f ( s tde r r , ”\ t − l Hold LDA and loop over s i z e s o f square submatr ices \n” ) ;

f p r i n t f ( s tde r r , ”\ t − i Maximum i t e r a t i o n count\n” ) ;

f p r i n t f ( s tde r r , ”\ t −x Number o f measurements between powers o f 2 .\n” ) ;

f p r i n t f ( s tde r r , ”\ t −m Spec i f y the log2 (maximum problem s i z e ) in bytes \n” ) ;

f p r i n t f ( s tde r r , ”\ t −d Report/use dimension s t a t i s t i c s i n s t ead o f bytes \n” ) ;

f p r i n t f ( s tde r r , ”\ t −N Do not f l u s h the cache between problem s i z e s .\n” ) ;

f p r i n t f ( s tde r r , ”\nDefault datatype : %s , %d bytes \n” , ”double ” , ( int ) s izeof (double ) ) ;

f p r i n t f ( s tde r r , ”Defau l t datatype : %s , %d bytes \n” , ” f l o a t ” , ( int ) s izeof ( f loat ) ) ;

f p r i n t f ( s tde r r , ”De fau l t s i f to t ty : −vat −x%d −m%d −e%d − i%d\n” ,

RESOLUTION−1,CACHE MAX BITS,REPEAT COUNT,ITERATIONS) ;

f p r i n t f ( s tde r r , ”De fau l t s i f to f i l e : −t −x%d −m%d −e1 − i%d\n” ,

RESOLUTION−1,CACHE MAX BITS, ITERATIONS) ;

Version 1.1 148

Page 149: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

e x i t ( 1 ) ;

}

t ime s l o t s = r e s o l u t i o n ∗( logmemsize − CACHE MIN BITS) + 1 ;

DBG( p r i n t f ( ”%d %d %d\n” , logmemsize , memsize , t ime s l o t s ) ) ;

return ( type ) ;

}

void i n i t i a l i z e a r r a y s ( int type )

{int i , j ;

a s s e r t ( t = (double ∗) mal loc ( t ime s l o t s ∗ r epeat count ∗( int ) s izeof (double ) ) ) ;

memset ( t , 0 x00 , ( t ime s l o t s ∗ r epeat count ∗( int ) s izeof (double ) ) ) ;

a s s e r t (bws = (double ∗) mal loc ( t ime s l o t s ∗ r epeat count ∗( int ) s izeof (double ) ) ) ;

memset (bws , 0 x00 , ( t ime s l o t s ∗ r epeat count ∗( int ) s izeof (double ) ) ) ;

a s s e r t ( opssmref = (double ∗) mal loc ( t ime s l o t s ∗ r epeat count ∗( int ) s izeof (double ) ) ) ;

memset ( opssmref , 0 x00 , ( t ime s l o t s ∗ r epeat count ∗( int ) s izeof (double ) ) ) ;

a s s e r t ( pe r cent s = (double ∗) mal loc ( t ime s l o t s ∗ r epeat count ∗( int ) s izeof (double ) ) ) ;

memset ( percents , 0 x00 , ( t ime s l o t s ∗ r epeat count ∗( int ) s izeof (double ) ) ) ;

a s s e r t ( s i z e s = ( int ∗) mal loc ( t ime s l o t s ∗( int ) s izeof ( int ) ) ) ;

for ( j =0; j<t ime s l o t s ; j+=r e s o l u t i o n )

{( s i z e s ) [ j ] = 1<<(CACHE MIN BITS+j / r e s o l u t i o n ) ;

DBG( p r i n t f ( ”POW: %d %d\n” , j , ( s i z e s ) [ j ] ) ) ;

for ( i =1; i<r e s o l u t i o n ; i++)

{i f ( j+i < t ime s l o t s )

{( s i z e s ) [ j+i ] = ( s i z e s ) [ j ] + i ∗ ( ( s i z e s ) [ j ] / r e s o l u t i o n ) ;

DBG( p r i n t f ( ”SUB: %d %d\n” , j+i , ( s i z e s ) [ j+i ] ) ) ;

}}

}}

void pr in t heade r ( int type , char ∗ s t r i n g )

{i f ( i s a t t y ( 1 ) )

{p r i n t f ( ”\n\ t \ t%s%s %s \n\n” ,

( type & NOCALIBRATE) ? ”Unca l ibrated ” : ”\ t ” ,

( type & SINGLEPRECISION) ? ” f l o a t ” : ”double ” , s t r i n g ) ;

i f ( type & REPORTDIMS)

p r i n t f ( ”BDims\tPDims\ t%% Fit \ t I t e r s \ tNansec\ t%% Chng\tMFlopsS\tMB/ sec \n” ) ;

Version 1.1 149

Page 150: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

else

p r i n t f ( ”BSize\ tPSize \ t%% Fit \ t I t e r s \ tNansec\ t%% Chng\tMFlopsS\tMB/ sec \n” ) ;

p r i n t f ( ”−−−−−\t−−−−−\t−−−−−\t−−−−−−\t−−−−−−\t−−−−−−\t−−−−−−−\t−−−−−−\n” ) ;

}}

int main ( int argc , char ∗∗ argv )

{int l im i t , i , j , dim , i t e r a t i o n s , r e a l i t e r a t i o n s ;

double tmic rosec = 0 . 0 , r e f c n t= 0 . 0 , p r e f cn t = 0 . 0 , opcnt = 0 . 0 ;

type = usage ( argc , argv , &i t e r a t i o n s , &r e a l i t e r a t i o n s ) ;

i t e r a t i o n s += ( i t e r a t i o n s % 4 ) ;

i n i t i a l i z e a r r a y s ( type ) ;

s e tbu f ( stdout ,NULL) ;

#ifdef T3E

foo fn = cpto f cd (&fooc , s izeof ( f ooc ) ) ;

#endif

/∗ Measure cache ∗/

i f ( type & VECTORVECTOR)

{

pr in t heade r ( type , ”AXPY Cache Test ” ) ;

i f ( type & SINGLEPRECISION)

{f loat ∗ sx , ∗ sy ;

dim = compute axpy dimension (memsize , ( int ) s izeof ( f loat ) ) ;

DBG( f p r i n t f ( s tde r r , ”Max dimension in bytes i s %d\n” ,dim∗( int ) s izeof ( f loat ) ) ) ;

DBG( f p r i n t f ( s tde r r , ”Total bytes used %d out o f %d\n” , ( dim+dim )∗ ( int ) s izeof ( f loat ) , memsize ) ) ;

a s s e r t ( sx = ( f loat ∗) mal loc (dim∗( int ) s izeof ( f loat ) ) ) ;

a s s e r t ( sy = ( f loat ∗) mal loc (dim∗( int ) s izeof ( f loat ) ) ) ;

memset ( sx , 0 x00 , dim∗( int ) s izeof ( f loat ) ) ;

memset ( sy , 0 x00 , dim∗( int ) s izeof ( f loat ) ) ;

i n i t a l l f l t ( sx , dim ) ;

i n i t a l l f l t ( sy , dim ) ;

for ( i = 0 ; i < t ime s l o t s ; i++)

{l im i t = compute axpy dimension ( s i z e s [ i ] , ( int ) s izeof ( f loat ) ) ;

DBG( f p r i n t f ( s tde r r , ”Max dimension in f l o a t s i s %d\n” , l im i t ) ) ;

DBG( f p r i n t f ( s tde r r , ”Cache s i z e i s %d bytes , %d f l o a t s \n” ,

s i z e s [ i ] , s i z e s [ i ] / ( int ) s izeof ( f loat ) ) ) ;

Version 1.1 150

Page 151: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

i f ( ( type & CONSTANTITERATIONS) == 0)

{r e a l i t e r a t i o n s = ( i == 0 ? i t e r a t i o n s : ( int ) ( p r e f cn t / ( 3 . 0∗ ( double ) l im i t ) ) ) ;

i f ( r e a l i t e r a t i o n s < LOWEST ITERATION COUNT)

r e a l i t e r a t i o n s = LOWEST ITERATION COUNT;

}

r e f c n t = (double ) r e a l i t e r a t i o n s ∗3 .0∗ (double ) l im i t ;

opcnt = (double ) r e a l i t e r a t i o n s ∗2 .0∗ (double ) l im i t ;

DBG( p r i n t f ( ” r e f c n t now %f , was %f , doing %d i t e r a t i o n s \n” , r e f cn t , pre f cnt , r e a l i t e r a t i o n s ) ) ;

p r e f cn t = r e f c n t ;

for ( j = 0 ; j < r epeat count ; j++)

{FLUSHALL( 1 ) ;

TIMER START;

do saxpy ( sx , sy , r e a l i t e r a t i o n s ,& l im i t ) ;

TIMER STOP;

tmic rosec = TIMER ELAPSED;

DBG( f p r i n t f ( s tde r r , ”R: %f us . t o t a l \n” , tmic rosec ) ) ;

DBG( f p r i n t f ( s tde r r , ”R: %f ns . per r e f \n” , ( tmic rosec ∗1000 .0 ) / r e f c n t ) ) ;

compute stats ( i , j , r e f cn t , ( double ) s izeof ( f loat ) , opcnt ,

tmicrosec , r e a l i t e r a t i o n s ,

( l im i t+l im i t )∗ ( int ) s izeof ( f loat ) ,

( l im i t+l im i t )∗ ( int ) s izeof ( f loat ) ,

l im i t , l im i t ) ;

}}

f r e e ( sx ) ;

f r e e ( sy ) ;

}else

{double ∗dx , ∗dy ;

dim = compute axpy dimension (memsize , ( int ) s izeof (double ) ) ;

DBG( f p r i n t f ( s tde r r , ”Max dimension in bytes i s %d\n” ,dim∗( int ) s izeof (double ) ) ) ;

DBG( f p r i n t f ( s tde r r , ”Total bytes used %d out o f %d\n” , ( dim+dim )∗ ( int ) s izeof (double ) , memsize ) ) ;

a s s e r t ( dx = (double ∗) mal loc (dim∗( int ) s izeof (double ) ) ) ;

a s s e r t ( dy = (double ∗) mal loc (dim∗( int ) s izeof (double ) ) ) ;

memset (dx , 0 x00 , dim∗( int ) s izeof (double ) ) ;

memset (dy , 0 x00 , dim∗( int ) s izeof (double ) ) ;

i n i t a l l d b l (dx , dim ) ;

i n i t a l l d b l (dy , dim ) ;

Version 1.1 151

Page 152: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

for ( i = 0 ; i < t ime s l o t s ; i++)

{l im i t = compute axpy dimension ( s i z e s [ i ] , ( int ) s izeof (double ) ) ;

DBG( f p r i n t f ( s tde r r , ”Max dimension in doubles i s %d\n” , l im i t ) ) ;

DBG( f p r i n t f ( s tde r r , ”Cache s i z e i s %d bytes , %d doubles \n” ,

s i z e s [ i ] , s i z e s [ i ] / ( int ) s izeof (double ) ) ) ;

i f ( ( type & CONSTANTITERATIONS) == 0)

{r e a l i t e r a t i o n s = ( i == 0 ? i t e r a t i o n s : ( int ) ( p r e f cn t / ( 3 . 0∗ ( double ) l im i t ) ) ) ;

i f ( r e a l i t e r a t i o n s < LOWEST ITERATION COUNT)

r e a l i t e r a t i o n s = LOWEST ITERATION COUNT;

}

r e f c n t = (double ) r e a l i t e r a t i o n s ∗3 .0∗ (double ) l im i t ;

opcnt = (double ) r e a l i t e r a t i o n s ∗2 .0∗ (double ) l im i t ;

DBG( p r i n t f ( ” r e f c n t now %f , was %f , doing %d i t e r a t i o n s \n” , r e f cn t , pre f cnt , r e a l i t e r a t i o n s ) ) ;

p r e f cn t = r e f c n t ;

for ( j = 0 ; j < r epeat count ; j++)

{FLUSHALL( 1 ) ;

TIMER START;

do daxpy (dx , dy , r e a l i t e r a t i o n s ,& l im i t ) ;

TIMER STOP;

tmic rosec = TIMER ELAPSED;

DBG( f p r i n t f ( s tde r r , ”R: %f us . t o t a l \n” , tmic rosec ) ) ;

DBG( f p r i n t f ( s tde r r , ”R: %f ns . per r e f \n” , ( tmic rosec ∗1000 .0 ) / r e f c n t ) ) ;

compute stats ( i , j , r e f cn t , ( double ) s izeof (double ) , opcnt ,

tmicrosec , r e a l i t e r a t i o n s ,

( l im i t+l im i t )∗ ( int ) s izeof (double ) ,

( l im i t+l im i t )∗ ( int ) s izeof (double ) ,

l im i t , l im i t ) ;

}}

f r e e (dx ) ;

f r e e (dy ) ;

}}

i f ( type & VECTORMATRIX)

{int lda ;

p r in t heade r ( type , ”GEMV Cache Test ” ) ;

Version 1.1 152

Page 153: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

i f ( type & SINGLEPRECISION)

{f loat ∗ sa , ∗ sx , ∗ sy ;

dim = compute gemv dimension (memsize , ( int ) s izeof ( f loat ) ) ;

DBG( f p r i n t f ( s tde r r , ”Max dimension in bytes i s %d\n” ,dim∗( int ) s izeof ( f loat ) ) ) ;

DBG( f p r i n t f ( s tde r r , ”Total bytes used %d out o f %d\n” ,

( ( dim∗dim)+dim+dim )∗ ( int ) s izeof ( f loat ) , memsize ) ) ;

a s s e r t ( sa = ( f loat ∗) mal loc (dim∗dim∗( int ) s izeof ( f loat ) ) ) ;

a s s e r t ( sx = ( f loat ∗) mal loc (dim∗( int ) s izeof ( f loat ) ) ) ;

a s s e r t ( sy = ( f loat ∗) mal loc (dim∗( int ) s izeof ( f loat ) ) ) ;

memset ( sa , 0 x00 , dim∗dim∗( int ) s izeof ( f loat ) ) ;

memset ( sx , 0 x00 , dim∗( int ) s izeof ( f loat ) ) ;

memset ( sy , 0 x00 , dim∗( int ) s izeof ( f loat ) ) ;

i n i t a l l f l t ( sa , dim∗dim ) ;

i n i t a l l f l t ( sx , dim ) ;

i n i t a l l f l t ( sy , dim ) ;

for ( i = 0 ; i < t ime s l o t s ; i++)

{l im i t = compute gemv dimension ( s i z e s [ i ] , ( int ) s izeof ( f loat ) ) ;

DBG( f p r i n t f ( s tde r r , ”Max dimension in f l o a t s i s %d\n” , l im i t ) ) ;

DBG( f p r i n t f ( s tde r r , ”Cache s i z e i s %d bytes , %d f l o a t s \n” ,

s i z e s [ i ] , s i z e s [ i ] / ( int ) s izeof ( f loat ) ) ) ;

i f ( ( type & CONSTANTITERATIONS) == 0)

{r e a l i t e r a t i o n s = ( i == 0 ? i t e r a t i o n s : ( int ) ( p r e f cn t / (2 . 0∗ l im i t ∗ l im i t + 2 .0∗ l im i t ) ) ) ;

i f ( r e a l i t e r a t i o n s < LOWEST ITERATION COUNT)

r e a l i t e r a t i o n s = LOWEST ITERATION COUNT;

}

r e f c n t = (double ) r e a l i t e r a t i o n s ∗ (2 . 0∗ l im i t ∗ l im i t + 2 .0∗ l im i t ) ;

opcnt = (double ) r e a l i t e r a t i o n s ∗ (2 . 0∗ l im i t ∗ l im i t + 2 .0∗ l im i t ) ;

DBG( p r i n t f ( ” r e f c n t now %f , was %f , doing %d i t e r a t i o n s \n” , r e f cn t , pre f cnt , r e a l i t e r a t i o n s ) ) ;

p r e f cn t = r e f c n t ;

lda = ( ( type & HOLDLDA) ? dim : l im i t ) ;

for ( j = 0 ; j < r epeat count ; j++)

{FLUSHALL( 1 ) ;

TIMER START;

do sgemv ( sa , sx , sy , r e a l i t e r a t i o n s ,& l im i t ,& lda ) ;

TIMER STOP;

Version 1.1 153

Page 154: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

tmic rosec = TIMER ELAPSED;

DBG( f p r i n t f ( s tde r r , ”R: %f us . t o t a l \n” , tmic rosec ) ) ;

DBG( f p r i n t f ( s tde r r , ”R: %f ns . per r e f \n” , ( tmic rosec ∗1000 .0 ) / r e f c n t ) ) ;

compute stats ( i , j , r e f cn t , ( double ) s izeof ( f loat ) , opcnt ,

tmicrosec , r e a l i t e r a t i o n s ,

( ( l im i t ∗ l im i t )+ l im i t+l im i t )∗ ( int ) s izeof ( f loat ) ,

( ( lda ∗ lda )+lda+lda )∗ ( int ) s izeof ( f loat ) ,

l im i t , lda ) ;

}}

f r e e ( sa ) ;

f r e e ( sx ) ;

f r e e ( sy ) ;

}else

{double ∗da , ∗dx , ∗dy ;

dim = compute gemv dimension (memsize , ( int ) s izeof (double ) ) ;

DBG( f p r i n t f ( s tde r r , ”Max dimension in bytes i s %d\n” ,dim∗( int ) s izeof (double ) ) ) ;

DBG( f p r i n t f ( s tde r r , ”Total bytes used %d out o f %d\n” ,

( ( dim∗dim)+dim+dim )∗ ( int ) s izeof (double ) , memsize ) ) ;

a s s e r t ( da = (double ∗) mal loc (dim∗dim∗( int ) s izeof (double ) ) ) ;

a s s e r t ( dx = (double ∗) mal loc (dim∗( int ) s izeof (double ) ) ) ;

a s s e r t ( dy = (double ∗) mal loc (dim∗( int ) s izeof (double ) ) ) ;

memset (da , 0 x00 , dim∗dim∗( int ) s izeof (double ) ) ;

memset (dx , 0 x00 , dim∗( int ) s izeof (double ) ) ;

memset (dy , 0 x00 , dim∗( int ) s izeof (double ) ) ;

i n i t a l l d b l (da , dim∗dim ) ;

i n i t a l l d b l (dx , dim ) ;

i n i t a l l d b l (dy , dim ) ;

for ( i = 0 ; i < t ime s l o t s ; i++)

{l im i t = compute gemv dimension ( s i z e s [ i ] , ( int ) s izeof (double ) ) ;

DBG( f p r i n t f ( s tde r r , ”Max dimension in doubles i s %d\n” , l im i t ) ) ;

DBG( f p r i n t f ( s tde r r , ”Cache s i z e i s %d bytes , %d doubles \n” ,

s i z e s [ i ] , s i z e s [ i ] / ( int ) s izeof (double ) ) ) ;

i f ( ( type & CONSTANTITERATIONS) == 0)

{r e a l i t e r a t i o n s = ( i == 0 ? i t e r a t i o n s : ( int ) ( p r e f cn t / (2 . 0∗ l im i t ∗ l im i t + 2 .0∗ l im i t ) ) ) ;

i f ( r e a l i t e r a t i o n s < LOWEST ITERATION COUNT)

r e a l i t e r a t i o n s = LOWEST ITERATION COUNT;

}

Version 1.1 154

Page 155: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

r e f c n t = (double ) r e a l i t e r a t i o n s ∗ (2 . 0∗ l im i t ∗ l im i t + 2 .0∗ l im i t ) ;

opcnt = (double ) r e a l i t e r a t i o n s ∗ (2 . 0∗ l im i t ∗ l im i t + 2 .0∗ l im i t ) ;

DBG( p r i n t f ( ” r e f c n t now %f , was %f , doing %d i t e r a t i o n s \n” , r e f cn t , pre f cnt , r e a l i t e r a t i o n s ) ) ;

p r e f cn t = r e f c n t ;

lda = ( ( type & HOLDLDA) ? dim : l im i t ) ;

for ( j = 0 ; j < r epeat count ; j++)

{FLUSHALL( 1 ) ;

TIMER START;

do dgemv (da , dx , dy , r e a l i t e r a t i o n s ,& l im i t ,& lda ) ;

TIMER STOP;

tmic rosec = TIMER ELAPSED;

DBG( f p r i n t f ( s tde r r , ”R: %f us . t o t a l \n” , tmic rosec ) ) ;

DBG( f p r i n t f ( s tde r r , ”R: %f ns . per r e f \n” , ( tmic rosec ∗1000 .0 ) / r e f c n t ) ) ;

compute stats ( i , j , r e f cn t , ( double ) s izeof (double ) , opcnt ,

tmicrosec , r e a l i t e r a t i o n s ,

( ( l im i t ∗ l im i t )+ l im i t+l im i t )∗ ( int ) s izeof (double ) ,

( ( lda ∗ lda )+lda+lda )∗ ( int ) s izeof (double ) ,

l im i t , lda ) ;

}}

f r e e ( da ) ;

f r e e (dx ) ;

f r e e (dy ) ;

}}

i f ( type & MATRIXMATRIX)

{int lda ;

p r in t heade r ( type , ”GEMM Cache Test ” ) ;

i f ( type & SINGLEPRECISION)

{f loat ∗ sa , ∗sb , ∗ sc ;

dim = compute gemm dimension (memsize , ( int ) s izeof ( f loat ) ) ;

DBG( f p r i n t f ( s tde r r , ”Max dimension in bytes i s %d\n” ,dim∗( int ) s izeof ( f loat ) ) ) ;

DBG( f p r i n t f ( s tde r r , ”Total bytes used %d out o f %d\n” , (3∗dim∗dim )∗ ( int ) s izeof ( f loat ) , memsize ) ) ;

a s s e r t ( sa = ( f loat ∗) mal loc (dim∗dim∗( int ) s izeof ( f loat ) ) ) ;

a s s e r t ( sb = ( f loat ∗) mal loc (dim∗dim∗( int ) s izeof ( f loat ) ) ) ;

a s s e r t ( sc = ( f loat ∗) mal loc (dim∗dim∗( int ) s izeof ( f loat ) ) ) ;

memset ( sa , 0 x00 , dim∗dim∗( int ) s izeof ( f loat ) ) ;

Version 1.1 155

Page 156: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

memset ( sb , 0 x00 , dim∗dim∗( int ) s izeof ( f loat ) ) ;

memset ( sc , 0 x00 , dim∗dim∗( int ) s izeof ( f loat ) ) ;

i n i t a l l f l t ( sa , dim∗dim ) ;

i n i t a l l f l t ( sa , dim∗dim ) ;

i n i t a l l f l t ( sa , dim∗dim ) ;

for ( i = 0 ; i < t ime s l o t s ; i++)

{l im i t = compute gemm dimension ( s i z e s [ i ] , ( int ) s izeof ( f loat ) ) ;

DBG( f p r i n t f ( s tde r r , ”Max dimension in f l o a t s i s %d\n” , l im i t ) ) ;

DBG( f p r i n t f ( s tde r r , ”Cache s i z e i s %d bytes , %d f l o a t s \n” ,

s i z e s [ i ] , s i z e s [ i ] / ( int ) s izeof ( f loat ) ) ) ;

i f ( ( type & CONSTANTITERATIONS) == 0)

{r e a l i t e r a t i o n s = ( i == 0 ? i t e r a t i o n s : ( int ) ( p r e f cn t / (2 . 0∗ l im i t ∗ l im i t ∗ l im i t +2.0∗ l im i t ∗ l im i t ) ) ) ;

/∗ For each o f n∗n elements , we have 2.0∗n + 1 reads , 1 wr i t e ∗/i f ( r e a l i t e r a t i o n s < LOWEST ITERATION COUNT)

r e a l i t e r a t i o n s = LOWEST ITERATION COUNT;

}

r e f c n t = (double ) r e a l i t e r a t i o n s ∗ (2 . 0∗ l im i t ∗ l im i t ∗ l im i t +2.0∗ l im i t ∗ l im i t ) ;

opcnt = (double ) r e a l i t e r a t i o n s ∗ (2 . 0∗ l im i t ∗ l im i t ∗ l im i t +2.0∗ l im i t ∗ l im i t ) ;

DBG( p r i n t f ( ” r e f c n t now %f , was %f , doing %d i t e r a t i o n s \n” , r e f cn t , pre f cnt , r e a l i t e r a t i o n s ) ) ;

p r e f cn t = r e f c n t ;

lda = ( ( type & HOLDLDA) ? dim : l im i t ) ;

for ( j = 0 ; j < r epeat count ; j++)

{FLUSHALL( 1 ) ;

TIMER START;

do sgemm( sa , sb , sc , r e a l i t e r a t i o n s ,& l im i t ,& lda ) ;

TIMER STOP;

tmic rosec = TIMER ELAPSED;

DBG( f p r i n t f ( s tde r r , ”R: %f us . t o t a l \n” , tmic rosec ) ) ;

DBG( f p r i n t f ( s tde r r , ”R: %f ns . per r e f \n” , ( tmic rosec ∗1000 .0 ) / r e f c n t ) ) ;

compute stats ( i , j , r e f cn t , ( double ) s izeof ( f loat ) , opcnt ,

tmicrosec , r e a l i t e r a t i o n s ,

(3∗ l im i t ∗ l im i t )∗ ( int ) s izeof ( f loat ) ,

(3∗ lda ∗ lda )∗ ( int ) s izeof ( f loat ) ,

l im i t , lda ) ;

}}

f r e e ( sa ) ;

Version 1.1 156

Page 157: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

f r e e ( sb ) ;

f r e e ( sc ) ;

}else

{double ∗da , ∗db , ∗dc ;

dim = compute gemm dimension (memsize , ( int ) s izeof (double ) ) ;

DBG( f p r i n t f ( s tde r r , ”Max dimension in bytes i s %d\n” ,dim∗( int ) s izeof (double ) ) ) ;

DBG( f p r i n t f ( s tde r r , ”Total bytes used %d out o f %d\n” , (3∗dim∗dim )∗ ( int ) s izeof (double ) , memsize ) ) ;

a s s e r t ( da = (double ∗) mal loc (dim∗dim∗( int ) s izeof (double ) ) ) ;

a s s e r t (db = (double ∗) mal loc (dim∗dim∗( int ) s izeof (double ) ) ) ;

a s s e r t ( dc = (double ∗) mal loc (dim∗dim∗( int ) s izeof (double ) ) ) ;

memset (da , 0 x00 , dim∗dim∗( int ) s izeof (double ) ) ;

memset (db , 0 x00 , dim∗dim∗( int ) s izeof (double ) ) ;

memset ( dc , 0 x00 , dim∗dim∗( int ) s izeof (double ) ) ;

i n i t a l l d b l (da , dim∗dim ) ;

i n i t a l l d b l (db , dim∗dim ) ;

i n i t a l l d b l ( dc , dim∗dim ) ;

for ( i = 0 ; i < t ime s l o t s ; i++)

{l im i t = compute gemm dimension ( s i z e s [ i ] , ( int ) s izeof (double ) ) ;

DBG( f p r i n t f ( s tde r r , ”Max dimension in doubles i s %d\n” , l im i t ) ) ;

DBG( f p r i n t f ( s tde r r , ”Cache s i z e i s %d bytes , %d doubles \n” ,

s i z e s [ i ] , s i z e s [ i ] / ( int ) s izeof (double ) ) )

i f ( ( type & CONSTANTITERATIONS) == 0)

{r e a l i t e r a t i o n s = ( i == 0 ? i t e r a t i o n s : ( int ) ( p r e f cn t / ( ( l im i t ∗ l im i t )∗ ( ( 2 . 0∗ l im i t )+2 ) ) ) ) ;

/∗ For each o f n∗n elements , we have 2.0∗n + 1 reads , 1 wr i t e ∗/i f ( r e a l i t e r a t i o n s < LOWEST ITERATION COUNT)

r e a l i t e r a t i o n s = LOWEST ITERATION COUNT;

}

r e f c n t = (double ) r e a l i t e r a t i o n s ∗( l im i t ∗ l im i t )∗ ( ( 2 . 0∗ l im i t )+2 .0 ) ;

opcnt = (double ) r e a l i t e r a t i o n s ∗ (2 . 0∗ l im i t ∗ l im i t ∗ l im i t +2.0∗ l im i t ∗ l im i t ) ;

DBG( p r i n t f ( ” r e f c n t now %f , was %f , doing %d i t e r a t i o n s \n” , r e f cn t , pre f cnt , r e a l i t e r a t i o n s ) ) ;

p r e f cn t = r e f c n t ;

lda = ( ( type & HOLDLDA) ? dim : l im i t ) ;

for ( j = 0 ; j < r epeat count ; j++)

{FLUSHALL( 1 ) ;

TIMER START;

do dgemm(da , db , dc , r e a l i t e r a t i o n s ,& l im i t ,& lda ) ;

Version 1.1 157

Page 158: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

TIMER STOP;

tmic rosec = TIMER ELAPSED;

DBG( f p r i n t f ( s tde r r , ”R: %f us . t o t a l \n” , tmic rosec ) ) ;

DBG( f p r i n t f ( s tde r r , ”R: %f ns . per r e f \n” , ( tmic rosec ∗1000 .0 ) / r e f c n t ) ) ;

compute stats ( i , j , r e f cn t , ( double ) s izeof (double ) , opcnt ,

tmicrosec , r e a l i t e r a t i o n s ,

(3∗ l im i t ∗ l im i t )∗ ( int ) s izeof (double ) ,

(3∗ lda ∗ lda )∗ ( int ) s izeof (double ) ,

l im i t , lda ) ;

}}

f r e e ( da ) ;

f r e e (db ) ;

f r e e ( dc ) ;

}}

FLUSHALL( 0 ) ;

e x i t ( 0 ) ;

}

Version 1.1 158

Page 159: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

8.6.3 CacheBench

cachebench.c

# cut cachebench.c

#include <s t d l i b . h>

#include <s t d i o . h>

#include <s i g n a l . h>

#include <sys / t imes . h>

#include <sys / types . h>

#include < f c n t l . h>

#include <time . h>

#include <a s s e r t . h>

#include <uni s td . h>

#include <memory . h>

#include <s t r i n g . h>

#include <sys / time . h>

#include ” l l cb ench . h”

#define ARRAY(x , i , j ,m) ∗( x+(( j )∗m)+( i ) )

#i f de f ined (USE DOUBLE)

#ifndef DATATYPE

#define DATATYPE double

#define DATASTRING ”double ”

#endif

#e l i f de f ined (USE INT)

#ifndef DATATYPE

#define DATATYPE int

#define DATASTRING ” in t ”

#endif

#e l i f de f ined (USE CHAR)

#ifndef DATATYPE

#define DATATYPE char

#define DATASTRING ”char ”

#endif

#e l i f de f ined (USE FLOAT)

#ifndef DATATYPE

#define DATATYPE f loat

#define DATASTRING ” f l o a t ”

#endif

#endif

#ifndef DATATYPE

#define DATATYPE double

#define DATASTRING ”double ”

#endif

#define READONLY 1<<0

Version 1.1 159

Page 160: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

#define WRITEONLY 1<<1

#define READWRITE 1<<2

#define NOCALIBRATE 1<<3

#define GUESSCACHESIZE 1<<4

#define MEMORYSET 1<<5

#define MEMORYCOPY 1<<6

#define HANDTUNED 1<<7

/∗ DEFAULT SETTINGS ∗/

#define CACHE MIN BITS (8) /∗ 1<<b i t s i s sma l l e s t cache in by t e s ∗/#define CACHE MAX BITS (24) /∗ 1<<b i t s i s l a r g e s t cache in b y t e s ∗/#define CACHE MIN (1<<CACHE MIN BITS)

#define CACHE MAX (1<<CACHE MAX BITS)

#define RESOLUTION (2)

#define TIME SLOTS (2∗ (CACHE MAX BITS−CACHE MIN BITS+1))

#define MEASURE TIME 5

#define DOUBLE NS(x ) ( (double ) x )∗1 . 0 e9

#define THRESHOLD (0 . 9 ) /∗ 1 s t l e v e l must be f a s t e r than 2nd l e v e l ∗/#define REPEAT COUNT 2

extern char ∗ optarg ;

stat ic int logmemsize = CACHE MAX BITS, memsize = 1<<CACHE MAX BITS, repeat count = REPEAT COUNT;

stat ic int r e s o l u t i o n = RESOLUTION, t imes l o t s , durat ion = MEASURE TIME, type = NOCALIBRATE;

stat ic int no f lu sh = 0 ;

volat i le int keepgoing = 0 ;

int go ( int a )

{i f ( a==−1)

return ( keepgoing ) ;

else

return ( keepgoing = a ) ;

}

void handler ( int a )

{go ( 0 ) ;

}

void compute stats ( int i , int j , double r e f cn t , double ove rhead per r e f ,

double ∗ times , double ∗bws , double ∗ percents , int ∗ s i z e s ,

double tmicrosec , int da ta s i z e )

{i f ( tmic rosec > 0 . 0 )

{ARRAY( times , i , j , r epeat count ) =

Version 1.1 160

Page 161: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

( ( tmic rosec ∗1000 .0 ) − ( r e f c n t ∗ ove rhead pe r r e f ) )/ r e f c n t ;

ARRAY(bws , i , j , r epeat count ) =

( ( r e f c n t ∗ da ta s i z e ) / ( 1024 . 0∗1024 . 0 ) ) /

( (ARRAY( times , i , j , r epeat count )∗ r e f c n t ) /1 . 0E9 ) ;

}

i f ( i == 0)

{i f ( j == 0)

ARRAY( percents , i , j , r epeat count ) = 1 . 0 ;

else

{ARRAY( percents , i , j , r epeat count ) =

ARRAY( times , i , j , r epeat count ) /

ARRAY( times , i , j −1, r epeat count ) ;

}}

else

{i f ( j == 0)

{ARRAY( percents , i , j , r epeat count ) =

ARRAY( times , i , j , r epeat count ) /

ARRAY( times , i −1, repeat count −1, r epeat count ) ;

}else

{ARRAY( percents , i , j , r epeat count ) =

ARRAY( times , i , j , r epeat count ) /

ARRAY( times , i , j −1, r epeat count ) ;

}}

i f ( i s a t t y ( 1 ) )

{p r i n t f ( ”%−15d %−15.2 f %−15.2 f %−15.2 f \n” ,

s i z e s [ i ] ,

ARRAY( times , i , j , r epeat count ) ,

ARRAY(bws , i , j , r epeat count ) ,

ARRAY( percents , i , j , r epeat count ) ) ;

}else

p r i n t f ( ”%d %f \n” ,

s i z e s [ i ] ,

ARRAY(bws , i , j , r epeat count ) ) ;

}

void compute cache s i ze s (double ∗ times , double ∗bws , double ∗ percents , int ∗ s i z e s )

Version 1.1 161

Page 162: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

{int i , maxb = 0 , maxa = 0 , cachea , cacheb ;

/∗ Look f o r 2 h i g h e s t percen tages ∗/

for ( i =0; i < t ime s l o t s ; i++)

i f ( pe r cent s [ i ] > percent s [ maxa ] )

maxa = i ;

for ( i =0; i < t ime s l o t s ; i++)

{i f ( ( i != maxa) && ( percent s [ i ] > percent s [maxb ] ) )

{maxb = i ;

}}

p r i n t f ( ”\n\ t \ t \ tCache Capacity Ana lys i s \n\n” ) ;

i f ( 1 . 0/ pe rcent s [ maxa ] >= THRESHOLD)

{p r i n t f ( ”No L1 l im i t found , must be l a r g e r than %d bytes .\n” , memsize ) ;

return ;

}

/∗ Set them to the index i f the entry f o r t ha t cache s i z e ∗//∗ Remember our percen t s are r e l a t i v e to the prev ious entry ∗/

cachea = s i z e s [ maxa−1] ;

cacheb = s i z e s [maxb−1] ;

i f ( cachea > cacheb )

p r i n t f ( ”Level 1 Cache : %d bytes \n” , cachea ) ;

else

{p r i n t f ( ”Level 1 Cache : %d bytes \n” , cachea ) ;

i f ( ( t imes [ maxa ] / t imes [maxb ] < THRESHOLD) && (1 . 0/ pe rcent s [maxb ] < THRESHOLD))

p r i n t f ( ”Level 2 Cache : %d bytes \n” , cacheb ) ;

}}

int usage ( int argc , char ∗∗ argv )

{int c ;

int e r r f l g = 0 ;

while ( ( c = getopt ( argc , argv , ”m: d : hrwbcsptx : e :N”) ) != −1)

switch ( c ) {case ’m’ :

Version 1.1 162

Page 163: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

i f ( ( ( logmemsize = a t o i ( optarg ) ) < 0) | | ( logmemsize <= CACHE MIN BITS) )

e r r f l g ++;

memsize = 1<<logmemsize ;

break ;

case ’ d ’ :

i f ( ( durat ion = a to i ( optarg ) ) < 0)

e r r f l g ++;

break ;

case ’ s ’ :

type |= MEMORYSET;

break ;

case ’ p ’ :

type |= MEMORYCOPY;

break ;

case ’ r ’ :

type |= READONLY;

break ;

case ’ h ’ :

e r r f l g ++;

break ;

case ’ t ’ :

type |= HANDTUNED;

break ;

case ’w ’ :

type |= WRITEONLY;

break ;

case ’ b ’ :

type |= READWRITE;

break ;

case ’ c ’ :

type ˆ= NOCALIBRATE;

break ;

case ’ g ’ :

type |= GUESSCACHESIZE;

break ;

case ’ x ’ :

i f ( ( r e s o l u t i o n = a to i ( optarg ) ) < 0)

e r r f l g ++;

r e s o l u t i o n++; /∗ Correct f o r my usage ∗/break ;

case ’ e ’ :

i f ( ( r epeat count = a to i ( optarg ) ) <= 0)

e r r f l g ++;

break ;

case ’N ’ :

no f lu sh = 1 ;

break ;

case ’ ? ’ :

e r r f l g ++;

Version 1.1 163

Page 164: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

break ; }

i f ( ( type & (READONLY|WRITEONLY|READWRITE|MEMORYCOPY|MEMORYSET) ) == 0)

{i f ( i s a t t y ( 1 ) )

type |= READONLY|WRITEONLY|READWRITE|MEMORYCOPY|MEMORYSET;

else

type |= READWRITE;

}

i f ( e r r f l g )

{f p r i n t f ( s tde r r , ”Usage : %s −rwbtsp [−x #] [−m #] [−d #] [−e #]\n” , argv [ 0 ] ) ;

f p r i n t f ( s tde r r , ”\ t −r Read benchmark\n” ) ;

f p r i n t f ( s tde r r , ”\ t −w Write benchmark\n” ) ;

f p r i n t f ( s tde r r , ”\ t −b Read/Modify/Write benchmark\n” ) ;

f p r i n t f ( s tde r r , ”\ t −t Use hand tuned v e r s i on s o f the above\n” ) ;

f p r i n t f ( s tde r r , ”\ t −s memset ( ) benchmark\n” ) ;

f p r i n t f ( s tde r r , ”\ t −p memcpy( ) benchmark\n” ) ;

/∗ f p r i n t f ( s t de r r , ”\ t −c Enable c a l i b r a t i o n code\n ”) ;

f p r i n t f ( s t de r r , ”\ t −g Enable cache s i z e gue s s ing code\n ”) ; ∗/f p r i n t f ( s tde r r , ”\ t −x Number o f measurements between powers o f 2 .\n” ) ;

f p r i n t f ( s tde r r , ”\ t −m Spec i f y the log2 ( a v a i l a b l e phy s i c a l memory)\n” ) ;

f p r i n t f ( s tde r r , ”\ t −d Number o f seconds per i t e r a t i o n \n” ) ;

f p r i n t f ( s tde r r , ”\ t −e Repeat count per cache s i z e \n\n” ) ;

f p r i n t f ( s tde r r , ”\ t −N Do not f l u s h the cache between problem s i z e s .\n” ) ;

f p r i n t f ( s tde r r , ”Datatype used i s %s , %d bytes .\n” ,DATASTRING, ( int ) s izeof (DATATYPE) ) ;

f p r i n t f ( s tde r r , ”De fau l t s i f t ty : −rwbsp −x%d −m%d −d%d −e%d\n” ,

RESOLUTION−1,CACHE MAX BITS,MEASURE TIME,REPEAT COUNT) ;

f p r i n t f ( s tde r r , ”De fau l t s i f f i l e : −b −x%d −m%d −d%d −e1\n” ,

RESOLUTION−1,CACHE MAX BITS,MEASURE TIME) ;

e x i t ( 1 ) ;

}

t ime s l o t s = r e s o l u t i o n ∗( logmemsize − CACHE MIN BITS) + 1 ;

DBG( p r i n t f ( ”%d %d %d %d\n” , logmemsize , memsize , durat ion , t ime s l o t s ) ) ;

return ( type ) ;

}

void f a k e ou t op t im i z a t i on s (DATATYPE ∗x , int bytes )

{stat ic int fd = −1;

i f ( fd == −1)

a s s e r t ( fd=open ( ”/dev/ nu l l ” ,OWRONLY) ) ;

a s s e r t ( wr i t e ( fd , ( void ∗)x , bytes )!=−1);

}

Version 1.1 164

Page 165: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

/∗ doub le ca l i b r a t e b enchmark ron l y (REGISTER DATATYPE ∗x , REGISTER in t l im i t , i n t ∗ oloops , doub le ∗ous )

{REGISTER in t index = 0 , l oops = 0;

REGISTER DATATYPE sum = 0 , foolem = 0;

f l u s h a l l ( x ) ;

keepgo ing = 1;

a s s e r t ( s i g n a l (SIGALRM, hand ler ) != SIG ERR) ;

l im i t −= 4; foolem = (DATATYPE) l im i t ;

alarm ( durat ion ) ;

TIMER START;

again :

sum += foolem + foolem+(DATATYPE)1 + foolem+(DATATYPE)2 + foolem+(DATATYPE)3 ;

i f ( ( ( index+=4) < l im i t ) && ( keepgo ing ) )

goto again ;

e l s e i f ( keepgo ing )

{index = 0;

l oops++;

goto again ;

}TIMER STOP;

index += 4;

x [ 0 ] = (DATATYPE)sum ;

x [ 1 ] = (DATATYPE) index ;

f a k e ou t o p t im i z a t i o n s ( x ,2∗ s i z e o f (DATATYPE) ) ;

∗ o loops = loops ;

∗ous = TIMER ELAPSED;

re turn ( ( ( doub l e ) l oops ∗( doub l e ) l im i t )+( doub le ) index ) ;

}

doub le ca l i b ra t e benchmark won ly (REGISTER DATATYPE ∗x , REGISTER in t l im i t , i n t ∗ oloops , doub le ∗ous )

{REGISTER in t index = 0 , l oops = 0;

REGISTER DATATYPE sum1 = (DATATYPE)0 , sum2 = (DATATYPE)0 , sum3 = (DATATYPE)0 , sum4 = (DATATYPE)0 ;

FLUSHALL(1 ) ;

keepgo ing = 1;

a s s e r t ( s i g n a l (SIGALRM, hand ler ) != SIG ERR) ;

l im i t −= 4;

alarm ( durat ion ) ;

TIMER START;

again :

sum1++;

Version 1.1 165

Page 166: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

sum2++;

sum3++;

sum4++;

i f ( ( ( index+=4) < l im i t ) && ( keepgo ing ) )

goto again ;

e l s e i f ( keepgo ing )

{index = 0;

l oops++;

goto again ;

}TIMER STOP;

index += 4;

x [ 0 ] = (DATATYPE)sum1 ;

x [ 1 ] = (DATATYPE)sum2 ;

f a k e ou t o p t im i z a t i o n s ( x ,2∗ s i z e o f (DATATYPE) ) ;

re turn ( ( ( doub l e ) l oops ∗( doub l e ) l im i t )+( doub le ) index ) ;

}

doub le ca l i b ra t e benchmark (REGISTER DATATYPE ∗x , REGISTER in t t o do l oops , REGISTER in t l im i t , doub le ∗ous )

{REGISTER in t index = 0 , l oops = 0;

REGISTER DATATYPE sum1 = (DATATYPE)0 ;

TIMER START;

wh i l e ( l oops < t o do l o op s )

{f o r ( index = 0; index < l im i t ; index++)

{sum1++;

}l oop s++;

}TIMER STOP;

x [ 0 ] = (DATATYPE)sum1 ;

x [ 1 ] = (DATATYPE) index ;

f a k e ou t o p t im i z a t i o n s ( x ,2∗ s i z e o f (DATATYPE) ) ;

∗ous = TIMER ELAPSED;

{doub le r e f c n t = (( doub le ) l oops ∗( doub l e ) l im i t )+( doub le ) index ;

DBG( f p r i n t f ( s tde r r , ”C: %d loops at l im i t %d took %f us , %f r e f s .\n” , loops , l im i t ,∗ ous , r e f c n t ) ) ;

re turn ( r e f c n t ) ;

}} ∗/

Version 1.1 166

Page 167: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

double benchmark cache ronly (REGISTER DATATYPE ∗x , REGISTER int l im i t , int ∗ oloops , double ∗ous )

{REGISTER int index = 0 , l oops = 0 ;

REGISTER DATATYPE sum = (DATATYPE) 0 ;

FLUSHALL( 1 ) ;

keepgoing = 1 ;

a s s e r t ( s i g n a l (SIGALRM, handler ) != SIG ERR ) ;

alarm ( durat ion ) ;

TIMER START;

#ifdef SOLARIS

while ( go (−1))

#else

while ( keepgoing )

#endif

{for ( index = 0 ; index < l im i t ; index++)

{sum += x [ index ] ;

}l oops++;

}

TIMER STOP;

x [ 0 ] = (DATATYPE)sum ;

x [ 1 ] = (DATATYPE) index ;

f a k e ou t op t im i z a t i on s (x ,2∗ s izeof (DATATYPE) ) ;

∗ o loops = loops ;

∗ous = TIMER ELAPSED;

{double r e f c n t = ( (double ) l oops ∗(double ) l im i t )+(double ) index ;

DBG( f p r i n t f ( s tde r r , ”T: %d loops at l im i t %d took %f us , %f r e f s .\n” , loops , l im i t ,∗ ous , r e f c n t ) ) ;

return ( r e f c n t ) ;

}}

double hand benchmark cache ronly (REGISTER DATATYPE ∗x , REGISTER int l im i t , int ∗ oloops , double ∗ous )

{REGISTER int index = 0 , loops = 0 ;

REGISTER DATATYPE sum = (DATATYPE) 0 ;

REGISTER DATATYPE sum2 = (DATATYPE) 0 ;

FLUSHALL( 1 ) ;

keepgoing = 1 ;

a s s e r t ( s i g n a l (SIGALRM, handler ) != SIG ERR ) ;

Version 1.1 167

Page 168: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

l im i t −= 8 ;

alarm ( durat ion ) ;

TIMER START;

again :

sum += x [ index ] + x [ index +1] + x [ index +2] + x [ index +3] ;

sum2 += x [ index +4] + x [ index +5] + x [ index +6] + x [ index +7] ;

i f ( ( index += 8) < l im i t )

goto again ;

else i f ( keepgoing )

{index = 0 ;

l oops++;

goto again ;

}

TIMER STOP;

index += 8 ;

x [ 0 ] = (DATATYPE)sum + (DATATYPE)sum2 ;

x [ 1 ] = (DATATYPE) index ;

f a k e ou t op t im i z a t i on s (x ,2∗ s izeof (DATATYPE) ) ;

∗ o loops = loops ;

∗ous = TIMER ELAPSED;

{double r e f c n t = ( (double ) l oops ∗(double ) l im i t )+(double ) index ;

DBG( f p r i n t f ( s tde r r , ”T: %d loops at l im i t %d took %f us , %f r e f s .\n” , loops , l im i t ,∗ ous , r e f c n t ) ) ;

return ( r e f c n t ) ;

}}

double benchmark cache wonly (REGISTER DATATYPE ∗x , REGISTER int l im i t , int ∗ oloops , double ∗ous )

{REGISTER int index = 0 , l oops = 0 ;

REGISTER DATATYPE wval = (DATATYPE)0 xf ;

FLUSHALL( 1 ) ;

keepgoing = 1 ;

a s s e r t ( s i g n a l (SIGALRM, handler ) != SIG ERR ) ;

wval = (DATATYPE) l im i t ;

alarm ( durat ion ) ;

TIMER START;

while ( keepgoing )

{for ( index = 0 ; index < l im i t ; index++)

Version 1.1 168

Page 169: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

x [ index ] = wval ;

l oops++;

}

TIMER STOP;

f ak e ou t op t im i z a t i on s (x , l im i t ∗ s izeof (DATATYPE) ) ;

∗ o loops = loops ;

∗ous = TIMER ELAPSED;

{double r e f c n t = ( (double ) l oops ∗(double ) l im i t )+(double ) index ;

DBG( f p r i n t f ( s tde r r , ”T: %d loops at l im i t %d took %f us , %f r e f s .\n” , loops , l im i t ,∗ ous , r e f c n t ) ) ;

return ( r e f c n t ) ;

}}

double hand benchmark cache wonly (REGISTER DATATYPE ∗x , REGISTER int l im i t , int ∗ oloops , double ∗ous )

{REGISTER int index = 0 , loops = 0 ;

REGISTER DATATYPE wval = (DATATYPE)0 xf ;

FLUSHALL( 1 ) ;

keepgoing = 1 ;

a s s e r t ( s i g n a l (SIGALRM, handler ) != SIG ERR ) ;

l im i t −= 8 ; wval = (DATATYPE) l im i t ;

alarm ( durat ion ) ;

TIMER START;

again :

x [ index ] = wval ;

x [ index +1] = wval ;

x [ index +2] = wval ;

x [ index +3] = wval ;

x [ index +4] = wval ;

x [ index +5] = wval ;

x [ index +6] = wval ;

x [ index +7] = wval ;

i f ( ( index+=8) < l im i t )

goto again ;

else i f ( keepgoing )

{index = 0 ;

l oops++;

goto again ;

}

TIMER STOP;

Version 1.1 169

Page 170: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

index += 8 ;

f ak e ou t op t im i z a t i on s (x , l im i t ∗ s izeof (DATATYPE) ) ;

∗ o loops = loops ;

∗ous = TIMER ELAPSED;

{double r e f c n t = ( (double ) l oops ∗(double ) l im i t )+(double ) index ;

DBG( f p r i n t f ( s tde r r , ”T: %d loops at l im i t %d took %f us , %f r e f s .\n” , loops , l im i t ,∗ ous , r e f c n t ) ) ;

return ( r e f c n t ) ;

}}

double benchmark cache (REGISTER DATATYPE ∗x , REGISTER int l im i t , int ∗ oloops , double ∗ous )

{REGISTER int index = 0 , l oops = 0 ;

FLUSHALL( 1 ) ;

keepgoing = 1 ;

a s s e r t ( s i g n a l (SIGALRM, handler ) != SIG ERR ) ;

alarm ( durat ion ) ;

TIMER START;

while ( keepgoing )

{for ( index = 0 ; index < l im i t ; index++)

x [ index ]++;

loops++;

}

TIMER STOP;

f ak e ou t op t im i z a t i on s (x , l im i t ∗ s izeof (DATATYPE) ) ;

∗ o loops = loops ;

∗ous = TIMER ELAPSED;

{double r e f c n t = ( (double ) l oops ∗(double ) l im i t )+(double ) index ;

DBG( f p r i n t f ( s tde r r , ”T: %d loops at l im i t %d took %f us , %f r e f s .\n” , loops , l im i t ,∗ ous , r e f c n t ) ) ;

return ( r e f c n t ) ;

}}

double hand benchmark cache (REGISTER DATATYPE ∗x , REGISTER int l im i t , int ∗ oloops , double ∗ous )

{REGISTER int index = 0 , l oops = 0 ;

FLUSHALL( 1 ) ;

Version 1.1 170

Page 171: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

keepgoing = 1 ;

a s s e r t ( s i g n a l (SIGALRM, handler ) != SIG ERR ) ;

alarm ( durat ion ) ;

TIMER START;

again :

x [ index ]++;

x [ index+1]++;

x [ index+2]++;

x [ index+3]++;

x [ index+4]++;

x [ index+5]++;

x [ index+6]++;

x [ index+7]++;

i f ( ( index+=8) <= l imi t −8)

goto again ;

else i f ( keepgoing )

{index = 0 ;

l oops++;

goto again ;

}

TIMER STOP;

f ak e ou t op t im i z a t i on s (x , l im i t ∗ s izeof (DATATYPE) ) ;

∗ o loops = loops ;

∗ous = TIMER ELAPSED;

{double r e f c n t = ( (double ) l oops ∗(double ) l im i t )+(double ) index ;

DBG( f p r i n t f ( s tde r r , ”T: %d loops at l im i t %d took %f us , %f r e f s .\n” , loops , l im i t ,∗ ous , r e f c n t ) ) ;

return ( r e f c n t ) ;

}}

double benchmark cache memory copy (REGISTER void ∗x , REGISTER void ∗y , REGISTER int bytes , int ∗ oloops , double ∗ous )

{REGISTER int l oops = 0 ;

FLUSHALL( 1 ) ;

keepgoing = 1 ;

a s s e r t ( s i g n a l (SIGALRM, handler ) != SIG ERR ) ;

alarm ( durat ion ) ;

TIMER START;

Version 1.1 171

Page 172: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

while ( keepgoing )

{memcpy(x , y , bytes ) ;

l oops++;

}

TIMER STOP;

f ak e ou t op t im i z a t i on s (x , bytes ) ;

f a k e ou t op t im i z a t i on s (y , bytes ) ;

∗ous = TIMER ELAPSED;

∗ o loops = loops ;

return ( (double ) l oops ∗(double ) bytes ) ;

}

double benchmark cache memory set (REGISTER void ∗x , REGISTER int bytes , int ∗ oloops , double ∗ous )

{REGISTER int l oops = 0 ;

FLUSHALL( 1 ) ;

keepgoing = 1 ;

a s s e r t ( s i g n a l (SIGALRM, handler ) != SIG ERR ) ;

alarm ( durat ion ) ;

TIMER START;

while ( keepgoing )

{memset (x , 0 xf0 , bytes ) ;

l oops++;

}

TIMER STOP;

f ak e ou t op t im i z a t i on s (x , bytes ) ;

∗ous = TIMER ELAPSED;

∗ o loops = loops ;

return ( (double ) l oops ∗(double ) bytes ) ;

}

void i n i t i a l i z e s i z e s ( int ∗ s i z e s )

{int i , j ;

for ( j =0; j<t ime s l o t s ; j+=r e s o l u t i o n )

{s i z e s [ j ] = 1<<(CACHE MIN BITS+j / r e s o l u t i o n ) ;

Version 1.1 172

Page 173: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

DBG( p r i n t f ( ”POW: %d %d\n” , j , s i z e s [ j ] ) ) ;

for ( i =1; i<r e s o l u t i o n ; i++)

{i f ( j+i < t ime s l o t s )

{s i z e s [ j+i ] = s i z e s [ j ] + i ∗( s i z e s [ j ] / r e s o l u t i o n ) ;

s i z e s [ j+i ] = s i z e s [ j+i ] − s i z e s [ j+i ]%( int ) s izeof (DATATYPE) ;

DBG( p r i n t f ( ”SUB: %d %d\n” , j+i , s i z e s [ j+i ] ) ) ;

}}

}}

void do memory copy ( int ∗ s i z e s , void ∗x , double ∗ times , double ∗bws , double ∗ percent s )

{int l im i t , j , i , t l o op s ;

double r e f cn t , ov e rhead pe r r e f = 0 . 0 , tmic rosec ;

/∗ doub le n u l l c n t = 0.0 , cmicrosec = 0 . 0 ; ∗/void ∗y ;

a s s e r t ( y = (void ∗) mal loc ( memsize ) ) ;

memset (y , 0 x0f , memsize ) ;

i f ( i s a t t y ( 1 ) )

{p r i n t f ( ”\n\ t \ t%sMemory Copy Library Cache Test\n\n” ,

( ! ( type & NOCALIBRATE) ) ? ”Ca l ibrated ” : ”” ) ;

p r i n t f ( ”C S i z e \ t \ tNanosec\ t \tMB/ sec \ t \ t%% Chnge\n” ) ;

p r i n t f ( ”−−−−−−−\t \ t−−−−−−−\t \ t−−−−−−−\t \ t−−−−−−−\n” ) ;

}

for ( i = 0 ; i < t ime s l o t s ; i++)

{l im i t = s i z e s [ i ] ;

for ( j = 0 ; j < r epeat count ; j++)

{r e f c n t = benchmark cache memory copy (x , y , l im i t , &t loops , &tmic rosec ) ∗ 2 . 0 ;

/∗ i f ( type & NOCALIBRATE)

{nu l l c n t = 0 . 0 ;

o v e rhead pe r r e f = 0 . 0 ;

cmicrosec = 0 . 0 ;

}e l s e

{nu l l c n t = cal ibrate benchmark cache memory copy ( x , t l oops , l im i t , &cmicrosec ) ;

o v e rh ead pe r r e f = ( cmicrosec ∗1000.0) / nu l l c n t ;

Version 1.1 173

Page 174: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

DBG( f p r i n t f ( s tde r r , ”C: %f ns per r e f .\n” , o v e rh ead pe r r e f ) ) ;

} ∗/

compute stats ( i , j , r e f cn t , ove rhead per r e f , times , bws , percents , s i z e s , tmicrosec , 1 ) ;

}}

/∗ i f ( ( i s a t t y (1))&&( type&GUESSCACHESIZE))

compute cache s i z e s ( times , bws , percents , s i z e s ) ; ∗/

f r e e ( y ) ;

}

void do memory set ( int ∗ s i z e s , DATATYPE ∗x , double ∗ times , double ∗bws , double ∗ percent s )

{int l im i t , j , i , t l o op s ;

double r e f cn t , ov e rhead pe r r e f = 0 . 0 , tmic rosec ;

/∗ doub le n u l l c n t = 0.0 , cmicrosec = 0 . 0 ; ∗/

i f ( i s a t t y ( 1 ) )

{p r i n t f ( ”\n\ t \ t%sMemory Set Library Cache Test\n\n” ,

( ( ! ( type & NOCALIBRATE) ) ? ”Ca l ibrated ” : ”” ) ) ;

p r i n t f ( ”C S i z e \ t \ tNanosec\ t \tMB/ sec \ t \ t%% Chnge\n” ) ;

p r i n t f ( ”−−−−−−−\t \ t−−−−−−−\t \ t−−−−−−−\t \ t−−−−−−−\n” ) ;

}

for ( i = 0 ; i < t ime s l o t s ; i++)

{l im i t = s i z e s [ i ] ;

for ( j = 0 ; j < r epeat count ; j++)

{r e f c n t = benchmark cache memory set (x , l im i t , &t loops , &tmicrosec ) ;

/∗ i f ( type & NOCALIBRATE)

{nu l l c n t = 0 . 0 ;

o v e rhead pe r r e f = 0 . 0 ;

cmicrosec = 0 . 0 ;

}e l s e

{nu l l c n t = cal ibrate benchmark cache memory copy ( x , t l oops , l im i t , &cmicrosec ) ;

o v e rh ead pe r r e f = ( cmicrosec ∗1000.0) / nu l l c n t ;

DBG( f p r i n t f ( s tde r r , ”C: %f ns per r e f .\n” , o v e rh ead pe r r e f ) ) ;

} ∗/

compute stats ( i , j , r e f cn t , ove rhead per r e f , times , bws , percents , s i z e s , tmicrosec , 1 ) ;

Version 1.1 174

Page 175: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

}}

/∗ i f ( ( i s a t t y (1))&&( type&GUESSCACHESIZE))

compute cache s i z e s ( times , bws , percents , s i z e s ) ; ∗/}

void do read on ly ( int ∗ s i z e s , DATATYPE ∗x , double ∗ times , double ∗bws , double ∗ percent s )

{int l im i t , j , i , t l o op s ;

double r e f cn t , ov e rhead pe r r e f = 0 . 0 , tmic rosec ;

/∗ doub le n u l l c n t = 0.0 , cmicrosec = 0 . 0 ; ∗/

i f ( i s a t t y ( 1 ) )

{p r i n t f ( ”\n\ t \ t%s%s%s Read Cache Test\n\n” ,

( ( type & HANDTUNED) ? ”Tuned ” : ””) ,

( ( ! ( type & NOCALIBRATE) ) ? ”Ca l ibrated ” : ””) , DATASTRING) ;

p r i n t f ( ”C S i z e \ t \ tNanosec\ t \tMB/ sec \ t \ t%% Chnge\n” ) ;

p r i n t f ( ”−−−−−−−\t \ t−−−−−−−\t \ t−−−−−−−\t \ t−−−−−−−\n” ) ;

}

for ( i = 0 ; i < t ime s l o t s ; i++)

{l im i t = s i z e s [ i ] / ( int ) s izeof (DATATYPE) ;

for ( j = 0 ; j < r epeat count ; j++)

{i f ( type & HANDTUNED)

r e f c n t = hand benchmark cache ronly (x , l im i t , &t loops , &tmic rosec ) ;

else

r e f c n t = benchmark cache ronly (x , l im i t , &t loops , &tmic rosec ) ;

/∗ i f ( type & NOCALIBRATE)

{nu l l c n t = 0 . 0 ;

o v e rhead pe r r e f = 0 . 0 ;

cmicrosec = 0 . 0 ;

}e l s e

{nu l l c n t = ca l i b ra t e benchmark ( x , t l oops , l im i t , &cmicrosec ) ;

o v e rh ead pe r r e f = ( cmicrosec ∗1000.0) / nu l l c n t ;

DBG( f p r i n t f ( s tde r r , ”C: %f ns per r e f .\n” , o v e rh ead pe r r e f ) ) ;

} ∗/

compute stats ( i , j , r e f cn t , ove rhead per r e f , times , bws , percents , s i z e s , tmicrosec , s izeof (DATATYPE) ) ;

}}

Version 1.1 175

Page 176: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

/∗ i f ( ( i s a t t y (1))&&( type&GUESSCACHESIZE))

compute cache s i z e s ( times , bws , percents , s i z e s ) ; ∗/}

void do wr i t e on ly ( int ∗ s i z e s , DATATYPE ∗x , double ∗ times , double ∗bws , double ∗ percent s )

{int l im i t , j , i , t l o op s ;

double r e f cn t , ov e rhead pe r r e f = 0 . 0 , tmic rosec ;

/∗ doub le n u l l c n t = 0.0 , cmicrosec = 0 . 0 ; ∗/

i f ( i s a t t y ( 1 ) )

{p r i n t f ( ”\n\ t \ t%s%s%s Write Cache Test\n\n” ,

( ( type & HANDTUNED) ? ”Tuned ” : ””) ,

( ( ! ( type & NOCALIBRATE) ) ? ”Ca l ibrated ” : ””) , DATASTRING) ;

p r i n t f ( ”C S i z e \ t \ tNanosec\ t \tMB/ sec \ t \ t%% Chnge\n” ) ;

p r i n t f ( ”−−−−−−−\t \ t−−−−−−−\t \ t−−−−−−−\t \ t−−−−−−−\n” ) ;

}

for ( i = 0 ; i < t ime s l o t s ; i++)

{l im i t = s i z e s [ i ] / ( int ) s izeof (DATATYPE) ;

for ( j = 0 ; j < r epeat count ; j++)

{i f ( type & HANDTUNED)

r e f c n t = hand benchmark cache wonly (x , l im i t , &t loops , &tmic rosec ) ;

else

r e f c n t = benchmark cache wonly (x , l im i t , &t loops , &tmic rosec ) ;

/∗ i f ( type & NOCALIBRATE)

{nu l l c n t = 0 . 0 ;

o v e rhead pe r r e f = 0 . 0 ;

cmicrosec = 0 . 0 ;

}e l s e

{nu l l c n t = ca l i b ra t e benchmark ( x , t l oops , l im i t , &cmicrosec ) ;

o v e rh ead pe r r e f = ( cmicrosec ∗1000.0) / nu l l c n t ;

DBG( f p r i n t f ( s tde r r , ”C: %f ns per r e f .\n” , o v e rh ead pe r r e f ) ) ;

} ∗/

compute stats ( i , j , r e f cn t , ove rhead per r e f , times , bws , percents , s i z e s , tmicrosec , s izeof (DATATYPE) ) ;

}}

/∗ i f ( ( i s a t t y (1))&&( type&GUESSCACHESIZE))

Version 1.1 176

Page 177: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

compute cache s i z e s ( times , bws , percents , s i z e s ) ; ∗/}

void do read wr i t e ( int ∗ s i z e s , DATATYPE ∗x , double ∗ times , double ∗bws , double ∗ percent s )

{int l im i t , j , i , t l o op s ;

double r e f cn t , ov e rhead pe r r e f = 0 . 0 , tmic rosec ;

/∗ doub le n u l l c n t = 0.0 , cmicrosec = 0 . 0 ; ∗/

i f ( i s a t t y ( 1 ) )

{p r i n t f ( ”\n\ t \ t%s%s%s RMW Cache Test\n\n” ,

( ( type & HANDTUNED) ? ”Tuned ” : ””) ,

( ( ! ( type & NOCALIBRATE) ) ? ”Ca l ibrated ” : ””) , DATASTRING) ;

p r i n t f ( ”C S i z e \ t \ tNanosec\ t \tMB/ sec \ t \ t%% Chnge\n” ) ;

p r i n t f ( ”−−−−−−−\t \ t−−−−−−−\t \ t−−−−−−−\t \ t−−−−−−−\n” ) ;

}

for ( i = 0 ; i < t ime s l o t s ; i++)

{l im i t = s i z e s [ i ] / ( int ) s izeof (DATATYPE) ;

for ( j = 0 ; j < r epeat count ; j++)

{i f ( type & HANDTUNED)

r e f c n t = hand benchmark cache (x , l im i t , &t loops , &tmic rosec ) ∗ 2 . 0 ;

else

r e f c n t = benchmark cache (x , l im i t , &t loops , &tmic rosec ) ∗ 2 . 0 ;

/∗ i f ( type & NOCALIBRATE)

{nu l l c n t = 0 . 0 ;

o v e rhead pe r r e f = 0 . 0 ;

cmicrosec = 0 . 0 ;

}e l s e

{nu l l c n t = ca l i b ra t e benchmark ( x , t l oops , l im i t , &cmicrosec ) ;

n u l l c n t ∗= 2;

ov e rhead pe r r e f = ( cmicrosec ∗1000.0) / nu l l c n t ;

DBG( f p r i n t f ( s tde r r , ”C: %f ns per r e f .\n” , o v e rh ead pe r r e f ) ) ;

} ∗/

compute stats ( i , j , r e f cn t , ove rhead per r e f , times , bws , percents , s i z e s , tmicrosec , s izeof (DATATYPE) ) ;

}}

/∗ i f ( ( i s a t t y (1))&&( type&GUESSCACHESIZE))

compute cache s i z e s ( times , bws , percents , s i z e s ) ; ∗/

Version 1.1 177

Page 178: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

}

int main ( int argc , char ∗∗ argv )

{DATATYPE ∗x ;

int ∗ s i z e s ;

double ∗ times , ∗bws , ∗ percent s ;

type = usage ( argc , argv ) ;

a s s e r t ( s i z e s = ( int ∗) mal loc ( t ime s l o t s ∗ s izeof ( int ) ) ) ;

memset ( s i z e s , 0 x00 , ( t ime s l o t s ∗ s izeof ( int ) ) ) ;

a s s e r t ( t imes = (double ∗) mal loc ( t ime s l o t s ∗ r epeat count ∗ s izeof (double ) ) ) ;

memset ( times , 0 x00 , ( t ime s l o t s ∗ r epeat count ∗ s izeof (double ) ) ) ;

a s s e r t (bws = (double ∗) mal loc ( t ime s l o t s ∗ r epeat count ∗ s izeof (double ) ) ) ;

memset (bws , 0 x00 , ( t ime s l o t s ∗ r epeat count ∗ s izeof (double ) ) ) ;

a s s e r t ( pe r cent s = (double ∗) mal loc ( t ime s l o t s ∗ r epeat count ∗ s izeof (double ) ) ) ;

memset ( percents , 0 x00 , ( t ime s l o t s ∗ r epeat count ∗ s izeof (double ) ) ) ;

a s s e r t ( x = (DATATYPE ∗) mal loc ( memsize ) ) ;

memset ( ( void ∗)x , 0 x00 , memsize ) ;

i n i t i a l i z e s i z e s ( s i z e s ) ;

/∗ Measure cache ∗/

i f ( type & MEMORYSET)

{do memory set ( s i z e s , x , times , bws , pe r cent s ) ;

}

i f ( type & MEMORYCOPY)

{do memory copy ( s i z e s , x , times , bws , pe r cent s ) ;

}

i f ( type & READONLY)

{do read on ly ( s i z e s , x , times , bws , pe r cent s ) ;

}

i f ( type & WRITEONLY)

{do wr i t e on ly ( s i z e s , x , times , bws , pe r cent s ) ;

}

i f ( type & READWRITE)

{do read wr i t e ( s i z e s , x , times , bws , pe r cent s ) ;

}

Version 1.1 178

Page 179: Benchmark SPARC vs. x86 -  · PDF fileSPARC vs. x86 Raphael Schlameuß ... ist ein RISC-Prozessor. 1995 wurde die urspr¨ungliche 32-Bit-Architektur auf 64-Bit erweitert und

8.6 Source-Code LLCBench

FLUSHALL( 0 ) ;

e x i t ( 0 ) ;

}

Version 1.1 179