Merge pull request #21995 from abbradar/opencl

Fix OpenCL support
This commit is contained in:
Nikolay Amiantov 2017-01-20 12:09:17 +03:00 committed by GitHub
commit d75a3cfb29
13 changed files with 152 additions and 119 deletions

View File

@ -96,7 +96,7 @@ in
example = literalExample "with pkgs; [ vaapiIntel libvdpau-va-gl vaapiVdpau ]";
description = ''
Additional packages to add to OpenGL drivers. This can be used
to add additional VA-API/VDPAU drivers.
to add OpenCL drivers, VA-API/VDPAU drivers etc.
'';
};
@ -107,7 +107,7 @@ in
description = ''
Additional packages to add to 32-bit OpenGL drivers on
64-bit systems. Used when <option>driSupport32Bit</option> is
set. This can be used to add additional VA-API/VDPAU drivers.
set. This can be used to add OpenCL drivers, VA-API/VDPAU drivers etc.
'';
};

View File

@ -6,111 +6,99 @@
, llvm
, libdrm
, libX11
, libXfixes
, libpthreadstubs
, libXdmcp
, libXdamage
, libXxf86vm
, python
, gl
, libXext
, python3
, ocl-icd
, mesa_noglu
, makeWrapper
, beignet
}:
stdenv.mkDerivation rec {
name = "beignet-${version}";
version = "1.1.2";
version = "1.2.1";
src = fetchurl {
url = "https://01.org/sites/default/files/${name}-source.tar.gz";
sha256 = "6a8d875afbb5e3c4fc57da1ea80f79abadd9136bfd87ab1f83c02784659f1d96";
sha256 = "07y8ga545654jdbijmplga7a7j3jn04q5gfdjsl8cax16hsv0kmp";
};
patches = [ ./clang_llvm.patch ];
enableParallelBuilding = true;
postPatch = ''
patchShebangs src/git_sha1.sh;
for f in $(find utests -type f)
do
sed -e "s@isnan(@std::isnan(@g" -i $f
sed -e "s@_std::isnan@_isnan@g" -i $f
sed -e "s@isinf(@std::isinf(@g" -i $f
sed -e "s@_std::isinf@_isinf@g" -i $f
done
patchShebangs src/git_sha1.sh
'';
configurePhase = ''
cmake . -DCMAKE_INSTALL_PREFIX=$out \
-DCLANG_LIBRARY_DIR="${clang-unwrapped}/lib" \
-DLLVM_INSTALL_DIR="${llvm}/bin" \
-DCLANG_INSTALL_DIR="${clang-unwrapped}/bin"
'';
postInstall = ''
mkdir -p $out/utests/kernels
mkdir -p $out/utests/lib
cp -r kernels $out/utests
cp src/libcl.so $out/utests/lib
cat > $out/utests/setenv.sh << EOF
#!/bin/sh
export OCL_BITCODE_LIB_PATH=$out/lib/beignet/beignet.bc
export OCL_HEADER_FILE_DIR=$out/lib/beignet/include
export OCL_PCH_PATH=$out/lib/beignet/beignet.pch
export OCL_GBE_PATH=$out/lib/beignet/libgbe.so
export OCL_INTERP_PATH=$out/lib/beignet/libgbeinterp.so
export OCL_KERNEL_PATH=$out/utests/kernels
export OCL_IGNORE_SELF_TEST=1
EOF
function fixRunPath {
p0=$(patchelf --print-rpath $1)
p1=$(echo $p0 | sed -e "s@$(pwd)/src@$out/utests/lib@g" -)
p2=$(echo $p1 | sed -e "s@$(pwd)/utests@$out/utests@g" -)
patchelf --set-rpath $p2 $1
}
fixRunPath utests/utest_run
fixRunPath utests/libutests.so
cp utests/utest_run $out/utests
cp utests/libutests.so $out/utests
mkdir -p $out/bin
ln -s $out/utests/setenv.sh $out/bin/beignet_setenv.sh
ln -s $out/utests/utest_run $out/bin/beignet_utest_run
'';
# To run the unit tests, the user must be in "video" group.
# The nix builders are members of only "nixbld" group, so
# they are able to compile the tests, but not to run them.
# To verify the installation, add yourself to "video" group,
# switch to a working directory which has both read and write
# permissions, run: nix-shell -p pkgs.beignet, and execute:
# . beignet_setenv.sh && beignet_utest_run
doCheck = false;
cmakeFlags = [ "-DCLANG_LIBRARY_DIR=${clang-unwrapped}/lib" ];
buildInputs = [
llvm
clang-unwrapped
cmake
libX11
pkgconfig
libdrm
gl
libXfixes
libXext
libpthreadstubs
libdrm
libXdmcp
libXdamage
libXxf86vm
python
ocl-icd
mesa_noglu
];
nativeBuildInputs = [
cmake
pkgconfig
python3
];
passthru.utests = stdenv.mkDerivation rec {
name = "beignet-utests-${version}";
inherit version src;
preConfigure = ''
cd utests
'';
enableParallelBuilding = true;
nativeBuildInputs = [
cmake
python3
pkgconfig
makeWrapper
];
buildInputs = [
ocl-icd
];
installPhase = ''
wrapBin() {
install -Dm755 "$1" "$out/bin/$(basename "$1")"
wrapProgram "$out/bin/$(basename "$1")" \
--set OCL_BITCODE_LIB_PATH ${beignet}/lib/beignet/beignet.bc \
--set OCL_HEADER_FILE_DIR "${beignet}/lib/beignet/include" \
--set OCL_PCH_PATH "${beignet}/lib/beignet/beignet.pch" \
--set OCL_GBE_PATH "${beignet}/lib/beignet/libgbe.so" \
--set OCL_INTERP_PATH "${beignet}/lib/beignet/libgbeinterp.so" \
--set OCL_KERNEL_PATH "$out/lib/beignet/kernels" \
--set OCL_IGNORE_SELF_TEST 1
}
install -Dm755 libutests.so $out/lib/libutests.so
wrapBin utest_run
wrapBin flat_address_space
mkdir $out/lib/beignet
cp -r ../../kernels $out/lib/beignet
'';
};
meta = with stdenv.lib; {
homepage = https://cgit.freedesktop.org/beignet/;
homepage = "https://cgit.freedesktop.org/beignet/";
description = "OpenCL Library for Intel Ivy Bridge and newer GPUs";
longDescription = ''
The package provides an open source implementation of the OpenCL specification for Intel GPUs.

View File

@ -1,14 +1,19 @@
{stdenv, fetchurl, ruby }:
{stdenv, fetchurl, ruby, opencl-headers, mesa_noglu }:
stdenv.mkDerivation rec {
name = "ocl-icd-2.2.9";
name = "ocl-icd-${version}";
version = "2.2.10";
src = fetchurl {
url = "https://forge.imag.fr/frs/download.php/716/${name}.tar.gz";
sha256 = "1rgaixwnxmrq2aq4kcdvs0yx7i6krakarya9vqs7qwsv5hzc32hc";
url = "https://forge.imag.fr/frs/download.php/810/${name}.tar.gz";
sha256 = "0f14gpa13sdm0kzqv5yycp4pschbmi6n5fj7wl4ilspzsrqcgqr2";
};
buildInputs = [ ruby ];
buildInputs = [ ruby opencl-headers ];
postPatch = ''
sed -i 's,"/etc/OpenCL/vendors","${mesa_noglu.driverLink}/etc/OpenCL/vendors",g' ocl_icd_loader.c
'';
meta = with stdenv.lib; {
description = "OpenCL ICD Loader";

View File

@ -0,0 +1,28 @@
{ stdenv, fetchFromGitHub, cmake, python, opencl-headers }:
stdenv.mkDerivation rec {
name = "opencl-clhpp-${version}";
version = "2.0.10";
src = fetchFromGitHub {
owner = "KhronosGroup";
repo = "OpenCL-CLHPP";
rev = "v${version}";
sha256 = "0h5kpg5cl8wzfnqmv6i26aig2apv06ffm9p3rh35938n9r8rladm";
};
nativeBuildInputs = [ cmake python ];
propagatedBuildInputs = [ opencl-headers ];
preConfigure = ''
cmakeFlags="-DCMAKE_INSTALL_PREFIX=$out/include -DBUILD_EXAMPLES=OFF -DBUILD_TESTS=OFF"
'';
meta = with stdenv.lib; {
description = "OpenCL Host API C++ bindings";
homepage = "http://github.khronos.org/OpenCL-CLHPP/";
license = licenses.mit;
platforms = platforms.unix;
};
}

View File

@ -1,13 +1,13 @@
{ stdenv, fetchFromGitHub, cmake }:
{ stdenv, fetchFromGitHub }:
stdenv.mkDerivation rec {
name = "opencl-headers-2.1.0";
name = "opencl-headers-2.1-2016-11-29";
src = fetchFromGitHub {
owner = "KhronosGroup";
repo = "OpenCL-Headers";
rev = "c1770dcc6cf1daadec1905e7393f3691c1dde200";
sha256 = "0m9fkblqja0686i2jjqiszvq3df95gp01a2674xknlmkd6525rck";
rev = "abb29588550c77f8340a6c3683531407013bf26b";
sha256 = "0zjznq65i4b2h4k36qfbbzq1acf2jdd9vygjv5az1yk7qgsp4jj7";
};
installPhase = ''
@ -17,7 +17,7 @@ stdenv.mkDerivation rec {
meta = with stdenv.lib; {
description = "Khronos OpenCL headers";
homepage = https://www.khronos.org/registry/cl/;
homepage = "https://www.khronos.org/registry/cl/";
license = licenses.mit;
platforms = platforms.unix;
};

View File

@ -1,18 +0,0 @@
{ stdenv, fetchurl, ruby, opencl-headers }: let
version = "2.2.9";
in stdenv.mkDerivation {
name = "opencl-icd-${version}";
buildInputs = [ ruby opencl-headers ];
configureFlags = [ "--enable-official-khronos-headers" ];
src = fetchurl {
url = "https://forge.imag.fr/frs/download.php/716/ocl-icd-${version}.tar.gz";
sha256 = "1rgaixwnxmrq2aq4kcdvs0yx7i6krakarya9vqs7qwsv5hzc32hc";
};
meta = {
platforms = stdenv.lib.platforms.linux;
};
}

View File

@ -10,7 +10,7 @@
, appdirs
, six
, opencl-headers
, opencl-icd
, ocl-icd
}:
buildPythonPackage rec {
@ -18,7 +18,7 @@ buildPythonPackage rec {
version = "2016.2";
name = "${pname}-${version}";
buildInputs = [ pytest opencl-headers opencl-icd ];
buildInputs = [ pytest opencl-headers ocl-icd ];
propagatedBuildInputs = [ numpy cffi pytools decorator appdirs six Mako ];
@ -36,4 +36,4 @@ buildPythonPackage rec {
license = stdenv.lib.licenses.mit;
maintainer = stdenv.lib.maintainers.fridh;
};
}
}

View File

@ -48,7 +48,7 @@ stdenv.mkDerivation ((lib.optionalAttrs (! isNull buildScript) {
++ lib.optional xineramaSupport pkgs.xorg.libXinerama
++ lib.optionals gstreamerSupport (with pkgs.gst_all; [ gstreamer gst-plugins-base gst-plugins-good gst-plugins-bad gst-plugins-ugly gst-ffmpeg ])
++ lib.optionals gtkSupport [ pkgs.gtk3 pkgs.glib ]
++ lib.optionals openclSupport [ pkgs.opencl-headers pkgs.opencl-icd ]
++ lib.optionals openclSupport [ pkgs.opencl-headers pkgs.ocl-icd ]
++ lib.optionals xmlSupport [ pkgs.libxml2 pkgs.libxslt ]
++ lib.optionals tlsSupport [ pkgs.openssl pkgs.gnutls ]
++ lib.optionals openglSupport [ pkgs.mesa pkgs.mesa_noglu.osmesa pkgs.libdrm ]

View File

@ -28,13 +28,15 @@ buildPhase() {
installPhase() {
# Install libGL and friends.
mkdir -p "$out/lib/vendors"
cp -p nvidia.icd $out/lib/vendors/
mkdir -p "$out/etc/OpenCL/vendors"
cp -p nvidia.icd $out/etc/OpenCL/vendors/
mkdir -p "$out/lib"
cp -prd *.so.* tls "$out/lib/"
rm "$out"/lib/lib{glx,nvidia-wfb}.so.* # handled separately
rm $out/lib/libGL.so.1.* # GLVND
rm $out/lib/libOpenCL.so* # ocl-icd is used instead
if test -z "$libsOnly"; then
# Install the X drivers.

View File

@ -1,4 +1,4 @@
{ stdenv, fetchurl, makeWrapper, opencl-headers, opencl-icd }:
{ stdenv, fetchurl, makeWrapper, opencl-headers, ocl-icd }:
assert stdenv.isLinux;
@ -22,7 +22,7 @@ stdenv.mkDerivation rec {
'';
postFixup = ''
wrapProgram $out/bin/hashcat --prefix LD_LIBRARY_PATH : ${opencl-icd}/lib
wrapProgram $out/bin/hashcat --prefix LD_LIBRARY_PATH : ${ocl-icd}/lib
'';
meta = {

View File

@ -0,0 +1,28 @@
{ stdenv, fetchFromGitHub, opencl-clhpp, ocl-icd }:
stdenv.mkDerivation {
name = "opencl-info-2014-02-21";
src = fetchFromGitHub {
owner = "marchv";
repo = "opencl-info";
rev = "3e53d001a98978feb865650cf0e93b045400c0d7";
sha256 = "114lxgnjg40ivjjszkv4n3f3yq2lbrvywryvbazf20kqmdz7315l";
};
buildInputs = [ opencl-clhpp ocl-icd ];
NIX_LDFLAGS = [ "-lOpenCL" ];
installPhase = ''
install -Dm755 opencl-info $out/bin/opencl-info
'';
meta = with stdenv.lib; {
description = "A tool to dump OpenCL platform/device information";
homepage = "https://github.com/marchv/opencl-info";
license = licenses.mit;
platforms = platforms.linux;
maintainers = with maintainers; [ abbradar ];
};
}

View File

@ -69,6 +69,7 @@ doNotDisplayTwice rec {
links = links2; # added 2016-01-31
lttngTools = lttng-tools; # added 2014-07-31
lttngUst = lttng-ust; # added 2014-07-31
m3d-linux = m33-linux; # added 2016-08-13
manpages = man-pages; # added 2015-12-06
man_db = man-db; # added 2016-05
midoriWrapper = midori; # added 2015-01
@ -81,6 +82,7 @@ doNotDisplayTwice rec {
ncat = nmap; # added 2016-01-26
nmap_graphical = nmap-graphical; # added 2017-01-19
nfsUtils = nfs-utils; # added 2014-12-06
opencl-icd = ocl-icd; # added 2017-01-20
owncloudclient = owncloud-client; # added 2016-08
pidgin-with-plugins = pidgin; # added 2016-06
pidginlatexSF = pidginlatex; # added 2014-11-02
@ -117,7 +119,6 @@ doNotDisplayTwice rec {
xf86_video_nouveau = xorg.xf86videonouveau; # added 2015-09
xlibs = xorg; # added 2015-09
youtubeDL = youtube-dl; # added 2014-10-26
m3d-linux = m33-linux; # added 2016-08-13
inherit (ocaml-ng) # added 2016-09-14
ocamlPackages_3_10_0 ocamlPackages_3_11_2 ocamlPackages_3_12_1

View File

@ -3114,6 +3114,8 @@ in
opencc = callPackage ../tools/text/opencc { };
opencl-info = callPackage ../tools/system/opencl-info { };
opencryptoki = callPackage ../tools/security/opencryptoki { };
opendbx = callPackage ../development/libraries/opendbx { };
@ -6842,10 +6844,7 @@ in
beecrypt = callPackage ../development/libraries/beecrypt { };
beignet = callPackage ../development/libraries/beignet {
inherit (llvmPackages_37) llvm clang-unwrapped;
inherit (xorg) libX11 libXfixes libpthreadstubs libXdmcp libXdamage libXxf86vm;
inherit (python3Packages) python;
inherit (purePackages) gl;
inherit (llvmPackages) llvm clang-unwrapped;
};
belle-sip = callPackage ../development/libraries/belle-sip { };
@ -8932,7 +8931,7 @@ in
opencl-headers = callPackage ../development/libraries/opencl-headers { };
opencl-icd = callPackage ../development/libraries/opencl-icd { };
opencl-clhpp = callPackage ../development/libraries/opencl-clhpp { };
opencollada = callPackage ../development/libraries/opencollada { };