Welcome!

Open Source Cloud Authors: Pat Romanski, Yeshim Deniz, Liz McMillan, Stackify Blog, Wesley Coelho

Related Topics: Open Source Cloud

Open Source Cloud: Article

Multi-Core Debugging and Performance Enhancement

Additional pressures on complex applications

Computer systems have fully entered the age of multi-core processing. This trend was examined in a white paper entitled, "Preparing for the Revolution, Maximizing Dual-Core Technology." While much of the focus had been on dual-core processors, Intel has now delivered quad-core processors and AMD has announced quad-core availability in 2007. Software developers who are just taking advantage of multiple processors also need to be looking ahead since even larger multi-core platforms will reach the market soon. This new technology puts additional pressures on complex applications. In essence, the push beyond dual-cores has made the choice of development tools a key factor for successful projects.

When writing multi-core software, there are two important issues facing software developers. The first and most familiar is correctness of the program, i.e., does the program work properly and get the right answer. While this seems obvious, in multi-core applications, incorrect program behavior can arise from several sources not present in single-core design.

The second important feature is program performance. An assumption that speed-up is automatic just because a program has been modified to utilize multi-cores can be a huge mistake. Improved performance is not necessarily automatic or guaranteed.

With the introduction of quad-core processors, applications have the option of using eight cores on one dual-socket motherboard. Proper use of these additional resources will be critical to software development. This article will provide some insight into these issues and present some solutions to the problems facing multi-core programmers using the Linux operating system.

Prerequisites
As suggested in the white paper mentioned above, some consideration should be given to the method of parallelization. Two basic models are available to programmers - program threads and message passing. While message passing is the predominant method used in High Performance Computing (HPC), threads are becoming more important as both the core and socket sizes increase in most new motherboards.

Given that message passing programming is covered by other sources, this article will focus on threaded programming on multi-core processors using Linux.

A general approach to parallel computing is first to take a working sequential program, a program that is known to operate correctly on one CPU, and use it as the basis for a parallel program. This technique has two big advantages. First, the program can be tested to ensure that it operates at an acceptable level of correctness. (i.e., the program works and any issues are known in advance). Second, the programmer has a performance baseline with which to measure the new multi-core program.

If a new program is being written, it's highly advisable to create and debug a sequential version first. Adding the additional complexity of parallel programming to standard software development makes isolating bugs and problems more difficult.

In general, threaded programs often have multiple independent parts that share the same data set. One way to use threaded programming is to allow subroutines to operate independently and at the same time. It's also possible to break large loops up into threads as well. In all cases, however, a good design will allow the threaded version to "collapse" into a single thread by setting a thread count variable to one.

Finally, since there are adequate resources for learning about threaded programming, we'll concentrate on ways to ensure correct program operation and optimal performance.

Programming with Threads
The thread model is a way for a program to split itself into two or more concurrent tasks. These tasks can be run on a single processor in a time-shared mode, or on separate processors (e.g., the two cores on a dual-core processor can each run threads). The term thread comes from "thread of execution" and is a reference to how a fabric (computer program) can be pulled apart into threads (concurrent parts). Threads are different from individual processes (or independent programs), because they inherit much of their state information and memory from the parent process. Threads provide the ability to share memory and offer very fine-grained synchronization with other sibling threads.

On Linux and Unix systems threads are often implemented using a POSIX Thread Library (pthreads). There are several other thread models (Windows threads) from which the programmer can choose, however, using a standards-based implementation like POSIX is highly recommended. As a low-level library, pthreads can be easily included in almost all programming applications. This article will discuss debugging and optimizing Linux threads.

Ensuring Program Correctness
Of course, all programmers know that just because a program finishes, it doesn't mean the answers are correct. With multi-core programming, this situation may manifest itself differently. The same program and data, run at different times, may produce different answers, or cease functioning altogether for no apparent reason. We'll explore some of these causes and present some solutions.

Deadlock and Livelock
Because individual threads share memory and I/O, there must be a way for each thread to protect memory segments and I/O resources while they're using it. To solve this problem, threaded code employs "locks" that provide the thread exclusive access to a resource.

While the introduction of locks provides a solution to this problem, it also creates the possibility of a deadlock occurring in the program. Consider the following scenario where there are two global variables called Total and Sub-Total.

Process 1 locks the variable Total
Process 2 locks the variable Sub-Total
Process 1 attempts to acquire a lock on Sub-Total
Process 2 attempts to acquire a lock on Total

The program is now in a deadlock situation. Deadlock may develop every time the program runs or it may happen randomly when the timing is right. There's also a condition called "livelock" that's similar to deadlock. Livelock results when a thread or threads are constantly trying to acquire a lock, but can't because it's being used by another part of the program (or more likely hasn't been unlocked properly). Livelock may stop certain threads, but not necessarily cause the whole program to stop. With livelock, a program may appear to be working, but in reality it's often stuck in a loop, which can make it hard to determine the exact cause of the problem.

While deadlock and livelock can often be recognized through program behavior (i.e., the program stops, crashes, or gets stuck in one place), locating the cause can be difficult at times unless you can look at the threads in real-time. Certain lock conditions have a temporal component and can be hard to reproduce unless the program is running in production mode (i.e., a specific sequence or timing of events caused the situation).

More Stories By Douglas Eadline

Dr. Douglas Eadline has over 25 years of experience in high-performance computing. You can contact him through Basement Supercomputing (http://basement-supercomputing.com).

More Stories By Vince Hauber

Vince Hauber, a senior product manager with Concurrent Computer Corporation, has over 40 years experience in system software and platform solutions. Concurrent is a leading provider of real-time Linux distributions and tools.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


@ThingsExpo Stories
Organizations do not need a Big Data strategy; they need a business strategy that incorporates Big Data. Most organizations lack a road map for using Big Data to optimize key business processes, deliver a differentiated customer experience, or uncover new business opportunities. They do not understand what’s possible with respect to integrating Big Data into the business model.
Recently, REAN Cloud built a digital concierge for a North Carolina hospital that had observed that most patient call button questions were repetitive. In addition, the paper-based process used to measure patient health metrics was laborious, not in real-time and sometimes error-prone. In their session at 21st Cloud Expo, Sean Finnerty, Executive Director, Practice Lead, Health Care & Life Science at REAN Cloud, and Dr. S.P.T. Krishnan, Principal Architect at REAN Cloud, will discuss how they b...
Enterprises have taken advantage of IoT to achieve important revenue and cost advantages. What is less apparent is how incumbent enterprises operating at scale have, following success with IoT, built analytic, operations management and software development capabilities – ranging from autonomous vehicles to manageable robotics installations. They have embraced these capabilities as if they were Silicon Valley startups. As a result, many firms employ new business models that place enormous impor...
SYS-CON Events announced today that Dasher Technologies will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 - Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Dasher Technologies, Inc. ® is a premier IT solution provider that delivers expert technical resources along with trusted account executives to architect and deliver complete IT solutions and services to help our clients execute their goals, plans and objectives. Since 1999, we'v...
SYS-CON Events announced today that MIRAI Inc. will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. MIRAI Inc. are IT consultants from the public sector whose mission is to solve social issues by technology and innovation and to create a meaningful future for people.
SYS-CON Events announced today that TidalScale, a leading provider of systems and services, will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 - Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. TidalScale has been involved in shaping the computing landscape. They've designed, developed and deployed some of the most important and successful systems and services in the history of the computing industry - internet, Ethernet, operating s...
SYS-CON Events announced today that TidalScale will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. TidalScale is the leading provider of Software-Defined Servers that bring flexibility to modern data centers by right-sizing servers on the fly to fit any data set or workload. TidalScale’s award-winning inverse hypervisor technology combines multiple commodity servers (including their ass...
Amazon is pursuing new markets and disrupting industries at an incredible pace. Almost every industry seems to be in its crosshairs. Companies and industries that once thought they were safe are now worried about being “Amazoned.”. The new watch word should be “Be afraid. Be very afraid.” In his session 21st Cloud Expo, Chris Kocher, a co-founder of Grey Heron, will address questions such as: What new areas is Amazon disrupting? How are they doing this? Where are they likely to go? What are th...
SYS-CON Events announced today that IBM has been named “Diamond Sponsor” of SYS-CON's 21st Cloud Expo, which will take place on October 31 through November 2nd 2017 at the Santa Clara Convention Center in Santa Clara, California.
Infoblox delivers Actionable Network Intelligence to enterprise, government, and service provider customers around the world. They are the industry leader in DNS, DHCP, and IP address management, the category known as DDI. We empower thousands of organizations to control and secure their networks from the core-enabling them to increase efficiency and visibility, improve customer service, and meet compliance requirements.
Join IBM November 1 at 21st Cloud Expo at the Santa Clara Convention Center in Santa Clara, CA, and learn how IBM Watson can bring cognitive services and AI to intelligent, unmanned systems. Cognitive analysis impacts today’s systems with unparalleled ability that were previously available only to manned, back-end operations. Thanks to cloud processing, IBM Watson can bring cognitive services and AI to intelligent, unmanned systems. Imagine a robot vacuum that becomes your personal assistant tha...
SYS-CON Events announced today that IBM has been named “Diamond Sponsor” of SYS-CON's 21st Cloud Expo, which will take place on October 31 through November 2nd 2017 at the Santa Clara Convention Center in Santa Clara, California.
In his Opening Keynote at 21st Cloud Expo, John Considine, General Manager of IBM Cloud Infrastructure, will lead you through the exciting evolution of the cloud. He'll look at this major disruption from the perspective of technology, business models, and what this means for enterprises of all sizes. John Considine is General Manager of Cloud Infrastructure Services at IBM. In that role he is responsible for leading IBM’s public cloud infrastructure including strategy, development, and offering ...
SYS-CON Events announced today that N3N will exhibit at SYS-CON's @ThingsExpo, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. N3N’s solutions increase the effectiveness of operations and control centers, increase the value of IoT investments, and facilitate real-time operational decision making. N3N enables operations teams with a four dimensional digital “big board” that consolidates real-time live video feeds alongside IoT sensor data a...
In a recent survey, Sumo Logic surveyed 1,500 customers who employ cloud services such as Amazon Web Services (AWS), Microsoft Azure, and Google Cloud Platform (GCP). According to the survey, a quarter of the respondents have already deployed Docker containers and nearly as many (23 percent) are employing the AWS Lambda serverless computing framework. It’s clear: serverless is here to stay. The adoption does come with some needed changes, within both application development and operations. Tha...
SYS-CON Events announced today that Avere Systems, a leading provider of enterprise storage for the hybrid cloud, will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 - Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Avere delivers a more modern architectural approach to storage that doesn't require the overprovisioning of storage capacity to achieve performance, overspending on expensive storage media for inactive data or the overbui...
With major technology companies and startups seriously embracing Cloud strategies, now is the perfect time to attend 21st Cloud Expo October 31 - November 2, 2017, at the Santa Clara Convention Center, CA, and June 12-14, 2018, at the Javits Center in New York City, NY, and learn what is going on, contribute to the discussions, and ensure that your enterprise is on the right path to Digital Transformation.
Smart cities have the potential to change our lives at so many levels for citizens: less pollution, reduced parking obstacles, better health, education and more energy savings. Real-time data streaming and the Internet of Things (IoT) possess the power to turn this vision into a reality. However, most organizations today are building their data infrastructure to focus solely on addressing immediate business needs vs. a platform capable of quickly adapting emerging technologies to address future ...
Digital transformation is changing the face of business. The IDC predicts that enterprises will commit to a massive new scale of digital transformation, to stake out leadership positions in the "digital transformation economy." Accordingly, attendees at the upcoming Cloud Expo | @ThingsExpo at the Santa Clara Convention Center in Santa Clara, CA, Oct 31-Nov 2, will find fresh new content in a new track called Enterprise Cloud & Digital Transformation.
Most technology leaders, contemporary and from the hardware era, are reshaping their businesses to do software. They hope to capture value from emerging technologies such as IoT, SDN, and AI. Ultimately, irrespective of the vertical, it is about deriving value from independent software applications participating in an ecosystem as one comprehensive solution. In his session at @ThingsExpo, Kausik Sridhar, founder and CTO of Pulzze Systems, will discuss how given the magnitude of today's applicati...