atrstm

Load and structure a combustion gas mixture
git clone git://git.meso-star.fr/atrstm.git
Log | Files | Refs | README | LICENSE

commit 2a2e1eba71ec7fa2705e214b2d6b435827a1c07d
parent 723a1a935d3e82baf85f40c886b3491ca74c399d
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Tue, 31 Oct 2023 11:20:09 +0100

Merge branch 'feature_posix_make' into develop

Diffstat:
M.gitignore | 14+++++++-------
AMakefile | 200+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
MREADME.md | 45++++++++++++++++++++++-----------------------
Aatrstm.pc.in | 18++++++++++++++++++
Dcmake/CMakeLists.txt | 162-------------------------------------------------------------------------------
Aconfig.mk | 122+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amake.sh | 71+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/atrstm.c | 2+-
Msrc/atrstm.h | 2+-
Msrc/atrstm_c.h | 2+-
Msrc/atrstm_cache.c | 2+-
Msrc/atrstm_cache.h | 2+-
Msrc/atrstm_dump_svx_octree.c | 2+-
Msrc/atrstm_log.c | 2+-
Msrc/atrstm_log.h | 2+-
Msrc/atrstm_partition.c | 2+-
Msrc/atrstm_partition.h | 2+-
Msrc/atrstm_radcoefs.c | 2+-
Msrc/atrstm_radcoefs.h | 2+-
Msrc/atrstm_radcoefs_simd4.c | 2+-
Msrc/atrstm_radcoefs_simd4.h | 2+-
Msrc/atrstm_rdgfa.c | 2+-
Msrc/atrstm_rdgfa.h | 2+-
Msrc/atrstm_rdgfa_simd4.h | 2+-
Msrc/atrstm_setup_octrees.c | 2+-
Msrc/atrstm_setup_octrees.h | 2+-
Msrc/atrstm_setup_uvm.c | 17++++++++++-------
Msrc/atrstm_svx.c | 2+-
Msrc/atrstm_svx.h | 2+-
Msrc/test_atrstm.c | 2+-
Msrc/test_atrstm_radcoefs.c | 2+-
Msrc/test_atrstm_radcoefs_simd.c | 2+-
32 files changed, 474 insertions(+), 223 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -1,12 +1,12 @@ .gitignore -CMakeCache.txt -CMakeFiles -Makefile -tmp [Bb]uild* *.sw[po] -*.[ao] -*.orig +*.[aod] +*.so *~ +test* +!test*.[ch] +.config +.test tags - +*.pc diff --git a/Makefile b/Makefile @@ -0,0 +1,200 @@ +# Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) +# Copyright (C) 2020, 2021 Centre National de la Recherche Scientifique +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +.POSIX: +.SUFFIXES: # Clean up default inference rules + +include config.mk + +LIBNAME_STATIC = libatrstm.a +LIBNAME_SHARED = libatrstm.so +LIBNAME = $(LIBNAME_$(LIB_TYPE)) + +################################################################################ +# Library building +################################################################################ +SRC =\ + src/atrstm.c\ + src/atrstm_cache.c\ + src/atrstm_dump_svx_octree.c\ + src/atrstm_log.c\ + src/atrstm_partition.c\ + src/atrstm_radcoefs.c\ + src/atrstm_rdgfa.c\ + src/atrstm_setup_octrees.c\ + src/atrstm_setup_uvm.c\ + src/atrstm_svx.c +OBJ = $(SRC:.c=.o) +DEP = $(SRC:.c=.d) + +build_library: .config $(DEP) + @$(MAKE) -fMakefile $$(for i in $(DEP); do echo -f $${i}; done) \ + $$(if [ -n "$(LIBNAME)" ]; then \ + echo "$(LIBNAME)"; \ + else \ + echo "$(LIBNAME_SHARED)"; \ + fi) + +$(DEP) $(OBJ): config.mk + +$(LIBNAME_SHARED): $(OBJ) + $(CC) $(CFLAGS_SO) $(RSYS_CFLAGS) -o $@ $(OBJ) $(LDFLAGS_SO) $(DPDC_LIBS) + +$(LIBNAME_STATIC): libatrstm.o + $(AR) -rc $@ $? + $(RANLIB) $@ + +libatrstm.o: $(OBJ) + $(LD) -r $(OBJ) -o $@ + $(OBJCOPY) $(OCPFLAGS) $@ + +.config: config.mk + @if ! $(PKG_CONFIG) --atleast-version $(ATRRI_VERSION) atrri; then \ + echo "atrri $(ATRRI_VERSION) not found" >&2; exit 1; fi + @if ! $(PKG_CONFIG) --atleast-version $(ATRTP_VERSION) atrtp; then \ + echo "atrtp $(ATRTP_VERSION) not found" >&2; exit 1; fi + @if $(RSIMD_EXISTS); then \ + if ! $(PKG_CONFIG) --atleast-version $(RSIMD_VERSION) rsimd; then \ + echo "rsimd $(RSIMD_VERSION) not found" >&2; exit 1; fi; fi + @if ! $(PKG_CONFIG) --atleast-version $(RSYS_VERSION) rsys; then \ + echo "rsys $(RSYS_VERSION) not found" >&2; exit 1; fi + @if ! $(PKG_CONFIG) --atleast-version $(SMSH_VERSION) smsh; then \ + echo "smsh $(SMSH_VERSION) not found" >&2; exit 1; fi + @if ! $(PKG_CONFIG) --atleast-version $(SUVM_VERSION) suvm; then \ + echo "suvm $(SUVM_VERSION) not found" >&2; exit 1; fi + @if ! $(PKG_CONFIG) --atleast-version $(SVX_VERSION) svx; then \ + echo "svx $(SVX_VERSION) not found" >&2; exit 1; fi + @echo "config done" > $@ + +.SUFFIXES: .c .d .o +.c.d: + @$(CC) $(CFLAGS_SO) $(DPDC_CFLAGS) -MM -MT "$(@:.d=.o) $@" $< -MF $@ + +.c.o: + $(CC) $(CFLAGS_SO) $(DPDC_CFLAGS) -DATRSTM_SHARED_BUILD -c $< -o $@ + +################################################################################ +# Installation +################################################################################ +pkg: + sed -e 's#@PREFIX@#$(PREFIX)#g'\ + -e 's#@VERSION@#$(VERSION)#g'\ + -e 's#@ATRRI_VERSION@#$(ATRRI_VERSION)#g'\ + -e 's#@ATRTP_VERSION@#$(ATRTP_VERSION)#g'\ + -e 's#@RSYS_VERSION@#$(RSYS_VERSION)#g'\ + -e 's#@SMSH_VERSION@#$(SMSH_VERSION)#g'\ + -e 's#@SUVM_VERSION@#$(SUVM_VERSION)#g'\ + -e 's#@SVX_VERSION@#$(SVX_VERSION)#g'\ + atrstm.pc.in | \ + if $(RSIMD_EXISTS); then \ + sed 's#@RSIMD@#, rsimd >= $(RSIMD_VERSION)#g'; \ + else \ + sed 's#@RSIMD@##g'; \ + fi > atrstm.pc + +atrstm-local.pc: atrstm.pc.in + sed -e '1d'\ + -e 's#^includedir=.*#includedir=./src/#'\ + -e 's#^libdir=.*#libdir=./#'\ + -e 's#@VERSION@#$(VERSION)#g'\ + -e 's#@ATRRI_VERSION@#$(ATRRI_VERSION)#g'\ + -e 's#@ATRTP_VERSION@#$(ATRTP_VERSION)#g'\ + -e 's#@RSYS_VERSION@#$(RSYS_VERSION)#g'\ + -e 's#@SMSH_VERSION@#$(SMSH_VERSION)#g'\ + -e 's#@SUVM_VERSION@#$(SUVM_VERSION)#g'\ + -e 's#@SVX_VERSION@#$(SVX_VERSION)#g'\ + atrstm.pc.in | \ + if $(RSIMD_EXISTS); then \ + sed 's#@RSIMD@#, rsimd >= $(RSIMD_VERSION)#g'; \ + else \ + sed 's#@RSIMD@##g'; \ + fi > $@ + +install: build_library pkg + @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/lib" $(LIBNAME) + @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/lib/pkgconfig" atrstm.pc + @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/include/astoria" src/atrstm.h + @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/share/doc/atrstm" COPYING README.md + +uninstall: + rm -f "$(DESTDIR)$(PREFIX)/lib/$(LIBNAME)" + rm -f "$(DESTDIR)$(PREFIX)/lib/pkgconfig/atrstm.pc" + rm -f "$(DESTDIR)$(PREFIX)/share/doc/atrstm/COPYING" + rm -f "$(DESTDIR)$(PREFIX)/share/doc/atrstm/README.md" + rm -f "$(DESTDIR)$(PREFIX)/include/astoria/atrstm.h" + +################################################################################ +# Miscellaneous targets +################################################################################ +all: build_library build_tests + +clean: clean_test + rm -f $(OBJ) $(TEST_OBJ) $(LIBNAME) + rm -f .config .test libatrstm.o atrstm.pc atrstm-local.pc + +distclean: clean + rm -f $(DEP) $(TEST_DEP) + +lint: + shellcheck -o all make.sh + +################################################################################ +# Tests +################################################################################ +TEST_SRC =\ + src/test_atrstm.c\ + src/test_atrstm_radcoefs.c\ + src/test_atrstm_radcoefs_simd.c +TEST_OBJ = $(TEST_SRC:.c=.o) +TEST_DEP = $(TEST_SRC:.c=.d) + +PKG_CONFIG_LOCAL = PKG_CONFIG_PATH="./:$${PKG_CONFIG_PATH}" $(PKG_CONFIG) +ATRSTM_CFLAGS = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --cflags atrstm-local.pc) +ATRSTM_LIBS = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --libs atrstm-local.pc) + +test: build_tests + @$(SHELL) make.sh run_test \ + src/test_atrstm_radcoefs.c \ + $$($(RSIMD_EXISTS) && echo src/test_atrstm_radcoefs_simd.c) + +build_tests: build_library $(TEST_DEP) .test + @$(MAKE) -fMakefile -f.test $$(for i in $(TEST_DEP); do echo -f"$${i}"; done) test_bin + +.test: Makefile make.sh + @$(SHELL) make.sh config_test \ + src/test_atrstm.c \ + src/test_atrstm_radcoefs.c \ + $$($(RSIMD_EXISTS) && echo src/test_atrstm_radcoefs_simd.c) \ + > $@ + +clean_test: + $(SHELL) make.sh clean_test $(TEST_SRC) + +$(TEST_DEP): config.mk atrstm-local.pc + @$(CC) $(CFLAGS_EXE) $(RSYS_CFLAGS) $(ATRSTM_CFLAGS) \ + -MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@ + +src/test_atrstm.o src/test_atrstm_radcoefs.o: config.mk atrstm-local.pc + $(CC) $(CFLAGS_EXE) $(ATRSTM_CFLAGS) $(RSYS_CFLAGS) -c $(@:.o=.c) -o $@ + +src/test_atrstm_radcoefs_simd.o: config.mk atrstm-local.pc + $(CC) $(CFLAGS_EXE) $(ATRSTM_CFLAGS) $(RSYS_CFLAGS) $(RSIMD_CFLAGS) -c $(@:.o=.c) -o $@ + +test_atrstm test_atrstm_radcoefs: config.mk atrstm-local.pc $(LIBNAME) + $(CC) $(CFLAGS_EXE) -o $@ src/$@.o $(LDFLAGS_EXE) $(ATRSTM_LIBS) $(RSYS_LIBS) -lm + +test_atrstm_radcoefs_simd: config.mk atrstm-local.pc $(LIBNAME) + $(CC) $(CFLAGS_EXE) -o $@ src/$@.o $(LDFLAGS_EXE) $(ATRSTM_LIBS) $(RSYS_LIBS) $(RSIMD_LIBS) diff --git a/README.md b/README.md @@ -1,27 +1,26 @@ # AsToRia: Semi-Transparent Medium -This C library loads and manages the spectral data of a gas mixture whose -geometric support are tetrahedra. - -## How to build - -This library is compatible GNU/Linux 64-bits. It relies the -[CMake](http://www.cmake.org) and the -[RCMake](https://gitlab.com/vaplv/rcmake/) packages to build. -It also depends on the -[Astoria: Thermodynamic Properties](https://gitlab.com/meso-star/atrtp/), -[RSys](https://gitlab.com/vaplv/rsys/), -[Star-UnstructuredVolumetricMesh](https://gitlab.com/meso-star/star-uvm/), -[Star-Mesh](https://gitlab.com/meso-star/star-mesh/) libraries, -and on [OpenMP](https://www.openmp.org) 1.2 the parallelize its computations. - -First ensure that CMake is installed on your system. Then install the RCMake -package as well as the aforementioned prerequisites. Finally generate the -project from the `cmake/CMakeLists.txt` file by appending to the -`CMAKE_PREFIX_PATH` variable the install directories of its dependencies. The -resulting project can be edited, built, tested and installed as any CMake -project. Refer to the [CMake documentation](https://cmake.org/documentation) -for further informations on CMake. +This C library loads and manages the geometric data and physical properties of +a gas mixture. + +## Requirements + +- C compiler with OpenMP support +- POSIX make +- pkg-config +- [Astoria: Thermodynamic Properties](https://gitlab.com/meso-star/atrtp) +- [Astoria: Refractive Index](https://gitlab.com/meso-star/atrri) +- [RSIMD](https://gitlab.com/vaplv/rsimd) (optional) +- [RSys](https://gitlab.com/vaplv/rsys) +- [Star Mesh](https://gitlab.com/meso-star/star-mesh) +- [Star Unstructured Volumetric Mesh](https://gitlab.com/meso-star/star-uvm) +- [Star VoXel](https://gitlab.com/meso-star/star-vx) + +## Installation + +Edit config.mk as needed, then run: + + make clean install ## Release notes @@ -34,7 +33,7 @@ for further informations on CMake. ## Copyright -Copyright (C) 2022, 2023 [|Méso|Star](http://www.meso-star.com) (<contact@meso-star.com>) +Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) Copyright (C) 2020, 2021 Centre National de la Recherche Scientifique (CNRS) ## License diff --git a/atrstm.pc.in b/atrstm.pc.in @@ -0,0 +1,18 @@ +prefix=@PREFIX@ +includedir=${prefix}/include +libdir=${prefix}/lib + +Requires:\ + rsys >= @RSYS_VERSION@,\ + suvm >= @SUVM_VERSION@,\ + svx >= @SVX_VERSION@ +Requires.private:\ + atrri >= @ATRRI_VERSION@,\ + atrtp >= @ATRTP_VERSION@,\ + smsh >= @SMSH_VERSION@ @RSIMD@ +Name: atrstm +Description: AsToRia Semi-Transparent Medium library +Version: @VERSION@ +Libs: -L${libdir} -latrstm +Libs.private: -fopenmp -lm +CFlags: -I${includedir} diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt @@ -1,162 +0,0 @@ -# Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) -# Copyright (C) 2020, 2021 CNRS -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - -cmake_minimum_required(VERSION 3.1) -project(atrstm C) -enable_testing() - -set(ATRSTM_SOURCE_DIR ${PROJECT_SOURCE_DIR}/../src) -option(NO_TEST "Do not build tests" OFF) - -################################################################################ -# Check dependencies -################################################################################ -find_package(AtrRI 0.0 REQUIRED) -find_package(AtrTP 0.0 REQUIRED) -find_package(OpenMP 1.2 REQUIRED) -find_package(RCMake 0.4 REQUIRED) -find_package(RSys 0.12 REQUIRED) -find_package(StarMesh REQUIRED) -find_package(StarUVM 0.0 REQUIRED) -find_package(StarVX 0.2 REQUIRED) -find_package(RSIMD 0.3) -if(RSIMD_FOUND) - option(USE_SIMD "Use SIMD instruction sets" ON) -endif() - -if(USE_SIMD) - message(STATUS "Use SIMD instruction sets") -else() - message(STATUS "Do not use SIMD instruction sets") -endif() - -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${RCMAKE_SOURCE_DIR}) -include(rcmake) -include(rcmake_runtime) - -include_directories( - ${AtrRI_INCLUDE_DIR} - ${AtrTP_INCLUDE_DIR} - ${RSys_INCLUDE_DIR} - ${StarMesh_INCLUDE_DIR} - ${StarUVM_INCLUDE_DIR} - ${StarVX_INCLUDE_DIR}) - -################################################################################ -# Configure and define targets -################################################################################ -set(VERSION_MAJOR 0) -set(VERSION_MINOR 0) -set(VERSION_PATCH 1) -set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) - -set(ATRSTM_FILES_SRC - atrstm.c - atrstm_cache.c - atrstm_dump_svx_octree.c - atrstm_log.c - atrstm_partition.c - atrstm_radcoefs.c - atrstm_rdgfa.c - atrstm_setup_octrees.c - atrstm_setup_uvm.c - atrstm_svx.c) - -set(ATRSTM_FILES_INC - atrstm_c.h - atrstm_cache.h - atrstm_log.h - atrstm_partition.h - atrstm_radcoefs.h - atrstm_setup_octrees.h - atrstm_svx.h) - -set(ATRSTM_FILES_INC_API - atrstm.h) - -set(ATRSTM_FILES_DOC COPYING README.md) - -# SIMD files -if(USE_SIMD) - set(ATRSTM_FILES_SRC ${ATRSTM_FILES_SRC} atrstm_radcoefs_simd4.c) - set(ATRSTM_FILES_INC ${ATRSTM_FILES_INC} - atrstm_radcoefs_simd4.h - atrstm_rdgfa_simd4.h) -endif() - -# Prepend each file in the `ATRSTM_FILES_<SRC|INC>' list by `ATRSTM_SOURCE_DIR' -rcmake_prepend_path(ATRSTM_FILES_SRC ${ATRSTM_SOURCE_DIR}) -rcmake_prepend_path(ATRSTM_FILES_INC ${ATRSTM_SOURCE_DIR}) -rcmake_prepend_path(ATRSTM_FILES_INC_API ${ATRSTM_SOURCE_DIR}) -rcmake_prepend_path(ATRSTM_FILES_DOC ${PROJECT_SOURCE_DIR}/../) - -add_library(atrstm SHARED - ${ATRSTM_FILES_SRC} - ${ATRSTM_FILES_INC} - ${ATRSTM_FILES_INC_API}) -target_link_libraries(atrstm AtrRI AtrTP RSys StarMesh StarUVM StarVX m) - -# Setup SIMD support on the target -if(USE_SIMD) - target_link_libraries(atrstm RSIMD) - set_target_properties(atrstm PROPERTIES - COMPILE_DEFINITIONS ATRSTM_USE_SIMD) -endif() - -if(CMAKE_COMPILER_IS_GNUCC) - set_target_properties(atrstm PROPERTIES LINK_FLAGS "${OpenMP_C_FLAGS}") -endif() - -set_target_properties(atrstm PROPERTIES - COMPILE_FLAGS ${OpenMP_C_FLAGS} - DEFINE_SYMBOL ATRSTM_SHARED_BUILD - VERSION ${VERSION} - SOVERSION ${VERSION_MAJOR}) - -rcmake_setup_devel(atrstm AtrSTM ${VERSION} astoria/atrstm_version.h) - -################################################################################ -# Add tests -################################################################################ -if(NOT NO_TEST) - function(build_test _name) - add_executable(${_name} - ${ATRSTM_SOURCE_DIR}/${_name}.c) - target_link_libraries(${_name} atrstm RSys ${ARGN}) - endfunction() - - function(new_test _name) - build_test(${_name} ${ARGN}) - add_test(${_name} ${_name}) - endfunction() - - build_test(test_atrstm) - new_test(test_atrstm_radcoefs) - if(USE_SIMD) - new_test(test_atrstm_radcoefs_simd) - endif() -endif() - -################################################################################ -# Define output & install directories -################################################################################ -install(TARGETS atrstm - ARCHIVE DESTINATION bin - LIBRARY DESTINATION lib - RUNTIME DESTINATION bin) -install(FILES ${ATRSTM_FILES_INC_API} DESTINATION include/astoria) -install(FILES ${ATRSTM_FILES_DOC} DESTINATION share/doc/atrstm) - diff --git a/config.mk b/config.mk @@ -0,0 +1,122 @@ +VERSION = 0.0.1 +PREFIX = /usr/local + +LIB_TYPE = SHARED +#LIB_TYPE = STATIC + +BUILD_TYPE = RELEASE +#BUILD_TYPE = DEBUG + +################################################################################ +# Tools +################################################################################ +AR = ar +CC = cc +LD = ld +OBJCOPY = objcopy +PKG_CONFIG = pkg-config +RANLIB = ranlib + +################################################################################ +# Dependencies +################################################################################ +PCFLAGS_SHARED = +PCFLAGS_STATIC = --static +PCFLAGS = $(PCFLAGS_$(LIB_TYPE)) + +ATRRI_VERSION = 0.1 +ATRRI_CFLAGS = $$($(PKG_CONFIG) $(PCFLAGS) --cflags atrri) +ATRRI_LIBS = $$($(PKG_CONFIG) $(PCFLAGS) --libs atrri) + +ATRTP_VERSION = 0.1 +ATRTP_CFLAGS = $$($(PKG_CONFIG) $(PCFLAGS) --cflags atrtp) +ATRTP_LIBS = $$($(PKG_CONFIG) $(PCFLAGS) --libs atrtp) + +RSIMD_VERSION = 0.5 +RSIMD_EXISTS = $(PKG_CONFIG) --exists rsimd +RSIMD_CFLAGS = $$($(RSIMD_EXISTS) && $(PKG_CONFIG) $(PCFLAGS) --cflags rsimd) +RSIMD_LIBS = $$($(RSIMD_EXISTS) && $(PKG_CONFIG) $(PCFLAGS) --libs rsimd) + +RSYS_VERSION = 0.14 +RSYS_CFLAGS = $$($(PKG_CONFIG) $(PCFLAGS) --cflags rsys) +RSYS_LIBS = $$($(PKG_CONFIG) $(PCFLAGS) --libs rsys) + +SMSH_VERSION = 0.1 +SMSH_CFLAGS = $$($(PKG_CONFIG) $(PCFLAGS) --cflags smsh) +SMSH_LIBS = $$($(PKG_CONFIG) $(PCFLAGS) --libs smsh) + +SUVM_VERSION = 0.3 +SUVM_CFLAGS = $$($(PKG_CONFIG) $(PCFLAGS) --cflags suvm) +SUVM_LIBS = $$($(PKG_CONFIG) $(PCFLAGS) --libs suvm) + +SVX_VERSION = 0.3 +SVX_CFLAGS = $$($(PKG_CONFIG) $(PCFLAGS) --cflags svx) +SVX_LIBS = $$($(PKG_CONFIG) $(PCFLAGS) --libs svx) + +DPDC_CFLAGS =\ + $(ATRRI_CFLAGS)\ + $(ATRTP_CFLAGS)\ + $(RSIMD_CFLAGS)\ + $(RSYS_CFLAGS)\ + $(SMSH_CFLAGS)\ + $(SUVM_CFLAGS)\ + $(SVX_CFLAGS)\ + -fopenmp +DPDC_LIBS=\ + $(ATRRI_LIBS)\ + $(ATRTP_LIBS)\ + $(RSIMD_LIBS)\ + $(RSYS_LIBS)\ + $(SMSH_LIBS)\ + $(SUVM_LIBS)\ + $(SVX_LIBS)\ + -fopenmp\ + -lm + +################################################################################ +# Compilation options +################################################################################ +WFLAGS =\ + -Wall\ + -Wcast-align\ + -Wconversion\ + -Wextra\ + -Wmissing-declarations\ + -Wmissing-prototypes\ + -Wshadow + +CFLAGS_HARDENED =\ + -D_FORTIFY_SOURCES=2\ + -fcf-protection=full\ + -fstack-clash-protection\ + -fstack-protector-strong + +CFLAGS_COMMON =\ + -std=c89\ + -pedantic\ + -fvisibility=hidden\ + -fstrict-aliasing\ + $(CFLAGS_HARDENED)\ + $(WFLAGS) + +CFLAGS_DEBUG = -g $(CFLAGS_COMMON) +CFLAGS_RELEASE = -O2 -DNDEBUG $(CFLAGS_COMMON) +CFLAGS = $(CFLAGS_$(BUILD_TYPE)) + +CFLAGS_SO = $(CFLAGS) -fPIC +CFLAGS_EXE = $(CFLAGS) -fPIE + +################################################################################ +# Linker options +################################################################################ +LDFLAGS_HARDENED = -Wl,-z,relro,-z,now +LDFLAGS_DEBUG = $(LDFLAGS_HARDENED) +LDFLAGS_RELEASE = -s $(LDFLAGS_HARDENED) +LDFLAGS = $(LDFLAGS_$(BUILD_TYPE)) + +LDFLAGS_SO = $(LDFLAGS) -shared -Wl,--no-undefined +LDFLAGS_EXE = $(LDFLAGS) -pie + +OCPFLAGS_DEBUG = --localize-hidden +OCPFLAGS_RELEASE = --localize-hidden --strip-unneeded +OCPFLAGS = $(OCPFLAGS_$(BUILD_TYPE)) diff --git a/make.sh b/make.sh @@ -0,0 +1,71 @@ +#!/bin/sh + +# Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) +# Copyright (C) 2020, 2021 Centre National de la Recherche Scientifique +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +set -e + +config_test() +{ + for i in "$@"; do + test=$(basename "${i}" ".c") + test_list="${test_list} ${test}" + printf "%s: %s\n" "${test}" "src/${test}.o" + done + printf "test_bin: %s\n" "${test_list}" +} + +run_test() +{ + for i in "$@"; do + test=$(basename "${i}" ".c") + + printf "%s " "${test}" + if "./${test}" > /dev/null 2>&1; then + printf "\033[1;32mOK\033[m\n" + else + printf "\033[1;31mError\033[m\n" + fi + done 2> /dev/null +} + +clean_test() +{ + for i in "$@"; do + rm -f "$(basename "${i}" ".c")" + done +} + +install() +{ + prefix=$1 + shift 1 + + mkdir -p "${prefix}" + + for i in "$@"; do + dst="${prefix}/${i##*/}" + + if cmp -s "${i}" "${dst}"; then + printf "Up to date %s\n" "${dst}" + else + printf "Installing %s\n" "${dst}" + cp "${i}" "${prefix}" + fi + done +} + +"$@" diff --git a/src/atrstm.c b/src/atrstm.c @@ -1,5 +1,5 @@ /* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2020, 2021 CNRS + * Copyright (C) 2020, 2021 Centre National de la Recherche Scientifique * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/atrstm.h b/src/atrstm.h @@ -1,5 +1,5 @@ /* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2020, 2021 CNRS + * Copyright (C) 2020, 2021 Centre National de la Recherche Scientifique * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/atrstm_c.h b/src/atrstm_c.h @@ -1,5 +1,5 @@ /* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2020, 2021 CNRS + * Copyright (C) 2020, 2021 Centre National de la Recherche Scientifique * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/atrstm_cache.c b/src/atrstm_cache.c @@ -1,5 +1,5 @@ /* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2020, 2021 CNRS + * Copyright (C) 2020, 2021 Centre National de la Recherche Scientifique * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/atrstm_cache.h b/src/atrstm_cache.h @@ -1,5 +1,5 @@ /* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2020, 2021 CNRS + * Copyright (C) 2020, 2021 Centre National de la Recherche Scientifique * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/atrstm_dump_svx_octree.c b/src/atrstm_dump_svx_octree.c @@ -1,5 +1,5 @@ /* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2020, 2021 CNRS + * Copyright (C) 2020, 2021 Centre National de la Recherche Scientifique * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/atrstm_log.c b/src/atrstm_log.c @@ -1,5 +1,5 @@ /* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2020, 2021 CNRS + * Copyright (C) 2020, 2021 Centre National de la Recherche Scientifique * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/atrstm_log.h b/src/atrstm_log.h @@ -1,5 +1,5 @@ /* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2020, 2021 CNRS + * Copyright (C) 2020, 2021 Centre National de la Recherche Scientifique * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/atrstm_partition.c b/src/atrstm_partition.c @@ -1,5 +1,5 @@ /* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2020, 2021 CNRS + * Copyright (C) 2020, 2021 Centre National de la Recherche Scientifique * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/atrstm_partition.h b/src/atrstm_partition.h @@ -1,5 +1,5 @@ /* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2020, 2021 CNRS + * Copyright (C) 2020, 2021 Centre National de la Recherche Scientifique * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/atrstm_radcoefs.c b/src/atrstm_radcoefs.c @@ -1,5 +1,5 @@ /* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2020, 2021 CNRS + * Copyright (C) 2020, 2021 Centre National de la Recherche Scientifique * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/atrstm_radcoefs.h b/src/atrstm_radcoefs.h @@ -1,5 +1,5 @@ /* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2020, 2021 CNRS + * Copyright (C) 2020, 2021 Centre National de la Recherche Scientifique * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/atrstm_radcoefs_simd4.c b/src/atrstm_radcoefs_simd4.c @@ -1,5 +1,5 @@ /* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2020, 2021 CNRS + * Copyright (C) 2020, 2021 Centre National de la Recherche Scientifique * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/atrstm_radcoefs_simd4.h b/src/atrstm_radcoefs_simd4.h @@ -1,5 +1,5 @@ /* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2020, 2021 CNRS + * Copyright (C) 2020, 2021 Centre National de la Recherche Scientifique * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/atrstm_rdgfa.c b/src/atrstm_rdgfa.c @@ -1,5 +1,5 @@ /* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2020, 2021 CNRS + * Copyright (C) 2020, 2021 Centre National de la Recherche Scientifique * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/atrstm_rdgfa.h b/src/atrstm_rdgfa.h @@ -1,5 +1,5 @@ /* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2020, 2021 CNRS + * Copyright (C) 2020, 2021 Centre National de la Recherche Scientifique * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/atrstm_rdgfa_simd4.h b/src/atrstm_rdgfa_simd4.h @@ -1,5 +1,5 @@ /* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2020, 2021 CNRS + * Copyright (C) 2020, 2021 Centre National de la Recherche Scientifique * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/atrstm_setup_octrees.c b/src/atrstm_setup_octrees.c @@ -1,5 +1,5 @@ /* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2020, 2021 CNRS + * Copyright (C) 2020, 2021 Centre National de la Recherche Scientifique * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/atrstm_setup_octrees.h b/src/atrstm_setup_octrees.h @@ -1,5 +1,5 @@ /* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2020, 2021 CNRS + * Copyright (C) 2020, 2021 Centre National de la Recherche Scientifique * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/atrstm_setup_uvm.c b/src/atrstm_setup_uvm.c @@ -1,5 +1,5 @@ /* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2020, 2021 CNRS + * Copyright (C) 2020, 2021 Centre National de la Recherche Scientifique * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -82,8 +82,9 @@ setup_unstructured_volumetric_mesh struct suvm_volume** out_volume) { struct suvm_tetrahedral_mesh_args mesh_args = SUVM_TETRAHEDRAL_MESH_ARGS_NULL; - struct smsh_create_args args = SMSH_CREATE_ARGS_DEFAULT; + struct smsh_create_args smsh_create_args = SMSH_CREATE_ARGS_DEFAULT; struct smsh_desc smsh_desc = SMSH_DESC_NULL; + struct smsh_load_args smsh_load_args = SMSH_LOAD_ARGS_NULL; struct smsh* smsh = NULL; struct suvm_volume* volume = NULL; struct time t0, t1; @@ -97,12 +98,14 @@ setup_unstructured_volumetric_mesh time_current(&t0); /* Load the volumetric mesh */ - args.logger = atrstm->logger; - args.allocator = atrstm->allocator; - args.verbose = atrstm->verbose; - res = smsh_create(&args, &smsh); + smsh_create_args.logger = atrstm->logger; + smsh_create_args.allocator = atrstm->allocator; + smsh_create_args.verbose = atrstm->verbose; + res = smsh_create(&smsh_create_args, &smsh); if(res != RES_OK) goto error; - res = smsh_load(smsh, smsh_filename); + smsh_load_args.path = smsh_filename; + smsh_load_args.memory_mapping = 1; + res = smsh_load(smsh, &smsh_load_args); if(res != RES_OK) goto error; res = smsh_get_desc(smsh, &smsh_desc); if(res != RES_OK) goto error; diff --git a/src/atrstm_svx.c b/src/atrstm_svx.c @@ -1,5 +1,5 @@ /* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2020, 2021 CNRS + * Copyright (C) 2020, 2021 Centre National de la Recherche Scientifique * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/atrstm_svx.h b/src/atrstm_svx.h @@ -1,5 +1,5 @@ /* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2020, 2021 CNRS + * Copyright (C) 2020, 2021 Centre National de la Recherche Scientifique * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/test_atrstm.c b/src/test_atrstm.c @@ -1,5 +1,5 @@ /* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2020, 2021 CNRS + * Copyright (C) 2020, 2021 Centre National de la Recherche Scientifique * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/test_atrstm_radcoefs.c b/src/test_atrstm_radcoefs.c @@ -1,5 +1,5 @@ /* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2020, 2021 CNRS + * Copyright (C) 2020, 2021 Centre National de la Recherche Scientifique * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/test_atrstm_radcoefs_simd.c b/src/test_atrstm_radcoefs_simd.c @@ -1,5 +1,5 @@ /* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2020, 2021 CNRS + * Copyright (C) 2020, 2021 Centre National de la Recherche Scientifique * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by