9 #include "FairRootManager.h"
10 #include "tbb/tick_count.h"
12 #include "tbb/parallel_for.h"
13 #include "tbb/parallel_invoke.h"
14 #include "tbb/spin_mutex.h"
16 #include "tbb/task_scheduler_init.h"
17 #include "tbb/task_scheduler_observer.h"
37 on_scheduler_entry(
bool Is_worker);
39 on_scheduler_exit(
bool Is_worker);
44 for (
int i = 0;
i < 8;
i++) {
54 #define handle_error_en(en, msg) \
62 pthread_t I = pthread_self();
63 spin_mutex::scoped_lock lock;
78 CPU_SET(cpuId, &cpuset);
80 s = pthread_setaffinity_np(thread,
sizeof(cpu_set_t), &cpuset);
82 cout <<
" pthread_setaffinity_np " << endl;
90 pthread_t I = pthread_self();
91 cout <<
"Thread with number " << I <<
" was ended " << --
threads_counter;
98 std::vector<std::vector<CbmRichHoughHit>>
fData;
102 const std::vector<std::vector<CbmRichHoughHit>>& data) {
109 for (
int i = 0;
i < fData.size();
i++) {
120 for (
int i = 0;
i < kMAX_NOF_THREADS;
i++) {
132 cout <<
"InitStatus CbmRichParallelQa::Init()" << endl;
134 FairRootManager* ioman = FairRootManager::Instance();
136 Fatal(
"CbmRichParallelQa::Init",
"RootManager not instantised!");
139 fRichHits = (TClonesArray*) ioman->GetObject(
"RichHit");
140 if (NULL == fRichHits) {
141 Fatal(
"CbmRichParallelQa::Init",
"No RichHit array!");
144 fRichRings = (TClonesArray*) ioman->GetObject(
"RichRing");
145 if (NULL == fRichRings) {
146 Fatal(
"CbmRichParallelQa::Init",
"No RichRing array!");
149 for (
int i = 0;
i < kMAX_NOF_THREADS;
i++) {
162 cout <<
"-I- Read event " << fEventNumber << endl;
163 std::vector<CbmRichHoughHit> data;
165 const Int_t nhits = fRichHits->GetEntriesFast();
167 cout <<
"-E- CbmRichRingFinderHough::DoFind:No hits in this event." << endl;
172 for (Int_t iHit = 0; iHit < nhits; iHit++) {
180 tempPoint.fId = iHit;
182 data.push_back(tempPoint);
186 fData.push_back(data);
188 if (fEventNumber == fNofEvents) {
189 cout <<
"-I- NofTasks = " << fNofTasks << endl;
193 tbb::task_scheduler_init init(fNofTasks);
199 tbb::tick_count t0 = tbb::tick_count::now();
200 task* root_task =
new (task::allocate_root()) empty_task;
201 root_task->set_ref_count(fNofTasks + 1);
204 for (
int iT = 0; iT < fNofTasks; iT++) {
205 list.push_back(*
new (root_task->allocate_child())
209 root_task->spawn_and_wait_for_all(list);
210 tbb::tick_count t1 = tbb::tick_count::now();
212 root_task->destroy(*root_task);
213 fExecTime += (t1 - t0).seconds();
214 cout << 1000. * fExecTime <<
" ms for " << fData.size() <<
" events" << endl;
215 cout << 1000. * fExecTime / (fData.size()) <<
" ms per event " << endl;
216 cout << fNofTasks * fData.size() / fExecTime <<
" events per sec" << endl;
219 fout.open(
"parallel.txt", std::ios_base::app);
220 fout << (int) (fNofTasks * fData.size() / fExecTime) <<
",";