Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memleak fix #258

Open
wants to merge 2 commits into
base: xs-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/gem5.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,30 @@ jobs:
bash util/memory_check/run-xs-with-valgrind.sh
cd $GEM5_HOME

valgrind_memory_check_ideal:
runs-on: self-hosted
continue-on-error: false
name: XS-GEM5 - Check memory corruption with ideal-kmhv3
steps:
- uses: actions/checkout@v2
- name: Build DRAMSim
run: |
export GEM5_HOME=$(pwd)
cd ext/dramsim3
git clone https://github.com/umd-memsys/DRAMsim3.git DRAMsim3
cd DRAMsim3 && mkdir -p build
cd build
cmake ..
make -j 48
cd $GEM5_HOME
- name: Build GEM5 debug
run: CC=gcc CXX=g++ scons build/RISCV/gem5.debug --linker=gold -j64
- name: Memory check
run: |
export GEM5_HOME=$(pwd)
bash util/memory_check/run-xs-with-valgrind.sh ideal
cd $GEM5_HOME

new_sim_script_test_gcb:
runs-on: self-hosted
continue-on-error: false
Expand Down
4 changes: 3 additions & 1 deletion src/cpu/pred/ftb/ftb_tage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ FTBTAGE::lookupHelper(Addr startAddr,
for (int b = 0; b < numBr; b++) {
// make main prediction
int phyBrIdx = getShuffledBrIndex(startAddr, b);
assert(phyBrIdx >= 0 && phyBrIdx < numBr);
int provider_counts = 0;
for (int i = numPredictors - 1; i >= 0; --i) {
Addr tmp_index = getTageIndex(startAddr, i);
Expand Down Expand Up @@ -575,7 +576,8 @@ FTBTAGE::getBrIndexUnshuffleBits(Addr pc)
Addr
FTBTAGE::getShuffledBrIndex(Addr pc, int brIdxToShuffle)
{
return getBrIndexUnshuffleBits(pc) ^ brIdxToShuffle;
// make sure the result is in the range of [0, numBr-1]
return (getBrIndexUnshuffleBits(pc) ^ brIdxToShuffle) & (numBr - 1);
}


Expand Down
39 changes: 20 additions & 19 deletions util/memory_check/run-xs-with-valgrind.sh
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
set -x

gem5_home=$(pwd)
gcpt_restore_path=/nfs/home/share/gem5_shared_tools/normal-gcb-restorer.bin
ref_so_path=/nfs-nvme/home/share/zhenhao/ref-h/build/riscv64-nemu-interpreter-so
test_cpt=/nfs/home/share/jiaxiaoyu/simpoint_checkpoint_archive/spec06_rv64gcb_O3_20m_gcc12.2.0-intFpcOff-jeMalloc/checkpoint-0-0-0/GemsFDTD/30385/_30385_0.268180_.gz
ref_so_path=/nfs/home/share/gem5_ci/ref/normal/riscv64-nemu-interpreter-so
export GCBV_REF_SO=$ref_so_path

export NEMU_HOME=$ref_so_path # dummy
raw_cpt=/nfs/home/share/gem5_ci/checkpoints/coremark-riscv64-xs.bin
# ideal config, $1 means ideal-kmhv3
IDEAL_CONFIG=""
if [ "$1" ]; then
IDEAL_CONFIG="--ideal-kmhv3"
fi
echo "IDEAL_CONFIG: $IDEAL_CONFIG"

mkdir -p $gem5_home/valgrind-test
cd $gem5_home/valgrind-test

valgrind -s --track-origins=yes --log-file=valgrind-out.txt --error-limit=no \
--suppressions=$gem5_home/util/valgrind-suppressions \
$gem5_home/build/RISCV/gem5.debug $gem5_home/configs/example/fs.py \
--xiangshan-system --cpu-type=DerivO3CPU --mem-size=8GB --caches --cacheline_size=64 \
--l1i_size=64kB --l1i_assoc=8 --l1d_size=64kB --l1d_assoc=8 \
--l1d-hwp-type=XSCompositePrefetcher --short-stride-thres=0 \
--l2cache --l2_size=1MB --l2_assoc=8 \
--l3cache --l3_size=16MB --l3_assoc=16 \
--l1-to-l2-pf-hint --l2-hwp-type=CompositeWithWorkerPrefetcher \
--l2-to-l3-pf-hint --l3-hwp-type=WorkerPrefetcher \
--mem-type=DRAMsim3 \
--dramsim3-ini=$gem5_home/ext/dramsim3/xiangshan_configs/xiangshan_DDR4_8Gb_x8_3200_2ch.ini \
--bp-type=DecoupledBPUWithFTB --enable-loop-predictor \
--enable-difftest --difftest-ref-so=$ref_so_path \
--generic-rv-cpt=$test_cpt \
--gcpt-restorer=$gcpt_restore_path \
--warmup-insts-no-switch=40000 --maxinsts=80000
$gem5_home/build/RISCV/gem5.debug \
$gem5_home/configs/example/xiangshan.py \
$IDEAL_CONFIG \
--raw-cpt \
--generic-rv-cpt=$raw_cpt

# if $? != 0, exit
if [ $? -ne 0 ]; then
echo "Valgrind test failed"
exit 1
fi

python3 $gem5_home/util/memory_check/check-memory-error.py $gem5_home/valgrind-test/valgrind-out.txt

Loading