From b6ef90c6c468d1d1aa94dd60d99d00b619b0a5a0 Mon Sep 17 00:00:00 2001 From: Daniel Nagy Date: Wed, 24 Feb 2021 21:55:50 +0100 Subject: [PATCH 1/2] dlib: support sse4 instructions --- pkgs/development/libraries/dlib/default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/development/libraries/dlib/default.nix b/pkgs/development/libraries/dlib/default.nix index fa7d70d52131..096910b238bb 100644 --- a/pkgs/development/libraries/dlib/default.nix +++ b/pkgs/development/libraries/dlib/default.nix @@ -2,6 +2,7 @@ , guiSupport ? false, libX11 # see http://dlib.net/compile.html +, sse4Support ? stdenv.hostPlatform.sse4_1Support , avxSupport ? stdenv.hostPlatform.avxSupport , cudaSupport ? true }: @@ -23,6 +24,7 @@ stdenv.mkDerivation rec { cmakeFlags = [ "-DUSE_DLIB_USE_CUDA=${if cudaSupport then "1" else "0"}" + "-DUSE_SSE4_INSTRUCTIONS=${if sse4Support then "yes" else "no"}" "-DUSE_AVX_INSTRUCTIONS=${if avxSupport then "yes" else "no"}" ]; nativeBuildInputs = [ cmake pkg-config ]; From 7db40fa5d52ae4b7aaf3e145d006dd27cec2028e Mon Sep 17 00:00:00 2001 From: Daniel Nagy Date: Wed, 24 Feb 2021 21:56:27 +0100 Subject: [PATCH 2/2] python3Packages.dlib: support sse4 instructions My understanding of the line that is removed is, that the logic is wrong. According to the setup.py file[0] it says that: > To exclude certain options in the cmake config use --no: > for example: > --no USE_AVX_INSTRUCTIONS: will set -DUSE_AVX_INSTRUCTIONS=no This means, that a true value of `avxSupport` will deactivate it in the setup, which is not what we want. [0]: https://github.com/davisking/dlib/blob/v19.21/setup.py#L22 --- pkgs/development/python-modules/dlib/default.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkgs/development/python-modules/dlib/default.nix b/pkgs/development/python-modules/dlib/default.nix index 204c1a985425..58ceb16870a8 100644 --- a/pkgs/development/python-modules/dlib/default.nix +++ b/pkgs/development/python-modules/dlib/default.nix @@ -1,4 +1,5 @@ { buildPythonPackage, stdenv, lib, dlib, python, pytest, more-itertools +, sse4Support ? stdenv.hostPlatform.sse4_1Support , avxSupport ? stdenv.hostPlatform.avxSupport }: @@ -12,7 +13,10 @@ buildPythonPackage { ${python.interpreter} nix_run_setup test --no USE_AVX_INSTRUCTIONS ''; - setupPyBuildFlags = lib.optional avxSupport "--no USE_AVX_INSTRUCTIONS"; + setupPyBuildFlags = [ + "--set USE_SSE4_INSTRUCTIONS=${if sse4Support then "yes" else "no"}" + "--set USE_AVX_INSTRUCTIONS=${if avxSupport then "yes" else "no"}" + ]; patches = [ ./build-cores.patch ];