forked from NixOS/nixpkgs
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add intel-compute-runtime / Intel NEO driver stack (NixOS#63705)
Add intel-compute-runtime / Intel NEO driver stack (cherry picked from commit c0cba22)
- Loading branch information
Showing
8 changed files
with
324 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
pkgs/development/compilers/intel-graphics-compiler/default.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
{ stdenv | ||
, fetchFromGitHub | ||
, cmake | ||
, pkgconfig | ||
|
||
, bison | ||
, flex | ||
, llvmPackages_8 | ||
, opencl-clang | ||
, python | ||
, spirv-llvm-translator | ||
|
||
, buildWithPatches ? true | ||
}: | ||
|
||
let | ||
llvmPkgs = llvmPackages_8 // { | ||
inherit spirv-llvm-translator; | ||
}; | ||
inherit (llvmPkgs) llvm; | ||
inherit (if buildWithPatches then opencl-clang else llvmPkgs) clang clang-unwrapped spirv-llvm-translator; | ||
inherit (stdenv.lib) getVersion optional optionals versionOlder versions; | ||
in | ||
|
||
stdenv.mkDerivation rec { | ||
pname = "intel-graphics-compiler"; | ||
version = "1.0.10"; | ||
|
||
src = fetchFromGitHub { | ||
owner = "intel"; | ||
repo = "intel-graphics-compiler"; | ||
rev = "igc-${version}"; | ||
sha256 = "1yqd2zvvvxxxzb5d3v0f03n0jdivid5l2cj11dw7ff7xz7jwiv2i"; | ||
}; | ||
|
||
nativeBuildInputs = [ clang cmake bison flex llvm python ]; | ||
|
||
buildInputs = [ clang opencl-clang spirv-llvm-translator ]; | ||
|
||
# checkInputs = [ lit pythonPackages.nose ]; | ||
|
||
# FIXME: How do we run the test suite? | ||
# https://github.com/intel/intel-graphics-compiler/issues/98 | ||
doCheck = false; | ||
|
||
# Handholding the braindead build script | ||
# We put this in a derivation because the cmake requires an absolute path | ||
prebuilds = stdenv.mkDerivation { | ||
name = "igc-cclang-prebuilds"; | ||
phases = [ "installPhase" ]; | ||
installPhase = '' | ||
mkdir $out | ||
ln -s ${clang}/bin/clang $out/ | ||
ln -s clang $out/clang-${versions.major (getVersion clang)} | ||
ln -s ${opencl-clang}/lib/* $out/ | ||
ln -s ${clang-unwrapped}/lib/clang/${getVersion clang}/include/opencl-c.h $out/ | ||
''; | ||
}; | ||
|
||
cmakeFlags = [ | ||
"-DCCLANG_BUILD_PREBUILDS=ON" | ||
"-DCCLANG_BUILD_PREBUILDS_DIR=${prebuilds}" | ||
"-DIGC_PREFERRED_LLVM_VERSION=${getVersion llvm}" | ||
]; | ||
|
||
meta = with stdenv.lib; { | ||
homepage = https://github.com/intel/intel-graphics-compiler; | ||
description = "LLVM-based compiler for OpenCL targeting Intel Gen graphics hardware"; | ||
license = licenses.mit; | ||
platforms = platforms.all; | ||
maintainers = with maintainers; [ gloaming ]; | ||
}; | ||
} |
38 changes: 38 additions & 0 deletions
38
pkgs/development/compilers/spirv-llvm-translator/default.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ stdenv | ||
, fetchFromGitHub | ||
, cmake | ||
|
||
, lit | ||
, llvm_8 | ||
}: | ||
|
||
stdenv.mkDerivation rec { | ||
pname = "SPIRV-LLVM-Translator"; | ||
version = "8.0.1-2"; | ||
|
||
src = fetchFromGitHub { | ||
owner = "KhronosGroup"; | ||
repo = "SPIRV-LLVM-Translator"; | ||
rev = "v${version}"; | ||
sha256 = "0hxalc3fkliqs61hpr97phbm3qsx4b8vgnlg30aimzr6aas403r5"; | ||
}; | ||
|
||
nativeBuildInputs = [ cmake ]; | ||
|
||
buildInputs = [ llvm_8 ]; | ||
|
||
checkInputs = [ lit ]; | ||
|
||
cmakeFlags = [ "-DLLVM_INCLUDE_TESTS=ON" ]; | ||
|
||
# FIXME: CMake tries to run "/llvm-lit" which of course doesn't exist | ||
doCheck = false; | ||
|
||
meta = with stdenv.lib; { | ||
homepage = https://github.com/KhronosGroup/SPIRV-LLVM-Translator; | ||
description = "A tool and a library for bi-directional translation between SPIR-V and LLVM IR"; | ||
license = licenses.ncsa; | ||
platforms = platforms.all; | ||
maintainers = with maintainers; [ gloaming ]; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
{ stdenv | ||
, fetchFromGitHub | ||
, fetchpatch | ||
, cmake | ||
, git | ||
|
||
, llvmPackages_8 | ||
, spirv-llvm-translator | ||
|
||
, buildWithPatches ? true | ||
}: | ||
|
||
let | ||
llvmPkgs = llvmPackages_8 // { | ||
inherit spirv-llvm-translator; | ||
}; | ||
|
||
inherit (stdenv.lib) getVersion; | ||
|
||
addPatches = component: pkg: | ||
with builtins; with stdenv.lib; | ||
let path = "${passthru.patchesOut}/${component}"; | ||
in pkg.overrideAttrs (super: { | ||
postPatch = (if super ? postPatch then super.postPatch + "\n" else "") + '' | ||
for p in ${path}/* | ||
do | ||
patch -p1 -i "$p" | ||
done | ||
''; | ||
}); | ||
|
||
passthru = rec { | ||
|
||
clang-unwrapped = addPatches "clang" llvmPkgs.clang-unwrapped; | ||
|
||
clang = llvmPkgs.clang.override { | ||
cc = clang-unwrapped; | ||
}; | ||
|
||
patchesOut = stdenv.mkDerivation rec { | ||
pname = "opencl-clang-patches"; | ||
inherit (lib) version src patches; | ||
installPhase = '' | ||
[ -d patches ] && cp -r patches/ $out || mkdir $out | ||
mkdir -p $out/clang $out/spirv | ||
''; | ||
}; | ||
|
||
spirv-llvm-translator = addPatches "spirv" llvmPkgs.spirv-llvm-translator; | ||
|
||
}; | ||
|
||
lib = let | ||
inherit (llvmPkgs) llvm; | ||
inherit (if buildWithPatches then passthru else llvmPkgs) clang-unwrapped spirv-llvm-translator; | ||
in | ||
stdenv.mkDerivation rec { | ||
pname = "opencl-clang"; | ||
version = "unstable-2019-08-16"; | ||
|
||
inherit passthru; | ||
|
||
src = fetchFromGitHub { | ||
owner = "intel"; | ||
repo = "opencl-clang"; | ||
rev = "94af090661d7c953c516c97a25ed053c744a0737"; | ||
sha256 = "05cg89m62nqjqm705h7gpdz4jd4hiczg8944dcjsvaybrqv3hcm5"; | ||
}; | ||
|
||
patches = [ | ||
# Build script tries to find Clang OpenCL headers under ${llvm} | ||
# Work around it by specifying that directory manually. | ||
./opencl-headers-dir.patch | ||
]; | ||
|
||
nativeBuildInputs = [ cmake git ]; | ||
|
||
buildInputs = [ clang-unwrapped llvm spirv-llvm-translator ]; | ||
|
||
cmakeFlags = [ | ||
"-DPREFERRED_LLVM_VERSION=${getVersion llvm}" | ||
"-DOPENCL_HEADERS_DIR=${clang-unwrapped}/lib/clang/${getVersion clang-unwrapped}/include/" | ||
|
||
"-DLLVMSPIRV_INCLUDED_IN_LLVM=OFF" | ||
"-DSPIRV_TRANSLATOR_DIR=${spirv-llvm-translator}" | ||
]; | ||
|
||
meta = with stdenv.lib; { | ||
homepage = https://github.com/intel/opencl-clang/; | ||
description = "A clang wrapper library with an OpenCL-oriented API and the ability to compile OpenCL C kernels to SPIR-V modules"; | ||
license = licenses.ncsa; | ||
platforms = platforms.all; | ||
maintainers = with maintainers; [ gloaming ]; | ||
}; | ||
}; | ||
in | ||
lib |
25 changes: 25 additions & 0 deletions
25
pkgs/development/libraries/opencl-clang/opencl-headers-dir.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
diff --git a/cl_headers/CMakeLists.txt b/cl_headers/CMakeLists.txt | ||
index 3dd2ea4..aeae6e9 100644 | ||
--- a/cl_headers/CMakeLists.txt | ||
+++ b/cl_headers/CMakeLists.txt | ||
@@ -11,12 +11,14 @@ add_custom_command( | ||
) | ||
endfunction(copy_file) | ||
|
||
-if(USE_PREBUILT_LLVM) | ||
- set(OPENCL_HEADERS_DIR | ||
- "${LLVM_LIBRARY_DIRS}/clang/${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}/include/") | ||
-else(USE_PREBUILT_LLVM) | ||
- set(OPENCL_HEADERS_DIR "${CLANG_SOURCE_DIR}/lib/Headers") | ||
-endif(USE_PREBUILT_LLVM) | ||
+if(NOT DEFINED OPENCL_HEADERS_DIR) | ||
+ if(USE_PREBUILT_LLVM) | ||
+ set(OPENCL_HEADERS_DIR | ||
+ "${LLVM_LIBRARY_DIRS}/clang/${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}/include/") | ||
+ else(USE_PREBUILT_LLVM) | ||
+ set(OPENCL_HEADERS_DIR "${CLANG_SOURCE_DIR}/lib/Headers") | ||
+ endif(USE_PREBUILT_LLVM) | ||
+endif() | ||
copy_file(${OPENCL_HEADERS_DIR}/opencl-c.h opencl-c.h) | ||
|
||
add_custom_target ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
{ stdenv | ||
, fetchFromGitHub | ||
, patchelf | ||
, cmake | ||
, pkgconfig | ||
|
||
, intel-gmmlib | ||
, intel-graphics-compiler | ||
, libva | ||
}: | ||
|
||
stdenv.mkDerivation rec { | ||
pname = "intel-compute-runtime"; | ||
version = "19.34.13959"; | ||
|
||
src = fetchFromGitHub { | ||
owner = "intel"; | ||
repo = "compute-runtime"; | ||
rev = version; | ||
sha256 = "1m54w5p5pilrkmlmqgvgrsm3d5dqfdr4jai5siq5ccsqj4gnv1wz"; | ||
}; | ||
|
||
# Build script tries to write the ICD to /etc | ||
patches = [ ./etc-dir.patch ]; | ||
|
||
nativeBuildInputs = [ cmake pkgconfig ]; | ||
|
||
buildInputs = [ intel-gmmlib intel-graphics-compiler libva ]; | ||
|
||
cmakeFlags = [ | ||
"-DSKIP_UNIT_TESTS=1" | ||
|
||
"-DIGC_DIR=${intel-graphics-compiler}" | ||
"-DETC_DIR=${placeholder "out"}/etc" | ||
|
||
# The install script assumes this path is relative to CMAKE_INSTALL_PREFIX | ||
"-DCMAKE_INSTALL_LIBDIR=lib" | ||
]; | ||
|
||
postInstall = '' | ||
# Avoid clash with intel-ocl | ||
mv $out/etc/OpenCL/vendors/intel.icd $out/etc/OpenCL/vendors/intel-neo.icd | ||
''; | ||
|
||
postFixup = '' | ||
patchelf --set-rpath ${stdenv.lib.makeLibraryPath [ intel-gmmlib intel-graphics-compiler libva ]} \ | ||
$out/lib/intel-opencl/libigdrcl.so | ||
''; | ||
|
||
meta = with stdenv.lib; { | ||
homepage = https://github.com/intel/compute-runtime; | ||
description = "Intel Graphics Compute Runtime for OpenCL. Replaces Beignet for Gen8 (Broadwell) and beyond."; | ||
license = licenses.mit; | ||
platforms = platforms.linux; | ||
maintainers = with maintainers; [ gloaming ]; | ||
}; | ||
} |
15 changes: 15 additions & 0 deletions
15
pkgs/os-specific/linux/intel-compute-runtime/etc-dir.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
diff --git a/package.cmake b/package.cmake | ||
index 24960d5..e9a21e7 100644 | ||
--- a/package.cmake | ||
+++ b/package.cmake | ||
@@ -24,7 +24,9 @@ if(UNIX) | ||
|
||
get_os_release_info(os_name os_version) | ||
|
||
- if("${os_name}" STREQUAL "clear-linux-os") | ||
+ if(DEFINED ETC_DIR) | ||
+ set(_dir_etc ${ETC_DIR}) | ||
+ elseif("${os_name}" STREQUAL "clear-linux-os") | ||
# clear-linux-os distribution avoids /etc for distribution defaults. | ||
set(_dir_etc "/usr/share/defaults/etc") | ||
else() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters