Solving Heterogeneous Programming Challenges with SYCL

By James Reinders

December 8, 2021

In the first of a series of guest posts on heterogenous computing, James Reinders, who returned to Intel last year after a short “retirement,” considers how SYCL will contribute to a heterogeneous future for C++. Reinders digs into SYCL from multiple angles and offers suggestions and tips on how to learn more.


SYCL is a Khronos standard that brings support for fully heterogeneous data parallelism to C++. That is much easier to say than it is to grasp why it is so important. SYCL is not a cure-all; SYCL is a solution to one aspect of a larger problem: how do we enable programming in the face of an explosion of hardware diversity that is coming?

Programming in the face of a Cambrian Explosion

John Hennessy and David Patterson described why we are entering “A New Golden Age for Computer Architecture.” They sum up their expectations saying “The next decade will see a Cambrian explosion of novel computer architectures, meaning exciting times for computer architects in academia and in industry.”

CPUs, GPUs, FPGAs, AI chips, ASICs, DSPs, and other innovations will vie for our attention to deliver performance for our applications. Add in the growing ability to integrate multiple dies into single packages in ways we’ve never seen before, and the combined opportunity to accelerate computing through more diversity is extraordinary.

The profound implication for programming is that we need simple solutions to support all hardware. This would never happen in a world of proprietary standards and technologies that ultimately always seek to advantage their creators.

For decades, we have written code focused on performance from a single type of device in the system, and our tools only needed to excel at delivering performance from that single device type.

As hardware diversity explodes (xPU simply means any computational unit from any vendor with any architecture), we can expect that a single application could use multiple device types for computation. This breaks our prior ability to rely on toolchains and languages that have a focused goal to exploit only a single type, or brand, of device.

In the future, we will increasingly need to be critical of tools and languages if they cannot expose the best capabilities of every part of a fully heterogeneous system. We need to demand support for open, multivendor, and multiarchitecture as a base expectation. Put another way, using our xPU term (any computational unit from any vendor with any architecture), we need to expect support for xPUs to be the norm for tools, libraries, compilers, frameworks, and anything else we rely upon as software developers.


“SYCL is not a cure-all; SYCL is a solution to one aspect of a larger problem: how do we enable programming in the face of an explosion of hardware diversity that is coming?”


How SYCL helps for a Cambrian Explosion

When we ask the question “how do we program a truly heterogeneous machine?”, we quickly see we need two things: (1) a way to learn at runtime about all the devices that are available to our application, and (2) a way to utilize the devices to help perform work for our application.

SYCL is a built upon modern C++ to solve exactly these two challenges for heterogeneous machines via two fundamental SYCL capabilities: queue and queue.submit.

SYCL queue

When a SYCL queue is constructed, it creates a connection to a single device. Our options for device selection are (a) accept a default that the runtime picks for us, (b) ask for a certain class of devices (like a GPU, or a CPU, or an FPGA), (c) supply even more hints (e.g., a device supporting device allocations of universal shared memory and FP16), or (d) take full control, examine all devices available, and score them using any system we choose to program.

// use the default selector

queue q1{}; // default_selector

queue q2{default_selector()};

// use a CPU

queue q3{cpu_selector()};

// use a GPU

queue q4{gpu_selector()};

// be a little more prescriptive

queue q6{aspect_selector(std::vector{aspect::fp16, aspect::usm_device_allocations})};

// use complex selection described in a function we write

queue q5{my_custom_selector(a, b, c)};

Constructing a SYCL queue to connect us to a device can be done to whatever level of precision we desire.

SYCL queue.submit

Once we have a queue, we can submit work to it. We refer to these as ‘kernels’ (of code). The order in which work is performed is left to the runtime provided it does not violate any known dependencies (e.g., data needs to be created before it is consumed). We do have an option to ask for an in-order queue if that programming style suits our needs better.

// I promised a queue.submit… here it is…

q.submit([&](handler &h) {

h.parallel_for(num_items,

[=](auto i) { sum[i] = a[i] + b[i]; }

);

});

// it can also be shortened…

q.parallel_for(num_items,

[=](auto i) { sum[i] = a[i] + b[i]; }

);

Work is submitted to a queue which in turn is connected to a device.
The line of code doing the summation is executed on the device.

Kernel programming is an effective approach for parallelism programming

Kernel programming is a great way to express parallelism because we can write a simple operation, like the summation in the above example, and then effectively tell a device to “run that operation in parallel on all the applicable data.” Kernel programming is a well-established concept found in shader compilers, CUDA, and OpenCL. Modern C++ supports this elegantly with lambda functions, as shown in the code examples above.

SYCL Implementations

When we (at Intel) created a project to implement SYCL for LLVM, we gave it the descriptive name Data Parallel C++ (DPC++). LLVM is a fantastic framework for compilers. Many companies have migrated their compiler efforts to use LLVM, including AMD, Apple, IBM, Intel, and Nvidia.

DPC++ is not the only implementation available for use, SYCL enjoys broad support and there are at least five compilers implementing SYCL support at this time: DPC++, ComputeCpp, triSYCL, hipSYCL, and neoSYCL. Intel was the initial creator of the LLVM project to implement SYCL known as DPC++, Codeplay created ComputeCpp, AMD and Xilinx created triSYCL, hipSYCL is from the University of Heidelberg, and neoSYCL is from NEC.

 

SYCL enjoys a growing number of implementations. Diagram from https://www.khronos.org/sycl.

Implications of spanning more than GPUs

Today, for maximum performance applications already do the work of specializing key routines for specific devices. For instance, libraries often choose different implementations for different CPUs or different GPUs.

SYCL offers a way to write common cross-architecture code while allowing specialization when we decide it is justified.

SYCL support for enumerating devices includes the ability to probe the platform and backends, and their capabilities. A key objective is to be open, multivendor, and multiarchitecture.

Many SYCL applications will employ generic program structure and kernel code that can execute on many devices, using device selectors and device queries to compute parameter adjustments. There is no magic/silver bullet here; the programming abstraction allows us to write portable programs, but the capabilities of the devices may require us to rewrite portions of our applications to get the most out of a given device.

Portability and Performance Portability are important, and the demands of a diverse heterogeneous world are getting serious attention far beyond what I can cover here. There’s a community growing around shared best practices (P3HPC). Their workshop (P3HPC = Performance, Portability & Productivity in HPC), held in conjunction with SC21, has a rich collection of presentations. For interested readers, the current state-of-the-art in measuring portability and performance portability is well summarized in “Navigating Performance, Portability, and Productivity.”

C++ parallelism

SYCL is modern C++, based entirely on standard C++ capabilities including templates and lambdas, and does not require any new keywords or language features. We have no syntax to learn beyond modern C++. Extending C++ compilers to be SYCL-aware enables optimizations that boost performance, and allow automatic invocation of multiple backends to create executables for arbitrarily many architectures in a single build.

Today SYCL offers answers to questions critical for full heterogeneous programming. These include “How do I manage local and remote memories, with various coherency models?”, “How do I learn about diverse compute capabilities?”, and “How do I assign work to specific devices, feed them the data they need, and manage their results?”

C++23 is next up in the evolution of C++ in supporting parallel programming. The current direction described for “std::execution” in p2300 aims to provide foundational support for structured asynchronous execution. Understandably, C++23 will not try to solve all the challenges of heterogeneous programming. Nor should it try to do so. Nor should it be criticized for not doing so.

Today, SYCL solves these problems in a way that lets us target hardware from many vendors, with many architectures, usefully. These will inform future standardization efforts, not only in C++ but in other efforts including Python. We have work to do now – SYCL enables that, and we will learn together along the journey.

Open, Multivendor, Multiarchitecture

If you believe in the power of diversity of hardware, and want to harness the impending Cambrian Explosion, then SYCL is worth a look. It’s not the only open, multivendor, multiarchitecture play – but it is the key one for C++ programmers.

SYCL is not magic, but it is a solid step forward in helping C++ users be ready for this New Golden Age of Computer Architecture. As programmers, we can help foster diversity in hardware by keeping our applications flexible. SYCL offers a way to do that, while keeping as much of our code common as fits our needs.

Learn More

For learning, there is nothing better than jumping in and trying it out yourself. The best collection of learning information about SYCL is https://sycl.tech/ including numerous online tutorials, a link for our SYCL book (free PDF download), and a link to the current SYCL 2020 standards specification. In my introductory XPU blog, I explain how to access Intel DevCloud (free online account with access to Intel CPUs, GPUs, and FPGAs), and give tips on trying out multiple SYCL compilers. Following those directions, you can be compiling and running your first SYCL program a few minutes from now.

About the Author

James Reinders believes the full benefits of the evolution to full heterogeneous computing will be best realized with an open, multivendor, multiarchitecture approach. Reinders rejoined Intel a year ago, specifically because he believes Intel can meaningfully help realize this open future. Reinders is an author (or co-author and/or editor) of ten technical books related to parallel programming; his latest book is about SYCL (it can be freely downloaded here). 

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!

Multiverse Targets ‘Quantum Computing for the Masses’

January 19, 2022

The race to deliver quantum computing solutions that shield users from the underlying complexity of quantum computing is heating up quickly. One example is Multiverse Computing, a European company, which today launched the second financial services product in its Singularity product group. The new offering, Fair Price, “delivers a higher accuracy in fair price calculations for financial... Read more…

Students at SC21: Out in Front, Alongside and Behind the Scenes

January 19, 2022

The Supercomputing Conference (SC) is one of the biggest international conferences dedicated to high-performance computing, networking, storage and analysis. SC21 was a true ‘hybrid’ conference, with a total of 380 o Read more…

New Algorithm Overcomes Hurdle in Fusion Energy Simulation

January 15, 2022

The exascale era has brought with it a bevy of fusion energy simulation projects, aiming to stabilize the notoriously delicate—and so far, unmastered—clean energy source that would transform the world virtually overn Read more…

Summit Powers Novel Protein Function Prediction Work

January 13, 2022

There are hundreds of millions of sequenced proteins and counting—but only 170,000 have had their structures solved by researchers, bottlenecking our understanding of proteins and their functions across organisms’ ge Read more…

Q-Ctrl – Tackling Quantum Hardware’s Noise Problems with Software

January 13, 2022

Implementing effective error mitigation and correction is a critical next step in advancing quantum computing. While a lot of attention has been given to efforts to improve the underlying ‘noisy’ hardware, there's be Read more…

AWS Solution Channel

shutterstock 377963800

New – Amazon EC2 Hpc6a Instance Optimized for High Performance Computing

High Performance Computing (HPC) allows scientists and engineers to solve complex, compute-intensive problems such as computational fluid dynamics (CFD), weather forecasting, and genomics. Read more…

Nvidia Defends Arm Acquisition Deal: a ‘Once-in-a-Generation Opportunity’

January 13, 2022

GPU-maker Nvidia is continuing to try to keep its proposed acquisition of British chip IP vendor Arm Ltd. alive, despite continuing concerns from several governments around the world. In its latest action, Nvidia filed a 29-page response to the U.K. government to point out a list of potential benefits of the proposed $40 billion deal. Read more…

Multiverse Targets ‘Quantum Computing for the Masses’

January 19, 2022

The race to deliver quantum computing solutions that shield users from the underlying complexity of quantum computing is heating up quickly. One example is Multiverse Computing, a European company, which today launched the second financial services product in its Singularity product group. The new offering, Fair Price, “delivers a higher accuracy in fair price calculations for financial... Read more…

Students at SC21: Out in Front, Alongside and Behind the Scenes

January 19, 2022

The Supercomputing Conference (SC) is one of the biggest international conferences dedicated to high-performance computing, networking, storage and analysis. SC Read more…

Q-Ctrl – Tackling Quantum Hardware’s Noise Problems with Software

January 13, 2022

Implementing effective error mitigation and correction is a critical next step in advancing quantum computing. While a lot of attention has been given to effort Read more…

Nvidia Defends Arm Acquisition Deal: a ‘Once-in-a-Generation Opportunity’

January 13, 2022

GPU-maker Nvidia is continuing to try to keep its proposed acquisition of British chip IP vendor Arm Ltd. alive, despite continuing concerns from several governments around the world. In its latest action, Nvidia filed a 29-page response to the U.K. government to point out a list of potential benefits of the proposed $40 billion deal. Read more…

Nvidia Buys HPC Cluster Management Company Bright Computing

January 10, 2022

Graphics chip powerhouse Nvidia today announced that it has acquired HPC cluster management company Bright Computing for an undisclosed sum. Unlike Nvidia’s bid to purchase semiconductor IP company Arm, which has been stymied by regulatory challenges, the Bright deal is a straightforward acquisition that aims to expand... Read more…

SC21 Panel on Programming Models – Tackling Data Movement, DSLs, More

January 6, 2022

How will programming future systems differ from current practice? This is an ever-present question in computing. Yet it has, perhaps, never been more pressing g Read more…

Edge to Exascale: A Trend to Watch in 2022

January 5, 2022

Edge computing is an approach in which the data is processed and analyzed at the point of origin – the place where the data is generated. This is done to make data more accessible to end-point devices, or users, and to reduce the response time for data requests. HPC-class computing and networking technologies are critical to many edge use cases, and the intersection of HPC and ‘edge’ promises to be a hot topic in 2022. Read more…

Citing ‘Shortfalls,’ NOAA Targets Hundred-Fold HPC Increase Over Next Decade

January 5, 2022

From upgrading the Global Forecast System (GFS) to acquiring new supercomputers, the National Oceanic and Atmospheric Administration (NOAA) has been making big moves in the HPC sphere over the last few years—but now it’s setting the bar even higher. In a new report, NOAA’s Science Advisory Board (SAB) highlighted... Read more…

IonQ Is First Quantum Startup to Go Public; Will It be First to Deliver Profits?

November 3, 2021

On October 1 of this year, IonQ became the first pure-play quantum computing start-up to go public. At this writing, the stock (NYSE: IONQ) was around $15 and its market capitalization was roughly $2.89 billion. Co-founder and chief scientist Chris Monroe says it was fun to have a few of the company’s roughly 100 employees travel to New York to ring the opening bell of the New York Stock... Read more…

US Closes in on Exascale: Frontier Installation Is Underway

September 29, 2021

At the Advanced Scientific Computing Advisory Committee (ASCAC) meeting, held by Zoom this week (Sept. 29-30), it was revealed that the Frontier supercomputer is currently being installed at Oak Ridge National Laboratory in Oak Ridge, Tenn. The staff at the Oak Ridge Leadership... Read more…

AMD Launches Milan-X CPU with 3D V-Cache and Multichip Instinct MI200 GPU

November 8, 2021

At a virtual event this morning, AMD CEO Lisa Su unveiled the company’s latest and much-anticipated server products: the new Milan-X CPU, which leverages AMD’s new 3D V-Cache technology; and its new Instinct MI200 GPU, which provides up to 220 compute units across two Infinity Fabric-connected dies, delivering an astounding 47.9 peak double-precision teraflops. “We're in a high-performance computing megacycle, driven by the growing need to deploy additional compute performance... Read more…

Intel Reorgs HPC Group, Creates Two ‘Super Compute’ Groups

October 15, 2021

Following on changes made in June that moved Intel’s HPC unit out of the Data Platform Group and into the newly created Accelerated Computing Systems and Graphics (AXG) business unit, led by Raja Koduri, Intel is making further updates to the HPC group and announcing... Read more…

Nvidia Buys HPC Cluster Management Company Bright Computing

January 10, 2022

Graphics chip powerhouse Nvidia today announced that it has acquired HPC cluster management company Bright Computing for an undisclosed sum. Unlike Nvidia’s bid to purchase semiconductor IP company Arm, which has been stymied by regulatory challenges, the Bright deal is a straightforward acquisition that aims to expand... Read more…

D-Wave Embraces Gate-Based Quantum Computing; Charts Path Forward

October 21, 2021

Earlier this month D-Wave Systems, the quantum computing pioneer that has long championed quantum annealing-based quantum computing (and sometimes taken heat fo Read more…

Killer Instinct: AMD’s Multi-Chip MI200 GPU Readies for a Major Global Debut

October 21, 2021

AMD’s next-generation supercomputer GPU is on its way – and by all appearances, it’s about to make a name for itself. The AMD Radeon Instinct MI200 GPU (a successor to the MI100) will, over the next year, begin to power three massive systems on three continents: the United States’ exascale Frontier system; the European Union’s pre-exascale LUMI system; and Australia’s petascale Setonix system. Read more…

Three Chinese Exascale Systems Detailed at SC21: Two Operational and One Delayed

November 24, 2021

Details about two previously rumored Chinese exascale systems came to light during last week’s SC21 proceedings. Asked about these systems during the Top500 media briefing on Monday, Nov. 15, list author and co-founder Jack Dongarra indicated he was aware of some very impressive results, but withheld comment when asked directly if he had... Read more…

Leading Solution Providers

Contributors

Lessons from LLVM: An SC21 Fireside Chat with Chris Lattner

December 27, 2021

Today, the LLVM compiler infrastructure world is essentially inescapable in HPC. But back in the 2000 timeframe, LLVM (low level virtual machine) was just getting its start as a new way of thinking about how to overcome shortcomings in the Java Virtual Machine. At the time, Chris Lattner was a graduate student of... Read more…

2021 Gordon Bell Prize Goes to Exascale-Powered Quantum Supremacy Challenge

November 18, 2021

Today at the hybrid virtual/in-person SC21 conference, the organizers announced the winners of the 2021 ACM Gordon Bell Prize: a team of Chinese researchers leveraging the new exascale Sunway system to simulate quantum circuits. The Gordon Bell Prize, which comes with an award of $10,000 courtesy of HPC pioneer Gordon Bell, is awarded annually... Read more…

The Latest MLPerf Inference Results: Nvidia GPUs Hold Sway but Here Come CPUs and Intel

September 22, 2021

The latest round of MLPerf inference benchmark (v 1.1) results was released today and Nvidia again dominated, sweeping the top spots in the closed (apples-to-ap Read more…

Three Universities Team for NSF-Funded ‘ACES’ Reconfigurable Supercomputer Prototype

September 23, 2021

As Moore’s law slows, HPC developers are increasingly looking for speed gains in specialized code and specialized hardware – but this specialization, in turn, can make testing and deploying code trickier than ever. Now, researchers from Texas A&M University, the University of Illinois at Urbana... Read more…

Julia Update: Adoption Keeps Climbing; Is It a Python Challenger?

January 13, 2021

The rapid adoption of Julia, the open source, high level programing language with roots at MIT, shows no sign of slowing according to data from Julialang.org. I Read more…

Top500: No Exascale, Fugaku Still Reigns, Polaris Debuts at #12

November 15, 2021

No exascale for you* -- at least, not within the High-Performance Linpack (HPL) territory of the latest Top500 list, issued today from the 33rd annual Supercomputing Conference (SC21), held in-person in St. Louis, Mo., and virtually, from Nov. 14–19. "We were hoping to have the first exascale system on this list but that didn’t happen," said Top500 co-author... Read more…

TACC Unveils Lonestar6 Supercomputer

November 1, 2021

The Texas Advanced Computing Center (TACC) is unveiling its latest supercomputer: Lonestar6, a three peak petaflops Dell system aimed at supporting researchers Read more…

10nm, 7nm, 5nm…. Should the Chip Nanometer Metric Be Replaced?

June 1, 2020

The biggest cool factor in server chips is the nanometer. AMD beating Intel to a CPU built on a 7nm process node* – with 5nm and 3nm on the way – has been i Read more…

  • arrow
  • Click Here for More Headlines
  • arrow
HPCwire