Skip to content

Commit

Permalink
Release 3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
psyrykh committed Jan 9, 2024
1 parent 85fdcc8 commit d1945d4
Show file tree
Hide file tree
Showing 51 changed files with 2,740 additions and 1,373 deletions.
20 changes: 20 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
BasedOnStyle: Google
AllowShortFunctionsOnASingleLine: None
ColumnLimit: 120
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^<waverian/.*>' # Waverian includes
Priority: 1
SortPriority: 2
- Regex: '^<(assert|locale|stddef|ctype|math|stdio|errno|setjmp|stdlib|float|signal|string|limits|stdarg|time)\.h>' # C standard libraries
Priority: 2
SortPriority: 3
- Regex: '^<.*>' # Other angle bracket includes
Priority: 3
SortPriority: 4
- Regex: '^\".*\"' # Remaining quoted includes
Priority: 4
SortPriority: 5
- Regex: '.*' # Remaining includes
Priority: 5
SortPriority: 6
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,7 @@ Mkfile.old
dkms.conf

cmake-build-*/
build_*/
build/
release/
.idea/
9 changes: 5 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,19 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

cmake_minimum_required(VERSION 3.4)
file (STRINGS "VERSION" LFK_VERSION)
file (STRINGS "VERSION" WB_VERSION)

project(lfkx VERSION ${LFK_VERSION} LANGUAGES C)
project(benchmark LANGUAGES C)

option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
option(BUILD_CONSOLE_APP "Build benchmark console application" ON)

include(cmake/compiler.cmake)
include(cmake/definitions.cmake)
include(cmake/options.cmake)

add_subdirectory(lfk_benchmark)
add_subdirectory(benchmark)

if(BUILD_CONSOLE_APP)
add_subdirectory(lfk_console)
add_subdirectory(benchmark_cli)
endif()
186 changes: 125 additions & 61 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,88 +22,152 @@
CC = cc
$(if $(shell which $(CC)),,$(error "No $(CC) in PATH"))

POSSIBLE_VALUES := ON OFF
# Check WB_USE_CPUID if defined and has a wrong value
ifeq ($(filter $(WB_USE_CPUID),POSSIBLE_VALUES),)
ifneq ($(origin WB_USE_CPUID), undefined)
$(error WB_USE_CPUID has a wrong value: $(WB_USE_CPUID))
endif
endif

# Check WB_USE_POSIX_THREADS if defined and has a wrong value
ifeq ($(filter $(WB_USE_THREADS),POSSIBLE_VALUES),)
ifneq ($(origin WB_USE_THREADS), undefined)
$(error WB_USE_THREADS has a wrong value: $(WB_USE_THREADS))
endif
endif

# Check WB_USE_UNISTD if defined and has a wrong value
ifeq ($(filter $(WB_USE_UNISTD),POSSIBLE_VALUES),)
ifneq ($(origin WB_USE_UNISTD), undefined)
$(error WB_USE_UNISTD has a wrong value: $(WB_USE_UNISTD))
endif
endif


##### DETECT COMPILER COMPATIBILITIES: #####
WB_FLAGS=

ifndef WB_USE_CPUID
$(info Checking CPUID...)
ifeq ($(shell $(CC) compiler_probes/posix_cpuid.c -o /dev/null 2> /dev/null && echo 1), 1)
WB_USE_CPUID=ON
WB_FLAGS+=-DWB_USE_POSIX_CPUID
else
WB_USE_CPUID=OFF
endif
endif

ifndef WB_USE_THREADS
$(info Checking PThreads...)
ifeq ($(shell $(CC) -lpthread compiler_probes/posix_threads.c -o /dev/null 2> /dev/null && echo 1), 1)
WB_USE_THREADS=ON
WB_FLAGS+=-DWB_USE_POSIX_THREADS
else
WB_USE_THREADS=OFF
endif
endif

ifndef WB_USE_UNISTD
$(info Checking unistd...)
ifeq ($(shell $(CC) compiler_probes/unistd.c -o /dev/null 2> /dev/null && echo 1), 1)
WB_USE_UNISTD=ON
WB_FLAGS+=-DWB_USE_UNISTD
else
WB_USE_UNISTD=OFF
endif
endif

BUILD_DIR?=build_make/

WB_VERSION=$(shell cat VERSION || echo "UNKNOWN")
WB_COMPILER=$(shell ${CC} --version | head -n1)

override CFLAGS += -DWB_VERSION="\"${WB_VERSION}\""\
-DWB_COMPILER="\"${WB_COMPILER}\""\
${WB_FLAGS}


BENCHMARK_CORE_PRIVATE_INCLUDE=benchmark/core/src/
BENCHMARK_CORE_PUBLIC_INCLUDE=benchmark/core/inc/

BENCHMARK_CORE_SRC=benchmark/src/core/core.c

BENCHMARK_CORE_OPT_OBJ=$(addprefix ${BUILD_DIR}, $(BENCHMARK_CORE_SRC:.c=.opt.o))
BENCHMARK_CORE_NONOPT_OBJ=$(addprefix ${BUILD_DIR}, $(BENCHMARK_CORE_SRC:.c=.nonopt.o))

BENCHMARK_CORE_OPT_LIB=${BUILD_DIR}core.opt.a
BENCHMARK_CORE_NOOPT_LIB=${BUILD_DIR}core.nonopt.a

BENCHMARK_CORE_DEPS=-lm

BENCHMARK_SRC=benchmark/src/platform.c\
benchmark/src/thread.c\
benchmark/src/constants.c\
benchmark/src/printers/html.c\
benchmark/src/printers/text.c\
benchmark/src/benchmark.c

ifeq ($(WB_USE_THREADS), ON)
BENCHMARK_DEPS=$(BENCHMARK_CORE_DEPS) -lpthread
else
BENCHMARK_DEPS=$(BENCHMARK_CORE_DEPS)
endif

BENCHMARK_OBJ=$(addprefix ${BUILD_DIR}, $(BENCHMARK_SRC:.c=.o))

BENCHMARK_PUBLIC_INC=benchmark/inc/
BENCHMARK_PRIVATE_INC=benchmark/src/

BENCHMARK_LIB=${BUILD_DIR}benchmark.a

BENCHMARK_CLI_BIN=benchmark-cli
BENCHMARK_CLI_SRC=benchmark_cli/src/app.c\
benchmark_cli/main.c
BENCHMARK_CLI_INC=benchmark_cli/src/

LFK_VERSION=$(shell cat VERSION || echo "UNKNOWN")
LFK_COMPILER=$(shell ${CC} --version | head -n1)
BUILD_DIR = build_dir/

##### TARGETS: #####

CFLAGS = -DLFK_VERSION="\"${LFK_VERSION}\"" -DLFK_COMPILER="\"${LFK_COMPILER}\""

LKF_LIB=${BUILD_DIR}lfk.a
LFK_CORE_OPT_LIB=${BUILD_DIR}lfk-core-optimized.a
LFK_CORE_NOOPT_LIB=${BUILD_DIR}lfk-core-nonoptimized.a

LFK_CORE_SRC=lfk_benchmark/src/core/lfk_core.c

LFK_CORE_OPT_OBJ=$(addprefix ${BUILD_DIR}, $(LFK_CORE_SRC:.c=.opt.o))
LFK_CORE_NONOPT_OBJ=$(addprefix ${BUILD_DIR}, $(LFK_CORE_SRC:.c=.nonopt.o))

LFK_CORE_PRIVATE_INCLUDE=lfk_benchmark/core/src/
LFK_CORE_PUBLIC_INCLUDE=lfk_benchmark/core/inc/
LFK_CORE_DEPS=-lm

LFK_SRC=lfk_benchmark/src/posix/platform.c\
lfk_benchmark/src/posix/thread.c\
lfk_benchmark/src/constants.c\
lfk_benchmark/src/lfk.c

LFK_OBJ=$(addprefix ${BUILD_DIR}, $(LFK_SRC:.c=.o))

LFK_PUBLIC_INC=lfk_benchmark/inc/
LFK_PRIVATE_INC=lfk_benchmark/src/

build: clean $(BENCHMARK_CLI_BIN)

${BUILD_DIR}%.opt.o : %.c
mkdir -p $(dir $@)
${CC} ${CFLAGS} -O3 -c -DOPTIMIZATION=optimized -o $@ $^ \
-I${LFK_CORE_PRIVATE_INCLUDE} -I${LFK_CORE_PUBLIC_INCLUDE} -I${LFK_PUBLIC_INC}
-I${BENCHMARK_CORE_PRIVATE_INCLUDE} -I${BENCHMARK_CORE_PUBLIC_INCLUDE} -I${BENCHMARK_PUBLIC_INC}

${BUILD_DIR}%.nonopt.o : %.c
mkdir -p $(dir $@)
${CC} ${CFLAGS} -O0 -c -DOPTIMIZATION=nonoptimized -o $@ $^ \
-I${LFK_CORE_PRIVATE_INCLUDE} -I${LFK_CORE_PUBLIC_INCLUDE} -I${LFK_PUBLIC_INC}
-I${BENCHMARK_CORE_PRIVATE_INCLUDE} -I${BENCHMARK_CORE_PUBLIC_INCLUDE} -I${BENCHMARK_PUBLIC_INC}

${BUILD_DIR}%.o : %.c
mkdir -p $(dir $@)
${CC} ${CFLAGS} -O3 -c -o $@ $^ \
-I${LFK_CORE_PUBLIC_INCLUDE} -I${LFK_PUBLIC_INC} -I${LFK_PRIVATE_INC}

-I${BENCHMARK_CORE_PUBLIC_INCLUDE} -I${BENCHMARK_PUBLIC_INC} -I${BENCHMARK_PRIVATE_INC}

$(LFK_CORE_OPT_LIB): $(LFK_CORE_OPT_OBJ)
%.a:
ar rcs $@ $^

$(LFK_CORE_NOOPT_LIB): $(LFK_CORE_NONOPT_OBJ)
ar rcs $@ $^

$(LKF_LIB): $(LFK_CORE_OPT_LIB) $(LFK_CORE_NOOPT_LIB) $(LFK_OBJ)
ar rcs $@ $^


LFK_CONSOLE_SRC=lfk_console/src/utils/html_report_generator.c\
lfk_console/src/utils/text_report_generator.c\
lfk_console/src/app.c\
lfk_console/main.c

LF_CONSOLE_INC=lfk_console/src/

lfk_console: $(LKF_LIB)
${CC} $(LFK_CONSOLE_SRC) -I${LF_CONSOLE_INC} -I${LFK_CORE_PUBLIC_INCLUDE} -I${LFK_PUBLIC_INC}\
-s ${LKF_LIB}\
-s ${LFK_CORE_OPT_LIB}\
-s ${LFK_CORE_NOOPT_LIB}\
-lm -lpthread\
$(BENCHMARK_CORE_OPT_LIB): $(BENCHMARK_CORE_OPT_OBJ)
$(BENCHMARK_CORE_NOOPT_LIB): $(BENCHMARK_CORE_NONOPT_OBJ)
$(BENCHMARK_LIB): $(BENCHMARK_CORE_OPT_LIB) $(BENCHMARK_CORE_NOOPT_LIB) $(BENCHMARK_OBJ)

$(BENCHMARK_CLI_BIN): $(BENCHMARK_LIB) $(BENCHMARK_CORE_OPT_LIB) $(BENCHMARK_CORE_NOOPT_LIB)
${CC} ${CFLAGS} \
${BENCHMARK_CLI_SRC}\
-I${BENCHMARK_CLI_INC}\
-I${BENCHMARK_CORE_PUBLIC_INCLUDE}\
-I${BENCHMARK_PUBLIC_INC}\
$^\
${BENCHMARK_DEPS}\
-o ${BUILD_DIR}$@
cp ${BUILD_DIR}$@ $@
@echo
@echo "Waverian benchmark executable is located ./benchmark-cli"

lfk_lib: $(LKF_LIB)
${CC} -I${LFK_CORE_PUBLIC_INCLUDE} -I${LFK_PUBLIC_INC}\
-s ${LKF_LIB}\
-s ${LFK_CORE_OPT_LIB}\
-s ${LFK_CORE_NOOPT_LIB}\
-lm -lpthread\
-o ${BUILD_DIR}$@
.build_dir: clean
mkdir -p ${BUILD_DIR}

clean:
rm -rf ${BUILD_DIR}
rm -rf ${BUILD_DIR}
31 changes: 16 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# LFK-MP
# Waverian benchmark

### Livermore fortran loops for multicore processors

LFK-MP is a benchmark based on the original [LFK benchmark](https://en.wikipedia.org/wiki/Livermore_loops) by Francis H.
Waverian benchmark is a benchmark based on the original [LFK benchmark](https://en.wikipedia.org/wiki/Livermore_loops) by Francis H.
McMahon with support of multicore proccessors.

The benchmark was rewritten in order tu support thread libraries (pthread and winapi threads), with big attention to
Expand Down Expand Up @@ -30,13 +28,17 @@ match [original benchmark](http://www.netlib.org/benchmark/livermorec) results.

1. Makefile based:
```sh
make lfk_console
# Executable located in ./build_dir/lfk_console
make
# Executable located at ./benchmark-cli
# To disable CPUID run with argument `WB_USE_CPUID=OFF`
# To disable threads support run with argument `WB_USE_THREADS=OFF`
```
2. Cmake based:
```sh
./tools/build.sh
# Executable located in ./build_local/
./cmake_build.sh
# Executable located at ./benchmark-cli
# To disable CPUID run with argument `-DWB_USE_CPUID=OFF`
# To disable threads support run with argument `-DWB_USE_THREADS=OFF`
```
3. Cmake based (for windows hosts):
```sh
Expand All @@ -46,14 +48,13 @@ match [original benchmark](http://www.netlib.org/benchmark/livermorec) results.
## How to run:

```sh
./build_dir/lfk_console --help
Livermore Fortran Loops (LFK) benchmark tool.
Waverian benchmark tool.
Usage:
-o <file> ..... report text file [default lfk-report.txt]
-r <file>.html ..... report html file [default lfk-report.html]
-j <cores> ..... number of cores (0 - auto detection) [default 1]
-t <seconds> ..... execution time in seconds per kernel [default 1]

-o <file> ..... .txt and .html reports file name [default waverian-benchmark-report]
-c <comment> ..... comment added to the report
-j <cores> ..... number of cores (0 - auto detection) [default 1]
-t <seconds> ..... execution time in seconds per kernel [default 0.5]
-w ..... enable workstation mode [default off]
```

## License
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.1
3.0.0

0 comments on commit d1945d4

Please sign in to comment.