Merge branch 'master' of bscpm02.bsc.es:rarias/bsc-nixpkgs
This commit is contained in:
commit
0eec726335
@ -6,9 +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/default.nix { };
|
||||
ppong = callPackage ./ppong/default.nix { };
|
||||
|
||||
mpptest = callPackage ./mpptest { };
|
||||
|
||||
ppong = callPackage ./ppong { };
|
||||
|
||||
exp = {
|
||||
mpiImpl = callPackage ./experiments {
|
||||
apps = genApps [ ppong ] (
|
||||
genConfigs {
|
||||
mpi = [ bsc.intel-mpi pkgs.mpich pkgs.openmpi ];
|
||||
}
|
||||
);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
in
|
||||
garlic
|
||||
|
61
bsc/garlic/experiments/config.nix
Normal file
61
bsc/garlic/experiments/config.nix
Normal file
@ -0,0 +1,61 @@
|
||||
let
|
||||
lib = import <nixpkgs/lib>;
|
||||
|
||||
inputParams = {
|
||||
# MPI implementation
|
||||
mpi = [
|
||||
"impi"
|
||||
"mpich"
|
||||
];
|
||||
|
||||
# Gcc compiler
|
||||
gcc = [
|
||||
"gcc9"
|
||||
"gcc7"
|
||||
];
|
||||
|
||||
# Additional cflags
|
||||
cflags = [
|
||||
["-O3" "-fnobugs"]
|
||||
["-Ofast"]
|
||||
];
|
||||
|
||||
# Which git branches
|
||||
# branches = [
|
||||
# "mpi+seq"
|
||||
# "seq"
|
||||
# ];
|
||||
};
|
||||
|
||||
apps = [
|
||||
"dummy"
|
||||
];
|
||||
|
||||
# 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));
|
||||
|
||||
|
||||
# Generates all configs from inputParams
|
||||
allConfigs = (genConfigs inputParams);
|
||||
|
||||
in
|
||||
{
|
||||
inherit allConfigs;
|
||||
}
|
39
bsc/garlic/experiments/default.nix
Normal file
39
bsc/garlic/experiments/default.nix
Normal file
@ -0,0 +1,39 @@
|
||||
{
|
||||
stdenv
|
||||
, mpi
|
||||
, fetchurl
|
||||
, apps
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "garlic-experiments";
|
||||
|
||||
src = ./.;
|
||||
|
||||
buildInputs = [] ++ apps;
|
||||
apps = apps;
|
||||
|
||||
buildPhase = ''
|
||||
for app in $apps; do
|
||||
test -e $app/bin/run || (echo $app/bin/run not found; exit 1)
|
||||
done
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/apps
|
||||
for app in $apps; do
|
||||
ln -s $app $out/apps/$(basename $app)
|
||||
done
|
||||
|
||||
mkdir -p $out/bin
|
||||
cat > $out/bin/run <<EOF
|
||||
#!/bin/bash
|
||||
|
||||
for app in $out/apps/*; do
|
||||
\$app/bin/run
|
||||
done
|
||||
EOF
|
||||
|
||||
chmod +x $out/bin/run
|
||||
'';
|
||||
}
|
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
|
@ -12,12 +12,22 @@ stdenv.mkDerivation {
|
||||
sha256 = "0d1w72gq9627448cb7ykknhgp2wszwd117dlbalbrpf7d0la8yc0";
|
||||
};
|
||||
|
||||
dontUnpack = true;
|
||||
unpackCmd = ''
|
||||
mkdir src
|
||||
cp $src src/ppong.c
|
||||
'';
|
||||
|
||||
dontConfigure = true;
|
||||
|
||||
buildPhase = ''
|
||||
pwd
|
||||
ls -la
|
||||
mpicc PPong.c -o ppong
|
||||
echo mpicc -include stdlib.h ppong.c -o ppong
|
||||
mpicc -include stdlib.h ppong.c -o ppong
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp ppong $out/bin/ppong
|
||||
ln -s $out/bin/ppong $out/bin/run
|
||||
'';
|
||||
|
||||
buildInputs = [ mpi ];
|
||||
|
Loading…
Reference in New Issue
Block a user