File indexing completed on 2024-10-17 22:59:07
0001 #include "Matrix.h"
0002
0003 #include <Debug.h>
0004
0005 #include "MkFitter.h"
0006
0007 #ifdef WITH_ROOT
0008 #include "TFile.h"
0009 #include "TTree.h"
0010 #include <mutex>
0011 #endif
0012
0013 #include "oneapi/tbb/parallel_for.h"
0014
0015 #include <iostream>
0016 #include <memory>
0017
0018 #if defined(USE_VTUNE_PAUSE)
0019 #include "ittnotify.h"
0020 #endif
0021
0022
0023
0024
0025
0026 #include "Pool.h"
0027 namespace {
0028 struct ExecutionContext {
0029 mkfit::Pool<mkfit::MkFitter> m_fitters;
0030
0031 void populate(int n_thr) { m_fitters.populate(n_thr - m_fitters.size()); }
0032 };
0033
0034 ExecutionContext g_exe_ctx;
0035 auto retfitr = [](mkfit::MkFitter* mkfp) { g_exe_ctx.m_fitters.ReturnToPool(mkfp); };
0036 }
0037
0038 namespace mkfit {
0039
0040 double runFittingTestPlex(Event& ev, std::vector<Track>& rectracks) {
0041 g_exe_ctx.populate(Config::numThreadsFinder);
0042 std::vector<Track>& simtracks = ev.simTracks_;
0043
0044 const int Nhits = Config::nLayers;
0045
0046
0047
0048
0049
0050
0051 int theEnd = simtracks.size();
0052 int count = (theEnd + NN - 1) / NN;
0053
0054 #ifdef USE_VTUNE_PAUSE
0055 __SSC_MARK(0x111);
0056 __itt_resume();
0057 #endif
0058
0059 double time = dtime();
0060
0061 tbb::parallel_for(tbb::blocked_range<int>(0, count, std::max(1, Config::numSeedsPerTask / NN)),
0062 [&](const tbb::blocked_range<int>& i) {
0063 std::unique_ptr<MkFitter, decltype(retfitr)> mkfp(g_exe_ctx.m_fitters.GetFromPool(), retfitr);
0064 mkfp->setNhits(Nhits);
0065 for (int it = i.begin(); it < i.end(); ++it) {
0066 int itrack = it * NN;
0067 int end = itrack + NN;
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081 mkfp->inputTracksForFit(simtracks, itrack, end);
0082
0083
0084
0085
0086 mkfp->fitTracksWithInterSlurp(ev.layerHits_, end - itrack);
0087
0088 mkfp->outputFittedTracks(rectracks, itrack, end);
0089 }
0090 });
0091
0092 time = dtime() - time;
0093
0094 #ifdef USE_VTUNE_PAUSE
0095 __itt_pause();
0096 __SSC_MARK(0x222);
0097 #endif
0098
0099 if (Config::fit_val)
0100 ev.validate();
0101
0102 return time;
0103 }
0104
0105 }