Spir-v

Aloha,

I hope I’m in the right subforum.
I have to confess that I’m an OpenCL Newbie, so please forgive me my probably stupid questions.

I was skimming over the OpenCL 2.2 changes and kept stuck at SPIR-V.
After a bit of research it seems like SPIR-V’s purpose is to deliver the OpenCL Kernel in a Binary form so one doing engineering won’t find out how the Kernel (source) exactly looks like.

Am I right with my assumption? I feel like I misunderstood something…

Greetz

[QUOTE=java4ever;41281]Aloha,

I hope I’m in the right subforum.
I have to confess that I’m an OpenCL Newbie, so please forgive me my probably stupid questions.

I was skimming over the OpenCL 2.2 changes and kept stuck at SPIR-V.
After a bit of research it seems like SPIR-V’s purpose is to deliver the OpenCL Kernel in a Binary form so one doing engineering won’t find out how the Kernel (source) exactly looks like.[/quote]

That’s not the point. That’s one of the possible effects, but that’s not the point of SPIR-V. Indeed, it’s really not very good at obfuscation, since the language isn’t very low-level.

The point of SPIR-V is to have an intermediate language, so that users can develop compilers for new languages that compile to SPIR-V (rather than OpenCL C++) and use those languages with OpenCL just as easily as they could with OpenCL C++ or whatever.

…and conversely, since SPIR-V is designed to be simpler to parse than C or C++, it allows implementations of OpenCL (hardware drivers, CPU JITs…) to be simpler as well, which should hopefully translate into lighter-weight and less buggy implementations.

Thank you for the answers.
Just for my understanding:
SPIR-V is a intermediate language which can be compiled from the raw source code form into a binary form.
This means I can place the OpenCL Kernel outside the “main” program and load like a .dll?
And I assume it isn’t possible to place SPIR-V Code inside a .cpp file, right?

Are there any tutorials or even books yet?

Currently, the only way to create a program is to provide a char** that contains OpenCL C code. SPIR-V merely provides an alternative function that takes a void*, containing the SPIR-V binary. You can already put your code into a dll, but you will put a plain text instead of SPIR-V blob.

Are there any tutorials or even books yet?

There aren’t even OpenCL 2.1 (where SPIR-V kernels are introduced) implementations yet. :smiley: Well, there is SPIR, which is somewhat different thing. Intel Tools for OpenCL™ Applications

Intel OpenCL 2.1 CPU implementation: Developer Software Forums - Intel Community