Skip to content

Commit f4d3c0f

Browse files
dyudakovJaccovG
authored andcommitted
Updated ciffar10 example for GNU
* Updated README.md fixed links * fixed typo in makefile and README.md * fixed typo in example_har_smartphone/Makefile, fixed default target to .DEFAULT_GOAL * fixed lib/make/makefile added ignored error of clean rules
1 parent 136cbb8 commit f4d3c0f

File tree

11 files changed

+523
-42
lines changed

11 files changed

+523
-42
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ examples and documentation.
3434

3535
## Building and quick start
3636
---------------------------
37-
By default embARC MLI Library can be build for (hw/em9d.tcf) which is based on the standard EM9D Voice Audio template,
37+
By default embARC MLI Library can be build for [/hw/em9d.tcf](/hw/em9d.tcf) which is based on the standard EM9D Voice Audio template,
3838
defined in MetaWare Development Tools, with extended XY memory. embARC MLI Library can be also built for a specific
3939
EM or HS configuration.
4040

4141
Build requirements:
42-
1. MetaWare Development tools 2018.09 or later
42+
1. MetaWare Development tools 2018.12 or later
4343

4444
Building of embARC MLI library
4545
1. Open command line and change working directory to './lib/make/'
@@ -56,7 +56,7 @@ Building of embARC MLI library
5656
3. Run CIFAR10 example
5757
'gmake run TCF_FILE=../../hw/em9d.tcf'
5858

59-
4. Result Quality shall be "S/N=2344.4 (67.4 db)"
59+
4. Result Quality shall be "S/N=3638.6 (71.2 db)"
6060

6161
## Building and running [Human Activity Recognition example](examples/example_har_smartphone/README.md)
6262
----------------------------------------------------------

examples/example_cifar10_caffe/Makefile

Lines changed: 54 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,32 +27,71 @@
2727

2828
# default toolchain
2929
TOOLCHAIN ?= mwdt
30-
TCF_FILE ?= ../../hw/em9d.tcf
30+
31+
# default hardware config file
32+
TCF_FILE ?= ../../hw/em9d.tcf
3133

3234
# Directories and files
33-
PUBLIC_DIR ?= ../..
34-
SRC_DIRS = $(PUBLIC_DIR)/examples/example_cifar10_caffe \
35-
$(PUBLIC_DIR)/examples/auxiliary
35+
EMBARC_MLI_DIR ?= ../..
36+
SRC_DIRS = $(EMBARC_MLI_DIR)/examples/example_cifar10_caffe \
37+
$(EMBARC_MLI_DIR)/examples/auxiliary
3638

37-
INC_DIRS = . \
38-
$(PUBLIC_DIR)/include\
39-
$(PUBLIC_DIR)/examples/auxiliary
39+
INC_DIRS = . \
40+
$(EMBARC_MLI_DIR)/include \
41+
$(EMBARC_MLI_DIR)/examples/auxiliary
4042

41-
EXT_LIBS ?= $(PUBLIC_DIR)/bin/libmli.a
42-
OUT_DIR ?= ./bin
43-
BUILD_DIR ?= ./obj
44-
OUT_NAME ?= example_cifar10_caffe
45-
CFLAGS = -Hnocopyr -Hpurge -Hheap=16K -Hstack=4K -Hfxapi -e_start -Bgrouplib -Hldopt=-q -O0
43+
EXT_LIBS_DIR ?= $(EMBARC_MLI_DIR)/bin
44+
EXT_LIBS ?= $(EXT_LIBS_DIR)/libmli.a
45+
OUT_DIR ?= ./bin
46+
BUILD_DIR ?= ./obj
47+
OUT_NAME ?= example_cifar10_caffe
48+
ifeq ($(TOOLCHAIN),mwdt)
49+
# MWDT specific options
50+
CFLAGS = -Hnocopyr -Hpurge -Hheap=8K -Hstack=4K -Hfxapi -e_start -Bgrouplib -Hldopt=-q -O0
51+
else
52+
PREBUILT_LIB ?= $(EMBARC_MLI_DIR)/examples/prebuilt/libmli.a
4653

47-
all: lib app
54+
# GNU toolchain specific options - correct it according to your target platform settings (see build_configuration.txt for input)
55+
#Iot DevKit config
56+
CFLAGS = -mcpu=em4_dmips -mlittle-endian -mcode-density -mdiv-rem -mswap -mnorm -mmpy-option=6 -mbarrel-shifter -mxy
57+
58+
# The embARC MLI Library specific options it according to your target platform settings
59+
#(EM5D or EM7D platform)
60+
#CFLAGS += -DV2DSP
61+
#(EM9D or EM11D platform)
62+
CFLAGS += -DV2DSP_XY
63+
#(HS45D or HS47D platform)
64+
#CFLAGS += -DV2DSP_WIDE
4865

49-
include $(PUBLIC_DIR)/build/rules.mk
66+
# GNU toolchain linker specific options
67+
LDFLAGS = --defsym=__DEFAULT_HEAP_SIZE=8k
68+
LDFLAGS += --defsym=__DEFAULT_STACK_SIZE=4k
69+
LDFLAGS += -Map $(OUT_DIR)/$(OUT_NAME).map
70+
71+
#specific options for run the example with the MetaWare Debuger on the nSim simulator.
72+
DBG_OPTS = -cmd="read mdb_com_gnu"
73+
endif
5074

5175
.PHONY: clean all lib cleanall app
52-
.DEFAULT: all
76+
.DEFAULT_GOAL := all
77+
78+
all: lib app
79+
80+
$(EXT_LIBS): $(EXT_LIBS_DIR)
81+
@echo Copy prebuilt library $(PREBUILT_LIB) to $@
82+
@$(CP) $(call fix_platform_path,$(PREBUILT_LIB)) $(call fix_platform_path,$@)
83+
84+
$(EXT_LIBS_DIR):
85+
$(MKDIR) $(call fix_platform_path, $@ )
86+
87+
include $(EMBARC_MLI_DIR)/build/rules.mk
5388

89+
ifeq ($(TOOLCHAIN),mwdt)
5490
lib:
5591
@ $(MAKE) generic_lib -C ..$(PS)..$(PS)lib$(PS)make$(PS) TCF_FILE="$(TCF_FILE)"
92+
else
93+
lib: $(EXT_LIBS)
94+
endif
5695

5796
app: generic_app
5897

examples/example_cifar10_caffe/README.md

Lines changed: 64 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,18 @@ Example is based on standard [Caffe tutorial](http://caffe.berkeleyvision.org/ga
55

66
Quick Start
77
--------------
8-
hw/em9d.tcf template is a default template for this example. Other templated can be also used.
98

10-
0. embARC MLI Library must be built for required hardware configuration first. See [embARC MLI Library building and quick start](public/README.md).
9+
Example supports building using MetaWare Development tools and ARC GNU toolchain and running with MetaWare Debuger on nSim simulator.
10+
11+
### Build with MetaWare Development tools
12+
13+
Build requirements:
14+
- MetaWare Development tools version 2018.12 or higher
15+
- gmake
16+
17+
Here we will consider building for [/hw/em9d.tcf](/hw/em9d.tcf) template. This template is a default template for this example. Other templated can be also used.
18+
19+
0. embARC MLI Library must be built for required hardware configuration first. See [embARC MLI Library building and quick start](/README.md#building-and-quick-start).
1120

1221
1. Open command line and change working directory to './examples/example_cifar10_caffe/'
1322

@@ -19,11 +28,54 @@ hw/em9d.tcf template is a default template for this example. Other templated can
1928

2029
gmake TCF_FILE=../../hw/em9d.tcf
2130

22-
4. Run example
31+
### Run example with MetaWare Debuger on nSim simulator.
2332

2433
gmake run TCF_FILE=../../hw/em9d.tcf
2534

26-
5. Result Quality shall be "S/N=2344.4 (67.4 db)"
35+
Result Quality shall be "S/N=3638.6 (71.2 db)"
36+
37+
### Build with ARC GNU toolchain
38+
39+
Here we will consider building with ARC GNU toolchain. As a platform for the assembly, we use the [IoT Devkit](https://embarc.org/embarc_osp/doc/build/html/board/iotdk.html) from [the embARC Open Software Platform (OSP)](https://embarc.org/embarc_osp/doc/build/html/introduction/introduction.html#)
40+
41+
Build requirements:
42+
- ARC GNU toolchain version 2018.09 or higher
43+
- embARC MLI Library prebuilt with MetaWare Development tools for IoT Devkit hardware configuration
44+
- gmake
45+
46+
0. Prebuilt embARC MLI Library must be copyied into the ./examples/prebuilt folder.
47+
48+
1. Open command line and change working directory to './examples/example_cifar10_caffe/'
49+
50+
2. Clean previous build artifacts (optional)
51+
52+
gmake TOOLCHAIN=gnu clean
53+
54+
3. Build example
55+
56+
gmake TOOLCHAIN=gnu
57+
58+
Notes: IoT Devkit hardware configuration is specifed in Makefile. Additionally used memory.x linkscript file for GNU linker.
59+
60+
### Run example with MetaWare Debuger on nSim simulator.
61+
62+
Run requirements:
63+
- MetaWare Development tools version 2018.12 or higher
64+
- arcem9d.tcf file with hardware configuration of IoT Devkit for setup nSim.
65+
66+
0. Copy the [arcem9d.tcf](https://github.com/foss-for-synopsys-dwc-arc-processors/embarc_osp/blob/master/board/iotdk/configs/10/tcf/arcem9d.tcf) file into example folder.
67+
68+
1. Run example
69+
70+
gmake run TOOLCHAIN=gnu TCF_FILE=arcem9d.tcf
71+
72+
Result Quality shall be "S/N=3638.6 (71.2 db)"
73+
74+
Notes: Example built by ARC GNU tools is run using mdb_com_gnu script file. Modify this file to customize the example run mode. See [More Options on Building and Running](README.md#more-options-on-building-and-running)
75+
76+
### Run example without MetaWare Development tools
77+
78+
See documentation on [IoT Devkit](https://embarc.org/embarc_osp/doc/build/html/board/iotdk.html) on how to run executable built with [ARC GNU](https://embarc.org/toolchain/index.html) and [ARC open source development tools](https://embarc.org/embarc_osp/doc/build/html/index.html) on IoT Devkit.
2779

2880

2981
Example Structure
@@ -43,11 +95,16 @@ Structure of example application may be logically divided on three parts:
4395
* ../auxiliary/tests_aux.h(.c)
4496
* ../auxiliary/idx_file.h(.c)
4597

46-
Example structure also contains test set including small subset of CIFAR-10 (20 vectors organized in IDX file format).
47-
98+
Example structure contains test set including small subset of CIFAR-10 (20 vectors organized in IDX file format).
99+
100+
Example structure also contains auxiliary files for development tools:
101+
* arcem9d.lcf - linkscript file for MetaWare linker.
102+
* memory.x - linkscript file for GNU linker.
103+
* mdb_com_gnu - command script file for MetaWare Debugger.
104+
48105
More Options on Building and Running
49106
---------------------------------------
50-
CIFAR-10 example application is implemented in the same way as LSTM Based HAR example and provides the same configuration and running abilities. For more details see appropriate HAR example [description part](public/examples/example_har_smartphone/README.md).
107+
CIFAR-10 example application is implemented in the same way as LSTM Based HAR example and provides the same configuration and running abilities. For more details see appropriate HAR example [description part](/examples/example_har_smartphone/README.md#more-options-on-building-and-running).
51108

52109
References
53110
----------------------------
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
MEMORY {
2+
# SYSTEM0 : ORIGIN = 0x00000000, LENGTH = 0x20000000
3+
ICCM0 : ORIGIN = 0x20000000, LENGTH = 0x00040000
4+
# CCMWRAP0: ORIGIN = 0x20040000, LENGTH = 0x0ffc0000
5+
# SYSTEM1 : ORIGIN = 0x30000000, LENGTH = 0x50000000
6+
DCCM : ORIGIN = 0x80000000, LENGTH = 0x00020000
7+
# CCMWRAP1: ORIGIN = 0x80020000, LENGTH = 0x0ffe0000
8+
# SYSTEM2 : ORIGIN = 0x90000000, LENGTH = 0x30000000
9+
XCCM : ORIGIN = 0xc0000000, LENGTH = 0x00008000
10+
# CCMWRAP2: ORIGIN = 0xc0008000, LENGTH = 0x0fff8000
11+
# SYSTEM3 : ORIGIN = 0xd0000000, LENGTH = 0x10000000
12+
YCCM : ORIGIN = 0xe0000000, LENGTH = 0x00008000
13+
# CCMWRAP3: ORIGIN = 0xe0008000, LENGTH = 0x0fff8000
14+
# SYSTEM4 : ORIGIN = 0xf0000000, LENGTH = 0x10000000
15+
}
16+
SECTIONS {
17+
GROUP: {
18+
.vectors (TEXT) SIZE(DEFINED _IVTSIZE?_IVTSIZE:684): {} = FILL(0xa5a5a5a5,4)
19+
.text? : { *('.text$crt*') }
20+
* (TEXT): {}
21+
* (LIT): {}
22+
} > ICCM0
23+
GROUP: {
24+
/* _SDA_BASE_ computed implicitly */
25+
.sdata?: {}
26+
.sbss?: {}
27+
* (DATA): {}
28+
* (BSS): {}
29+
.mli_model_p2 : {}
30+
.stack ALIGN(4) SIZE(DEFINED _STACKSIZE?_STACKSIZE:32768): {}
31+
.heap? ALIGN(4) SIZE(DEFINED _HEAPSIZE?_HEAPSIZE:0): {}
32+
} > DCCM
33+
GROUP: {
34+
.Xdata? : {}
35+
.mli_model : {}
36+
} > XCCM
37+
GROUP: {
38+
.Ydata? : {}
39+
} > YCCM
40+
41+
}

examples/example_cifar10_caffe/cifar10_constants.h

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,31 @@ typedef int16_t w_type;
4747
// Defining data sections attributes
4848
//===================================
4949
#if (ARC_PLATFORM == V2DSP_XY)
50-
// Model Weights attribute
50+
#if defined (__GNUC__) && !defined (__CCAC__)
51+
// ARC GNU tools
52+
// Model Weights attribute
53+
#define _Wdata_attr __attribute__((section(".mli_model")))
54+
#define _W _Wdata_attr
55+
56+
// Model Weights (part 2) attribute
57+
#define _W2data_attr __attribute__((section(".mli_model_p2")))
58+
#define _W2 _W2data_attr
59+
60+
// Bank X (XCCM) attribute
61+
#define __Xdata_attr __attribute__((section(".Xdata")))
62+
#define _X __Xdata_attr
63+
64+
// Bank Y (YCCM) attribute
65+
#define __Ydata_attr __attribute__((section(".Ydata")))
66+
#define _Y __Ydata_attr
67+
68+
// Bank Z (DCCM) attribute
69+
#define __Zdata_attr __attribute__((section(".Zdata")))
70+
#define _Z __Zdata_attr
71+
72+
#else
73+
// Metaware tools
74+
// Model Weights attribute
5175
#define _Wdata_attr __attribute__((section(".mli_model")))
5276
#define _W __xy _Wdata_attr
5377

@@ -66,6 +90,7 @@ typedef int16_t w_type;
6690
// Bank Z (DCCM) attribute
6791
#define __Zdata_attr __attribute__((section(".Zdata")))
6892
#define _Z __xy __Zdata_attr
93+
#endif // if defined (__GNUC__) && !defined (__CCAC__)
6994

7095
#else
7196
#define _X __attribute__((section(".mli_ir_buf")))
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//This script emulates the arvc and argv parameters in examples for GNU tools
2+
3+
off=cr_for_more
4+
5+
break main
6+
7+
run
8+
//Select one mode to uncomment lines with the fillmem command
9+
10+
//----------mode 1-----------------------------------
11+
//--Built-in input processing------------------------
12+
fillmem 0x1 &mode 1
13+
fillmem "dummy_for_check" &param[0][0] 15
14+
15+
//----------mode 2-----------------------------------
16+
//--External test-set processing---------------------
17+
//fillmem 0x2 &mode 1
18+
//fillmem "dummy_for_check" &param[0][0] 15
19+
//fillmem "small_test_base/tests.idx" &param[1][0] 25
20+
21+
//-----------mode 3----------------------------------
22+
//--Accuracy measurement for testset-----------------
23+
//fillmem 0x3 &mode 1
24+
//fillmem "dummy_for_check" &param[0][0] 15
25+
//fillmem "small_test_base/tests.idx" &param[1][0] 25
26+
//fillmem "small_test_base/labels.idx" &param[2][0] 26
27+
28+
run

0 commit comments

Comments
 (0)