Skip to content

Commit

Permalink
Merge pull request #172 from pierrekraemer/develop
Browse files Browse the repository at this point in the history
remove topo_caches & modify foreach for "filter" and "cache" masks
  • Loading branch information
pierrekraemer committed Mar 31, 2016
2 parents aa94e56 + cd81678 commit e0e966f
Show file tree
Hide file tree
Showing 10 changed files with 482 additions and 328 deletions.
98 changes: 88 additions & 10 deletions benchmarks/multithreading/bench_multithreading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,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 @@ -115,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 @@ -141,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 @@ -150,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 Down Expand Up @@ -198,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 @@ -236,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/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ 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
Expand Down
4 changes: 0 additions & 4 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
Loading

0 comments on commit e0e966f

Please sign in to comment.