forked from rarias/jungle
Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
c7ce05e8b7 | |||
1fe7048d95 |
@ -47,6 +47,7 @@ let
|
||||
ovni = callPackage ./pkgs/ovni/default.nix { };
|
||||
ovniGit = final.ovni.override { useGit = true; };
|
||||
paraverKernel = callPackage ./pkgs/paraver/kernel.nix { };
|
||||
pocl = callPackage ./pkgs/pocl/default.nix { };
|
||||
prometheus-slurm-exporter = prev.callPackage ./pkgs/slurm-exporter/default.nix { };
|
||||
#pscom = callPackage ./pkgs/parastation/pscom.nix { }; # Unmaintaned
|
||||
#psmpi = callPackage ./pkgs/parastation/psmpi.nix { }; # Unmaintaned
|
||||
@ -92,6 +93,8 @@ let
|
||||
clangNosvOmpv-ld = callPackage ./test/compilers/clang-openmp-ld.nix {
|
||||
stdenv = final.stdenvClangOmpss2NodesOmpv;
|
||||
};
|
||||
|
||||
pocl = callPackage ./test/compilers/pocl.nix { };
|
||||
};
|
||||
|
||||
pkgs = filterAttrs (_: isDerivation) bscPkgs;
|
||||
|
26
pkgs/pocl/0001-cmake-do-not-use-suffix.patch
Normal file
26
pkgs/pocl/0001-cmake-do-not-use-suffix.patch
Normal file
@ -0,0 +1,26 @@
|
||||
From ccf301659caac9b5e973ba1f2d32352acf617a98 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Aleix=20Bon=C3=A9?= <aleix.boneribo@bsc.es>
|
||||
Date: Tue, 2 Jul 2024 16:45:05 +0200
|
||||
Subject: [PATCH] cmake: do not use suffix
|
||||
|
||||
---
|
||||
cmake/LLVM.cmake | 3 ++
|
||||
1 files changed, 3 insertions(+)
|
||||
|
||||
diff --git a/cmake/LLVM.cmake b/cmake/LLVM.cmake
|
||||
index f4dbda065..e29144dce 100644
|
||||
--- a/cmake/LLVM.cmake
|
||||
+++ b/cmake/LLVM.cmake
|
||||
@@ -65,6 +65,9 @@ else()
|
||||
message(WARNING "Cannot determine llvm binary suffix from ${LLVM_CONFIG}")
|
||||
endif()
|
||||
message(STATUS "LLVM binaries suffix : ${LLVM_BINARY_SUFFIX}")
|
||||
+
|
||||
+ # We don't want suffixes in nix
|
||||
+ set(LLVM_BINARY_SUFFIX "")
|
||||
endif()
|
||||
|
||||
get_filename_component(LLVM_CONFIG_LOCATION "${LLVM_CONFIG}" DIRECTORY)
|
||||
--
|
||||
2.45.1
|
||||
|
33
pkgs/pocl/0001-cmake-native-build-tools.patch
Normal file
33
pkgs/pocl/0001-cmake-native-build-tools.patch
Normal file
@ -0,0 +1,33 @@
|
||||
From f24b456c50f587b05cc8f2699c94d8cdefc5b13e Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Aleix=20Bon=C3=A9?= <aleix.boneribo@bsc.es>
|
||||
Date: Tue, 2 Jul 2024 17:11:11 +0200
|
||||
Subject: [PATCH] cmake: native build tools
|
||||
|
||||
---
|
||||
cmake/LLVM.cmake | 7 +-
|
||||
1 files changed, 6 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/cmake/LLVM.cmake b/cmake/LLVM.cmake
|
||||
index e29144dce..b9f14ce6a 100644
|
||||
--- a/cmake/LLVM.cmake
|
||||
+++ b/cmake/LLVM.cmake
|
||||
@@ -269,10 +269,15 @@ endforeach()
|
||||
|
||||
####################################################################
|
||||
|
||||
+if(DEFINED LLVM_NATIVE_TOOL_DIR)
|
||||
+ set(TOOL_DIR "${LLVM_NATIVE_TOOL_DIR}")
|
||||
+ message(STATUS "TOOL_DIR=${TOOL_DIR}")
|
||||
+endif()
|
||||
+
|
||||
macro(find_program_or_die OUTPUT_VAR PROG_NAME DOCSTRING)
|
||||
find_program(${OUTPUT_VAR}
|
||||
NAMES "${PROG_NAME}${LLVM_BINARY_SUFFIX}${CMAKE_EXECUTABLE_SUFFIX}"
|
||||
- HINTS "${LLVM_BINDIR}" "${LLVM_CONFIG_LOCATION}"
|
||||
+ HINTS "${TOOL_DIR}" "${LLVM_BINDIR}" "${LLVM_CONFIG_LOCATION}"
|
||||
DOC "${DOCSTRING}"
|
||||
NO_CMAKE_PATH
|
||||
NO_CMAKE_ENVIRONMENT_PATH
|
||||
--
|
||||
2.45.1
|
||||
|
48
pkgs/pocl/0001-cmake-use-clang-from-cmake-variable.patch
Normal file
48
pkgs/pocl/0001-cmake-use-clang-from-cmake-variable.patch
Normal file
@ -0,0 +1,48 @@
|
||||
From 4688b5ce895761c884ae15fc0234ed8d623b988b Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Aleix=20Bon=C3=A9?= <aleix.boneribo@bsc.es>
|
||||
Date: Tue, 2 Jul 2024 15:41:47 +0200
|
||||
Subject: [PATCH] cmake: use clang from cmake variable
|
||||
|
||||
---
|
||||
cmake/LLVM.cmake | 22 ++++++++++++++++++++--
|
||||
1 file changed, 20 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/cmake/LLVM.cmake b/cmake/LLVM.cmake
|
||||
index 71b786dc7..f4dbda065 100644
|
||||
--- a/cmake/LLVM.cmake
|
||||
+++ b/cmake/LLVM.cmake
|
||||
@@ -281,11 +281,29 @@ macro(find_program_or_die OUTPUT_VAR PROG_NAME DOCSTRING)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
-find_program_or_die( CLANG "clang" "clang binary")
|
||||
+# -DCMAKE_C_COMPILER=riscv64-unknown-linux-gnu-clang -DCMAKE_CXX_COMPILER=riscv64-unknown-linux-gnu-clang++
|
||||
+
|
||||
+# if(DEFINED CLANG_EXECUTABLE)
|
||||
+if(DEFINED CMAKE_C_COMPILER)
|
||||
+ # set(CLANG "${CLANG_EXECUTABLE}")
|
||||
+ set(CLANG "${CMAKE_C_COMPILER}")
|
||||
+ message(STATUS "Using CLANG_EXECUTABLE: ${CLANG}")
|
||||
+else()
|
||||
+ find_program_or_die( CLANG "clang" "clang binary")
|
||||
+endif()
|
||||
execute_process(COMMAND "${CLANG}" "--version" OUTPUT_VARIABLE LLVM_CLANG_VERSION RESULT_VARIABLE CLANG_RES)
|
||||
+
|
||||
# TODO this should be optional
|
||||
-find_program_or_die( CLANGXX "clang++" "clang++ binary")
|
||||
+# if(DEFINED CLANGXX_EXECUTABLE)
|
||||
+if(DEFINED CMAKE_CXX_COMPILER)
|
||||
+ # set(CLANGXX "${CLANGXX_EXECUTABLE}")
|
||||
+ set(CLANGXX "${CMAKE_CXX_COMPILER}")
|
||||
+ message(STATUS "Using CLANGXX_EXECUTABLE: ${CLANGXX}")
|
||||
+else()
|
||||
+ find_program_or_die( CLANGXX "clang++" "clang++ binary")
|
||||
+endif()
|
||||
execute_process(COMMAND "${CLANGXX}" "--version" OUTPUT_VARIABLE LLVM_CLANGXX_VERSION RESULT_VARIABLE CLANGXX_RES)
|
||||
+
|
||||
if(CLANGXX_RES OR CLANG_RES)
|
||||
message(FATAL_ERROR "Failed running clang/clang++ --version")
|
||||
endif()
|
||||
--
|
||||
2.45.1
|
||||
|
216
pkgs/pocl/default.nix
Normal file
216
pkgs/pocl/default.nix
Normal file
@ -0,0 +1,216 @@
|
||||
{ lib
|
||||
, llvmPackages
|
||||
, ninja
|
||||
, cmake
|
||||
, hwloc
|
||||
, ocl-icd
|
||||
, opencl-headers
|
||||
, getconf
|
||||
, pkg-config
|
||||
, spirv-llvm-translator
|
||||
, spirv-tools
|
||||
, libxml2 # required for statically linked llvm
|
||||
, python3
|
||||
, writableTmpDirAsHomeHook
|
||||
|
||||
, fetchFromGitHub
|
||||
|
||||
, useGit ? false
|
||||
, gitUrl ? "git@gitlab-internal.bsc.es:task-awareness/pocl/pocl.git"
|
||||
, gitBranch ? "new-device"
|
||||
, gitCommit ? "dd10c2221b31223cbb796182df6a07f11c7541f5"
|
||||
|
||||
, staticLLVM ? true
|
||||
, enableICD ? true
|
||||
, enableSPIRV ? true
|
||||
, enableHWLOC ? true
|
||||
, enableRemoteServer ? false
|
||||
, enableRemoteClient ? false
|
||||
, enableDistroVariants ? false
|
||||
|
||||
, lttng-ust
|
||||
, enableLTTNG ? false
|
||||
|
||||
, tbb
|
||||
, enableTBB ? false
|
||||
|
||||
, nosv ? null
|
||||
, ovni ? null
|
||||
, enableNOSV ? useGit
|
||||
, enableOVNI ? useGit
|
||||
|
||||
, buildPackages
|
||||
, nix-update-script
|
||||
}:
|
||||
|
||||
let
|
||||
|
||||
release = rec {
|
||||
version = "7.0";
|
||||
src = fetchFromGitHub {
|
||||
owner = "pocl";
|
||||
repo = "pocl";
|
||||
tag = "v${version}";
|
||||
hash = "sha256-pyolM0SR6xiwhad7K0mX9I/PKbIa8Ltin0CYoA1U/qo=";
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
git = rec {
|
||||
version = src.shortRev;
|
||||
src = builtins.fetchGit {
|
||||
url = gitUrl;
|
||||
ref = gitBranch;
|
||||
rev = gitCommit;
|
||||
};
|
||||
};
|
||||
|
||||
source = if (useGit) then git else release;
|
||||
|
||||
stdenv = llvmPackages.stdenv;
|
||||
|
||||
buildLlvmPackages = buildPackages.llvmPackages;
|
||||
|
||||
isCross = stdenv.hostPlatform != stdenv.buildPlatform;
|
||||
|
||||
featureList = lib.concatStringsSep "+" (
|
||||
(lib.optionals enableICD ["icd"]) ++
|
||||
(lib.optionals enableNOSV ["nosv"]) ++
|
||||
(lib.optionals enableOVNI ["ovni"]) ++
|
||||
(lib.optionals enableSPIRV ["spirv"]) ++
|
||||
(lib.optionals enableTBB ["tbb"]) ++
|
||||
(lib.optionals enableRemoteClient ["server"]) ++
|
||||
(lib.optionals enableRemoteServer ["client"])
|
||||
);
|
||||
in
|
||||
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "pocl";
|
||||
version = featureList + "-" + source.version;
|
||||
inherit (source) src;
|
||||
|
||||
patches = lib.optionals useGit [
|
||||
./0001-cmake-use-clang-from-cmake-variable.patch
|
||||
./0001-cmake-do-not-use-suffix.patch
|
||||
./0001-cmake-native-build-tools.patch
|
||||
];
|
||||
|
||||
cmakeFlags = [
|
||||
(lib.cmakeOptionType "filepath" "WITH_LLVM_CONFIG" (lib.getExe' buildLlvmPackages.llvm.dev "llvm-config"))
|
||||
(lib.cmakeOptionType "filepath" "CLANG" (lib.getExe' buildLlvmPackages.clangUseLLVM "clang"))
|
||||
(lib.cmakeOptionType "filepath" "CLANGXX" (lib.getExe' buildLlvmPackages.clangUseLLVM "clang++"))
|
||||
(lib.cmakeOptionType "path" "CLANG_RESOURCE_DIR" "${llvmPackages.stdenv.cc}/resource-root")
|
||||
|
||||
(lib.cmakeBool "ENABLE_TESTS" finalAttrs.finalPackage.doCheck)
|
||||
|
||||
(lib.cmakeBool "ENABLE_RELOCATION" true)
|
||||
(lib.cmakeBool "ENABLE_POCL_BUILDING" false)
|
||||
|
||||
(lib.cmakeBool "ENABLE_TBB_DEVICE" enableTBB)
|
||||
(lib.cmakeBool "ENABLE_OVNI" enableOVNI)
|
||||
(lib.cmakeBool "ENABLE_NOSV" enableNOSV)
|
||||
(lib.cmakeBool "ENABLE_ICD" enableICD)
|
||||
(lib.cmakeBool "ENABLE_HWLOC" enableHWLOC)
|
||||
(lib.cmakeBool "ENABLE_LTTNG" enableLTTNG)
|
||||
|
||||
(lib.cmakeBool "ENABLE_REMOTE_CLIENT" enableRemoteClient)
|
||||
(lib.cmakeBool "ENABLE_REMOTE_SERVER" enableRemoteServer)
|
||||
|
||||
# avoid the runtime linker pulling in a different llvm e.g. from graphics drivers
|
||||
(lib.cmakeBool "STATIC_LLVM" staticLLVM)
|
||||
] ++ lib.optionals (!isCross && enableDistroVariants) [
|
||||
(lib.cmakeFeature "KERNELLIB_HOST_CPU_VARIANTS" "distro") # TODO: check if we can do it when cross compiling
|
||||
] ++ lib.optionals isCross [
|
||||
(lib.cmakeFeature "CMAKE_SYSTEM_NAME" "Linux")
|
||||
(lib.cmakeFeature "CMAKE_FIND_ROOT_PATH_MODE_PROGRAM" "NEVER")
|
||||
(lib.cmakeFeature "CMAKE_FIND_ROOT_PATH_MODE_LIBRARY" "ONLY")
|
||||
(lib.cmakeFeature "CMAKE_FIND_ROOT_PATH_MODE_INCLUDE" "ONLY")
|
||||
(lib.cmakeFeature "CMAKE_FIND_ROOT_PATH_MODE_PACKAGE" "ONLY")
|
||||
] ++ lib.optionals stdenv.hostPlatform.isRiscV [
|
||||
(lib.cmakeFeature "LLC_TRIPLE" "riscv64-unknown-linux-gnu")
|
||||
(lib.cmakeFeature "LLC_HOST_CPU" "rv64g")
|
||||
(lib.cmakeFeature "CLANG_MARCH_FLAG" "-march=")
|
||||
];
|
||||
|
||||
# Fixes error: ld: cannot find -lgcc / -lgcc_s when linking from libpocl on
|
||||
# host
|
||||
preConfigure = ''
|
||||
cmakeFlagsArray+=(
|
||||
-DEXTRA_HOST_LD_FLAGS="${lib.escapeShellArg (builtins.readFile "${stdenv.cc}/nix-support/cc-ldflags")}"
|
||||
)
|
||||
'' + lib.optionalString stdenv.hostPlatform.isRiscV ''
|
||||
cmakeFlagsArray+=(
|
||||
-DEXTRA_HOST_LLC_FLAGS=${lib.escapeShellArg ([
|
||||
"-march=rv64g"
|
||||
"-mcpu=sifive-u74"
|
||||
])}
|
||||
-DEXTRA_HOST_CLANG_FLAGS=${lib.escapeShellArg ([
|
||||
"-mabi=lp64d"
|
||||
"-march=rv64g"
|
||||
"-mcpu=sifive-u74"
|
||||
"-mtune=sifive-7-series"
|
||||
])}
|
||||
)
|
||||
'';
|
||||
|
||||
nativeBuildInputs = [
|
||||
cmake
|
||||
getconf
|
||||
ninja
|
||||
pkg-config
|
||||
python3
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
opencl-headers
|
||||
llvmPackages.libclang
|
||||
llvmPackages.llvm
|
||||
] ++ lib.optionals staticLLVM [ libxml2 ]
|
||||
++ lib.optionals enableNOSV [ nosv ]
|
||||
++ lib.optionals enableOVNI [ ovni ]
|
||||
++ lib.optionals enableHWLOC [ hwloc ]
|
||||
++ lib.optionals enableTBB [ tbb ]
|
||||
++ lib.optionals enableICD [ ocl-icd ]
|
||||
++ lib.optionals enableLTTNG [ lttng-ust ]
|
||||
++ lib.optionals enableSPIRV [
|
||||
(spirv-llvm-translator.override { inherit (llvmPackages) llvm; })
|
||||
spirv-tools
|
||||
];
|
||||
|
||||
nativeInstallCheckInputs = [
|
||||
writableTmpDirAsHomeHook
|
||||
];
|
||||
|
||||
doInstallCheck = true;
|
||||
|
||||
installCheckPhase = lib.optionalString enableICD ''
|
||||
runHook preInstallCheck
|
||||
|
||||
export OCL_ICD_VENDORS=$out/etc/OpenCL/vendors
|
||||
$out/bin/poclcc -o poclcc.cl.pocl $src/examples/poclcc/poclcc.cl
|
||||
|
||||
runHook postInstallCheck
|
||||
'';
|
||||
|
||||
setupHook = ./setup-hook.sh;
|
||||
|
||||
passthru = {
|
||||
updateScript = nix-update-script { };
|
||||
git = finalAttrs.finalPackage.override { useGit = true; };
|
||||
};
|
||||
|
||||
propagatedBuildInputs = [ stdenv.cc.cc ];
|
||||
|
||||
meta = with lib; {
|
||||
description = "A portable open source (MIT-licensed) implementation of the OpenCL standard";
|
||||
homepage = "http://portablecl.org";
|
||||
license = licenses.mit;
|
||||
maintainers = with maintainers; [
|
||||
leixb
|
||||
jansol
|
||||
xddxdd
|
||||
bsc.maintainers.leixb
|
||||
];
|
||||
platforms = platforms.linux ++ platforms.darwin;
|
||||
};
|
||||
})
|
6
pkgs/pocl/setup-hook.sh
Normal file
6
pkgs/pocl/setup-hook.sh
Normal file
@ -0,0 +1,6 @@
|
||||
preCheckHooks+=('setupPoclCheck')
|
||||
preInstallCheckHooks+=('setupPoclCheck')
|
||||
|
||||
setupPoclCheck () {
|
||||
export OCL_ICD_VENDORS="@out@/etc/OpenCL/vendors"
|
||||
}
|
26
test/compilers/pocl.nix
Normal file
26
test/compilers/pocl.nix
Normal file
@ -0,0 +1,26 @@
|
||||
{
|
||||
runCommand,
|
||||
pocl,
|
||||
clinfo,
|
||||
writableTmpDirAsHomeHook,
|
||||
}:
|
||||
|
||||
runCommand "clinfo-pocl"
|
||||
{
|
||||
nativeBuildInputs = [
|
||||
clinfo
|
||||
writableTmpDirAsHomeHook
|
||||
];
|
||||
|
||||
requiredSystemFeatures = [ "sys-devices" ];
|
||||
|
||||
env = {
|
||||
POCL_DEBUG = "error,warn";
|
||||
OCL_ICD_VENDORS = "${pocl}/etc/OpenCL/vendors";
|
||||
};
|
||||
}
|
||||
''
|
||||
set -x
|
||||
clinfo | tee $out
|
||||
set +x
|
||||
''
|
Loading…
x
Reference in New Issue
Block a user