Skip to content

Commit

Permalink
Merge pull request #207 from cgogn/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
pierrekraemer committed May 24, 2016
2 parents 170a589 + 00b4f67 commit 4a8be03
Show file tree
Hide file tree
Showing 277 changed files with 14,529 additions and 4,998 deletions.
38 changes: 36 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ endif()

#### CGoGN PATH
set(CGOGN_PATH "${CMAKE_CURRENT_SOURCE_DIR}")

#### Here are located the FindPackages that we need
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
list(APPEND CMAKE_PREFIX_PATH "${CMAKE_BINARY_DIR}")

#### Compile Options
include(cmake/CompilerOptions.cmake)
Expand All @@ -30,7 +32,7 @@ include(cmake/EnableCoverageReport.cmake)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
set(CGOGN_SOURCE_DIR ${CGOGN_PATH}/cgogn)
set(CGOGN_SOURCE_DIR ${CGOGN_PATH})

### External Templates
option(CGOGN_EXTERNAL_TEMPLATES "Use external templates to reduce compile time" OFF)
Expand All @@ -43,8 +45,10 @@ set(CGOGN_THIRDPARTY_DIR ${CGOGN_PATH}/thirdparty)
option(CGOGN_PROVIDE_EIGEN "Use the version of eigen that is packaged with CGoGN." ON)
option(CGOGN_PROVIDE_TINYXML2 "Use the version of tinyxml2 that is packaged with CGoGN." ON)
option(CGOGN_BUILD_TESTS "Build cgogn unit tests using google test framework." ON)
option(CGOGN_BUILD_EXAMPLES "Build some example apps." ON)
option(CGOGN_BUILD_BENCHS "Build the benchmarks using google benchmark framework." ON)
option(CGOGN_USE_OPENMP "Activate openMP directives." OFF)
option(CGOGN_ENABLE_LTO "Enable link-time optimizations (only with gcc)" ON)
if (NOT MSVC)
option(CGOGN_USE_GLIBCXX_DEBUG "Use the debug version of STL (useful for bounds checking)." OFF)
option(CGOGN_USE_GLIBCXX_DEBUG_PEDANTIC "Use an extremely picky debug version of STL." OFF)
Expand Down Expand Up @@ -125,14 +129,44 @@ else()
add_definitions("-DCGOGN_ENDIANNESS=CGOGN_LITTLE_ENDIAN")
endif()

#### Link time optimisation
if (CGOGN_ENABLE_LTO AND ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") AND (NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Debug"))
add_flags(CMAKE_CXX_FLAGS_RELEASE -flto)
find_program(GCC_AR gcc-ar)
if (GCC_AR)
set(CMAKE_AR ${GCC_AR})
endif()
find_program(GCC_RANLIB gcc-ranlib)
if (GCC_RANLIB)
set(CMAKE_RANLIB ${GCC_RANLIB})
endif()
endif()

include(GenerateExportHeader)
include(CMakePackageConfigHelpers)

add_subdirectory(${CGOGN_THIRDPARTY_DIR})
add_subdirectory(${CGOGN_SOURCE_DIR})
add_subdirectory(${CGOGN_SOURCE_DIR}/cgogn)

if(${CGOGN_BUILD_BENCHS})
add_subdirectory(benchmarks)
endif(${CGOGN_BUILD_BENCHS})

if(CGOGN_BUILD_TESTS)
add_subdirectory(cgogn/core/tests)
add_subdirectory(cgogn/geometry/tests)
add_subdirectory(cgogn/modeling/tests)
endif()

if(CGOGN_BUILD_EXAMPLES)
add_subdirectory(cgogn/core/examples)
add_subdirectory(cgogn/geometry/examples)
add_subdirectory(cgogn/io/examples)
add_subdirectory(cgogn/io/mesh_generation/examples)
add_subdirectory(cgogn/modeling/examples)
add_subdirectory(cgogn/rendering/examples)
endif()


## TODO a mettre dans un fichier cmake particulier

Expand Down
73 changes: 40 additions & 33 deletions benchmarks/multithreading/bench_multithreading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
#include <chrono>
#include <vector>

#include <core/utils/logger.h>
#include <core/cmap/cmap2.h>
#include <io/map_import.h>
#include <geometry/algos/normal.h>
#include <cgogn/core/utils/logger.h>
#include <cgogn/core/cmap/cmap2.h>
#include <cgogn/io/map_import.h>
#include <cgogn/geometry/algos/normal.h>

#include <benchmark/benchmark.h>

Expand All @@ -51,9 +51,9 @@ const uint32 ITERATIONS = 1u;
using Vec3 = cgogn::geometry::Vec_T<std::array<float64,3>>;

template <typename T>
using VertexAttributeHandler = Map2::VertexAttributeHandler<T>;
using VertexAttribute = Map2::VertexAttribute<T>;
template <typename T>
using FaceAttributeHandler = Map2::FaceAttributeHandler<T>;
using FaceAttribute = Map2::FaceAttribute<T>;

static void BENCH_Dart_count_single_threaded(benchmark::State& state)
{
Expand Down Expand Up @@ -90,9 +90,9 @@ static void BENCH_faces_normals_single_threaded(benchmark::State& state)
while(state.KeepRunning())
{
state.PauseTiming();
VertexAttributeHandler<Vec3> vertex_position = bench_map.get_attribute<Vec3, VERTEX>("position");
VertexAttribute<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");
FaceAttribute<Vec3> face_normal = bench_map.get_attribute<Vec3, FACE>("normal");
cgogn_assert(face_normal.is_valid());
state.ResumeTiming();

Expand All @@ -108,18 +108,20 @@ 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");
VertexAttribute<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");
FaceAttribute<Vec3> face_normal = bench_map.get_attribute<Vec3, FACE>("normal");
cgogn_assert(face_normal.is_valid());

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

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

Expand All @@ -129,9 +131,9 @@ static void BENCH_faces_normals_multi_threaded(benchmark::State& state)
while(state.KeepRunning())
{
state.PauseTiming();
VertexAttributeHandler<Vec3> vertex_position = bench_map.get_attribute<Vec3, VERTEX>("position");
VertexAttribute<Vec3> vertex_position = bench_map.get_attribute<Vec3, VERTEX>("position");
cgogn_assert(vertex_position.is_valid());
FaceAttributeHandler<Vec3> face_normal_mt = bench_map.get_attribute<Vec3, FACE>("normal_mt");
FaceAttribute<Vec3> face_normal_mt = bench_map.get_attribute<Vec3, FACE>("normal_mt");
cgogn_assert(face_normal_mt.is_valid());
state.ResumeTiming();

Expand All @@ -143,7 +145,7 @@ static void BENCH_faces_normals_multi_threaded(benchmark::State& state)
{
state.PauseTiming();

FaceAttributeHandler<Vec3> face_normal = bench_map.get_attribute<Vec3, FACE>("normal");
FaceAttribute<Vec3> face_normal = bench_map.get_attribute<Vec3, FACE>("normal");
bench_map.template foreach_cell<cgogn::TraversalStrategy::FORCE_DART_MARKING>([&] (Face f)
{
Vec3 error = face_normal[f] - face_normal_mt[f];
Expand All @@ -157,7 +159,6 @@ static void BENCH_faces_normals_multi_threaded(benchmark::State& state)
});
state.ResumeTiming();
}

}
}

Expand All @@ -166,18 +167,20 @@ 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");
VertexAttribute<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");
FaceAttribute<Vec3> face_normal = bench_map.get_attribute<Vec3, FACE>("normal");
cgogn_assert(face_normal.is_valid());

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

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

Expand All @@ -188,9 +191,9 @@ static void BENCH_vertices_normals_single_threaded(benchmark::State& state)
while(state.KeepRunning())
{
state.PauseTiming();
VertexAttributeHandler<Vec3> vertex_position = bench_map.get_attribute<Vec3, VERTEX>("position");
VertexAttribute<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");
VertexAttribute<Vec3> vertices_normal = bench_map.get_attribute<Vec3, VERTEX>("normal");
cgogn_assert(vertices_normal.is_valid());
state.ResumeTiming();

Expand All @@ -206,18 +209,20 @@ 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");
VertexAttribute<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");
VertexAttribute<Vec3> vertices_normal = bench_map.get_attribute<Vec3, VERTEX>("normal");
cgogn_assert(vertices_normal.is_valid());

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

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

Expand All @@ -227,9 +232,9 @@ static void BENCH_vertices_normals_multi_threaded(benchmark::State& state)
while(state.KeepRunning())
{
state.PauseTiming();
VertexAttributeHandler<Vec3> vertex_position = bench_map.get_attribute<Vec3, VERTEX>("position");
VertexAttribute<Vec3> vertex_position = bench_map.get_attribute<Vec3, VERTEX>("position");
cgogn_assert(vertex_position.is_valid());
VertexAttributeHandler<Vec3> vertices_normal_mt = bench_map.get_attribute<Vec3, VERTEX>("normal_mt");
VertexAttribute<Vec3> vertices_normal_mt = bench_map.get_attribute<Vec3, VERTEX>("normal_mt");
cgogn_assert(vertices_normal_mt.is_valid());
state.ResumeTiming();

Expand All @@ -241,7 +246,7 @@ static void BENCH_vertices_normals_multi_threaded(benchmark::State& state)
{
state.PauseTiming();

VertexAttributeHandler<Vec3> vertices_normal = bench_map.get_attribute<Vec3, VERTEX>("normal");
VertexAttribute<Vec3> vertices_normal = bench_map.get_attribute<Vec3, VERTEX>("normal");
bench_map.template foreach_cell<cgogn::TraversalStrategy::FORCE_DART_MARKING>([&] (Vertex v)
{
Vec3 error = vertices_normal[v] - vertices_normal_mt[v];
Expand All @@ -263,18 +268,20 @@ 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");
VertexAttribute<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");
VertexAttribute<Vec3> vertices_normal = bench_map.get_attribute<Vec3, VERTEX>("normal");
cgogn_assert(vertices_normal.is_valid());

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

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

Expand Down
2 changes: 1 addition & 1 deletion cgogn/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
add_subdirectory(core)
add_subdirectory(io)
add_subdirectory(geometry)
add_subdirectory(io)
add_subdirectory(modeling)

if(CGOGN_USE_QT)
Expand Down
56 changes: 36 additions & 20 deletions cgogn/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ set(HEADER_FILES
cmap/cmap2_builder.h
cmap/cmap3.h
cmap/cmap3_builder.h
cmap/attribute_handler.h
cmap/attribute.h

container/chunk_array_container.h
container/chunk_array_factory.h
Expand All @@ -36,14 +36,14 @@ set(HEADER_FILES
utils/serialization.h
utils/thread.h
utils/thread_pool.h
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
utils/numerics.h
utils/type_traits.h
)

set(SOURCE_FILES
Expand Down Expand Up @@ -76,37 +76,53 @@ set(SOURCE_FILES
)

add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES})
# generate_export_header(${PROJECT_NAME}
# EXPORT_MACRO_NAME "CGOGN_CORE_API"
# EXPORT_FILE_NAME "${CMAKE_BINARY_DIR}/exports/${PROJECT_NAME}_export.h"
# )

# use of target_compile_options to have a transitive c++11 flag
# use of target_compile_options to have transitive flags
if(NOT MSVC)
target_compile_options(${PROJECT_NAME} PUBLIC "-std=c++11")
remove_flags(CMAKE_CXX_FLAGS "-std=c++11")
if(${CGOGN_USE_CXX11_ABI})
target_compile_options(${PROJECT_NAME} PUBLIC "-D_GLIBCXX_USE_CXX11_ABI")
remove_flags(CMAKE_CXX_FLAGS "-D_GLIBCXX_USE_CXX11_ABI")
endif()
if (${CGOGN_USE_GLIBCXX_DEBUG})
target_compile_options(${PROJECT_NAME} PUBLIC "-D_GLIBCXX_DEBUG")
remove_flags(CMAKE_CXX_FLAGS "-D_GLIBCXX_DEBUG")
if(${CGOGN_USE_GLIBCXX_DEBUG_PEDANTIC})
target_compile_options(${PROJECT_NAME} PUBLIC "-D_GLIBCXX_DEBUG_PEDANTIC")
remove_flags(CMAKE_CXX_FLAGS "-D_GLIBCXX_DEBUG_PEDANTIC")
endif()
endif()
if(${CGOGN_USE_PARALLEL_GLIBCXX} AND (NOT ${CGOGN_USE_GLIBCXX_DEBUG}))
target_compile_options(${PROJECT_NAME} PUBLIC "-D_GLIBCXX_PARALLEL")
remove_flags(CMAKE_CXX_FLAGS "-D_GLIBCXX_PARALLEL")
endif()
endif()

if(MSVC)
target_compile_options(${PROJECT_NAME} PUBLIC "-D_USE_MATH_DEFINES")
## CGOGN_WIN_VER : has value 61 for windows 7, 62 for windows 8, 63 for windows 8.1, 100 for windows 10
set(WIN_VERSION "")
string(REPLACE "." "" WIN_VERSION ${CMAKE_SYSTEM_VERSION})
target_compile_options(${PROJECT_NAME} PUBLIC "-DCGOGN_WIN_VER=${WIN_VERSION}")
endif()

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>
$<INSTALL_INTERFACE:include>
)

install(DIRECTORY basic cmap container utils
DESTINATION include/cgogn/core/
install(FILES "dll.h" DESTINATION "include/cgogn/core/")
install(DIRECTORY basic cmap container utils
DESTINATION "include/cgogn/core/"
FILES_MATCHING PATTERN "*.h"
)

install(TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}Targets
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)

add_subdirectory(examples)
)

if(CGOGN_BUILD_TESTS)
add_subdirectory(tests)
endif()
cgogn_create_package("${CGOGN_SOURCE_DIR};${CGOGN_THIRDPARTY_TERMCOLOR_INCLUDE_DIR}" "include")
Loading

0 comments on commit 4a8be03

Please sign in to comment.