Skip to content

Commit 85094f3

Browse files
Fix-Pointxiaoxiang781216
authored andcommitted
benchmarks: support tinymembench
This patch adds tinymembench for memory bandwidth and latency measuring. Signed-off-by: ouyangxiangzhen <[email protected]>
1 parent b42bbcb commit 85094f3

File tree

5 files changed

+214
-0
lines changed

5 files changed

+214
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
From f478ab0f728bea1ed352844339f8bdc87f7792fa Mon Sep 17 00:00:00 2001
2+
From: ouyangxiangzhen <[email protected]>
3+
Date: Fri, 31 May 2024 19:58:48 +0800
4+
Subject: [PATCH] tinymembench: fix compiling error for NuttX
5+
6+
This patch fix compilation error: Resolve conflict between `util.c` function fmin and math library function fmin
7+
8+
Signed-off-by: ouyangxiangzhen <[email protected]>
9+
---
10+
util.c | 2 +-
11+
1 file changed, 1 insertion(+), 1 deletion(-)
12+
13+
diff --git a/util.c b/util.c
14+
index a0d562c..539049f 100644
15+
--- a/util.c
16+
+++ b/util.c
17+
@@ -303,7 +303,7 @@ double gettime(void)
18+
return (double)((int64_t)tv.tv_sec * 1000000 + tv.tv_usec) / 1000000.;
19+
}
20+
21+
-double fmin(double a, double b)
22+
+__attribute__((weak)) double fmin(double a, double b)
23+
{
24+
return a < b ? a : b;
25+
}
26+
--
27+
2.34.1
28+
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#
2+
# Copyright (C) 2024 Xiaomi Corporation
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
5+
# use this file except in compliance with the License. You may obtain a copy of
6+
# the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
# License for the specific language governing permissions and limitations under
14+
# the License.
15+
#
16+
17+
if(CONFIG_BENCHMARK_TINY_MEMBENCH)
18+
19+
set(TINYMB_UNPACK ${CMAKE_CURRENT_LIST_DIR}/tinymembench)
20+
set(TINYMB_URL https://github.com/ssvb/tinymembench/archive)
21+
set(TINYMB_ZIP master.zip)
22+
23+
if(NOT EXISTS ${TINYMB_UNPACK})
24+
25+
FetchContent_Declare(
26+
tinymb_fetch
27+
URL ${TINYMB_URL}/${TINYMB_ZIP} SOURCE_DIR ${TINYMB_UNPACK} BINARY_DIR
28+
${CMAKE_BINARY_DIR}/apps/benchmarks/tinymembench/tinymembench
29+
PATCH_COMMAND
30+
patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} <
31+
${CMAKE_CURRENT_LIST_DIR}/0001-tinymembench-fix-compiling-error-for-NuttX.patch
32+
DOWNLOAD_NO_PROGRESS true
33+
TIMEOUT 30)
34+
35+
FetchContent_GetProperties(tinymb_fetch)
36+
if(NOT tinymb_fetch_POPULATED)
37+
FetchContent_Populate(tinymb_fetch)
38+
endif()
39+
40+
endif()
41+
42+
list(APPEND CFLAGS -Wno-unused-but-set-variable -Wno-unused-variable
43+
-Wno-strict-prototypes)
44+
45+
set(SRCS tinymembench/main.c)
46+
47+
list(
48+
APPEND
49+
SRCS
50+
tinymembench/aarch64-asm.S
51+
tinymembench/arm-neon.S
52+
tinymembench/x86-sse2.S
53+
tinymembench/mips-32.S
54+
tinymembench/asm-opt.c
55+
tinymembench/util.c)
56+
57+
nuttx_add_application(
58+
NAME
59+
tinymembench
60+
PRIORITY
61+
${CONFIG_BENCHMARK_TINY_MEMBENCH_PRIORITY}
62+
STACKSIZE
63+
${CONFIG_BENCHMARK_TINY_MEMBENCH_STACKSIZE}
64+
MODULE
65+
${CONFIG_BENCHMARK_TINY_MEMBENCH}
66+
COMPILE_FLAGS
67+
${CFLAGS}
68+
SRCS
69+
${SRCS})
70+
endif()

benchmarks/tinymembench/Kconfig

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#
2+
# Copyright (C) 2024 Xiaomi Corporation
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
config BENCHMARK_TINY_MEMBENCH
18+
tristate "TinyMemBench"
19+
default n
20+
---help---
21+
Measure the memory bandwidth and latency
22+
23+
if BENCHMARK_TINY_MEMBENCH
24+
25+
config BENCHMARK_TINY_MEMBENCH_PRIORITY
26+
int "TinyMemBench task priority"
27+
default 100
28+
29+
config BENCHMARK_TINY_MEMBENCH_STACKSIZE
30+
int "TinyMemBench stack size"
31+
default DEFAULT_TASK_STACKSIZE
32+
33+
endif

benchmarks/tinymembench/Make.defs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#
2+
# Copyright (C) 2024 Xiaomi Corporation
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
ifneq ($(CONFIG_BENCHMARK_TINY_MEMBENCH),)
18+
CONFIGURED_APPS += $(APPDIR)/benchmarks/tinymembench
19+
endif

benchmarks/tinymembench/Makefile

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#
2+
# Copyright (C) 2024 Xiaomi Corporation
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
include $(APPDIR)/Make.defs
18+
19+
PROGNAME = tinymembench
20+
PRIORITY = $(CONFIG_BENCHMARK_TINY_MEMBENCH_PRIORITY)
21+
STACKSIZE = $(CONFIG_BENCHMARK_TINY_MEMBENCH_STACKSIZE)
22+
MODULE = $(CONFIG_BENCHMARK_TINY_MEMBENCH)
23+
24+
TINYMB_UNPACK = tinymembench
25+
TINYMB_GIT = github.com/ssvb/tinymembench
26+
TINYMB_URL = https://github.com/ssvb/tinymembench/archive
27+
TINYMB_VERSION = master
28+
TINYMB_ZIP = $(TINYMB_UNPACK)-$(TINYMB_VERSION).zip
29+
UNPACK ?= unzip -q -o
30+
31+
$(TINYMB_ZIP):
32+
@echo "Downloading: $(TINYMB_URL)"
33+
$(Q) curl -L $(TINYMB_URL)/$(TINYMB_VERSION).zip -o $(TINYMB_UNPACK)-$(TINYMB_VERSION).zip
34+
35+
$(TINYMB_UNPACK): $(TINYMB_ZIP)
36+
@echo "Unpacking: $(TINYMB_ZIP) -> $(TINYMB_UNPACK)"
37+
$(Q) $(UNPACK) $(TINYMB_ZIP)
38+
$(Q) mv tinymembench-$(TINYMB_VERSION) $(TINYMB_UNPACK)
39+
$(Q) touch $(TINYMB_UNPACK)
40+
@echo "Patching: Applying patch"
41+
$(Q) cd tinymembench && patch -p1 < ../0001-tinymembench-fix-compiling-error-for-NuttX.patch
42+
43+
ifeq ($(wildcard $(TINYMB_UNPACK)/.git),)
44+
context:: $(TINYMB_UNPACK)
45+
46+
distclean::
47+
$(call DELDIR, $(TINYMB_UNPACK))
48+
$(call DELFILE, $(TINYMB_ZIP))
49+
endif
50+
51+
ASRCS += $(TINYMB_UNPACK)/aarch64-asm.S
52+
ASRCS += $(TINYMB_UNPACK)/arm-neon.S
53+
ASRCS += $(TINYMB_UNPACK)/x86-sse2.S
54+
ASRCS += $(TINYMB_UNPACK)/mips-32.S
55+
56+
CSRCS += $(TINYMB_UNPACK)/asm-opt.c
57+
CSRCS += $(TINYMB_UNPACK)/util.c
58+
59+
MAINSRC = $(TINYMB_UNPACK)/main.c
60+
61+
CFLAGS += -Wno-unused-but-set-variable -Wno-unused-variable
62+
CFLAGS += -Wno-strict-prototypes
63+
64+
include $(APPDIR)/Application.mk

0 commit comments

Comments
 (0)