From 91ec35ea82f672e9d2d61e430cbd529f0bb641c7 Mon Sep 17 00:00:00 2001 From: Yinan Xu Date: Sun, 29 Dec 2024 23:07:20 +0800 Subject: [PATCH 1/5] fix(libso): include headers from RTL simulators Since libso requires some headers from RTL simulators, this commit adds the corresponding include flags. As we are not sure whether the headers are simulator-dependent, we include VCS headers with a higher priority than Verilator. We also add a CI test for difftest-so on XiangShan --- .github/workflows/main.yml | 31 +++++++++++++++++++++++++++++++ libso.mk | 16 ++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 611255f0d..b9a75a9bf 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -306,3 +306,34 @@ jobs: make simv VCS=verilator -j2 ./build/simv +workload=$WORKLOAD +b=0 +e=-1 +diff=$REF_SO +max-instrs=5000 +warmup_instr=1000 make clean + + test-difftest-xiangshan: + # ubuntu 22.04 has the same version of libc as our VCS machines + runs-on: ubuntu-22.04 + + steps: + - uses: actions/checkout@v4 + + - name: Prepare environment + run: | + cd $GITHUB_WORKSPACE/.. + wget https://github.com/OpenXiangShan/xs-env/raw/refs/heads/master/install-verilator.sh + wget https://github.com/OpenXiangShan/xs-env/raw/refs/heads/master/setup-tools.sh + sudo bash setup-tools.sh + + - name: Prepare XiangShan + run: | + cd $GITHUB_WORKSPACE/.. + git clone --depth 1 https://github.com/OpenXiangShan/XiangShan.git + cd XiangShan && make init && rm -rf difftest && cp -r $GITHUB_WORKSPACE . + echo "NOOP_HOME=$(pwd)" >> $GITHUB_ENV + + - name: Chisel Elaboration + run: | + cd $NOOP_HOME + make sim-verilog CHISEL_TARGET=chirrtl JVM_XMX=10G + + - name: Build difftest-so + run: | + cd $NOOP_HOME + make -C difftest difftest-so diff --git a/libso.mk b/libso.mk index 332a75b87..c80ee0200 100644 --- a/libso.mk +++ b/libso.mk @@ -10,10 +10,26 @@ ifeq ($(WITH_DRAMSIM3),1) LD_LIB = -L $(DRAMSIM3_HOME)/ -ldramsim3 -Wl,-rpath-link=$(DRAMSIM3_HOME)/libdramsim3.so endif +# Include headers that are implicitly included by RTL simulators +# Priority: (1) VCS, (2) Verilator +ifneq ($(VCS_HOME),) +LIB_CXXFLAGS += -I$(VCS_HOME)/include +else +VERILATOR_ROOT = $(shell verilator -V 2>/dev/null | awk '/VERILATOR_ROOT/ {print $$3; exit}') +ifneq ($(VERILATOR_ROOT),) +LIB_CXXFLAGS += -I$(VERILATOR_ROOT)/include/vltstd +else +LIBSO_WARNING_MISSING_HEADERS = 1 +endif +endif + $(CC_OBJ_DIR): mkdir -p $(CC_OBJ_DIR) difftest-so: $(CC_OBJ_DIR) +ifeq ($(LIBSO_WARNING_MISSING_HEADERS),1) + @echo "No available RTL simulators. Headers may be missing. Still try to build it." +endif cd $(CC_OBJ_DIR) && \ $(CC) $(LIB_CXXFLAGS) $(LIB_CXXFILES) && \ $(CC) -o $(LIBDIFFTEST_SO) -m64 -shared *.o $(LD_LIB) From c0ee0ae31fb6e174f1e255ea30da3dee1804f740 Mon Sep 17 00:00:00 2001 From: Yinan Xu Date: Sun, 29 Dec 2024 23:14:23 +0800 Subject: [PATCH 2/5] ci: move to nightly --- .github/workflows/main.yml | 31 ------------------------------- .github/workflows/nightly.yml | 29 +++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 31 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b9a75a9bf..611255f0d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -306,34 +306,3 @@ jobs: make simv VCS=verilator -j2 ./build/simv +workload=$WORKLOAD +b=0 +e=-1 +diff=$REF_SO +max-instrs=5000 +warmup_instr=1000 make clean - - test-difftest-xiangshan: - # ubuntu 22.04 has the same version of libc as our VCS machines - runs-on: ubuntu-22.04 - - steps: - - uses: actions/checkout@v4 - - - name: Prepare environment - run: | - cd $GITHUB_WORKSPACE/.. - wget https://github.com/OpenXiangShan/xs-env/raw/refs/heads/master/install-verilator.sh - wget https://github.com/OpenXiangShan/xs-env/raw/refs/heads/master/setup-tools.sh - sudo bash setup-tools.sh - - - name: Prepare XiangShan - run: | - cd $GITHUB_WORKSPACE/.. - git clone --depth 1 https://github.com/OpenXiangShan/XiangShan.git - cd XiangShan && make init && rm -rf difftest && cp -r $GITHUB_WORKSPACE . - echo "NOOP_HOME=$(pwd)" >> $GITHUB_ENV - - - name: Chisel Elaboration - run: | - cd $NOOP_HOME - make sim-verilog CHISEL_TARGET=chirrtl JVM_XMX=10G - - - name: Build difftest-so - run: | - cd $NOOP_HOME - make -C difftest difftest-so diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 4d4ce179b..05ff20229 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -65,3 +65,32 @@ jobs: make emu XFUZZ=1 REF=$SPIKE_HOME/difftest/build/riscv64-spike-so LLVM_COVER=1 -j2 ./build/fuzzer -v -- $CORPUS/I-add-01.bin ./build/fuzzer -f --max-runs 100 --corpus-input $CORPUS -- --max-cycles 10000 | grep max_runs + + test-difftest-xiangshan: + # ubuntu 22.04 has the same version of libc as our VCS machines + runs-on: ubuntu-22.04 + + steps: + - uses: actions/checkout@v4 + + - name: Prepare environment + run: | + cd $GITHUB_WORKSPACE/.. + wget https://github.com/OpenXiangShan/xs-env/raw/refs/heads/master/install-verilator.sh + wget https://github.com/OpenXiangShan/xs-env/raw/refs/heads/master/setup-tools.sh + sudo bash setup-tools.sh + + - name: Prepare XiangShan + run: | + cd $GITHUB_WORKSPACE/.. + git clone --depth 1 https://github.com/OpenXiangShan/XiangShan.git + cd XiangShan && make init && rm -rf difftest && cp -r $GITHUB_WORKSPACE . + echo "NOOP_HOME=$(pwd)" >> $GITHUB_ENV + + - name: Chisel Elaboration + run: | + make -C $NOOP_HOME sim-verilog CHISEL_TARGET=chirrtl JVM_XMX=10G + + - name: Build difftest-so + run: | + make -C $NOOP_HOME/difftest difftest-so From 4a0f4932741e12f2de21938d819ca703143ef847 Mon Sep 17 00:00:00 2001 From: Yinan Xu Date: Wed, 1 Jan 2025 20:00:50 +0800 Subject: [PATCH 3/5] Update tests --- .github/workflows/main.yml | 36 +++++++++++++++++++++++++++++++++++ .github/workflows/nightly.yml | 29 ---------------------------- 2 files changed, 36 insertions(+), 29 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 611255f0d..a8401ddef 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -306,3 +306,39 @@ jobs: make simv VCS=verilator -j2 ./build/simv +workload=$WORKLOAD +b=0 +e=-1 +diff=$REF_SO +max-instrs=5000 +warmup_instr=1000 make clean + + test-difftest-xiangshan: + strategy: + matrix: + os: [ubuntu-20.04, ubuntu-22.04, ubuntu-24.04] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + + - name: Prepare environment + run: | + cd $GITHUB_WORKSPACE/.. + wget https://github.com/OpenXiangShan/xs-env/raw/refs/heads/master/install-verilator.sh + wget https://github.com/OpenXiangShan/xs-env/raw/refs/heads/master/setup-tools.sh + sudo bash setup-tools.sh + + - name: Prepare XiangShan + run: | + cd $GITHUB_WORKSPACE/.. + git clone --depth 1 https://github.com/OpenXiangShan/XiangShan.git + cd XiangShan && make init && rm -rf difftest && cp -r $GITHUB_WORKSPACE . + echo "NOOP_HOME=$(pwd)" >> $GITHUB_ENV + + - name: Chisel Elaboration + run: | + make -C $NOOP_HOME sim-verilog CHISEL_TARGET=chirrtl JVM_XMX=10G + + - name: Build difftest-so + run: | + make -C $NOOP_HOME/difftest difftest-so + + - name: Release libdifftest.so to artifacts + uses: actions/upload-artifact@v4 + with: + name: libdifftest-${{ matrix.os }}-xiangshan.so + path: $NOOP_HOME/build/libdifftest.so diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 05ff20229..4d4ce179b 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -65,32 +65,3 @@ jobs: make emu XFUZZ=1 REF=$SPIKE_HOME/difftest/build/riscv64-spike-so LLVM_COVER=1 -j2 ./build/fuzzer -v -- $CORPUS/I-add-01.bin ./build/fuzzer -f --max-runs 100 --corpus-input $CORPUS -- --max-cycles 10000 | grep max_runs - - test-difftest-xiangshan: - # ubuntu 22.04 has the same version of libc as our VCS machines - runs-on: ubuntu-22.04 - - steps: - - uses: actions/checkout@v4 - - - name: Prepare environment - run: | - cd $GITHUB_WORKSPACE/.. - wget https://github.com/OpenXiangShan/xs-env/raw/refs/heads/master/install-verilator.sh - wget https://github.com/OpenXiangShan/xs-env/raw/refs/heads/master/setup-tools.sh - sudo bash setup-tools.sh - - - name: Prepare XiangShan - run: | - cd $GITHUB_WORKSPACE/.. - git clone --depth 1 https://github.com/OpenXiangShan/XiangShan.git - cd XiangShan && make init && rm -rf difftest && cp -r $GITHUB_WORKSPACE . - echo "NOOP_HOME=$(pwd)" >> $GITHUB_ENV - - - name: Chisel Elaboration - run: | - make -C $NOOP_HOME sim-verilog CHISEL_TARGET=chirrtl JVM_XMX=10G - - - name: Build difftest-so - run: | - make -C $NOOP_HOME/difftest difftest-so From 12c124838fd8febbd26f726306d1cc832af82b60 Mon Sep 17 00:00:00 2001 From: Yinan Xu Date: Wed, 1 Jan 2025 20:46:09 +0800 Subject: [PATCH 4/5] move to nightly --- .github/workflows/main.yml | 36 ----------------------------------- .github/workflows/nightly.yml | 36 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a8401ddef..611255f0d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -306,39 +306,3 @@ jobs: make simv VCS=verilator -j2 ./build/simv +workload=$WORKLOAD +b=0 +e=-1 +diff=$REF_SO +max-instrs=5000 +warmup_instr=1000 make clean - - test-difftest-xiangshan: - strategy: - matrix: - os: [ubuntu-20.04, ubuntu-22.04, ubuntu-24.04] - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v4 - - - name: Prepare environment - run: | - cd $GITHUB_WORKSPACE/.. - wget https://github.com/OpenXiangShan/xs-env/raw/refs/heads/master/install-verilator.sh - wget https://github.com/OpenXiangShan/xs-env/raw/refs/heads/master/setup-tools.sh - sudo bash setup-tools.sh - - - name: Prepare XiangShan - run: | - cd $GITHUB_WORKSPACE/.. - git clone --depth 1 https://github.com/OpenXiangShan/XiangShan.git - cd XiangShan && make init && rm -rf difftest && cp -r $GITHUB_WORKSPACE . - echo "NOOP_HOME=$(pwd)" >> $GITHUB_ENV - - - name: Chisel Elaboration - run: | - make -C $NOOP_HOME sim-verilog CHISEL_TARGET=chirrtl JVM_XMX=10G - - - name: Build difftest-so - run: | - make -C $NOOP_HOME/difftest difftest-so - - - name: Release libdifftest.so to artifacts - uses: actions/upload-artifact@v4 - with: - name: libdifftest-${{ matrix.os }}-xiangshan.so - path: $NOOP_HOME/build/libdifftest.so diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 4d4ce179b..c3ab0965c 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -65,3 +65,39 @@ jobs: make emu XFUZZ=1 REF=$SPIKE_HOME/difftest/build/riscv64-spike-so LLVM_COVER=1 -j2 ./build/fuzzer -v -- $CORPUS/I-add-01.bin ./build/fuzzer -f --max-runs 100 --corpus-input $CORPUS -- --max-cycles 10000 | grep max_runs + + test-difftest-xiangshan: + strategy: + matrix: + os: [ubuntu-20.04, ubuntu-22.04, ubuntu-24.04] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + + - name: Prepare environment + run: | + cd $GITHUB_WORKSPACE/.. + wget https://github.com/OpenXiangShan/xs-env/raw/refs/heads/master/install-verilator.sh + wget https://github.com/OpenXiangShan/xs-env/raw/refs/heads/master/setup-tools.sh + sudo bash setup-tools.sh + + - name: Prepare XiangShan + run: | + cd $GITHUB_WORKSPACE/.. + git clone --depth 1 https://github.com/OpenXiangShan/XiangShan.git + cd XiangShan && make init && rm -rf difftest && cp -r $GITHUB_WORKSPACE . + echo "NOOP_HOME=$(pwd)" >> $GITHUB_ENV + + - name: Chisel Elaboration + run: | + make -C $NOOP_HOME sim-verilog CHISEL_TARGET=chirrtl JVM_XMX=10G + + - name: Build libdifftest.so + run: | + make -C $NOOP_HOME/difftest difftest-so + + - name: Release libdifftest.so to artifacts + uses: actions/upload-artifact@v4 + with: + name: libdifftest-${{ matrix.os }}-xiangshan.so + path: $NOOP_HOME/build/libdifftest.so From d0d8d2a4ff54ddb0657298de9500a7fb0d4b2152 Mon Sep 17 00:00:00 2001 From: Yinan Xu Date: Wed, 1 Jan 2025 20:48:42 +0800 Subject: [PATCH 5/5] fix(ci): fix the name for nightly CI --- .github/workflows/nightly.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index c3ab0965c..f217c7eec 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -1,4 +1,4 @@ -name: CI +name: Nightly Regression on: schedule: