Skip to content

Commit 61ef6a5

Browse files
committed
add optimization mode for size
1 parent 025616d commit 61ef6a5

File tree

5 files changed

+21
-3
lines changed

5 files changed

+21
-3
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,15 @@ Building of embARC MLI library
7373

7474
5. Result Quality shall be "S/N=1823.9 (65.2 db)"
7575

76+
## Optimizations for code size
77+
------------------------------
78+
By default the embARC MLI Library is build for optimal speed. If code size needs to be reduced, there are two things that can be done:
79+
1. For convolution and pooling layers there are specialized funtions for specific kernel sizes, they are called by a wrapper functions based on the parameters.
80+
These parameters are compile time constant in the application, so the application can directly call the specialized functions. This will reduce over all code size.
81+
Please be aware that the list of specializations is not guaranteed to be backwards compatible between releases.
82+
83+
2. Use a different optimization mode when calling the makefile. OPTMODE=size will optimize for size. default is OPTMODE=speed
84+
'gmake TCF_FILE=../../hw/em9d.tcf OPTMODE=size'
7685

7786
## Known Issues
7887
---------------

build/rules.mk

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ quote=$(subst %,$(Q)%, \
6464
# Global settings
6565
#=============================================================
6666
TOOLCHAIN ?= gnu
67+
#optmization mode
68+
OPTMODE ?= speed
6769

6870
export DEBUG_BUILD?=ON
6971
#export ASM_OUT?=OFF
@@ -76,6 +78,13 @@ endif
7678
# # CFLAGS += -Hon=Print_var_info
7779
#endif
7880

81+
ifeq ($(OPTMODE),size)
82+
CFLAGS += -O2 -Hlto
83+
endif
84+
ifeq ($(OPTMODE),speed)
85+
CFLAGS += -O3
86+
endif
87+
7988
#=============================================================
8089
# Files and directories
8190
#=============================================================

examples/example_cifar10_caffe/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ BUILD_DIR ?= ./obj
2828
OUT_NAME ?= example_cifar10_caffe
2929
ifeq ($(TOOLCHAIN),mwdt)
3030
# MWDT specific options
31-
CFLAGS = -Hnocopyr -Hpurge -Hheap=8K -Hstack=1K -Hfxapi -e_start -Bgrouplib -Hldopt=-q -O0 -Hsdata0
31+
CFLAGS = -Hnocopyr -Hpurge -Hheap=8K -Hstack=1K -Hfxapi -e_start -Bgrouplib -Hldopt=-q -Hsdata0 -Xdsp_ctrl=postshift,guard,convergent -Hdense_prologue
3232
else
3333
PREBUILT_LIB ?= $(EMBARC_MLI_DIR)/examples/prebuilt/libmli.a
3434

examples/example_har_smartphone/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ BUILD_DIR ?= ./obj
2828
OUT_NAME ?= example_har_smartphone
2929
ifeq ($(TOOLCHAIN),mwdt)
3030
# MWDT specific options
31-
CFLAGS = -Hnocopyr -Hpurge -Hheap=8K -Hstack=1K -Hfxapi -e_start -Bgrouplib -Hldopt=-q -O0 -Hsdata0
31+
CFLAGS = -Hnocopyr -Hpurge -Hheap=8K -Hstack=1K -Hfxapi -e_start -Bgrouplib -Hldopt=-q -Hsdata0 -Xdsp_ctrl=postshift,guard,convergent -Hdense_prologue
3232
else
3333
PREBUILT_LIB ?= $(EMBARC_MLI_DIR)/examples/prebuilt/libmli.a
3434

lib/make/makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ LIBRARY_DIR ?= ../../bin
5353
OUT_NAME ?= libmli
5454
BUILD_DIR ?= ../../obj
5555
GEN_DIR ?= ../gen
56-
CFLAGS += -O3 -Xdsp_ctrl=postshift,guard,convergent -Hnocopyr -Hfxapi -Hpurge -Hsdata0 -Hdense_prologue
56+
CFLAGS += -Xdsp_ctrl=postshift,guard,convergent -Hnocopyr -Hfxapi -Hpurge -Hsdata0 -Hdense_prologue
5757

5858
vpath %.py $(GEN_DIR)
5959
vpath %.txt $(GEN_DIR)

0 commit comments

Comments
 (0)