Go Parallel
Parallelism As a First Class Citizen in C and C++

We need mechanisms for parallelism that have strong space-time guarantees, simple program understanding, and serialization semantics — all things we do not have in C and C++ today

By James Reinders
August 16, 2011
URL : http://www.drdobbs.com/cpp/parallelism-as-a-first-class-citizen-in/231500025

It is time to make Parallelism a full First Class Citizen in C and C++. Hardware is once again ahead of software, and we need to close the gap so that application development is better able to utilize the hardware without low level programming.

The time has come for high level constructs for task and data parallelism to be explicitly added to C and C++. This will enable Parallel Programming in C and C++ to be fully portable, easily intelligible, and consistently decipherable by a compiler.

Language solutions are superior to library solutions. Library solutions provide fertile grounds for exploration. Intel Threading Building Blocks (TBB) has been the most popular library solution for parallelism for C++. For more than five years, TBB has grown and proven itself. It is time to take it to the next level, and move to language solutions to support what we can be confident is needed in C and C++.

We need mechanisms for parallelism that have strong space-time guarantees, simple program understanding, and serialization semantics — all things we do not have in C and C++ today.

We should tackle task and data parallelism both, and as an industry we know how.

The solutions that show the most promise are documented in the Cilk Plus open specification. They are as follows:

For data parallelism:

For task parallelism:

Like other popular programming languages, neither C nor C++ was designed as parallel programming languages. Parallelism is always hidden from a compiler and needs "discovery." Compilers are not good at "complex discovery" — they are much better at optimizing and packaging up things that are explicit. Explicit constructs for parallelism solve this and make compiler support more likely. The constructs do not need to be numerous, just enough for other constructs to build upon…fewer is better!

For something as involved, or complex, as parallelism, incorporating parallelism semantics into the programming language improves both the expressability of the language, as well as the efficiency by which the compiler can implement parallelism.

Years of investigation and experimentation have had some great results. Compiler writers have found they can offer substantial benefits for ease of programming, performance, debugging and portability. These have appeared in a variety of papers and talks over the years, and could be the topic of future blogs.

Top of mind thoughts are:

None of this is radical — and none of it need be proprietary.

If we don't get carried away adding other stuff, KISS, we can add these and make a fundamental and important advance for task and data parallelism in C and C++…the languages that lead the evolution to parallelism, and are becoming more (not less) important in the future.

Copyright © 2012 UBM Techweb