www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.ldc - Plan of Attack for SPIRV and NVPTX

reply Nicholas Wilson <iamthewilsonator hotmail.com> writes:
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 21 2016
parent reply Johan Engelen <j j.nl> writes:
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
parent reply Nicholas Wilson <iamthewilsonator hotmail.com> writes:
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
parent reply Nicholas Wilson <iamthewilsonator hotmail.com> writes:
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
parent reply Johan Engelen <j j.nl> writes:
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 22 2016
parent reply Nicholas Wilson <iamthewilsonator hotmail.com> writes:
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
next sibling parent reply Johan Engelen <j j.nl> writes:
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
parent reply Nicholas Wilson <iamthewilsonator hotmail.com> writes:
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 23 2016
parent Johan Engelen <j j.nl> writes:
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
prev sibling parent reply Johan Engelen <j j.nl> writes:
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 :)
May 24 2016
next sibling parent David Nadlinger via digitalmars-d-ldc <digitalmars-d-ldc puremagic.com> writes:
On 24 May 2016, at 13:21, Johan Engelen via digitalmars-d-ldc wrote:
 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 :)
Yes, it definitely does deserve more appreciation (I'm guilty of this too). ;) — David
May 24 2016
prev sibling parent reply Nicholas Wilson <iamthewilsonator hotmail.com> writes:
On Tuesday, 24 May 2016 at 12:21:24 UTC, Johan Engelen wrote:
 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 :)
Pardon my ignorance, whats a lit-based test suite? ( I've got a cold atm so I'm not thinking properly.)
May 24 2016
parent Johan Engelen <j j.nl> writes:
On Tuesday, 24 May 2016 at 23:41:46 UTC, Nicholas Wilson wrote:
 
 Pardon my ignorance, whats a lit-based test suite? ( I've got a 
 cold atm so I'm not thinking properly.)
http://forum.dlang.org/post/jorzeoxnxzkzcsdajewf forum.dlang.org
May 25 2016