Skip to content

Commit

Permalink
Merge pull request OpenXiangShan#266 from OpenXiangShan/checkpoint_zs…
Browse files Browse the repository at this point in the history
…td_decompress

support using zstd to take and restore checkpoints
  • Loading branch information
shinezyy committed Feb 26, 2024
2 parents dc3492f + 0f0ab55 commit fe61fbf
Show file tree
Hide file tree
Showing 15 changed files with 437 additions and 130 deletions.
18 changes: 14 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,25 @@ jobs:
# test boot linux
./build/riscv64-nemu-interpreter -b ./ready-to-run/linux.bin
make clean-all
- name: test cpt taking and restoring
- name: test cpt taking and restoring using gz format
run: |
make riscv64-xs-novga_defconfig
make riscv64-xs-cpt_defconfig
make -j
cd resource/gcpt_restore && make && cd $NEMU_HOME
# take cpt, and put cpt in output_top/test/linux
bash ./scripts/take.sh
bash ./scripts/take_gz.sh
# restore cpt
bash ./scripts/restore.sh
bash ./scripts/restore_gz.sh
make clean-all
- name: test cpt taking and restoring using zstd format
run: |
make riscv64-xs-cpt_defconfig
make -j
cd resource/gcpt_restore && make && cd $NEMU_HOME
# take cpt, and put cpt in output_top/test/linux
bash ./scripts/take_zstd.sh
# restore cpt
bash ./scripts/restore_zstd.sh
make clean-all
- name: Build NEMU as difftest ref
run: |
Expand Down
19 changes: 19 additions & 0 deletions configs/riscv64-xs-cpt_defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
CONFIG_ISA_riscv64=y
CONFIG_CLINT_MMIO=0x38000000
# CONFIG_RVV is not set
CONFIG_USE_XS_ARCH_CSRS=y
CONFIG_MSIZE=0x200000000
CONFIG_PC_RESET_OFFSET=0x0
# CONFIG_MEM_RANDOM is not set
CONFIG_MEM_COMPRESS=y
# CONFIG_HAS_SERIAL is not set
CONFIG_HAS_UARTLITE=y
CONFIG_UARTLITE_MMIO=0x40600000
CONFIG_FB_ADDR=0x50000000
CONFIG_VGA_CTL_MMIO=0x40001000
# CONFIG_HAS_AUDIO is not set
# CONFIG_HAS_DISK is not set
CONFIG_SDCARD_CTL_MMIO=0x40002000
CONFIG_FPU_SOFT=y
CONFIG_AC_SOFT=y
# CONFIG_DISABLE_INSTR_CNT is not set
3 changes: 3 additions & 0 deletions include/checkpoint/cpt_env.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@
#ifndef __CHECKPOINT_CPT_ENV__
#define __CHECKPOINT_CPT_ENV__

enum { GZ_FORMAT, ZSTD_FORMAT };

extern char *output_base_dir;
extern char *config_name;
extern char *workload_name;
extern char *simpoints_dir;
extern int cpt_id;
extern char *cpt_file;
extern char *restorer;
extern char compress_file_format;

#endif
6 changes: 4 additions & 2 deletions include/memory/image_loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
#ifndef __IMAGE_LOADER_H__
#define __IMAGE_LOADER_H__

#include<stddef.h>
#include <stddef.h>


long load_gz_img(const char *filename);

long load_img(char* img_name, char *which_img, uint64_t load_start, size_t img_size);
long load_zstd_img(const char *filename);

long load_img(char *img_name, char *which_img, uint64_t load_start, size_t img_size);

#endif // __IMAGE_LOADER_H__
1 change: 1 addition & 0 deletions include/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ void iqueue_dump();
extern "C" {
#endif
bool is_gz_file(const char *filename);
bool is_zstd_file(const char *filename);
#ifdef __cplusplus
}
#endif
Expand Down
4 changes: 4 additions & 0 deletions scripts/build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ else
OBJS = $(COBJS) $(XOBJS)
endif

ifdef CONFIG_MEM_COMPRESS
LDFLAGS += -lzstd
endif

# Compilation patterns
$(OBJ_DIR)/%.o: %.c
@echo + CC $<
Expand Down
File renamed without changes.
20 changes: 20 additions & 0 deletions scripts/restore_zstd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#***************************************************************************************
# Copyright (c) 2020-2022 Institute of Computing Technology, Chinese Academy of Sciences
#
# NEMU is licensed under Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
# http://license.coscl.org.cn/MulanPSL2
#
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
#
# See the Mulan PSL v2 for more details.
#**************************************************************************************/

cpt=`find output_top/test/linux/10000000 -name "*.zstd"`
./build/riscv64-nemu-interpreter -b\
-r resource/gcpt_restore/build/gcpt.bin \
--restore -I 99000000\
$cpt
3 changes: 2 additions & 1 deletion scripts/take.sh → scripts/take_gz.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@
-w linux \
-r ./resource/gcpt_restore/build/gcpt.bin \
--dont-skip-boot\
-I 11000000 ./ready-to-run/linux-0xa0000.bin
-I 11000000 ./ready-to-run/linux-0xa0000.bin \
--checkpoint-format gz
24 changes: 24 additions & 0 deletions scripts/take_zstd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#***************************************************************************************
# Copyright (c) 2020-2022 Institute of Computing Technology, Chinese Academy of Sciences
#
# NEMU is licensed under Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
# http://license.coscl.org.cn/MulanPSL2
#
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
#
# See the Mulan PSL v2 for more details.
#**************************************************************************************/

./build/riscv64-nemu-interpreter \
--cpt-interval 10000000 -u -b \
-D output_top \
-C test \
-w linux \
-r ./resource/gcpt_restore/build/gcpt.bin \
--dont-skip-boot\
-I 11000000 ./ready-to-run/linux-0xa0000.bin \
--checkpoint-format zstd
Loading

0 comments on commit fe61fbf

Please sign in to comment.