Switched BLAS libraries; now works on Nix

This commit is contained in:
2023-01-30 15:30:01 +01:00
parent 462de223a4
commit e45fab1389
4 changed files with 156 additions and 53 deletions

18
flake.lock generated
View File

@@ -2,11 +2,11 @@
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1659877975,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"type": "github"
},
"original": {
@@ -17,16 +17,18 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1661704917,
"narHash": "sha256-h1deRhxLw9iaYzIovHT9mLFuZq/9hoge+pXSbX98B78=",
"lastModified": 1674641431,
"narHash": "sha256-qfo19qVZBP4qn5M5gXc/h1MDgAtPA5VxJm9s8RUAkVk=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "adf66cc31390f920854340679d7505ac577a5a8b",
"rev": "9b97ad7b4330aacda9b2343396eb3df8a853b4fc",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {

View File

@@ -1,32 +1,65 @@
{
description = "Flake utils demo";
description = "my project description";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let pkgs = nixpkgs.legacyPackages.${system}; in
{
packages = rec {
hello = pkgs.hello;
default = hello;
};
apps = rec {
hello = flake-utils.lib.mkApp { drv = self.packages.${system}.hello; };
default = hello;
};
devShell = pkgs.mkShell rec {
buildInputs = with pkgs; [
cabal-install
stack
haskell-language-server
ghc
let
pkgs = nixpkgs.legacyPackages.${system};
openblas
openblas.out
];
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs;
lapack = pkgs.amd-libflame.overrideAttrs (attrs: {
postInstall = attrs.postInstall + "\nln -s $out/lib/libflame.so.${attrs.version} $out/lib/liblapack.so";
});
hPkgs =
pkgs.haskell.packages."ghc925"; # need to match Stackage LTS version
# from stack.yaml resolver
clibs = with pkgs; [
amd-blis lapack
];
myDevTools = [
hPkgs.ghc # GHC compiler in the desired version (will be available on PATH)
hPkgs.ghcid # Continuous terminal Haskell compile checker
#hPkgs.ormolu # Haskell formatter
#hPkgs.hlint # Haskell codestyle checker
hPkgs.hoogle # Lookup Haskell documentation
#hPkgs.haskell-language-server # LSP server for editor
#hPkgs.implicit-hie # auto generate LSP hie.yaml file from cabal
#hPkgs.retrie # Haskell refactoring tool
# hPkgs.cabal-install
stack-wrapped
pkgs.ltrace
] ++ clibs;
# Wrap Stack to work with our Nix integration. We don't want to modify
# stack.yaml so non-Nix users don't notice anything.
# - no-nix: We don't want Stack's way of integrating Nix.
# --system-ghc # Use the existing GHC on PATH (will come from this Nix file)
# --no-install-ghc # Don't try to install GHC if no matching GHC found on PATH
stack-wrapped = pkgs.symlinkJoin {
name = "stack"; # will be available as the usual `stack` in terminal
paths = [ pkgs.stack ];
buildInputs = [ pkgs.makeWrapper ];
postBuild = ''
wrapProgram $out/bin/stack \
--add-flags "\
--no-nix \
--system-ghc \
--no-install-ghc \
"
'';
};
}
);
in {
devShells.default = pkgs.mkShell {
buildInputs = myDevTools;
# Make external Nix c libraries like zlib known to GHC, like
# pkgs.haskell.lib.buildStackProject does
# https://github.com/NixOS/nixpkgs/blob/d64780ea0e22b5f61cd6012a456869c702a72f20/pkgs/development/haskell-modules/generic-stack-builder.nix#L38
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath myDevTools;
};
});
}

View File

@@ -34,23 +34,24 @@ executable petzval-hs
-- LANGUAGE extensions used by modules in this package.
-- other-extensions:
build-depends: base ^>=4.15.1.0,
ad ^>=4.5.2,
linear ^>=1.21,
lens ^>=5.0,
criterion ^>=1.5,
hmatrix ^>= 0.20.2,
build-depends: base,
ad,
linear,
lens,
criterion,
hmatrix,
petzval-hs
hs-source-dirs: app
executable petzval-prof
import: base
main-is: Main.hs
build-depends: base ^>=4.15.1.0,
ad ^>=4.5.2,
linear ^>=1.21,
lens ^>=5.0,
criterion ^>=1.5,
build-depends: base,
ad,
linear,
lens,
criterion,
hmatrix,
petzval-hs
hs-source-dirs: app
ghc-options:
@@ -73,13 +74,13 @@ library
other-modules:
Petzval.Internal.Vec
hs-source-dirs: lib
build-depends: base ^>=4.15.1.0,
lens ^>=5.0,
ad ^>=4.5.2,
linear ^>=1.21,
reflection ^>=2.1,
mtl ^>=2.2,
deepseq ^>=1.4,
containers ^>=0.6.4.1,
monad-loops ^>= 0.4.3,
hmatrix ^>= 0.20.2
build-depends: base,
lens,
ad,
linear,
reflection,
mtl,
deepseq,
containers,
monad-loops,
hmatrix

67
stack.yaml Normal file
View File

@@ -0,0 +1,67 @@
# This file was automatically generated by 'stack init'
#
# Some commonly used options have been documented as comments in this file.
# For advanced use and comprehensive documentation of the format, please see:
# https://docs.haskellstack.org/en/stable/yaml_configuration/
# Resolver to choose a 'specific' stackage snapshot or a compiler version.
# A snapshot resolver dictates the compiler version and the set of packages
# to be used for project dependencies. For example:
#
# resolver: lts-3.5
# resolver: nightly-2015-09-21
# resolver: ghc-7.10.2
#
# The location of a snapshot can be provided as a file or url. Stack assumes
# a snapshot provided as a file might change, whereas a url resource does not.
#
# resolver: ./custom-snapshot.yaml
# resolver: https://example.com/snapshots/2018-01-01.yaml
resolver:
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/20/9.yaml
# User packages to be built.
# Various formats can be used as shown in the example below.
#
# packages:
# - some-directory
# - https://example.com/foo/bar/baz-0.0.2.tar.gz
# subdirs:
# - auto-update
# - wai
packages:
- .
# Dependency packages to be pulled from upstream that are not in the resolver.
# These entries can reference officially published versions as well as
# forks / in-progress versions pinned to a git hash. For example:
#
# extra-deps:
# - acme-missiles-0.3
# - git: https://github.com/commercialhaskell/stack.git
# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a
#
# extra-deps: []
# Override default flag values for local packages and extra-deps
# flags: {}
# Extra package databases containing global packages
# extra-package-dbs: []
# Control whether we use the GHC we find on the path
# system-ghc: true
#
# Require a specific version of stack, using version ranges
# require-stack-version: -any # Default
# require-stack-version: ">=2.9"
#
# Override the architecture used by stack, especially useful on Windows
# arch: i386
# arch: x86_64
#
# Extra directories used by stack for building
# extra-include-dirs: [/path/to/dir]
# extra-lib-dirs: [/path/to/dir]
#
# Allow a newer minor version of GHC than the snapshot specifies
# compiler-check: newer-minor