forked from rarias/jungle
Compare commits
26 Commits
pkgs/tacud
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 8dab0d82ba | |||
| 958dcd4774 | |||
| 7a6e4232de | |||
| 3b56e905e5 | |||
| 2d41309466 | |||
| deb0cd1488 | |||
| cd1f502ecc | |||
| dda6a66782 | |||
| 22420e6ac8 | |||
| a71cd78b4c | |||
| e84a2cadbb | |||
| d3e43eb651 | |||
| a491546ffb | |||
| 933c78a80b | |||
| 150969be9b | |||
| 9097729759 | |||
| 779449f1db | |||
| 6cbe33bd80 | |||
| 3f1f5ae8f2 | |||
| fe8586e780 | |||
| 8677adba27 | |||
| f614149edf | |||
| 859eebda98 | |||
| c2a201b085 | |||
| f921f0a4bd | |||
| aa16bfc0bc |
6
flake.lock
generated
6
flake.lock
generated
@@ -2,11 +2,11 @@
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1764522689,
|
||||
"narHash": "sha256-SqUuBFjhl/kpDiVaKLQBoD8TLD+/cTUzzgVFoaHrkqY=",
|
||||
"lastModified": 1767634882,
|
||||
"narHash": "sha256-2GffSfQxe3sedHzK+sTKlYo/NTIAGzbFCIsNMUPAAnk=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "8bb5646e0bed5dbd3ab08c7a7cc15b75ab4e1d0f",
|
||||
"rev": "3c9db02515ef1d9b6b709fc60ba9a540957f661c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
@@ -57,6 +57,18 @@
|
||||
};
|
||||
};
|
||||
|
||||
services.fail2ban = {
|
||||
enable = true;
|
||||
maxretry = 5;
|
||||
bantime-increment = {
|
||||
enable = true; # Double ban time on each attack
|
||||
maxtime = "7d"; # Ban up to a week
|
||||
};
|
||||
};
|
||||
|
||||
# Disable SSH login with password, allow only keypair
|
||||
services.openssh.settings.PasswordAuthentication = false;
|
||||
|
||||
networking.firewall = {
|
||||
extraCommands = ''
|
||||
# Blackhole BSC vulnerability scanner (OpenVAS) as it is spamming our
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
address = "10.0.40.40";
|
||||
prefixLength = 24;
|
||||
} ];
|
||||
interfaces.ibp5s0.ipv4.addresses = [ {
|
||||
interfaces.ibs785.ipv4.addresses = [ {
|
||||
address = "10.0.42.40";
|
||||
prefixLength = 24;
|
||||
} ];
|
||||
|
||||
@@ -2,11 +2,36 @@
|
||||
|
||||
{
|
||||
environment.systemPackages = with pkgs; [
|
||||
vim wget git htop tmux pciutils tcpdump ripgrep nix-index nixos-option
|
||||
nix-diff ipmitool freeipmi ethtool lm_sensors cmake gnumake file tree
|
||||
ncdu perf ldns pv
|
||||
cmake
|
||||
ethtool
|
||||
file
|
||||
freeipmi
|
||||
git
|
||||
gnumake
|
||||
home-manager
|
||||
htop
|
||||
ipmitool
|
||||
ldns
|
||||
lm_sensors
|
||||
ncdu
|
||||
nix-diff
|
||||
nix-index
|
||||
nix-output-monitor
|
||||
nixfmt-tree
|
||||
nixos-option
|
||||
pciutils
|
||||
perf
|
||||
pv
|
||||
ripgrep
|
||||
tcpdump
|
||||
tmux
|
||||
tree
|
||||
vim
|
||||
wget
|
||||
|
||||
# From jungle overlay
|
||||
osumb nixgen
|
||||
nixgen
|
||||
osumb
|
||||
];
|
||||
|
||||
programs.direnv.enable = true;
|
||||
|
||||
@@ -139,6 +139,7 @@
|
||||
openssh.authorizedKeys.keys = [
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKGt0ESYxekBiHJQowmKpfdouw0hVm3N7tUMtAaeLejK vincent@varch"
|
||||
];
|
||||
shell = pkgs.zsh;
|
||||
};
|
||||
|
||||
pmartin1 = {
|
||||
@@ -193,6 +194,19 @@
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOlRX7ZCnqtUJYCxKgWmgSrFCYuA2LHY96rVwqxXPl86 aaguirre@BSC-8488184117"
|
||||
];
|
||||
};
|
||||
|
||||
emonteir = {
|
||||
uid = 9656;
|
||||
isNormalUser = true;
|
||||
home = "/home/Computational/emonteir";
|
||||
description = "Erwin Royson Monteiro";
|
||||
group = "Computational";
|
||||
hosts = [ "apex" "fox" ];
|
||||
hashedPassword = "$6$0mU88zd3ZuK5NiJQ$DFWL5RMLH6esQM5UyhBCiiNryw4lDDmvJp7Usz3tmevnsiSJr6u0RsUKAnR/K8GRBFrV1.GocrgNjKjik5GY//";
|
||||
openssh.authorizedKeys.keys = [
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOKZKot/Y3F5Wq9pQIXlCbyvQuVVeWMCsAC96Nd+LTcG erwin@Oreo"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
groups = {
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
{ config, pkgs, lib, ... }:
|
||||
{ pkgs, lib, ... }:
|
||||
|
||||
{
|
||||
# add the perf tool
|
||||
environment.systemPackages = with pkgs; [
|
||||
config.boot.kernelPackages.perf
|
||||
];
|
||||
|
||||
# allow non-root users to read tracing data from the kernel
|
||||
boot.kernel.sysctl."kernel.perf_event_paranoid" = -2;
|
||||
boot.kernel.sysctl."kernel.kptr_restrict" = 0;
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
address = "10.0.40.7";
|
||||
prefixLength = 24;
|
||||
} ];
|
||||
interfaces.ibp5s0.ipv4.addresses = [ {
|
||||
interfaces.ibs785.ipv4.addresses = [ {
|
||||
address = "10.0.42.7";
|
||||
prefixLength = 24;
|
||||
} ];
|
||||
|
||||
@@ -4,8 +4,8 @@ let
|
||||
name = "jungle-web";
|
||||
src = pkgs.fetchgit {
|
||||
url = "https://jungle.bsc.es/git/rarias/jungle-website.git";
|
||||
rev = "52abaf4d71652a9ef77a0b098db14ca33bffff4c";
|
||||
hash = "sha256-/ul9GazbOrOkmlvSgDz/+2W+V+ir5725Y7mVLc3rb0M=";
|
||||
rev = "5f18335d14126d2fef134c0cd441771436f7dfa1";
|
||||
hash = "sha256-s9VBF91sQ7hg9+lrwNFPYgoXTTyXaQcAulCiGJgWERo=";
|
||||
};
|
||||
buildInputs = [ pkgs.hugo ];
|
||||
buildPhase = ''
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
address = "10.0.40.42";
|
||||
prefixLength = 24;
|
||||
} ];
|
||||
interfaces.ibp5s0.ipv4.addresses = [ {
|
||||
interfaces.ibs785.ipv4.addresses = [ {
|
||||
address = "10.0.42.42";
|
||||
prefixLength = 24;
|
||||
} ];
|
||||
|
||||
27
m/module/tc1-board.nix
Normal file
27
m/module/tc1-board.nix
Normal file
@@ -0,0 +1,27 @@
|
||||
{ lib, pkgs, ... }:
|
||||
|
||||
{
|
||||
# Allow user access to FTDI USB device
|
||||
services.udev.packages = lib.singleton (pkgs.writeTextFile {
|
||||
# Needs to be < 73
|
||||
name = "60-ftdi-tc1.rules";
|
||||
text = ''
|
||||
# Bus 003 Device 003: ID 0403:6011 Future Technology Devices International, Ltd FT4232H Quad HS USB-UART/FIFO IC
|
||||
# Use := to make sure it doesn't get changed later
|
||||
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6011", MODE:="0666"
|
||||
'';
|
||||
destination = "/etc/udev/rules.d/60-ftdi-tc1.rules";
|
||||
});
|
||||
|
||||
# Allow access to USB for docker in GitLab runner
|
||||
services.gitlab-runner = {
|
||||
services.gitlab-bsc-docker = {
|
||||
registrationFlags = [
|
||||
# We need raw access to the USB port to reboot the board
|
||||
"--docker-devices /dev/bus/usb/003/003"
|
||||
# And TTY access for the serial port
|
||||
"--docker-devices /dev/ttyUSB2"
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -20,7 +20,7 @@
|
||||
address = "10.0.40.1";
|
||||
prefixLength = 24;
|
||||
} ];
|
||||
interfaces.ibp5s0.ipv4.addresses = [ {
|
||||
interfaces.ibs785.ipv4.addresses = [ {
|
||||
address = "10.0.42.1";
|
||||
prefixLength = 24;
|
||||
} ];
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
prefixLength = 24;
|
||||
} ];
|
||||
# Watch out! The OmniPath device is not in the same place here:
|
||||
interfaces.ibp129s0.ipv4.addresses = [ {
|
||||
interfaces.ibs801.ipv4.addresses = [ {
|
||||
address = "10.0.42.2";
|
||||
prefixLength = 24;
|
||||
} ];
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
../module/p.nix
|
||||
../module/vpn-dac.nix
|
||||
../module/hut-substituter.nix
|
||||
../module/tc1-board.nix
|
||||
];
|
||||
|
||||
# Select the this using the ID to avoid mismatches
|
||||
|
||||
@@ -27,4 +27,7 @@
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# Allow gitea user to send mail
|
||||
users.users.gitea.extraGroups = [ "mail-robot" ];
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ let
|
||||
name = "jungle-web";
|
||||
src = pkgs.fetchgit {
|
||||
url = "https://jungle.bsc.es/git/rarias/jungle-website.git";
|
||||
rev = "52abaf4d71652a9ef77a0b098db14ca33bffff4c";
|
||||
hash = "sha256-/ul9GazbOrOkmlvSgDz/+2W+V+ir5725Y7mVLc3rb0M=";
|
||||
rev = "5f18335d14126d2fef134c0cd441771436f7dfa1";
|
||||
hash = "sha256-s9VBF91sQ7hg9+lrwNFPYgoXTTyXaQcAulCiGJgWERo=";
|
||||
};
|
||||
buildInputs = [ pkgs.hugo ];
|
||||
buildPhase = ''
|
||||
|
||||
18
overlay.nix
18
overlay.nix
@@ -50,8 +50,6 @@ 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 { };
|
||||
pocl-noicd = callPackage ./pkgs/pocl/default.nix { enableICD = false; };
|
||||
prometheus-slurm-exporter = prev.callPackage ./pkgs/slurm-exporter/default.nix { };
|
||||
#pscom = callPackage ./pkgs/parastation/pscom.nix { }; # Unmaintaned
|
||||
#psmpi = callPackage ./pkgs/parastation/psmpi.nix { }; # Unmaintaned
|
||||
@@ -64,16 +62,7 @@ let
|
||||
tagaspi = callPackage ./pkgs/tagaspi/default.nix { };
|
||||
tampi = callPackage ./pkgs/tampi/default.nix { };
|
||||
upc-qaire-exporter = prev.callPackage ./pkgs/upc-qaire-exporter/default.nix { };
|
||||
taopencl = callPackage ./pkgs/taopencl/default.nix { };
|
||||
wxparaver = callPackage ./pkgs/paraver/default.nix { };
|
||||
|
||||
gromacs = callPackage ./pkgs/gromacs/default.nix { enableSYCL = true; };
|
||||
|
||||
_cuda = prev._cuda.extend (_: _prev: final.lib.recursiveUpdate _prev {
|
||||
extensions = _prev.extensions ++ [(finalAttrs: _: {
|
||||
tacuda = finalAttrs.callPackage ./pkgs/tacuda/default.nix { };
|
||||
})];
|
||||
});
|
||||
};
|
||||
|
||||
tests = rec {
|
||||
@@ -107,13 +96,6 @@ let
|
||||
clangNosvOmpv-ld = callPackage ./test/compilers/clang-openmp-ld.nix {
|
||||
stdenv = final.stdenvClangOmpss2NodesOmpv;
|
||||
};
|
||||
|
||||
ocl-build = callPackage ./test/compilers/opencl.nix { };
|
||||
ocl-build-noicd = callPackage ./test/compilers/opencl.nix { ocl-icd = final.pocl-noicd; };
|
||||
|
||||
pocl = callPackage ./test/compilers/pocl.nix { };
|
||||
ocl-run-pocl = ocl-build.test-icd;
|
||||
ocl-run-pocl-noicd = ocl-build-noicd.test-noicd;
|
||||
};
|
||||
|
||||
# For now, only build toplevel packages in CI/Hydra
|
||||
|
||||
@@ -1,190 +0,0 @@
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
fetchurl,
|
||||
cmake,
|
||||
hwloc,
|
||||
fftw,
|
||||
perl,
|
||||
blas,
|
||||
lapack,
|
||||
llvmPackages,
|
||||
intelPackages ? null,
|
||||
mpi,
|
||||
cudaPackages,
|
||||
plumed,
|
||||
singlePrec ? true,
|
||||
config,
|
||||
enableSYCL ? false,
|
||||
enableCuda ? config.cudaSupport,
|
||||
enableMpi ? false,
|
||||
enablePlumed ? false,
|
||||
cpuAcceleration ? null,
|
||||
}:
|
||||
|
||||
# CUDA is only implemented for single precission
|
||||
assert enableCuda -> singlePrec;
|
||||
|
||||
assert !(enableSYCL && enableCuda);
|
||||
|
||||
assert enableSYCL -> intelPackages != null;
|
||||
|
||||
let
|
||||
inherit (cudaPackages.flags) cmakeCudaArchitecturesString;
|
||||
|
||||
# Select reasonable defaults for all major platforms
|
||||
# The possible values are defined in CMakeLists.txt:
|
||||
# AUTO None SSE2 SSE4.1 AVX_128_FMA AVX_256 AVX2_256
|
||||
# AVX2_128 AVX_512 AVX_512_KNL MIC ARM_NEON ARM_NEON_ASIMD
|
||||
SIMD =
|
||||
x:
|
||||
if (cpuAcceleration != null) then
|
||||
x
|
||||
else if stdenv.hostPlatform.system == "i686-linux" then
|
||||
"SSE2"
|
||||
else if stdenv.hostPlatform.system == "x86_64-linux" then
|
||||
"SSE4.1"
|
||||
else if stdenv.hostPlatform.system == "x86_64-darwin" then
|
||||
"SSE4.1"
|
||||
else if stdenv.hostPlatform.system == "aarch64-linux" then
|
||||
"ARM_NEON_ASIMD"
|
||||
else
|
||||
"None";
|
||||
|
||||
source =
|
||||
if enablePlumed then
|
||||
{
|
||||
version = "2024.2";
|
||||
hash = "sha256-gCp+M18uiVdw9XsVnk7DaOuw/yzm2sz3BsboAlw2hSs=";
|
||||
}
|
||||
else
|
||||
{
|
||||
version = "2025.3";
|
||||
hash = "sha256-i9/KAmjz8Qp8o8BuWbYvc+oCQgxnIRwP85EvMteDPGU=";
|
||||
};
|
||||
|
||||
stdenv' = if enableSYCL then intelPackages.stdenv else stdenv;
|
||||
|
||||
in
|
||||
stdenv'.mkDerivation rec {
|
||||
pname = "gromacs";
|
||||
version = source.version;
|
||||
|
||||
src = fetchurl {
|
||||
url = "ftp://ftp.gromacs.org/pub/gromacs/gromacs-${version}.tar.gz";
|
||||
inherit (source) hash;
|
||||
};
|
||||
|
||||
patches = [ (if enablePlumed then ./pkgconfig-2024.patch else ./pkgconfig-2025.patch) ];
|
||||
|
||||
postPatch = lib.optionalString enablePlumed ''
|
||||
plumed patch -p -e gromacs-${source.version}
|
||||
'';
|
||||
|
||||
outputs = [
|
||||
"out"
|
||||
"dev"
|
||||
"man"
|
||||
];
|
||||
|
||||
nativeBuildInputs = [
|
||||
cmake
|
||||
]
|
||||
++ lib.optional enablePlumed plumed
|
||||
++ lib.optionals enableCuda [ cudaPackages.cuda_nvcc ];
|
||||
|
||||
env.MKLROOT = intelPackages.mkl;
|
||||
|
||||
buildInputs = [
|
||||
fftw
|
||||
perl
|
||||
hwloc
|
||||
blas
|
||||
lapack
|
||||
]
|
||||
++ lib.optional enableMpi mpi
|
||||
++ lib.optionals enableCuda [
|
||||
cudaPackages.cuda_cccl
|
||||
cudaPackages.cuda_cudart
|
||||
cudaPackages.libcufft
|
||||
cudaPackages.cuda_profiler_api
|
||||
]
|
||||
++ lib.optional stdenv.hostPlatform.isDarwin llvmPackages.openmp;
|
||||
|
||||
propagatedBuildInputs = lib.optional enableMpi mpi;
|
||||
propagatedUserEnvPkgs = lib.optional enableMpi mpi;
|
||||
|
||||
cmakeFlags = [
|
||||
(lib.cmakeBool "GMX_HWLOC" true)
|
||||
"-DGMX_SIMD:STRING=${SIMD cpuAcceleration}"
|
||||
"-DGMX_OPENMP:BOOL=TRUE"
|
||||
"-DBUILD_SHARED_LIBS=ON"
|
||||
]
|
||||
++ (
|
||||
if singlePrec then
|
||||
[
|
||||
"-DGMX_DOUBLE=OFF"
|
||||
]
|
||||
else
|
||||
[
|
||||
"-DGMX_DOUBLE=ON"
|
||||
"-DGMX_DEFAULT_SUFFIX=OFF"
|
||||
]
|
||||
)
|
||||
++ (
|
||||
if enableMpi then
|
||||
[
|
||||
"-DGMX_MPI:BOOL=TRUE"
|
||||
"-DGMX_THREAD_MPI:BOOL=FALSE"
|
||||
]
|
||||
else
|
||||
[
|
||||
"-DGMX_MPI:BOOL=FALSE"
|
||||
]
|
||||
)
|
||||
++ (lib.optionals enableSYCL [
|
||||
"-DGMX_GPU=SYCL"
|
||||
"-DGMX_OPENMP=OFF" # TODO: enable OpenMP with SYCL?
|
||||
])
|
||||
++ lib.optionals enableCuda [
|
||||
"-DGMX_GPU=CUDA"
|
||||
(lib.cmakeFeature "CMAKE_CUDA_ARCHITECTURES" cmakeCudaArchitecturesString)
|
||||
|
||||
# Gromacs seems to ignore and override the normal variables, so we add this ad hoc:
|
||||
(lib.cmakeFeature "GMX_CUDA_TARGET_COMPUTE" cmakeCudaArchitecturesString)
|
||||
];
|
||||
|
||||
postInstall = ''
|
||||
moveToOutput share/cmake $dev
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
homepage = "https://www.gromacs.org";
|
||||
license = licenses.lgpl21Plus;
|
||||
description = "Molecular dynamics software package";
|
||||
longDescription = ''
|
||||
GROMACS is a versatile package to perform molecular dynamics,
|
||||
i.e. simulate the Newtonian equations of motion for systems
|
||||
with hundreds to millions of particles.
|
||||
|
||||
It is primarily designed for biochemical molecules like
|
||||
proteins, lipids and nucleic acids that have a lot of
|
||||
complicated bonded interactions, but since GROMACS is
|
||||
extremely fast at calculating the nonbonded interactions (that
|
||||
usually dominate simulations) many groups are also using it
|
||||
for research on non-biological systems, e.g. polymers.
|
||||
|
||||
GROMACS supports all the usual algorithms you expect from a
|
||||
modern molecular dynamics implementation, (check the online
|
||||
reference or manual for details), but there are also quite a
|
||||
few features that make it stand out from the competition.
|
||||
|
||||
See: https://www.gromacs.org/about.html for details.
|
||||
'';
|
||||
platforms = platforms.unix;
|
||||
maintainers = with maintainers; [
|
||||
sheepforce
|
||||
markuskowa
|
||||
];
|
||||
};
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
diff --git a/src/external/muparser/muparser.pc.in b/src/external/muparser/muparser.pc.in
|
||||
index 646787cb53..9b97ad57f7 100644
|
||||
--- a/src/external/muparser/muparser.pc.in
|
||||
+++ b/src/external/muparser/muparser.pc.in
|
||||
@@ -1,7 +1,5 @@
|
||||
-prefix=@CMAKE_INSTALL_PREFIX@
|
||||
-exec_prefix=${prefix}
|
||||
-libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
|
||||
-includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
|
||||
+libdir=@CMAKE_INSTALL_FULL_LIBDIR@
|
||||
+includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
|
||||
|
||||
Name: @PACKAGE_NAME@
|
||||
Description: Mathematical expressions parser library
|
||||
diff --git a/src/gromacs/libgromacs.pc.cmakein b/src/gromacs/libgromacs.pc.cmakein
|
||||
index ec1ed6684e..ca1105474a 100644
|
||||
--- a/src/gromacs/libgromacs.pc.cmakein
|
||||
+++ b/src/gromacs/libgromacs.pc.cmakein
|
||||
@@ -1,4 +1,4 @@
|
||||
-libdir=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@
|
||||
+libdir=@CMAKE_INSTALL_FULL_LIBDIR@
|
||||
|
||||
Name: libgromacs@GMX_LIBS_SUFFIX@
|
||||
Description: Gromacs library
|
||||
@@ -1,36 +0,0 @@
|
||||
diff --git a/src/external/muparser/muparser.pc.in b/src/external/muparser/muparser.pc.in
|
||||
index 646787cb53..d26e84de8f 100644
|
||||
--- a/src/external/muparser/muparser.pc.in
|
||||
+++ b/src/external/muparser/muparser.pc.in
|
||||
@@ -1,11 +1,9 @@
|
||||
-prefix=@CMAKE_INSTALL_PREFIX@
|
||||
-exec_prefix=${prefix}
|
||||
-libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
|
||||
-includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
|
||||
-
|
||||
-Name: @PACKAGE_NAME@
|
||||
-Description: Mathematical expressions parser library
|
||||
-Version: @MUPARSER_VERSION@
|
||||
-Requires:
|
||||
-Libs: -L${libdir} -lmuparser
|
||||
-Cflags: -I${includedir} @PKG_CONFIG_FLAGS@
|
||||
+libdir=@CMAKE_INSTALL_FULL_LIBDIR@
|
||||
+includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
|
||||
+
|
||||
+Name: @PACKAGE_NAME@
|
||||
+Description: Mathematical expressions parser library
|
||||
+Version: @MUPARSER_VERSION@
|
||||
+Requires:
|
||||
+Libs: -L${libdir} -lmuparser
|
||||
+Cflags: -I${includedir} @PKG_CONFIG_FLAGS@
|
||||
diff --git a/src/gromacs/libgromacs.pc.cmakein b/src/gromacs/libgromacs.pc.cmakein
|
||||
index af9b5a6dc0..5f58d549bf 100644
|
||||
--- a/src/gromacs/libgromacs.pc.cmakein
|
||||
+++ b/src/gromacs/libgromacs.pc.cmakein
|
||||
@@ -1,5 +1,4 @@
|
||||
-prefix=@CMAKE_INSTALL_PREFIX@
|
||||
-libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
|
||||
+libdir=@CMAKE_INSTALL_FULL_LIBDIR@
|
||||
|
||||
Name: libgromacs@GMX_LIBS_SUFFIX@
|
||||
Description: Gromacs library
|
||||
@@ -1,26 +0,0 @@
|
||||
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
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
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
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
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
|
||||
|
||||
@@ -1,255 +0,0 @@
|
||||
{
|
||||
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,
|
||||
writeText,
|
||||
runCommand,
|
||||
opencl-cts,
|
||||
|
||||
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,
|
||||
|
||||
onetbb,
|
||||
enableTBB ? false,
|
||||
|
||||
nosv ? null,
|
||||
ovni ? null,
|
||||
enableNOSV ? useGit,
|
||||
enableOVNI ? useGit,
|
||||
|
||||
buildPackages,
|
||||
targetPackages,
|
||||
nix-update-script,
|
||||
}:
|
||||
|
||||
assert (enableNOSV || enableOVNI) -> useGit;
|
||||
|
||||
let
|
||||
|
||||
release = rec {
|
||||
version = "7.1";
|
||||
src = fetchFromGitHub {
|
||||
owner = "pocl";
|
||||
repo = "pocl";
|
||||
tag = "v${version}";
|
||||
hash = "sha256-bS6vTIjLO7YLs7qYLKW0cYYbEJ/hRS/+IjjAKbkj8ac=";
|
||||
};
|
||||
};
|
||||
|
||||
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 = [
|
||||
# TODO: all these are broken when cross compiling. Upstream has refactored
|
||||
# all the cmake infra for cross compilation, but it's not in a release yet
|
||||
(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" true)
|
||||
(lib.cmakeBool "POCL_ICD_ABSOLUTE_PATH" true)
|
||||
|
||||
(lib.cmakeBool "ENABLE_TBB_DEVICE" enableTBB)
|
||||
(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 (enableNOSV || enableOVNI) [
|
||||
(lib.cmakeBool "ENABLE_NOSV" enableNOSV)
|
||||
(lib.cmakeBool "ENABLE_OVNI" enableOVNI)
|
||||
]
|
||||
++ 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 "${targetPackages.stdenv.cc}/nix-support/cc-ldflags")}"
|
||||
-DEXTRA_KERNEL_FLAGS="${lib.escapeShellArg (builtins.readFile "${targetPackages.stdenv.cc}/nix-support/cc-ldflags")}"
|
||||
)
|
||||
'';
|
||||
|
||||
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 [ onetbb ]
|
||||
++ lib.optionals enableICD [ ocl-icd ]
|
||||
++ lib.optionals enableLTTNG [ lttng-ust ]
|
||||
++ lib.optionals enableSPIRV [
|
||||
(spirv-llvm-translator.override { inherit (llvmPackages) llvm; })
|
||||
spirv-tools
|
||||
];
|
||||
|
||||
nativeInstallCheckInputs = [
|
||||
writableTmpDirAsHomeHook # needed for POCL_CACHE_DIR
|
||||
];
|
||||
|
||||
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 = lib.optionalDrvAttr enableICD (
|
||||
writeText "setup-hook" ''
|
||||
addToSearchPath OCL_ICD_VENDORS @out@/etc/OpenCL/vendors
|
||||
''
|
||||
);
|
||||
|
||||
passthru =
|
||||
let
|
||||
self = finalAttrs.finalPackage;
|
||||
in
|
||||
{
|
||||
updateScript = nix-update-script { };
|
||||
git = self.override { useGit = true; };
|
||||
|
||||
withICD = enableICD;
|
||||
|
||||
test = {
|
||||
# Run builtin tests (causes a rebuild)
|
||||
self = self.overrideAttrs { doCheck = true; };
|
||||
|
||||
# Run basic test from Khronos OpenCL Conformance Test Suite
|
||||
# WARN: despite its name, test_basic is very exhaustive, and can take more
|
||||
# than 1 hour in a marenostrum5 node.
|
||||
cts =
|
||||
assert enableICD;
|
||||
lib.genAttrs [ "api" "basic" "c11_atomics" "printf" "svm" ] (
|
||||
name:
|
||||
runCommand "pocl-cts-test_${name}" {
|
||||
nativeBuildInputs = [ self ];
|
||||
requiredSystemFeatures = [ "sys-devices" ];
|
||||
env = {
|
||||
POCL_DEBUG = "error,warn";
|
||||
POCL_CACHE_DIR = "/build/pocl_cache";
|
||||
};
|
||||
} "${opencl-cts}/bin/Release/test_${name} | tee $out"
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
env.HWLOC_SYNTHETIC = lib.optionalDrvAttr enableHWLOC "node:1 core:1 pu:1";
|
||||
|
||||
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;
|
||||
};
|
||||
})
|
||||
@@ -1,72 +0,0 @@
|
||||
{
|
||||
backendStdenv,
|
||||
fetchFromGitHub,
|
||||
automake,
|
||||
autoconf,
|
||||
libtool,
|
||||
gnumake,
|
||||
autoreconfHook,
|
||||
boost,
|
||||
cudatoolkit,
|
||||
libcublas,
|
||||
cuda_cudart,
|
||||
|
||||
useGit ? false,
|
||||
gitUrl ? "git@gitlab-internal.bsc.es:task-awareness/tacuda/tacuda.git",
|
||||
gitBranch ? "main",
|
||||
gitCommit ? "35234f9445e6149a2bd38d119841e2485d6ee05e",
|
||||
}:
|
||||
|
||||
let
|
||||
|
||||
release_ver = "2.1.0";
|
||||
release = {
|
||||
version = release_ver;
|
||||
src = fetchFromGitHub {
|
||||
owner = "bsc-pm";
|
||||
repo = "tacuda";
|
||||
rev = release_ver;
|
||||
hash = "sha256-Cj3EiLVJSLvRv0ydeg7Vp4SpkniEqHkcWF+YOJQ8EcM=";
|
||||
};
|
||||
};
|
||||
|
||||
git = rec {
|
||||
version = src.shortRev;
|
||||
src = builtins.fetchGit {
|
||||
url = gitUrl;
|
||||
ref = gitBranch;
|
||||
rev = gitCommit;
|
||||
};
|
||||
};
|
||||
|
||||
source = if (useGit) then git else release;
|
||||
|
||||
in
|
||||
|
||||
backendStdenv.mkDerivation {
|
||||
pname = "tacuda";
|
||||
inherit (source) src version;
|
||||
|
||||
enableParallelBuilding = true;
|
||||
separateDebugInfo = true;
|
||||
strictDeps = true;
|
||||
|
||||
nativeBuildInputs = [
|
||||
autoreconfHook
|
||||
automake
|
||||
autoconf
|
||||
libtool
|
||||
gnumake
|
||||
];
|
||||
|
||||
patches = [ ./fix_config.patch ];
|
||||
|
||||
configureFlags = [ "--with-cuda-include=${cudatoolkit}/include" ];
|
||||
|
||||
buildInputs = [
|
||||
boost
|
||||
libcublas
|
||||
cuda_cudart
|
||||
];
|
||||
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
diff --git a/m4/cuda.m4 b/m4/cuda.m4
|
||||
index 23f5c94..8f9b534 100644
|
||||
--- a/m4/cuda.m4
|
||||
+++ b/m4/cuda.m4
|
||||
@@ -40,7 +40,7 @@ search_libs="cuda cublas cudart"
|
||||
required_libs=""
|
||||
|
||||
m4_foreach([function],
|
||||
- [cuInit,
|
||||
+ [
|
||||
cublasSgemm,
|
||||
cudaStreamCreate,
|
||||
cudaLaunchKernel,
|
||||
@@ -1,46 +0,0 @@
|
||||
{
|
||||
stdenv,
|
||||
automake,
|
||||
autoconf,
|
||||
libtool,
|
||||
gnumake,
|
||||
boost,
|
||||
mpi,
|
||||
gcc,
|
||||
autoreconfHook,
|
||||
ocl-icd,
|
||||
opencl-headers,
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "taopencl";
|
||||
version = finalAttrs.src.shortRev;
|
||||
|
||||
src = builtins.fetchGit {
|
||||
url = "git@gitlab-internal.bsc.es:task-awareness/taopencl/taopencl.git";
|
||||
ref = "master";
|
||||
rev = "c3b7b32ae8fa4af7ceff598532a881f8f1490aaf";
|
||||
};
|
||||
|
||||
enableParallelBuilding = true;
|
||||
separateDebugInfo = true;
|
||||
|
||||
configureFlags = [
|
||||
"--with-opencl-lib=${ocl-icd}/lib"
|
||||
"--with-opencl-include=${opencl-headers}/include"
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
autoreconfHook
|
||||
automake
|
||||
autoconf
|
||||
libtool
|
||||
gnumake
|
||||
boost
|
||||
mpi
|
||||
gcc
|
||||
];
|
||||
|
||||
dontDisableStatic = true;
|
||||
hardeningDisable = [ "all" ];
|
||||
})
|
||||
@@ -1,127 +0,0 @@
|
||||
#include <CL/cl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define BUF_LEN 128
|
||||
|
||||
cl_int exit_err = CL_SUCCESS;
|
||||
|
||||
#define CHECK(cmd) \
|
||||
do { \
|
||||
cl_int err = cmd; \
|
||||
if (err != CL_SUCCESS) { \
|
||||
printf("[ERROR] " #cmd " (Error code: %d)\n" \
|
||||
"@ "__FILE__ \
|
||||
":%d", \
|
||||
err, __LINE__); \
|
||||
exit_err = err; \
|
||||
goto cleanup; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
const char *kernel_source = "__kernel void vector_add(__global const float *a, "
|
||||
"__global const float *b, __global float *c) {\n"
|
||||
" int gid = get_global_id(0);\n"
|
||||
" c[gid] = a[gid] + b[gid];\n"
|
||||
"}\n";
|
||||
|
||||
cl_int test_kernel_compilation(cl_platform_id platform) {
|
||||
cl_device_id device = NULL;
|
||||
cl_context context = NULL;
|
||||
cl_program program = NULL;
|
||||
cl_int err = CL_SUCCESS;
|
||||
char device_name[BUF_LEN];
|
||||
|
||||
// Get first device for this platform
|
||||
CHECK(clGetDeviceIDs(platform, CL_DEVICE_TYPE_ALL, 1, &device, NULL));
|
||||
|
||||
// Get device name
|
||||
CHECK(clGetDeviceInfo(device, CL_DEVICE_NAME, sizeof(device_name),
|
||||
device_name, NULL));
|
||||
printf(" Device: %s\n", device_name);
|
||||
|
||||
context = clCreateContext(NULL, 1, &device, NULL, NULL, &err);
|
||||
CHECK(err);
|
||||
|
||||
program = clCreateProgramWithSource(context, 1, &kernel_source, NULL, &err);
|
||||
CHECK(err);
|
||||
|
||||
err = clBuildProgram(program, 1, &device, NULL, NULL, NULL);
|
||||
if (err != CL_SUCCESS) {
|
||||
printf(" [ERROR] Kernel compilation failed (Error code: %d)\n", err);
|
||||
|
||||
// Build log
|
||||
size_t log_size;
|
||||
CHECK(clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG, 0, NULL,
|
||||
&log_size));
|
||||
char *log = (char *)malloc(log_size);
|
||||
CHECK(clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG, log_size,
|
||||
log, NULL));
|
||||
printf(" Build log:\n%s\n", log);
|
||||
free(log);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
printf(" [OK] Kernel compiled successfully!\n");
|
||||
|
||||
cleanup:
|
||||
if (program)
|
||||
clReleaseProgram(program);
|
||||
if (context)
|
||||
clReleaseContext(context);
|
||||
printf("\n");
|
||||
|
||||
return exit_err;
|
||||
}
|
||||
|
||||
int main() {
|
||||
cl_uint num_platforms;
|
||||
cl_platform_id *platforms = NULL;
|
||||
|
||||
// Get number of platforms
|
||||
CHECK(clGetPlatformIDs(0, NULL, &num_platforms));
|
||||
|
||||
printf("Found %d OpenCL platform(s)\n\n", num_platforms);
|
||||
|
||||
if (num_platforms == 0) {
|
||||
printf("No OpenCL platforms found!\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// Allocate memory for platforms
|
||||
platforms = (cl_platform_id *)malloc(sizeof(cl_platform_id) * num_platforms);
|
||||
|
||||
// Get platform IDs
|
||||
CHECK(clGetPlatformIDs(num_platforms, platforms, NULL));
|
||||
|
||||
// Query each platform and test kernel compilation
|
||||
for (cl_uint i = 0; i < num_platforms; i++) {
|
||||
char platform_name[BUF_LEN];
|
||||
char platform_vendor[BUF_LEN];
|
||||
char platform_version[BUF_LEN];
|
||||
|
||||
CHECK(clGetPlatformInfo(platforms[i], CL_PLATFORM_NAME,
|
||||
sizeof(platform_name), platform_name, NULL));
|
||||
CHECK(clGetPlatformInfo(platforms[i], CL_PLATFORM_VENDOR,
|
||||
sizeof(platform_vendor), platform_vendor, NULL));
|
||||
CHECK(clGetPlatformInfo(platforms[i], CL_PLATFORM_VERSION,
|
||||
sizeof(platform_version), platform_version, NULL));
|
||||
|
||||
printf("Platform %d: %s\n", i, platform_name);
|
||||
printf(" Vendor: %s\n", platform_vendor);
|
||||
printf(" Version: %s\n", platform_version);
|
||||
|
||||
// Test kernel compilation
|
||||
CHECK(test_kernel_compilation(platforms[i]));
|
||||
}
|
||||
|
||||
cleanup:
|
||||
if (platforms)
|
||||
free(platforms);
|
||||
|
||||
if (exit_err == CL_SUCCESS)
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
{
|
||||
stdenv,
|
||||
ocl-icd,
|
||||
opencl-headers,
|
||||
pocl,
|
||||
clinfo,
|
||||
runCommand,
|
||||
lib,
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "opencl-pocl-test";
|
||||
version = "1.0.0";
|
||||
|
||||
src = ./opencl.c;
|
||||
|
||||
dontUnpack = true;
|
||||
dontConfigure = true;
|
||||
|
||||
buildInputs = [
|
||||
ocl-icd
|
||||
opencl-headers
|
||||
];
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
$CC -Wall -Wextra -D CL_TARGET_OPENCL_VERSION=100 $src -o ocl-hello -lOpenCL
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/bin
|
||||
cp ocl-hello $out/bin
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
passthru = {
|
||||
test-icd =
|
||||
runCommand "custom-clinfo"
|
||||
{
|
||||
nativeBuildInputs =
|
||||
assert !(lib.hasPrefix "pocl" ocl-icd.pname);
|
||||
[
|
||||
clinfo
|
||||
finalAttrs.finalPackage
|
||||
pocl
|
||||
];
|
||||
|
||||
env = {
|
||||
POCL_DEBUG = "error,warn";
|
||||
POCL_CACHE_DIR = "/build/pocl_cache";
|
||||
};
|
||||
|
||||
requiredSystemFeatures = [ "sys-devices" ];
|
||||
}
|
||||
|
||||
''
|
||||
set -x
|
||||
|
||||
mkdir $out
|
||||
|
||||
clinfo -l >$out/clinfo
|
||||
clinfo >$out/clinfo-full
|
||||
|
||||
ocl-hello >$out/hello
|
||||
|
||||
for i in $out/*; do
|
||||
grep "Portable Computing Language" $i
|
||||
done
|
||||
|
||||
echo $OCL_ICD_VENDORS >$out/env
|
||||
|
||||
grep "pocl.*/etc/OpenCL/vendors" $out/env
|
||||
|
||||
set +x
|
||||
'';
|
||||
# this needs: ocl-icd = pocl-noicd
|
||||
test-noicd =
|
||||
runCommand "custom-clinfo"
|
||||
{
|
||||
nativeBuildInputs = [
|
||||
finalAttrs.finalPackage
|
||||
];
|
||||
|
||||
env = {
|
||||
POCL_DEBUG = "error,warn";
|
||||
POCL_CACHE_DIR = "/build/pocl_cache";
|
||||
};
|
||||
|
||||
requiredSystemFeatures = [ "sys-devices" ];
|
||||
}
|
||||
|
||||
''
|
||||
ocl-hello >$out
|
||||
|
||||
grep "Portable Computing Language" $out
|
||||
'';
|
||||
};
|
||||
})
|
||||
@@ -1,27 +0,0 @@
|
||||
{
|
||||
runCommand,
|
||||
pocl,
|
||||
clinfo,
|
||||
}:
|
||||
|
||||
runCommand "clinfo-pocl"
|
||||
{
|
||||
nativeBuildInputs = [
|
||||
clinfo
|
||||
pocl
|
||||
];
|
||||
|
||||
requiredSystemFeatures = [ "sys-devices" ];
|
||||
|
||||
env = {
|
||||
POCL_DEBUG = "error,warn";
|
||||
POCL_CACHE_DIR = "/build/pocl_cache";
|
||||
};
|
||||
}
|
||||
''
|
||||
echo $OCL_ICD_VENDORS
|
||||
clinfo >$out
|
||||
|
||||
# check that we have PoCL:
|
||||
grep "Portable Computing Language" $out
|
||||
''
|
||||
Reference in New Issue
Block a user