Commit eaba5f9a authored by Marco Clemencic's avatar Marco Clemencic
Browse files

Merge branch 'master' into dev/cmake

Updated to v23r2.
parents 66ca6393 0b2594e6
package Gaudi
version v23r1
version v23r2
branches doc cmt
use GaudiSys *
......
Package : Gaudi
Package manager : Marco Clemencic
================================ Gaudi v23r2 =================================
! 2012-03-15 - Marco Clemencic
- Fixed bug #92122: option '--printsequence' of gaudirun.py no longer works
Moved the call to the printsequence function from gaudirun.py to
gaudimain.run(), thus also fixing the possible configuration corruption due
to the use of the option.
================================ Gaudi v23r1 =================================
! 2012-02-22 - Marco Clemencic
- Modified gaudirun.py to be able to preload arbitrary libraries (option
......
......@@ -17,6 +17,7 @@ class gaudimain(object) :
if "GAUDIAPPVERSION" in os.environ:
appMgr.AppVersion = str(os.environ["GAUDIAPPVERSION"])
self.log = logging.getLogger(__name__)
self.printsequence = False
def setupParallelLogging( self ) :
# ---------------------------------------------------
......@@ -106,7 +107,11 @@ class gaudimain(object) :
log.error("Unknown file type '%s'. Must be any of %r.", ext, write.keys())
sys.exit(1)
def printsequence(self):
def _printsequence(self):
if not self.printsequence:
# No printing requested
return
def printAlgo( algName, appMgr, prefix = ' ') :
print prefix + algName
alg = appMgr.algorithm( algName.split( "/" )[ -1 ] )
......@@ -117,8 +122,7 @@ class gaudimain(object) :
elif prop.has_key( "DetectorList" ) :
subs = prop[ "DetectorList" ].value()
for i in subs : printAlgo( algName.split( "/" )[ -1 ] + i.strip( '"' ) + "Seq", appMgr, prefix + " ")
import GaudiPython
self.g = GaudiPython.AppMgr()
mp = self.g.properties()
print "\n ****************************** Algorithm Sequence **************************** \n"
for i in mp["TopAlg"].value(): printAlgo( i, self.g )
......@@ -144,6 +148,7 @@ class gaudimain(object) :
self.log.debug('-'*80)
sysStart = time()
self.g = GaudiPython.AppMgr()
self._printsequence()
runner = self.mainLoop or (lambda app, nevt: app.run(nevt))
statuscode = runner(self.g, self.g.EvtMax)
if hasattr(statuscode, "isSuccess"):
......
......@@ -195,9 +195,14 @@ if __name__ == "__main__":
c.printconfig(opts.old_opts, opts.all_opts)
if opts.output:
c.writeconfig(opts.output, opts.all_opts)
if opts.printsequence:
c.printsequence()
c.printsequence = opts.printsequence
if opts.printsequence:
if opts.ncpus:
logging.warning("--printsequence not supported with --ncpus: ignored")
elif opts.dry_run:
logging.warning("--printsequence not supported with --dry-run: ignored")
# re-enable the GaudiPython module
del sys.modules["GaudiPython"]
......
......@@ -4,6 +4,11 @@
# Description: standard and commonly used components
################################################################################
! 2012-04-19 - Marco Clemencic
- Added new signatures to HistogramSvc::Helper::act to absorb the change in the
return type of TH1::Add, TH1::Divide and TH1::Multiply.
See http://root.cern.ch/viewvc/trunk/hist/hist/inc/TH1D.h?r1=43732&r2=43802
============================ GaudiCommonSvc v1r1 =============================
! 2012-02-14 - Chris Jones
- Add a "TESVetoList" property to InputCopyStream, to allow certain locations
......
......@@ -106,6 +106,16 @@ protected:
return 0;
}
template <class R, class S, class T1, class T2>
static R* act(R* res,const S& b, Bool_t (T1::*pmf)(const T2*,Double_t), Double_t scale) {
T1 *h1 = Gaudi::getRepresentation<R,T1>(*res);
T1 *h2 = Gaudi::getRepresentation<R,T1>(b);
if ( h1 && h2 ) {
(h1->*pmf)(h2,scale);
return res;
}
return 0;
}
template <class R, class S, class T1, class T2>
static R* act(R* res,const S& b, void (T1::*pmf)(const T2*)) {
T1 *h1 = Gaudi::getRepresentation<R,T1>(*res);
T1 *h2 = Gaudi::getRepresentation<R,T1>(b);
......@@ -115,6 +125,16 @@ protected:
}
return 0;
}
template <class R, class S, class T1, class T2>
static R* act(R* res,const S& b, Bool_t (T1::*pmf)(const T2*)) {
T1 *h1 = Gaudi::getRepresentation<R,T1>(*res);
T1 *h2 = Gaudi::getRepresentation<R,T1>(b);
if ( h1 && h2 ) {
(h1->*pmf)(h2);
return res;
}
return 0;
}
};
......
......@@ -44,7 +44,8 @@ Selections/*.cpp
SvcInitLoop/*.cpp
StringKeys/*.cpp
StatusCodeSvc/*.cpp
testing/*.cpp )
testing/*.cpp
IntelProfiler/*.cpp )
gaudi_add_library(GaudiExamplesLib Lib/*.cpp
LINK_LIBRARIES GaudiGSLLib GaudiUtilsLib HepPDT ROOT
......
package GaudiExamples
version v23r1
version v23r2
use ROOT * LCG_Interfaces
use Reflex * LCG_Interfaces -no_auto_imports
......@@ -56,6 +56,7 @@ library GaudiExamples -import=Reflex -no_static \
StringKeys/*.cpp \
StatusCodeSvc/*.cpp \
testing/*.cpp \
IntelProfiler/*.cpp \
Dll/GaudiExamples*.cpp
......
Intel Profiler Example
================================================================================
Simple Gaudi algorithm to test [Intel Profiler][profiler].
[A video guide to installing profiler package][video].
[video]: http://youtu.be/h9tx00MGZTQ
CpuHungryAlg algorithms define 4 functions:
```cpp
double mysin();
double mycos();
double mytan();
double myatan();
```
, and we would like to profile them. Execution of this functions depends on
name of algorithm.
```cpp
StatusCode CpuHungryAlg::execute() {
m_nevent++;
double result = 0;
if (name() == "Alg1") {
result = mysin();
}else if (name() == "Alg2") {
result = mycos();
}else {
result = mytan();
}
return StatusCode::SUCCESS;
}
```
Run
--------------------------------------------------------------------------------
```sh
$> intelprofiler -o ~/profiler GaudiExamples/options/IntelProfiler.py
```
At the end you should see something like that:
```terminal
...
IntelProfilerAu... INFO Start profiling (event #1)
IntelProfilerAu... DEBUG Skip component TopSequence
IntelProfilerAu... DEBUG Start profiling component TopSequence SubSequence
IntelProfilerAu... DEBUG Start event type 2 for TopSequence SubSequence
IntelProfilerAu... DEBUG Pause event 2
IntelProfilerAu... DEBUG Start profiling component TopSequence SubSequence Alg1
IntelProfilerAu... DEBUG Start event type 3 for TopSequence SubSequence Alg1
IntelProfilerAu... DEBUG End event for Alg1
IntelProfilerAu... DEBUG Resume event for 2
IntelProfilerAu... DEBUG Skip component Alg2
IntelProfilerAu... DEBUG Resume
IntelProfilerAu... DEBUG Pause event 2
IntelProfilerAu... DEBUG Start profiling component TopSequence SubSequence Alg3
IntelProfilerAu... DEBUG Start event type 4 for TopSequence SubSequence Alg3
IntelProfilerAu... DEBUG End event for Alg3
IntelProfilerAu... DEBUG Resume event for 2
IntelProfilerAu... DEBUG End event for SubSequence
IntelProfilerAu... DEBUG Pause
IntelProfilerAu... DEBUG Skip component Alg4
IntelProfilerAu... DEBUG Pause
IntelProfilerAu... INFO Stop profiling (event #2)
ApplicationMgr INFO Application Manager Stopped successfully
EventLoopMgr INFO Histograms converted successfully according to request.
ApplicationMgr INFO Application Manager Finalized successfully
ApplicationMgr INFO Application Manager Terminated successfully
Using result path `/data/amazurov/Amplifier/IntelProfilingExample/r050hs`
```
, where ``Using result path `/data/amazurov/Amplifier/IntelProfilingExample/r050hs` ``
is our profiling database.
Analyze
--------------------------------------------------------------------------------
### GUI
```sh
$> amplxe-gui ~/profiler/r000hs
```
### Command line
#### Hot spots report:
```sh
amplxe-cl -report hotspots -r ~/profiler/r000hs
```
If options file looks like this:
```python
#!/usr/bin/env gaudirun.py
from Gaudi.Configuration import *
from Configurables import IntelProfilerAuditor, CpuHungryAlg
MessageSvc().OutputLevel = INFO
alg1 = CpuHungryAlg("Alg1")
alg2 = CpuHungryAlg("Alg2")
alg3 = CpuHungryAlg("Alg3")
alg4 = CpuHungryAlg("Alg4")
alg1.Loops = alg2.Loops = alg3.Loops = alg4.Loops = 5000000
subtop = Sequencer('SubSequence', Members = [alg1, alg2, alg3], StopOverride = True )
top = Sequencer('TopSequence', Members = [subtop, alg4], StopOverride = True )
profiler = IntelProfilerAuditor()
profiler.OutputLevel = DEBUG
profiler.StartFromEventN = 1
profiler.StopAtEventN = 2
profiler.ComponentsForTaskTypes = []
profiler.IncludeAlgorithms = ["SubSequence"]
profiler.ExcludeAlgorithms = ["Alg2"]
AuditorSvc().Auditors += [profiler]
ApplicationMgr( EvtMax = 3,
EvtSel = 'NONE',
HistogramPersistency = 'NONE',
TopAlg = [top],
AuditAlgorithms=True)
```
, as a result we can see the following:
```terminal
Function Module CPU Time
CpuHungryAlg::mysin libIntelProfilerExample.so 0.410
CpuHungryAlg::myatan libIntelProfilerExample.so 0.380
CpuHungryAlg::mytan libIntelProfilerExample.so 0.370
CpuHungryAlg::mycos libIntelProfilerExample.so 0.250
[Import thunk tan] libIntelProfilerExample.so 0.010
```
#### Report by algorithm chain:
```sh
$> amplxe-cl -report hotspots -r ~/profiler/r000hs --group-by task
```
Result:
```
Task Type CPU Time
TopSequence SubSequence Alg3 0.759
TopSequence SubSequence Alg1 0.410
TopSequence SubSequence 0.250
```
#### Report by algorithm chain with function's name:
```sh
$> amplxe-cl -report hotspots -r ~/profiler/r000hs --group-by task-function
```
Result:
```terminal
Function Task Type CPU Time
CpuHungryAlg::mysin TopSequence SubSequence Alg1 0.410
CpuHungryAlg::myatan TopSequence SubSequence Alg3 0.380
CpuHungryAlg::mytan TopSequence SubSequence Alg3 0.370
CpuHungryAlg::mycos TopSequence SubSequence 0.250
[Import thunk tan] TopSequence SubSequence Alg3 0.010
```
[profiler]: https://github.com/mazurov/IntelProfiler
\ No newline at end of file
Package GaudiExamples
Package manager : Marco Clemencic
============================ GaudiExamples v23r2 =============================
! 2012-02-24 - Sasha Mazurov
- Patch #5210: add example for IntelProfiler
(see doc/intelprofiler.md)
============================ GaudiExamples v23r1 =============================
! 2012-02-27 - Marco Clemencic
- Fixed glitches in the Google Profiling tests
......
#!/usr/bin/env gaudirun.py
from Gaudi.Configuration import *
from Configurables import IntelProfilerAuditor, CpuHungryAlg
MessageSvc().OutputLevel = INFO
alg1 = CpuHungryAlg("Alg1")
alg2 = CpuHungryAlg("Alg2")
alg3 = CpuHungryAlg("Alg3")
alg4 = CpuHungryAlg("Alg4")
alg1.Loops = alg2.Loops = alg3.Loops = alg4.Loops = 5000000
subtop = Sequencer('SubSequence', Members = [alg1, alg2, alg3], StopOverride = True )
top = Sequencer('TopSequence', Members = [subtop, alg4], StopOverride = True )
profiler = IntelProfilerAuditor()
profiler.OutputLevel = DEBUG
profiler.StartFromEventN = 1
profiler.StopAtEventN = 2
profiler.ComponentsForTaskTypes = []
profiler.IncludeAlgorithms = ["SubSequence"]
profiler.ExcludeAlgorithms = ["Alg2"]
AuditorSvc().Auditors += [profiler]
ApplicationMgr( EvtMax = 3,
EvtSel = 'NONE',
HistogramPersistency = 'NONE',
TopAlg = [top],
AuditAlgorithms=True)
// # Include files
// Standart:
#include <unistd.h>
#include <math.h>
// Gaudi:
#include "GaudiAlg/GaudiAlgorithm.h"
#include "GaudiKernel/AlgFactory.h"
/// Algorithm which consume a lot of CPU.
///
/// Author: Alexander Mazurov (alexander.mazurov@gmail.com)
class CpuHungryAlg: public GaudiAlgorithm {
public:
/// Standard constructor
CpuHungryAlg(const std::string& name, ISvcLocator* pSvcLocator);
/// ... and desctructor
virtual ~CpuHungryAlg(); ///< Destructor
virtual StatusCode initialize(); ///< Algorithm initialization
virtual StatusCode execute (); ///< Algorithm execution
virtual StatusCode finalize (); ///< Algorithm finalization
private:
double mysin();
double mycos();
double mytan();
double myatan();
private:
long m_loops;
int m_nevent;
};
// Register algorithm
DECLARE_ALGORITHM_FACTORY(CpuHungryAlg)
CpuHungryAlg::CpuHungryAlg(const std::string& name, ISvcLocator* pSvcLocator)
: GaudiAlgorithm(name, pSvcLocator),m_nevent(0)
{
declareProperty("Loops", m_loops = 1000000);
}
CpuHungryAlg::~CpuHungryAlg() {}
/// Initialization.
StatusCode CpuHungryAlg::initialize() {
StatusCode sc = GaudiAlgorithm::initialize(); // must be executed first
if ( sc.isFailure() ) return sc; // error printed already by GaudiAlgorithm
if ( msgLevel(MSG::DEBUG) ) debug() << "==> Initialize" << endmsg;
return StatusCode::SUCCESS;
}
/// Execute.
double CpuHungryAlg::mysin() {
double result = 0;
for(long i=0; i <= m_loops; ++i) {
result += sin(i);
}
return result;
}
double CpuHungryAlg::mycos() {
double result = 0;
for(long i=0; i<=m_loops; ++i) {
result += cos(i);
}
return result;
}
double CpuHungryAlg::mytan() {
double result = 0;
for(long i=0; i<=m_loops; ++i) {
result += tan(i);
}
result += myatan();
return result;
}
double CpuHungryAlg::myatan() {
double result = 0;
for(long i=0; i<=m_loops; ++i) {
result += tan(i);
}
return result;
}
StatusCode CpuHungryAlg::execute() {
m_nevent++;
double result = 0;
if (name() == "Alg1") {
result = mysin();
}else if (name() == "Alg2") {
result = mycos();
}else {
result = mytan();
}
return StatusCode::SUCCESS;
}
/// Finalize
StatusCode CpuHungryAlg::finalize() {
if ( msgLevel(MSG::DEBUG) ) debug() << "==> Finalize" << endmsg;
return GaudiAlgorithm::finalize(); // must be called after all other actions
}
// ============================================================================
Package : GaudiKernel
Package manager : Marco Clemencic
! 2012-03-26 - Marco Clemencic
- Added missing __init__.py in python/GaudiKernel
============================= GaudiKernel v28r1 ==============================
! 2012-02-13 - Marco Clemencic
- Fixed compatibility problem with Python 2.7.
......
......@@ -10,6 +10,28 @@ find_package(PythonLibs)
find_package(unwind)
find_package(tcmalloc)
#---------------------------------------------------------------------------
# Hack the VTune detection
if(NOT VTune_FOUND)
set(VTune_version 2011)
set(VTune_home /afs/cern.ch/sw/IntelSoftware/linux/${CMAKE_HOST_SYSTEM_PROCESSOR}/xe${VTune_version}/vtune_amplifier_xe_${VTune_version})
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
set(VTune_LIBRARY_DIR_HINT ${VTune_home}/lib64)
else()
set(VTune_LIBRARY_DIR_HINT ${VTune_home}/lib32)
endif()
set(VTune_INCLUDE_DIR_HINT ${VTune_home}/include)
find_library(VTune_LIBRARIES ittnotify HINTS ${VTune_LIBRARY_DIR_HINT})
find_path(VTune_INCLUDE_DIRS ittnotify.h HINTS ${VTune_INCLUDE_DIR_HINT})
if(VTune_LIBRARIES AND VTune_INCLUDE_DIRS)
set(VTune_FOUND ${VTune_LIBRARIES} CACHE INTERNAL "")
message(STATUS "Found VTune: ${VTune_LIBRARIES}")
endif()
endif()
#---------------------------------------------------------------------------
#---Libraries---------------------------------------------------------------
include_directories(src/component)
gaudi_add_module(GaudiProfiling component/*.cpp
......@@ -18,6 +40,13 @@ gaudi_add_module(GaudiProfiling component/*.cpp
gaudi_add_module(GaudiGoogleProfiling component/google/*.cpp
LINK_LIBRARIES GaudiKernel GaudiAlgLib z
INCLUDE_DIRS tcmalloc)
if(VTune_FOUND)
gaudi_add_module(IntelProfiler component/intel/*.cpp
LINK_LIBRARIES ${VTune_LIBRARIES} GaudiKernel
INCLUDE_DIRS ${VTune_INCLUDE_DIRS})
else()
message(WARNING "VTune libraries not found, the module IntelProfiler is disabled")
endif()
# Special handling of unresorlved symbols in GaudiGoogleProfiling.
# The profilers need to have libtcmalloc.so or libprofiler.so pre-loaded to
# work, so it's better if the symbols stay undefined in case somebody tries to
......
#!/bin/sh
if [ -d "$VTUNE_HOME" ] ; then
echo have-vtune
else
echo not-have-vtune
fi
# =============================================================================
package GaudiProfiling
version v1r3
version v1r4
# ============== structure ====================================================
branches GaudiProfiling src cmt doc data python scripts
......@@ -13,12 +13,16 @@ use ROOT v* LCG_Interfaces
use Boost v* LCG_Interfaces # Boost also used to bind cpp to python
# ============== constituents =================================================
library GaudiProfiling component/*.cpp -no_static
library GaudiGoogleProfiling component/google/*.cpp -import=GaudiAlg -import=tcmalloc -no_static
application GaudiGenProfilingHtml app/pfm_gen_analysis.cpp
library GaudiGoogleProfiling component/google/*.cpp -import=GaudiAlg -import=tcmalloc -no_static
library IntelProfiler component/intel/*.cpp -no_static
# ============== patterns =====================================================
apply_pattern component_library library="GaudiProfiling"
apply_pattern component_library library="GaudiGoogleProfiling"
apply_pattern component_library library="IntelProfiler"
apply_pattern install_python_modules
apply_pattern install_scripts
......@@ -27,6 +31,42 @@ macro_append GaudiProfiling_linkopts " -ldl " target-winxp ""
# ============== private ======================================================
private
#==== LCG_Interfaces/VTune - Begin
# This part should be moved to a VTune LCG_Interfaces package
macro VTune_config_version "2011"
macro VTune_native_version "$(VTune_config_version)"
macro Intel_base "/afs/cern.ch/sw/IntelSoftware/linux/x86_64" \
target-i686 "/afs/cern.ch/sw/IntelSoftware/linux/ia32"
macro VTune_home "$(Intel_base)/xe$(VTune_native_version)/vtune_amplifier_xe_$(VTune_config_version)"
set VTUNE_HOME "$(VTune_home)"
#include_path none
#include_dirs $(VTune_home)/include
macro VTune_linkopts "$(VTune_home)/$(unixdirname)/libittnotify.a"
macro VTune_cppflags "-I$(VTune_home)/include"
# Check if the VTune directory is present and set the tag have-vtune accordingly
# Note: we do not have VTune for i686.
macro have_vtune "not-have-vtune" target-x86_64&target-linux `$(GaudiProfiling_root)/cmt/check_vtune`
apply_tag $(have_vtune)
#==== LCG_Interfaces/VTune - End
# Keep the IntelProfiler targets only if we do have VTune.
macro_remove constituents "IntelProfilerConfDbMerge" have-vtune ""
macro_remove constituents "IntelProfilerConf" have-vtune ""
macro_remove constituents "IntelProfilerMergeMap" have-vtune ""
macro_remove constituents "IntelProfilerRootMap" have-vtune ""
macro_remove constituents "IntelProfiler" have-vtune ""
macro_remove GaudiProfiling_python_init_dependencies "IntelProfilerConf" \
have-vtune ""
macro_remove zip_GaudiProfiling_python_modules_dependencies "IntelProfilerConfDbMerge" \
have-vtune ""
macro_append use_includes " $(VTune_cppflags) "
macro_append IntelProfiler_use_linkopts " $(VTune_linkopts) "
use libunwind v* LCG_Interfaces