Commit ac2b88d1 authored by Sebastian Wolf's avatar Sebastian Wolf

Merge branch 'development' of git:xerus/xerus into development

parents 26def04b 1eb54d75
Pipeline #1238 passed with stages
in 17 minutes and 51 seconds
#=================================================================================================
# Compiler Options
#=================================================================================================
CXX = g++
CXX = clang++
COMPATIBILITY = -std=c++14
DEBUG_OPTIMIZATION = TRUE
......
......@@ -35,7 +35,7 @@ job_test_gcc_nocheck:
job_code_coverage:
stage: code_coverage
script: "g++ --version; cp .gitlab-ci-configs/.config.mk.ci.cc config.mk; mkdir -p build; make test &> build/build_output.txt; tail -n 500 build/build_output.txt"
script: "g++ --version; cp .gitlab-ci-configs/.config.mk.ci.cc config.mk; mkdir -p build; make test &> build/build_output.txt || { tail -n 500 build/build_output.txt && readelf -S XerusTest && objdump -s -j .cc_loc XerusTest && false; }; tail -n 500 build/build_output.txt"
when: always
artifacts:
expire_in: 3h
......
......@@ -5,14 +5,15 @@
# ------------------------------------------------------------------------------------------------------
help:
@printf "Possible make targets are:\n \
\t\tshared \t\t -- Build xerus as a shared library.\n \
\t\tstatic \t\t -- Build xerus as a static library.\n \
\t\tpython2 \t\t -- Build the xerus python2 wrappers.\n \
\t\tpython3 \t\t -- Build the xerus python3 wrappers.\n \
\t\tdoc \t\t -- Build the html documentation for the xerus library.\n \
\t\tversion \t -- Print the version of xerus.\n \
\t\tshared \t -- Build xerus as a shared library.\n \
\t\tstatic \t -- Build xerus as a static library.\n \
\t\tpython2 \t -- Build the xerus python2 wrappers.\n \
\t\tpython3 \t -- Build the xerus python3 wrappers.\n \
\t\tdoc \t -- Build the html documentation for the xerus library.\n \
\t\tinstall \t -- Install the shared library and header files (may require root).\n \
\t\ttest \t\t -- Build and run the xerus unit tests.\n \
\t\tclean \t\t -- Remove all object, library and executable files.\n"
\t\ttest \t -- Build and run the xerus unit tests.\n \
\t\tclean \t -- Remove all object, library and executable files.\n"
# ------------------------------------------------------------------------------------------------------
......@@ -282,8 +283,7 @@ install:
@printf "Cannot install xerus: INSTALL_LIB_PATH not set. Please set the path in config file.\n"
endif
$(TEST_NAME): $(MINIMAL_DEPS) $(UNIT_TEST_OBJECTS) $(TEST_OBJECTS) build/libxerus.a build/libxerus_misc.a
$(TEST_NAME): libxerus_misc_dependencies libxerus_dependencies $(MINIMAL_DEPS) $(UNIT_TEST_OBJECTS) $(TEST_OBJECTS) build/libxerus.a build/libxerus_misc.a
$(CXX) -D XERUS_UNITTEST $(FLAGS) $(UNIT_TEST_OBJECTS) $(TEST_OBJECTS) build/libxerus.a build/libxerus_misc.a $(SUITESPARSE) $(LAPACK_LIBRARIES) $(ARPACK_LIBRARIES) $(BLAS_LIBRARIES) $(BOOST_LIBS) $(CALLSTACK_LIBS) -o $(TEST_NAME)
build/print_boost_version: src/print_boost_version.cpp
......@@ -297,7 +297,7 @@ ifdef BROCKEN_CI
test:
mkdir -p build
make $(TEST_NAME)
@cat build/build_output.txt | grep "‘EnumMarker’ is deprecated" > build/required_tests.txt
@cat build/build_output.txt | grep "REQUIRE_TEST @" > build/required_tests.txt
./$(TEST_NAME) all
else
......@@ -307,7 +307,7 @@ JOB_FLAG := $(filter -j%, $(subst -j ,-j,$(shell ps T | grep "^\s*$(MAKE_PID).*$
test:
mkdir -p build
make $(TEST_NAME) $(JOB_FLAG) &> build/build_output.txt || cat build/build_output.txt
@cat build/build_output.txt | grep "‘EnumMarker’ is deprecated" > build/required_tests.txt
@cat build/build_output.txt | grep "REQUIRE_TEST @" > build/required_tests.txt
./$(TEST_NAME) all
endif
else
......@@ -316,13 +316,16 @@ test: $(TEST_NAME)
endif
test_python2: build/libxerus.so build/python2/xerus.so
.PHONY: test_python2_dependencies
test_python2_dependencies:
@:$(call check_defined, PYTEST2, pytest executable)
test_python2: test_python2_dependencies build/libxerus.so build/python2/xerus.so
@PYTHONPATH=build/python2:${PYTHONPATH} LD_LIBRARY_PATH=build:${LD_LIBRARY_PATH} $(PYTEST2) src/pyTests
test_python3: build/libxerus.so build/python3/xerus.so
.PHONY: test_python3_dependencies
test_python3_dependencies:
@:$(call check_defined, PYTEST3, pytest executable)
test_python3: test_python3_dependencies build/libxerus.so build/python3/xerus.so
@PYTHONPATH=build/python3:${PYTHONPATH} LD_LIBRARY_PATH=build:${LD_LIBRARY_PATH} $(PYTEST3) src/pyTests
......@@ -342,7 +345,7 @@ clean:
make -C doc clean
version:
@echo $(VERSION)
@echo $(XERUS_MAJOR_V).$(XERUS_MINOR_V).$(XERUS_REVISION_V)
......
......@@ -3,4 +3,5 @@ DIRNAME=$(dirname $0)
docker build "$@" -t firemarmot/base $DIRNAME/base
docker build "$@" -t firemarmot/suitesparse $DIRNAME/suitesparse
docker build "$@" -t firemarmot/xerus $DIRNAME/xerus
docker build "$@" -t firemarmot $DIRNAME
# docker build "$@" -t firemarmot/interactive $DIRNAME/interactive
docker build "$@" -t firemarmot/interactive_fenics $DIRNAME/interactive_fenics
This diff is collapsed.
#!/bin/bash
DIRNAME=$(dirname $0)
docker image rm -f firemarmot/xerus
docker image rm -f firemarmot
docker build -t firemarmot/xerus $DIRNAME/xerus
docker build -t firemarmot $DIRNAME
......@@ -27,7 +27,16 @@
#include "../basic.h"
#include "../forwardDeclarations.h"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsuggest-override"
#pragma GCC diagnostic ignored "-Wold-style-cast"
#pragma GCC diagnostic ignored "-Wparentheses"
#pragma GCC diagnostic ignored "-Wuseless-cast"
#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
#pragma GCC diagnostic ignored "-Wfloat-equal"
#include <boost/circular_buffer.hpp>
#pragma GCC diagnostic pop
......
......@@ -30,13 +30,13 @@
#ifdef XERUS_TEST_COVERAGE
#define S1(x) #x
#define S2(x) S1(x)
#define LOCATION __FILE__ ":" S2(__LINE__)
#define LOCATION_MARKED "@" LOCATION "@"
#define XERUS_CC_MARK_WARNING enum [[deprecated(LOCATION_MARKED)]] EnumMarker {}; [[maybe_unused]] EnumMarker trigger;
#define XERUS_S1(x) #x
#define XERUS_S2(x) XERUS_S1(x)
#define XERUS_LOCATION __FILE__ ":" XERUS_S2(__LINE__)
#define XERUS_LOCATION_MARKED "@" XERUS_LOCATION "@"
#define XERUS_DO_PRAGMA(x) _Pragma (#x)
#define XERUS_CC_MARK(msg) XERUS_DO_PRAGMA(message ("REQUIRE_TEST @" msg "@"))
/**
* @def XERUS_REQUIRE_TEST
......@@ -45,7 +45,7 @@
*/
#define XERUS_REQUIRE_TEST \
do { \
static const char * const xerusCCLocalFunctionLocation = LOCATION;\
static const char * const xerusCCLocalFunctionLocation = XERUS_LOCATION;\
static const char * const xerusCCLocalFunctionName = __PRETTY_FUNCTION__;\
__asm__( \
".pushsection .cc_loc, \"a\", @progbits" "\n" \
......@@ -56,7 +56,7 @@
); \
xerus::misc::CodeCoverage::covered(xerusCCLocalFunctionLocation, xerusCCLocalFunctionName); \
\
XERUS_CC_MARK_WARNING \
XERUS_CC_MARK(XERUS_LOCATION) \
} while(false)
#else
......@@ -68,8 +68,6 @@ namespace xerus { namespace misc { namespace CodeCoverage {
extern std::map<std::string, std::unordered_set<std::string>>* testsCovered;
extern std::map<std::string, std::unordered_set<std::string>>* testsRequiredInit;
void register_test(const std::string& _location, const std::string& _identifier);
void covered(const std::string& _location, const std::string& _identifier);
void print_code_coverage();
......
......@@ -30,7 +30,16 @@
#include <limits>
#include <functional>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsuggest-override"
#pragma GCC diagnostic ignored "-Wold-style-cast"
#pragma GCC diagnostic ignored "-Wparentheses"
#pragma GCC diagnostic ignored "-Wuseless-cast"
#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
#pragma GCC diagnostic ignored "-Wfloat-equal"
#include <boost/math/tools/polynomial.hpp>
#pragma GCC diagnostic pop
namespace xerus { namespace misc {
......
......@@ -27,8 +27,8 @@ static misc::UnitTest trasd_frr("TRASD", "Fixed_Rank_Recovery", [](){
auto myTRASD = TRASD;
myTRASD.maxIterations = 500;
myTRASD.targetRelativeResidual = 1e-6;
myTRASD.maxIterations = 100;
myTRASD.targetRelativeResidual = 1e-3;
for(const auto d : orders) {
size_t residualSucc = 0, ErrorSucc = 0;
......@@ -52,8 +52,8 @@ static misc::UnitTest trasd_frr("TRASD", "Fixed_Rank_Recovery", [](){
myTRASD(solution, measurments);
const double error = frob_norm(target-solution)/targetNorm;
const double residual = measurments.test(solution);
if(residual < 1e-6) { residualSucc++; }
if(error < 1e-4) { ErrorSucc++; }
if(residual < 1e-3) { residualSucc++; }
if(error < 3e-3) { ErrorSucc++; }
}
MTEST(residualSucc >= successThreshold, "Only " << residualSucc << " of " << runs << " were succesfull in terms of residual.");
......@@ -69,8 +69,8 @@ static misc::UnitTest trasd_rar("TRASD", "Rank_Adaptive_Recovery", [](){
auto myTRASD = TRASD;
myTRASD.maxIterations = 500;
myTRASD.targetRelativeResidual = 1e-6;
myTRASD.maxIterations = 100;
myTRASD.targetRelativeResidual = 1e-3;
for(const auto d : orders) {
size_t residualSucc = 0, ErrorSucc = 0;
......@@ -94,8 +94,8 @@ static misc::UnitTest trasd_rar("TRASD", "Rank_Adaptive_Recovery", [](){
myTRASD(solution, measurments, std::vector<size_t>(d-1, 10));
const double error = frob_norm(target-solution)/targetNorm;
const double residual = measurments.test(solution);
if(residual < 1e-4) { residualSucc++; }
if(error < 1e-4) { ErrorSucc++; }
if(residual < 1e-3) { residualSucc++; }
if(error < 3e-3) { ErrorSucc++; }
}
MTEST(residualSucc >= successThreshold, "Only " << residualSucc << " of " << runs << " were succesfull in terms of residual.");
......
......@@ -115,7 +115,7 @@ static misc::UnitTest tensor_rnd_add_sub("Tensor", "Random_Add_Sub", [](){
std::vector<size_t> dimensions;
std::vector<size_t> idxPow(5, 0);
for(size_t d = 0; d < 10; ++d) {
for(size_t d = 0; d < 5; ++d) {
std::vector<size_t> opDim(dimensions);
opDim.insert(opDim.end(), dimensions.begin(), dimensions.end());
std::uniform_int_distribution<size_t> numDist (0, misc::product(dimensions));
......
......@@ -32,7 +32,7 @@ static misc::UnitTest alg_largestEntry("Algorithm", "LargestEntry", [](){
std::uniform_int_distribution<size_t> dimDist(1, 4);
std::uniform_int_distribution<size_t> rankDist(1, 5);
const size_t D = 15;
const size_t D = 7;
for(size_t k = 0; k < 3; ++k) {
std::vector<size_t> stateDims;
......
......@@ -28,7 +28,7 @@ using namespace xerus;
static misc::UnitTest alg_adf_inverseidx("Algorithm", "adf_inverse_index_ratios", [](){
const size_t D = 6;
const size_t N = 10;
const size_t N = 5;
const size_t R = 3;
const size_t CS = 3;
......
......@@ -24,7 +24,16 @@
#include <xerus/algorithms/asd.h>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsuggest-override"
#pragma GCC diagnostic ignored "-Wold-style-cast"
#pragma GCC diagnostic ignored "-Wparentheses"
#pragma GCC diagnostic ignored "-Wuseless-cast"
#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
#pragma GCC diagnostic ignored "-Wfloat-equal"
#include <boost/circular_buffer.hpp>
#pragma GCC diagnostic pop
#include <xerus/misc/math.h>
#include <xerus/misc/basicArraySupport.h>
......
......@@ -28,8 +28,17 @@
#include <xerus/misc/basicArraySupport.h>
#include <xerus/misc/internal.h>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsuggest-override"
#pragma GCC diagnostic ignored "-Wold-style-cast"
#pragma GCC diagnostic ignored "-Wparentheses"
#pragma GCC diagnostic ignored "-Wuseless-cast"
#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
#pragma GCC diagnostic ignored "-Wfloat-equal"
#include <boost/math/special_functions/hermite.hpp>
#include <boost/math/special_functions/legendre.hpp>
#pragma GCC diagnostic pop
#ifdef _OPENMP
#include <omp.h>
......
......@@ -29,7 +29,16 @@
#include <xerus/misc/math.h>
#include <xerus/misc/internal.h>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsuggest-override"
#pragma GCC diagnostic ignored "-Wold-style-cast"
#pragma GCC diagnostic ignored "-Wparentheses"
#pragma GCC diagnostic ignored "-Wuseless-cast"
#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
#pragma GCC diagnostic ignored "-Wfloat-equal"
#include <boost/circular_buffer.hpp>
#pragma GCC diagnostic pop
#ifdef _OPENMP
#include <omp.h>
......@@ -43,6 +52,7 @@ namespace xerus { namespace uq { namespace impl_uqRaAdf {
const size_t N;
const size_t d;
double initialResiduum = 0.0;
const double targetResidual;
const size_t maxRank = 50;
const double minRankEps = 1e-10;
......@@ -456,7 +466,7 @@ namespace xerus { namespace uq { namespace impl_uqRaAdf {
}
}
LOG(uqADF, "Residual decrease from " << std::scientific << 0.0 /* TODO */ << " to " << std::scientific << residuals.back() << " in " << _iteration << " iterations.");
LOG(uqADF, "Residual decrease from " << std::scientific << initialResiduum << " to " << std::scientific << residuals.back() << " in " << _iteration << " iterations.");
}
......@@ -469,9 +479,12 @@ namespace xerus { namespace uq { namespace impl_uqRaAdf {
calc_right_stack(corePosition);
}
double optResidual, testResidual;
std::vector<double> setResiduals;
std::tie(optResidual, testResidual, setResiduals) = calc_residuals(0);
initialResiduum = optResidual; /* TODO: inefficient */
for(size_t iteration = 0; maxIterations == 0 || iteration < maxIterations; ++iteration) {
double optResidual, testResidual;
std::vector<double> setResiduals;
std::tie(optResidual, testResidual, setResiduals) = calc_residuals(0);
residuals.push_back(optResidual);
prevRanks.push_back(x.ranks());
......
......@@ -644,10 +644,10 @@ namespace xerus {
lapackAnswer = LAPACKE_dpotrf2(
LAPACK_ROW_MAJOR,
'U', // Upper triangle of A is read
static_cast<int>(_n), // dimensions of A
tmpA.get(), // input: A, output: cholesky factorisation
static_cast<int>(_n) // LDA
'U', // Upper triangle of A is read
static_cast<int>(_n), // dimensions of A
tmpA.get(), // input: A, output: cholesky factorisation
static_cast<int>(_n) // LDA
);
XERUS_PA_END("Dense LAPACK", "Cholesky decomposition", misc::to_string(_n)+"x"+misc::to_string(_n));
......@@ -661,13 +661,13 @@ namespace xerus {
lapackAnswer = LAPACKE_dpotrs(
LAPACK_ROW_MAJOR,
'U', // upper triangle of cholesky decomp is stored in tmpA
static_cast<int>(_n), // dimensions of A
static_cast<int>(_nrhs),// number of rhs
tmpA.get(), // input: cholesky decomp
static_cast<int>(_n), // lda
_x, // input: rhs b, output: solution x
static_cast<int>(_nrhs) // ldb
'U', // upper triangle of cholesky decomp is stored in tmpA
static_cast<int>(_n), // dimensions of A
static_cast<int>(_nrhs), // number of rhs
tmpA.get(), // input: cholesky decomp
static_cast<int>(_n), // lda
_x, // input: rhs b, output: solution x
static_cast<int>(_nrhs) // ldb
);
CHECK(lapackAnswer == 0, error, "Unable to solve Ax = b (cholesky solver). Lapacke says: " << lapackAnswer);
......
......@@ -46,15 +46,6 @@
namespace xerus { namespace misc { namespace CodeCoverage {
std::map<std::string, std::unordered_set<std::string>>* testsCovered;
std::map<std::string, std::unordered_set<std::string>>* testsRequiredInit;
void register_test(const std::string& _location, const std::string& _identifier) {
// Initialization order is undefined, therefore the first one has to initialize.
if(!testsRequiredInit) { testsRequiredInit = new std::map<std::string, std::unordered_set<std::string>>; }
(*testsRequiredInit)[_location].insert(_identifier);
}
void covered(const std::string& _location, const std::string& _identifier) {
// Initialization order is undefined, therefore the first covered test has to initialize.
......@@ -74,7 +65,7 @@ namespace xerus { namespace misc { namespace CodeCoverage {
// Load required tests from .cc_loc section
auto range = get_range_of_section(reinterpret_cast<void*>(&print_code_coverage) /* ie inside this executable */, ".cc_loc");
auto step = sizeof(uintptr_t);
size_t count = 0;
// size_t count = 0;
for (auto p = range.first; p < range.second; p += 2*step) {
char * loc = *reinterpret_cast<char **>(*reinterpret_cast<uintptr_t*>(p));
const auto locationParts = misc::explode(loc, ':');
......@@ -85,10 +76,7 @@ namespace xerus { namespace misc { namespace CodeCoverage {
const auto file = xerus::misc::normalize_pathname(locationParts[0]);
const auto lineNumber = xerus::misc::from_string<size_t>(locationParts[1]);
char * name = *reinterpret_cast<char **>(*reinterpret_cast<uintptr_t*>(p+step));
if (requiredTests.count(file) == 0 || requiredTests[file].count(lineNumber) == 0 || requiredTests[file][lineNumber].count(name) == 0) {
requiredTests[file][lineNumber][name] = false;
count += 1;
}
requiredTests[file][lineNumber][name] = false;
// LOG(codeCoverage, count << " " << file << ":" << lineNumber);
}
......@@ -97,8 +85,12 @@ namespace xerus { namespace misc { namespace CodeCoverage {
const auto testLines = xerus::misc::explode(xerus::misc::read_file("build/required_tests.txt"), '\n');
for(const auto& line : testLines) {
if (line.find("note: #pragma message: REQUIRE_TEST @")==line.npos // gcc
&& line.find("warning: REQUIRE_TEST @")==line.npos // clang
) {
continue;
}
const auto lineParts = xerus::misc::explode(line, '@');
REQUIRE(lineParts.size() == 3, "Error parsing the required tests.");
const auto locationParts = misc::explode(lineParts[1], ':');
REQUIRE(locationParts.size() == 2, "Error parsing the required tests.");
const auto file = xerus::misc::normalize_pathname(locationParts[0]);
......
......@@ -27,7 +27,16 @@
#include <xerus/misc/stringUtilities.h>
#include <fstream>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsuggest-override"
#pragma GCC diagnostic ignored "-Wold-style-cast"
#pragma GCC diagnostic ignored "-Wparentheses"
#pragma GCC diagnostic ignored "-Wuseless-cast"
#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
#pragma GCC diagnostic ignored "-Wfloat-equal"
#include <boost/filesystem.hpp>
#pragma GCC diagnostic pop
namespace xerus { namespace misc {
......
......@@ -22,10 +22,25 @@
* @brief Definition of common functions for the python bindings.
*/
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsuggest-override"
#pragma GCC diagnostic ignored "-Wold-style-cast"
#pragma GCC diagnostic ignored "-Wparentheses"
#pragma GCC diagnostic ignored "-Wuseless-cast"
#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
#pragma GCC diagnostic ignored "-Wfloat-equal"
#pragma GCC diagnostic ignored "-Wshadow"
#pragma GCC diagnostic ignored "-Wfloat-conversion"
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#pragma GCC diagnostic ignored "-Wundef"
#pragma GCC diagnostic ignored "-Wcast-qual"
#pragma GCC diagnostic ignored "-Wswitch-default"
#include <boost/function.hpp>
#include <boost/python.hpp>
#include <boost/python/stl_iterator.hpp>
#include <boost/python/call.hpp>
#pragma GCC diagnostic pop
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wuseless-cast"
......
......@@ -130,8 +130,6 @@ namespace xerus { namespace misc {
#undef main
int main(int argc, char* argv[]) {
using required_test_t = void (*)();
// signal(SIGINT, xerus::misc::internal::catch_signals); // users ctrl+c should actually terminate the program
// signal(SIGTERM, xerus::misc::internal::catch_signals);
// signal(SIGHUP, xerus::misc::internal::catch_signals);
......@@ -143,19 +141,6 @@ int main(int argc, char* argv[]) {
// Prevent swap usage
mlockall(MCL_CURRENT | MCL_FUTURE);
// TODO Is this code useful?
// perform required_test initializations
// pass address of xerus::misc::internal::catch_signals as the address of main cannot be taken as by ISO c++...
std::pair<uintptr_t, uintptr_t> requiredTestRange = xerus::misc::get_range_of_section(reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(&xerus::misc::internal::catch_signals)), "required_tests");
for (required_test_t* p = reinterpret_cast<required_test_t*>(requiredTestRange.first); p < reinterpret_cast<required_test_t*>(requiredTestRange.second); p += 1) {
try {
(*p)();
} catch (...) {
std::cout << "Required test initialization failed. Required test listing will be wrong." << std::endl;
break;
}
}
//Calculate complete time
std::chrono::high_resolution_clock::time_point startTime = std::chrono::high_resolution_clock::now();
......
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