Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add coremark port #76

Merged
merged 1 commit into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,6 @@ fi

[ "${PORTS_FS_MARK}" = "y" ] && ./phoenix-rtos-ports/fs_mark/build.sh

[ "${PORTS_COREMARK}" = "y" ] && ./phoenix-rtos-ports/coremark/build.sh

exit 0
28 changes: 28 additions & 0 deletions coremark/01-core_portme.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
diff --git a/posix/core_portme.mak b/posix/core_portme.mak
index 2852069..3eaaabe 100755
--- a/posix/core_portme.mak
+++ b/posix/core_portme.mak
@@ -24,8 +24,12 @@ OUTFLAG= -o
CC?= cc
# Flag: CFLAGS
# Use this flag to define compiler options. Note, you can add compiler options from the command line using XCFLAGS="other flags"
-PORT_CFLAGS = -O2
-FLAGS_STR = "$(PORT_CFLAGS) $(XCFLAGS) $(XLFLAGS) $(LFLAGS_END)"
+PORT_CFLAGS =
+FLAGS_STR := $(filter-out -I%,$(PORT_CFLAGS) $(XCFLAGS) $(XLFLAGS) $(LFLAGS_END))
+FLAGS_STR := $(filter-out --sysroot=%,$(FLAGS_STR))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uh, removing the --sysroot makes the port build against libphoenix embedded in toolchain, not in project - so IMHO not intended? Also -B is needed for selection correct crt0.o (project against toolchain) if I remember correctly

Copy link
Member Author

@lukileczo lukileczo May 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only for the FLAGS_STR define (which prints out in coremark)

CoreMark Size    : 666
Total ticks      : 21151
Total time (secs): 21.151000
Iterations/Sec   : 520.069973
Iterations       : 11000
Compiler version : GCC9.5.0
Compiler flags   : -fomit-frame-pointer -mcmodel=medany --sysroot=/home/lukasz/master-phoenix/phoenix-rtos-project/_build/riscv64-generic-qemu/sysroot/ -B/home/lukasz/master-phoenix/phoenix-rtos-project/_build/riscv64-generic-qemu/sysroot/lib/ -iprefix /home/lukasz/master-phoenix/phoenix-rtos-project/_build/riscv64-generic-qemu/sysroot/ -fmacro-prefix-map=/home/lukasz/master-phoenix/= -ffunction-sections -fdata-sections -DUSE_PTHREAD -DMULTITHREAD=1 -L/home/lukasz/master-phoenix/phoenix-rtos-project/_build/riscv64-generic-qemu/lib/ -Wl,--gc-sections

I removed the flags from the string so that we don't get wall of flags not affecting performance of the benchmark (and only leave the important ones).
The application is built with all the flags defined.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see https://github.com/phoenix-rtos/phoenix-rtos-build/blob/master/makes/setup-sysroot.mk#L20 for detailed breakdown of how sysroot options are used.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I don't think we understand each other :) FLAGS_STR is only provided to preprocessor define (https://github.com/eembc/coremark/blob/d5fad6bd094899101a4e5fd53af7298160ced6ab/posix/core_portme.mak#L29). Here's what actual build uses: https://github.com/eembc/coremark/blob/d5fad6bd094899101a4e5fd53af7298160ced6ab/Makefile#L87

Only I've now realized that XLFLAGS are not passed correctly, will fix that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, when I was posting my reply, I haven't yet see your reply (it was just an update over original comment).

I was mislead by the original comment above (that it's being used for compilation) and the patch doesn't have the variable usage. Maybe small comment regarding why you're removing it / it's safe to do so would prevent any confusion in the future ;)

+FLAGS_STR := $(filter-out -B%,$(FLAGS_STR))
+FLAGS_STR := $(filter-out -L%,$(FLAGS_STR))
+FLAGS_STR := "$(filter-out -fmacro-prefix-map=%,$(FLAGS_STR))"
nalajcie marked this conversation as resolved.
Show resolved Hide resolved
CFLAGS = $(PORT_CFLAGS) -I$(PORT_DIR) -Iposix -I. -DFLAGS_STR=\"$(FLAGS_STR)\"
# Flag: NO_LIBRT
# Define if the platform does not provide a librt
@@ -65,7 +69,7 @@ LOAD = echo Loading done
RUN =

OEXT = .o
-EXE = .exe
+EXE =

# Flag: SEPARATE_COMPILE
# Define if you need to separate compilation from link stage.
64 changes: 64 additions & 0 deletions coremark/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/usr/bin/env bash

set -e

COREMARK_VER="1.0"
COREMARK=coremark-${COREMARK_VER}
COREMARK_COMMIT="d5fad6bd094899101a4e5fd53af7298160ced6ab"
PKG_URL="https://github.com/eembc/coremark/archive/${COREMARK_COMMIT}.tar.gz"
PKG_MIRROR_URL="https://files.phoesys.com/ports/${COREMARK}.tar.gz"

b_log "Building coremark"
PREFIX_COREMARK="${PREFIX_PROJECT}/phoenix-rtos-ports/coremark"
PREFIX_COREMARK_BUILD="${PREFIX_BUILD}/coremark"
PREFIX_COREMARK_SRC="${PREFIX_COREMARK_BUILD}/${COREMARK}"
PREFIX_COREMARK_MARKERS="${PREFIX_COREMARK_BUILD}/markers"

#
# Download and unpack
#
mkdir -p "$PREFIX_COREMARK_BUILD"
if ! [ -f "${PREFIX_COREMARK}/${COREMARK}.tar.gz" ]; then
if ! wget "$PKG_URL" -O "${PREFIX_COREMARK}/${COREMARK}.tar.gz" --no-check-certificate; then
wget "$PKG_MIRROR_URL" -P "${PREFIX_COREMARK}" --no-check-certificate
fi
fi

if ! [ -d "${PREFIX_COREMARK_SRC}" ]; then
tar xzf "${PREFIX_COREMARK}/${COREMARK}.tar.gz" -C "${PREFIX_COREMARK_BUILD}" && mv "${PREFIX_COREMARK_BUILD}"/coremark-"${COREMARK_COMMIT}" "${PREFIX_COREMARK_BUILD}"/${COREMARK}
fi

#
# Apply patches
#
mkdir -p "$PREFIX_COREMARK_MARKERS"

for patchfile in "$PREFIX_COREMARK"/*.patch; do
if [ ! -f "$PREFIX_COREMARK_BUILD/markers/$(basename "$patchfile").applied" ]; then
echo "applying patch: $patchfile"
patch -d "$PREFIX_COREMARK_SRC" -p1 < "$patchfile"
touch "$PREFIX_COREMARK_MARKERS/$(basename "$patchfile").applied"
fi
done

#
# Configure
#
mkdir -p "${PREFIX_COREMARK_BUILD}/${COREMARK}/phoenix"
cp -a "$PREFIX_COREMARK/core-portme.mak" "$PREFIX_COREMARK_BUILD/${COREMARK}/phoenix/core_portme.mak"

cd "${PREFIX_COREMARK_BUILD}/${COREMARK}"

if [ -z ${PORTS_COREMARK_THREADS+x} ]; then
PORTS_COREMARK_THREADS="1"
fi

export XCFLAGS="${CFLAGS} -DUSE_PTHREAD -DMULTITHREAD=${PORTS_COREMARK_THREADS}"
lukileczo marked this conversation as resolved.
Show resolved Hide resolved
export XLFLAGS="${LDFLAGS}"

# Build coremark
PORT_DIR=phoenix make compile

cp -a "$PREFIX_COREMARK_BUILD/${COREMARK}/coremark" "$PREFIX_PROG/coremark"
"${CROSS}strip" -s "${PREFIX_PROG}/coremark" -o "${PREFIX_PROG_STRIPPED}/coremark"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

invalid stripping for NOMMU (removing relocations). Either write that nommu is not supported or do it properly.

b_install "$PREFIX_PORTS_INSTALL/coremark" /bin
3 changes: 3 additions & 0 deletions coremark/core-portme.mak
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
NO_LIBRT = 1

include posix/core_portme.mak
Loading