Retrofitting Programming Languages for a Parallel World

By James Reinders

February 23, 2012

The most widely used computer programming languages today were not designed as parallel programming languages. But retrofitting existing programming languages for parallel programming is underway. We can compare and contrast retrofits by looking at four key features, five key qualities, and the various implementation approaches.

In this article, I focus on the features and qualities, leaving the furious debates over best approaches (language vs. library vs. directives, and abstract and portable vs. low-level with lots of controls) for another day.

Four features we need

Features that any parallel programming solution, including retrofits, should include a defined memory model, synchronization, tasks, and data parallelism.

Memory model

Defining how changes in shared data are observable by different tasks had been an under-appreciated problem. Hans-J. Boehm wrote a report in 2004, titled Threads Cannot Be Implemented As a Library, which explains these issues. Having a well-defined ordering among accesses to distinct variables, and enabling the independence of updates to distinct variables, is so important that they have been addressed in Java, C11 and C++11. Without these retrofits, every parallel program sits on a crumbling foundation.

Synchronization

The need for portable and efficient synchronization is substantial. Boost libraries, Intel’s Threading Building Blocks (TBB) and OpenMP offer solutions that are widely utilized. C++11 and C11 now offer support. Beyond these, the concept of transactions is a topic worth exploring in a future article. Synchronization retrofitting is helping portability. Substantial opportunities remain for helping efficiency.

Tasks, not threads

Programming should be an exercise in writing tasks that can run concurrently, without the programmer specifying the precise mapping of tasks onto hardware threads. An introduction to this challenge is The Problem with Threads by Edward A. Lee.

Mapping should be the job of tools, including run-time schedulers, not explicit programming. This philosophy is being well supported by retrofits like OpenMP, TBB, Cilk Plus, Microsoft’s Parallel Patterns Library (PPL) and Apple’s Grand Central Dispatch (GCD). The need to assert some control over task to thread mapping to maximize performance is still present when using such systems today, but not always supported.

Nevertheless, programming directly to native threads (e.g., pthreads) in applications is something that should be completely avoided. Retrofits are sufficient today to make tasks the method of choice.

Data parallel support

It should be reasonably straightforward to write a portable program that takes advantage of data parallel hardware. Ideally, data parallel support should be able to utilize vector and task parallel capabilities without a programmer having to explicitly code the division between the two.

Unfortunately, no such solution is in wide spread use today even for vectorization alone. Effective auto-parallelization is very dependent on highly optimizing compilers. Compiler intrinsics lock code into a particular vector width (MMX=64, SSE=128, AVX=256, etc.). Elemental functions in CUDA, OpenCL, and Cilk Plus offer a glimpse into possible retrofits. Intel proposes we adopt the vectorization benefits of Fortran 90 array notations into C and C++ as part of the Cilk Plus project.

Vector hardware is increasingly important in processors, GPUs and co-processors. OpenCL and OpenMP wrestle today with how to embrace data parallel hardware and how tightly tied programming will be to it. Microsoft C++ AMP has similar challenges when it comes to market with the next Microsoft Visual Studio. Standard, abstract, portable and effective solutions wanted!

Five qualities we should desire

Five key qualities that are desirable, for parallel programming, include composability, sequential reasoning, communication minimization, performance portability and safety.

All of these qualities are unobtainable, in an absolute sense, whether as retrofits in an old language or with a clean slate and a new language. That is why we cannot call them features. The more of these qualities we obtain the better off we are. That makes them very important to keep in mind.

Composability

Composability is a well-known concept in programming, offering rules for combining different things together (functions, objects, modules, etc.) so that it is easy to compose (think: combine in unanticipated ways). It is important to think of composability in terms of both correctness and performance.

OpenCL, largely because it is less abstract, has low composability on both accounts. OpenMP and OpenCL have very serious performance composability unless they are used very carefully. New and abstract retrofits (TBB, Cilk, PPL, GCD) are much more tolerant and able to deliver high composability.

Self-composability is an essential first step, but the ability to compose multiple retrofits together is essential in the long run as well. A welcome solution for tool vendors, Microsoft’s Concurrency Runtime has allowed retrofits from multiple vendors to coexist with increased composability. Parallel programming without the ability to mix and match freely, is undesirable and counterproductive.

Composability deserves more attention than it gets.

Sequential reasoning

Sequential reasoning, the norm for reading a serial implementation, can apply with an appropriately expressed parallel program. OpenMP uses hints to create the use of parallelism instead of code changes. This allows the intent of a program to remain evident in the code. TBB and PPL emphasize relaxed sequential semantics to provide parallelism as an accelerator without making it mandatory for correctness. Writing a program in a sequentially consistent fashion is permitted and encouraged.

An explicit goal of Cilk Plus is to offer sequential semantics to set it apart from other retrofits. The serial elision (or C elision) of a Cilk program is touted in papers from MIT. Programming that preserves sequential semantics has received praise as easier to learn and use. The elemental functions in OpenCL, CUDA and Cilk Plus have similar objectives.

It is fair to say that programming in a manner that requires understanding parallel semantics, in order to understand intent, is both unpopular and out of vogue today. Such mandatory parallelism is harder to understand and to debug.

Sequential reasoning can be extended to debuggers too. A hot area to watch here is debuggers working to present a debugging experience more akin to sequential experiences, with features like Rogue Wave’s replay capabilities in the Totalview debugger.

Instead of sequential reasoning being a retrofit, it is more accurate to think of sequential reasoning as often being purposefully sought and preserved in a parallel world.

Communication minimization

Performance tuning on parallel systems often focuses on ensuring data is local when you use it and minimizing the need to move it around. Data motion means communication of some sort, and communication is generally expensive. Decisions in the design and implementation of retrofits, as well as the application programming itself, often impact performance dramatically. The task stealing algorithms of TBB, Cilk, PPL and GCD all have cache reuse strongly in mind in their designs. Retrofits to help, with communication minimization, are a tricky business and could use more attention.

Performance portability

The goal here is that a tuned program on one piece of hardware performs reasonably well on another piece of hardware. It is desirable to be able to describe data and tasks in such a way that performance scales as parallelism increases (number of cores, or size of vectors, or cache size, etc.). Nothing is ever fully performance portable, but more abstract retrofits tend to hold up better.

Unfortunately, implementations of abstractions can struggle to offer peak performance. It took years for compilers to offer performance for MMX or SSE that was competitive with assembly language programming. Use of cache-agnostic algorithms generally increase performance portability. Today, competing on performance with carefully-crafted CUDA and OpenCL code can be challenging because the coding is low level enough to encourage, or even require, the program structure to match the hardware. The lack of performance portability of such code is frequently shown, but effective alternatives remain works-in-progress. Language design, algorithm choices and programming style can affect performance portability a great deal.

Safety

The freedom from deadlocks and race conditions, may be the most difficult to provide via a retrofit. No method to add complete safety to C or C++ has gained wide popularity. Safety has not been incorporated into non-managed languages easily, despite some valiant efforts to do so.

To make a language safe, pointers have to be removed or severely restricted. Meanwhile, tools are maturing to help us cope with safety despite lack of direct language support, and safer coding style and safer retrofits appear to help as well. Perhaps safety comes via a combination of “good enough” and “we can cope using tools.”

A journey ahead, together

There are at least four key programming problems that any parallel programming solution should address, and five key qualities that can make a programming model, retrofit or otherwise, more desirable. Evolution in hardware will help as well.

—–

About the author

James Reinders has helped develop supercomputers, microprocessors and software tools for 25 years. He is a senior engineer for Intel in Hillsboro Oregon.

Subscribe to HPCwire's Weekly Update!

Be the most informed person in the room! Stay ahead of the tech trends with industy updates delivered to you every week!

AWS Introduces a Flurry of New EC2 Instances at re:Invent

November 30, 2022

AWS has announced three new Amazon Elastic Compute Cloud (Amazon EC2) instances powered by AWS-designed chips, as well as several new Intel-powered instances – including ones targeting HPC – at its AWS re:Invent 2022 Read more…

Quantum Riches and Hardware Diversity Are Discouraging Collaboration

November 28, 2022

Quantum computing is viewed as a technology for generations, and the spoils for the winners are huge, but the diversity of technology is discouraging collaboration, an Intel executive said last week. There are close t Read more…

2022 Road Trip: NASA Ames Takes Off

November 25, 2022

I left Dallas very early Friday morning after the conclusion of SC22. I had a race with the devil to get from Dallas to Mountain View, Calif., by Sunday. According to Google Maps, this 1,957 mile jaunt would be the longe Read more…

2022 Road Trip: Sandia Brain Trust Sounds Off

November 24, 2022

As the 2022 Great American Supercomputing Road Trip carries on, it’s Sandia’s turn. It was a bright sunny day when I rolled into Albuquerque after a high-speed run from Los Alamos National Laboratory. My interview su Read more…

2022 HPC Road Trip: Los Alamos

November 23, 2022

With SC22 in the rearview mirror, it’s time to get back to the 2022 Great American Supercomputing Road Trip. To refresh everyone’s memory, I jumped in the car on November 3rd and headed towards SC22 in Dallas, stoppi Read more…

AWS Solution Channel

Shutterstock 110419589

Thank you for visiting AWS at SC22

Accelerate high performance computing (HPC) solutions with AWS. We make extreme-scale compute possible so that you can solve some of the world’s toughest environmental, social, health, and scientific challenges. Read more…

 

shutterstock_1431394361

AI and the need for purpose-built cloud infrastructure

Modern AI solutions augment human understanding, preferences, intent, and even spoken language. AI improves our knowledge and understanding by delivering faster, more informed insights that fuel transformation beyond anything previously imagined. Read more…

Chipmakers Looking at New Architecture to Drive Computing Ahead

November 23, 2022

The ability to scale current computing designs is reaching a breaking point, and chipmakers such as Intel, Qualcomm and AMD are putting their brains together on an alternate architecture to push computing forward. The chipmakers are coalescing around the new concept of sparse computing, which involves bringing computing to data... Read more…

AWS Introduces a Flurry of New EC2 Instances at re:Invent

November 30, 2022

AWS has announced three new Amazon Elastic Compute Cloud (Amazon EC2) instances powered by AWS-designed chips, as well as several new Intel-powered instances Read more…

Quantum Riches and Hardware Diversity Are Discouraging Collaboration

November 28, 2022

Quantum computing is viewed as a technology for generations, and the spoils for the winners are huge, but the diversity of technology is discouraging collaborat Read more…

2022 HPC Road Trip: Los Alamos

November 23, 2022

With SC22 in the rearview mirror, it’s time to get back to the 2022 Great American Supercomputing Road Trip. To refresh everyone’s memory, I jumped in the c Read more…

QuEra’s Quest: Build a Flexible Neutral Atom-based Quantum Computer

November 23, 2022

Last month, QuEra Computing began providing access to its 256-qubit, neutral atom-based quantum system, Aquila, from Amazon Braket. Founded in 2018, and built o Read more…

SC22’s ‘HPC Accelerates’ Plenary Stresses Need for Collaboration

November 21, 2022

Every year, SC has a theme. For SC22 – held last week in Dallas – it was “HPC Accelerates”: a theme that conference chair Candace Culhane said reflected Read more…

Quantum – Are We There (or Close) Yet? No, Says the Panel

November 19, 2022

For all of its politeness, a fascinating panel on the last day of SC22 – Quantum Computing: A Future for HPC Acceleration? – mostly served to illustrate the Read more…

RISC-V Is Far from Being an Alternative to x86 and Arm in HPC

November 18, 2022

One of the original RISC-V designers this week boldly predicted that the open architecture will surpass rival chip architectures in performance. "The prediction is two or three years we'll be surpassing your architectures and available performance with... Read more…

Gordon Bell Special Prize Goes to LLM-Based Covid Variant Prediction

November 17, 2022

For three years running, ACM has awarded not only its long-standing Gordon Bell Prize (read more about this year’s winner here!) but also its Gordon Bell Spec Read more…

Nvidia Shuts Out RISC-V Software Support for GPUs 

September 23, 2022

Nvidia is not interested in bringing software support to its GPUs for the RISC-V architecture despite being an early adopter of the open-source technology in its GPU controllers. Nvidia has no plans to add RISC-V support for CUDA, which is the proprietary GPU software platform, a company representative... Read more…

RISC-V Is Far from Being an Alternative to x86 and Arm in HPC

November 18, 2022

One of the original RISC-V designers this week boldly predicted that the open architecture will surpass rival chip architectures in performance. "The prediction is two or three years we'll be surpassing your architectures and available performance with... Read more…

AWS Takes the Short and Long View of Quantum Computing

August 30, 2022

It is perhaps not surprising that the big cloud providers – a poor term really – have jumped into quantum computing. Amazon, Microsoft Azure, Google, and th Read more…

Chinese Startup Biren Details BR100 GPU

August 22, 2022

Amid the high-performance GPU turf tussle between AMD and Nvidia (and soon, Intel), a new, China-based player is emerging: Biren Technology, founded in 2019 and headquartered in Shanghai. At Hot Chips 34, Biren co-founder and president Lingjie Xu and Biren CTO Mike Hong took the (virtual) stage to detail the company’s inaugural product: the Biren BR100 general-purpose GPU (GPGPU). “It is my honor to present... Read more…

AMD Thrives in Servers amid Intel Restructuring, Layoffs

November 12, 2022

Chipmakers regularly indulge in a game of brinkmanship, with an example being Intel and AMD trying to upstage one another with server chip launches this week. But each of those companies are in different positions, with AMD playing its traditional role of a scrappy underdog trying to unseat the behemoth Intel... Read more…

Tesla Bulks Up Its GPU-Powered AI Super – Is Dojo Next?

August 16, 2022

Tesla has revealed that its biggest in-house AI supercomputer – which we wrote about last year – now has a total of 7,360 A100 GPUs, a nearly 28 percent uplift from its previous total of 5,760 GPUs. That’s enough GPU oomph for a top seven spot on the Top500, although the tech company best known for its electric vehicles has not publicly benchmarked the system. If it had, it would... Read more…

JPMorgan Chase Bets Big on Quantum Computing

October 12, 2022

Most talk about quantum computing today, at least in HPC circles, focuses on advancing technology and the hurdles that remain. There are plenty of the latter. F Read more…

Using Exascale Supercomputers to Make Clean Fusion Energy Possible

September 2, 2022

Fusion, the nuclear reaction that powers the Sun and the stars, has incredible potential as a source of safe, carbon-free and essentially limitless energy. But Read more…

Leading Solution Providers

Contributors

UCIe Consortium Incorporates, Nvidia and Alibaba Round Out Board

August 2, 2022

The Universal Chiplet Interconnect Express (UCIe) consortium is moving ahead with its effort to standardize a universal interconnect at the package level. The c Read more…

Nvidia, Qualcomm Shine in MLPerf Inference; Intel’s Sapphire Rapids Makes an Appearance.

September 8, 2022

The steady maturation of MLCommons/MLPerf as an AI benchmarking tool was apparent in today’s release of MLPerf v2.1 Inference results. Twenty-one organization Read more…

SC22 Unveils ACM Gordon Bell Prize Finalists

August 12, 2022

Courtesy of the schedule for the SC22 conference, we now have our first glimpse at the finalists for this year’s coveted Gordon Bell Prize. The Gordon Bell Pr Read more…

Not Just Cash for Chips – The New Chips and Science Act Boosts NSF, DOE, NIST

August 3, 2022

After two-plus years of contentious debate, several different names, and final passage by the House (243-187) and Senate (64-33) last week, the Chips and Science Act will soon become law. Besides the $54.2 billion provided to boost US-based chip manufacturing, the act reshapes US science policy in meaningful ways. NSF’s proposed budget... Read more…

Intel Is Opening up Its Chip Factories to Academia

October 6, 2022

Intel is opening up its fabs for academic institutions so researchers can get their hands on physical versions of its chips, with the end goal of boosting semic Read more…

AMD’s Genoa CPUs Offer Up to 96 5nm Cores Across 12 Chiplets

November 10, 2022

AMD’s fourth-generation Epyc processor line has arrived, starting with the “general-purpose” architecture, called “Genoa,” the successor to third-gen Eypc Milan, which debuted in March of last year. At a launch event held today in San Francisco, AMD announced the general availability of the latest Epyc CPUs with up to 96 TSMC 5nm Zen 4 cores... Read more…

AMD Previews 400 Gig Adaptive SmartNIC SOC at Hot Chips

August 24, 2022

Fresh from finalizing its acquisitions of FPGA provider Xilinx (Feb. 2022) and DPU provider Pensando (May 2022) ), AMD previewed what it calls a 400 Gig Adaptive smartNIC SOC yesterday at Hot Chips. It is another contender in the increasingly crowded and blurry smartNIC/DPU space where distinguishing between the two isn’t always easy. The motivation for these device types... Read more…

Google Program to Free Chips Boosts University Semiconductor Design

August 11, 2022

A Google-led program to design and manufacture chips for free is becoming popular among researchers and computer enthusiasts. The search giant's open silicon program is providing the tools for anyone to design chips, which then get manufactured. Google foots the entire bill, from a chip's conception to delivery of the final product in a user's hand. Google's... Read more…

  • arrow
  • Click Here for More Headlines
  • arrow
HPCwire