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

MagFieldElements: Optimize some functions, even in dbg builds.

The function AtlasFieldCache::getField makes heavy use of Eigen and
runs extremely slowly in dbg builds.  Adjust to compile this function with
optimization, even in dbg builds.  For the MuonCombinedConfig unit test,
this results in a 20% speedup in the dbg build.
parent 3ed7b411
No related merge requests found
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
# Declare the package name:
atlas_subdir( MagFieldElements )
......@@ -18,3 +18,16 @@ atlas_add_library( MagFieldElements
atlas_add_test( BFieldExample_test
SOURCES test/BFieldExample_test.cxx
LINK_LIBRARIES MagFieldElements)
# 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/AtlasFieldCache.cxx
PROPERTIES
COMPILE_FLAGS "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}"
COMPILE_DEFINITIONS "FLATTEN" )
endif()
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/
//
......@@ -14,6 +14,14 @@
#include <cmath>
#include <iostream>
#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
void
MagField::AtlasFieldCache::getField(const double* ATH_RESTRICT xyz,
double* ATH_RESTRICT bxyz,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment