Skip to content

Commit

Permalink
V0.1 (#7)
Browse files Browse the repository at this point in the history
* separate core from cli + start doc

* pass lib from .so to .a

* add custom initialiser feature

* check rd perf + clean wrap cereal dep

* start implementing cereal serialization

* Improve post process package + check monod model

* improve way to get particle properties with kokkos_view in post_process and data_exporter

* Refractor kernel into functor + reduce branching in move process + check cstr simulation

* Refractor and add autogenerated compile_time flag + start impl probes

Remove all compile time flag from core and lib to put them into Meson
Generated header + move model selection output dir ("autogenerated").
Working poc implementation of probes to export some events during
simulation using fixed size buffer.

Check RTD for 0D reactor : OK with same stochastic algo

* Fix(simulation) RTD for batch and continuous reactor; Fix(init) gas scalar initialiaser

* Fix(model): mass_transfer + feed support, optimisation(MC), refractor(data_exporter_wip)

MC: use of Kokkos Scatter to limit use of atomic with host space +
change algortihm to remove dead particle

* WIP(Data exporter): new data exporter architecture

* feat: Implement DataExporter and MPI Feed

- Added DataExporter feature to facilitate data export.
- Split DataExporter into two components: main file for host node and partial file for worker nodes.
- Workers now write particle data efficiently.
- Fixed Kokkos/MPI thread count settings for improved performance.
- Updated .dockerfile to ensure proper environment setup.

* feat,fix: add mass calculation function and improve Monod uptake

fix: dataexporter OK
fix: correct weight calculation
feat: start updating postprocess package to handle new export format

* chore, fix(dataexport): refractor, new files

chore: move simulation parameter to core
fix: datexporter file path + integration in to whole algorithm to
correclty export data
fix: post process data with multiple files

* fix: matrix layout (row/column major) between Eigen and Kokkos

* chore + fix rtd

* misc: test sanofi ok

* fix(monod model): fix model to have correct final biomass concentration

* feat: steady_state test

* feat: test model parameters

* Fix Monod and Uptake model, working in steady state

* script steady

* perf: improve flowmap creation and transition performance

* add external hdf5 compressor

* opti: bench and add profiling

* feat: add prng to division model function

* opti,feat: bench try opti + start impl sunya's model

* refractor: model_uptake rename k_pts

* feat(model) fix uptake, implem metabolism

* fix(simulation): fix oxygen transfer and henry constant

* fix(cli): scalar gas-liquid from files, todo find better fix

* fix(main): confirm overriding when using MPI

* chore

* feat,fix,,chore: working 0.0.9 version

* version upgrade

---------

Co-authored-by: Casale Benjamin <casale@insa-toulouse.fr>
  • Loading branch information
Benncs and Casale Benjamin authored Oct 30, 2024
1 parent 1fe96d1 commit 653edfd
Show file tree
Hide file tree
Showing 202 changed files with 9,411 additions and 1,008,714 deletions.
10 changes: 9 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
BasedOnStyle: llvm
BasedOnStyle: llvm
BreakBeforeBraces: Allman
BraceWrapping:
AfterFunction: true
Expand All @@ -7,3 +7,11 @@ BinPackArguments: false
BinPackParameters: false
NamespaceIndentation: All
IndentPPDirectives: AfterHash

ColumnLimit: 150 # Disables column limit to prevent unwanted line wrapping.
CommentPragmas: true # Properly formats comments with pragmas.
SpaceBeforeParens: ControlStatements # Space before parentheses for control statements.
UseTab: Never # Use spaces for indentation instead of tabs.



74 changes: 6 additions & 68 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
name: Format
'on':
push:
branches:
- main
- v*/**
pull_request:
branches:
- main
- v*/**

on: [push, pull_request]
permissions:
contents: read
jobs:
Expand All @@ -30,27 +23,11 @@ jobs:
name: clang-tidy
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: actions/checkout@v4
- name: Install Python
uses: actions/setup-python@v5
with:
token: '${{ secrets.PAT_TOKEN }}'
- name: Clone GitLab submodule
run: >
git config --global credential.helper '!f() { echo "username=${{
secrets.USER_GITLAB }}"; echo "password=${{ secrets.PAT_GITLAB }}"; };
f'
git submodule update --init --recursive
- name: install Python
run: >-
sudo apt-get install python3 python3-pip python3-setuptools
python3-wheel ninja-build
- name: install dependencies
run: >-
sudo apt-get install -y libomp-dev libopenmpi-dev libeigen3-dev libtbb-dev
pkg-config ninja-build
- name: Install Meson
run: pip3 install meson
python-version: "3.11"
- name: get LLVM clang-tidy/clang-format
run: |
sudo sh devutils/clang_config.sh 17
Expand All @@ -61,42 +38,3 @@ jobs:
run: |
ninja -C builddir clang-tidy
clang-format:
name: clang-format
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: '${{ secrets.PAT_TOKEN }}'
- name: Clone GitLab submodule
run: >
git config --global credential.helper '!f() { echo "username=${{
secrets.USER_GITLAB }}"; echo "password=${{ secrets.PAT_GITLAB }}"; };
f'
git submodule update --init --recursive
- name: install Python
run: >-
sudo apt-get install python3 python3-pip python3-setuptools
python3-wheel ninja-build
- name: install dependencies
run: >-
sudo apt-get install -y libomp-dev libopenmpi-dev libeigen3-dev
pkg-config ninja-build
- name: Install Meson
run: pip3 install meson
- name: get LLVM clang-tidy/clang-format
run: |
sudo sh devutils/clang_config.sh 17
- name: Configure project
run: |
meson setup builddir/ --buildtype=release -Dcpp_std=gnu++20
- name: Clang-Format
run: |
ninja -C builddir clang-format-check

# which meson
# exec=$(which meson)
# $exec --internal clangformat $(pwd) $(pwd)/builddir/debug --check
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ __old

./Documentation/html
./Documentation/latex


tmp*
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "subprojects/cmtool"]
path = subprojects/cmtool
url = https://gitlab.com/Bencs/mirror_cma.git
url = https://gitlab.com/codes_tim/compartment-modelling-tool.git
branch = main
65 changes: 65 additions & 0 deletions apps/autogenerated/biocma_cst_config.hpp.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#ifndef __BIOMC__AUTOGENERATED_CONFIG_HPP__
#define __BIOMC__AUTOGENERATED_CONFIG_HPP__

/* ---------------------------------------------------------
* BIOCMA_MC ST
*
* This file has been autogenerated by Meson during project
* configuration.
*
* Be careful when modifying values.
* ---------------------------------------------------------
*/


#include <cstddef>
#include <cstdint>
#include <string_view>

#mesondefine _BIOMC_VERSION_MAJOR
#mesondefine _BIOMC_VERSION_MINOR
#mesondefine _BIOMC_VERSION_DEV


namespace AutoGenerated
{

constexpr std::string_view cma_data_folder_path = @cma_data_folder_path@; ///<Default folder to find CMA for simulation
constexpr std::string_view result_dir_path = @result_dir_path@; ///<Default folder to store simulation results

constexpr std::size_t probe_buffer_size = @probe_buffer_size@; ///<Default size for probes buffer


constexpr double default_particle_container_allocation_factor = @default_particle_container_allocation_factor@;
constexpr std::size_t MC_MAX_PARTICLE_BUFFER = @MC_MAX_PARTICLE_BUFFER@;
constexpr uint64_t debug_MC_RAND_DEFAULT_SEED = @debug_MC_RAND_DEFAULT_SEED@;

constexpr double dead_particle_ratio_threshold = @_dead_particle_ratio_threshold@;


/**
* @namespace FlagCompileTIme
* @brief Namespace containing compile-time flags for application configuration.
*
* This namespace defines compile-time constants that control specific behavior
* of the application, such as verbosity and output redirection. These flags are
* set based on predefined macros and allow for conditional compilation.
*/
namespace FlagCompileTIme
{
constexpr bool __f__redirect__ = @__f__redirect__@; //< Controls whether standard output should be redirected.
constexpr bool verbose = @__f_verbose__@; //< Controls whether verbose logging is enabled.
constexpr bool dump_particle_state = @dump_particle_state@;
constexpr bool use_probe = @use_probe@;
constexpr bool const_number_simulation = @const_number_simulation@;

#ifdef NO_MPI
constexpr bool use_mpi = false;
#else
constexpr bool use_mpi = true;
#endif
} // namespace FlagCompileTIme

} //namespace AutoGenerated

#endif
58 changes: 58 additions & 0 deletions apps/autogenerated/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Use to generate source/header file before compilation

version = meson.project_version().split('.')
assert(version.length()==3)

conf_data = configuration_data(
{
'_BIOMC_VERSION_MAJOR': version[0],
'_BIOMC_VERSION_MINOR': version[1],
'_BIOMC_VERSION_DEV': version[2],
'probe_buffer_size': '10e3',
'__f__redirect__': 'false',
'__f_verbose__': 'true',
'dump_particle_state': 'true',
'use_probe': 'true',
'const_number_simulation': 'false',
'default_particle_container_allocation_factor': '2.5',
'MC_MAX_PARTICLE_BUFFER': '100e6',
'debug_MC_RAND_DEFAULT_SEED': '2024',
'_dead_particle_ratio_threshold':'0.01',
'result_dir_path':'"./results/"',
'cma_data_folder_path':'"cma_data"'
},
)

configure_file(
input: 'biocma_cst_config.hpp.in',
output: 'biocma_cst_config.hpp',
configuration: conf_data,
)

prog_python = find_program('python3')

model_loader = meson.current_source_dir()+'/model_loader.cxx'
model_loader_header = meson.current_source_dir()+'/model_loader.hxx'
variant_model = meson.current_source_dir()+'/variant_model.hxx'

# custom target to generate model_loader.cpp and model_list.hpp
generated_model_selection = custom_target(
'generated_model_selection.[ch]',
output: [
'wrap_init_model_selector.cpp',
'wrap_init_model_selector.hpp',
'variant_model.hpp',
],
input: f'@root@/devutils/auto_generate/generate_model_loader.py',
command: [
prog_python,
'@INPUT@',
f'@root@/apps/libs/biomodels',
model_loader,
'@OUTPUT0@',
model_loader_header,
'@OUTPUT1@',
variant_model,
'@OUTPUT2@',
],
)
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
// NOLINTBEGIN
#include <mc/mcinit.hpp>
#include <string_view>
#include <unordered_map>

/* ---------------------------------------------------------
* BIOCMA_MC ST
*
* This file has been autogenerated by Meson during project
* configuration.
*
* Be careful when modifying values.
* ---------------------------------------------------------
*/

// clang-format off
@INCLUDES@

namespace AutoGenerated
namespace AutoGenerated
{
std::unique_ptr<MC::MonteCarloUnit> wrap_init_model_selector(
const int i_model,
const int i_model,
const ExecInfo &info,
size_t numper_particle,
std::span<double> liq_volume,
Expand All @@ -29,13 +41,13 @@
int get_model_index_from_name(std::string_view model_name) noexcept
{
@MODEL_INDEX_MAP@


auto it = map.find(model_name);
if (it != map.end()) {
return it->second;
if (it != map.end())
{
return it->second;
}
std::cerr<<"Model not found, using DefaultModel instead"<<std::endl;
std::cerr << "Model not found, using DefaultModel instead" << std::endl;
return -1;
}

Expand All @@ -44,3 +56,5 @@
return {};
}
} // namespace AutoGenerated
// clang-format on
// NOLINTEND
34 changes: 34 additions & 0 deletions apps/autogenerated/model_loader.hxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#ifndef __GENERATED_MODEL_WRAP__HPP__
#define __GENERATED_MODEL_WRAP__HPP__

#include <common/execinfo.hpp>
#include <mc/unit.hpp>
#include <memory>
#include <span>
#include <string_view>

/* ---------------------------------------------------------
* BIOCMA_MC ST
*
* This file has been autogenerated by Meson during project
* configuration.
*
* Be careful when modifying values.
* ---------------------------------------------------------
*/

namespace AutoGenerated
{
std::unique_ptr<MC::MonteCarloUnit> wrap_init_model_selector(int i_model,
const ExecInfo &info,
size_t numper_particle,
std::span<double> liq_volume,
CmaRead::Neighbors::Neighbors_const_view_t liquid_neighbors,
double x0) noexcept;

int get_model_index_from_name(std::string_view model_name) noexcept;

std::vector<std::string> get_model_list() noexcept;
} // namespace AutoGenerated

#endif //__GENERATED_MODEL_WRAP__HPP__
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
#ifndef __AUTOGENRATED_VARIANT_MODEL_HPP__
#define __AUTOGENRATED_VARIANT_MODEL_HPP__

#include <mc/particles/particles_container.hpp>
#include <mc/particles/particle_model.hpp>
#include <mc/particles/particles_container.hpp>
#include <variant>

/* ---------------------------------------------------------
* BIOCMA_MC ST
*
* This file has been autogenerated by Meson during project
* configuration.
*
* Be careful when modifying values.
* ---------------------------------------------------------
*/

// clang-format off
@INCLUDES@

namespace AutoGenerated
{
using ContainerVariant = std::variant<@VARIANT_TYPE@>;
} // namespace AutoGenerated

// clang-format on

#endif //__AUTOGENRATED_VARIANT_MODEL_HPP__
Loading

0 comments on commit 653edfd

Please sign in to comment.