Welcome back to the oneAPI channel.
If you’ve watched my videos so far, you heard me talking about software
portability and the ability to run the same code on multiple architectures by multiple vendors..
We all want it, and it is happening. and I’d like to show you a great example.
But first, what is the problem.. Let’s take just a CPU and a GPU as an example,
Totally different architectures, designed for totally different tasks..
So it is pretty obvious why the SW stack that was built for the CPU..
Will be totally different than the one for the GPU,
If we want the same code to be able to run on both,
we need a unified application layer, that could be translated to both these devices
It could be at a lower level.. Any level
And this is exactly what oneAPI is doing, with unified direct programming,
unified libraries, that could be run on multiple devices by multiple vendors..
And now with the plugins supplied by CodePlay you
can run the same SYCL code on nVidia and on AMD GPUs.
These are plugins, so you’ll need the oneAPI base toolkit + the
right plugin , they are not stand-alone It will use the CUDA or ROCm layers underneath,
but you do not have to care about it. We code at SYCL level..
This link will take you to the blog with many more details,
and to the instructions, you can also find the link below..
And of course, I’ve managed to get an nVidia GPU and tried it myself..
Let me show you.
so first thing, I’m getting the oneAPI base toolkit
And then, just follow the instructions here, I’ll leave you the link
I’ll follow the support for nVidia GPU, AMD guide is also here
And I actually have an RTX 4000, which is not here in the supported platforms, but it just worked..
I have ubuntu, you have here instructions for almost every OS flavor
I already have the oneAPI base toolkit, which will have the DPC++ , SYCL compiler..
And now yea.. You have to install CUDA.. It takes some time but worked smoothly as well
And now.. Download the plug-in from CodePlay, install and you are all set.
So I have the base toolkit and the plugins installed,
so let’s initialize oneapi. And here is a nice trick,
Just type sycl-ls, and you can see all the devices detected on this system.
You can see here the FPGA emulator that comes with the base toolkit,
My Xeon Gold CPU And an nVidia RTX 4000
All are detected by SYCL now.. -cool
As a real example, I’ll show you the n-body simulation,
Check my other video for the full details..
This is the code, it was automatically converted from CUDA using Syclomatic.
It takes a minute, and zero coding It looks like C++, it is SYCL..
And here we submit the kernel to the execution Q..
This Q is a attached to the default device.. Usually the GPU…
So if I want to run the kernel on the CPU, I have to get a Q attached to the CPU…
So really minor change here, of the device that we select will move the kernel from
the CPU to the GPU or other device. But I’ll show you even nicer trick..
We’ll keep the default device.. We will not change it
And we will run the same code, only change the default device from outside of the code.
So exactly the same code, to run on CPU and GPU… let’s see
So here on top, you see the CPU utilization On the bottom is the GPU utilization
And I’m running the nbody simulation, I set the default device to be CPU,
And it is running.. On my Xeon CPU… About 60mS for the kernel..
You can see that the CPU has 11 logical work working.
And the GPU is only doing the graphic rendering. And now I’m using the SAME code.
I’m just going to change the default device to GPU…
And yes, The same SYCL code, is running on the RTX4000
Kernel time is great, 5-6mS.. Only 2 CPU cores are working.
And the GPU is doing Compute and Graphics.. Is it cool or not?
The ability to run the same code on a CPU by Intel and a GPU by nVidia or AMD, is just the beginning
And I really hope to see more companies building such plugins for their preferred hardware..
Try it out. Subscribe, enjoy