Jump to page: 1 2
Thread overview
Plan of Attack for SPIRV and NVPTX
May 22, 2016
Nicholas Wilson
May 22, 2016
Johan Engelen
May 22, 2016
Nicholas Wilson
May 22, 2016
Nicholas Wilson
May 22, 2016
Johan Engelen
May 23, 2016
Nicholas Wilson
May 23, 2016
Johan Engelen
May 23, 2016
Nicholas Wilson
May 24, 2016
Johan Engelen
May 24, 2016
Johan Engelen
May 24, 2016
David Nadlinger
May 24, 2016
Nicholas Wilson
May 25, 2016
Johan Engelen
May 22, 2016
Hello

I have made a wiki entry for targeting SPIRV and NVPTX.

I will have some time over the upcoming (southern hemisphere) winter break to work on this.

please comment and destroy.
May 22, 2016
On Sunday, 22 May 2016 at 06:41:53 UTC, Nicholas Wilson wrote:
> Hello
>
> I have made a wiki entry for targeting SPIRV and NVPTX.
>
> I will have some time over the upcoming (southern hemisphere) winter break to work on this.
>
> please comment and destroy.

Sounds like a great (tough!) project!

For plan of attack, what I would do is:

1. Get something _super_ simple working. For example, a kernel for vector addition.
   Don't do any legality checks, etc, really just get it to work. Code can be ugly hacks, whatever you need to get it to work.
This would teach you how to integrate the target into LDC. Possibly you find out that the design you started out with doesn't quite fit well, and so you may have to reimplement parts with a better design knowing what you've learned so far.

2. Legality: disable pretty much all fancy D features for @kernel stuff.
   Try to stay out of the ddmd code as much as possible, perhaps do the legality checking in an extra semantic pass (AST walk) in LDC code, an equivalent of a "semantic4" but with a better name.
   Add a ton of test cases.

3. Start implementing support for D features, slowly relaxing the legality contraints.

May 22, 2016
On Sunday, 22 May 2016 at 10:13:02 UTC, Johan Engelen wrote:
> On Sunday, 22 May 2016 at 06:41:53 UTC, Nicholas Wilson wrote:
>> [...]
>
> Sounds like a great (tough!) project!
>
> For plan of attack, what I would do is:
>
> [...]

Thanks, does ldc have an -emit-llvm switch (in one of the llvm switches it hides)?
May 22, 2016
On Sunday, 22 May 2016 at 11:24:43 UTC, Nicholas Wilson wrote:
> On Sunday, 22 May 2016 at 10:13:02 UTC, Johan Engelen wrote:
>> On Sunday, 22 May 2016 at 06:41:53 UTC, Nicholas Wilson wrote:
>>> [...]
>>
>> Sounds like a great (tough!) project!
>>
>> For plan of attack, what I would do is:
>>
>> [...]
>
> Thanks, does ldc have an -emit-llvm switch (in one of the llvm switches it hides)?

Found it -output-ll
May 22, 2016
On Sunday, 22 May 2016 at 11:31:43 UTC, Nicholas Wilson wrote:
>
> Found it -output-ll

Have a look in the tests/codegen folder of how we use this to do IR testing. I think it will be very useful for your work.

May 23, 2016
On Sunday, 22 May 2016 at 12:02:21 UTC, Johan Engelen wrote:
> On Sunday, 22 May 2016 at 11:31:43 UTC, Nicholas Wilson wrote:
>>
>> Found it -output-ll
>
> Have a look in the tests/codegen folder of how we use this to do IR testing. I think it will be very useful for your work.

Heh so is clangs.

How do you go about creating metadata?

I want to do

!nvvm.annotations = !{!n}
!n = !{void (float*)* @my_kernel, !"kernel", i32 1}

where !n is a unique MDNode.
 so far i have
llvm::NamedMDNode *nnvm_annotations = gIR->module.getOrInsertNamedMetadata(StringRef("nnvm.annotations"));
llvm::MDNode *kernel_md_node = new llvm::MDNode(gIR->context,???what goes here???);
nnvm_annotations->addOperand(kernel_md_node);

I have access to the function as
 llvm::Function *func;

many thanks
Nic
May 23, 2016
On Monday, 23 May 2016 at 08:21:09 UTC, Nicholas Wilson wrote:
>
> How do you go about creating metadata?

For that I usually also look at how Clang/LLVM does it. Often there are helper functions around to create metadata.
The llvm::MDBuilder class is useful too:  http://llvm.org/docs/doxygen/html/classllvm_1_1MDBuilder.html

-Johan
May 23, 2016
On Monday, 23 May 2016 at 08:26:38 UTC, Johan Engelen wrote:
> On Monday, 23 May 2016 at 08:21:09 UTC, Nicholas Wilson wrote:
>>
>> How do you go about creating metadata?
>
> For that I usually also look at how Clang/LLVM does it. Often there are helper functions around to create metadata.
> The llvm::MDBuilder class is useful too:  http://llvm.org/docs/doxygen/html/classllvm_1_1MDBuilder.html
>
> -Johan

Thanks

What type is a function pointer MDNode? A DISubroutineType?
May 24, 2016
On Monday, 23 May 2016 at 09:31:30 UTC, Nicholas Wilson wrote:
> 
> What type is a function pointer MDNode? A DISubroutineType?

Sorry I don't know.
I guess you already had a look at how Clang generates the metadata?
May 24, 2016
On Monday, 23 May 2016 at 08:21:09 UTC, Nicholas Wilson wrote:
> On Sunday, 22 May 2016 at 12:02:21 UTC, Johan Engelen wrote:
>> On Sunday, 22 May 2016 at 11:31:43 UTC, Nicholas Wilson wrote:
>>>
>>> Found it -output-ll
>>
>> Have a look in the tests/codegen folder of how we use this to do IR testing. I think it will be very useful for your work.
>
> Heh so is clangs.

Btw, I'd be happy to help with the lit-based testsuite if you have any issues or special requests.
I am a huge fan of it :)
« First   ‹ Prev
1 2