Beware: Concurrent applications are closer than you think!

By Don Kretsch, Sun Studio Engineering Director, December 15, 2005  
Creating concurrent, multi-threaded applications has historically been the realm of developers focused on creating high-performance applications... demanding scientific applications or customized enterprise applications that required advanced programming techniques. With the introduction of multi-core processors, these programming techniques need to be understood and practiced by every programmer. Whether a common desktop application or a total enterprise platform handling thousands of transactions a second, threading unlocks the inherent power delivered in today's multi-core chips. Developers need to invest some time and talent becoming proficient in this software technology to stay marketable in the coming years.

What are Multi-core Systems?

Simply stated, a multi-core system is powered by a processor that contains more than one CPU on a single piece of silicon. Each individual CPU is called a core. A multi-core processor is capable of executing multiple simultaneous software threads, one thread on each of its processor cores. Executing multiple software threads within a single processor increases a processor's efficiency as wait latencies are minimized. In particular, when one thread is waiting for a memory access to occur, the other threads can continue executing on other cores in parallel. This lays the foundation for a significant increase in overall system's throughput.

When it comes to mainstream computing, there are only three chip architectures left: IBM's Power, Intel-compatible architectures, and Sun's SPARC. Each of these companies have historically invested in chip designs that tweaked the clock-rate, memory sub-system, and caching mechanisms to provide systems that delivered more performance. However, there has been a hidden cost that until recently, was ignored, the resulting power consumption. These fast systems used more power and were increasingly harder to cool. Sun recognized this problem a number of years ago and began an aggressive investment in a new chip design, namely a multi-core SPARC chip. Sun's first generation was the UltraSPARC IV, a dual-core chip released in Feb. 2004. Its second generation dual-core system, the UltraSPARC IV+, was released in Oct. 2004 . Sun's third generation, released in Dec. 2005. is the UltraSPARC T1 processor with CoolThreads technology, which provides eight processing cores with four threads per core on a single piece of silicon.

Other vendors also noticed that the power-in / performance-out curve was flattening and started projects of their own. IBM introduced a dual-core Power-series chip in July, 2005.  In the x86-compatible market, AMD took the lead and was first to release a 64-bit x86-compatible chip and more recently a dual-core 64-bit x86-compatible version in April, 2005. Once Intel realized that the industry was shifting, they quickly canceled a number of projects  an d started on their own dual-core x86 chip. Intel's dual-core desktop systems were announced April 2005 and their dual-core server chips in Oct . 2005.

When all the major chip suppliers move in the same direction, there is a fundamental paradigm shift occurring and it makes sense to take a closer look to understand how this impacts future software development. What used to be a 2-processor system is now a single processor, dual core system. What used to be a mid-range 8-processor system, can now be a higher-end 16 (2x8) core or 64 (8x8) core system. It's like a rack of servers on one chip!

Why should Developers care, won't all these systems be faster?

Multi-core processors are designed to deliver more resources to applications that seek to accomplish a large amount of work in aggregate. This has the potential of significantly improving the performance and throughput of your applications, but only if they are programmed to take advantage of this fundamental systems change. This is where it touches our developer space. To take advantage of this processing power, developers need to design applications with scaling and throughput in mind. Such applications would generally fall into one of the following categories:

  • Multi-threaded applications: Multi-threaded applications are characterized by having a small number of highly-threaded processes. The threads can be executed on a single processor or simultaneously on many processors. There are multiple techniques for creating multi-threaded applications, some of which are discussed below.

  • Multi-process applications: Multi-process applications are characterized by the presence of many single threaded processes working together to achieve a coordinated result.

  • Concurrent applications: Even single-threaded applications can benefit from a multi-core architecture by running multiple, concurrent instances of the application. If multiple application instances require some degree of isolation, Solaris Zones technology can be used to provide each of them its own separate and secure environment.

Sun has engineered all the key software elements necessary to deliver the best performance for these application classes executing on multi-core systems. First, its one thing to have a fast multi-core processor, but that speed will be wasted if the operating system can't deliver available processor resources to the application. Sun has a long history of providing industry-leading operating systems, dating back to the July 1992 release of the Solaris 2.0 OS, the first pre-emptable multi-threaded UNIX-based kernel. Sun's commitment to scalability and multithreading is most apparent in Solaris 10. The Solaris 10 OS provides innovative features to improve application performance on multi-core systems, including process scheduling, virtualization, tuning, and management of multi-core processor resources. For the developer, Solaris offers both optimized threading primitives  a nd the de-facto OpenGroup POSIX threading standard . Of course, with the Solaris binary compatibility guarantee, applications written for the Solaris platform need not be recompiled since they are guaranteed to run with no modification. However, to achieve maximum application performance, recompiling your applications with Sun's latest tools geared for multi-core systems will be your best approach to unlock the system's power.

Second, Java applications embrace threading in a fundamental way. Not only does the Java language greatly facilitate multi-threaded applications with its built-in threading model, but the Java Virtual Machine is a multithreaded process that provides scheduling and memory management for Java applications. The Solaris 10 JVM has been tuned such that all Java applications can immediately benefit from running on a multi-core system.

Third, and most important for all C, C++, and Fortran developers, Sun has released Sun Studio 11 and has made it free of charge! The optimizing compilers in Sun Studio 11 are tuned to generate the most performant multi-core code. Sun Studio 11 uses advanced analytical techniques, such as detailed dependence analyses, to assist automatic code execution parallelization - thereby optimizing the utilization of available processor resources and increasing throughput performance. These compilers have established 15 world record benchmark results in 2005 on both SPARC and Opteron-based systems making these the tools of choice for serious multi-threaded application developers. Sun's compilers even have flags that will attempt to auto-parallelize your code (-xautopar). This is a quick and easy way to get started in this new paradigm.

All the Sun Studio11 developer tools support the OpenMP v2.5 specification for multi-threaded programming. This includes an OpenMP-aware debugger making it easier for you to find/fix some of the nastier threading issues and a Performance Analyzer capable of providing detailed, thread-specific views of your program and how it is interacting with the OS and multi-core hardware.

Sun also provides a suite of highly tuned mathmatical libraries. In some common cases, the compilers can automatically detect particular code patterns and call a corresponding tuned library function. Users can also directly use the provided library functions saving development and tuning costs.

Whether you are developing for Solaris or Linux, SPARC or AMD, 32 or 64-bit applications, the Sun Studio 11 tool suite helps you develop bug-free, scalable, multi-threaded applications that take best advantage of these new multi-core systems. And best of all, its free so you can start developing multi-threaded applications today.

What Does this Mean to you, the Developer?

So, how can you get started learning about, and becoming successful in, this new world of multi-core computing?

First, become familiar with multi-threading techniques There is extensive on-line documentation about how to best design your applications for multi-threaded systems, including the Solaris multi-threaded programming guide and the OpenMP Users guide .Some programming language-specific information is available on how to best parallelize C code and how to use the C++ Standard Template Library in multi-threaded applications. Second, become familiar with the recommended guidelines for multi-threaded development . Third, download the Sun S tudio 11 tools for your Solaris, SuSE, and Red Hat multi-core development projects. Finally, try putting all of the above together and write some performant multi-threaded appplications with some detailed help from the Sun Developer Network article: Improving Application Efficiency through Chip Multithreading.

Yes, it is truly an interesting time to be a developer.  Multi-core systems will soon become ubiquitous. Application design and the right developer tools will be key elements to unlock the maximum system throughput and performance of these multi-core powerhouses. Will you be ready?

About the Author
Don Kretsch is the Engineering Director responsible for the Sun Studio developer tools product line for both SPARC and AMD systems. He has developed UNIX system software for 30 years, originally at AT&T Bell Labs, and for the last 15 years with Sun Microsystems.
Rate and Review
Tell us what you think of the content of this page.
Excellent   Good   Fair   Poor  
Your email address (no reply is possible without an address):
Sun Privacy Policy

Note: We are not able to respond to all submitted comments.