|
17 | 17 |
|
18 | 18 | ******************************************************************************/ |
19 | 19 |
|
20 | | -#include <chrono> |
21 | | - |
22 | 20 | #include "algorithms/tearing/tearing.hpp" |
| 21 | +#include "algorithms/tearing/tearing_data.hpp" |
| 22 | +#include "algorithms/tearing/tearing_impl.hpp" |
| 23 | +#include "algorithms/tearing/tearing_v1.hpp" |
| 24 | +#include "sbg/directed_sbg.hpp" |
| 25 | +#include "util/debug.hpp" |
23 | 26 | #include "util/logger.hpp" |
| 27 | +#include "util/time_profiler.hpp" |
24 | 28 |
|
25 | 29 | namespace SBG { |
26 | 30 |
|
27 | 31 | namespace LIB { |
28 | 32 |
|
29 | 33 | //////////////////////////////////////////////////////////////////////////////// |
30 | | -// Auxiliary structures -------------------------------------------------------- |
| 34 | +// Tearing Algorithm --------------------------------------------------------------- |
31 | 35 | //////////////////////////////////////////////////////////////////////////////// |
32 | 36 |
|
33 | | -TearingData::TearingData(DSBG dsbg, PWMap rmap, PWMap tearIOMap) |
34 | | - : dsbg_(dsbg), rmap_(rmap), tearIOMap_(tearIOMap) {} |
35 | | - |
36 | | -const DSBG& TearingData::dsbg() const { return dsbg_; } |
37 | | -const PWMap& TearingData::rmap() const { return rmap_; } |
38 | | -const PWMap& TearingData::tearIOMap() const { return tearIOMap_; } |
39 | | - |
40 | | -//////////////////////////////////////////////////////////////////////////////// |
41 | | -// Tearing Algorithm Abstract Strategy Constructors -------------------------------- |
42 | | -//////////////////////////////////////////////////////////////////////////////// |
43 | | - |
44 | | -TearingStrategy::TearingStrategy() {} |
45 | | - |
46 | | -//////////////////////////////////////////////////////////////////////////////// |
47 | | -// Tearing Algorithm Interface ----------------------------------------------------- |
48 | | -//////////////////////////////////////////////////////////////////////////////// |
49 | | - |
50 | | -Tearing::Tearing(TearingStratPtr strat) : strategy_(std::move(strat)) {} |
| 37 | +Tearing::Tearing() : _impl() |
| 38 | +{ |
| 39 | + TearingKind kind = TEARING_IMPL.kind(); |
| 40 | + switch (kind) { |
| 41 | + case TearingKind::kTearingV1: { |
| 42 | + _impl = detail::TearingImpl{}; |
| 43 | + break; |
| 44 | + } |
| 45 | + |
| 46 | + default: { |
| 47 | + Util::ERROR("Unsupported Tearing implementation"); |
| 48 | + break; |
| 49 | + } |
| 50 | + } |
| 51 | +} |
51 | 52 |
|
52 | | -TearingData Tearing::calculate(const DSBG& dsbg) |
| 53 | +TearingData Tearing::calculate(const DirectedSBG& dsbg) |
53 | 54 | { |
54 | | - return strategy_->calculate(dsbg); |
| 55 | + Util::Internal::TimeProfiler profiler{"Total SCC execution time: "}; |
| 56 | + |
| 57 | + return std::visit([&](auto& a) { return a.calculate(dsbg); }, _impl); |
55 | 58 | } |
56 | 59 |
|
57 | 60 | } // namespace LIB |
|
0 commit comments