Skip to content
Snippets Groups Projects
Verified Commit dc04e5aa authored by Dorian Stoll's avatar Dorian Stoll
Browse files

zellularautomat: c: Switch to Meson

parent 57766d01
No related branches found
No related tags found
No related merge requests found
{
"format": {
"line_width": 100,
"use_tabchars": true
}
}
cmake_minimum_required(VERSION 3.14)
project(praktikum)
# Always create a compile_commands.json for clangd
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Enable optimization by default
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
# Enable LTO
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
project(
'praktikum',
'c',
default_options: [
'warning_level=3',
'buildtype=release',
'b_lto=true',
],
)
subdir('src')
subdir('zellularautomat')
BASE_CC=gcc
COMMON_CFLAGS=-O2
COMMON_LDFLAGS=-lcrypto -lrt
BASE_CFLAGS=-Wall -std=gnu99 -pedantic
OMP_CFLAGS=-fopenmp
C_DEPS=ca_common.c random.c
TARGETS=ca_openmp
.PHONY: all
all: $(TARGETS)
.PHONY: cpu
cpu: ca_openmp
ca_openmp: ca_openmp.c $(C_DEPS)
$(BASE_CC) $(COMMON_CFLAGS) $(BASE_CFLAGS) $(OMP_CFLAGS) $^ $(COMMON_LDFLAGS) -o $@
.PHONY: test
test: $(TARGETS)
@for ITS in 10 31 57 100; do \
for LINES in 10 33 47 100; do \
echo "$$LINES lines, $$ITS iterations"; \
for BINARY in $^; do printf '%-10s\t' $$BINARY; ./$$BINARY $$LINES $$ITS; done; \
done \
done
.PHONY: bench
bench: ca_openmp
@for ITS in 128 256 512; do \
for LINES in 1000 10000 50000; do \
echo "$$LINES lines, $$ITS iterations"; \
for BINARY in $^; do printf '%-10s\t' $$BINARY; time ./$$BINARY $$LINES $$ITS; done; \
done \
done
.PHONY: omp_scaling
omp_scaling: ca_openmp
@for ITS in 128 256 512; do \
for LINES in 1000 10000 50000; do \
echo "$$LINES lines, $$ITS iterations"; \
for THREADS in `seq \`nproc\``; do \
printf "$$THREADS threads\t"; \
OMP_NUM_THREADS=$$THREADS ./ca_openmp $$LINES $$ITS; \
done; \
done; \
done
.PHONY: clean
clean:
rm -f *.o
rm -f $(TARGETS)
cc = meson.get_compiler('c')
sources = [
'ca_common.c',
'ca_openmp.c',
'random.c',
]
dependencies = [
dependency('openmp'),
cc.find_library('crypto'),
cc.find_library('rt'),
]
options = [
'c_std=c99',
]
executable(
'zellularautomat-c',
sources,
dependencies: dependencies,
override_options: options,
)
subdir('c')
subdir('benchmarks')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment