diff --git a/ports/raspberrypi/boards/pajenicko_picopad/mpconfigboard.mk b/ports/raspberrypi/boards/pajenicko_picopad/mpconfigboard.mk index b5df0e6ecb5..03a203dc2de 100644 --- a/ports/raspberrypi/boards/pajenicko_picopad/mpconfigboard.mk +++ b/ports/raspberrypi/boards/pajenicko_picopad/mpconfigboard.mk @@ -50,8 +50,3 @@ CFLAGS += \ # Must be accompanied by a linker script change CFLAGS += -DCIRCUITPY_FIRMWARE_SIZE='(1536 * 1024)' - -# The rp2 port default is -O3; on this Cortex-M0+ (no SIMD/FPU, 16 KB XIP cache) -O2 plus -# these five loop passes measures within +-1% of -O3 across the picogame render kernels -# while using ~150 KB less flash (gc.o/vm.o stay -O3 via SUPEROPT regardless). -OPTIMIZATION_FLAGS = -O2 -funswitch-loops -fpredictive-commoning -fgcse-after-reload -ftree-partial-pre -fsplit-paths diff --git a/ports/raspberrypi/boards/raspberry_pi_pico/mpconfigboard.mk b/ports/raspberrypi/boards/raspberry_pi_pico/mpconfigboard.mk index 20607d50e41..2026a9727d9 100644 --- a/ports/raspberrypi/boards/raspberry_pi_pico/mpconfigboard.mk +++ b/ports/raspberrypi/boards/raspberry_pi_pico/mpconfigboard.mk @@ -9,4 +9,7 @@ CHIP_FAMILY = rp2 EXTERNAL_FLASH_DEVICES = "W25Q16JVxQ" CIRCUITPY__EVE = 1 + +CIRCUITPY_PICOGAME = 1 +CIRCUITPY_PICOGAME_FAST_DISPLAY = 1 CIRCUITPY_PICODVI = 1 diff --git a/ports/raspberrypi/boards/raspberry_pi_pico_w/mpconfigboard.mk b/ports/raspberrypi/boards/raspberry_pi_pico_w/mpconfigboard.mk index e658db65f4d..bb7a9208899 100644 --- a/ports/raspberrypi/boards/raspberry_pi_pico_w/mpconfigboard.mk +++ b/ports/raspberrypi/boards/raspberry_pi_pico_w/mpconfigboard.mk @@ -12,6 +12,9 @@ CIRCUITPY_USB_HOST = 0 CIRCUITPY__EVE = 1 +CIRCUITPY_PICOGAME = 1 +CIRCUITPY_PICOGAME_FAST_DISPLAY = 1 + CIRCUITPY_CYW43 = 1 CIRCUITPY_SSL = 1 CIRCUITPY_HASHLIB = 1 diff --git a/ports/raspberrypi/mpconfigport.mk b/ports/raspberrypi/mpconfigport.mk index 551ab00ab47..c62df7a5692 100644 --- a/ports/raspberrypi/mpconfigport.mk +++ b/ports/raspberrypi/mpconfigport.mk @@ -63,6 +63,33 @@ CIRCUITPY_TOUCHIO ?= 1 # delay in ms before calling cyw43_arch_init_with_country CIRCUITPY_CYW43_INIT_DELAY ?= 1000 + +# -O2 plus the two flags that carry -O3 here, which is 130 KB less flash than -O3 for the same +# speed on everything measured. That headroom is what lets a board fit. +# +# -funswitch-loops Hoists a test that cannot change inside a loop out of it and keeps +# one copy of the body per value. Costs 16 KB, because it duplicates +# loop bodies in 94 functions. Buys 24 % on a flipped sprite blit, +# 9 % on a textured floor, and 1-2 % on bitmaptools.alphablend and +# the ulab reductions. +# +# -fvect-cost-model=dynamic -O2 sets very-cheap, which turns nearly every loop down. dynamic +# accepts them, which here means memset, memcpy and a 16-bit row +# fill get unrolled with an alignment prologue. Costs 4 KB. Buys +# 37 % on rectangle fills and bytearray copies and 16 % on aesio. +# Runs shorter than the prologue lose: a four-pixel span fill is +# 7 % slower. +# +# The four other -O3 loop passes we measured (-fpredictive-commoning, -fgcse-after-reload, +# -ftree-partial-pre, -fsplit-paths) emit the same code as -O2 for the loops that matter here, +# so they are left out. So is the rest of -O3: its inline parameters alone are 92 KB, and they +# also take the 60-factorial loop 56 % slower. +# +# Neither flag reaches the bytecode dispatch loop: py/py.mk builds gc.o and vm.o at -O3 whatever +# this is set to, so pure interpreter work measures the same under all of them. +# +# RP2350 keeps plain -O3. There an -O2 set runs 24-41 % slower on fill loops. +OPTIMIZATION_FLAGS ?= -O2 -funswitch-loops -fvect-cost-model=dynamic endif ifeq ($(CHIP_VARIANT),RP2350)