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. (www.pgroup.com), 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 industry updates delivered to you every week!

Kathy Yelick on Post-Exascale Challenges

April 18, 2024

With the exascale era underway, the HPC community is already turning its attention to zettascale computing, the next of the 1,000-fold performance leaps that have occurred about once a decade. With this in mind, the ISC Read more…

2024 Winter Classic: Texas Two Step

April 18, 2024

Texas Tech University. Their middle name is ‘tech’, so it’s no surprise that they’ve been fielding not one, but two teams in the last three Winter Classic cluster competitions. Their teams, dubbed Matador and Red Read more…

2024 Winter Classic: The Return of Team Fayetteville

April 18, 2024

Hailing from Fayetteville, NC, Fayetteville State University stayed under the radar in their first Winter Classic competition in 2022. Solid students for sure, but not a lot of HPC experience. All good. They didn’t Read more…

Software Specialist Horizon Quantum to Build First-of-a-Kind Hardware Testbed

April 18, 2024

Horizon Quantum Computing, a Singapore-based quantum software start-up, announced today it would build its own testbed of quantum computers, starting with use of Rigetti’s Novera 9-qubit QPU. The approach by a quantum Read more…

2024 Winter Classic: Meet Team Morehouse

April 17, 2024

Morehouse College? The university is well-known for their long list of illustrious graduates, the rigor of their academics, and the quality of the instruction. They were one of the first schools to sign up for the Winter Read more…

MLCommons Launches New AI Safety Benchmark Initiative

April 16, 2024

MLCommons, organizer of the popular MLPerf benchmarking exercises (training and inference), is starting a new effort to benchmark AI Safety, one of the most pressing needs and hurdles to widespread AI adoption. The sudde Read more…

Kathy Yelick on Post-Exascale Challenges

April 18, 2024

With the exascale era underway, the HPC community is already turning its attention to zettascale computing, the next of the 1,000-fold performance leaps that ha Read more…

Software Specialist Horizon Quantum to Build First-of-a-Kind Hardware Testbed

April 18, 2024

Horizon Quantum Computing, a Singapore-based quantum software start-up, announced today it would build its own testbed of quantum computers, starting with use o Read more…

MLCommons Launches New AI Safety Benchmark Initiative

April 16, 2024

MLCommons, organizer of the popular MLPerf benchmarking exercises (training and inference), is starting a new effort to benchmark AI Safety, one of the most pre Read more…

Exciting Updates From Stanford HAI’s Seventh Annual AI Index Report

April 15, 2024

As the AI revolution marches on, it is vital to continually reassess how this technology is reshaping our world. To that end, researchers at Stanford’s Instit Read more…

Intel’s Vision Advantage: Chips Are Available Off-the-Shelf

April 11, 2024

The chip market is facing a crisis: chip development is now concentrated in the hands of the few. A confluence of events this week reminded us how few chips Read more…

The VC View: Quantonation’s Deep Dive into Funding Quantum Start-ups

April 11, 2024

Yesterday Quantonation — which promotes itself as a one-of-a-kind venture capital (VC) company specializing in quantum science and deep physics  — announce Read more…

Nvidia’s GTC Is the New Intel IDF

April 9, 2024

After many years, Nvidia's GPU Technology Conference (GTC) was back in person and has become the conference for those who care about semiconductors and AI. I Read more…

Google Announces Homegrown ARM-based CPUs 

April 9, 2024

Google sprang a surprise at the ongoing Google Next Cloud conference by introducing its own ARM-based CPU called Axion, which will be offered to customers in it Read more…

Nvidia H100: Are 550,000 GPUs Enough for This Year?

August 17, 2023

The GPU Squeeze continues to place a premium on Nvidia H100 GPUs. In a recent Financial Times article, Nvidia reports that it expects to ship 550,000 of its lat Read more…

Synopsys Eats Ansys: Does HPC Get Indigestion?

February 8, 2024

Recently, it was announced that Synopsys is buying HPC tool developer Ansys. Started in Pittsburgh, Pa., in 1970 as Swanson Analysis Systems, Inc. (SASI) by John Swanson (and eventually renamed), Ansys serves the CAE (Computer Aided Engineering)/multiphysics engineering simulation market. Read more…

Intel’s Server and PC Chip Development Will Blur After 2025

January 15, 2024

Intel's dealing with much more than chip rivals breathing down its neck; it is simultaneously integrating a bevy of new technologies such as chiplets, artificia Read more…

Choosing the Right GPU for LLM Inference and Training

December 11, 2023

Accelerating the training and inference processes of deep learning models is crucial for unleashing their true potential and NVIDIA GPUs have emerged as a game- Read more…

Baidu Exits Quantum, Closely Following Alibaba’s Earlier Move

January 5, 2024

Reuters reported this week that Baidu, China’s giant e-commerce and services provider, is exiting the quantum computing development arena. Reuters reported � Read more…

Comparing NVIDIA A100 and NVIDIA L40S: Which GPU is Ideal for AI and Graphics-Intensive Workloads?

October 30, 2023

With long lead times for the NVIDIA H100 and A100 GPUs, many organizations are looking at the new NVIDIA L40S GPU, which it’s a new GPU optimized for AI and g Read more…

Shutterstock 1179408610

Google Addresses the Mysteries of Its Hypercomputer 

December 28, 2023

When Google launched its Hypercomputer earlier this month (December 2023), the first reaction was, "Say what?" It turns out that the Hypercomputer is Google's t Read more…

AMD MI3000A

How AMD May Get Across the CUDA Moat

October 5, 2023

When discussing GenAI, the term "GPU" almost always enters the conversation and the topic often moves toward performance and access. Interestingly, the word "GPU" is assumed to mean "Nvidia" products. (As an aside, the popular Nvidia hardware used in GenAI are not technically... Read more…

Leading Solution Providers

Contributors

Shutterstock 1606064203

Meta’s Zuckerberg Puts Its AI Future in the Hands of 600,000 GPUs

January 25, 2024

In under two minutes, Meta's CEO, Mark Zuckerberg, laid out the company's AI plans, which included a plan to build an artificial intelligence system with the eq Read more…

DoD Takes a Long View of Quantum Computing

December 19, 2023

Given the large sums tied to expensive weapon systems – think $100-million-plus per F-35 fighter – it’s easy to forget the U.S. Department of Defense is a Read more…

China Is All In on a RISC-V Future

January 8, 2024

The state of RISC-V in China was discussed in a recent report released by the Jamestown Foundation, a Washington, D.C.-based think tank. The report, entitled "E Read more…

Shutterstock 1285747942

AMD’s Horsepower-packed MI300X GPU Beats Nvidia’s Upcoming H200

December 7, 2023

AMD and Nvidia are locked in an AI performance battle – much like the gaming GPU performance clash the companies have waged for decades. AMD has claimed it Read more…

Nvidia’s New Blackwell GPU Can Train AI Models with Trillions of Parameters

March 18, 2024

Nvidia's latest and fastest GPU, codenamed Blackwell, is here and will underpin the company's AI plans this year. The chip offers performance improvements from Read more…

Eyes on the Quantum Prize – D-Wave Says its Time is Now

January 30, 2024

Early quantum computing pioneer D-Wave again asserted – that at least for D-Wave – the commercial quantum era has begun. Speaking at its first in-person Ana Read more…

GenAI Having Major Impact on Data Culture, Survey Says

February 21, 2024

While 2023 was the year of GenAI, the adoption rates for GenAI did not match expectations. Most organizations are continuing to invest in GenAI but are yet to Read more…

The GenAI Datacenter Squeeze Is Here

February 1, 2024

The immediate effect of the GenAI GPU Squeeze was to reduce availability, either direct purchase or cloud access, increase cost, and push demand through the roof. A secondary issue has been developing over the last several years. Even though your organization secured several racks... Read more…

  • arrow
  • Click Here for More Headlines
  • arrow
HPCwire