@@ -6,3 +6,59 @@ config BR2_PACKAGE_COREMARK
used in embedded systems
https://www.eembc.org/coremark/
+
+if BR2_PACKAGE_COREMARK
+config BR2_PACKAGE_COREMARK_MULTITHREAD
+ int "coremark number of parallel executions"
+ default 4
+ help
+ Additional CFLAGS to pass to CoreMark platform specific port.
+ Any additional flags indicated here will be added to the
+ CFLAGS_PORT variable.
+
+choice
+ prompt "coremark implementation"
+ help
+ Coremark provides either POSIX thread API if supported by the
+ toolchain, or forking.
+ select BR2_PACKAGE_COREMARK_IMPLEMENTATION_THREAD if BR2_TOOLCHAIN_HAS_THREADS
+ select BR2_PACKAGE_COREMARK_IMPLEMENTATION_FORK
+
+if BR2_TOOLCHAIN_HAS_THREADS
+config BR2_PACKAGE_COREMARK_IMPLEMENTATION_THREAD
+ bool "POSIX thread API"
+endif
+
+if !BR2_TOOLCHAIN_HAS_THREADS
+comment "POSIX thread API requires the toolchain to have threading support"
+endif
+
+config BR2_PACKAGE_COREMARK_IMPLEMENTATION_FORK
+ bool "Forking"
+endchoice
+
+
+config BR2_PACKAGE_COREMARK_ITERATIONS
+ int "number of coremark benchmark iterations"
+ default 0
+ help
+ From Coremark documentation:
+ By default, the benchmark will run between 10-100 seconds. To
+ override, use ITERATIONS=N.
+ Minimum required run time: Results are only valid for reporting
+ if the benchmark ran for at least 10 secs!
+
+ This option allows to indicate this number of iterations, 0
+ being the default, and running the benchmark for 10-100 seconds.
+
+config BR2_PACKAGE_COREMARK_PORT_CFLAGS_EXTRA
+ string "coremark port extra CFLAGS"
+ default ""
+ help
+ Additional CFLAGS to pass to CoreMark platform specific port.
+ Any additional flags indicated here will be added to the
+ CFLAGS_PORT variable.
+ Please use with caution, since this can break Coremark build.
+ Use only if you have additional flags unrelated to Coremark
+ internal build.
+endif
@@ -9,14 +9,30 @@ COREMARK_SITE = $(call github,eembc,coremark,v$(COREMARK_VERSION))
COREMARK_LICENSE = Apache-2.0
COREMARK_LICENSE_FILES = LICENSE.md
+COREMARK_CFLAGS = \
+ $(TARGET_CFLAGS) \
+ $(call qstrip,$(BR2_PACKAGE_COREMARK_PORT_CFLAGS_EXTRA))
+
+ifeq ($(BR2_PACKAGE_COREMARK_IMPLEMENTATION_THREAD),y)
+ COREMARK_CFLAGS += -DUSE_PTHREAD -pthread -lpthread
+else # !BR2_PACKAGE_COREMARK_IMPLEMENTATION_THREAD
+ ifeq ($(BR2_PACKAGE_COREMARK_IMPLEMENTATION_FORK),y)
+ COREMARK_CFLAGS += -DUSE_FORK
+ else # !BR2_PACKAGE_COREMARK_IMPLEMENTATION_FORK
+ $(error Unknown Coremark implementation)
+ endif # !BR2_PACKAGE_COREMARK_IMPLEMENTATION_FORK
+endif # !BR2_PACKAGE_COREMARK_IMPLEMENTATION_THREAD
+COREMARK_CFLAGS += -DMULTITHREAD=$(call qstrip,$(BR2_PACKAGE_COREMARK_MULTITHREAD))
+COREMARK_CFLAGS += -DITERATIONS=$(call qstrip,$(BR2_PACKAGE_COREMARK_ITERATIONS))
+
define COREMARK_BUILD_CMDS
$(TARGET_MAKE_ENV) $(MAKE) CC="$(TARGET_CC)" -C $(@D) \
- PORT_CFLAGS="$(TARGET_CFLAGS)" \
+ PORT_CFLAGS="$(COREMARK_CFLAGS)" \
PORT_DIR=linux$(if $(BR2_ARCH_IS_64),64) EXE= link
-endef
+endef # COREMARK_BUILD_CMDS
define COREMARK_INSTALL_TARGET_CMDS
$(INSTALL) -D $(@D)/coremark $(TARGET_DIR)/usr/bin/coremark
-endef
+endef # COREMARK_INSTALL_TARGET_CMDS
$(eval $(generic-package))
This passes -DUSE_PTHREAD to coremark CFLAGS BR2_TOOLCHAIN_HAS_THREAD is set, and allows passing any additional custom ones defined in the Buildroot configuration. Signed-off-by: Jimmy Durand Wesolowski <jimmy.wesolowski@mobileye.com> --- Changes v1 -> v2: - do not add mips-i6500 through a patch, but copy it through rsync in POST_EXTRACT_HOOKS (suggested by Andreas Ziegler <br025@umbiko.net>) - allow specifying a port directory to use through kconfig, such as mips-i6500. The default stays linux for 32-bits architecture, linux64 for 64. - allow passing extra PORT_CFLAGS through kconfig (suggested by Andreas Ziegler <br025@umbiko.net>) Changes v2 -> v3: - do not include the mips-i6500 files as they are redundant with the linux port. (suggested by Andreas Ziegler <br025@umbiko.net>) - fix indentation in Config.in and coremark.mk - drop the ability to pass custom port (no longer necessary). - adapt the name and description of the patch accordingly. - author and signed-off-by reset due to patch significant changes. Changes v3 -> v4: - add -lpthread in CFLAGS (since only CFLAGS are used to compile and link). Changes v4 -> v5: - add custom kconfig options for ITERATIONS, MULTITHREAD, and USE_THREAD/USE_FORK to reduce the risk of incorrect CFLAGS. - use "-pthread" instead of -lpthread, as recommended in the documentation. --- package/coremark/Config.in | 56 ++++++++++++++++++++++++++++++++++++ package/coremark/coremark.mk | 22 ++++++++++++-- 2 files changed, 75 insertions(+), 3 deletions(-)