Skip to content

Commit

Permalink
refactor!: remove ThreadPoolParam
Browse files Browse the repository at this point in the history
  • Loading branch information
c-dilks committed Sep 25, 2024
1 parent 5b9d51b commit 289adee
Show file tree
Hide file tree
Showing 46 changed files with 71 additions and 156 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -408,10 +408,10 @@ jobs:
- name: benchmark algorithms
if: ${{ matrix.id == 'coverage' }} # use the coverage job's GITHUB_STEP_SUMMARY
run: |
for suite in single_threaded memoize threadpool; do
for suite in single_threaded memoize; do
meson test --benchmark --suite $suite -C iguana_build | tee benchmark_$suite.txt
done
iguana_src/.github/make-benchmark-table.rb benchmark_{single_threaded,memoize,threadpool}.txt | xargs -0 -I{} echo {} >> $GITHUB_STEP_SUMMARY
iguana_src/.github/make-benchmark-table.rb benchmark_{single_threaded,memoize}.txt | xargs -0 -I{} echo {} >> $GITHUB_STEP_SUMMARY
### coverage
- name: coverage
if: ${{ matrix.id == 'coverage' }}
Expand Down
1 change: 0 additions & 1 deletion doc/gen/Doxyfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,6 @@ ALIASES += config_param{3|}="<tr><td>`\1`</td><td>`\2`</td><td>\3</td></tr>"
# action functions
ALIASES += action_function{1}="\xrefitem action \"Function Type\" \"List of all Action Functions\" \1 \brief **Action Function:** "
ALIASES += when_to_call{1}="@note This function should be called **\1**"
ALIASES += thread_id_desc="the thread index, if using `GlobalConcurrencyModel == \"threadpool\"`; otherwise, just use the default value"
# examples
ALIASES += begin_doc_example{1}="@addtogroup examples_\1^^@{"
ALIASES += end_doc_example="@}"
Expand Down
5 changes: 2 additions & 3 deletions examples/iguana_ex_fortran_01_action_functions.f
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,11 @@ program iguana_ex_fortran_01_action_functions
c before using the Z-vertext filter, we must "prepare" the
c algorithm's configuration for this event; the resulting
c 'key_vz_filter' must be passed to the action function;
c we leave the `thread_id` at zero (since we don't need it)
call iguana_clas12_zvertexfilter_prepareevent(
& algo_vz_filter, runnum(1), 0, key_vz_filter)
& algo_vz_filter, runnum(1), key_vz_filter)
c similarly for the inclusive kinematics algorithm
call iguana_physics_inclusivekinematics_prepareevent(
& algo_inc_kin, runnum(1), 0, key_inc_kin)
& algo_inc_kin, runnum(1), key_inc_kin)
c call iguana filters
c - the `logical` variable `accept` must be initialized to
Expand Down
3 changes: 1 addition & 2 deletions src/iguana/algorithms/Algorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ namespace iguana {

/// @brief Run this algorithm for an event.
/// @param banks the list of banks to process
/// @param thread_id @thread_id_desc
virtual void Run(hipo::banklist& banks, concurrent_key_t const thread_id = 0) const = 0;
virtual void Run(hipo::banklist& banks) const = 0;

/// @brief Finalize this algorithm after all events are processed.
virtual void Stop() = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/iguana/algorithms/AlgorithmSequence.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ namespace iguana {
for(auto const& algo : m_sequence)
algo->Start(banks);
}
void AlgorithmSequence::Run(hipo::banklist& banks, concurrent_key_t const thread_id) const
void AlgorithmSequence::Run(hipo::banklist& banks) const
{
for(auto const& algo : m_sequence)
algo->Run(banks, thread_id);
algo->Run(banks);
}
void AlgorithmSequence::Stop()
{
Expand Down
2 changes: 1 addition & 1 deletion src/iguana/algorithms/AlgorithmSequence.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace iguana {
public:

void Start(hipo::banklist& banks) override;
void Run(hipo::banklist& banks, concurrent_key_t const thread_id = 0) const override;
void Run(hipo::banklist& banks) const override;
void Stop() override;

/// Create and add an algorithm to the sequence, by name.
Expand Down
2 changes: 1 addition & 1 deletion src/iguana/algorithms/Validator.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace iguana {
virtual ~Validator() {}

void Start(hipo::banklist& banks) override{};
void Run(hipo::banklist& banks, concurrent_key_t const thread_id = 0) const override{};
void Run(hipo::banklist& banks) const override{};
void Stop() override{};

/// Set this validator's output directory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace iguana::clas12 {
}


void EventBuilderFilter::Run(hipo::banklist& banks, concurrent_key_t const thread_id) const
void EventBuilderFilter::Run(hipo::banklist& banks) const
{

// get the banks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace iguana::clas12 {
public:

void Start(hipo::banklist& banks) override;
void Run(hipo::banklist& banks, concurrent_key_t const thread_id = 0) const override;
void Run(hipo::banklist& banks) const override;
void Stop() override;

/// @action_function{scalar filter} checks if the PDG `pid` is a part of the list of user-specified PDGs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace iguana::clas12 {
electron_mass = particle::mass.at(particle::electron);
}

void FTEnergyCorrection::Run(hipo::banklist& banks, concurrent_key_t const thread_id) const {
void FTEnergyCorrection::Run(hipo::banklist& banks) const {
auto& ftParticleBank = GetBank(banks, b_ft_particle, "RECFT::Particle");
ShowBank(ftParticleBank, Logger::Header("INPUT FT PARTICLES"));
for(auto const& row : ftParticleBank.getRowList()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace iguana::clas12 {
public:

void Start(hipo::banklist& banks) override;
void Run(hipo::banklist& banks, concurrent_key_t const thread_id = 0) const override;
void Run(hipo::banklist& banks) const override;
void Stop() override;

/// @action_function{scalar transformer}
Expand Down
2 changes: 1 addition & 1 deletion src/iguana/algorithms/clas12/FiducialFilter/Algorithm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace iguana::clas12 {

}

void FiducialFilter::Run(hipo::banklist& banks, concurrent_key_t const thread_id) const {
void FiducialFilter::Run(hipo::banklist& banks) const {
// get the banks
auto& particleBank = GetBank(banks, b_particle, "REC::Particle");
auto& trajBank = GetBank(banks, b_traj, "REC::Traj");
Expand Down
2 changes: 1 addition & 1 deletion src/iguana/algorithms/clas12/FiducialFilter/Algorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace iguana::clas12 {
public:

void Start(hipo::banklist& banks) override;
void Run(hipo::banklist& banks, concurrent_key_t const thread_id = 0) const override;
void Run(hipo::banklist& banks) const override;
void Stop() override;

/// structure to hold `REC::Traj` data
Expand Down
4 changes: 2 additions & 2 deletions src/iguana/algorithms/clas12/FiducialFilter/Validator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ namespace iguana::clas12 {
}


void FiducialFilterValidator::Run(hipo::banklist& banks, concurrent_key_t const thread_id) const
void FiducialFilterValidator::Run(hipo::banklist& banks) const
{
// get the momenta before
auto& particle_bank = GetBank(banks, b_particle, "REC::Particle");
Expand All @@ -104,7 +104,7 @@ namespace iguana::clas12 {
}

// run the fiducial cuts
m_algo_seq->Run(banks, thread_id);
m_algo_seq->Run(banks);

// fill the plots
for(auto const& row : particle_bank.getRowList()) {
Expand Down
2 changes: 1 addition & 1 deletion src/iguana/algorithms/clas12/FiducialFilter/Validator.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace iguana::clas12 {
public:

void Start(hipo::banklist& banks) override;
void Run(hipo::banklist& banks, concurrent_key_t const thread_id = 0) const override;
void Run(hipo::banklist& banks) const override;
void Stop() override;

private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace iguana::clas12 {
}


void LorentzTransformer::Run(hipo::banklist& banks, concurrent_key_t const thread_id) const
void LorentzTransformer::Run(hipo::banklist& banks) const
{

auto& particleBank = GetBank(banks, b_particle, "REC::Particle");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace iguana::clas12 {
public:

void Start(hipo::banklist& banks) override;
void Run(hipo::banklist& banks, concurrent_key_t const thread_id = 0) const override;
void Run(hipo::banklist& banks) const override;
void Stop() override;

/// @action_function{scalar transformer} boost the 4-momentum @f$p=(p_x,p_y,p_z,E)@f$ along @f$\beta=(\beta_x, \beta_y, \beta_z)@f$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace iguana::clas12 {
}


void MomentumCorrection::Run(hipo::banklist& banks, concurrent_key_t const thread_id) const
void MomentumCorrection::Run(hipo::banklist& banks) const
{
auto& particleBank = GetBank(banks, b_particle, "REC::Particle");
auto& sectorBank = GetBank(banks, b_sector, "REC::Particle::Sector");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace iguana::clas12 {
public:

void Start(hipo::banklist& banks) override;
void Run(hipo::banklist& banks, concurrent_key_t const thread_id = 0) const override;
void Run(hipo::banklist& banks) const override;
void Stop() override;

/// @action_function{scalar transformer} Apply the momentum correction
Expand Down
4 changes: 2 additions & 2 deletions src/iguana/algorithms/clas12/MomentumCorrection/Validator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace iguana::clas12 {
}


void MomentumCorrectionValidator::Run(hipo::banklist& banks, concurrent_key_t const thread_id) const
void MomentumCorrectionValidator::Run(hipo::banklist& banks) const
{
// get the momenta before
auto& particle_bank = GetBank(banks, b_particle, "REC::Particle");
Expand All @@ -61,7 +61,7 @@ namespace iguana::clas12 {
particle_bank.getFloat("pz", row)));

// run the momentum corrections
m_algo_seq->Run(banks, thread_id);
m_algo_seq->Run(banks);

// lock the mutex, so we can mutate plots
std::scoped_lock<std::mutex> lock(m_mutex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace iguana::clas12 {
public:

void Start(hipo::banklist& banks) override;
void Run(hipo::banklist& banks, concurrent_key_t const thread_id = 0) const override;
void Run(hipo::banklist& banks) const override;
void Stop() override;

private:
Expand Down
2 changes: 1 addition & 1 deletion src/iguana/algorithms/clas12/PhotonGBTFilter/Algorithm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace iguana::clas12 {



void PhotonGBTFilter::Run(hipo::banklist& banks, concurrent_key_t const thread_id) const
void PhotonGBTFilter::Run(hipo::banklist& banks) const
{

auto& particleBank = GetBank(banks, b_particle, "REC::Particle");
Expand Down
2 changes: 1 addition & 1 deletion src/iguana/algorithms/clas12/PhotonGBTFilter/Algorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace iguana::clas12 {
public:

void Start(hipo::banklist& banks) override;
void Run(hipo::banklist& banks, concurrent_key_t const thread_id = 0) const override;
void Run(hipo::banklist& banks) const override;
void Stop() override;

/// **Method**: Applies forward detector cut using REC::Particle Theta
Expand Down
4 changes: 2 additions & 2 deletions src/iguana/algorithms/clas12/PhotonGBTFilter/Validator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace iguana::clas12 {
InitializeHistograms();
}

void PhotonGBTFilterValidator::Run(hipo::banklist& banks, concurrent_key_t const thread_id) const
void PhotonGBTFilterValidator::Run(hipo::banklist& banks) const
{
// get the particle bank
auto& particle_bank = GetBank(banks, b_particle, "REC::Particle");
Expand All @@ -45,7 +45,7 @@ namespace iguana::clas12 {
}

// run the photon filter
m_algo_seq->Run(banks, thread_id);
m_algo_seq->Run(banks);

std::vector<ROOT::Math::PxPyPzEVector> filtered_photons;
for(auto const& row : particle_bank.getRowList()) {
Expand Down
2 changes: 1 addition & 1 deletion src/iguana/algorithms/clas12/PhotonGBTFilter/Validator.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace iguana::clas12 {
public:

void Start(hipo::banklist& banks) override;
void Run(hipo::banklist& banks, concurrent_key_t const thread_id = 0) const override;
void Run(hipo::banklist& banks) const override;
void Stop() override;

private:
Expand Down
2 changes: 1 addition & 1 deletion src/iguana/algorithms/clas12/SectorFinder/Algorithm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace iguana::clas12 {
i_pindex = result_schema.getEntryOrder("pindex");
}

void SectorFinder::Run(hipo::banklist& banks, concurrent_key_t const thread_id) const
void SectorFinder::Run(hipo::banklist& banks) const
{
auto& particleBank = GetBank(banks, b_particle, "REC::Particle");
auto& resultBank = GetBank(banks, b_result, "REC::Particle::Sector");
Expand Down
2 changes: 1 addition & 1 deletion src/iguana/algorithms/clas12/SectorFinder/Algorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace iguana::clas12 {
public:

void Start(hipo::banklist& banks) override;
void Run(hipo::banklist& banks, concurrent_key_t const thread_id = 0) const override;
void Run(hipo::banklist& banks) const override;
void Stop() override;

/// @action_function{vector creator} for a given particle with index `pindex`, get its sector from a detector bank's list of `sectors` and `pindices` (both must be ordered in the same way);
Expand Down
4 changes: 2 additions & 2 deletions src/iguana/algorithms/clas12/SectorFinder/Validator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ namespace iguana::clas12 {

}

void SectorFinderValidator::Run(hipo::banklist& banks, concurrent_key_t const thread_id) const
void SectorFinderValidator::Run(hipo::banklist& banks) const
{

auto& particle_bank = GetBank(banks, b_particle, "REC::Particle");
auto& sector_bank = GetBank(banks, b_sector, "REC::Particle::Sector");
auto& cal_bank = GetBank(banks, b_cal, "REC::Calorimeter");


m_algo_seq->Run(banks, thread_id);
m_algo_seq->Run(banks);

// lock the mutex, so we can mutate plots
std::scoped_lock<std::mutex> lock(m_mutex);
Expand Down
2 changes: 1 addition & 1 deletion src/iguana/algorithms/clas12/SectorFinder/Validator.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace iguana::clas12 {
public:

void Start(hipo::banklist& banks) override;
void Run(hipo::banklist& banks, concurrent_key_t const thread_id = 0) const override;
void Run(hipo::banklist& banks) const override;
void Stop() override;

private:
Expand Down
3 changes: 0 additions & 3 deletions src/iguana/algorithms/clas12/ZVertexFilter/Action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ actions:
inputs:
- name: runnum
type: int
- name: thread_id
type: concurrent_key_t
cast: int
outputs:
- type: concurrent_key_t
cast: int
Expand Down
15 changes: 8 additions & 7 deletions src/iguana/algorithms/clas12/ZVertexFilter/Algorithm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace iguana::clas12 {
b_config = GetBankIndex(banks, "RUN::config");
}

void ZVertexFilter::Run(hipo::banklist& banks, concurrent_key_t const thread_id) const
void ZVertexFilter::Run(hipo::banklist& banks) const
{

// get the banks
Expand All @@ -28,7 +28,7 @@ namespace iguana::clas12 {
ShowBank(particleBank, Logger::Header("INPUT PARTICLES"));

// prepare the event, reloading configuration parameters, if necessary
auto key = PrepareEvent(configBank.getInt("run", 0), thread_id);
auto key = PrepareEvent(configBank.getInt("run", 0));

// filter the input bank for requested PDG code(s)
particleBank.getMutableRowList().filter([this, &key](auto bank, auto row) {
Expand All @@ -44,18 +44,19 @@ namespace iguana::clas12 {
ShowBank(particleBank, Logger::Header("OUTPUT PARTICLES"));
}

concurrent_key_t ZVertexFilter::PrepareEvent(int const runnum, concurrent_key_t thread_id) const {
m_log->Trace("calling PrepareEvent({}, {})", runnum, thread_id);
concurrent_key_t ZVertexFilter::PrepareEvent(int const runnum) const {
m_log->Trace("calling PrepareEvent({})", runnum);
if(o_runnum->NeedsHashing()) {
std::hash<int> hash_ftn;
auto hash_key = hash_ftn(runnum);
if(!o_runnum->HasKey(hash_key))
Reload(runnum, hash_key);
return hash_key;
} else {
if(o_runnum->IsEmpty() || o_runnum->Load(0) != runnum)
Reload(runnum, 0);
return 0;
}
if(o_runnum->IsEmpty() || o_runnum->Load(thread_id) != runnum)
Reload(runnum, thread_id);
return thread_id;
}

void ZVertexFilter::Reload(int const runnum, concurrent_key_t key) const {
Expand Down
5 changes: 2 additions & 3 deletions src/iguana/algorithms/clas12/ZVertexFilter/Algorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,14 @@ namespace iguana::clas12 {
public:

void Start(hipo::banklist& banks) override;
void Run(hipo::banklist& banks, concurrent_key_t const thread_id = 0) const override;
void Run(hipo::banklist& banks) const override;
void Stop() override;

/// @action_function{reload} prepare the event
/// @when_to_call{for each event}
/// @param runnum the run number
/// @param thread_id @thread_id_desc
/// @returns the key to be used in `::Filter`
concurrent_key_t PrepareEvent(int const runnum, concurrent_key_t thread_id = 0) const;
concurrent_key_t PrepareEvent(int const runnum) const;

/// @action_function{scalar filter} checks if the Z Vertex is within specified bounds if pid is one for which the filter should be applied to.;
/// Cuts applied to particles in FD or CD (ie not in FT).
Expand Down
4 changes: 2 additions & 2 deletions src/iguana/algorithms/clas12/ZVertexFilter/Validator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace iguana::clas12 {
}


void ZVertexFilterValidator::Run(hipo::banklist& banks, concurrent_key_t const thread_id) const
void ZVertexFilterValidator::Run(hipo::banklist& banks) const
{
auto& particle_bank = GetBank(banks, b_particle, "REC::Particle");

Expand All @@ -69,7 +69,7 @@ namespace iguana::clas12 {
}

// run the momentum corrections
m_algo_seq->Run(banks, thread_id);
m_algo_seq->Run(banks);

// fill the plots after
for(auto const& row : particle_bank.getRowList()) {
Expand Down
Loading

0 comments on commit 289adee

Please sign in to comment.