Welcome back to the oneAPI channel.
At the heart of whatever we scientists, researchers or programmers do there is the math
We might not see it, but Math is the foundation of it all
We want these basic functions to be as easy and as flexible to use
We want them to run as fast as possible And we want them to be able to run everywhere,
CPU, GPU, AI accelerators..
Everywhere..
In one word.. oneMKL
In previous videos we have talked about the oneAPI components.
We mentioned the multi-device multi-vendor open spec libraries..
That are arranged in toolkits..
One of these libraries is the oneMKL The oneAPI Math Kernel Library
oneMKL is basically a Library of highly optimized and extensively parallelized routines,
That was built to provide you with maximum performance across a variety of CPUs and accelerators
There are many functions included, in various domains..
You can find here FFTs, random numbers, sparse and dense linear algebra, statistics and more
There are many routings supported by the DPC++ interface on CPU and GPU
We’ll see an example soon
Maybe the easiest way to understand which functions you can use, is to navigate to oneapi.com
To the oneapi spec
To oneMKL spec Here you can find the architecture and execution
model,
And all the supported domains Let’s go to “dense linear algebra”
Sub domain LAPACK And here are all the routines, and If I click
one of them I’m getting the description, the API and so on.
This was the spec,
Now I google oneMKL Intel implementation You can find here benchmark for specific functions,
and you can see the performance and how it scales with additional threads
If you are not convinced about the performance benefits, it’s a good place to start
And vector math performance numbers
If you’d like to try it out on our dev cloud, just click here
And you’ll get remote access to code samples with ready installed environment.
Or you can download the oneAPI base toolkit,
or only the oneMKL library here
Documentation, and let’s see the DPC++ reference All the available routines, per domain..
The oneMKL code is open source and if you navigate to the oneMKL git-hub page,
you’ll find implementations for intel CPU and GPU but also to other devices from other
vendors.
Let’s look at a simple DPC++ example This code is pretty simple and portable..
You can use the same code for a CPU or a GPU and in the future for other accelerators.
And get great performance on both the architectures.
We’ll take function GEMM for example General Matrix multiplication, just multiply
matrix A by Matrix B.
The DPC++ interface facilitates device discovery, and the runtime manages device offload.
So, before I call a oneMKL function, I create a SYCL queue for the device where I intend
to submit tasks.
In this example, I’m just using the default selector.
This will find an accelerator, if one is available.
If no accelerator is available, it will create a queue for the host CPU
Of course, you can define multiple queues on multiple accelerators to be handled by
the runtime,
unlike OpenCL for example, SYCL queues are asynchronous.
This is a big advantage because it allows me to create multiple queues for multiple
devices and submit work to them asynchronously.
However, this also means that I sometimes have to synchronize the host and device execution.
So here, I’m declaring a SYCL event so that the host knows when the oneMKL function completes
I may have to let the device know that execution can’t begin until the necessary data is
available, so I can provide a vector of SYCL events to
the oneMKL function and it will not execute until the dependencies are available.
Now that any dependencies are clearly defined, I can safely call the oneMKL function, in
this case, gemm.
To be run on my queue with all the parameters and dependencies..
And that’s all DPC++ run-time is managing the asynchronous
execution and all I have to do is wait for it to finish,
You can find this example as well as many others in the oneAPI samples repository.
Just scan this QR code.
So, great scalable performance, on multiple devices, across multiple vendors
There are many ways to enjoy oneMKL You can try it out on the intel dev-cloud
You can install the oneAPI Base toolkit, or just the oneMKL library
And if you are using the intel distribution of python from the AI analytics toolkit,
The optimized Numpy or SciPy will call the oneMKL routines under the hood.
Subscribe to the oneAPI channel to get more content like this video
Thank you !