ROOT Version:_ 6.24/02
Platform:Linux/Fedora 34
Compiler: gcc version 11.3.1 20220421
I get the following error when I enable multithreading with ROOT::EnableImplicitMT(); in the attached code (2.4 KB).
RDataFrame::Run: event loop was interrupted
Error in <TRint::HandleTermInput()>: std::runtime_error caught: Cannot fill histogram with values in containers of different sizes.
Without multithreading the code works perfectly and produces output that is exactly same with my earlier approach using TChain.
Is the code contained in your functions thread safe?
RDataFrame invokes it from different threads and any usage of global variables in that context would lead to data races.
Frankly speaking, I’m not sure how to check whether the code/functions is/are thread safe.
The code that I have been using is attached in the previous post. Can you please take a look at it?
As I was hinting, your code is not thread safe. You are manipulating global variables inside the functions that Define invokes. I did not look at the details of your code, but I see two rough options:
I am certainly benefited by RDataFrame. However, there is one thing which I don’t quite understand - The number of cores and the amount of time with multi-threading doesn’t really scale one-to-one. I am sorting the data on a machine with 32 cores. Then shouldn’t the sorting be 32 times faster than when the data is sorted using a single core? While in the present case I gain only by a factor of ~ 2.5 in time.