mirror of
https://github.com/libretro/RetroArch.git
synced 2026-11-23 09:49:34 -10:00
Rewind diffing (find_change for the next dirty word, find_same for the end of a dirty run) gains an AVX-512BW tier next to SSE2 and AVX2, and find_same gets the AVX2 form it lacked. Tiers are picked once from cpu_features_get(); RETRO_SIMD_AVX512 promises BW. Three things make the wide scans pay off rather than lose to SSE2: - The two blocks are now 64-byte aligned and a whole number of lines apart, so a scan position has the same offset within a line in both. The wide loops step back to a line boundary inside bytes already proven equal, and from there no load straddles a cache line on either block. Before this, AVX-512 lost to SSE2 on dirty states. - Each scan starts narrow (16 bytes, then 32) and only then goes to full width, since most scans in a dirty state end within the first few words. - raw_compress is compiled once per tier with the scans inlined. A target function cannot inline into baseline code, and a call per scan cost more than the scan on dirty states. All tiers write byte-identical patches. Median time against SSE2, paired runs on an Emerald Rapids Xeon (lower is faster): state pattern avx2 avx512 16K clean 0.49 0.28 64K 1 dirty in 4096 0.60 0.45 256K 16-word runs 0.61 0.49 256K 1 dirty in 256 0.70 0.61 1M clean 0.85 0.84 any 1 dirty in 64 ~1.0 ~1.0-1.05 4M+ any ~1.0 ~1.0 (memory bound) samples/state_rewind allocates its blocks the same way and checks that every tier the CPU has writes the same patch over 300 seeded pairs, with the sentinel and scan-pad cases re-run under each tier.
55 lines
1.3 KiB
Makefile
55 lines
1.3 KiB
Makefile
include ../sample_objdir.mk
|
|
|
|
compiler := gcc
|
|
TARGET := state_rewind_test
|
|
|
|
CORE_DIR = ../..
|
|
LIBRETRO_COMM_DIR = $(CORE_DIR)/libretro-common
|
|
INCDIRS := -I$(LIBRETRO_COMM_DIR)/include -I$(CORE_DIR) -I$(CORE_DIR)/deps
|
|
|
|
CC := $(compiler)
|
|
flags += -std=gnu99
|
|
|
|
# The harness includes state_manager.c so it can drive the codec and the
|
|
# ring directly; the frontend it calls into is stubbed.
|
|
SOURCES_C := \
|
|
state_rewind_test.c \
|
|
$(LIBRETRO_COMM_DIR)/features/features_cpu.c \
|
|
$(LIBRETRO_COMM_DIR)/memmap/memalign.c \
|
|
$(LIBRETRO_COMM_DIR)/compat/compat_strl.c
|
|
|
|
CFLAGS += -Wall $(INCDIRS) -DRARCH_INTERNAL -DHAVE_REWIND -DHAVE_THREADS -DHAVE_CONFIGFILE -DHAVE_MENU -D_GNU_SOURCE
|
|
LDFLAGS += -lm -lpthread
|
|
|
|
ifneq ($(SAN),)
|
|
SANITIZER := $(SAN)
|
|
endif
|
|
ifneq ($(SANITIZER),)
|
|
CFLAGS := -fsanitize=$(SANITIZER) -fno-omit-frame-pointer -g1 $(CFLAGS)
|
|
LDFLAGS := -fsanitize=$(SANITIZER) $(LDFLAGS)
|
|
endif
|
|
|
|
OBJS := $(call sample_objs,$(SOURCES_C:.c=.o))
|
|
|
|
all: $(TARGET)
|
|
|
|
%.o: %.c
|
|
$(CC) $(INCDIRS) $(CFLAGS) $(flags) -c -o$@ $<
|
|
|
|
$(SAMPLE_OBJDIR)/%.o: $$(call sample_src,$$*).c
|
|
@mkdir -p $(@D)
|
|
$(CC) $(INCDIRS) $(CFLAGS) $(flags) -c -o$@ $<
|
|
|
|
$(TARGET): $(OBJS)
|
|
$(CC) -o$@ $(OBJS) $(LDFLAGS)
|
|
|
|
check: $(TARGET)
|
|
./$(TARGET)
|
|
|
|
clean:
|
|
rm -rf $(SAMPLE_OBJDIR)
|
|
rm -f $(OBJS)
|
|
rm -f $(TARGET)
|
|
|
|
.PHONY: clean all check
|