From bc6259bfa8c21b3ed389e3a311d9f71866a74d5d Mon Sep 17 00:00:00 2001 From: xieby1 Date: Fri, 6 Dec 2024 20:02:15 +0800 Subject: [PATCH 01/11] flat --- benchmarks/openblas/default.nix | 4 +- benchmarks/spec2006/build-all.nix | 14 +- benchmarks/spec2006/default.nix | 9 +- builders/cptBuilder/1.profiling.nix | 31 ++-- builders/cptBuilder/2.cluster.nix | 5 +- builders/cptBuilder/3.checkpoint.nix | 28 +-- builders/cptBuilder/default.nix | 29 +--- builders/default.nix | 10 -- builders/imgBuilder/default.nix | 7 +- builders/imgBuilder/gcpt/default.nix | 6 +- builders/imgBuilder/linux/default.nix | 8 +- .../linux/initramfs/base/default.nix | 4 +- .../imgBuilder/linux/initramfs/default.nix | 8 +- .../linux/initramfs/overlays/default.nix | 10 +- builders/imgBuilder/opensbi/default.nix | 10 +- default.nix | 161 +++++++++++++----- 16 files changed, 193 insertions(+), 151 deletions(-) delete mode 100644 builders/default.nix diff --git a/benchmarks/openblas/default.nix b/benchmarks/openblas/default.nix index 5379c71..aec9b61 100644 --- a/benchmarks/openblas/default.nix +++ b/benchmarks/openblas/default.nix @@ -1,8 +1,6 @@ { stdenv , fetchFromGitHub -, dconfig -, traceDConfig , riscv64-pkgs , riscv64-cc , riscv64-fortran @@ -10,7 +8,7 @@ }: let riscv64-libfortran = riscv64-pkgs.gfortran.cc; in stdenv.mkDerivation { - pname = traceDConfig dconfig "openblas"; + pname = "openblas"; version = "0.3.28"; src = fetchFromGitHub { owner = "OpenMathLib"; diff --git a/benchmarks/spec2006/build-all.nix b/benchmarks/spec2006/build-all.nix index 6789959..1847725 100644 --- a/benchmarks/spec2006/build-all.nix +++ b/benchmarks/spec2006/build-all.nix @@ -3,12 +3,12 @@ , fetchFromGitHub , libxcrypt-legacy -, dconfig -, traceDConfig , riscv64-pkgs , riscv64-cc , riscv64-fortran , riscv64-libc-static +, src +, size ? "ref" # "ref" or "test" }: let customJemalloc = riscv64-pkgs.jemalloc.overrideAttrs (oldAttrs: { @@ -34,11 +34,11 @@ let hash = "sha256-qNxmM9Dmobr6fvTZapacu8jngcBPRbybwayTi7CZGd0="; }; in stdenv.mkDerivation { - name = traceDConfig dconfig "spec2006exe"; + name = "spec2006exe"; system = "x86_64-linux"; srcs = [ - dconfig.src + src CPU2006LiteWrapper ]; sourceRoot = "."; @@ -103,8 +103,8 @@ in stdenv.mkDerivation { pushd $WORK_DIR mkdir -p run if [ -d data/all/input ]; then cp -r data/all/input/* run/; fi - if [ -d data/${dconfig.size}/input ]; then cp -r data/${dconfig.size}/input/* run/; fi - if [ -f extra-data/${dconfig.size}.sh ]; then sh extra-data/${dconfig.size}.sh ; fi + if [ -d data/${size}/input ]; then cp -r data/${size}/input/* run/; fi + if [ -f extra-data/${size}.sh ]; then sh extra-data/${size}.sh ; fi mkdir -p $out/$WORK_DIR/run/ cp -r run/* $out/$WORK_DIR/run/ @@ -113,7 +113,7 @@ in stdenv.mkDerivation { # E.g.: 481.wrf/run-ref.sh # before replace: [run-ref.h]: $APP > rsl.out.0000 # after replace: [run.sh]: ./481.wrf > rsl.out.0000 - sed 's,\$APP,./'$WORK_DIR',' run-${dconfig.size}.sh > $out/$WORK_DIR/run/run-spec.sh + sed 's,\$APP,./'$WORK_DIR',' run-${size}.sh > $out/$WORK_DIR/run/run-spec.sh popd done diff --git a/benchmarks/spec2006/default.nix b/benchmarks/spec2006/default.nix index ddf7568..fac4d76 100644 --- a/benchmarks/spec2006/default.nix +++ b/benchmarks/spec2006/default.nix @@ -1,6 +1,6 @@ -{ callPackage -, runCommand -, dconfig +{ runCommand + +, build-all }: let testCases = [ "400.perlbench" @@ -33,9 +33,6 @@ "482.sphinx3" "483.xalancbmk" ]; - build-all = callPackage ./build-all.nix { - dconfig = import ./config.nix // dconfig; - }; in builtins.listToAttrs ( builtins.map (testcase: { # change `.` to `_`, e.g. "403.gcc" to "403_gcc" diff --git a/builders/cptBuilder/1.profiling.nix b/builders/cptBuilder/1.profiling.nix index b76e173..c9be0b7 100644 --- a/builders/cptBuilder/1.profiling.nix +++ b/builders/cptBuilder/1.profiling.nix @@ -1,46 +1,51 @@ { runCommand , lib -, dconfig , qemu , nemu -, gcpt +, img +, workload ? "miao" +, intervals ? "20000000" +, simulator ? "qemu" # "qemu" or "nemu" +, profiling_log ? "profiling.log" }: let - name = "${lib.removeSuffix ".gcpt" gcpt.name}.1_profiling"; + name = "${lib.removeSuffix ".gcpt" img.name}.1_profiling"; qemuCommand = [ "${qemu}/bin/qemu-system-riscv64" - "-bios ${gcpt}" + "-bios ${img}" "-M nemu" "-nographic" "-m 8G" "-smp 1" "-cpu rv64,v=true,vlen=128,h=false,sv39=true,sv48=false,sv57=false,sv64=false" - "-plugin ${qemu}/lib/libprofiling.so,workload=${dconfig.workload},intervals=${toString dconfig.intervals},target=$out" + "-plugin ${qemu}/lib/libprofiling.so,workload=${workload},intervals=${intervals},target=$out" "-icount shift=0,align=off,sleep=off" ]; nemuCommand = [ "${nemu}/bin/riscv64-nemu-interpreter" - "${gcpt}" + "${img}" "-b" "-D $out" "-C ${name}" - "-w ${dconfig.workload}" + "-w ${workload}" "--simpoint-profile" - "--cpt-interval ${toString dconfig.intervals}" + "--cpt-interval ${intervals}" ]; -in runCommand name {} '' +in runCommand name { + passthru = { inherit qemu nemu img; }; +} '' mkdir -p $out - ${if dconfig.simulator == "qemu" then '' + ${if simulator == "qemu" then '' echo ${builtins.toString qemuCommand} - ${builtins.toString qemuCommand} | tee $out/${dconfig.profiling_log} + ${builtins.toString qemuCommand} | tee $out/${profiling_log} '' else '' echo ${builtins.toString nemuCommand} - ${builtins.toString nemuCommand} | tee $out/${dconfig.profiling_log} - cp $out/${name}/${dconfig.workload}/simpoint_bbv.gz $out/ + ${builtins.toString nemuCommand} | tee $out/${profiling_log} + cp $out/${name}/${workload}/simpoint_bbv.gz $out/ ''} '' diff --git a/builders/cptBuilder/2.cluster.nix b/builders/cptBuilder/2.cluster.nix index 077043c..a92efe6 100644 --- a/builders/cptBuilder/2.cluster.nix +++ b/builders/cptBuilder/2.cluster.nix @@ -4,8 +4,9 @@ , maxK ? "30" , simpoint , stage1-profiling -, ... -}: runCommand "${lib.removeSuffix ".1_profiling" stage1-profiling.name}.2_cluster" {} ('' +}: runCommand "${lib.removeSuffix ".1_profiling" stage1-profiling.name}.2_cluster" { + passthru = { inherit simpoint stage1-profiling; }; +} ('' mkdir -p $out '' + (builtins.toString [ "${simpoint}/bin/simpoint" diff --git a/builders/cptBuilder/3.checkpoint.nix b/builders/cptBuilder/3.checkpoint.nix index 7ff10ad..135416e 100644 --- a/builders/cptBuilder/3.checkpoint.nix +++ b/builders/cptBuilder/3.checkpoint.nix @@ -1,17 +1,21 @@ { runCommand , lib -, dconfig , qemu , nemu -, gcpt +, img , stage2-cluster +, intervals ? "20000000" +, workload ? "miao" +, checkpoint_format ? "zstd" # gz or zstd, qemu only support zstd compressed +, simulator ? "qemu" # nemu or qemu +, checkpoint_log ? "checkpoint.log" }: let qemuCommand = [ "${qemu}/bin/qemu-system-riscv64" - "-bios ${gcpt}" - "-M nemu,simpoint-path=${stage2-cluster},workload=.,cpt-interval=${toString dconfig.intervals},output-base-dir=$out,config-name=${dconfig.workload},checkpoint-mode=SimpointCheckpoint" + "-bios ${img}" + "-M nemu,simpoint-path=${stage2-cluster},workload=.,cpt-interval=${intervals},output-base-dir=$out,config-name=${workload},checkpoint-mode=SimpointCheckpoint" "-nographic" "-m 8G" "-smp 1" @@ -21,24 +25,26 @@ let nemuCommand = [ "${nemu}/bin/riscv64-nemu-interpreter" - "${gcpt}" + "${img}" "-b" "-D $out" "-C checkpoint" "-w ." "-S ${stage2-cluster}" - "--cpt-interval ${toString dconfig.intervals}" - "--checkpoint-format ${toString dconfig.checkpoint_format}" + "--cpt-interval ${intervals}" + "--checkpoint-format ${checkpoint_format}" ]; -in runCommand "${lib.removeSuffix ".2_cluster" stage2-cluster.name}.3_checkpoint" {} '' +in runCommand "${lib.removeSuffix ".2_cluster" stage2-cluster.name}.3_checkpoint" { + passthru = { inherit qemu nemu img stage2-cluster; }; +} '' mkdir -p $out - ${if dconfig.simulator == "qemu" then '' + ${if simulator == "qemu" then '' echo "Executing QEMU command: ${builtins.toString qemuCommand}" - ${builtins.toString qemuCommand} | tee $out/${dconfig.checkpoint_log} + ${builtins.toString qemuCommand} | tee $out/${checkpoint_log} '' else '' echo "Executing NEMU command: ${builtins.toString nemuCommand}" - ${builtins.toString nemuCommand} | tee $out/${dconfig.checkpoint_log} + ${builtins.toString nemuCommand} | tee $out/${checkpoint_log} ''} '' diff --git a/builders/cptBuilder/default.nix b/builders/cptBuilder/default.nix index d7213a4..f8173a5 100644 --- a/builders/cptBuilder/default.nix +++ b/builders/cptBuilder/default.nix @@ -1,25 +1,14 @@ -{ callPackage - -, imgBuilder -, ... -}@args: let - # TODO: move folders to cptBuilder/ - qemu = callPackage ./qemu {}; - nemu = callPackage ./nemu {}; - gcpt = imgBuilder.gcpt; - stage1-profiling = callPackage ./1.profiling.nix { - inherit qemu nemu gcpt; - }; - simpoint = callPackage ./simpoint {}; - stage2-cluster = callPackage ./2.cluster.nix ({ - inherit simpoint stage1-profiling; - } // args); - stage3-checkpoint = callPackage ./3.checkpoint.nix { - inherit qemu nemu gcpt stage2-cluster; - }; +{ benchmark +, build-stage3-checkpoint +}: let + stage3-checkpoint = build-stage3-checkpoint benchmark; + stage2-cluster = stage3-checkpoint.stage2-cluster; + stage1-profiling = stage2-cluster.stage1-profiling; in stage3-checkpoint.overrideAttrs (old: { passthru = { - inherit qemu nemu simpoint; inherit stage1-profiling stage2-cluster stage3-checkpoint; + qemu = stage1-profiling.qemu; + nemu = stage1-profiling.nemu; + simpoint = stage2-cluster.simpoint; }; }) diff --git a/builders/default.nix b/builders/default.nix deleted file mode 100644 index 1db0969..0000000 --- a/builders/default.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ callPackage - -, benchmark -, ... -}@args: let - imgBuilder = callPackage ./imgBuilder { inherit benchmark; }; - cptBuilder = callPackage ./cptBuilder ({ inherit imgBuilder; } // args); -in cptBuilder.overrideAttrs (old: { - passthru = { inherit benchmark imgBuilder cptBuilder; }; -}) diff --git a/builders/imgBuilder/default.nix b/builders/imgBuilder/default.nix index 2cdd12d..f00db85 100644 --- a/builders/imgBuilder/default.nix +++ b/builders/imgBuilder/default.nix @@ -1,8 +1,3 @@ -{ callPackage - -, benchmark -}: let - gcpt = callPackage ./gcpt { inherit benchmark; }; -in gcpt.overrideAttrs (old: { +{ gcpt }: gcpt.overrideAttrs (old: { passthru = { inherit gcpt; }; }) diff --git a/builders/imgBuilder/gcpt/default.nix b/builders/imgBuilder/gcpt/default.nix index a951e8d..7753277 100644 --- a/builders/imgBuilder/gcpt/default.nix +++ b/builders/imgBuilder/gcpt/default.nix @@ -1,12 +1,10 @@ { stdenv , fetchFromGitHub -, callPackage , riscv64-cc , benchmark -}: let - opensbi = callPackage ../opensbi { inherit benchmark; }; -in stdenv.mkDerivation { +, opensbi +}: stdenv.mkDerivation { name = "${benchmark.name}.gcpt"; src = fetchFromGitHub { diff --git a/builders/imgBuilder/linux/default.nix b/builders/imgBuilder/linux/default.nix index 42c9bbf..7e97a04 100644 --- a/builders/imgBuilder/linux/default.nix +++ b/builders/imgBuilder/linux/default.nix @@ -1,16 +1,14 @@ { stdenv -, callPackage , bc , flex , bison , riscv64-cc , benchmark -}: let - initramfs = callPackage ./initramfs { inherit benchmark; }; +, initramfs # TODO: use overlayfs to reduce disk usage - common-build = callPackage ./common-build.nix {}; -in stdenv.mkDerivation { +, common-build +}: stdenv.mkDerivation { name = "${benchmark.name}.linux"; src = common-build; buildInputs = [ diff --git a/builders/imgBuilder/linux/initramfs/base/default.nix b/builders/imgBuilder/linux/initramfs/base/default.nix index 58dff9a..b191d2f 100644 --- a/builders/imgBuilder/linux/initramfs/base/default.nix +++ b/builders/imgBuilder/linux/initramfs/base/default.nix @@ -1,6 +1,7 @@ { writeText , runCommand -, callPackage + +, gen_init_cpio }: let name = "init.cpio"; @@ -26,7 +27,6 @@ let nod /dev/console 644 0 0 c 5 1 nod /dev/null 644 0 0 c 1 3 ''; - gen_init_cpio = callPackage ./gen_init_cpio {}; in runCommand name { passthru = { inherit cpio_list gen_init_cpio; diff --git a/builders/imgBuilder/linux/initramfs/default.nix b/builders/imgBuilder/linux/initramfs/default.nix index 7a102c2..a6d91c3 100644 --- a/builders/imgBuilder/linux/initramfs/default.nix +++ b/builders/imgBuilder/linux/initramfs/default.nix @@ -1,15 +1,11 @@ { runCommand -, callPackage , cpio , benchmark +, base +, overlays }: let cpioPatched = cpio.overrideAttrs (old: { patches = [./cpio_reset_timestamp.patch]; }); - base = callPackage ./base {}; - overlays = callPackage ./overlays { - # TODO: check if `run` doest not exist, throw an error - benchmark-run = benchmark.run; - }; in runCommand "${benchmark.name}.cpio" { passthru = { inherit base overlays; diff --git a/builders/imgBuilder/linux/initramfs/overlays/default.nix b/builders/imgBuilder/linux/initramfs/overlays/default.nix index 09f67c9..60fc5e6 100644 --- a/builders/imgBuilder/linux/initramfs/overlays/default.nix +++ b/builders/imgBuilder/linux/initramfs/overlays/default.nix @@ -1,16 +1,15 @@ { writeText , runCommand -, callPackage -, dconfig , riscv64-pkgs +, before_workload +, qemu_trap +, nemu_trap +, trapCommand ? "qemu_trap" # "nemu_trap" or "qemu_trap" , benchmark-run }: let name = "initramfs-overlays"; - before_workload = callPackage ./before_workload {}; - qemu_trap = callPackage ./qemu_trap {}; - nemu_trap = callPackage ./nemu_trap {}; riscv64-busybox = riscv64-pkgs.busybox.override { enableStatic = true; useMusl = true; @@ -19,7 +18,6 @@ let ::sysinit:/bin/busybox --install -s /dev/console::sysinit:-/bin/sh /bin/run.sh ''; - trapCommand = if dconfig.simulator == "nemu" then "nemu_trap" else "qemu_trap"; run_sh = writeText "run.sh" '' before_workload echo start diff --git a/builders/imgBuilder/opensbi/default.nix b/builders/imgBuilder/opensbi/default.nix index 2a0d3d7..7c2520b 100644 --- a/builders/imgBuilder/opensbi/default.nix +++ b/builders/imgBuilder/opensbi/default.nix @@ -1,14 +1,12 @@ { stdenv , python3 -, callPackage , riscv64-cc , benchmark -}: let - linux = callPackage ../linux { inherit benchmark; }; - dts = callPackage ./dts {}; - common-build = callPackage ./common-build.nix {inherit dts;}; -in stdenv.mkDerivation { +, linux +, dts +, common-build +}: stdenv.mkDerivation { name = "${benchmark.name}.opensbi"; src = common-build; diff --git a/default.nix b/default.nix index 714ddfa..2a2ef3a 100644 --- a/default.nix +++ b/default.nix @@ -1,53 +1,126 @@ -# pin to latest nixos-24.05 { pkgs ? import (fetchTarball { url = "https://github.com/NixOS/nixpkgs/archive/e8c38b73aeb218e27163376a2d617e61a2ad9b59.tar.gz"; sha256 = "1n6gdjny8k5rwkxh6sp1iwg1y3ni1pm7lvh9sisifgjb18jdvzbm"; }) {} -, ... -} @ args: let - scope = pkgs.lib.makeScope pkgs.newScope (self: rec { - riscv64-pkgs = pkgs.pkgsCross.riscv64; - riscv64-stdenv = riscv64-pkgs."${dconfig.cc}Stdenv"; - riscv64-cc = riscv64-stdenv.cc; - riscv64-libc-static = riscv64-stdenv.cc.libc.static; - riscv64-fortran = riscv64-pkgs.wrapCCWith { - cc = riscv64-stdenv.cc.cc.override { - name = "gfortran"; - langFortran = true; - langCC = false; - langC = false; - profiledCompiler = false; - }; - # fixup wrapped prefix, which only appear if hostPlatform!=targetPlatform - # for more details see /pkgs/build-support/cc-wrapper/default.nix - stdenvNoCC = riscv64-pkgs.stdenvNoCC.override { - hostPlatform = pkgs.stdenv.hostPlatform; - }; - # Beginning from 24.05, wrapCCWith receive `runtimeShell`. - # If leave it empty, the default uses riscv64-pkgs.runtimeShell, - # thus executing the sheBang will throw error: - # `cannot execute: required file not found`. - runtimeShell = pkgs.runtimeShell; + , ... +} @ args: +# TODO: support overlay +rec { + riscv64-pkgs = pkgs.pkgsCross.riscv64; + # TODO: gcc14 have a bug to compile spec2006 & spec2017's xalan + # * https://github.com/llvm/llvm-project/issues/109966 + # * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116064 + riscv64-stdenv = riscv64-pkgs.gcc13Stdenv; + riscv64-cc = riscv64-stdenv.cc; + riscv64-libc-static = riscv64-stdenv.cc.libc.static; + riscv64-fortran = riscv64-pkgs.wrapCCWith { + cc = riscv64-stdenv.cc.cc.override { + name = "gfortran"; + langFortran = true; + langCC = false; + langC = false; + profiledCompiler = false; }; - dconfig = import ./config.nix // args; - traceDConfig = dconfig: name: builtins.trace - "🧾 ${name}'s dconfig = ${pkgs.lib.generators.toPretty {} dconfig} 😺" - name; + # fixup wrapped prefix, which only appear if hostPlatform!=targetPlatform + # for more details see /pkgs/build-support/cc-wrapper/default.nix + stdenvNoCC = riscv64-pkgs.stdenvNoCC.override { + hostPlatform = pkgs.stdenv.hostPlatform; + }; + # Beginning from 24.05, wrapCCWith receive `runtimeShell`. + # If leave it empty, the default uses riscv64-pkgs.runtimeShell, + # thus executing the sheBang will throw error: + # `cannot execute: required file not found`. + runtimeShell = pkgs.runtimeShell; + }; + scope = pkgs.lib.makeScope pkgs.newScope (self: { + inherit riscv64-pkgs riscv64-stdenv riscv64-cc riscv64-libc-static riscv64-fortran; }); -in { - spec2006 = let - benchmarks = scope.callPackage ./benchmarks/spec2006 {}; - checkpointsAttrs = builtins.mapAttrs (name: benchmark: - scope.callPackage ./builders ( - { inherit benchmark; } // - (pkgs.lib.optionalAttrs (name=="483_xalancbmk") { maxK="100"; }) - ) - ) (pkgs.lib.filterAttrs (n: v: (pkgs.lib.isDerivation v)) benchmarks); + + spec2006-build-all = scope.callPackage ./benchmarks/spec2006/build-all.nix { + src = if args ? spec2006-src + then args.spec2006-src + else throw '' + Please specify the path of spec2006, for example: + nix-build ... --arg spec2006-src /path/of/spec2006.tar.gz ... + ''; + }; + spec2006 = scope.callPackage ./benchmarks/spec2006 { + build-all = spec2006-build-all; + }; + + openblas = scope.callPackage ./benchmarks/openblas {}; + + gen_init_cpio = scope.callPackage ./builders/imgBuilder/linux/initramfs/base/gen_init_cpio {}; + initramfs_base = scope.callPackage ./builders/imgBuilder/linux/initramfs/base { + inherit gen_init_cpio; + }; + + before_workload = scope.callPackage ./builders/imgBuilder/linux/initramfs/overlays/before_workload {}; + nemu_trap = scope.callPackage ./builders/imgBuilder/linux/initramfs/overlays/nemu_trap {}; + qemu_trap = scope.callPackage ./builders/imgBuilder/linux/initramfs/overlays/qemu_trap {}; + build-initramfs_overlays = benchmark-run: scope.callPackage ./builders/imgBuilder/linux/initramfs/overlays { + inherit before_workload qemu_trap nemu_trap benchmark-run; + }; + + build-initramfs = benchmark: scope.callPackage ./builders/imgBuilder/linux/initramfs { + inherit benchmark; + base = initramfs_base; + overlays = build-initramfs_overlays benchmark.run; + }; + + linux-common-build = scope.callPackage ./builders/imgBuilder/linux/common-build.nix {}; + build-linux = benchmark: scope.callPackage ./builders/imgBuilder/linux { + inherit benchmark; + initramfs = build-initramfs benchmark; + common-build = linux-common-build; + }; + + dts = scope.callPackage ./builders/imgBuilder/opensbi/dts {}; + opensbi-common-build = scope.callPackage ./builders/imgBuilder/opensbi/common-build.nix { + inherit dts; + }; + build-opensbi = benchmark: scope.callPackage ./builders/imgBuilder/opensbi { + inherit benchmark dts; + linux = build-linux benchmark; + common-build = opensbi-common-build; + }; + build-gcpt = benchmark: scope.callPackage ./builders/imgBuilder/gcpt { + inherit benchmark; + opensbi = build-opensbi benchmark; + }; + build-img = benchmark: scope.callPackage ./builders/imgBuilder { + gcpt = build-gcpt benchmark; + }; + + nemu = scope.callPackage ./builders/cptBuilder/nemu {}; + qemu = scope.callPackage ./builders/cptBuilder/qemu {}; + simpoint = scope.callPackage ./builders/cptBuilder/simpoint {}; + build-stage1-profiling = benchmark: scope.callPackage ./builders/cptBuilder/1.profiling.nix { + inherit qemu nemu; + img = build-img benchmark; + }; + build-stage2-cluster = benchmark: scope.callPackage ./builders/cptBuilder/2.cluster.nix { + inherit simpoint; + stage1-profiling = build-stage1-profiling benchmark; + }; + build-stage3-checkpoint = benchmark: scope.callPackage ./builders/cptBuilder/3.checkpoint.nix { + inherit qemu nemu; + img = build-img benchmark; + stage2-cluster = build-stage2-cluster benchmark; + }; + build-cpt = benchmark: scope.callPackage ./builders/cptBuilder { + inherit benchmark build-stage3-checkpoint; + }; + + + # TODO: 483_xalancbmk maxK="100" + cpt-spec2006 = let + attrs = builtins.mapAttrs (name: benchmark: + build-cpt benchmark + ) (pkgs.lib.filterAttrs (n: v: (pkgs.lib.isDerivation v)) spec2006); in (pkgs.linkFarm "checkpoints" ( - pkgs.lib.mapAttrsToList ( name: path: {inherit name path; } ) checkpointsAttrs - )).overrideAttrs (old: { passthru = checkpointsAttrs; }); + pkgs.lib.mapAttrsToList ( name: path: {inherit name path; } ) attrs + )).overrideAttrs (old: { passthru = attrs; }); - openblas = let - benchmark = scope.callPackage ./benchmarks/openblas {}; - in scope.callPackage ./builders { inherit benchmark; }; + cpt-openblas = build-cpt openblas; } From d47c744935a0b9de0684f560fb2416c9cf8315b3 Mon Sep 17 00:00:00 2001 From: xieby1 Date: Sat, 7 Dec 2024 22:21:48 +0800 Subject: [PATCH 02/11] flat: split default.nix to builders/default.nix --- builders/cptBuilder/default.nix | 5 +- builders/default.nix | 65 +++++++++++++++++++ default.nix | 107 +++++++------------------------- 3 files changed, 88 insertions(+), 89 deletions(-) create mode 100644 builders/default.nix diff --git a/builders/cptBuilder/default.nix b/builders/cptBuilder/default.nix index f8173a5..b714865 100644 --- a/builders/cptBuilder/default.nix +++ b/builders/cptBuilder/default.nix @@ -1,7 +1,4 @@ -{ benchmark -, build-stage3-checkpoint -}: let - stage3-checkpoint = build-stage3-checkpoint benchmark; +{ stage3-checkpoint }: let stage2-cluster = stage3-checkpoint.stage2-cluster; stage1-profiling = stage2-cluster.stage1-profiling; in stage3-checkpoint.overrideAttrs (old: { diff --git a/builders/default.nix b/builders/default.nix new file mode 100644 index 0000000..46756a8 --- /dev/null +++ b/builders/default.nix @@ -0,0 +1,65 @@ +{ riscv64-scope }: +{ benchmark +, overlays ? [] # TODO +}: let + # TODO: callPackage = riscv64-scope.callPackage + scope = riscv64-scope; +in rec { + # TODO: inherit riscv64-scope benchmark; + gen_init_cpio = scope.callPackage ./imgBuilder/linux/initramfs/base/gen_init_cpio {}; + initramfs_base = scope.callPackage ./imgBuilder/linux/initramfs/base { + inherit gen_init_cpio; + }; + + before_workload = scope.callPackage ./imgBuilder/linux/initramfs/overlays/before_workload {}; + nemu_trap = scope.callPackage ./imgBuilder/linux/initramfs/overlays/nemu_trap {}; + qemu_trap = scope.callPackage ./imgBuilder/linux/initramfs/overlays/qemu_trap {}; + initramfs_overlays = scope.callPackage ./imgBuilder/linux/initramfs/overlays { + inherit before_workload qemu_trap nemu_trap; + benchmark-run = benchmark.run; + }; + + initramfs = scope.callPackage ./imgBuilder/linux/initramfs { + inherit benchmark; + base = initramfs_base; + overlays = initramfs_overlays; + }; + + linux-common-build = scope.callPackage ./imgBuilder/linux/common-build.nix {}; + linux = scope.callPackage ./imgBuilder/linux { + inherit benchmark initramfs; + common-build = linux-common-build; + }; + + dts = scope.callPackage ./imgBuilder/opensbi/dts {}; + opensbi-common-build = scope.callPackage ./imgBuilder/opensbi/common-build.nix { + inherit dts; + }; + opensbi = scope.callPackage ./imgBuilder/opensbi { + inherit benchmark dts linux; + common-build = opensbi-common-build; + }; + gcpt = scope.callPackage ./imgBuilder/gcpt { + inherit benchmark opensbi; + }; + img = scope.callPackage ./imgBuilder { + inherit gcpt; + }; + + nemu = scope.callPackage ./cptBuilder/nemu {}; + qemu = scope.callPackage ./cptBuilder/qemu {}; + simpoint = scope.callPackage ./cptBuilder/simpoint {}; + stage1-profiling = scope.callPackage ./cptBuilder/1.profiling.nix { + inherit qemu nemu img; + }; + stage2-cluster = scope.callPackage ./cptBuilder/2.cluster.nix { + inherit simpoint stage1-profiling; + }; + stage3-checkpoint = scope.callPackage ./cptBuilder/3.checkpoint.nix { + inherit qemu nemu img stage2-cluster; + }; + cpt = scope.callPackage ./cptBuilder { + inherit stage3-checkpoint; + }; + +} diff --git a/default.nix b/default.nix index 2a2ef3a..3fa5931 100644 --- a/default.nix +++ b/default.nix @@ -4,8 +4,7 @@ }) {} , ... } @ args: -# TODO: support overlay -rec { +let riscv64-pkgs = pkgs.pkgsCross.riscv64; # TODO: gcc14 have a bug to compile spec2006 & spec2017's xalan # * https://github.com/llvm/llvm-project/issues/109966 @@ -32,95 +31,33 @@ rec { # `cannot execute: required file not found`. runtimeShell = pkgs.runtimeShell; }; - scope = pkgs.lib.makeScope pkgs.newScope (self: { + riscv64-scope = pkgs.lib.makeScope pkgs.newScope (self: { inherit riscv64-pkgs riscv64-stdenv riscv64-cc riscv64-libc-static riscv64-fortran; }); - - spec2006-build-all = scope.callPackage ./benchmarks/spec2006/build-all.nix { - src = if args ? spec2006-src - then args.spec2006-src - else throw '' - Please specify the path of spec2006, for example: - nix-build ... --arg spec2006-src /path/of/spec2006.tar.gz ... - ''; - }; - spec2006 = scope.callPackage ./benchmarks/spec2006 { - build-all = spec2006-build-all; - }; - - openblas = scope.callPackage ./benchmarks/openblas {}; - - gen_init_cpio = scope.callPackage ./builders/imgBuilder/linux/initramfs/base/gen_init_cpio {}; - initramfs_base = scope.callPackage ./builders/imgBuilder/linux/initramfs/base { - inherit gen_init_cpio; - }; - - before_workload = scope.callPackage ./builders/imgBuilder/linux/initramfs/overlays/before_workload {}; - nemu_trap = scope.callPackage ./builders/imgBuilder/linux/initramfs/overlays/nemu_trap {}; - qemu_trap = scope.callPackage ./builders/imgBuilder/linux/initramfs/overlays/qemu_trap {}; - build-initramfs_overlays = benchmark-run: scope.callPackage ./builders/imgBuilder/linux/initramfs/overlays { - inherit before_workload qemu_trap nemu_trap benchmark-run; - }; - - build-initramfs = benchmark: scope.callPackage ./builders/imgBuilder/linux/initramfs { - inherit benchmark; - base = initramfs_base; - overlays = build-initramfs_overlays benchmark.run; - }; - - linux-common-build = scope.callPackage ./builders/imgBuilder/linux/common-build.nix {}; - build-linux = benchmark: scope.callPackage ./builders/imgBuilder/linux { - inherit benchmark; - initramfs = build-initramfs benchmark; - common-build = linux-common-build; - }; - - dts = scope.callPackage ./builders/imgBuilder/opensbi/dts {}; - opensbi-common-build = scope.callPackage ./builders/imgBuilder/opensbi/common-build.nix { - inherit dts; - }; - build-opensbi = benchmark: scope.callPackage ./builders/imgBuilder/opensbi { - inherit benchmark dts; - linux = build-linux benchmark; - common-build = opensbi-common-build; - }; - build-gcpt = benchmark: scope.callPackage ./builders/imgBuilder/gcpt { - inherit benchmark; - opensbi = build-opensbi benchmark; - }; - build-img = benchmark: scope.callPackage ./builders/imgBuilder { - gcpt = build-gcpt benchmark; - }; - - nemu = scope.callPackage ./builders/cptBuilder/nemu {}; - qemu = scope.callPackage ./builders/cptBuilder/qemu {}; - simpoint = scope.callPackage ./builders/cptBuilder/simpoint {}; - build-stage1-profiling = benchmark: scope.callPackage ./builders/cptBuilder/1.profiling.nix { - inherit qemu nemu; - img = build-img benchmark; - }; - build-stage2-cluster = benchmark: scope.callPackage ./builders/cptBuilder/2.cluster.nix { - inherit simpoint; - stage1-profiling = build-stage1-profiling benchmark; - }; - build-stage3-checkpoint = benchmark: scope.callPackage ./builders/cptBuilder/3.checkpoint.nix { - inherit qemu nemu; - img = build-img benchmark; - stage2-cluster = build-stage2-cluster benchmark; - }; - build-cpt = benchmark: scope.callPackage ./builders/cptBuilder { - inherit benchmark build-stage3-checkpoint; - }; - - + build = import ./builders { inherit riscv64-scope; }; +in { # TODO: 483_xalancbmk maxK="100" - cpt-spec2006 = let + spec2006 = let + # TODO: spec2006-build-all is an inner package, remove it from here + spec2006-build-all = riscv64-scope.callPackage ./benchmarks/spec2006/build-all.nix { + src = if args ? spec2006-src + then args.spec2006-src + else throw '' + Please specify the path of spec2006, for example: + nix-build ... --arg spec2006-src /path/of/spec2006.tar.gz ... + ''; + }; + benchmarks = riscv64-scope.callPackage ./benchmarks/spec2006 { + build-all = spec2006-build-all; + }; attrs = builtins.mapAttrs (name: benchmark: - build-cpt benchmark - ) (pkgs.lib.filterAttrs (n: v: (pkgs.lib.isDerivation v)) spec2006); + build { inherit benchmark; } + ) (pkgs.lib.filterAttrs (n: v: (pkgs.lib.isDerivation v)) benchmarks); in (pkgs.linkFarm "checkpoints" ( pkgs.lib.mapAttrsToList ( name: path: {inherit name path; } ) attrs )).overrideAttrs (old: { passthru = attrs; }); - cpt-openblas = build-cpt openblas; + openblas = let + benchmark = riscv64-scope.callPackage ./benchmarks/openblas {}; + in build { inherit benchmark; }; } From 49dfeed473ab446586aeb8a8b501b5c85f19569d Mon Sep 17 00:00:00 2001 From: xieby1 Date: Sat, 7 Dec 2024 22:34:38 +0800 Subject: [PATCH 03/11] flat: change spec2006-build-all into an inner package --- benchmarks/spec2006/build-all.nix | 2 +- benchmarks/spec2006/default.nix | 5 ++++- default.nix | 6 +----- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/benchmarks/spec2006/build-all.nix b/benchmarks/spec2006/build-all.nix index 1847725..b3e4da7 100644 --- a/benchmarks/spec2006/build-all.nix +++ b/benchmarks/spec2006/build-all.nix @@ -8,7 +8,7 @@ , riscv64-fortran , riscv64-libc-static , src -, size ? "ref" # "ref" or "test" +, size }: let customJemalloc = riscv64-pkgs.jemalloc.overrideAttrs (oldAttrs: { diff --git a/benchmarks/spec2006/default.nix b/benchmarks/spec2006/default.nix index fac4d76..fcb470c 100644 --- a/benchmarks/spec2006/default.nix +++ b/benchmarks/spec2006/default.nix @@ -1,6 +1,8 @@ { runCommand -, build-all +, callPackage +, src +, size ? "ref" # "ref" or "test" }: let testCases = [ "400.perlbench" @@ -33,6 +35,7 @@ "482.sphinx3" "483.xalancbmk" ]; + build-all = callPackage ./build-all.nix { inherit src size; }; in builtins.listToAttrs ( builtins.map (testcase: { # change `.` to `_`, e.g. "403.gcc" to "403_gcc" diff --git a/default.nix b/default.nix index 3fa5931..15cfddb 100644 --- a/default.nix +++ b/default.nix @@ -38,8 +38,7 @@ let in { # TODO: 483_xalancbmk maxK="100" spec2006 = let - # TODO: spec2006-build-all is an inner package, remove it from here - spec2006-build-all = riscv64-scope.callPackage ./benchmarks/spec2006/build-all.nix { + benchmarks = riscv64-scope.callPackage ./benchmarks/spec2006 { src = if args ? spec2006-src then args.spec2006-src else throw '' @@ -47,9 +46,6 @@ in { nix-build ... --arg spec2006-src /path/of/spec2006.tar.gz ... ''; }; - benchmarks = riscv64-scope.callPackage ./benchmarks/spec2006 { - build-all = spec2006-build-all; - }; attrs = builtins.mapAttrs (name: benchmark: build { inherit benchmark; } ) (pkgs.lib.filterAttrs (n: v: (pkgs.lib.isDerivation v)) benchmarks); From 027e61becf9c8372df601b1a648611b144ef64b0 Mon Sep 17 00:00:00 2001 From: xieby1 Date: Sat, 7 Dec 2024 22:37:54 +0800 Subject: [PATCH 04/11] flat: misc: use callPackage to replace scope.callPackage --- builders/default.nix | 45 ++++++++++++++++++++++---------------------- default.nix | 5 +++-- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/builders/default.nix b/builders/default.nix index 46756a8..301073f 100644 --- a/builders/default.nix +++ b/builders/default.nix @@ -2,63 +2,62 @@ { benchmark , overlays ? [] # TODO }: let - # TODO: callPackage = riscv64-scope.callPackage - scope = riscv64-scope; + callPackage = riscv64-scope.callPackage; in rec { # TODO: inherit riscv64-scope benchmark; - gen_init_cpio = scope.callPackage ./imgBuilder/linux/initramfs/base/gen_init_cpio {}; - initramfs_base = scope.callPackage ./imgBuilder/linux/initramfs/base { + gen_init_cpio = callPackage ./imgBuilder/linux/initramfs/base/gen_init_cpio {}; + initramfs_base = callPackage ./imgBuilder/linux/initramfs/base { inherit gen_init_cpio; }; - before_workload = scope.callPackage ./imgBuilder/linux/initramfs/overlays/before_workload {}; - nemu_trap = scope.callPackage ./imgBuilder/linux/initramfs/overlays/nemu_trap {}; - qemu_trap = scope.callPackage ./imgBuilder/linux/initramfs/overlays/qemu_trap {}; - initramfs_overlays = scope.callPackage ./imgBuilder/linux/initramfs/overlays { + before_workload = callPackage ./imgBuilder/linux/initramfs/overlays/before_workload {}; + nemu_trap = callPackage ./imgBuilder/linux/initramfs/overlays/nemu_trap {}; + qemu_trap = callPackage ./imgBuilder/linux/initramfs/overlays/qemu_trap {}; + initramfs_overlays = callPackage ./imgBuilder/linux/initramfs/overlays { inherit before_workload qemu_trap nemu_trap; benchmark-run = benchmark.run; }; - initramfs = scope.callPackage ./imgBuilder/linux/initramfs { + initramfs = callPackage ./imgBuilder/linux/initramfs { inherit benchmark; base = initramfs_base; overlays = initramfs_overlays; }; - linux-common-build = scope.callPackage ./imgBuilder/linux/common-build.nix {}; - linux = scope.callPackage ./imgBuilder/linux { + linux-common-build = callPackage ./imgBuilder/linux/common-build.nix {}; + linux = callPackage ./imgBuilder/linux { inherit benchmark initramfs; common-build = linux-common-build; }; - dts = scope.callPackage ./imgBuilder/opensbi/dts {}; - opensbi-common-build = scope.callPackage ./imgBuilder/opensbi/common-build.nix { + dts = callPackage ./imgBuilder/opensbi/dts {}; + opensbi-common-build = callPackage ./imgBuilder/opensbi/common-build.nix { inherit dts; }; - opensbi = scope.callPackage ./imgBuilder/opensbi { + opensbi = callPackage ./imgBuilder/opensbi { inherit benchmark dts linux; common-build = opensbi-common-build; }; - gcpt = scope.callPackage ./imgBuilder/gcpt { + gcpt = callPackage ./imgBuilder/gcpt { inherit benchmark opensbi; }; - img = scope.callPackage ./imgBuilder { + img = callPackage ./imgBuilder { inherit gcpt; }; - nemu = scope.callPackage ./cptBuilder/nemu {}; - qemu = scope.callPackage ./cptBuilder/qemu {}; - simpoint = scope.callPackage ./cptBuilder/simpoint {}; - stage1-profiling = scope.callPackage ./cptBuilder/1.profiling.nix { + nemu = callPackage ./cptBuilder/nemu {}; + qemu = callPackage ./cptBuilder/qemu {}; + simpoint = callPackage ./cptBuilder/simpoint {}; + stage1-profiling = callPackage ./cptBuilder/1.profiling.nix { inherit qemu nemu img; }; - stage2-cluster = scope.callPackage ./cptBuilder/2.cluster.nix { + stage2-cluster = callPackage ./cptBuilder/2.cluster.nix { inherit simpoint stage1-profiling; }; - stage3-checkpoint = scope.callPackage ./cptBuilder/3.checkpoint.nix { + stage3-checkpoint = callPackage ./cptBuilder/3.checkpoint.nix { inherit qemu nemu img stage2-cluster; }; - cpt = scope.callPackage ./cptBuilder { + cpt = callPackage ./cptBuilder { inherit stage3-checkpoint; }; diff --git a/default.nix b/default.nix index 15cfddb..6a8cf96 100644 --- a/default.nix +++ b/default.nix @@ -34,11 +34,12 @@ let riscv64-scope = pkgs.lib.makeScope pkgs.newScope (self: { inherit riscv64-pkgs riscv64-stdenv riscv64-cc riscv64-libc-static riscv64-fortran; }); + callPackage = riscv64-scope.callPackage; build = import ./builders { inherit riscv64-scope; }; in { # TODO: 483_xalancbmk maxK="100" spec2006 = let - benchmarks = riscv64-scope.callPackage ./benchmarks/spec2006 { + benchmarks = callPackage ./benchmarks/spec2006 { src = if args ? spec2006-src then args.spec2006-src else throw '' @@ -54,6 +55,6 @@ in { )).overrideAttrs (old: { passthru = attrs; }); openblas = let - benchmark = riscv64-scope.callPackage ./benchmarks/openblas {}; + benchmark = callPackage ./benchmarks/openblas {}; in build { inherit benchmark; }; } From ed25577ef3d4d12b53e43333a8b0ae0a36aa77b0 Mon Sep 17 00:00:00 2001 From: xieby1 Date: Sat, 7 Dec 2024 23:07:16 +0800 Subject: [PATCH 05/11] flat: enable overlay of builders --- builders/default.nix | 22 +++++++++++++--------- default.nix | 2 +- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/builders/default.nix b/builders/default.nix index 301073f..b588698 100644 --- a/builders/default.nix +++ b/builders/default.nix @@ -1,10 +1,10 @@ -{ riscv64-scope }: +{ lib +, callPackage +}: { benchmark -, overlays ? [] # TODO -}: let - callPackage = riscv64-scope.callPackage; -in rec { - # TODO: inherit riscv64-scope benchmark; +, overlay ? (self: super: {}) +}: let allPackages = self: super: with self; { + inherit benchmark; gen_init_cpio = callPackage ./imgBuilder/linux/initramfs/base/gen_init_cpio {}; initramfs_base = callPackage ./imgBuilder/linux/initramfs/base { inherit gen_init_cpio; @@ -59,6 +59,10 @@ in rec { }; cpt = callPackage ./cptBuilder { inherit stage3-checkpoint; - }; - -} + };}; + # refer to /pkgs/top-level/stage.nix + toFix = lib.foldl' (lib.flip lib.extends) (self: {}) [ + allPackages + overlay + ]; +in lib.fix toFix diff --git a/default.nix b/default.nix index 6a8cf96..091196e 100644 --- a/default.nix +++ b/default.nix @@ -35,7 +35,7 @@ let inherit riscv64-pkgs riscv64-stdenv riscv64-cc riscv64-libc-static riscv64-fortran; }); callPackage = riscv64-scope.callPackage; - build = import ./builders { inherit riscv64-scope; }; + build = callPackage ./builders {}; in { # TODO: 483_xalancbmk maxK="100" spec2006 = let From 54cf6aab477c1e854f8a3b4de0c4064f35481c5f Mon Sep 17 00:00:00 2001 From: xieby1 Date: Sat, 7 Dec 2024 23:21:27 +0800 Subject: [PATCH 06/11] flat: spec2006: 483_xalancbmk maxK="100" --- default.nix | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/default.nix b/default.nix index 091196e..e70708b 100644 --- a/default.nix +++ b/default.nix @@ -37,7 +37,6 @@ let callPackage = riscv64-scope.callPackage; build = callPackage ./builders {}; in { - # TODO: 483_xalancbmk maxK="100" spec2006 = let benchmarks = callPackage ./benchmarks/spec2006 { src = if args ? spec2006-src @@ -47,9 +46,12 @@ in { nix-build ... --arg spec2006-src /path/of/spec2006.tar.gz ... ''; }; - attrs = builtins.mapAttrs (name: benchmark: - build { inherit benchmark; } - ) (pkgs.lib.filterAttrs (n: v: (pkgs.lib.isDerivation v)) benchmarks); + attrs = builtins.mapAttrs (name: benchmark: build { + inherit benchmark; + overlay = if name=="483_xalancbmk" then (self: super: { + stage2-cluster = super.stage2-cluster.override {maxK="100";}; + }) else (self: super: {}); + }) (pkgs.lib.filterAttrs (n: v: (pkgs.lib.isDerivation v)) benchmarks); in (pkgs.linkFarm "checkpoints" ( pkgs.lib.mapAttrsToList ( name: path: {inherit name path; } ) attrs )).overrideAttrs (old: { passthru = attrs; }); From 045e2014188db4b18894062db77dcd82f7f137ad Mon Sep 17 00:00:00 2001 From: xieby1 Date: Sun, 8 Dec 2024 11:44:12 +0800 Subject: [PATCH 07/11] flat: add spec2006-cpt --- default.nix | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/default.nix b/default.nix index e70708b..45c10c3 100644 --- a/default.nix +++ b/default.nix @@ -46,15 +46,20 @@ in { nix-build ... --arg spec2006-src /path/of/spec2006.tar.gz ... ''; }; - attrs = builtins.mapAttrs (name: benchmark: build { + spec2006-bare = builtins.mapAttrs (name: benchmark: build { inherit benchmark; overlay = if name=="483_xalancbmk" then (self: super: { stage2-cluster = super.stage2-cluster.override {maxK="100";}; }) else (self: super: {}); }) (pkgs.lib.filterAttrs (n: v: (pkgs.lib.isDerivation v)) benchmarks); - in (pkgs.linkFarm "checkpoints" ( - pkgs.lib.mapAttrsToList ( name: path: {inherit name path; } ) attrs - )).overrideAttrs (old: { passthru = attrs; }); + in spec2006-bare // { + # TODO: add other attrs into spec2006-bare + cpt = pkgs.linkFarm "checkpoints" ( + pkgs.lib.mapAttrsToList (testCase: buildResult: { + name = testCase; + path = buildResult.cpt; + }) spec2006-bare); + }; openblas = let benchmark = callPackage ./benchmarks/openblas {}; From 93a1403e77627318528956928d2645c23d57cb51 Mon Sep 17 00:00:00 2001 From: xieby1 Date: Sun, 8 Dec 2024 11:54:58 +0800 Subject: [PATCH 08/11] flat: update h, clean old config --- benchmarks/spec2006/config.nix | 4 ---- config.nix | 14 -------------- docs/config.md | 6 ------ shell.nix | 14 ++++++-------- 4 files changed, 6 insertions(+), 32 deletions(-) delete mode 100644 benchmarks/spec2006/config.nix delete mode 100644 config.nix diff --git a/benchmarks/spec2006/config.nix b/benchmarks/spec2006/config.nix deleted file mode 100644 index 4cbcf4e..0000000 --- a/benchmarks/spec2006/config.nix +++ /dev/null @@ -1,4 +0,0 @@ -{ - size = "ref"; # test or ref - src = /nfs/home/yanyue/tools/spec2006; -} diff --git a/config.nix b/config.nix deleted file mode 100644 index c44a815..0000000 --- a/config.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ - # TODO: gcc14 have a bug to compile spec2006 & spec2017's xalan - # * https://github.com/llvm/llvm-project/issues/109966 - # * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116064 - cc = "gcc13"; - # TODO: nemu is not deterministic - simulator = "qemu"; # nemu or qemu - intervals = 20000000; - workload = "miao"; - # TODO: remove *_log - profiling_log = "profiling.log"; - checkpoint_log = "checkpoint.log"; - checkpoint_format = "zstd"; # gz or zstd, qemu only support zstd compressed -} diff --git a/docs/config.md b/docs/config.md index 6ebd72c..ff9aebf 100644 --- a/docs/config.md +++ b/docs/config.md @@ -1,9 +1,3 @@ # 🧾配置(Configurations) TODO: - -Priority: - -* CLI Configurations -* Benchmark-Specific Configurations -* Global Configurations diff --git a/shell.nix b/shell.nix index cf5109c..abaedf3 100755 --- a/shell.nix +++ b/shell.nix @@ -15,23 +15,21 @@ let * Configure by CLI: * `nom-build ... --arg ...` * `nom-build ... --argstr ...` - * E.g: Generate spec2006 checkpoints using given source code, by nemu, in test size: - * `nom-build -A spec2006 --arg src ~/Codes/spec2006.tar.gz --argstr simulator nemu --argstr size test` - * Configure by global config file: edit `./config.nix` - * Configure by per-benchmark config file: edit `./benchmarks/*/config.nix` + * E.g: Generate spec2006 checkpoints using given source code: + * `nom-build --arg spec2006-src -A spec2006-cpt` ## Generation * Generate the checkpoints for a given into `result/`: * `nom-build -A ` * E.g: Generate checkpoints for all spec2006 testcases: - * `nom-build -A spec2006` + * `nom-build -A spec2006.cpt` * E.g: Generate checkpoints only for spec2006 403_gcc testcase: - * `nom-build -A spec2006.403_gcc` + * `nom-build -A spec2006.403_gcc.cpt` * E.g: Generate checkpoints for openblas: - * `nom-build -A openblas` + * `nom-build -A openblas.cpt` * Generate the checkpoints for a given into a dedicated : - * `nom-build -A -o ` + * `nom-build -A .cpt -o ` ## Documentation From d55ce73f4cf2f1b41d8ac9ac9d461396f6bb09ae Mon Sep 17 00:00:00 2001 From: xieby1 Date: Sun, 8 Dec 2024 11:58:36 +0800 Subject: [PATCH 09/11] flat: move riscv64-* into riscv64-scope --- default.nix | 53 ++++++++++++++++++++++++++--------------------------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/default.nix b/default.nix index 45c10c3..94185c4 100644 --- a/default.nix +++ b/default.nix @@ -5,34 +5,33 @@ , ... } @ args: let - riscv64-pkgs = pkgs.pkgsCross.riscv64; - # TODO: gcc14 have a bug to compile spec2006 & spec2017's xalan - # * https://github.com/llvm/llvm-project/issues/109966 - # * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116064 - riscv64-stdenv = riscv64-pkgs.gcc13Stdenv; - riscv64-cc = riscv64-stdenv.cc; - riscv64-libc-static = riscv64-stdenv.cc.libc.static; - riscv64-fortran = riscv64-pkgs.wrapCCWith { - cc = riscv64-stdenv.cc.cc.override { - name = "gfortran"; - langFortran = true; - langCC = false; - langC = false; - profiledCompiler = false; - }; - # fixup wrapped prefix, which only appear if hostPlatform!=targetPlatform - # for more details see /pkgs/build-support/cc-wrapper/default.nix - stdenvNoCC = riscv64-pkgs.stdenvNoCC.override { - hostPlatform = pkgs.stdenv.hostPlatform; - }; - # Beginning from 24.05, wrapCCWith receive `runtimeShell`. - # If leave it empty, the default uses riscv64-pkgs.runtimeShell, - # thus executing the sheBang will throw error: - # `cannot execute: required file not found`. - runtimeShell = pkgs.runtimeShell; - }; riscv64-scope = pkgs.lib.makeScope pkgs.newScope (self: { - inherit riscv64-pkgs riscv64-stdenv riscv64-cc riscv64-libc-static riscv64-fortran; + riscv64-pkgs = pkgs.pkgsCross.riscv64; + # TODO: gcc14 have a bug to compile spec2006 & spec2017's xalan + # * https://github.com/llvm/llvm-project/issues/109966 + # * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116064 + riscv64-stdenv = self.riscv64-pkgs.gcc13Stdenv; + riscv64-cc = self.riscv64-stdenv.cc; + riscv64-libc-static = self.riscv64-stdenv.cc.libc.static; + riscv64-fortran = self.riscv64-pkgs.wrapCCWith { + cc = self.riscv64-stdenv.cc.cc.override { + name = "gfortran"; + langFortran = true; + langCC = false; + langC = false; + profiledCompiler = false; + }; + # fixup wrapped prefix, which only appear if hostPlatform!=targetPlatform + # for more details see /pkgs/build-support/cc-wrapper/default.nix + stdenvNoCC = self.riscv64-pkgs.stdenvNoCC.override { + hostPlatform = pkgs.stdenv.hostPlatform; + }; + # Beginning from 24.05, wrapCCWith receive `runtimeShell`. + # If leave it empty, the default uses riscv64-pkgs.runtimeShell, + # thus executing the sheBang will throw error: + # `cannot execute: required file not found`. + runtimeShell = pkgs.runtimeShell; + }; }); callPackage = riscv64-scope.callPackage; build = callPackage ./builders {}; From ce23ae635e84feec30672f8c501bc804779ccd0c Mon Sep 17 00:00:00 2001 From: xieby1 Date: Sun, 8 Dec 2024 12:35:50 +0800 Subject: [PATCH 10/11] flat: clean benchmark that only used in naming --- builders/default.nix | 6 +++--- builders/imgBuilder/gcpt/default.nix | 4 ++-- builders/imgBuilder/linux/default.nix | 4 ++-- builders/imgBuilder/opensbi/default.nix | 4 ++-- default.nix | 3 +++ 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/builders/default.nix b/builders/default.nix index b588698..82e9641 100644 --- a/builders/default.nix +++ b/builders/default.nix @@ -26,7 +26,7 @@ linux-common-build = callPackage ./imgBuilder/linux/common-build.nix {}; linux = callPackage ./imgBuilder/linux { - inherit benchmark initramfs; + inherit initramfs; common-build = linux-common-build; }; @@ -35,11 +35,11 @@ inherit dts; }; opensbi = callPackage ./imgBuilder/opensbi { - inherit benchmark dts linux; + inherit dts linux; common-build = opensbi-common-build; }; gcpt = callPackage ./imgBuilder/gcpt { - inherit benchmark opensbi; + inherit opensbi; }; img = callPackage ./imgBuilder { inherit gcpt; diff --git a/builders/imgBuilder/gcpt/default.nix b/builders/imgBuilder/gcpt/default.nix index 7753277..a496474 100644 --- a/builders/imgBuilder/gcpt/default.nix +++ b/builders/imgBuilder/gcpt/default.nix @@ -2,10 +2,10 @@ , fetchFromGitHub , riscv64-cc -, benchmark +, rmExt , opensbi }: stdenv.mkDerivation { - name = "${benchmark.name}.gcpt"; + name = "${rmExt opensbi.name}.gcpt"; src = fetchFromGitHub { owner = "OpenXiangShan"; diff --git a/builders/imgBuilder/linux/default.nix b/builders/imgBuilder/linux/default.nix index 7e97a04..08cd406 100644 --- a/builders/imgBuilder/linux/default.nix +++ b/builders/imgBuilder/linux/default.nix @@ -4,12 +4,12 @@ , bison , riscv64-cc -, benchmark +, rmExt , initramfs # TODO: use overlayfs to reduce disk usage , common-build }: stdenv.mkDerivation { - name = "${benchmark.name}.linux"; + name = "${rmExt initramfs.name}.linux"; src = common-build; buildInputs = [ bc diff --git a/builders/imgBuilder/opensbi/default.nix b/builders/imgBuilder/opensbi/default.nix index 7c2520b..d8e8144 100644 --- a/builders/imgBuilder/opensbi/default.nix +++ b/builders/imgBuilder/opensbi/default.nix @@ -2,12 +2,12 @@ , python3 , riscv64-cc -, benchmark +, rmExt , linux , dts , common-build }: stdenv.mkDerivation { - name = "${benchmark.name}.opensbi"; + name = "${rmExt linux.name}.opensbi"; src = common-build; diff --git a/default.nix b/default.nix index 94185c4..6c4d1ac 100644 --- a/default.nix +++ b/default.nix @@ -32,6 +32,9 @@ let # `cannot execute: required file not found`. runtimeShell = pkgs.runtimeShell; }; + rmExt = name: builtins.concatStringsSep "." + (pkgs.lib.init + (pkgs.lib.splitString "." name)); }); callPackage = riscv64-scope.callPackage; build = callPackage ./builders {}; From 00b12d67d50ccfb87f1d0caaa1b8bc235687b569 Mon Sep 17 00:00:00 2001 From: xieby1 Date: Sun, 8 Dec 2024 12:38:24 +0800 Subject: [PATCH 11/11] flat: update runner.yml --- .github/workflows/runner.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/runner.yml b/.github/workflows/runner.yml index 25e3c9d..a8d89ce 100644 --- a/.github/workflows/runner.yml +++ b/.github/workflows/runner.yml @@ -15,8 +15,8 @@ jobs: contents: write steps: - uses: actions/checkout@v4 - - run: nix-build -A openblas -o result-openblas - - run: nix-build -A spec2006 --arg src $(ls -d /spec2006* | head -n1) -j29 -o result-spec2006 + - run: nix-build -A openblas.cpt -o result-openblas + - run: nix-build -A spec2006.cpt --arg src $(ls -d /spec2006* | head -n1) -j29 -o result-spec2006 - run: | git rev-parse HEAD > /tmp/rev (date +%y%m%d%H%M%S && cat /tmp/rev && readlink result-openblas) | tr '\n' ',' > /tmp/openblas.txt