Skip to content

Commit

Permalink
Introduce ablation study feature
Browse files Browse the repository at this point in the history
Block chaining and macro-operation (MOP) fusion are accelerator
techniques designed to enhance performance. To conduct further ablation
studies, two feature options, MOP_FUSION and BLOCK_CHAINING, are
introduced. These features can be freely combined with the other
emulator features.

Ablation study of these two techniques in system emulation:
| Metric             | Block Chaining & | Block Chaining | MOP fusion |
|                    | MOP fusion       |                |            |
|--------------------|------------------|----------------|------------|
| Dhrystone (DMIPS)  | 175              | 123            | 175        |
| (1000000 runs)     |                  |                |            |
|                    |                  |                |            |
| Coremark  (Iter/s) | 222              | 204            | 222        |
  • Loading branch information
ChinYikMing committed Dec 16, 2024
1 parent 0abaf24 commit e85a43b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ CFLAGS += -include src/common.h -Isrc/
ENABLE_ELF_LOADER ?= 0
$(call set-feature, ELF_LOADER)

# Enable MOP fusion, easier for ablation study
ENABLE_MOP_FUSION ?= 1
$(call set-feature, MOP_FUSION)

# Enable block chaining, easier for ablation study
ENABLE_BLOCK_CHAINING ?= 1
$(call set-feature, BLOCK_CHAINING)

# Enable system emulation
ENABLE_SYSTEM ?= 0
$(call set-feature, SYSTEM)
Expand Down
4 changes: 4 additions & 0 deletions src/emulate.c
Original file line number Diff line number Diff line change
Expand Up @@ -865,8 +865,10 @@ static block_t *block_find_or_translate(riscv_t *rv)
#if RV32_HAS(GDBSTUB)
if (likely(!rv->debug_mode))
#endif
#if RV32_HAS(MOP_FUSION)
/* macro operation fusion */
match_pattern(rv, next_blk);
#endif

#if !RV32_HAS(JIT)
/* insert the block into block map */
Expand Down Expand Up @@ -1027,6 +1029,7 @@ void rv_step(void *arg)
* the previous block.
*/

#if RV32_HAS(BLOCK_CHAINING)
if (prev) {
rv_insn_t *last_ir = prev->ir_tail;
/* chain block */
Expand All @@ -1042,6 +1045,7 @@ void rv_step(void *arg)
}
}
}
#endif
last_pc = rv->PC;
#if RV32_HAS(JIT)
#if RV32_HAS(T2C)
Expand Down
10 changes: 10 additions & 0 deletions src/feature.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,15 @@
#define RV32_FEATURE_ELF_LOADER 0
#endif

/* MOP fusion */
#ifndef RV32_FEATURE_MOP_FUSION
#define RV32_FEATURE_MOP_FUSION 1
#endif

/* Block chaining */
#ifndef RV32_FEATURE_BLOCK_CHAINING
#define RV32_FEATURE_BLOCK_CHAINING 1
#endif

/* Feature test macro */
#define RV32_HAS(x) RV32_FEATURE_##x

0 comments on commit e85a43b

Please sign in to comment.