Compilers and More: OpenCL Promises and Potential

By Michael Wolfe

September 10, 2009

OpenCL was introduced with great fanfare and promise. Apple has served a key role, perhaps the key role, in pushing OpenCL to ratification and public release. In fact, Apple has apparently filed for trademark protection on OpenCL technology, presumably (or hopefully) to prevent anyone else from claiming prior art and thereby preventing Apple from using it themselves. The development of OpenCL included dozens of industrial and institutional partners, including AMD, ARM, IBM, Intel, NVIDIA, and Texas Instruments.

The excitement is intensified by a quote from Steve Jobs saying, “It’s way beyond what NVIDIA or anyone else has, and it’s really simple,” (more on this later), and the first line on the Khronos OpenCL page: “OpenCL is the first open, royalty-free standard for cross-platform, parallel programming of modern processors found in personal computers, servers and handheld/embedded devices.” That last comment leaves me rankled, since I’m personally deeply involved in OpenMP, another open, royalty-free standard for parallel programming of modern processors; perhaps there are enough adjectival phrases in the OpenCL statement to distinguish it. At the SC08 OpenCL Technical Briefing, Tim Mattson from Intel, who is also deeply involved in OpenMP language development, gushed about how we now finally have a portable parallel programming model, and predicted that half the people in the room would be using OpenCL by the next SC conference. I guess we’ll see in just a couple of months.

So, given all the hype, what can we expect from OpenCL? Is it really simple? Is it portable? Will it replace other parallel programming models? It’s still a little early; we’ve seen a multicore demonstration of OpenCL from AMD, a limited developer release from NVIDIA, and Apple is planning to release its next generation operating system in September, including OpenCL support. Yet we can prognosticate, given what we know about the language and related technologies.

Is it simple?

Simple is a loaded term. One can claim anything is simple if it’s simpler than something else that’s even more complex. But I’ve said before that parallel programming is hard, and is going to remain so. Perhaps that’s overstating the case: we can probably make it easy to write parallel programs that perform badly, but I’m assuming that isn’t the intent and is obviously unacceptable.

So, is there a metric by which we can claim that OpenCL is simple? I’m going to give a qualified no. In OpenCL, you have a host and one or more compute devices; you have a host program that launches kernels; you have task parallelism and data parallelism, work-items and work-groups; you have contexts and command queues; you have global memory, local memory, and private memory, not to mention constant memory, with different consistency models across the memory types; you have buffer objects, image objects, and sampler objects; and you have language restrictions and language extensions. It’s not simple.

Over fifty years of programming language development has led us to expect certain features in our programming environment, such as simple access to modular programming (procedures, argument passing, linkers), which are not so well represented in OpenCL. There’s no linker for GPU kernels in OpenCL; you must include library calls to build a device program and extract a handle to the kernel function. There’s no direct function call to the kernel; you must set up the arguments one at a time with a series of library calls. The OpenCL strategy was to not perturb the host programming language with additional keywords or syntax, but to encapsulate additional functionality in a host-side library. You can expect any number of OpenCL preprocessors to convert a higher-level representation (a la NVIDIA’s CUDA) to the lower-level OpenCL. If I haven’t convinced you that OpenCL isn’t simple, look at an OpenCL example program, in this case to compute the sum of a vector of numbers (provided by Apple).

So, what’s my qualification? If you had looked at the hoops programmers had to jump through to program GPUs for general purpose computing before OpenCL and CUDA, you’d agree that these languages are a very large step in the right direction. Much simpler, though not really simple.

Is it portable?

Again, we should define our metric. We’ve grown accustomed to being able to write programs that will run across a wide variety of target systems with almost no modifications. Compiled languages (Fortran, C, C++) will require a recompile for a new processor or operating system, and may need changes for system calls. Just-in-time platforms (for Java, C#) and interpreted languages (Perl, Python) don’t even need that.

However, in the HPC world we want more than the program to just work; we want it to deliver high performance. The gold standard in this regard has been vectorizing compilers. When the Cray-1 was delivered in 1976, the primary method to access the vector instructions was to use the vectorizing Fortran compiler, CFT (Cray Fortran Translator). The compiler generated a vectorization listing telling the user what loops were or were not vectorized; if there were vector hazards (data dependences) or other limitations (IO statements, procedure calls, conditionals), the listing would call them out. Programmers learned to read the listing and, if the loop were critical to performance, rewrite the loop so it would vectorize. They were rewarded with vector performance on that application, and they learned how to write code that would vectorize for their next project. Moreover, and this is the key, those programs would also vectorize on subsequent generations of vector machines from Fujitsu, NEC, IBM, Convex, Alliant, Hitachi, and others. Those vector programs were not just portable, they were performance portable.

Side note: We use exactly the same compiler technology for today’s packed instruction set extensions, like SSE on X64 and Altivec on IBM Power. And enjoy the same performance portability benefits as well.

So, are OpenCL programs going to be performance portable or not? Sadly, not. An OpenCL kernel is a low-level representation of the work to be done on the accelerator or GPU itself. To optimize the performance, you must know and take advantage of device-specific information such as the optimal number of work-items in a work-group, the amount of local memory and perhaps the number of banks, and trade-offs between parallelism and efficiency. An optimized kernel for one device may or may not perform well on another, but is unlikely to be optimal for that second device. This is not a condemnation of OpenCL, or even a failure of the language. It was intended and designed to be a low-level, high-performance, close-to-the-metal, efficient programming interface, borrowing phrases. The intent is apparently that OpenCL will support an ecosystem of tools, middleware and applications, not to be the portable parallel abstraction. Even though the kernels are not performance portable, even if you have to tune your kernels for each device, the ability to write your kernels for different devices in the same language is a great leap forward from where we are today.

Will it replace or supersede other parallel programming models?

What other models might it replace? The dominant parallel programming models are MPI for cluster programming and OpenMP for shared memory programming. Many others exist: Java threads, TBB, Map/Reduce, Unified Parallel C, Cilk, and many more, but let’s stick with the classics.

MPI programming targets a network of homogeneous or heterogeneous nodes running in MIMD mode, each communicating and synchronizing with other nodes, one-to-one or collectively. The node program is a complete scalar program; from the language perspective, it just happens to use a library that happens to communicate through I/O channels with other copies of itself that just happen to be running at the same time. OpenMP programming targets a homogeneous shared-memory multiprocessor running in MIMD mode, with a master thread that controls when the other threads running on other processors start to cooperate to help with parallel work. Unlike an MPI node program, the OpenMP program is a global program; it describes all the work to be done, with directives telling the compiler which parts to run on the master thread, which parts to run redundantly on all threads, and (most importantly) which parts to split up among the worker threads.

OpenCL kernel routines are like MPI node programs; they describe the work to be done by one thread. The OpenCL host program is like the OpenMP master thread; it controls the execution of the kernels and the parallel threads. OpenCL uses shared memory in the compute devices, like OpenMP, but has a weaker consistency model and weaker synchronization semantics. The requirement to break up the parallel part of the program into kernels, with a single host thread acting as master, and the shared memory among the compute devices, makes OpenCL an unlikely candidate to replace MPI on large network supercomputers. The separate host and compute device memory, very limited synchronization, and non-incremental nature make it unlikely to replace OpenMP as the preferred method to program multicore or other shared memory multiprocessors.

Will OpenCL replace CUDA?

This is a more interesting question. The OpenCL JumpStart Guide from NVIDIA points out that CUDA has two library API layers. There is a Runtime API, which includes some language syntax extensions, and which automates some of the handshaking between the host thread and the compute device. There is also a lower level, Driver API, which requires the programmer to manage all the interaction between the host and the device. OpenCL is quite similar in many respects to CUDA using the Driver API, and the above mentioned JumpStart Guide gives the correspondence between the two.

Will NVIDIA adopt OpenCL in place of CUDA? That would be silly; NVIDIA already has a large contingent of CUDA users, and CUDA C does include the higher level, easier-to-use Runtime API. NVIDIA has had a two-year head start in the GPU/Accelerator programming game. While OpenCL has the potential to level the playing field somewhat, the CUDA Runtime API gives NVIDIA a slight edge in programmability, so NVIDIA will not likely abandon it.

Does OpenCL have any value at all?

We certainly hope so, given how much effort has gone into its definition and various implementations from AMD, Apple, NVIDIA, and certainly others. Today, if you have the right kind of parallelism in your application, and you’re willing to expend the effort to recast your program in CUDA kernels and write the host program interface, you can see some dramatic performance improvements. Replacing CUDA with OpenCL may allow you to port your program from an NVIDIA device to an ATI GPU or Intel Larrabee with only an incremental effort. So, yes, there is definite value here. The question remaining to be answered is how much value, and how long will it continue to be valuable. I can’t answer that, and I don’t want to raise the FUD (fear, uncertainty, doubt) factor. If Intel’s Larrabee and other similar devices, which support a richer programming model, replace GPUs as the dominant compute accelerator, OpenCL may join the dead language heap, along with Thinking Machine’s C*, MasPar’s MPL, and ClearSpeed’s Cn. However, if GPUs and other accelerators can continue to use the OpenCL programming model efficiently, and deliver high performance at relatively low cost, then OpenCL can enjoy a long, useful life. My opinion: it’s likely to be more useful as a target language for higher level programming languages, tools, and environments, or as a language to implement optimized libraries, than as a language for a more general programming community.

So let’s accept and even celebrate OpenCL for what it is, and not try to make it what it can’t be. There’s danger is raising expectations too high, or claiming too much (a la Bernie Madoff); OpenCL can be influential and succeed without replacing other parallel languages. To correct Steve Job’s quote: “While OpenCL is very similar in many respects to NVIDIA’s CUDA, it adds features to take advantage of other targets; and though it’s quite complex, it has the potential to deliver very high performance, and is much easier than trying to map your computation into OpenGL or graphics primitives.” Hype I can agree with; but then, I’m not the Apple CEO.


Michael Wolfe has developed compilers for over 30 years in both academia and industry, and is now a senior compiler engineer at The Portland Group, Inc. (, a wholly-owned subsidiary of STMicroelectronics, Inc. The opinions stated here are those of the author, and do not represent opinions of The Portland Group, Inc. or STMicroelectronics, Inc.

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!

RSC Reports 500Tflops, Hot Water Cooled System Deployed at JINR

April 18, 2018

RSC, developer of supercomputers and advanced HPC systems based in Russia, today reported deployment of “the world's first 100% ‘hot water’ liquid cooled supercomputer” at Joint Institute for Nuclear Research (JI Read more…

By Staff

New Device Spots Quantum Particle ‘Fingerprint’

April 18, 2018

Majorana particles have been observed by university researchers employing a device consisting of layers of magnetic insulators on a superconducting material. The advance opens the door to controlling the elusive particle Read more…

By George Leopold

Cray Rolls Out AMD-Based CS500; More to Follow?

April 18, 2018

Cray was the latest OEM to bring AMD back into the fold with introduction today of a CS500 option based on AMD’s Epyc processor line. The move follows Cray’s introduction of an ARM-based system (XC-50) last November. Read more…

By John Russell

HPE Extreme Performance Solutions

Hybrid HPC is Speeding Time to Insight and Revolutionizing Medicine

High performance computing (HPC) is a key driver of success in many verticals today, and health and life science industries are extensively leveraging these capabilities. Read more…

Hennessy & Patterson: A New Golden Age for Computer Architecture

April 17, 2018

On Monday June 4, 2018, 2017 A.M. Turing Award Winners John L. Hennessy and David A. Patterson will deliver the Turing Lecture at the 45th International Symposium on Computer Architecture (ISCA) in Los Angeles. The Read more…

By Staff

Cray Rolls Out AMD-Based CS500; More to Follow?

April 18, 2018

Cray was the latest OEM to bring AMD back into the fold with introduction today of a CS500 option based on AMD’s Epyc processor line. The move follows Cray’ Read more…

By John Russell

IBM: Software Ecosystem for OpenPOWER is Ready for Prime Time

April 16, 2018

With key pieces of the IBM/OpenPOWER versus Intel/x86 gambit settling into place – e.g., the arrival of Power9 chips and Power9-based systems, hyperscaler sup Read more…

By John Russell

US Plans $1.8 Billion Spend on DOE Exascale Supercomputing

April 11, 2018

On Monday, the United States Department of Energy announced its intention to procure up to three exascale supercomputers at a cost of up to $1.8 billion with th Read more…

By Tiffany Trader

Cloud-Readiness and Looking Beyond Application Scaling

April 11, 2018

There are two aspects to consider when determining if an application is suitable for running in the cloud. The first, which we will discuss here under the title Read more…

By Chris Downing

Transitioning from Big Data to Discovery: Data Management as a Keystone Analytics Strategy

April 9, 2018

The past 10-15 years has seen a stark rise in the density, size, and diversity of scientific data being generated in every scientific discipline in the world. Key among the sciences has been the explosion of laboratory technologies that generate large amounts of data in life-sciences and healthcare research. Large amounts of data are now being stored in very large storage name spaces, with little to no organization and a general unease about how to approach analyzing it. Read more…

By Ari Berman, BioTeam, Inc.

IBM Expands Quantum Computing Network

April 5, 2018

IBM is positioning itself as a first mover in establishing the era of commercial quantum computing. The company believes in order for quantum to work, taming qu Read more…

By Tiffany Trader

FY18 Budget & CORAL-2 – Exascale USA Continues to Move Ahead

April 2, 2018

It was not pretty. However, despite some twists and turns, the federal government’s Fiscal Year 2018 (FY18) budget is complete and ended with some very positi Read more…

By Alex R. Larzelere

Nvidia Ups Hardware Game with 16-GPU DGX-2 Server and 18-Port NVSwitch

March 27, 2018

Nvidia unveiled a raft of new products from its annual technology conference in San Jose today, and despite not offering up a new chip architecture, there were still a few surprises in store for HPC hardware aficionados. Read more…

By Tiffany Trader

Inventor Claims to Have Solved Floating Point Error Problem

January 17, 2018

"The decades-old floating point error problem has been solved," proclaims a press release from inventor Alan Jorgensen. The computer scientist has filed for and Read more…

By Tiffany Trader

Researchers Measure Impact of ‘Meltdown’ and ‘Spectre’ Patches on HPC Workloads

January 17, 2018

Computer scientists from the Center for Computational Research, State University of New York (SUNY), University at Buffalo have examined the effect of Meltdown Read more…

By Tiffany Trader

Russian Nuclear Engineers Caught Cryptomining on Lab Supercomputer

February 12, 2018

Nuclear scientists working at the All-Russian Research Institute of Experimental Physics (RFNC-VNIIEF) have been arrested for using lab supercomputing resources to mine crypto-currency, according to a report in Russia’s Interfax News Agency. Read more…

By Tiffany Trader

How the Cloud Is Falling Short for HPC

March 15, 2018

The last couple of years have seen cloud computing gradually build some legitimacy within the HPC world, but still the HPC industry lies far behind enterprise I Read more…

By Chris Downing

Chip Flaws ‘Meltdown’ and ‘Spectre’ Loom Large

January 4, 2018

The HPC and wider tech community have been abuzz this week over the discovery of critical design flaws that impact virtually all contemporary microprocessors. T Read more…

By Tiffany Trader

Fast Forward: Five HPC Predictions for 2018

December 21, 2017

What’s on your list of high (and low) lights for 2017? Volta 100’s arrival on the heels of the P100? Appearance, albeit late in the year, of IBM’s Power9? Read more…

By John Russell

How Meltdown and Spectre Patches Will Affect HPC Workloads

January 10, 2018

There have been claims that the fixes for the Meltdown and Spectre security vulnerabilities, named the KPTI (aka KAISER) patches, are going to affect applicatio Read more…

By Rosemary Francis

Nvidia Responds to Google TPU Benchmarking

April 10, 2017

Nvidia highlights strengths of its newest GPU silicon in response to Google's report on the performance and energy advantages of its custom tensor processor. Read more…

By Tiffany Trader

Leading Solution Providers

Deep Learning at 15 PFlops Enables Training for Extreme Weather Identification at Scale

March 19, 2018

Petaflop per second deep learning training performance on the NERSC (National Energy Research Scientific Computing Center) Cori supercomputer has given climate Read more…

By Rob Farber

Lenovo Unveils Warm Water Cooled ThinkSystem SD650 in Rampup to LRZ Install

February 22, 2018

This week Lenovo took the wraps off the ThinkSystem SD650 high-density server with third-generation direct water cooling technology developed in tandem with par Read more…

By Tiffany Trader

AI Cloud Competition Heats Up: Google’s TPUs, Amazon Building AI Chip

February 12, 2018

Competition in the white hot AI (and public cloud) market pits Google against Amazon this week, with Google offering AI hardware on its cloud platform intended Read more…

By Doug Black

HPC and AI – Two Communities Same Future

January 25, 2018

According to Al Gara (Intel Fellow, Data Center Group), high performance computing and artificial intelligence will increasingly intertwine as we transition to Read more…

By Rob Farber

New Blueprint for Converging HPC, Big Data

January 18, 2018

After five annual workshops on Big Data and Extreme-Scale Computing (BDEC), a group of international HPC heavyweights including Jack Dongarra (University of Te Read more…

By John Russell

US Plans $1.8 Billion Spend on DOE Exascale Supercomputing

April 11, 2018

On Monday, the United States Department of Energy announced its intention to procure up to three exascale supercomputers at a cost of up to $1.8 billion with th Read more…

By Tiffany Trader

Momentum Builds for US Exascale

January 9, 2018

2018 looks to be a great year for the U.S. exascale program. The last several months of 2017 revealed a number of important developments that help put the U.S. Read more…

By Alex R. Larzelere

Google Chases Quantum Supremacy with 72-Qubit Processor

March 7, 2018

Google pulled ahead of the pack this week in the race toward "quantum supremacy," with the introduction of a new 72-qubit quantum processor called Bristlecone. Read more…

By Tiffany Trader

  • arrow
  • Click Here for More Headlines
  • arrow
Share This