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

Add adaptive replacement cache #118

Merged
merged 2 commits into from
Mar 13, 2023
Merged
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
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_COMPUTED_GOTO=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