Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class CompressorRecipe(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "CMakeDeps"
generators = "CMakeConfigDeps"

def requirements(self):
self.requires("spdlog/1.16.0", options={"use_std_fmt": True, "no_exceptions": True}) # type: ignore
Expand Down
4 changes: 3 additions & 1 deletion source/centipede/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
add_library(core SHARED)
add_library(centipede::centipede ALIAS core)
target_compile_features(core PRIVATE cxx_std_26)
target_compile_features(core PUBLIC cxx_std_26)
target_compile_options(
core
PRIVATE
Expand All @@ -22,6 +22,8 @@ target_sources(
FILES centipede.hpp
)

target_link_libraries(core PUBLIC Eigen3::Eigen GSL::gsl)

add_subdirectory(core)
add_subdirectory(util)
add_subdirectory(writer)
Expand Down
2 changes: 0 additions & 2 deletions source/centipede/core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
target_sources(
core
PRIVATE handler.cpp
PUBLIC
FILE_SET publicHeaders
TYPE HEADERS
Expand All @@ -10,7 +9,6 @@ target_sources(
engines/master_engine.hpp
handler.hpp
)
target_link_libraries(core PUBLIC Eigen3::Eigen GSL::gsl)
target_compile_definitions(
core
PUBLIC
Expand Down
2 changes: 1 addition & 1 deletion source/centipede/core/engines/base_engine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ namespace centipede::core::engine
/**
* @brief Empty base engine class. The real implementation is defined in its specialization.
*/
template <MatrixEngineType engine_type, typename DataType>
template <MatrixEngine engine_type, typename DataType>
class Engine
{
};
Expand Down
13 changes: 7 additions & 6 deletions source/centipede/core/engines/eigen_engine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace centipede::core::engine
* @brief Engine template specialization for Eigen library implementation.
*/
template <typename DataType>
class Engine<MatrixEngineType::eigen, DataType> : public Base<DataType>
class Engine<MatrixEngine::eigen, DataType> : public Base<DataType>
{
public:
/**
Expand Down Expand Up @@ -192,7 +192,7 @@ namespace centipede::core::engine
global_t_.setFromSortedTriplets(triplets_.begin(), triplets_.end());
}

auto fit_local_pars() -> EnumError<>
auto fit_local_pars() -> VoidError
{
// NOTE: Multiplications will trigger temporary object (memory allocation later during the assignment.)
Eigen::internal::set_is_malloc_allowed(false);
Expand Down Expand Up @@ -234,7 +234,7 @@ namespace centipede::core::engine
return std::pair{ ndf, chi_square };
}

auto update_global_factor_matrix() -> EnumError<>
auto update_global_factor_matrix() -> VoidError
{
// TODO: Perform the production using index accessing.
// NOTE: Seems that there is no way to prevent memory allocation with sparse matrices.
Expand All @@ -257,7 +257,7 @@ namespace centipede::core::engine
return {};
}

auto update_global_rhs_vector() -> EnumError<>
auto update_global_rhs_vector() -> VoidError
{
// TODO: Perform the production using index accessing.
// NOTE: Seems that there is no way to prevent memory allocation with sparse matrices.
Expand All @@ -274,9 +274,10 @@ namespace centipede::core::engine

static void resize_globals(Globals& globals, std::size_t n_globals)
{
globals.rhs_vec.resize(n_globals);
const auto num_of_globals = static_cast<long>(n_globals);
globals.rhs_vec.resize(num_of_globals);
globals.rhs_vec.setZero();
globals.factor_matrix.resize(n_globals, n_globals);
globals.factor_matrix.resize(num_of_globals, num_of_globals);
globals.factor_matrix.setZero();
}

Expand Down
2 changes: 1 addition & 1 deletion source/centipede/core/engines/engine_concept.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace centipede::core::engine
/**
* @brief Concept used for core::engine::Master option.
*/
template <EngineType engine_type, typename DataType>
template <MatrixEngine engine_type, typename DataType>
concept EngineLike = requires(Engine<engine_type, DataType> engine,
Result<DataType>& result,
typename Engine<engine_type, DataType>::Globals& globals) {
Expand Down
6 changes: 3 additions & 3 deletions source/centipede/core/engines/engine_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace centipede::core::engine
* @brief Engine types.
*
*/
enum class MatrixEngineType : uint8_t
enum class MatrixEngine : uint8_t
{
eigen,
xtensor,
Expand All @@ -20,13 +20,13 @@ namespace centipede::core::engine
*/
struct MasterOpt
{
MatrixEngineType engine_type = MatrixEngineType::eigen;
MatrixEngine engine_type = MatrixEngine::eigen;
bool has_multi_slaves = false; //!< Use taskflow or not.
};

} // namespace centipede::core::engine

namespace centipede
{
using EngineType = core::engine::MatrixEngineType;
using MatrixEngine = core::engine::MatrixEngine;
}
4 changes: 2 additions & 2 deletions source/centipede/core/engines/master_engine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace centipede::core::engine
Entry<DataType> entry; //!< Data storing the current entry.
};

using Result = Result<DataType>;
using ResultType = Result<DataType>;
using EngineImp = Engine<opt.engine_type, DataType>;
using DataTypeUsed = DataType;

Expand Down Expand Up @@ -153,7 +153,7 @@ namespace centipede::core::engine

private:
Config config_;
Result result_;
ResultType result_;
State current_state_;
EngineImp engine_imp_{};
EngineImp::Globals globals_{};
Expand Down
Empty file removed source/centipede/core/handler.cpp
Empty file.
8 changes: 4 additions & 4 deletions source/centipede/core/handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
#include "centipede/util/return_types.hpp"
#include <cstddef>

namespace centipede::core
namespace centipede
{

/**
* @brief Main frontend handler to the library
*
* This class should handle all inputs and configurations from users
*/
template <typename DataType = double, engine::MasterOpt opt = {}>
template <typename DataType = double, core::engine::MasterOpt opt = {}>
class Handler
{
public:
Expand All @@ -26,7 +26,7 @@ namespace centipede::core
{
std::size_t n_globals = 0; //!< Number of global parameters.
};
using EngineType = engine::Master<DataType, opt>;
using EngineType = core::engine::Master<DataType, opt>;

/**
* @brief Constructor
Expand Down Expand Up @@ -61,4 +61,4 @@ namespace centipede::core

// std::vector<>
};
} // namespace centipede::core
} // namespace centipede
8 changes: 8 additions & 0 deletions source/centipede/util/return_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,19 @@

namespace centipede
{
/**
* @brief Template alias for expected string results.
*/
using StrError = std::expected<void, std::string>;

/**
* @brief Template alias for expected return values.
*/
template <typename T = void>
using EnumError = std::expected<T, ErrorCode>;

/**
* @brief Template alias for expected void results.
*/
using VoidError = std::expected<void, ErrorCode>;
} // namespace centipede
27 changes: 22 additions & 5 deletions test/integration_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,14 @@ set(COMPILE_OPTIONS
-fno-rtti
)

#===================================writer===================================

add_executable(integration_test_writer test_writer.cpp)

target_link_libraries(integration_test_writer PRIVATE centipede::centipede)

target_compile_options(integration_test_writer PRIVATE ${COMPILE_OPTIONS})

# if(ENABLE_COVERAGE)
# target_compile_options(integration_test_writer PRIVATE --coverage)
# target_link_options(integration_test_writer PRIVATE --coverage)
# endif()

add_test(NAME integration_test_writer_data_gen COMMAND integration_test_writer)
set_tests_properties(integration_test_writer_data_gen PROPERTIES TIMEOUT 10)

Expand All @@ -33,3 +30,23 @@ set_tests_properties(
integration_test_writer_res
PROPERTIES DEPENDS integration_test_writer_data_gen
)

#===================================eigen core===============================

find_package(mps)

if(mps_FOUND)
message(STATUS "Testing with simulated data from mps is enabled!")
add_executable(test_eigen test_eigen.cpp)

target_link_libraries(test_eigen PRIVATE centipede::centipede mps::mps)

target_compile_options(test_eigen PRIVATE ${COMPILE_OPTIONS})

add_test(NAME integration_test_eigen COMMAND test_eigen)
set_tests_properties(integration_test_eigen PROPERTIES TIMEOUT 10)
else()
message(STATUS "Testing with simulated data from mps is disabled!")
endif()

#==============================================================================
17 changes: 17 additions & 0 deletions test/integration_tests/test_eigen.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include "centipede/centipede.hpp"
#include <cstdlib>
#include <vector>

namespace
{
// void entrypoints_generator() {}
} // namespace

auto main() -> int
{
auto entries = std::vector<centipede::EntryPoint<>>{};

Check warning on line 12 in test/integration_tests/test_eigen.cpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

test/integration_tests/test_eigen.cpp#L12

Variable 'entries' is assigned a value that is never used.

auto handler = centipede::Handler<double, { .engine_type = centipede::MatrixEngine::eigen }>{};

return EXIT_SUCCESS;
}
12 changes: 6 additions & 6 deletions test/unit_tests/test_eigen_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace centipede::test
TEST(eigen_engine, constructor)
{
constexpr auto n_global_pars = 10;
auto engine = core::engine::Engine<core::engine::MatrixEngineType::eigen, float>{ n_global_pars };
auto engine = core::engine::Engine<core::engine::MatrixEngine::eigen, float>{ n_global_pars };
const auto& factor_matrix = engine.get_global_factor_matrix();
EXPECT_EQ(factor_matrix.rows(), n_global_pars);
EXPECT_EQ(factor_matrix.cols(), n_global_pars);
Expand All @@ -24,7 +24,7 @@ namespace centipede::test

TEST(eigen_engine, solve_rank_deficit)
{
using EngineClass = core::engine::Engine<core::engine::MatrixEngineType::eigen, float>;
using EngineClass = core::engine::Engine<core::engine::MatrixEngine::eigen, float>;

auto result = Result<float>{};
const auto globals = []()
Expand All @@ -48,7 +48,7 @@ namespace centipede::test

TEST(eigen_engine, solve_negative_definite)
{
using EngineClass = core::engine::Engine<core::engine::MatrixEngineType::eigen, float>;
using EngineClass = core::engine::Engine<core::engine::MatrixEngine::eigen, float>;

auto result = Result<float>{};
const auto globals = []()
Expand All @@ -69,7 +69,7 @@ namespace centipede::test

TEST(eigen_engine, solve_zero_factor_matrix)
{
using EngineClass = core::engine::Engine<core::engine::MatrixEngineType::eigen, float>;
using EngineClass = core::engine::Engine<core::engine::MatrixEngine::eigen, float>;

auto result = Result<float>{};
const auto globals = []()
Expand All @@ -90,7 +90,7 @@ namespace centipede::test

TEST(eigen_engine, solve_zero_rhs_vector)
{
using EngineClass = core::engine::Engine<core::engine::MatrixEngineType::eigen, float>;
using EngineClass = core::engine::Engine<core::engine::MatrixEngine::eigen, float>;

auto result = Result<float>{};
const auto globals = []()
Expand All @@ -111,7 +111,7 @@ namespace centipede::test

TEST(eigen_engine, solve)
{
using EngineClass = core::engine::Engine<core::engine::MatrixEngineType::eigen, float>;
using EngineClass = core::engine::Engine<core::engine::MatrixEngine::eigen, float>;

auto result = Result<float>{};
const auto globals = []()
Expand Down
2 changes: 1 addition & 1 deletion test/unit_tests/test_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace
{
constexpr auto DEFAULT_MAX_POINT = 30;
using centipede::core::Handler;
using centipede::Handler;

} // namespace

Expand Down
Loading
Loading