summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--pkgs/applications/science/computer-architecture/accelergy/default.nix27
-rw-r--r--pkgs/applications/science/computer-architecture/timeloop/default.nix99
-rw-r--r--pkgs/top-level/all-packages.nix4
3 files changed, 130 insertions, 0 deletions
diff --git a/pkgs/applications/science/computer-architecture/accelergy/default.nix b/pkgs/applications/science/computer-architecture/accelergy/default.nix
new file mode 100644
index 0000000000000..ec702d2b2906e
--- /dev/null
+++ b/pkgs/applications/science/computer-architecture/accelergy/default.nix
@@ -0,0 +1,27 @@
+{ lib, fetchFromGitHub, python3Packages, pkgs }:
+
+python3Packages.buildPythonApplication rec {
+  pname = "accelergy";
+  version = "unstable-2022-05-03";
+
+  src = fetchFromGitHub {
+    owner = "Accelergy-Project";
+    repo = "accelergy";
+    rev = "34df8e87a889ae55cecba58992d4573466b40565";
+    hash = "sha256-SRtt1EocHy5fKszpoumC+mOK/qhreoA2/Ff1wcu5WKo=";
+  };
+
+  propagatedBuildInputs = with python3Packages; [
+    pyyaml
+    yamlordereddictloader
+    pyfiglet
+    setuptools
+  ];
+
+  meta = with lib; {
+    description = "An architecture-level energy/area estimator for accelerator designs";
+    license = licenses.mit;
+    homepage = "https://accelergy.mit.edu/";
+    maintainers = with maintainers; [ gdinh ];
+  };
+}
diff --git a/pkgs/applications/science/computer-architecture/timeloop/default.nix b/pkgs/applications/science/computer-architecture/timeloop/default.nix
new file mode 100644
index 0000000000000..e1ed24be78350
--- /dev/null
+++ b/pkgs/applications/science/computer-architecture/timeloop/default.nix
@@ -0,0 +1,99 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, scons
+, libconfig
+, boost
+, libyaml
+, libyamlcpp
+, ncurses
+, gpm
+, enableAccelergy ? true
+, enableISL ? false
+, accelergy
+}:
+
+stdenv.mkDerivation rec {
+  pname = "timeloop";
+  version = "unstable-2022-11-29";
+
+  src = fetchFromGitHub {
+    owner = "NVlabs";
+    repo = "timeloop";
+    rev = "905ba953432c812772de935d57fd0a674a89d3c1";
+    hash = "sha256-EXiWXf8hdX4vFRNk9wbFSOsix/zVkwrafGUtFrsoAN0=";
+  };
+
+  nativeBuildInputs = [ scons ];
+
+  buildInputs = [
+    libconfig
+    boost
+    libyaml
+    libyamlcpp
+    ncurses
+    accelergy
+   ] ++ lib.optionals stdenv.isLinux [ gpm ];
+
+  preConfigure = ''
+    cp -r ./pat-public/src/pat ./src/pat
+  '';
+
+  enableParallelBuilding = true;
+
+  #link-time optimization fails on darwin
+  #see https://github.com/NixOS/nixpkgs/issues/19098
+  NIX_CFLAGS_COMPILE = lib.optional stdenv.isDarwin "-fno-lto";
+
+  postPatch = ''
+    # use nix ar/ranlib
+    substituteInPlace ./SConstruct \
+      --replace "env.Replace(AR = \"gcc-ar\")" "" \
+      --replace "env.Replace(RANLIB = \"gcc-ranlib\")" ""
+    '' + lib.optionalString stdenv.isDarwin ''
+    # prevent clang from dying on errors that gcc is fine with
+    substituteInPlace ./src/SConscript --replace "-Werror" "-Wno-inconsistent-missing-override"
+
+    # disable LTO on macos
+    substituteInPlace ./src/SConscript --replace ", '-flto'" ""
+
+    # static builds on mac fail as no static libcrt is provided by apple
+    # see https://stackoverflow.com/questions/3801011/ld-library-not-found-for-lcrt0-o-on-osx-10-6-with-gcc-clang-static-flag
+    substituteInPlace ./src/SConscript \
+      --replace "'-static-libgcc', " "" \
+      --replace "'-static-libstdc++', " "" \
+      --replace "'-Wl,--whole-archive', '-static', " "" \
+      --replace ", '-Wl,--no-whole-archive'" ""
+
+    #remove hardcoding of gcc
+    sed -i '40i env.Replace(CC = "${stdenv.cc.targetPrefix}cc")' ./SConstruct
+    sed -i '40i env.Replace(CXX = "${stdenv.cc.targetPrefix}c++")' ./SConstruct
+
+    #gpm doesn't exist on darwin
+    substituteInPlace ./src/SConscript --replace ", 'gpm'" ""
+   '';
+
+  sconsFlags =
+    # will fail on clang/darwin on link without --static due to undefined extern
+    # however, will fail with static on linux as nixpkgs deps aren't static
+    lib.optional stdenv.isDarwin "--static"
+    ++ lib.optional enableAccelergy "--accelergy"
+    ++ lib.optional enableISL "--with-isl";
+
+
+  installPhase = ''
+    cp -r ./bin ./lib $out
+    mkdir -p $out/share
+    cp -r ./doc $out/share
+    mkdir -p $out/data
+    cp -r ./problem-shapes ./configs $out/data
+   '';
+
+  meta = with lib; {
+    description = "Chip modeling/mapping benchmarking framework";
+    homepage = "https://timeloop.csail.mit.edu";
+    license = licenses.bsd3;
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ gdinh ];
+  };
+}
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 172ba6fd737b0..9b7c317492e8e 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -2433,6 +2433,8 @@ with pkgs;
 
   twine = with python3Packages; toPythonApplication twine;
 
+  accelergy = callPackage ../applications/science/computer-architecture/accelergy { };
+
   aldo = callPackage ../applications/radio/aldo { };
 
   alglib = callPackage ../development/libraries/alglib { };
@@ -37229,6 +37231,8 @@ with pkgs;
 
   shellz = callPackage ../tools/security/shellz { };
 
+  timeloop = pkgs.darwin.apple_sdk_11_0.callPackage ../applications/science/computer-architecture/timeloop { };
+
   canon-cups-ufr2 = callPackage ../misc/cups/drivers/canon { };
 
   hll2390dw-cups = callPackage ../misc/cups/drivers/hll2390dw-cups { };