forked from kscience/kmath
clang support
This commit is contained in:
parent
633eb7ad4e
commit
927916a01f
@ -13,8 +13,7 @@ differentiable program written on top of
|
|||||||
|
|
||||||
## Installation from source
|
## Installation from source
|
||||||
|
|
||||||
Currently, we support only
|
Currently, we support only the linux platform for the native artifacts.
|
||||||
the [GNU](https://gcc.gnu.org/) toolchain for the native artifacts.
|
|
||||||
For `GPU` kernels, we require a compatible
|
For `GPU` kernels, we require a compatible
|
||||||
[CUDA](https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html)
|
[CUDA](https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html)
|
||||||
installation. If you are on Windows, we recommend setting up
|
installation. If you are on Windows, we recommend setting up
|
||||||
|
@ -12,7 +12,7 @@ plugins {
|
|||||||
id("de.undercouch.download")
|
id("de.undercouch.download")
|
||||||
}
|
}
|
||||||
|
|
||||||
description = "Wrapper for the Bayesian Computation library NOA on top of LibTorch"
|
description = "Wrapper for the Differentiable Computation library NOA on top of LibTorch"
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(project(":kmath-tensors"))
|
implementation(project(":kmath-tensors"))
|
||||||
@ -30,9 +30,13 @@ val cudaFound = cudaHome?.isNotEmpty() ?: false or cudaDefault
|
|||||||
|
|
||||||
val cmakeArchive = "cmake-3.20.5-linux-x86_64"
|
val cmakeArchive = "cmake-3.20.5-linux-x86_64"
|
||||||
val torchArchive = "libtorch"
|
val torchArchive = "libtorch"
|
||||||
|
val clangArchive = "clang+llvm-12.0.1-x86_64-linux-gnu-ubuntu-16.04"
|
||||||
|
|
||||||
val cmakeCmd = "$thirdPartyDir/cmake/$cmakeArchive/bin/cmake"
|
val cmakeCmd = "$thirdPartyDir/cmake/$cmakeArchive/bin/cmake"
|
||||||
val ninjaCmd = "$thirdPartyDir/ninja/ninja"
|
val ninjaCmd = "$thirdPartyDir/ninja/ninja"
|
||||||
|
val clangRootDir = "$thirdPartyDir/clang/$clangArchive"
|
||||||
|
val clangCmd = "$clangRootDir/bin/clang"
|
||||||
|
val clangxxCmd = "$clangRootDir/bin/clang++"
|
||||||
|
|
||||||
val generateJNIHeader by tasks.registering {
|
val generateJNIHeader by tasks.registering {
|
||||||
doLast {
|
doLast {
|
||||||
@ -60,6 +64,13 @@ val downloadNinja by tasks.registering(Download::class) {
|
|||||||
overwrite(false)
|
overwrite(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val downloadClang by tasks.registering(Download::class) {
|
||||||
|
val tarFile = "$clangArchive.tar.xz"
|
||||||
|
src("https://github.com/llvm/llvm-project/releases/download/llvmorg-12.0.1/$tarFile")
|
||||||
|
dest(File("$thirdPartyDir/clang", tarFile))
|
||||||
|
overwrite(false)
|
||||||
|
}
|
||||||
|
|
||||||
val downloadTorch by tasks.registering(Download::class) {
|
val downloadTorch by tasks.registering(Download::class) {
|
||||||
val torchVersion = "$torchArchive-shared-with-deps-1.9.0%2B"
|
val torchVersion = "$torchArchive-shared-with-deps-1.9.0%2B"
|
||||||
val cudaUrl = "https://download.pytorch.org/libtorch/cu111/${torchVersion}cu111.zip"
|
val cudaUrl = "https://download.pytorch.org/libtorch/cu111/${torchVersion}cu111.zip"
|
||||||
@ -93,6 +104,22 @@ val extractNinja by tasks.registering(Copy::class) {
|
|||||||
into("$thirdPartyDir/ninja")
|
into("$thirdPartyDir/ninja")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val extractClang by tasks.registering {
|
||||||
|
dependsOn(downloadClang)
|
||||||
|
onlyIf { !file(clangRootDir).exists() }
|
||||||
|
doLast {
|
||||||
|
exec {
|
||||||
|
workingDir("$thirdPartyDir/clang")
|
||||||
|
commandLine("mkdir", clangArchive)
|
||||||
|
}
|
||||||
|
exec {
|
||||||
|
workingDir("$thirdPartyDir/clang")
|
||||||
|
commandLine("tar", "-xf", "$clangArchive.tar.xz",
|
||||||
|
"-C", clangArchive, "--strip-components", "1")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val extractTorch by tasks.registering(Copy::class) {
|
val extractTorch by tasks.registering(Copy::class) {
|
||||||
dependsOn(downloadTorch)
|
dependsOn(downloadTorch)
|
||||||
from(zipTree(downloadTorch.get().dest))
|
from(zipTree(downloadTorch.get().dest))
|
||||||
@ -123,6 +150,8 @@ val configureCpp by tasks.registering {
|
|||||||
jNoaDir,
|
jNoaDir,
|
||||||
"-GNinja",
|
"-GNinja",
|
||||||
"-DCMAKE_MAKE_PROGRAM=$ninjaCmd",
|
"-DCMAKE_MAKE_PROGRAM=$ninjaCmd",
|
||||||
|
"-DCMAKE_C_COMPILER=$clangCmd",
|
||||||
|
"-DCMAKE_CXX_COMPILER=$clangxxCmd",
|
||||||
"-DCMAKE_PREFIX_PATH=$thirdPartyDir/torch/$torchArchive",
|
"-DCMAKE_PREFIX_PATH=$thirdPartyDir/torch/$torchArchive",
|
||||||
"-DJAVA_HOME=$javaHome",
|
"-DJAVA_HOME=$javaHome",
|
||||||
"-DBUILD_JNOA=ON",
|
"-DBUILD_JNOA=ON",
|
||||||
|
Loading…
Reference in New Issue
Block a user