Skip to content

Commit

Permalink
[ci] fix subsystem run in ci
Browse files Browse the repository at this point in the history
- specify test lists for subsystem in individual file
- move subsystem build to better machine
- remove cycle related perf data from subsystem tests

Signed-off-by: Avimitin <[email protected]>
  • Loading branch information
Avimitin committed Feb 4, 2024
1 parent e6e31c8 commit c999ddf
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 49 deletions.
17 changes: 17 additions & 0 deletions .github/cases/v1024-l8-b2-fp/subsystem.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"rvv-vp-intrinsic-add-mlir": 291,
"rvv-vp-intrinsic-add-scalable-mlir": 448,
"hello-mlir": 72,
"stripmining-mlir": 23635,
"conv2d-less-m2-intrinsic": 27600,
"linear-normalization-intrinsic": 1,
"matmul-intrinsic": 1,
"softmax-intrinsic": 1,
"uarttest-intrinsic": 1,
"fpsmoke-asm": 1,
"memcpy-asm": 1,
"mmm-asm": 61401,
"smoke-asm": 7539,
"strlen-asm": 1,
"utf8-count-asm": 1
}
17 changes: 17 additions & 0 deletions .github/cases/v1024-l8-b2/subsystem.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"rvv-vp-intrinsic-add-mlir": 291,
"rvv-vp-intrinsic-add-scalable-mlir": 448,
"hello-mlir": 72,
"stripmining-mlir": 23635,
"conv2d-less-m2-intrinsic": 27600,
"linear-normalization-intrinsic": 1,
"matmul-intrinsic": 1,
"softmax-intrinsic": 1,
"uarttest-intrinsic": 1,
"fpsmoke-asm": 1,
"memcpy-asm": 1,
"mmm-asm": 61401,
"smoke-asm": 7539,
"strlen-asm": 1,
"utf8-count-asm": 1
}
38 changes: 21 additions & 17 deletions .github/scripts/ci.sc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ def scheduleTasks(allTasksFile: Seq[os.Path], bucketSize: Int): Seq[String] = {
.toSeq
})
// Initialize a list of buckets
val cargo = (0 until bucketSize).map(_ => new BucketBuffer())
val size = bucketSize.min(allCycleData.size)
val cargo = (0 until size).map(_ => new BucketBuffer())
// _2 is the cycle number
val (unProcessedData, normalData) = allCycleData.partition(_._2 <= 0)
// Group tests that have cycle data into subset by their cycle size
Expand All @@ -63,8 +64,8 @@ def scheduleTasks(allTasksFile: Seq[os.Path], bucketSize: Int): Seq[String] = {
})
// For unprocessed data, just split them into subset that have equal size
cargo.zipWithIndex.foreach { case(buffer, i) =>
val startIdx = i * bucketSize
val endIdx = math.min((i + 1) * bucketSize, unProcessedData.length)
val startIdx = i * size
val endIdx = math.min((i + 1) * size, unProcessedData.length)
unProcessedData.slice(startIdx, endIdx).foreach { case(name, cycle) => buffer.push_back(name, cycle) }
}
cargo.map(_.mkString).toSeq
Expand All @@ -80,18 +81,15 @@ def toMatrixJson(buckets: Seq[String]) =
// Read default tests information from '.github/cases/default.txt' file, and use that information to generate GitHub CI matrix.
// The result will be printed to stdout, and should be pipe into $GITHUB_OUTPUT
@main
def generateCiMatrix(
runnersAmount: Int,
) = {
val defaultCases = os.pwd / os.RelPath(".github/cases/default.txt")
println(toMatrixJson(
scheduleTasks(
os.read
.lines(defaultCases)
.map(defaultCases / os.up / os.RelPath(_)),
runnersAmount
),
))
def generateCiMatrix(defaultCases: String = "default.json", runnersAmount: Int) = {
println(
toMatrixJson(
scheduleTasks(
os.walk(os.pwd/".github"/"cases").filter(_.last == defaultCases),
runnersAmount
),
)
)
}

// Resolve all the executable test and filter out unpassed tests, appending perf testcases
Expand Down Expand Up @@ -229,16 +227,22 @@ def runTests(jobs: String, runTarget: String = "ip", resultDir: Option[os.Path],
case(failed, (job, i)) => {
val Array(config, caseName) = job.split(",")
System.err.println(s"\n\n\n>>>[${i+1}/${totalJobs.length}] Running test case $config,$caseName")
val args = Seq("scripts/run-test.py", runTarget, "-c", config, "--base-out-dir", testRunDir.toString) ++
{ if (runTarget == "ip") Seq("--no-log") else Seq() } ++
Seq(caseName)
val handle = os
.proc("scripts/run-test.py", runTarget, "-c", config, "--no-log", "--base-out-dir", testRunDir, caseName)
.proc(args)
.call(check=false)
if (handle.exitCode != 0) {
val outDir = testRunDir / config / caseName
System.err.println(s"Test case $job failed")
os.write(actualResultDir / "failed-logs" / s"$job.txt", handle.out.text)
failed :+ job
} else {
writeCycleUpdates(job, testRunDir, actualResultDir)
if (runTarget == "ip") {
writeCycleUpdates(job, testRunDir, actualResultDir)
}

failed
}
}
Expand Down
32 changes: 4 additions & 28 deletions .github/workflows/subsystem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@ concurrency:
jobs:
build-emulators:
name: "Build Emulators"
runs-on: [self-hosted, linux, nixos]
runs-on: [self-hosted, linux, nixos, AMD Ryzen 9 7940HS w/ Radeon 780M Graphics]
strategy:
matrix:
config:
- "v1024-l8-b2"
- "v1024-l8-b2-fp"
- "v4096-l8-b4"
- "v4096-l8-b4-fp"
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -52,19 +50,18 @@ jobs:
name: "Generate test matrix"
run: |
echo -n matrix= >> "$GITHUB_OUTPUT"
nix shell ".#ammonite" -c .github/scripts/ci.sc generateCiMatrix --runnersAmount "$RUNNERS" >> "$GITHUB_OUTPUT"
nix shell ".#ammonite" -c .github/scripts/ci.sc generateCiMatrix subsystem.json "$RUNNERS" >> "$GITHUB_OUTPUT"
build-trace-emulators:
name: "Build trace emulator"
runs-on: [self-hosted, linux, nixos]
needs: [gen-matrix]
runs-on: [self-hosted, linux, nixos, AMD Ryzen 9 7940HS w/ Radeon 780M Graphics]
strategy:
fail-fast: false
matrix:
config:
- "v1024-l8-b2"
- "v1024-l8-b2-fp"
- "v4096-l8-b4"
- "v4096-l8-b4-fp"
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -115,8 +112,6 @@ jobs:
name: test-reports-${{ matrix.id }}
path: |
test-results-*/failed-tests.md
test-results-*/cycle-updates.md
test-results-*/*_cycle.json
- uses: actions/upload-artifact@v4
if: failure()
Expand Down Expand Up @@ -202,22 +197,3 @@ jobs:
echo -e "\n## Failed tests\n" >> $GITHUB_STEP_SUMMARY
shopt -s nullglob
cat test-results-*/failed-tests.md >> $GITHUB_STEP_SUMMARY
echo -e "\n## Cycle updates\n" >> $GITHUB_STEP_SUMMARY
shopt -s nullglob
cat test-results-*/cycle-updates.md >> $GITHUB_STEP_SUMMARY
- name: "Commit cycle updates"
run: |
nix shell ".#ammonite" -c .github/scripts/ci.sc mergeCycleData
git config user.name github-actions
git config user.email [email protected]
changed_cases=$(git diff --name-only '.github/cases/**/default.json')
if [ -n "$changed_cases" ]; then
echo "changed cases: $changed_cases"
git add '.github/cases/**/default.json'
git commit -m "[ci] update test case cycle data"
git push origin ${{ github.head_ref }}
else
echo "No cycle change detect"
fi
8 changes: 4 additions & 4 deletions scripts/run-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,11 @@ def load_elf_from_dir(config, cases_dir, case_name, use_individual_drv, force_x8
)
else:
nix_args.append(f".#t1.{config}.{cases_attr_name}.all")
logger.info(f'Run "{" ".join(nix_args)}"')
logger.info(f'Get ELFs dir by cmd: "{" ".join(nix_args)}"')
cases_dir = subprocess.check_output(nix_args).strip().decode("UTF-8")

cases_dir = Path(cases_dir)
logger.info(f"Running cases in {cases_dir}")
logger.info(f"Reading ELFs in {cases_dir}")

case_config_path = (
cases_dir / f"{case_name}.json"
Expand Down Expand Up @@ -206,7 +206,7 @@ def run_test(args):
"-t",
f"{args.out_dir}",
]
logger.info(f'Run "{" ".join(configgen_args)}"')
logger.info(f'Get emulator config by cmd: "{" ".join(configgen_args)}"')
subprocess.Popen(configgen_args).wait()
assert (
elaborate_config_path.exists()
Expand Down Expand Up @@ -275,7 +275,7 @@ def optionals(cond, items):
]
) + emu_args

logger.info(f'Run "{" ".join(process_args)}"')
logger.info(f'Run {emu_type} emulator with cmd: "{" ".join(process_args)}"')
return_code = subprocess.Popen(process_args).wait()

if return_code != 0:
Expand Down

0 comments on commit c999ddf

Please sign in to comment.