Skip to content

Commit

Permalink
Merge pull request #173 from cgogn/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
pierrekraemer committed Mar 31, 2016
2 parents 18c18c3 + e0e966f commit 170a589
Show file tree
Hide file tree
Showing 166 changed files with 120,957 additions and 4,347 deletions.
109 changes: 94 additions & 15 deletions benchmarks/multithreading/bench_multithreading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <chrono>
#include <vector>

#include <core/utils/logger.h>
#include <core/cmap/cmap2.h>
#include <io/map_import.h>
#include <geometry/algos/normal.h>
Expand Down Expand Up @@ -102,6 +103,26 @@ static void BENCH_faces_normals_single_threaded(benchmark::State& state)
}
}

static void BENCH_faces_normals_cache_single_threaded(benchmark::State& state)
{
while(state.KeepRunning())
{
state.PauseTiming();
VertexAttributeHandler<Vec3> vertex_position = bench_map.get_attribute<Vec3, VERTEX>("position");
cgogn_assert(vertex_position.is_valid());
FaceAttributeHandler<Vec3> face_normal = bench_map.get_attribute<Vec3, FACE>("normal");
cgogn_assert(face_normal.is_valid());

cgogn::CellCache<Face, Map2> cache(bench_map);
state.ResumeTiming();

bench_map.foreach_cell([&] (Face f)
{
face_normal[f] = cgogn::geometry::face_normal<Vec3>(bench_map, f, vertex_position);
}, cache);
}
}

template<cgogn::TraversalStrategy STRATEGY>
static void BENCH_faces_normals_multi_threaded(benchmark::State& state)
{
Expand All @@ -114,7 +135,7 @@ static void BENCH_faces_normals_multi_threaded(benchmark::State& state)
cgogn_assert(face_normal_mt.is_valid());
state.ResumeTiming();

bench_map.template parallel_foreach_cell<STRATEGY>([&] (Face f,uint32)
bench_map.template parallel_foreach_cell<STRATEGY>([&] (Face f, uint32)
{
face_normal_mt[f] = cgogn::geometry::face_normal<Vec3>(bench_map, f, vertex_position);
});
Expand All @@ -128,7 +149,7 @@ static void BENCH_faces_normals_multi_threaded(benchmark::State& state)
Vec3 error = face_normal[f] - face_normal_mt[f];
if (!cgogn::almost_equal_absolute(error.squaredNorm(), 0., 1e-9 ))
{
std::cerr << __FILE__ << ":" << __LINE__ << " : there was an error during computation of normals" << std::endl;
cgogn_log_warning("bench_multithreading") << "There was an error during computation of normals.";
// std::cerr << "face_normal " << face_normal[f] << std::endl;
// std::cerr << "face_normal_mt " << face_normal_mt[f] << std::endl;
}
Expand All @@ -140,6 +161,26 @@ static void BENCH_faces_normals_multi_threaded(benchmark::State& state)
}
}

static void BENCH_faces_normals_cache_multi_threaded(benchmark::State& state)
{
while(state.KeepRunning())
{
state.PauseTiming();
VertexAttributeHandler<Vec3> vertex_position = bench_map.get_attribute<Vec3, VERTEX>("position");
cgogn_assert(vertex_position.is_valid());
FaceAttributeHandler<Vec3> face_normal = bench_map.get_attribute<Vec3, FACE>("normal");
cgogn_assert(face_normal.is_valid());

cgogn::CellCache<Face, Map2> cache(bench_map);
state.ResumeTiming();

bench_map.parallel_foreach_cell([&] (Face f, uint32)
{
face_normal[f] = cgogn::geometry::face_normal<Vec3>(bench_map, f, vertex_position);
}, cache);
}
}


template<cgogn::TraversalStrategy STRATEGY>
static void BENCH_vertices_normals_single_threaded(benchmark::State& state)
Expand All @@ -149,17 +190,37 @@ static void BENCH_vertices_normals_single_threaded(benchmark::State& state)
state.PauseTiming();
VertexAttributeHandler<Vec3> vertex_position = bench_map.get_attribute<Vec3, VERTEX>("position");
cgogn_assert(vertex_position.is_valid());
VertexAttributeHandler<Vec3> vartices_normal = bench_map.get_attribute<Vec3, VERTEX>("normal");
cgogn_assert(vartices_normal.is_valid());
VertexAttributeHandler<Vec3> vertices_normal = bench_map.get_attribute<Vec3, VERTEX>("normal");
cgogn_assert(vertices_normal.is_valid());
state.ResumeTiming();

bench_map.template foreach_cell<STRATEGY>([&] (Vertex v)
{
vartices_normal[v] = cgogn::geometry::vertex_normal<Vec3>(bench_map, v, vertex_position);
vertices_normal[v] = cgogn::geometry::vertex_normal<Vec3>(bench_map, v, vertex_position);
});
}
}

static void BENCH_vertices_normals_cache_single_threaded(benchmark::State& state)
{
while(state.KeepRunning())
{
state.PauseTiming();
VertexAttributeHandler<Vec3> vertex_position = bench_map.get_attribute<Vec3, VERTEX>("position");
cgogn_assert(vertex_position.is_valid());
VertexAttributeHandler<Vec3> vertices_normal = bench_map.get_attribute<Vec3, VERTEX>("normal");
cgogn_assert(vertices_normal.is_valid());

cgogn::CellCache<Vertex, Map2> cache(bench_map);
state.ResumeTiming();

bench_map.foreach_cell([&] (Vertex v)
{
vertices_normal[v] = cgogn::geometry::vertex_normal<Vec3>(bench_map, v, vertex_position);
}, cache);
}
}

template<cgogn::TraversalStrategy STRATEGY>
static void BENCH_vertices_normals_multi_threaded(benchmark::State& state)
{
Expand All @@ -186,7 +247,7 @@ static void BENCH_vertices_normals_multi_threaded(benchmark::State& state)
Vec3 error = vertices_normal[v] - vertices_normal_mt[v];
if (!cgogn::almost_equal_absolute(error.squaredNorm(), 0., 1e-9 ))
{
std::cerr << __FILE__ << ":" << __LINE__ << " : there was an error during computation of vertices normals" << std::endl;
cgogn_log_warning("bench_multithreading") << "There was an error during computation of vertices normals.";
// std::cerr << "vertices_normal " << vertices_normal[v] << std::endl;
// std::cerr << "vertices_normal_mt " << vertices_normal_mt[v] << std::endl;
}
Expand All @@ -197,22 +258,42 @@ static void BENCH_vertices_normals_multi_threaded(benchmark::State& state)
}
}

static void BENCH_vertices_normals_cache_multi_threaded(benchmark::State& state)
{
while(state.KeepRunning())
{
state.PauseTiming();
VertexAttributeHandler<Vec3> vertex_position = bench_map.get_attribute<Vec3, VERTEX>("position");
cgogn_assert(vertex_position.is_valid());
VertexAttributeHandler<Vec3> vertices_normal = bench_map.get_attribute<Vec3, VERTEX>("normal");
cgogn_assert(vertices_normal.is_valid());

cgogn::CellCache<Vertex, Map2> cache(bench_map);
state.ResumeTiming();

bench_map.parallel_foreach_cell([&] (Vertex v, uint32)
{
vertices_normal[v] = cgogn::geometry::vertex_normal<Vec3>(bench_map, v, vertex_position);
}, cache);
}
}

BENCHMARK(BENCH_Dart_count_single_threaded);
BENCHMARK(BENCH_Dart_count_multi_threaded)->UseRealTime();

BENCHMARK_TEMPLATE(BENCH_faces_normals_single_threaded, cgogn::TraversalStrategy::FORCE_DART_MARKING)->UseRealTime();
BENCHMARK_TEMPLATE(BENCH_faces_normals_multi_threaded, cgogn::TraversalStrategy::FORCE_DART_MARKING)->UseRealTime();
BENCHMARK_TEMPLATE(BENCH_faces_normals_single_threaded, cgogn::TraversalStrategy::FORCE_CELL_MARKING)->UseRealTime();
BENCHMARK_TEMPLATE(BENCH_faces_normals_multi_threaded, cgogn::TraversalStrategy::FORCE_CELL_MARKING)->UseRealTime();
BENCHMARK_TEMPLATE(BENCH_faces_normals_single_threaded, cgogn::TraversalStrategy::FORCE_TOPO_CACHE)->UseRealTime();
BENCHMARK_TEMPLATE(BENCH_faces_normals_multi_threaded, cgogn::TraversalStrategy::FORCE_TOPO_CACHE)->UseRealTime();
BENCHMARK(BENCH_faces_normals_cache_single_threaded)->UseRealTime();
BENCHMARK(BENCH_faces_normals_cache_multi_threaded)->UseRealTime();

BENCHMARK_TEMPLATE(BENCH_vertices_normals_single_threaded, cgogn::TraversalStrategy::FORCE_DART_MARKING)->UseRealTime();
BENCHMARK_TEMPLATE(BENCH_vertices_normals_multi_threaded, cgogn::TraversalStrategy::FORCE_DART_MARKING)->UseRealTime();
BENCHMARK_TEMPLATE(BENCH_vertices_normals_single_threaded, cgogn::TraversalStrategy::FORCE_CELL_MARKING)->UseRealTime();
BENCHMARK_TEMPLATE(BENCH_vertices_normals_multi_threaded, cgogn::TraversalStrategy::FORCE_CELL_MARKING)->UseRealTime();
BENCHMARK_TEMPLATE(BENCH_vertices_normals_single_threaded, cgogn::TraversalStrategy::FORCE_TOPO_CACHE)->UseRealTime();
BENCHMARK_TEMPLATE(BENCH_vertices_normals_multi_threaded, cgogn::TraversalStrategy::FORCE_TOPO_CACHE)->UseRealTime();
BENCHMARK(BENCH_vertices_normals_cache_single_threaded)->UseRealTime();
BENCHMARK(BENCH_vertices_normals_cache_multi_threaded)->UseRealTime();


int main(int argc, char** argv)
Expand All @@ -222,9 +303,9 @@ int main(int argc, char** argv)

if (argc < 2)
{
std::cout << "USAGE: " << argv[0] << " [filename]" << std::endl;
surfaceMesh = std::string(DEFAULT_MESH_PATH) + std::string("aneurysm3D_1.off");
std::cout << "Using default mesh : " << surfaceMesh << std::endl;
cgogn_log_info("bench_multithreading") << "USAGE: " << argv[0] << " [filename]";
surfaceMesh = std::string(DEFAULT_MESH_PATH) + std::string("off/aneurysm_3D.off");
cgogn_log_info("bench_multithreading") << "Using default mesh : \"" << surfaceMesh << "\".";
}
else
surfaceMesh = std::string(argv[1]);
Expand All @@ -235,8 +316,6 @@ int main(int argc, char** argv)
bench_map.add_attribute<Vec3, FACE>("normal_mt");
bench_map.add_attribute<Vec3, VERTEX>("normal");
bench_map.add_attribute<Vec3, VERTEX>("normal_mt");
bench_map.enable_topo_cache<FACE>();
bench_map.enable_topo_cache<VERTEX>();

::benchmark::RunSpecifiedBenchmarks();
return 0;
Expand Down
1 change: 1 addition & 0 deletions cgogn/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
add_subdirectory(core)
add_subdirectory(io)
add_subdirectory(geometry)
add_subdirectory(modeling)

if(CGOGN_USE_QT)
add_subdirectory(rendering)
Expand Down
10 changes: 10 additions & 0 deletions cgogn/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ set(HEADER_FILES
utils/thread_barrier.h
utils/string.h
utils/precision.h
utils/masks.h
utils/logger.h
utils/log_entry.h
utils/logger_output.h
utils/log_stream.h
)

set(SOURCE_FILES
Expand All @@ -64,6 +69,10 @@ set(SOURCE_FILES
utils/thread.cpp
utils/thread_pool.cpp
utils/serialization.cpp
utils/logger.cpp
utils/log_entry.cpp
utils/logger_output.cpp
utils/log_stream.cpp
)

add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES})
Expand All @@ -80,6 +89,7 @@ set_target_properties(${PROJECT_NAME} PROPERTIES DEBUG_POSTFIX "_d")

target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CGOGN_SOURCE_DIR}>
$<BUILD_INTERFACE:${CGOGN_THIRDPARTY_TERMCOLOR_INCLUDE_DIR}>
$<INSTALL_INTERFACE:include/cgogn/core>
)

Expand Down
9 changes: 0 additions & 9 deletions cgogn/core/basic/cell.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,6 @@ inline std::string orbit_name(Orbit orbit)

/**
* \brief Cellular typing
*
* \details warning to automatic conversion
* cell -> Dart (or const Dart&) ok
* Dart -> Cell (or const Cell&) ok
* \tparam ORBIT The type of the orbit used to create the Cell
*/
template <Orbit ORBIT_VAL>
Expand Down Expand Up @@ -119,11 +115,6 @@ class Cell
//TODO
// Cell(Cell<ORBIT>&& ) = delete;

/**
* \brief Cast operator.
* \return the dart
*/
inline operator Dart() const { return dart; }

/**
* \brief Tests the validity of the cell.
Expand Down
28 changes: 8 additions & 20 deletions cgogn/core/basic/dart_marker.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,14 @@ class DartMarker_T
mark_attribute_ = map_.get_topology_mark_attribute();
}

CGOGN_NOT_COPYABLE_NOR_MOVABLE(DartMarker_T);

virtual ~DartMarker_T()
{
if (MapGen::is_alive(&map_))
map_.release_topology_mark_attribute(mark_attribute_);
}

DartMarker_T(const Self& dm) = delete;
DartMarker_T(Self&& dm) = delete;
Self& operator=(const Self& dm) = delete;
Self& operator=(Self&& dm) = delete;

inline void mark(Dart d)
{
cgogn_message_assert(mark_attribute_ != nullptr, "DartMarker has null mark attribute");
Expand Down Expand Up @@ -116,16 +113,13 @@ class DartMarker : public DartMarker_T<MAP>
Inherit(map)
{}

CGOGN_NOT_COPYABLE_NOR_MOVABLE(DartMarker);

~DartMarker() override
{
unmark_all();
}

DartMarker(const Self& dm) = delete;
DartMarker(Self&& dm) = delete;
Self& operator=(Self&& dm) = delete;
Self& operator=(const Self& dm) = delete;

inline void unmark_all()
{
cgogn_message_assert(this->mark_attribute_ != nullptr, "DartMarker has null mark attribute");
Expand Down Expand Up @@ -154,17 +148,14 @@ class DartMarkerStore : public DartMarker_T<MAP>
marked_darts_ = cgogn::get_dart_buffers()->get_buffer();
}

CGOGN_NOT_COPYABLE_NOR_MOVABLE(DartMarkerStore);

~DartMarkerStore() override
{
unmark_all();
cgogn::get_dart_buffers()->release_buffer(marked_darts_);
}

DartMarkerStore(const Self& dm) = delete;
DartMarkerStore(Self&& dm) = delete;
Self& operator=(Self&& dm) = delete;
Self& operator=(const Self& dm) = delete;

inline void mark(Dart d)
{
cgogn_message_assert(this->mark_attribute_ != nullptr, "DartMarkerStore has null mark attribute");
Expand Down Expand Up @@ -210,13 +201,10 @@ class DartMarkerNoUnmark : public DartMarker_T<MAP>
Inherit(map)
{}

CGOGN_NOT_COPYABLE_NOR_MOVABLE(DartMarkerNoUnmark);

~DartMarkerNoUnmark() override
{}

DartMarkerNoUnmark(const Self& dm) = delete;
DartMarkerNoUnmark(Self&& dm) = delete;
Self& operator=(Self&& dm) = delete;
Self& operator=(const Self& dm) = delete;
};

} // namespace cgogn
Expand Down
7 changes: 2 additions & 5 deletions cgogn/core/cmap/cmap0.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,11 @@ class CMap0_T : public MapBase<MAP_TRAITS, MAP_TYPE>
CMap0_T() : Inherit()
{}

CGOGN_NOT_COPYABLE_NOR_MOVABLE(CMap0_T);

~CMap0_T() override
{}

CMap0_T(Self const&) = delete;
CMap0_T(Self &&) = delete;
Self& operator=(Self const&) = delete;
Self& operator=(Self &&) = delete;

/*!
* \brief Check the integrity of embedding information
*/
Expand Down
Loading

0 comments on commit 170a589

Please sign in to comment.