www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.ldc - How to build SPIR-V supported LDC?

reply Sobaya <sobaya007 gmail.com> writes:
I'd like to try dcompute.(https://github.com/libmir/dcompute)

This requires SPIR-V supported LLVM and LDC built with it.

But I don't understand how to build LDC with SPIR-V support.

Please tell me the way.

Thanks, Sobaya
Apr 23 2018
next sibling parent kinke <noone nowhere.com> writes:
On Monday, 23 April 2018 at 16:03:13 UTC, Sobaya wrote:
 I'd like to try dcompute.(https://github.com/libmir/dcompute)

 This requires SPIR-V supported LLVM and LDC built with it.
Not 100% correct; dcompute works with 2 target backends, nvptx (CUDA) and SPIR-V (OpenCL). nvptx is an official LLVM target & included in the prebuilt LDC packages, so if you have an Nvidia card, you should be able to play around with dcompute out of the box. AFAIK, Nicholas maintains an inofficial SPIR-V target, which would need to be integrated into the LLVM src tree: https://github.com/thewilsonator/llvm-target-spirv You'd then need to build LLVM yourself incl. the SPIR-V target and then build LDC with that LLVM, see the Wiki for how-to.
Apr 23 2018
prev sibling parent reply Nicholas Wilson <iamthewilsonator hotmail.com> writes:
On Monday, 23 April 2018 at 16:03:13 UTC, Sobaya wrote:
 I'd like to try dcompute.(https://github.com/libmir/dcompute)

 This requires SPIR-V supported LLVM and LDC built with it.

 But I don't understand how to build LDC with SPIR-V support.

 Please tell me the way.

 Thanks, Sobaya
If you want SPIR-V support you'll need to check out my fork of llvm (https://github.com/thewilsonator/llvm) and its git submodules. Then build LLVM (this takes a while, I'd recommend only building the arch you use (e.g. X86) + SPIR-V and optionally NVPTX). Then build LDC against that LLVM. There's a chance it might not build against LDC, I apologise if that happens I've been very busy and haven't been able to keep on top of changes. Hopefully this will become much simpler once there is an official SPIR-V backend (hopefully June at the earliest). I provide prebuilts for OS X, and I can do them for Windows and Linux but don't have them on hand. I might be able to build them before I leave for DConf, but don't bet on it, after that sure.
Apr 23 2018
parent reply Sobaya <sobaya007 gmail.com> writes:
On Monday, 23 April 2018 at 23:54:51 UTC, Nicholas Wilson wrote:
 On Monday, 23 April 2018 at 16:03:13 UTC, Sobaya wrote:
 I'd like to try dcompute.(https://github.com/libmir/dcompute)

 This requires SPIR-V supported LLVM and LDC built with it.

 But I don't understand how to build LDC with SPIR-V support.

 Please tell me the way.

 Thanks, Sobaya
If you want SPIR-V support you'll need to check out my fork of llvm (https://github.com/thewilsonator/llvm) and its git submodules. Then build LLVM (this takes a while, I'd recommend only building the arch you use (e.g. X86) + SPIR-V and optionally NVPTX). Then build LDC against that LLVM. There's a chance it might not build against LDC, I apologise if that happens I've been very busy and haven't been able to keep on top of changes. Hopefully this will become much simpler once there is an official SPIR-V backend (hopefully June at the earliest). I provide prebuilts for OS X, and I can do them for Windows and Linux but don't have them on hand. I might be able to build them before I leave for DConf, but don't bet on it, after that sure.
I tried like below. git clone https://github.com/thewilsonator/llvm.git git checkout compute git mkdir build cd build cmake .. But cmake error occured. The error message is " CMake Error at CMakeLists.txt:659 (message): Unexpected failure executing llvm-build: llvm-build: fatal error: missing LLVMBuild.txt file at: '/home/sobaya/git/llvm/lib/Target/SPIRV/LLVMBuild.txt' " What's wrong?
Apr 24 2018
parent reply kinke <kinke libero.it> writes:
On Tuesday, 24 April 2018 at 08:09:18 UTC, Sobaya wrote:
 But cmake error occured.
 The error message is
 "
 CMake Error at CMakeLists.txt:659 (message):
   Unexpected failure executing llvm-build: llvm-build: fatal 
 error: missing
   LLVMBuild.txt file at:
   '/home/sobaya/git/llvm/lib/Target/SPIRV/LLVMBuild.txt'
 "

 What's wrong?
You didn't clone recursively and so don't have the SPIR-V target git submodule. `git submocule update --init` should do the trick now.
Apr 24 2018
parent reply Sobaya <sobaya007 gmail.com> writes:
On Tuesday, 24 April 2018 at 09:22:38 UTC, kinke wrote:
 On Tuesday, 24 April 2018 at 08:09:18 UTC, Sobaya wrote:
 But cmake error occured.
 The error message is
 "
 CMake Error at CMakeLists.txt:659 (message):
   Unexpected failure executing llvm-build: llvm-build: fatal 
 error: missing
   LLVMBuild.txt file at:
   '/home/sobaya/git/llvm/lib/Target/SPIRV/LLVMBuild.txt'
 "

 What's wrong?
You didn't clone recursively and so don't have the SPIR-V target git submodule. `git submocule update --init` should do the trick now.
It was exactly as you said. And I executed 'make', an error occurred while building libLTO.so. I noticed that this error is about the issue https://github.com/thewilsonator/llvm-target-spirv/issues/1. As the issue was opened, I thought I cannot solve the program. But I noticed you merged to master branch the commit you mentioned at the last comment of the issue, so tried to build again at the master and made it. It was the right process? If it was right, should you change the submodule's commit attached to comute branch from 74687b to master?
Apr 24 2018
parent Sobaya <sobaya007 gmail.com> writes:
On Tuesday, 24 April 2018 at 12:19:26 UTC, Sobaya wrote:
 On Tuesday, 24 April 2018 at 09:22:38 UTC, kinke wrote:
 On Tuesday, 24 April 2018 at 08:09:18 UTC, Sobaya wrote:
 But cmake error occured.
 The error message is
 "
 CMake Error at CMakeLists.txt:659 (message):
   Unexpected failure executing llvm-build: llvm-build: fatal 
 error: missing
   LLVMBuild.txt file at:
   '/home/sobaya/git/llvm/lib/Target/SPIRV/LLVMBuild.txt'
 "

 What's wrong?
You didn't clone recursively and so don't have the SPIR-V target git submodule. `git submocule update --init` should do the trick now.
It was exactly as you said. And I executed 'make', an error occurred while building libLTO.so. I noticed that this error is about the issue https://github.com/thewilsonator/llvm-target-spirv/issues/1. As the issue was opened, I thought I cannot solve the program. But I noticed you merged to master branch the commit you mentioned at the last comment of the issue, so tried to build again at the master and made it. It was the right process? If it was right, should you change the submodule's commit attached to comute branch from 74687b to master?
Additionaly, I tried to build LDC with the SPIR-V supported LLVM like git clone https://github.com/ldc-developers/ldc.git --recursive cd ldc mkdir build cd build cmake .. -DLLVM_CONFIG=../../llvm/build/bin/llvm_config make But this build was failed. This is because LDC cannot be built with LLVM with its version over 6.0.0 while your LLVM' s version is 7.0.0svn. You can really build LDC with your LLVM?
Apr 24 2018