Skip to content

Commit

Permalink
speeds ups for CI
Browse files Browse the repository at this point in the history
  • Loading branch information
tevans committed Dec 13, 2024
1 parent 4fb165d commit 1a70ec8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
1 change: 1 addition & 0 deletions apps/AmpGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ template <class T> void generateSource(T& pdf, const std::string& sourceFile, Mi

double norm = 1;
if( normalise ){
INFO("Normalising PDF");
TRandom3 rnd(seed);
unsigned d_i = pdf.eventType().dim().first;
Generator<PhaseSpace> phsp(pdf.eventType());
Expand Down
2 changes: 1 addition & 1 deletion python/ampgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def make_ampgen_model( options_file, src = "" ) :
if src == "" : src=mkstemp( suffix='.cpp')[1]
lib=src.replace(".cpp",".so")
if not os.path.isfile(lib) :
cmd = ["AmpGen", options_file, f"--Output {src}", "--Normalise=0", "--CompilerWrapper::Verbose=1"]
cmd = ["AmpGen", options_file, f"--Output {src}", "--Normalise=0", "--CompilerWrapper::Verbose=1", "--AutoCompile=0"]
print( f"Running command {cmd}")
subprocess.run(cmd, check=True, text=True)
return AmpGenModel(os.path.abspath(lib))
22 changes: 10 additions & 12 deletions src/CoherentSum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <numeric>
#include <ratio>
#include <thread>
#include <csignal>

#include "AmpGen/CompiledExpression.h"
#include "AmpGen/ErrorPropagator.h"
Expand Down Expand Up @@ -45,6 +46,7 @@ CoherentSum::CoherentSum( const EventType& type, const MinuitParameterSet& mps,
, m_prefix (prefix)
, m_mps(&mps)
{
bool autocompile = NamedParameter<bool>("AutoCompile", true);
auto rules = AmplitudeRules::create(mps);
auto amplitudes = rules->getMatchingRules( m_eventType, prefix);
if( amplitudes.size() == 0 ){
Expand All @@ -56,19 +58,14 @@ CoherentSum::CoherentSum( const EventType& type, const MinuitParameterSet& mps,
size_t nThreads = NamedParameter<size_t> ("nCores" , std::thread::hardware_concurrency(), "Number of threads to use" );
ThreadPool tp(nThreads);
auto head_rules = rules->rulesForDecay(m_eventType.mother(), m_prefix);
/*
for( const auto& rule : head_rules )
{
auto indices = findIndices(m_matrixElements, rule.particle().decayDescriptor() );
INFO( rule.particle() << " [" << vectorToString(indices, " ") << "]" );
}
*/
for(size_t i = 0; i < m_matrixElements.size(); ++i){
tp.enqueue( [i, this, &mps, &amplitudes]() mutable {
auto task = [i, this, &mps, &amplitudes, autocompile]() mutable {
this->m_matrixElements[i] =
MatrixElement(amplitudes[i].first, amplitudes[i].second, mps, this->m_eventType.getEventFormat(), this->m_dbThis);
CompilerWrapper().compile( this->m_matrixElements[i], this->m_objCache);
} );
if(autocompile) CompilerWrapper().compile( this->m_matrixElements[i], this->m_objCache);
};
if( autocompile ) tp.enqueue( task );
else task();
}
}

Expand All @@ -77,10 +74,11 @@ void CoherentSum::prepare()
transferParameters();
ProfileClock clockEval;
for (auto& t : m_matrixElements ) {
if( not t.isReady() )
if( not t.isReady() ){
raise(SIGSEGV);
FATAL( t.decayDescriptor() << " not ready, fix me");
}
t.prepare();

if ( m_prepareCalls != 0 && !t.hasExternalsChanged() ) continue;
if ( m_events != nullptr ) m_cache.update(t);
m_integrator.updateCache(t);
Expand Down

0 comments on commit 1a70ec8

Please sign in to comment.