Wednesday Nov 07, 2007


Using OpenMP MIT PressIn October, MIT Press published the first really comprehensive book on parallel programming using the OpenMP API.

Using OpenMP,
Portable Shared Memory Parallel Programming, by Barbara Chapman, Gabriele Jost and Ruud van der Pas, with a foreword by David J. Kuck, covers shared-memory parallelization on a number of platforms.

I've had a pre-publication peek at it (because one of the authors, Ruud van der Pas, is a Sun engineer I work very closely with), and I can say that it packs a lot of very useful information in one place.

Most useful is a discussion of how cache lines can interfere with OpenMP parallelization and cause performance and scaling degradation if you are not aware of what's going on.

This will be a very valuable book on my shelf when it's available.



Wednesday Jun 27, 2007

New Article: Prefetching

Prefetching Pragmas and Intrinsics

Diane Meirowitz, Senior Staff Engineer, and Spiros Kalogeropulos, Staff Engineer, June, 2007


Explicit data prefetching pragmas and intrinsics for the x86 platform and additional pragmas and intrinscs for the SPARC platform are now available in Sun Studio 12 compilers, released June 2007.

Prefetch instructions can increase the speed of an application substantially by bringing data into cache so that it is available when the processor needs it. This benefits performance because today's processors are so fast that it is difficult to bring data into them quickly enough to keep them busy, even with hardware prefetching and multiple levels of data cache.

The compilers have several options that enable them to generate prefetch instructions automatically: -xprefetch, -xprefetch_level, and -xprefetch_auto_type (described below). The compilers generally do an excellent job of inserting prefetch instructions, and this is the most portable and best way to use prefetch. If finer control of prefetching is desired, prefetch pragmas or intrinsics can be used. Note that the performance benefit due to prefetch instructions is hardware-dependent and prefetches which improve performance on one chip may not have the same effect on a different chip. It is a good idea to study the instruction reference manual for the target hardware before inserting prefetch pragmas or intrinsics. Furthermore, the Sun Studio Performance Analyzer can be used to identify the cache misses of an application.

[Read More]

Friday Jun 22, 2007

C and C++ Technical Articles

There are a lot of useful, short, technical articles on the SDN portal directed at the C and C++ programmer on Solaris. 

This article gives an overview of the C-language extensions (part of the GNU C-implementation) introduced in the Sun Studio 12 C compiler. Although these extensions are not part of the latest ISO C99 standard, they are supported by the popular gcc compilers. (June 13, 2007)
Ever wonder what's in a patch? Take a look inside a typical Sun Studio compiler patch that includes updated C++ shared libraries. (November 10, 2006)
The Sun C++ compiler ships with two libraries that implement the C++ standard library: libCstd and libstlport. This article discusses the differences between the two libraries and explores the situations in which one library is preferred over the other. (May 17, 2006)
Hiding non-interface symbols of a library within the library makes the library more robust and less vulnerable to symbol collisions from outside the library. To get the appropriate linker scoping in a source program, you can now use language extensions built into the Sun Studio C/C++ compilers. (May 17, 2005)
The author shows how a simple C++ program fails without language linkage, but can succeed with proper linkage. (This article is on the Solaris portal.) (March 23, 2005)
In this test case, the DTrace capability in the Solaris 10 OS is used to identify an error common to C++ applications -- the memory leak. (This article is on the Solaris OS developer portal.) (February 17, 2005)
The C++ language provides mechanisms for mixing code that is compiled by compatible C and C++ compilers in the same program. You can experience varying degrees of success as you port such code to different platforms and compilers. This article shows how to solve common problems that arise when you mix C and C++ code, and highlights the areas where you might run into portability issues. (July 25, 2003)
This article discusses some of the runtime errors related to memory management and how you can use the garbage collection library, libgc to fix these errors. In most cases, just linking with the library without making any changes to your code will fix the errors. (July 25, 2003)
Using the restrict qualifier appropriately in C programs may allow the compiler to produce significantly faster executables. (July 17, 2003)
A discussion of the evolution of the C++ Application Binary Interface, and its implications. (March 20,2003)
Application software developers can learn to use the latest version of the Solaris OS while supporting previous versions. (January 1, 2002)

New Article: Fortran Library Functions - How To Call Them

Here's a new article from Michael Ingrassia, one of the lead developers in the Fortran Compiler team at Sun:



The Fortran language, both the standard language adhered to by all vendors and the extended language offered to Sun customers, contains several different models for how to call library functions. Confusion can result if you aren't clear about which model you should use for the particular library function you are calling. In this paper we try to describe the different models and provide examples of what might go wrong.

In general, any function found in a library can be called from Fortran. (Subroutines are rarer; for convenience we'll consistently refer to functions in this article where we should properly say function/subroutine). Here's a recipe for how to do it, which contains several specific recommendations for good coding practices.

To start , gather the following information:

  • The name of the function/subroutine
  • The correct declaration for the function/subroutine
    (sometimes this is provided in a file which must be included into your program)
  • The name of the library in which the function is supplied
    (not required for intrinsic functions)

Depending on what you find, there are 5 different models determining how to properly call this function:

  • It's a standard Fortran intrinsic
  • It's a non-standard Fortran intrinsic
  • It's a non-intrinsic Fortran run-time library function
  • It's a non-intrinsic function not supplied in the Fortran run-time libraries, but callable from Fortran
  • It's not a Fortran-callable function

Lets look at each situation in detail.


[Read More]

Wednesday Jun 13, 2007

New Sun Studio Article: C Language Extensions

There's a new article on the Sun Studio SDN portal: 

New Language Extensions in the Sun Studio 12 C Compiler

By Dmitry Mikhailichenko, Sun Microsystems, St Petersburg, Russia, June 2007  

This article gives an overview of the following C-language extensions (part of the GNU C-implementation) introduced in the Sun Studio 12 C compiler. Although these extensions are not part of the latest ISO C99 standard, they are supported by the popular gcc compilers.

  • The typeof keyword which allows references to an arbitrary type
  • Statement expressions that make it possible to specify declarations and statements in expressions
  • Block-scope label names

The article also demonstrates how to use the new C compiler features for creating generic macros on example of linked-list manipulation-routines. Such macros semantically mimic C++ Standard Template Library, support arbitrary data types and provide strict compile-time type-checking.

 ┬╗Read the entire article on the Sun Studio portal

Friday Jun 08, 2007

New Features in Sun Studio 12 Compilers

Here's what's new and changed in the Sun Studio 12 compilers: 

A New Way To Specify 32-bit or 64-bit Address Model

You no longer need use the -xarch option to specify a 32-bit or 64-bit address model (LP64 versus ILP32). Two new options make it easier:

  • -m32 specifies the ILP32 model: 32-bit ints, longs, and pointer types.

  • -m64 specifies the LP64 model: 32-bit ints, 64-bit longs and pointers types. (Note that -m64 is the default on Linux platforms.)

Deprecated -xarch Flags and Their Replacements Across SPARC and x86

  • Use -m64 in place of -xarch=generic64

  • Use -m64 -xarch=native in place of -xarch=native64

If you are using -xarch=v9 or -xarch=amd64 to specify a 64-bit address model, use just -m64 instead. No -xarch value is required.

[Read More]

Application development on Solaris OS


« June 2016