Skip to content
Snippets Groups Projects
Commit 8a25c826 authored by scott snyder's avatar scott snyder
Browse files

GeoModelKernel: Compile GeoXF.cxx with optimization, even in debug builds.

GeoXF.cxx makes heavy use of Eigen.  In debug builds it ends up being
much, much slower than in optimized builds, to the point where where it
makes it difficult to run things in dbg.  Tweak the build so that we compile
GeoXF.cxx with optimization, even in dbg builds.  We also need to use the
flatten attribute on the functions that use Eigen, so ensure that the Eigen
operations are completely inlined.

This was motivated by the fact that numerous tests are timing out in the dbg
build.  This change alone reduced the time required by one test from ~600s
to ~400s.
parent 11f0f983
No related branches found
No related tags found
1 merge request!51GeoModelKernel: Compile GeoXF.cxx with optimization, even in debug builds.
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
# Find the header and source files.
file( GLOB SOURCES src/*.cxx )
......@@ -20,6 +20,19 @@ set_target_properties( GeoModelKernel PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR} )
# Code in this file makes heavy use of eigen and runs orders of magnitude
# more slowly without optimization. So force this to be optimized even
# in debug builds. If you need to debug it you might want to change this.
# Specifying optimization via an attribute on the particular
# function didn't work, because that still didn't allow inlining.
if ( "${CMAKE_BUILD_TYPE}" STREQUAL "Debug" )
set_source_files_properties(
${CMAKE_CURRENT_SOURCE_DIR}/src/GeoXF.cxx
PROPERTIES
COMPILE_FLAGS "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}"
COMPILE_DEFINITIONS "FLATTEN" )
endif()
# Set up an alias with the same name that you would get by "finding" a pre-built
# version of the library.
add_library( GeoModelCore::GeoModelKernel ALIAS GeoModelKernel )
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/
#include "GeoModelKernel/GeoXF.h"
......@@ -134,11 +134,23 @@ namespace GeoXF
return m_arg2->dimensionality ();
}
#if defined(FLATTEN) && defined(__GNUC__)
// We compile this package with optimization, even in debug builds; otherwise,
// the heavy use of Eigen makes it too slow. However, from here we may call
// to out-of-line Eigen code that is linked from other DSOs; in that case,
// it would not be optimized. Avoid this by forcing all Eigen code
// to be inlined here if possible.
__attribute__ ((flatten))
#endif
GeoTrf::Transform3D PreMult::operator () (double x) const
{
return m_arg1 * (*m_arg2) (x);
}
#if defined(FLATTEN) && defined(__GNUC__)
// See above.
__attribute__ ((flatten))
#endif
GeoTrf::Transform3D PreMult::operator () (const GeoGenfun::Argument & x) const
{
return m_arg1 * (*m_arg2) (x);
......@@ -181,11 +193,19 @@ namespace GeoXF
return m_arg1->dimensionality ();
}
#if defined(FLATTEN) && defined(__GNUC__)
// See above.
__attribute__ ((flatten))
#endif
GeoTrf::Transform3D PostMult::operator () (double x) const
{
return (*m_arg1) (x) * m_arg2;
}
#if defined(FLATTEN) && defined(__GNUC__)
// See above.
__attribute__ ((flatten))
#endif
GeoTrf::Transform3D PostMult::operator () (const GeoGenfun::Argument & x) const
{
return (*m_arg1) (x) * m_arg2;
......@@ -202,6 +222,10 @@ namespace GeoXF
delete m_function;
}
#if defined(FLATTEN) && defined(__GNUC__)
// See above.
__attribute__ ((flatten))
#endif
GeoTrf::Transform3D Pow::operator() (double x) const
{
//
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment