From 4ced6a91caf8d9ddc1a40d57d0df648e09cb6ae2 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Date: Mon, 29 Aug 2022 10:38:24 +0200 Subject: [PATCH] Prepare nix build for nanos6 rt tests --- nix/0001-Emit-a-fill-event-at-shutdown.patch | 29 ++++++ nix/nanos6.nix | 93 ++++++++++++++++++++ nix/ovni.nix | 32 +++++++ 3 files changed, 154 insertions(+) create mode 100644 nix/0001-Emit-a-fill-event-at-shutdown.patch create mode 100644 nix/nanos6.nix create mode 100644 nix/ovni.nix diff --git a/nix/0001-Emit-a-fill-event-at-shutdown.patch b/nix/0001-Emit-a-fill-event-at-shutdown.patch new file mode 100644 index 0000000..a5e40d1 --- /dev/null +++ b/nix/0001-Emit-a-fill-event-at-shutdown.patch @@ -0,0 +1,29 @@ +From abeed615777690ba748f64bdb72a35fe5311259b Mon Sep 17 00:00:00 2001 +From: Rodrigo Arias +Date: Thu, 25 Aug 2022 16:36:38 +0200 +Subject: [PATCH] Emit a fill event at shutdown + +--- + src/instrument/ovni/InstrumentThreadManagement.cpp | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/src/instrument/ovni/InstrumentThreadManagement.cpp b/src/instrument/ovni/InstrumentThreadManagement.cpp +index c79a9750..4872b2d9 100644 +--- a/src/instrument/ovni/InstrumentThreadManagement.cpp ++++ b/src/instrument/ovni/InstrumentThreadManagement.cpp +@@ -92,6 +92,12 @@ void Instrument::threadHasResumed(__attribute__((unused)) external_thread_id_t t + + void Instrument::threadWillShutdown() + { ++ ThreadLocalData &tld = getThreadLocalData(); ++ if (tld._hungry) { ++ tld._hungry = false; ++ Ovni::schedFill(); ++ } ++ + Ovni::threadEnd(); + } + +-- +2.36.1 + diff --git a/nix/nanos6.nix b/nix/nanos6.nix new file mode 100644 index 0000000..9da14cd --- /dev/null +++ b/nix/nanos6.nix @@ -0,0 +1,93 @@ +let + pkgs = import (builtins.fetchTarball + "https://pm.bsc.es/gitlab/rarias/bscpkgs/-/archive/master/bscpkgs-master.tar.gz"); + + rWrapper = pkgs.rWrapper.override { + packages = with pkgs.rPackages; [ tidyverse rjson jsonlite egg viridis ]; + }; + + # Recursively set MPI + bsc = pkgs.bsc.extend (last: prev: { + mpi = last.impi; + #mpi = last.openmpi; + + nanos6 = (prev.nanos6Git.override { + gitUrl = "ssh://git@bscpm03.bsc.es/nanos6/forks/nanos6-extern-001.git"; + gitBranch = "ovni_instr"; + extrae = null; + }).overrideAttrs (old: { + buildInputs = old.buildInputs ++ [ last.ovni ]; + patches = [ ./0001-Emit-a-fill-event-at-shutdown.patch ]; + configureFlags = old.configureFlags ++ [ + "--with-ovni=${last.ovni}" + ]; + }); + + # Quick hack, as we only need the libovni runtime to match ours + nanos6' = /nix/store/zg989jl3mgdps7amdskna43hipb6snsq-nanos6-60fc5f2; + + ompss2 = { + clangUnwrapped = prev.clangOmpss2Unwrapped.overrideAttrs ( + old: + rec { + src = ../kk/llvm-mono-d3d4f2bf231b9461a5881c5bf56659516d45e670.tar.bz2; + #src = fetchTarball { + # url = ../kk/llvm-mono-d3d4f2bf231b9461a5881c5bf56659516d45e670.tar.bz2; + #}; + #builtins.fetchTree { + # type = "git"; + # url = "ssh://git@bscpm03.bsc.es/llvm-ompss/llvm-mono.git"; + # ref = "master"; + # # Master at 2022-07-26 + # rev = "d3d4f2bf231b9461a5881c5bf56659516d45e670"; + # shallow = true; + #}; + version = "d3d4f2bf"; + } + ); + + #clangUnwrapped = /nix/store/fg621rqj50x85gnsbh1pj304049yqlaq-clang-ompss2-d3d4f2b; + + clang = prev.clangOmpss2.override { + clangOmpss2Unwrapped = last.ompss2.clangUnwrapped; + }; + + #clang = /nix/store/qva7b665inxgg8wrfl2jf9dwzdp69sxq-clang-ompss2-wrapper-d3d4f2b; + + stdenv = pkgs.overrideCC pkgs.llvmPackages_11.stdenv bsc.ompss2.clang; + }; + + nosv = pkgs.stdenv.mkDerivation rec { + pname = "nosv"; + version = src.shortRev; + buildInputs = with pkgs; [ autoreconfHook pkg-config numactl last.ovni ]; + configureFlags = [ "--with-ovni=${last.ovni}" ]; + dontStrip = true; + src = builtins.fetchGit { + url = "ssh://git@gitlab-internal.bsc.es/nos-v/nos-v.git"; + ref = "master"; + }; + }; + + # Quick fix to avoid rebuilding every time the ovni source changes. + # Use this nosv' version below as dependency of ovni-rt + nosv' = /nix/store/rvnrbc7ibpw06jdilz6mha7szzxcr2mi-nosv-8936f3e; + + ovni = last.callPackage ./ovni.nix { }; + + ovni-rt = (last.ovni.override { + stdenv = last.ompss2.stdenv; + }).overrideAttrs (old: { + __impure = true; + __noChroot = true; + buildInputs = old.buildInputs ++ [ + last.nosv' + pkgs.strace + ]; + cmakeFlags = old.cmakeFlags ++ [ "-DBUILD_RT_TESTING=ON" ]; + }); + }); + +in + bsc.ovni-rt + #bsc.ompss2.clang diff --git a/nix/ovni.nix b/nix/ovni.nix new file mode 100644 index 0000000..e08e2e9 --- /dev/null +++ b/nix/ovni.nix @@ -0,0 +1,32 @@ +{ + stdenv +, cmake +, openmpi +}: + +stdenv.mkDerivation rec { + name = "ovni"; + + buildInputs = [ cmake openmpi ]; + + # Prevent accidental reutilization of previous builds, as we are taking the + # current directory as-is + preConfigure = '' + rm -rf build install + + # There is no /bin/bash + patchShebangs test/*.sh + ''; + + cmakeBuildType = "Debug"; + cmakeFlags = [ "-DCMAKE_SKIP_BUILD_RPATH=OFF" ]; + buildFlags = [ "VERBOSE=1" ]; + preCheck = '' + export CTEST_OUTPUT_ON_FAILURE=1 + ''; + dontStrip = true; + doCheck = true; + checkTarget = "test"; + + src = ../.; +}