-
Notifications
You must be signed in to change notification settings - Fork 443
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MFT] Move static arrays to be initialized before the processing starts #10665
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @robincaron13
Thanks for taking care, but this not what I meant: moving the static array from the base class to the derived one will change nothing: it will still be allocated w/o the creation of the actual object, i.e. in any process which links to this library.
Instead, I would define in the TrackerConfig.h
using BinContainer = std::array<std::array<std::array<std::vector<Int_t>, constants::index_table::MaxRPhiBins>, (constants::mft::LayersNumber - 1)>, (constants::mft::LayersNumber - 1)>;
static std_unique_ptr<BinContainer> mBins;
static std_unique_ptr<BinContainer> mBinsS;
static initBinContainers() { // implementation can go to cxx file
if (!mBins) {
mBins = std::make_unique<BinContainer>();
initBins(mBins.get()); // init bins with static method. If not possible to do using static method, then make this method non-static and lock the code by mutex.
//
}
// same for mBinsS
}
In the TrackerSpec call this initBinContainers
before instantiating the trackers (e.g. in its init method (or in the beginning of updateTimeDependentParams) if this method can be static.
Otherwise, put the non-static method (protected by mutex) in the Tracker constructed.
Same for destroying arrays via mBins.reset()
: do this either in the Tracker destructor of the protecting the call with mutex or in the TrackerSpec destructor.
For the usage of the mutex see e.g. how the
static std::mutex sTGMutex; |
AliceO2/Detectors/Base/src/GeometryManager.cxx
Lines 37 to 48 in 816da25
std::mutex GeometryManager::sTGMutex; | |
//______________________________________________________________________ | |
Bool_t GeometryManager::getOriginalMatrix(const char* symname, TGeoHMatrix& m) | |
{ | |
m.Clear(); | |
if (!gGeoManager || !gGeoManager->IsClosed()) { | |
LOG(error) << "No active geometry or geometry not yet closed!"; | |
; | |
return kFALSE; | |
} | |
std::lock_guard<std::mutex> guard(sTGMutex); |
Hi @shahor02, Thanks a lot for your answer and your proposal. |
|
Hi @shahor02, Thanks for your answer. Some modifications are pushed according to your comments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @robincaron13
In general ok, but please see some comments below.
Detectors/ITSMFT/MFT/tracking/include/MFTTracking/TrackerConfig.h
Outdated
Show resolved
Hide resolved
Detectors/ITSMFT/MFT/tracking/include/MFTTracking/TrackerConfig.h
Outdated
Show resolved
Hide resolved
Hi @shahor02 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, looks good
To follow PR#10654, here the arrays are kept as static member and are moved to the tracker class to be initialized before the processing starts (not sure if it was what you were thinking @shahor02)