Skip to content

Commit

Permalink
[script] support multiple config release
Browse files Browse the repository at this point in the history
- Fix path as config
- Fix multiple config release name collision

Signed-off-by: Avimitin <[email protected]>
  • Loading branch information
Avimitin committed Apr 12, 2024
1 parent 5b169ed commit 4958d57
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 24 deletions.
34 changes: 24 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ jobs:
matrix:
config:
- blastoise
- machamp
- sandslash
outputs:
cache-key: ${{ steps.build.outputs.cache-key }}
steps:
Expand All @@ -24,25 +26,37 @@ jobs:
run: |
closure="$(nix build -L '.#t1.${{ matrix.config }}.release.docker-layers.final-image' --no-link --print-out-paths)"
echo "path: $closure"
cp "$closure/image.tar" /tmp/t1-image.tar
echo "cache-key=$(nix hash file --base32 /tmp/t1-image.tar)" > $GITHUB_OUTPUT
cp "$closure/image.tar" /tmp/t1-${{ matrix.config }}-image.tar
echo "cache-key-${{ matrix.config }}=$(nix hash file --base32 $closure/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 }}
path: /tmp/t1-${{ matrix.config }}-image.tar
key: ${{ steps.build.outputs[format('cache-key-{0}', matrix.config)] }}
- uses: actions/upload-artifact@v4
with:
name: docs-${{ matrix.config }}.pdf
path: |
docs/*.pdf
upload:
runs-on: ubuntu-latest
needs: [build]
strategy:
matrix:
config:
- blastoise
- machamp
- sandslash
steps:
- name: Restore from cache
- name: Restore ${{ matrix.config }} from cache
uses: actions/cache/restore@v4
id: cache
with:
path: /tmp/t1-image.tar
path: /tmp/t1-${{ matrix.config }}-image.tar
fail-on-cache-miss: true
key: ${{ needs.build.outputs.cache-key }}
key: ${{ steps.build.outputs[format('cache-key-{0}', matrix.config)] }}
- name: Login to GHCR dot IO
uses: docker/login-action@v2
with:
Expand All @@ -51,6 +65,6 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}
- name: Load and push
run: |
docker load < /tmp/t1-image.tar
docker tag t1/release:latest ghcr.io/chipsalliance/t1:latest
docker push ghcr.io/chipsalliance/t1:latest
docker load < /tmp/t1-${{ matrix.config }}-image.tar
docker tag chipsalliance/t1-${{ matrix.config }}:latest ghcr.io/chipsalliance/t1-${{ matrix.config }}:latest
docker push ghcr.io/chipsalliance/t1-${{ matrix.config }}:latest
4 changes: 1 addition & 3 deletions nix/t1/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 { };
})
)
)
12 changes: 9 additions & 3 deletions nix/t1/release/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 { };
Expand Down
3 changes: 2 additions & 1 deletion nix/t1/release/doc.typ
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
```
3 changes: 2 additions & 1 deletion nix/t1/release/docker-layers.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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; [
Expand Down
15 changes: 9 additions & 6 deletions script/src/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -142,6 +143,7 @@ object Main:
@main def ipemu(
@arg(
name = "case",
short = 'C',
doc = "name alias for loading test case"
) testCase: String,
@arg(
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 4958d57

Please sign in to comment.