try to compile with clang and on osx in travis

This commit is contained in:
Patrick Brosi 2018-07-23 02:46:31 +02:00
parent 1a9482a445
commit df2ab2df77
10 changed files with 485 additions and 269 deletions

View file

@ -1,6 +1,12 @@
language: generic language: cpp
sudo: false
dist: trusty os:
- linux
- osx
compiler:
- gcc
- clang
addons: addons:
apt: apt:
@ -21,4 +27,4 @@ script:
notifications: notifications:
email: email:
on_success: never on_success: never
on_failure: always on_failure: never

View file

@ -20,7 +20,12 @@ if(OPENMP_FOUND)
endif() endif()
# set compiler flags, see http://stackoverflow.com/questions/7724569/debug-vs-release-in-cmake # set compiler flags, see http://stackoverflow.com/questions/7724569/debug-vs-release-in-cmake
set(CMAKE_CXX_FLAGS "-fopenmp -Ofast -fno-signed-zeros -fno-trapping-math -frename-registers -Wall -Wno-format-extra-args -Wextra -Wformat-nonliteral -Wformat-security -Wformat=2") if(OPENMP_FOUND)
set(CMAKE_CXX_FLAGS "-fopenmp -Ofast -fno-signed-zeros -fno-trapping-math -Wall -Wno-format-extra-args -Wextra -Wformat-nonliteral -Wformat-security -Wformat=2 -Wfatal-errors -Wextra -Wno-implicit-fallthrough -pedantic")
else()
message(WARNING "Configuring without OpenMP!")
set(CMAKE_CXX_FLAGS "-Ofast -fno-signed-zeros -fno-trapping-math -Wall -Wno-format-extra-args -Wextra -Wformat-nonliteral -Wformat-security -Wformat=2 -Wfatal-errors -Wextra -Wno-implicit-fallthrough -pedantic")
endif()
set(CMAKE_CXX_FLAGS_DEBUG "-Og -g -DLOGLEVEL=3") set(CMAKE_CXX_FLAGS_DEBUG "-Og -g -DLOGLEVEL=3")
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS} -DLOGLEVEL=2") set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS} -DLOGLEVEL=2")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -DLOGLEVEL=2") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -DLOGLEVEL=2")

@ -1 +1 @@
Subproject commit 3a462c37358da19f10e89f77fb7a277d69c6c4dc Subproject commit eae77cfdfb7eb64f87ddd48204ea9b90d6d5cfd8

View file

@ -29,7 +29,6 @@ class Collector {
public: public:
Collector(const std::string& evalOutPath, const std::vector<double>& dfBins) Collector(const std::string& evalOutPath, const std::vector<double>& dfBins)
: _noOrigShp(0), : _noOrigShp(0),
_noMatchShp(0),
_fdSum(0), _fdSum(0),
_unmatchedSegSum(0), _unmatchedSegSum(0),
_unmatchedSegLengthSum(0), _unmatchedSegLengthSum(0),
@ -70,7 +69,6 @@ class Collector {
std::map<const Shape*, std::map<const Shape*, std::pair<size_t, double> > > std::map<const Shape*, std::map<const Shape*, std::pair<size_t, double> > >
_dACache; _dACache;
size_t _noOrigShp; size_t _noOrigShp;
size_t _noMatchShp;
double _fdSum; double _fdSum;
size_t _unmatchedSegSum; size_t _unmatchedSegSum;

View file

@ -2,7 +2,13 @@
// Chair of Algorithms and Data Structures. // Chair of Algorithms and Data Structures.
// Authors: Patrick Brosi <brosi@informatik.uni-freiburg.de> // Authors: Patrick Brosi <brosi@informatik.uni-freiburg.de>
#ifdef _OPENMP
#include <omp.h> #include <omp.h>
#else
#define omp_get_thread_num() 0
#define omp_get_num_procs() 1
#endif
#include <algorithm> #include <algorithm>
#include <fstream> #include <fstream>
#include <limits> #include <limits>
@ -193,8 +199,7 @@ double CombCostFunc::operator()(const router::Edge* from, const router::Node* n,
} }
// _____________________________________________________________________________ // _____________________________________________________________________________
Router::Router(const trgraph::Graph& g, size_t numThreads) Router::Router(size_t numThreads) : _cache(numThreads) {
: _g(g), _cache(numThreads) {
for (size_t i = 0; i < numThreads; i++) { for (size_t i = 0; i < numThreads; i++) {
_cache[i] = new Cache(); _cache[i] = new Cache();
} }

View file

@ -135,7 +135,7 @@ struct CombCostFunc
class Router { class Router {
public: public:
// Init this router with caches for numThreads threads // Init this router with caches for numThreads threads
Router(const trgraph::Graph& g, size_t numThreads); explicit Router(size_t numThreads);
~Router(); ~Router();
// Find the most likely path through the graph for a node candidate route. // Find the most likely path through the graph for a node candidate route.
@ -160,8 +160,6 @@ class Router {
size_t getCacheNumber() const; size_t getCacheNumber() const;
private: private:
const trgraph::Graph& _g;
mutable std::vector<Cache*> _cache; mutable std::vector<Cache*> _cache;
HopBand getHopBand(const NodeCandGroup& a, const NodeCandGroup& b, HopBand getHopBand(const NodeCandGroup& a, const NodeCandGroup& b,
const RoutingAttrs& rAttrs, const RoutingOpts& rOpts, const RoutingAttrs& rAttrs, const RoutingOpts& rOpts,

View file

@ -2,7 +2,13 @@
// Chair of Algorithms and Data Structures. // Chair of Algorithms and Data Structures.
// Authors: Patrick Brosi <brosi@informatik.uni-freiburg.de> // Authors: Patrick Brosi <brosi@informatik.uni-freiburg.de>
#ifdef _OPENMP
#include <omp.h> #include <omp.h>
#else
#define omp_get_thread_num() 0
#define omp_get_num_procs() 1
#endif
#include <map> #include <map>
#include <mutex> #include <mutex>
#include <unordered_map> #include <unordered_map>
@ -49,7 +55,7 @@ ShapeBuilder::ShapeBuilder(Feed* feed, MOTs mots,
_motCfg(motCfg), _motCfg(motCfg),
_ecoll(ecoll), _ecoll(ecoll),
_cfg(cfg), _cfg(cfg),
_crouter(_g, omp_get_num_procs()), _crouter(omp_get_num_procs()),
_curShpCnt(0) { _curShpCnt(0) {
_numThreads = _crouter.getCacheNumber(); _numThreads = _crouter.getCacheNumber();
writeMotStops(); writeMotStops();

View file

@ -23,6 +23,7 @@ using namespace util::graph;
const lest::test specification[] = { const lest::test specification[] = {
// ___________________________________________________________________________ // ___________________________________________________________________________
{
CASE("atof") { CASE("atof") {
EXPECT(util::atof("45.534215") == approx(45.534215)); EXPECT(util::atof("45.534215") == approx(45.534215));
EXPECT(util::atof("5.534") == approx(5.534)); EXPECT(util::atof("5.534") == approx(5.534));
@ -33,9 +34,10 @@ CASE("atof") {
// TODO: more test cases // TODO: more test cases
}, }},
// ___________________________________________________________________________ // ___________________________________________________________________________
{
CASE("dirgraph") { CASE("dirgraph") {
DirGraph<int, int> g; DirGraph<int, int> g;
@ -74,9 +76,10 @@ CASE("dirgraph") {
EXPECT(a->getDeg() == (size_t)1); EXPECT(a->getDeg() == (size_t)1);
// TODO: more test cases // TODO: more test cases
}, }},
// ___________________________________________________________________________ // ___________________________________________________________________________
{
CASE("unddirgraph") { CASE("unddirgraph") {
UndirGraph<int, int> g; UndirGraph<int, int> g;
@ -118,9 +121,10 @@ CASE("unddirgraph") {
// TODO: more test cases // TODO: more test cases
}, }},
// ___________________________________________________________________________ // ___________________________________________________________________________
{
CASE("grid") { CASE("grid") {
Grid<int, Line, double> g(.5, .5, Box<double>(Point<double>(0, 0), Point<double>(3, 3))); Grid<int, Line, double> g(.5, .5, Box<double>(Point<double>(0, 0), Point<double>(3, 3)));
@ -151,9 +155,10 @@ CASE("grid") {
// TODO: more test cases // TODO: more test cases
}, }},
// ___________________________________________________________________________ // ___________________________________________________________________________
{
CASE("densify") { CASE("densify") {
Line<double> a; Line<double> a;
a.push_back(Point<double>(1, 1)); a.push_back(Point<double>(1, 1));
@ -179,9 +184,10 @@ CASE("densify") {
dense = util::geo::simplify(dense, 0.1); dense = util::geo::simplify(dense, 0.1);
EXPECT(dense.size() == (size_t)3); EXPECT(dense.size() == (size_t)3);
}, }},
// ___________________________________________________________________________ // ___________________________________________________________________________
{
CASE("summed frechet distance") { CASE("summed frechet distance") {
Line<double> a; Line<double> a;
a.push_back(Point<double>(1, 1)); a.push_back(Point<double>(1, 1));
@ -203,9 +209,10 @@ CASE("summed frechet distance") {
double fd = util::geo::accFrechetDistC(a, b, 0.1); double fd = util::geo::accFrechetDistC(a, b, 0.1);
EXPECT(fd == approx(2)); EXPECT(fd == approx(2));
}, }},
// ___________________________________________________________________________ // ___________________________________________________________________________
{
CASE("frechet distance") { CASE("frechet distance") {
Line<double> e; Line<double> e;
e.push_back(Point<double>(1, 1)); e.push_back(Point<double>(1, 1));
@ -268,9 +275,10 @@ CASE("frechet distance") {
fd = util::geo::frechetDist(g, h, 0.1); fd = util::geo::frechetDist(g, h, 0.1);
EXPECT(fd == approx(1)); EXPECT(fd == approx(1));
}, }},
// ___________________________________________________________________________ // ___________________________________________________________________________
{
CASE("geo box alignment") { CASE("geo box alignment") {
Line<double> a; Line<double> a;
a.push_back(Point<double>(1, 1)); a.push_back(Point<double>(1, 1));
@ -304,32 +312,36 @@ CASE("geo box alignment") {
EXPECT(parallelity(box, ml) == approx(0)); EXPECT(parallelity(box, ml) == approx(0));
ml = rotate(ml, 45); ml = rotate(ml, 45);
EXPECT(parallelity(box, ml) == approx(1)); EXPECT(parallelity(box, ml) == approx(1));
}, }},
// ___________________________________________________________________________ // ___________________________________________________________________________
{
CASE("url decode") { CASE("url decode") {
EXPECT("zürich" == util::urlDecode("z%C3%BCrich")); EXPECT("zürich" == util::urlDecode("z%C3%BCrich"));
EXPECT("!@$%^*()" == util::urlDecode("!%40%24%25%5E*()")); EXPECT("!@$%^*()" == util::urlDecode("!%40%24%25%5E*()"));
EXPECT("Løkken" == util::urlDecode("L%C3%B8kken")); EXPECT("Løkken" == util::urlDecode("L%C3%B8kken"));
EXPECT("á é" == util::urlDecode("%C3%A1%20%C3%A9")); EXPECT("á é" == util::urlDecode("%C3%A1%20%C3%A9"));
EXPECT("á é" == util::urlDecode("%C3%A1+%C3%A9")); EXPECT("á é" == util::urlDecode("%C3%A1+%C3%A9"));
}, }},
// ___________________________________________________________________________ // ___________________________________________________________________________
{
CASE("json escape") { CASE("json escape") {
EXPECT("Hello\\\\Goodbye!" == util::jsonStringEscape("Hello\\Goodbye!")); EXPECT("Hello\\\\Goodbye!" == util::jsonStringEscape("Hello\\Goodbye!"));
EXPECT("\\\"Hello\\\"" == util::jsonStringEscape("\"Hello\"")); EXPECT("\\\"Hello\\\"" == util::jsonStringEscape("\"Hello\""));
}, }},
// ___________________________________________________________________________ // ___________________________________________________________________________
{
CASE("split") { CASE("split") {
EXPECT(util::split("hello,again", ',').size() == (size_t)2); EXPECT(util::split("hello,again", ',').size() == (size_t)2);
EXPECT(util::split("hello,,again", ',').size() == (size_t)3); EXPECT(util::split("hello,,again", ',').size() == (size_t)3);
EXPECT(util::split("hello", ',').size() == (size_t)1); EXPECT(util::split("hello", ',').size() == (size_t)1);
EXPECT(util::split("", ',').size() == (size_t)0); EXPECT(util::split("", ',').size() == (size_t)0);
}, }},
// ___________________________________________________________________________ // ___________________________________________________________________________
{
CASE("editdist") { CASE("editdist") {
EXPECT(util::editDist("hello", "mello") == (size_t)1); EXPECT(util::editDist("hello", "mello") == (size_t)1);
EXPECT(util::editDist("mello", "hello") == (size_t)1); EXPECT(util::editDist("mello", "hello") == (size_t)1);
@ -338,15 +350,17 @@ CASE("editdist") {
EXPECT(util::editDist("xabcd", "abcde") == (size_t)2); EXPECT(util::editDist("xabcd", "abcde") == (size_t)2);
EXPECT(util::editDist("abcd", "abcdes") == (size_t)2); EXPECT(util::editDist("abcd", "abcdes") == (size_t)2);
EXPECT(util::editDist("hello", "hello") == (size_t)0); EXPECT(util::editDist("hello", "hello") == (size_t)0);
}, }},
// ___________________________________________________________________________ // ___________________________________________________________________________
{
CASE("toString") { CASE("toString") {
EXPECT(util::toString(34) == "34"); EXPECT(util::toString(34) == "34");
EXPECT(util::toString("34") == "34"); EXPECT(util::toString("34") == "34");
}, }},
// ___________________________________________________________________________ // ___________________________________________________________________________
{
CASE("replace") { CASE("replace") {
std::string a("lorem ipsum ipsum lorem"); std::string a("lorem ipsum ipsum lorem");
@ -380,9 +394,10 @@ CASE("replace") {
EXPECT(!util::replaceAll(b, "", "ee")); EXPECT(!util::replaceAll(b, "", "ee"));
EXPECT(b == "loree aaaau aaaau loree"); EXPECT(b == "loree aaaau aaaau loree");
}, }},
// ___________________________________________________________________________ // ___________________________________________________________________________
{
CASE("Edge-based Dijkstra directed, 1 to all") { CASE("Edge-based Dijkstra directed, 1 to all") {
DirGraph<std::string, int> g; DirGraph<std::string, int> g;
@ -436,9 +451,10 @@ CASE("Edge-based Dijkstra directed, 1 to all") {
int single = EDijkstra::shortestPath(u.first, eBC, cFunc); int single = EDijkstra::shortestPath(u.first, eBC, cFunc);
EXPECT(single == u.second); EXPECT(single == u.second);
} }
}, }},
// ___________________________________________________________________________ // ___________________________________________________________________________
{
CASE("Edge-based Dijkstra undirected, edge 1 to 1") { CASE("Edge-based Dijkstra undirected, edge 1 to 1") {
UndirGraph<std::string, int> g; UndirGraph<std::string, int> g;
@ -494,9 +510,10 @@ CASE("Edge-based Dijkstra undirected, edge 1 to 1") {
cost = EDijkstra::shortestPath(eAB, b, cFunc, &resE, &res); cost = EDijkstra::shortestPath(eAB, b, cFunc, &resE, &res);
EXPECT(cost == 0); EXPECT(cost == 0);
}, }},
// ___________________________________________________________________________ // ___________________________________________________________________________
{
CASE("Edge-based Dijkstra undirected, edge 1 to n") { CASE("Edge-based Dijkstra undirected, edge 1 to n") {
UndirGraph<std::string, int> g; UndirGraph<std::string, int> g;
@ -542,9 +559,10 @@ CASE("Edge-based Dijkstra undirected, edge 1 to n") {
EDijkstra::EList<std::string, int> resE; EDijkstra::EList<std::string, int> resE;
int cost = EDijkstra::shortestPath(eAB, tos, cFunc, &resE, &res); int cost = EDijkstra::shortestPath(eAB, tos, cFunc, &resE, &res);
EXPECT(cost == 0); EXPECT(cost == 0);
}, }},
// ___________________________________________________________________________ // ___________________________________________________________________________
{
CASE("Edge-based Dijkstra undirected, 1 to n") { CASE("Edge-based Dijkstra undirected, 1 to n") {
UndirGraph<std::string, int> g; UndirGraph<std::string, int> g;
@ -596,9 +614,10 @@ CASE("Edge-based Dijkstra undirected, 1 to n") {
EXPECT(resE[eDC]->size() == (size_t)3); EXPECT(resE[eDC]->size() == (size_t)3);
EXPECT(res[eED]->size() == (size_t)3); EXPECT(res[eED]->size() == (size_t)3);
}, }},
// ___________________________________________________________________________ // ___________________________________________________________________________
{
CASE("Edge-based Dijkstra undirected") { CASE("Edge-based Dijkstra undirected") {
UndirGraph<std::string, int> g; UndirGraph<std::string, int> g;
@ -668,9 +687,10 @@ CASE("Edge-based Dijkstra undirected") {
cost = EDijkstra::shortestPath(a, d, cFunc, &res); cost = EDijkstra::shortestPath(a, d, cFunc, &res);
EXPECT(cost == 2); EXPECT(cost == 2);
}, }},
// ___________________________________________________________________________ // ___________________________________________________________________________
{
CASE("Edge-based Dijkstra") { CASE("Edge-based Dijkstra") {
DirGraph<int, int> g; DirGraph<int, int> g;
@ -715,9 +735,10 @@ CASE("Edge-based Dijkstra") {
cost = EDijkstra::shortestPath(a, d, cFunc, &res); cost = EDijkstra::shortestPath(a, d, cFunc, &res);
EXPECT(cost == 2); EXPECT(cost == 2);
}, }},
// ___________________________________________________________________________ // ___________________________________________________________________________
{
CASE("Dijkstra") { CASE("Dijkstra") {
DirGraph<int, int> g; DirGraph<int, int> g;
@ -779,9 +800,10 @@ CASE("Dijkstra") {
EXPECT(costs[c] == 1); EXPECT(costs[c] == 1);
EXPECT(costs[d] == 2); EXPECT(costs[d] == 2);
EXPECT(costs[x] == 999); EXPECT(costs[x] == 999);
}, }},
// ___________________________________________________________________________ // ___________________________________________________________________________
{
CASE("nullable") { CASE("nullable") {
{ {
util::Nullable<std::string> nullable; util::Nullable<std::string> nullable;
@ -840,9 +862,10 @@ CASE("nullable") {
EXPECT_THROWS(nullable == voidnull); EXPECT_THROWS(nullable == voidnull);
} }
}, }},
// ___________________________________________________________________________ // ___________________________________________________________________________
{
CASE("geometry") { CASE("geometry") {
geo::Point<double> a(1, 2); geo::Point<double> a(1, 2);
geo::Point<double> b(2, 3); geo::Point<double> b(2, 3);
@ -1188,7 +1211,7 @@ CASE("geometry") {
EXPECT(geo::contains(geo::Polygon<double>({{0.0, 0.0}, {1.0, 1.0}, {1.5, 0.5}, {0.5, -0.5}}), geo::convexHull(obox))); EXPECT(geo::contains(geo::Polygon<double>({{0.0, 0.0}, {1.0, 1.0}, {1.5, 0.5}, {0.5, -0.5}}), geo::convexHull(obox)));
} }
}; }};
// _____________________________________________________________________________ // _____________________________________________________________________________
int main(int argc, char** argv) { int main(int argc, char** argv) {

File diff suppressed because it is too large Load diff

@ -1 +1 @@
Subproject commit b87c8262361f72fff05ca0b1320f8a1d9160b5cd Subproject commit f8e187d07f9d8045bb41883d3e1c7d0ed6f241e4