6 #include <unordered_map>
23 std::unordered_map<unsigned int, bool> validationMap;
25 for (
auto memBlock : memBlocks)
27 validationMap[memBlock.m_Index] =
false;
30 auto memBinVect = m_Strategy->Optimize(memBlocks);
36 for (
auto memBin : memBinVect)
38 for (
auto block : memBin.m_MemBlocks)
42 if (!validationMap.at(block.m_Index))
44 validationMap.at(block.m_Index) =
true;
51 catch (
const std::out_of_range&)
58 for (
auto memBlock : memBlocks)
60 if (!validationMap.at(memBlock.m_Index))
67 for (
auto bin : memBinVect)
69 for (
unsigned int i = 0; i < bin.m_MemBlocks.size(); ++i)
71 auto Block1 = bin.m_MemBlocks[i];
72 auto B1Left = Block1.m_Offset;
73 auto B1Right = Block1.m_Offset + Block1.m_MemSize;
75 auto B1Top = Block1.m_StartOfLife;
76 auto B1Bottom = Block1.m_EndOfLife;
79 for (
unsigned int j = i + 1; j < bin.m_MemBlocks.size(); ++j)
81 auto Block2 = bin.m_MemBlocks[j];
82 auto B2Left = Block2.m_Offset;
83 auto B2Right = Block2.m_Offset + Block2.m_MemSize;
85 auto B2Top = Block2.m_StartOfLife;
86 auto B2Bottom = Block2.m_EndOfLife;
88 switch (m_Strategy->GetMemBlockStrategyType())
92 if (B1Top <= B2Bottom && B1Bottom >= B2Top)
95 "invalid as two Memblocks overlap on the Y axis for SingleAxisPacking");
103 if (B1Left <= B2Right && B1Right >= B2Left &&
104 B1Top <= B2Bottom && B1Bottom >= B2Top)
108 "two Memblocks overlap on both the X and Y axis");