Thread overview
Compiling to SPIR
Oct 15, 2014
John Colvin
Oct 16, 2014
Kai Nacke
Oct 16, 2014
John Colvin
October 15, 2014
How unrealistic would it be to compile a small subset of D, e.g. betterc, to OpenCL SPIR https://www.khronos.org/spir ?

It would be fantastic to use all of D's code-generation and compile-time abstractions for writing opencl kernels. In addition, compile-time introspection of the kernel code would allow for significant improvements in the host API.
October 16, 2014
Hi John!

On Wednesday, 15 October 2014 at 18:14:22 UTC, John Colvin wrote:
> How unrealistic would it be to compile a small subset of D, e.g. betterc, to OpenCL SPIR https://www.khronos.org/spir ?
>
> It would be fantastic to use all of D's code-generation and compile-time abstractions for writing opencl kernels. In addition, compile-time introspection of the kernel code would allow for significant improvements in the host API.

As far as I know SPIR is a LLVM IR subset based on LLVM 3.0. Currently, I don't know what needs to be done here.

But in general it should be possible. Here is a tutorial which shows how to compile Ada to a CUDA kernel: http://markmail.org/download.xqy?id=4xfv2vajltcydmhi&number=1
This can be done with D, too. It requires some fiddeling with address spaces which is currently not implemented.

Regards,
Kai
October 16, 2014
On Thursday, 16 October 2014 at 04:32:58 UTC, Kai Nacke wrote:
> Hi John!
>
> On Wednesday, 15 October 2014 at 18:14:22 UTC, John Colvin wrote:
>> How unrealistic would it be to compile a small subset of D, e.g. betterc, to OpenCL SPIR https://www.khronos.org/spir ?
>>
>> It would be fantastic to use all of D's code-generation and compile-time abstractions for writing opencl kernels. In addition, compile-time introspection of the kernel code would allow for significant improvements in the host API.
>
> As far as I know SPIR is a LLVM IR subset based on LLVM 3.0. Currently, I don't know what needs to be done here.

SPIR 2.0 is based on llvm 3.2 IIRC. Is ldc likely to require >3.2 any time soon?

> But in general it should be possible. Here is a tutorial which shows how to compile Ada to a CUDA kernel: http://markmail.org/download.xqy?id=4xfv2vajltcydmhi&number=1
> This can be done with D, too. It requires some fiddeling with address spaces which is currently not implemented.
>
> Regards,
> Kai