Skip to content

Commit

Permalink
CI: enable PGO when building emu for CI (#3080)
Browse files Browse the repository at this point in the history
  • Loading branch information
cyyself committed Jun 15, 2024
1 parent 0184a80 commit 9810c04
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/emu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ jobs:
python3 $GITHUB_WORKSPACE/scripts/xiangshan.py --clean
- name: Build EMU
run: |
python3 $GITHUB_WORKSPACE/scripts/xiangshan.py --wave-dump $WAVE_HOME --build --threads 16 --mfc
python3 $GITHUB_WORKSPACE/scripts/xiangshan.py --wave-dump $WAVE_HOME --build --threads 16 --mfc \
--pgo $GITHUB_WORKSPACE/ready-to-run/coremark-2-iteration.bin --llvm-profdata llvm-profdata
- name: Basic Test - cputest
run: |
python3 $GITHUB_WORKSPACE/scripts/xiangshan.py --wave-dump $WAVE_HOME --threads 16 --ci cputest 2> /dev/zero
Expand Down Expand Up @@ -152,7 +153,8 @@ jobs:
run: |
python3 $GITHUB_WORKSPACE/scripts/xiangshan.py --build \
--dramsim3 /nfs/home/share/ci-workloads/DRAMsim3 \
--with-dramsim3 --threads 16 --mfc
--with-dramsim3 --threads 16 --mfc \
--pgo $GITHUB_WORKSPACE/ready-to-run/coremark-2-iteration.bin --llvm-profdata llvm-profdata
- name: SPEC06 Test - mcf
run: |
python3 $GITHUB_WORKSPACE/scripts/xiangshan.py --wave-dump $WAVE_HOME --threads 16 --max-instr 5000000 --numa --ci mcf 2> perf.log
Expand Down Expand Up @@ -218,7 +220,8 @@ jobs:
python3 $GITHUB_WORKSPACE/scripts/xiangshan.py --build \
--num-cores 2 --emu-optimize "" \
--dramsim3 /nfs/home/share/ci-workloads/DRAMsim3 \
--with-dramsim3 --threads 16 --mfc
--with-dramsim3 --threads 16 --mfc \
--pgo $GITHUB_WORKSPACE/ready-to-run/coremark-2-iteration.bin --llvm-profdata llvm-profdata
- name: MC Test
run: |
python3 $GITHUB_WORKSPACE/scripts/xiangshan.py --wave-dump $WAVE_HOME --threads 16 --numa --diff ./ready-to-run/riscv64-nemu-interpreter-dual-so --ci mc-tests 2> /dev/zero
Expand Down
2 changes: 1 addition & 1 deletion difftest
Submodule difftest updated 1 files
+7 −0 verilator.mk
17 changes: 15 additions & 2 deletions scripts/xiangshan.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import subprocess
import sys
import time

import shlex
import psutil


Expand Down Expand Up @@ -94,6 +94,10 @@ def __init__(self, args):
self.fork = not args.disable_fork
self.disable_diff = args.no_diff
self.disable_db = args.no_db
self.pgo = args.pgo
self.pgo_max_cycle = args.pgo_max_cycle
self.pgo_emu_args = args.pgo_emu_args
self.llvm_profdata = args.llvm_profdata
# wave dump path
if args.wave_dump is not None:
self.set_wave_home(args.wave_dump)
Expand Down Expand Up @@ -133,9 +137,14 @@ def get_makefile_args(self):
(self.is_mfc, "MFC"),
(self.emu_optimize, "EMU_OPTIMIZE"),
(self.xprop, "ENABLE_XPROP"),
(self.with_chiseldb, "WITH_CHISELDB")
(self.with_chiseldb, "WITH_CHISELDB"),
(self.pgo, "PGO_WORKLOAD"),
(self.pgo_max_cycle, "PGO_MAX_CYCLE"),
(self.pgo_emu_args, "PGO_EMU_ARGS"),
(self.llvm_profdata, "LLVM_PROFDATA"),
]
args = filter(lambda arg: arg[0] is not None, makefile_args)
args = [(shlex.quote(str(arg[0])), arg[1]) for arg in args] # shell escape
return args

def get_emu_args(self):
Expand Down Expand Up @@ -511,6 +520,10 @@ def get_free_cores(n):
parser.add_argument('--ram-size', nargs='?', type=str, help='manually set simulation memory size (8GB by default)')
# both makefile and emu arguments
parser.add_argument('--no-db', action='store_true', help='disable chiseldb dump')
parser.add_argument('--pgo', nargs='?', type=str, help='workload for pgo (null to disable pgo)')
parser.add_argument('--pgo-max-cycle', nargs='?', default=400000, type=int, help='maximun cycle to train pgo')
parser.add_argument('--pgo-emu-args', nargs='?', default='--no-diff', type=str, help='emu arguments for pgo')
parser.add_argument('--llvm-profdata', nargs='?', type=str, help='corresponding llvm-profdata command of clang to compile emu, do not set with GCC')

args = parser.parse_args()

Expand Down

0 comments on commit 9810c04

Please sign in to comment.