Skip to content

Commit

Permalink
Merge pull request sysprog21#118 from qwe661234/wip/add_ARC
Browse files Browse the repository at this point in the history
Add adaptive replacement cache
  • Loading branch information
jserv authored Mar 13, 2023
2 parents 7495392 + 730bae8 commit 24c76b2
Show file tree
Hide file tree
Showing 20 changed files with 3,695 additions and 3 deletions.
4 changes: 4 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ UseTab: Never
IndentWidth: 4
BreakBeforeBraces: Linux
AccessModifierOffset: -4
ForEachMacros:
- list_for_each_entry
- list_for_each_entry_safe
- hlist_for_each_entry
6 changes: 4 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ jobs:
sudo apt-get install libsdl2-dev
- name: default build
run: make
- name: check
run: make check
- name: check + tests
run: |
make check
make tests
- name: diverse configurations
run: |
make distclean ENABLE_EXT_C=0
Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ OBJS := \
emulate.o \
riscv.o \
elf.o \
cache.o \
$(OBJS_EXT) \
main.o

Expand All @@ -109,6 +110,7 @@ $(BIN): $(OBJS)

# RISC-V Architecture Tests
include mk/riscv-arch-test.mk
include mk/tests.mk

CHECK_ELF_FILES := \
hello \
Expand Down Expand Up @@ -143,7 +145,7 @@ endif
endif

clean:
$(RM) $(BIN) $(OBJS) $(deps)
$(RM) $(BIN) $(OBJS) $(deps) $(CACHE_OUT)
distclean: clean
-$(RM) $(DOOM_DATA) $(QUAKE_DATA)
$(RM) -r $(OUT)/id1
Expand Down
46 changes: 46 additions & 0 deletions mk/tests.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
CACHE_TEST_DIR := tests/cache
CACHE_BUILD_DIR := build/cache
TARGET := test-cache

CACHE_OBJS := \
test-cache.o

CACHE_OBJS := $(addprefix $(CACHE_BUILD_DIR)/, $(CACHE_OBJS))
OBJS += $(CACHE_OBJS)
deps += $(CACHE_OBJS:%.o=%.o.d)


CACHE_CHECK_ELF_FILES := \
cache-new \
cache-put \
cache-get \
cache-lru-replace \
cache-lfu-replace \
cache-lfu-ghost-replace

CACHE_OUT = $(addprefix $(CACHE_BUILD_DIR)/, $(CACHE_CHECK_ELF_FILES:%=%.out))

tests : $(CACHE_OUT)
$(Q)$(foreach e,$(CACHE_CHECK_ELF_FILES),\
$(PRINTF) "Running $(e) ... "; \
if cmp $(CACHE_TEST_DIR)/$(e).expect $(CACHE_BUILD_DIR)/$(e).out; then \
$(call notice, [OK]); \
else \
$(PRINTF) "Failed.\n"; \
exit 1; \
fi; \
)

$(CACHE_OUT): $(TARGET)
$(Q)$(foreach e,$(CACHE_CHECK_ELF_FILES),\
$(CACHE_BUILD_DIR)/$(TARGET) $(CACHE_TEST_DIR)/$(e).in > $(CACHE_BUILD_DIR)/$(e).out; \
)

$(TARGET): $(CACHE_OBJS)
$(VECHO) " CC\t$@\n"
$(Q)$(CC) $^ build/cache.o -o $(CACHE_BUILD_DIR)/$(TARGET)

$(CACHE_BUILD_DIR)/%.o: $(CACHE_TEST_DIR)/%.c
$(VECHO) " CC\t$@\n"
$(Q)mkdir -p $(dir $@)
$(Q)$(CC) -o $@ $(CFLAGS) -I./src -c -MMD -MF $@.d $<
Loading

0 comments on commit 24c76b2

Please sign in to comment.