Thursday, August 19, 2010

Dhrystone and Whetstone

Dhrystone and whetstone are open source synthetic benchmark programs. These benchmarks are used in the following cases:
  • to measure and compare the performance of two different processors
  • to measure the performance of compilers for a processor

What is benchmark?

Benchmark is the standard based on which the performance is measured. Benchmarking is the act of measuring the performance of a system against a standard.

Benchmark programs are the set of programs which are used to assess the relative performance of a system. The benchmark programs are written such that they impose a particular type of workload on a system. And provide the metrics on the system performance for the workload imposed.

One way of writing the benchmark program is to first take the statistics of all the operations from various application program. Then, get the proportion of each operation and write the program based on the derived proportion. Thus created benchmark programs are called synthetic benchmark programs.


Dhrystone:

Dhrystone is the indicator of integer arithmetic performance. It stresses the ALU. Dhrystone doesn't contain any floating point operations. The name dhrystone is a pun on the name of another benchmark program "whetstone" (which is for floating point operations).

Dhrystone measures the performance in "Dhrystone per second". "Dhrystone per second" implies the number of times the program can run in a second.

Dhrystone doesn't provide the result in number of instructions per second. There is reason. Assume a task say 'x'. In a RISC machine, to accomplish this tasks it requires 2 instructions. Whereas the CISC machine requires 1 instruction. But the task 'x' is done faster in RISC machine than the CISC machine. So, here the performance measure in instruction count fails. Hence dhrystone performs the calculation in a machine specific way (of counting the number of program completion per second).

The main drawback of dhrystone is in most cases it is not the representation of the real-life programs. Also Dr. Reinhold Weicker who created Dhrystone says that “Although the Dhrystone benchmark that I published in 1984 was useful at the time, it cannot claim to be useful for modern workloads and CPUs because it is so short, it fits in on‐chip caches, and fails to stress the memory system. Also, because it is so short and does not read from an input file, special compiler optimizations can benefit Dhrystone performance more than normal program performance.”



Whetstone:

Whetstone is the indicator of floating point arithmetic performance. It stresses the FPU. Whetstone measures the performance in MWIPS (Million Whetstone Instructions Per Second). Whetstone is named after the town Whetstone in England where it was designed.

Whetstone mostly contains the floating point data and operations. In general, whetstone can be defined as the mix of operations that are typically performed in scientific applications.

The drawback of whetstone is, it doesn't show-up the advantages of architectures such as RISC. This is because, most of the variables in whetstone are global. Whereas, the large amount of processor registers that are available with RISC architectures would get exploited only for handling the local variables.


References:
http://en.wikipedia.org/wiki/Dhrystone
http://www.johnloomis.org/NiosII/dhrystone/ECLDhrystoneWhitePaper.pdf
http://dhrystone-benchmark.downloadaces.com/
http://www.dell.com/downloads/global/products/pedge/en/guide_to_server_benchmarks.pdf
http://www.keil.com/benchmarks/whetstone.asp
http://www.cse.dmu.ac.uk/~bb/Teaching/ComputerSystems/SystemBenchmarks/BenchMarks.html#whetstone
http://homepage.virgin.net/roy.longbottom/whetstone.htm
http://homepage.virgin.net/roy.longbottom/whetstone.pdf

Wednesday, August 18, 2010

My first usage of GTK!

Today I used the GTK for the first time. So what is GTK? GTK expands to GIMP ToolKit. GTK is the library to build graphical user interfaces. It is called GIMP ToolKit because, originally it was developed for the program GIMP (GNU Image Manipulation Program). Now many programs are using it.

I installed GTK in my ubuntu-9.10 desktop. With build essentials already with my system, I issued the following command at the terminal to install GTK+-2.0:

sudo apt-get install libgtk2.0-dev libgtk2.0-doc devhelp

libgtk2.0-dev installs the GTK library. libgtk2.0-doc and devhelp installs the documents of GTK and the browser for the documents respectively.

I wrote a simple hello world program. The program was written to create a window with a button on it. The button would have the label "Hello, World! Bye...". And once the button is clicked, the application would quit.

Download: helloworld_gtk.c

Compiled the hello world program and built the executable for the same by issuing the following command at the terminal:

gcc helloworld_gtk.c -o helloworld `pkg-config --cflags --libs gtk+-2.0`

Here,
  1. pkg-config is the program that reads the .pc which comes with GTK to determine what compiler switches are needed to compile programs that use GTK.
  2. pkg-config --cflags gtk+-2.0 will output a list of include directories for the compiler to look in
  3. pkg-config --libs gtk+-2.0 will output the list of libraries for the compiler to link with and the directories to find them in.

Monday, February 1, 2010

A study on genericizer in GCC

The need for genericizer in GCC depends on how well GENERIC can be made to match up with the source language that is supported in GCC front-end.

I.e. In GCC, if the parser for a language uses GENERIC as intermediate language representation, then a genericizer is not required. If the parser language uses any other intermediate language representation, then a genericizer is required to convert that intermediate language representation to GENERIC.

Note: Any intermediate language representation that seems appropriate for a language can be used. [Ref: Page 93 of GCC Internals for GCC version 4.4.0].


Hence there are following two cases:
  • Case1: Parser uses GENERIC as intermediate language representation
  • Case2: Parser uses any other intermediate language representation


Case1: Parser uses GENERIC as intermediate language representation


In this case, the language parser uses GENERIC and some language specific trees as intermediate language representation. [Ref: Page 93 of GCC Internals for GCC version 4.4.0]. The Gimplifier (which belongs to 'language-independent portions of the compiler') is called directly for the GENERIC representation generated by the parser.

The language specific trees which is generated along with the GENERIC by the parser would be converted into GIMPLE as follows [Ref: Page 201 of GCC Internals for GCC version 4.4.0]:

  1. Convert the language specific trees to GENERIC. And then provide the GENERIC to the Gimplifier to generate GIMPLE.
  2. Convert the language specific trees to GIMPLE straightly.
The above two tasks would be done by the gimplifier hooks [Ref: Page 199 of GCC Internals for GCC version 4.4.0]. Gimplifier hooks are the one that are used to over-ride the standard functions of Gimplifier. This over-riding of standard functions is required because of language specific trees generated as intermediate represenation by parser.

Example:

For C, the language specific trees are converted into GIMPLE straightly (without converting into GENERIC) by the gimplifier hooks [Ref: Page 201of GCC Internals for GCC version 4.4.0].



Case2: Parser uses any other intermediate language representation



In this case, the language parser uses its own intermediate language representation [Ref: Page 93 of GCC Internals for GCC version 4.4.0]. And for this intermediate language representation to be used by Gimplifier (which belongs to 'language-independent portions of the compiler'), it should be converted to GENERIC. For this we require a 'Genericizer'. Genericizer converts the intermediate language representation generated by the parser to the GENERIC form. Hence the genericizer would be the language dependent portion of the compiler.

Thus generated GENERIC is given to the gimplifier.

Example: