Tidy nbody experiment

This commit is contained in:
Rodrigo Arias 2020-08-10 15:27:46 +02:00
parent b777fbc6d5
commit 8db4ef2594
6 changed files with 52 additions and 176 deletions

View File

@ -7,11 +7,11 @@ 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 genApp genConfigs;
garlic = rec {
# Load some helper functions to generate app variants
inherit (import ./gen.nix) genApps genApp genConfigs;
mpptest = callPackage ./mpptest { };
ppong = callPackage ./ppong {
@ -23,75 +23,14 @@ let
gitBranch = "garlic/seq";
};
srunner = callPackage ./srunner.nix { };
ppong-job = srunner { app=ppong; };
sbatch = callPackage ./sbatch.nix { };
sbatchLauncher = callPackage ./sbatch-launcher.nix { };
exp = {
jobs = callPackage ./experiments {
apps = map (app: srunner {app=app;}) (
genApps [ ppong ] (
genConfigs {
mpi = [ bsc.intel-mpi pkgs.mpich pkgs.openmpi ];
}
)
);
};
mpiImpl = callPackage ./experiments {
apps = genApps [ ppong ] (
genConfigs {
mpi = [ bsc.intel-mpi pkgs.mpich pkgs.openmpi ];
}
);
};
nbodyExp = callPackage ./experiments {
apps = genApp nbody [
{ cc=bsc.icc;
cflags="-march=core-avx2"; }
{ cc=bsc.clang-ompss2;
cflags="-O3 -march=core-avx2 -ffast-math -Rpass-analysis=loop-vectorize"; }
];
};
nbodyBS = callPackage ./experiments {
apps = genApp nbody (
genConfigs {
cc = [ bsc.icc ];
blocksize = [ 1024 2048 4096 ];
});
};
nbodyBSjob = callPackage ./dispatcher.nix {
jobs = map (app: srunner {
app=app;
prefix="/gpfs/projects/bsc15/nix";
exclusive=false;
ntasks = "1";
}
) (
genApp nbody (
genConfigs {
cc = [ bsc.icc ];
blocksize = [ 1024 2048 4096 ];
}
)
);
};
# Test if there is any difference between intel -march and -xCORE
# with target avx2.
march = callPackage ./experiments {
apps = genApps [ nbody ] (( genConfigs {
cc = [ bsc.icc ];
cflags = [ "-march=core-avx2" "-xCORE-AVX2" ];
}) ++ ( genConfigs {
cc = [ bsc.clang-ompss2 ];
cflags = [ "-O3 -march=core-avx2 -Rpass-analysis=loop-vectorize" ];
}));
nbody = {
bs = callPackage ./exp/nbody/bs.nix {
inherit bsc;
};
};
};
};

View File

@ -0,0 +1,38 @@
{
bsc
, nbody
, genApp
, genConfigs
, sbatch
, sbatchLauncher
}:
let
# Set the configuration for the experiment
config = {
cc = [ bsc.icc ];
blocksize = [ 1024 2048 4096 ];
};
# Compute the cartesian product of all configurations
configList = genConfigs config;
# Generate each app variant via override
appList = genApp nbody configList;
# Job generator helper function
genJobs = map (app:
sbatch {
app = app;
prefix = "/gpfs/projects/bsc15/nix";
exclusive = false;
ntasks = "1";
}
);
# Generate one job for each app variant
jobList = genJobs appList;
# And merge all jobs in a script to lauch them all with sbatch
launcher = sbatchLauncher jobList;
in
launcher

View File

@ -1,61 +0,0 @@
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;
}

View File

@ -1,41 +0,0 @@
{
stdenv
, mpi
, fetchurl
, apps
}:
stdenv.mkDerivation {
name = "garlic-experiments";
preferLocalBuild = true;
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
echo "running \$app"
\$app/bin/run
done
EOF
chmod +x $out/bin/run
'';
}

View File

@ -1,10 +1,11 @@
{
stdenv
, jobs
}:
jobs:
stdenv.mkDerivation {
name = "slurm-dispatcher";
name = "launcher";
preferLocalBuild = true;
buildInputs = [] ++ jobs;
@ -18,7 +19,7 @@ stdenv.mkDerivation {
done
mkdir -p $out/bin
cat > $out/bin/execute-all-jobs <<EOF
cat > $out/bin/run <<EOF
#!/bin/sh
for j in $out/jobs/*; do
@ -27,6 +28,6 @@ stdenv.mkDerivation {
done
EOF
chmod +x $out/bin/execute-all-jobs
chmod +x $out/bin/run
'';
}