By rchrd on Jun 08, 2007
There's a new article on the SDN Sun Studio portal:
|By Timothy Jacobson, Sun Microsystems, June 2007||
By using performance flags, developers can quickly improve execution speed. However, sometimes compiler flags alone do not result in optimum performance. For this reason, Sun Studio compilers also allow inline assembly code to be placed in critical areas. The inline code behaves similarly to a function or subroutine call, which enables cleaner, more readable code and also enables variables to be directly accessed in the inline assembly code.
This paper provides a demonstration of how to measure the performance of a critical piece of code. An example using a compiler flag and another example using inline assembly code are provided. The results are compared to show the benefits and differences of each approach.
- Example 1: The Mandelbrot Set Algorithm
- Example 2: Mandelbrot Calculation in C
- Example 3: Compiling and Timing
- Example 4: Compiling and Timing
- Example 5: Sun Studio Inline Assembly Declaration for C
- Example 6. Mandelbrot Calculation in C With Inline Assembly Code
- Example 7: Typical Inline Assembly Code Template
- Example 8: Inline Assembly Code for the Iterative Mandelbrot Calculation
- Example 9: Compiling and Timing for
mandelbrot.cWith Inline Assembly Code
For demonstration purposes, this paper uses an academic program to generate the Mandelbrot set. The example Mandelbrot program is written in C. Computing all the pixel values of the Mandelbrot set using the Sun Studio compiler is timed. Then, optimization flags are used and the computations are timed again. Finally, example Sun Studio inline assembly code is used and the computations are timed again and compared with the previous timings. The examples demonstrate two different methods for improving performance with the Sun Studio compiler: using flags and using inline assembly code.
THE REST OF THE ARTICLE IS ON THE SUN STUDIO SDN PORTAL