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!

Q&A with Nvidia’s Chief of DGX Systems on the DGX-GB200 Rack-scale System

March 27, 2024

Pictures of Nvidia's new flagship mega-server, the DGX GB200, on the GTC show floor got favorable reactions on social media for the sheer amount of computing power it brings to artificial intelligence.  Nvidia's DGX Read more…

Call for Participation in Workshop on Potential NSF CISE Quantum Initiative

March 26, 2024

Editor’s Note: Next month there will be a workshop to discuss what a quantum initiative led by NSF’s Computer, Information Science and Engineering (CISE) directorate could entail. The details are posted below in a Ca Read more…

Waseda U. Researchers Reports New Quantum Algorithm for Speeding Optimization

March 25, 2024

Optimization problems cover a wide range of applications and are often cited as good candidates for quantum computing. However, the execution time for constrained combinatorial optimization applications on quantum device Read more…

NVLink: Faster Interconnects and Switches to Help Relieve Data Bottlenecks

March 25, 2024

Nvidia’s new Blackwell architecture may have stolen the show this week at the GPU Technology Conference in San Jose, California. But an emerging bottleneck at the network layer threatens to make bigger and brawnier pro Read more…

Who is David Blackwell?

March 22, 2024

During GTC24, co-founder and president of NVIDIA Jensen Huang unveiled the Blackwell GPU. This GPU itself is heavily optimized for AI work, boasting 192GB of HBM3E memory as well as the the ability to train 1 trillion pa Read more…

Nvidia Appoints Andy Grant as EMEA Director of Supercomputing, Higher Education, and AI

March 22, 2024

Nvidia recently appointed Andy Grant as Director, Supercomputing, Higher Education, and AI for Europe, the Middle East, and Africa (EMEA). With over 25 years of high-performance computing (HPC) experience, Grant brings a Read more…

Q&A with Nvidia’s Chief of DGX Systems on the DGX-GB200 Rack-scale System

March 27, 2024

Pictures of Nvidia's new flagship mega-server, the DGX GB200, on the GTC show floor got favorable reactions on social media for the sheer amount of computing po Read more…

NVLink: Faster Interconnects and Switches to Help Relieve Data Bottlenecks

March 25, 2024

Nvidia’s new Blackwell architecture may have stolen the show this week at the GPU Technology Conference in San Jose, California. But an emerging bottleneck at Read more…

Who is David Blackwell?

March 22, 2024

During GTC24, co-founder and president of NVIDIA Jensen Huang unveiled the Blackwell GPU. This GPU itself is heavily optimized for AI work, boasting 192GB of HB Read more…

Nvidia Looks to Accelerate GenAI Adoption with NIM

March 19, 2024

Today at the GPU Technology Conference, Nvidia launched a new offering aimed at helping customers quickly deploy their generative AI applications in a secure, s Read more…

The Generative AI Future Is Now, Nvidia’s Huang Says

March 19, 2024

We are in the early days of a transformative shift in how business gets done thanks to the advent of generative AI, according to Nvidia CEO and cofounder Jensen 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…

Nvidia Showcases Quantum Cloud, Expanding Quantum Portfolio at GTC24

March 18, 2024

Nvidia’s barrage of quantum news at GTC24 this week includes new products, signature collaborations, and a new Nvidia Quantum Cloud for quantum developers. Wh Read more…

Houston We Have a Solution: Addressing the HPC and Tech Talent Gap

March 15, 2024

Generations of Houstonian teachers, counselors, and parents have either worked in the aerospace industry or know people who do - the prospect of entering the fi Read more…

Alibaba Shuts Down its Quantum Computing Effort

November 30, 2023

In case you missed it, China’s e-commerce giant Alibaba has shut down its quantum computing research effort. It’s not entirely clear what drove the change. 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…

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…

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…

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…

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…

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…

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…

Leading Solution Providers

Contributors

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…

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…

Google Introduces ‘Hypercomputer’ to Its AI Infrastructure

December 11, 2023

Google ran out of monikers to describe its new AI system released on December 7. Supercomputer perhaps wasn't an apt description, so it settled on Hypercomputer 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…

Intel Won’t Have a Xeon Max Chip with New Emerald Rapids CPU

December 14, 2023

As expected, Intel officially announced its 5th generation Xeon server chips codenamed Emerald Rapids at an event in New York City, where the focus was really o Read more…

IBM Quantum Summit: Two New QPUs, Upgraded Qiskit, 10-year Roadmap and More

December 4, 2023

IBM kicks off its annual Quantum Summit today and will announce a broad range of advances including its much-anticipated 1121-qubit Condor QPU, a smaller 133-qu Read more…

  • arrow
  • Click Here for More Headlines
  • arrow
HPCwire