Skip to content
Snippets Groups Projects
Commit 0ff7234a authored by Christos Anastopoulos's avatar Christos Anastopoulos
Browse files

inline_hints : tidy and move more clients

parent 464bfa2e
No related branches found
No related tags found
No related merge requests found
......@@ -24,19 +24,19 @@
* - The always_inline attibute disables inlining heuristics and inlining is
* always attempted regardless of optimization level.
*
* These can and will affect debug and optimised builds
* These can and will affect debug and optimized builds
*
* As an example :
* - We use flatten quite a bit to avoid out of line eigen calls
* - We use always_inline for helpers containing code that was repeated in
* different methods and we factorized it in a separate function.
* But we want to keep the semantics of the original
* But we want to keep the semantics of the original code
* - We use noinline to avoid the compiler being too smart
*
* More or less all these assume that given a context one knows something more
* than the compiler. Inlining (the optimization) can improve or worsen the
* performance, it can reduce or increase the code size. Check carefully
* before deciding and confirm.
* performance, it can reduce or increase the code size etc
* Check carefully before deciding and confirm.
*
*
*/
......@@ -44,22 +44,15 @@
#ifndef CXXUTILS_ALWAYS_INLINE_H
#define CXXUTILS_ALWAYS_INLINE_H
#if (defined(__GNUC__) || defined(__clang__))
#if defined(__GNUC__)
#define ATH_FLATTEN [[gnu::flatten]]
#else
#define ATH_FLATTEN
#endif
#if (defined(__GNUC__) || defined(__clang__))
#define ATH_ALWAYS_INLINE [[gnu::always_inline]] inline
#else
#define ATH_ALWAYS_INLINE inline
#endif
#if (defined(__GNUC__) || defined(__clang__))
#define ATH_NOINLINE [[gnu::noinline]]
#else
#define ATH_FLATTEN
#define ATH_ALWAYS_INLINE inline
#define ATH_NOINLINE
#endif
#endif
......@@ -14,6 +14,8 @@
#include <cmath>
#include <iostream>
#include "CxxUtils/inline_hints.h"
namespace {
/* In Gaudi Units
* Units.tesla
......@@ -26,14 +28,12 @@ namespace {
constexpr double defaultB = 0.1 * Gaudi::Units::gauss;
}
#if 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.
[[gnu::flatten]]
#endif
ATH_FLATTEN
void
MagField::AtlasFieldCache::getField(const double* ATH_RESTRICT xyz,
double* ATH_RESTRICT bxyz,
......
......@@ -2,6 +2,7 @@
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/
#include "CxxUtils/inline_hints.h"
namespace Trk {
inline bool
......@@ -263,20 +264,16 @@ Surface::associateLayer(const Layer& lay)
m_associatedLayer = (&lay);
}
#if defined(__GNUC__)
[[gnu::flatten]]
// Avoid out-of-line-eigen calls
#endif
ATH_FLATTEN
inline Amg::Transform3D
Surface::inverseTransformHelper() const
{
return transform().inverse();
}
#if defined(__GNUC__)
[[gnu::flatten]]
// Avoid out-of-line-eigen calls
#endif
ATH_FLATTEN
inline Amg::Vector3D
Surface::inverseTransformMultHelper(const Amg::Vector3D& pos) const
{
......
......@@ -40,13 +40,13 @@ Trk::PerigeeSurface::PerigeeSurface(const Amg::Transform3D& tTransform)
std::make_unique<Transforms>(tTransform, tTransform.translation(), s_xAxis);
}
#if defined(FLATTEN) && defined(__GNUC__)
#if defined(FLATTEN)
// We compile this function 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.
[[gnu::flatten]]
ATH_FLATTEN
#endif
Trk::PerigeeSurface::PerigeeSurface(const PerigeeSurface& pesf)
: Surface(pesf)
......@@ -160,14 +160,12 @@ Trk::PerigeeSurface::localToGlobal(const Trk::LocalParameters& locpars) const
return {0., 0., locpars[Trk::z0] + (center().z())};
}
#if defined(__GNUC__)
// We compile this function 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.
[[gnu::flatten]]
#endif
ATH_FLATTEN
// true local to global method/
void
Trk::PerigeeSurface::localToGlobal(const Amg::Vector2D& locpos,
......
......@@ -35,10 +35,8 @@ dummyCacheElement(GsfMaterial::Combined& elem)
elem.deltaCovariances[0] = AmgSymMatrix(5)::Zero();
}
#if defined(__GNUC__)
[[gnu::flatten]]
// Avoid out-of-line Eigen calls
#endif
ATH_FLATTEN
inline void
updateCacheElement(GsfMaterial::Combined& update,
size_t index,
......
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