From f13f496c94fc23e8c5afa07bf9b2fefc2c739ea7 Mon Sep 17 00:00:00 2001 From: Avimitin Date: Fri, 12 Apr 2024 01:03:51 +0800 Subject: [PATCH] [script] support multiple config release - Fix path as config - Fix multiple config release name collision Signed-off-by: Avimitin --- .github/workflows/release.yml | 8 ++++++++ nix/t1/default.nix | 4 +--- nix/t1/release/default.nix | 12 +++++++++--- nix/t1/release/doc.typ | 3 ++- nix/t1/release/docker-layers.nix | 3 ++- script/src/Main.scala | 15 +++++++++------ 6 files changed, 31 insertions(+), 14 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 70de682d6..4b28c2a66 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,6 +12,8 @@ jobs: matrix: config: - blastoise + - machamp + - sandslash outputs: cache-key: ${{ steps.build.outputs.cache-key }} steps: @@ -26,11 +28,17 @@ jobs: echo "path: $closure" cp "$closure/image.tar" /tmp/t1-image.tar echo "cache-key=$(nix hash file --base32 /tmp/t1-image.tar)" > $GITHUB_OUTPUT + nix build -L '.#t1.${{ matrix.config }}.release.doc' --out-link docs - name: Upload to cache uses: actions/cache/save@v4 with: path: /tmp/t1-image.tar key: ${{ steps.build.outputs.cache-key }} + - uses: actions/upload-artifact@v4 + with: + name: docs-${{ matrix.config }}.pdf + path: | + docs/*.pdf upload: runs-on: ubuntu-latest diff --git a/nix/t1/default.nix b/nix/t1/default.nix index 373155df5..e720595ec 100644 --- a/nix/t1/default.nix +++ b/nix/t1/default.nix @@ -85,9 +85,7 @@ lib.makeScope newScope rtl = innerSelf.callPackage ./rtl.nix { mlirbc = innerSelf.subsystem.mlirbc; }; }; - release = innerSelf.callPackage ./release { - ip-emulator = ip.emu-trace; - }; + release = innerSelf.callPackage ./release { }; }) ) ) diff --git a/nix/t1/release/default.nix b/nix/t1/release/default.nix index 0f80a8cd5..3b0ebe9cc 100644 --- a/nix/t1/release/default.nix +++ b/nix/t1/release/default.nix @@ -10,13 +10,13 @@ , configName , t1-script -, ip-emulator +, ip , cases , elaborateConfigJson }: lib.makeScope newScope (scope: rec { - inherit ip-emulator elaborateConfigJson; + inherit elaborateConfigJson configName; testCases = with cases; [ intrinsic.matmul @@ -34,7 +34,13 @@ lib.makeScope newScope (scope: rec { makeWrapper ${t1-script}/bin/t1-helper $out/bin/ip-emulator \ --add-flags "ipemu" \ --add-flags "--config ${elaborateConfigJson}" \ - --add-flags "--emulator-path ${ip-emulator}/bin/emulator" + --add-flags "--emulator-path ${ip.emu}/bin/emulator" + + makeWrapper ${t1-script}/bin/t1-helper $out/bin/ip-emulator-trace \ + --add-flags "ipemu" \ + --add-flags "--config ${elaborateConfigJson}" \ + --add-flags "--trace" \ + --add-flags "--emulator-path ${ip.emu-trace}/bin/emulator" ''; docker-layers = scope.callPackage ./docker-layers.nix { }; diff --git a/nix/t1/release/doc.typ b/nix/t1/release/doc.typ index 1b721c581..ad82fa9f1 100644 --- a/nix/t1/release/doc.typ +++ b/nix/t1/release/doc.typ @@ -52,6 +52,7 @@ docker run --name t1 -it -v $PWD:/workspace --rm t1/release:latest /bin/bash == What is inside + IP emulator: `/bin/ip-emulator` ++ IP emulator with trace functionality: `/bin/ip-emulator-trace` + Softmax & Linear Normalization & Matmul test cases: `/workspace/cases` == How to run some workload using IP emulator @@ -64,5 +65,5 @@ ls /workspace/cases ip-emulator --case cases/intrinsic-matmul/bin/intrinsic.matmul.elf # Get waveform trace file -ip-emulator --trace --case ... +ip-emulator-trace --case cases/intrinsic-linear_normalization/bin/intrinsic.linear_normalization.elf ``` diff --git a/nix/t1/release/docker-layers.nix b/nix/t1/release/docker-layers.nix index ce731618b..e8c164f90 100644 --- a/nix/t1/release/docker-layers.nix +++ b/nix/t1/release/docker-layers.nix @@ -13,12 +13,13 @@ , rv32-stdenv , emulator-wrapped , testCases +, configName }: let # Don't use buildImage which relies on KVM feature self = dockerTools.streamLayeredImage { - name = "t1/release"; + name = "chipsalliance/t1-${configName}"; tag = "latest"; contents = with dockerTools; [ diff --git a/script/src/Main.scala b/script/src/Main.scala index a8feca15e..1daf89e07 100644 --- a/script/src/Main.scala +++ b/script/src/Main.scala @@ -115,20 +115,21 @@ object Main: caseName: String ): os.Path = val pathTail = - if (os.exists(os.Path(caseName, os.pwd))) then + if os.exists(os.Path(caseName, os.pwd)) || os.exists(os.Path(config, os.pwd)) then // It is hard to canoncalize user specify path, so here we use date time instead - java.time.LocalDateTime + val now = java.time.LocalDateTime .now() .format( java.time.format.DateTimeFormatter.ofPattern("yy-MM-dd-HH-mm-ss") ) - else caseName + os.RelPath(now) + else os.RelPath(s"$config/$caseName") val path = if (outputDir.isEmpty) then if (outputBaseDir.isEmpty) then - os.pwd / "testrun" / s"${emuType}emu" / config / pathTail - else os.Path(outputBaseDir.get, os.pwd) / config / pathTail + os.pwd / "testrun" / s"${emuType}emu" / pathTail + else os.Path(outputBaseDir.get, os.pwd) / pathTail else os.Path(outputDir.get) os.makeDir.all(path) @@ -142,6 +143,7 @@ object Main: @main def ipemu( @arg( name = "case", + short = 'C', doc = "name alias for loading test case" ) testCase: String, @arg( @@ -206,7 +208,8 @@ object Main: doc = "Force using x86_64 as cross compiling host platform" ) forceX86: Boolean = false, @arg( - name = "dump-cycle", + name = "dump-from-cycle", + short = 'D', doc = "Specify the dump starting point" ) dumpCycle: String = "0.0", @arg(