Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable DART_ENABLE_SIMD by default #790

Merged
merged 8 commits into from
Oct 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

* Build

* Modified to build DART without SIMD options by default: [#790](https://github.com/dartsim/dart/pull/790)
* Modified to build external libraries as separately build targets: [#787](https://github.com/dartsim/dart/pull/787)
* Modified to export CMake target files separately per target: [#786](https://github.com/dartsim/dart/pull/786)

Expand Down
24 changes: 9 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,15 @@ if(MSVC)
else()
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
endif()
option(DART_ENABLE_SIMD "Build DART with SIMD enabled" ON)
# Warning: DART_ENABLE_SIMD should be ON only when you build DART and the DART
# dependent projects on the same machine. If this option is on, then compile
# option `-march=native` is added to the target `dart` that enables all
# instruction subsets supported by the local machine. If the architecture of
# local machines are different then the projects will be built with different
# compile options, which may cause runtime errors especially memory alignment
# errors.
option(DART_ENABLE_SIMD
"Build DART with all SIMD instructions on the current local machine" OFF)
option(DART_BUILD_GUI_OSG "Build osgDart library" ON)
option(DART_COVERALLS "Turn on coveralls support" OFF)
option(DART_COVERALLS_UPLOAD "Upload the generated coveralls json" ON)
Expand Down Expand Up @@ -160,14 +168,6 @@ if(MSVC)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${DART_RUNTIME_LIBRARY}d /Zi /Gy /W1 /EHsc")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${DART_RUNTIME_LIBRARY} /Zi /GL /Gy /W1 /EHsc")
endif(NOT DART_MSVC_DEFAULT_OPTIONS)
if(DART_ENABLE_SIMD)
add_definitions(/arch:SSE2 /arch:AVX /arch:AVX2)
# /arch:SSE2 option is effective only for x86 but not for x64 since it's
# enabled for x64 by default. The option will be ignored on x64 with a
# warning message. If anyone knows how to detect the system's architecture
# in CMake time, then I would gratefully apply these options differently
# depending on the architectures.
endif()

elseif(CMAKE_COMPILER_IS_GNUCXX)

Expand All @@ -187,9 +187,6 @@ elseif(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS_DEBUG "-g -fno-omit-frame-pointer -fno-inline-functions -fno-inline-functions-called-once -fno-optimize-sibling-calls")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE} ${CMAKE_CXX_FLAGS_DEBUG}")
set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_DEBUG} -pg")
if(DART_ENABLE_SIMD)
add_definitions(-march=native)
endif()

elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")

Expand All @@ -214,9 +211,6 @@ elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_CXX_FLAGS_DEBUG "-g -fno-omit-frame-pointer -fno-inline-functions -fno-optimize-sibling-calls")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE} ${CMAKE_CXX_FLAGS_DEBUG}")
set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_DEBUG} -pg")
if(DART_ENABLE_SIMD)
add_definitions(-march=native)
endif()

else()

Expand Down
16 changes: 16 additions & 0 deletions dart/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,22 @@ target_link_libraries(
${PROJECT_NAME}-external-odelcpsolver
)

# Build DART with all available SIMD instructions
if(DART_ENABLE_SIMD)
if(MSVC)
target_compile_options(dart PUBLIC /arch:SSE2 /arch:AVX /arch:AVX2)
# /arch:SSE2 option is effective only for x86 but not for x64 since it's
# enabled for x64 by default. The option will be ignored on x64 with a
# warning message. If anyone knows how to detect the system's architecture
# in CMake time, then I would gratefully apply these options differently
# depending on the architectures.
elseif(CMAKE_COMPILER_IS_GNUCXX)
target_compile_options(dart PUBLIC -march=native)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
target_compile_options(dart PUBLIC -march=native)
endif()
endif()

# Default component
add_component_targets(
${PROJECT_NAME}
Expand Down
2 changes: 1 addition & 1 deletion dart/dynamics/detail/EulerJointAspect.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ struct EulerJointProperties :
{
/// Composed constructor
EulerJointProperties(
const GenericJoint<math::R3Space>::Properties& GenericJointProperties =
const GenericJoint<math::R3Space>::Properties& genericJointProperties =
GenericJoint<math::R3Space>::Properties(),
const EulerJointUniqueProperties& eulerJointProperties =
EulerJointUniqueProperties());
Expand Down
4 changes: 2 additions & 2 deletions dart/dynamics/detail/PlanarJointAspect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ void PlanarJointUniqueProperties::setArbitraryPlane(

//==============================================================================
PlanarJointProperties::PlanarJointProperties(
const GenericJoint<math::R3Space>::Properties& GenericJointProperties,
const GenericJoint<math::R3Space>::Properties& genericJointProperties,
const PlanarJointUniqueProperties& planarProperties)
: GenericJoint<math::R3Space>::Properties(GenericJointProperties),
: GenericJoint<math::R3Space>::Properties(genericJointProperties),
PlanarJointUniqueProperties(planarProperties)
{
// Do nothing
Expand Down
2 changes: 1 addition & 1 deletion dart/dynamics/detail/PlanarJointAspect.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ struct PlanarJointProperties :
PlanarJointUniqueProperties
{
PlanarJointProperties(
const GenericJoint<math::R3Space>::Properties& GenericJointProperties =
const GenericJoint<math::R3Space>::Properties& genericJointProperties =
GenericJoint<math::R3Space>::Properties(),
const PlanarJointUniqueProperties& planarProperties =
PlanarJointUniqueProperties());
Expand Down
4 changes: 2 additions & 2 deletions dart/dynamics/detail/PrismaticJointAspect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ PrismaticJointUniqueProperties::PrismaticJointUniqueProperties(

//==============================================================================
PrismaticJointProperties::PrismaticJointProperties(
const GenericJoint<math::R1Space>::Properties& GenericJointProperties,
const GenericJoint<math::R1Space>::Properties& genericJointProperties,
const PrismaticJointUniqueProperties& prismaticProperties)
: GenericJoint<math::R1Space>::Properties(GenericJointProperties),
: GenericJoint<math::R1Space>::Properties(genericJointProperties),
PrismaticJointUniqueProperties(prismaticProperties)
{
// Do nothing
Expand Down
2 changes: 1 addition & 1 deletion dart/dynamics/detail/PrismaticJointAspect.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ struct PrismaticJointProperties :
PrismaticJointUniqueProperties
{
PrismaticJointProperties(
const GenericJoint<math::R1Space>::Properties& GenericJointProperties =
const GenericJoint<math::R1Space>::Properties& genericJointProperties =
GenericJoint<math::R1Space>::Properties(),
const PrismaticJointUniqueProperties& prismaticProperties =
PrismaticJointUniqueProperties());
Expand Down
4 changes: 2 additions & 2 deletions dart/dynamics/detail/RevoluteJointAspect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ RevoluteJointUniqueProperties::RevoluteJointUniqueProperties(

//==============================================================================
RevoluteJointProperties::RevoluteJointProperties(
const GenericJoint<math::R1Space>::Properties& GenericJointProperties,
const GenericJoint<math::R1Space>::Properties& genericJointProperties,
const RevoluteJointUniqueProperties& revoluteProperties)
: GenericJoint<math::R1Space>::Properties(GenericJointProperties),
: GenericJoint<math::R1Space>::Properties(genericJointProperties),
RevoluteJointUniqueProperties(revoluteProperties)
{
// Do nothing
Expand Down
2 changes: 1 addition & 1 deletion dart/dynamics/detail/RevoluteJointAspect.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ struct RevoluteJointProperties :
RevoluteJointUniqueProperties
{
RevoluteJointProperties(
const GenericJoint<math::R1Space>::Properties& GenericJointProperties =
const GenericJoint<math::R1Space>::Properties& genericJointProperties =
GenericJoint<math::R1Space>::Properties(),
const RevoluteJointUniqueProperties& revoluteProperties =
RevoluteJointUniqueProperties());
Expand Down
4 changes: 2 additions & 2 deletions dart/dynamics/detail/ScrewJointAspect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ ScrewJointUniqueProperties::ScrewJointUniqueProperties(

//==============================================================================
ScrewJointProperties::ScrewJointProperties(
const GenericJoint<math::R1Space>::Properties& GenericJointProperties,
const GenericJoint<math::R1Space>::Properties& genericJointProperties,
const ScrewJointUniqueProperties& screwProperties)
: GenericJoint<math::R1Space>::Properties(GenericJointProperties),
: GenericJoint<math::R1Space>::Properties(genericJointProperties),
ScrewJointUniqueProperties(screwProperties)
{
// Do nothing
Expand Down
2 changes: 1 addition & 1 deletion dart/dynamics/detail/ScrewJointAspect.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ struct ScrewJointProperties : GenericJoint<math::R1Space>::Properties,
ScrewJointUniqueProperties
{
ScrewJointProperties(
const GenericJoint<math::R1Space>::Properties& GenericJointProperties =
const GenericJoint<math::R1Space>::Properties& genericJointProperties =
GenericJoint<math::R1Space>::Properties(),
const ScrewJointUniqueProperties& screwProperties =
ScrewJointUniqueProperties());
Expand Down
4 changes: 2 additions & 2 deletions dart/dynamics/detail/UniversalJointAspect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ UniversalJointUniqueProperties::UniversalJointUniqueProperties(

//==============================================================================
UniversalJointProperties::UniversalJointProperties(
const GenericJoint<math::R2Space>::Properties& GenericJointProperties,
const GenericJoint<math::R2Space>::Properties& genericJointProperties,
const UniversalJointUniqueProperties& universalProperties)
: GenericJoint<math::R2Space>::Properties(GenericJointProperties),
: GenericJoint<math::R2Space>::Properties(genericJointProperties),
UniversalJointUniqueProperties(universalProperties)
{
// Do nothing
Expand Down
2 changes: 1 addition & 1 deletion dart/dynamics/detail/UniversalJointAspect.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ struct UniversalJointProperties :
UniversalJointUniqueProperties
{
UniversalJointProperties(
const GenericJoint<math::R2Space>::Properties& GenericJointProperties =
const GenericJoint<math::R2Space>::Properties& genericJointProperties =
GenericJoint<math::R2Space>::Properties(),
const UniversalJointUniqueProperties& universalProperties =
UniversalJointUniqueProperties());
Expand Down