Add generators for experiments
This commit is contained in:
parent
bbc851db78
commit
979888eede
@ -6,19 +6,26 @@
|
||||
let
|
||||
callPackage = pkgs.lib.callPackageWith (pkgs // bsc // garlic);
|
||||
callPackages = pkgs.lib.callPackagesWith (pkgs // bsc // garlic);
|
||||
|
||||
# Load some helper functions to generate app variants
|
||||
inherit (import ./gen.nix) genApps genConfigs;
|
||||
|
||||
garlic = rec {
|
||||
|
||||
mpptest = callPackage ./mpptest { };
|
||||
|
||||
ppong = callPackage ./ppong { };
|
||||
|
||||
experiments = callPackage ./experiments {
|
||||
apps = [
|
||||
(ppong.override { mpi=bsc.intel-mpi;})
|
||||
(ppong.override { mpi=pkgs.mpich;})
|
||||
];
|
||||
exp = {
|
||||
mpiImpl = callPackage ./experiments {
|
||||
apps = genApps [ ppong ] (
|
||||
genConfigs {
|
||||
mpi = [ bsc.intel-mpi pkgs.mpich pkgs.openmpi ];
|
||||
}
|
||||
);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
in
|
||||
garlic
|
||||
|
34
bsc/garlic/gen.nix
Normal file
34
bsc/garlic/gen.nix
Normal file
@ -0,0 +1,34 @@
|
||||
let
|
||||
lib = import <nixpkgs/lib>;
|
||||
|
||||
gen = rec {
|
||||
# genAttrSets "a" ["hello" "world"]
|
||||
# [ { a = "hello"; } { a = "world"; } ]
|
||||
genAttrSets = (name: arr: (map (x: {${name}=x; })) arr);
|
||||
|
||||
# addAttrSets "a" [1 2] {e=4;}
|
||||
# [ { a = 1; e = 4; } { a = 2; e = 4; } ]
|
||||
addAttrSets = (name: arr: set: (map (x: set // {${name}=x; })) arr);
|
||||
|
||||
# attrToList {a=1;}
|
||||
# [ { name = "a"; value = 1; } ]
|
||||
attrToList = (set: map (name: {name=name; value=set.${name};} ) (builtins.attrNames set));
|
||||
|
||||
# mergeConfig [{e=1;}] {name="a"; value=[1 2]
|
||||
# [ { a = 1; e = 1; } { a = 2; e = 1; } ]
|
||||
mergeConfig = (arr: new: lib.flatten ( map (x: addAttrSets new.name new.value x) arr));
|
||||
|
||||
# genConfigs {a=[1 2]; b=[3 4];}
|
||||
# [ { a = 1; b = 3; } { a = 1; b = 4; } { a = 2; b = 3; } { a = 2; b = 4; } ]
|
||||
genConfigs = (config: lib.foldl mergeConfig [{}] (attrToList config));
|
||||
|
||||
# Generate multiple app versions by override with each config
|
||||
genApp = (app: configs: map (conf: app.override conf) configs);
|
||||
|
||||
# Generate app version from an array of apps
|
||||
genApps = (apps: configs:
|
||||
lib.flatten (map (app: genApp app configs) apps));
|
||||
|
||||
};
|
||||
in
|
||||
gen
|
Loading…
Reference in New Issue
Block a user