Commit 5e369340 authored by Lukas Weber's avatar Lukas Weber Committed by Lukas Weber
Browse files

change to meson build system

parent 7db49e3b
*.pyc
subprojects/*
!subprojects/*.wrap
cmake_minimum_required(VERSION 3.1)
project(load_leveller)
find_package (PkgConfig REQUIRED)
find_package(MPI REQUIRED)
find_package(fmt CONFIG REQUIRED)
pkg_check_modules(yaml-cpp REQUIRED IMPORTED_TARGET yaml-cpp)
pkg_check_modules(HDF5 REQUIRED IMPORTED_TARGET HDF5)
set(CMAKE_CXX_STANDARD 17)
set(SRCs
dump.cpp
evalable.cpp
measurements.cpp
observable.cpp
parser.cpp
random.cpp
runner.cpp
merger.cpp
mc.cpp
runner_single.cpp
runner_task.cpp
results.cpp
)
add_library(load_leveller ${SRCs})
target_link_libraries(load_leveller PUBLIC MPI::MPI_CXX fmt::fmt PkgConfig::yaml-cpp PkgConfig::HDF5)
install(FILES load_leveller.h DESTINATION include)
#ifndef MCL_ACML_RAND_H
#define MCL_ACML_RAND_H
extern "C" void dranduniform_(int *N, double *A, double *B, int *state, double *X, int *info);
extern "C" void dranddiscreteuniform_(int *N, int *A, int *B, int *state, int *X, int *info);
extern "C" void drandinitialize_(int *GENID, int *SUBID, int *SEED, int *LSEED, int *STATE,
int *LSTATE, int *INFO);
#include <cstdlib>
class acml_rand {
public:
acml_rand(uint seed, double A, double B, int len = 1000) {
len_ = len;
vec = new double[len_];
A_ = A;
B_ = B;
// fill seed array
seed_len = 624;
int *seed_array = new int[seed_len];
srand48(seed);
for(uint i = 0; i < (uint)seed_len; ++i) {
seed_array[i] = (int)lrand48();
}
// initialize Mersenne PRNG int genid = 3;
int info;
int ignored = 0;
int genid = 3;
state_len = 700;
state = new int[state_len];
drandinitialize_(&genid, &ignored, seed_array, &seed_len, state, &state_len, &info);
generate();
}
~acml_rand() {
delete[] vec;
delete[] state;
}
inline const double &operator()(void) {
if(pos < len_)
return vec[pos++];
generate();
return vec[pos++];
}
private:
void generate() {
pos = 0;
int info;
dranduniform_(&len_, &A_, &B_, state, vec, &info);
}
int pos;
int len_;
int state_len;
int seed_len;
double *vec;
int *state;
double A_, B_;
};
class acml_rand_discrete {
public:
acml_rand_discrete(uint seed, int A, int B, int len = 1000) {
len_ = len;
vec = new int[len_];
A_ = A;
B_ = B;
// fill seed array
seed_len = 624;
int *seed_array = new int[seed_len];
srand48(seed);
for(uint i = 0; i < (uint)seed_len; ++i) {
seed_array[i] = (int)lrand48();
}
// initialize Mersenne PRNG int genid = 3;
int info;
int ignored = 0;
int genid = 3;
//@fixme why 700? not 633?
state_len = 700;
state = new int[state_len];
drandinitialize_(&genid, &ignored, seed_array, &seed_len, state, &state_len, &info);
generate();
}
~acml_rand_discrete() {
delete[] vec;
delete[] state;
}
inline const int &operator()(void) {
if(pos < len_)
return vec[pos++];
generate();
return vec[pos++];
}
private:
void generate() {
pos = 0;
int info;
dranddiscreteuniform_(&len_, &A_, &B_, state, vec, &info);
}
int pos;
int len_;
int state_len;
int seed_len;
int *vec;
int *state;
int A_, B_;
};
#endif
project('load-leveller', 'c', 'cpp',
version : '2.0',
meson_version : '>=0.50.0',
default_options : [
'warning_level=3',
'cpp_std=c++17',
]
)
fmt_dep = dependency('fmt', fallback : ['fmt', 'fmt_dep'])
yamlcpp_dep = dependency('yaml-cpp', version : '>=0.6.0', fallback : ['yaml-cpp', 'yamlcpp_dep'])
mpi_dep = dependency('mpi')
# HDF5 is a pain
cc = meson.get_compiler('cpp')
hdf5_lib = cc.find_library('hdf5')
loadleveller_deps = [ fmt_dep, yamlcpp_dep, mpi_dep, hdf5_lib ]
subdir('src')
#include "measurements.h"
#include <fmt/format.h>
bool measurements::observable_name_is_legal(const std::string& obs_name) {
bool measurements::observable_name_is_legal(const std::string &obs_name) {
if(obs_name.find('/') != obs_name.npos) {
return false;
}
......@@ -11,31 +11,32 @@ bool measurements::observable_name_is_legal(const std::string& obs_name) {
return true;
}
void measurements::add_observable(const std::string& name, size_t bin_size, size_t vector_length, size_t initial_length) {
void measurements::add_observable(const std::string &name, size_t bin_size, size_t vector_length,
size_t initial_length) {
if(!observable_name_is_legal(name)) {
throw std::runtime_error(fmt::format("Illegal observable name '{}': names must not contain / or .", name));
throw std::runtime_error(
fmt::format("Illegal observable name '{}': names must not contain / or .", name));
}
observables_.emplace(name, observable{name, bin_size, vector_length, initial_length});
}
void measurements::checkpoint_write(const iodump::group& dump_file) {
for(const auto& obs : observables_) {
void measurements::checkpoint_write(const iodump::group &dump_file) {
for(const auto &obs : observables_) {
obs.second.checkpoint_write(dump_file.open_group(obs.first));
}
}
void measurements::checkpoint_read(const iodump::group& dump_file) {
for(const auto& obs_name : dump_file) {
void measurements::checkpoint_read(const iodump::group &dump_file) {
for(const auto &obs_name : dump_file) {
add_observable(obs_name);
observables_.at(obs_name).checkpoint_read(dump_file.open_group(obs_name));
}
}
void measurements::samples_write(const iodump::group& meas_file) {
for(auto& obs : observables_) {
void measurements::samples_write(const iodump::group &meas_file) {
for(auto &obs : observables_) {
auto g = meas_file.open_group(obs.first);
obs.second.measurement_write(g);
}
}
loadleveller_sources = files([
'dump.cpp',
'evalable.cpp',
'mc.cpp',
'measurements.cpp',
'merger.cpp',
'observable.cpp',
'parser.cpp',
'random.cpp',
'results.cpp',
'runner.cpp',
'runner_single.cpp',
'runner_task.cpp',
])
loadleveller_headers = files([
'dump.h',
'evalable.h',
'loadleveller.h',
'mc.h',
'measurements.h',
'merger.h',
'MersenneTwister.h',
'observable.h',
'parser.h',
'random.h',
'results.h',
'runner.h',
'runner_single.h',
'runner_task.h',
])
libloadleveller = library('loadleveller',
loadleveller_sources,
dependencies : loadleveller_deps,
version : meson.project_version(),
install : true,
)
pkg = import('pkgconfig')
pkg.generate(libloadleveller,
description : 'Framework for distributed (Quantum) Monte Carlo codes',
)
install_headers(loadleveller_headers, subdir : 'loadleveller')
loadleveller_dep = declare_dependency(
include_directories : include_directories('.'),
link_with : libloadleveller,
dependencies : loadleveller_deps,
version : meson.project_version(),
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment