Skip to content

Commit

Permalink
[ci] add cycle update support
Browse files Browse the repository at this point in the history
Signed-off-by: Avimitin <[email protected]>
  • Loading branch information
Avimitin committed Sep 4, 2024
1 parent 44e2909 commit ab27d9a
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 88 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/t1rocket.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,19 @@ jobs:
--cycle-update-file-path ./cycle-update.md \
--emu-type vcs
cat ./failed-tests.md >> $GITHUB_STEP_SUMMARY
echo >> $GITHUB_STEP_SUMMARY
cat ./cycle-update.md >> $GITHUB_STEP_SUMMARY
- name: "Commit cycle updates"
run: |
git config user.name github-actions
git config user.email [email protected]
changed_cases=$(git diff --name-only '.github/**/default.json')
if [ -n "$changed_cases" ]; then
echo "changed cases: $changed_cases"
git add '.github/**/default.json'
git commit -m "[ci] update test case cycle data"
git push origin ${{ github.head_ref }}
else
echo "No cycle change detect"
fi
22 changes: 20 additions & 2 deletions .github/workflows/vcs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,24 @@ jobs:
ref: ${{ github.head_ref }}
- name: "Print step summary"
run: |
nix run ".#ci-helper" -- postCI --failed-tests-file-path ./failed-tests.md --emu-type vcs --cycle-update-file-path ./cycle-update.md
cat ./failed-tests.md >> $GITHUB_STEP_SUMMARY
nix run ".#ci-helper" -- postCI \
--cycle-update-file-path ./cycle-update.md \
--failed-tests-file-path ./failed-tests.md \
--emu-type vcs
cat ./cycle-update.md >> $GITHUB_STEP_SUMMARY
echo >> $GITHUB_STEP_SUMMARY
cat ./failed-tests.md >> $GITHUB_STEP_SUMMARY
- name: "Commit cycle updates"
run: |
git config user.name github-actions
git config user.email [email protected]
changed_cases=$(git diff --name-only '.github/**/default.json')
if [ -n "$changed_cases" ]; then
echo "changed cases: $changed_cases"
git add '.github/**/default.json'
git commit -m "[ci] update test case cycle data"
git push origin ${{ github.head_ref }}
else
echo "No cycle change detect"
fi
15 changes: 15 additions & 0 deletions .github/workflows/verilator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,19 @@ jobs:
--failed-tests-file-path ./failed-tests.md \
--cycle-update-file-path ./cycle-update.md
cat ./failed-tests.md >> $GITHUB_STEP_SUMMARY
echo >> $GITHUB_STEP_SUMMARY
cat ./cycle-update.md >> $GITHUB_STEP_SUMMARY
- name: "Commit cycle updates"
run: |
git config user.name github-actions
git config user.email [email protected]
changed_cases=$(git diff --name-only '.github/**/default.json')
if [ -n "$changed_cases" ]; then
echo "changed cases: $changed_cases"
git add '.github/**/default.json'
git commit -m "[ci] update test case cycle data"
git push origin ${{ github.head_ref }}
else
echo "No cycle change detect"
fi
2 changes: 1 addition & 1 deletion nix/t1/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ lib.makeScope newScope
# Grouped emulator packages
# ---------------------------------------------------------------------------------
# Nix specification for t1rocket (with rocket-chip as Scalar core) emulator
t1rocket = t1Scope.callPackage ./t1rocket { };
t1rocket = t1Scope.callPackage ./t1rocket.nix { };
# Nix specification for rocket (rocket-chip only) emulator
rocketv = t1Scope.callPackage ../../rocketemu { };

Expand Down
16 changes: 8 additions & 8 deletions nix/t1/t1rocket/default.nix → nix/t1/t1rocket.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
{
ip = lib.makeScope newScope (scope: {

cases = scope.callPackage ../../../tests { };
run = scope.callPackage ../run { configName = "t1rocket"; };
cases = scope.callPackage ../../tests { };
run = scope.callPackage ./run { configName = "t1rocket"; };

mlirbc = chisel-to-mlirbc {
outputName = "t1rocketemu-parsed.mlirbc";
elaboratorArgs = [
"t1rocketemu"
"--t1rocket-config"
"${../../../t1rocketemu/configs/default.json}"
"${../../t1rocketemu/configs/default.json}"
];
};

Expand All @@ -41,7 +41,7 @@
];
};

makeDPI = scope.callPackage ../../../difftest { };
makeDPI = scope.callPackage ../../difftest { };
verilator-dpi-lib = scope.makeDPI {
outputName = "t1rocket-verilator-dpi-lib";
buildType = "t1rocket";
Expand Down Expand Up @@ -72,7 +72,7 @@
];
};

offline-checker = scope.callPackage ../../../t1rocketemu/offline { };
offline-checker = scope.callPackage ../../t1rocketemu/offline { };

vcs-dpi-lib = scope.makeDPI {
outputName = "t1rocket-vcs-dpi-lib";
Expand All @@ -87,12 +87,12 @@
};

vcs-emu = sv-to-vcs-simulator {
mainProgram = "t1-vcs-simulator";
mainProgram = "t1rocket-vcs-simulator";
rtl = scope.rtl;
vcsLinkLibs = [ "${scope.vcs-dpi-lib}/lib/libdpi_t1rocket.a" ];
};
vcs-emu-trace = sv-to-vcs-simulator {
mainProgram = "t1-vcs-trace-simulator";
mainProgram = "t1rocket-vcs-trace-simulator";
rtl = scope.rtl;
enableTrace = true;
vcsLinkLibs = [ "${scope.vcs-dpi-lib-trace}/lib/libdpi_t1rocket.a" ];
Expand All @@ -112,7 +112,7 @@
throw "Invalid vlen extension `${ext}` specify, expect Zvl{N}b";

# TODO: designConfig should be read from OM
designConfig = with builtins; (fromJSON (readFile ../../../t1rocketemu/configs/default.json)).parameter;
designConfig = with builtins; (fromJSON (readFile ../../t1rocketemu/configs/default.json)).parameter;

# TODO: We should have a type define, to keep t1 and t1rocket feeds same `rtlDesignMetadata` data structure.
rtlDesignMetadata = rec {
Expand Down
62 changes: 0 additions & 62 deletions nix/t1/t1rocket/verilated-c-lib.nix

This file was deleted.

21 changes: 8 additions & 13 deletions script/ci/src/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ object Main:
@arg(
name = "cycle-update-file-path",
doc = "specify the cycle update markdown file output path"
) cycleUpdateFilePath: Option[String],
) cycleUpdateFilePath: String,
@arg(
name = "emu-type",
doc = "Specify emulation type"
Expand All @@ -226,11 +226,10 @@ object Main:
val failedTestsFile = os.Path(failedTestsFilePath, os.pwd)
os.write.over(failedTestsFile, "## Failed Tests\n")

if cycleUpdateFilePath.nonEmpty then
os.write.over(
os.Path(cycleUpdateFilePath.get, os.pwd),
"## Cycle Update\n"
)
os.write.over(
os.Path(cycleUpdateFilePath, os.pwd),
"## Cycle Update\n"
)

os.walk(os.pwd / ".github" / caseDir)
.filter(_.last == "default.json")
Expand Down Expand Up @@ -261,15 +260,11 @@ object Main:

if cycleUpdateFilePath.nonEmpty then
Logger.info("Collecting cycle update info")
val perfCycleRegex = raw"total_cycles:\s(\d+)".r
val allCycleUpdates = os
.walk(emuResultPath)
.filter(path => path.last == "perf.txt")
.filter(path => path.last == "perf.json")
.map(path => {
val cycle = os.read.lines(path).head match
case perfCycleRegex(cycle) => cycle.toInt
case _ =>
throw new Exception("perf.txt file is not format as expected")
val cycle = ujson.read(os.read(path)).obj("total_cycles").num.toInt
val caseName = path.segments.toSeq.reverse.drop(1).head
(caseName, cycle, cycleRecord.obj(caseName).num.toInt)
})
Expand All @@ -282,7 +277,7 @@ object Main:
else s"* 🐢 $caseName($config): $oldCycle -> $newCycle"

os.write.append(
os.Path(cycleUpdateFilePath.get, os.pwd),
os.Path(cycleUpdateFilePath, os.pwd),
allCycleUpdates.mkString("\n") + "\n"
)

Expand Down
5 changes: 3 additions & 2 deletions script/emu/src/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ object Main:
zstdProc.join(-1)
driverProc.join(-1)
if zstdProc.exitCode() != 0 then Logger.fatal("fail to compress data")
if driverProc.exitCode() != 0 then Logger.fatal("fail to compress data")
if driverProc.exitCode() != 0 then Logger.fatal("online driver run failed")

val statePath = outputPath / "driver-state.json"
os.write(
Expand Down Expand Up @@ -332,7 +332,8 @@ object Main:
)
Logger.info(s"Running offline checker: ${driverArgs.mkString(" ")}")

os.proc(driverArgs).call(stdout = os.Inherit, stderr = os.Inherit)
val ret = os.proc(driverArgs).call(stdout = os.Inherit, stderr = os.Inherit, check = false)
if (ret.exitCode != 0) then Logger.fatal("offline checker run failed")
end offline

def main(args: Array[String]): Unit = ParserForMethods(this).runOrExit(args)
Expand Down

0 comments on commit ab27d9a

Please sign in to comment.