improved private arrays analysis
This commit is contained in:
@@ -311,7 +311,7 @@ static bool checkDimensionLength(const AccessingSet& array, const map<tuple<int,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void addPrivateArraysToLoop(LoopGraph* loop, const arrayAccessingIndexes& privates, set<SgStatement*>& insertedPrivates,
|
static int addPrivateArraysToLoop(LoopGraph* loop, const arrayAccessingIndexes& privates, set<SgStatement*>& insertedPrivates,
|
||||||
map<string, vector<Messages>>& SPF_messages,
|
map<string, vector<Messages>>& SPF_messages,
|
||||||
const map<tuple<int, string, string>, pair<DIST::Array*, DIST::ArrayAccessInfo*>>& declaredArrays)
|
const map<tuple<int, string, string>, pair<DIST::Array*, DIST::ArrayAccessInfo*>>& declaredArrays)
|
||||||
{
|
{
|
||||||
@@ -367,7 +367,7 @@ static void addPrivateArraysToLoop(LoopGraph* loop, const arrayAccessingIndexes&
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void findPrivateArrays(map<string, vector<LoopGraph*>>& loopGraph, map<FuncInfo*,
|
int findPrivateArrays(map<string, vector<LoopGraph*>>& loopGraph, map<FuncInfo*,
|
||||||
vector<SAPFOR::BasicBlock*>>& FullIR,
|
vector<SAPFOR::BasicBlock*>>& FullIR,
|
||||||
set<SgStatement*>& insertedPrivates,
|
set<SgStatement*>& insertedPrivates,
|
||||||
map<string, vector<Messages>>& SPF_messages,
|
map<string, vector<Messages>>& SPF_messages,
|
||||||
@@ -419,4 +419,26 @@ void findPrivateArrays(map<string, vector<LoopGraph*>>& loopGraph, map<FuncInfo*
|
|||||||
addPrivateArraysToLoop(loop, result[loop], insertedPrivates, SPF_messages, declaredArrays);
|
addPrivateArraysToLoop(loop, result[loop], insertedPrivates, SPF_messages, declaredArrays);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const auto& [loop, accesing] : result)
|
||||||
|
{
|
||||||
|
if (accesing.size())
|
||||||
|
{
|
||||||
|
__spf_print(1, "found for loop on line %d in file %s\n", loop->lineNum, loop->fileName.c_str());
|
||||||
|
for (const auto& [name, accesingSet] : accesing)
|
||||||
|
{
|
||||||
|
const auto& byDimention = accesingSet.GetElements();
|
||||||
|
__spf_print(1, " for array %s with dimention %d\n", name.c_str(), byDimention.size());
|
||||||
|
|
||||||
|
for (int z = 0; z < byDimention.size(); ++z)
|
||||||
|
{
|
||||||
|
__spf_print(1, " dim %d (start, step, tripCount):\n", z);
|
||||||
|
for (auto& elem : byDimention[z])
|
||||||
|
__spf_print(1, " [%ld %ld %ld]\n", elem.start, elem.step, elem.tripCount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return insertedPrivates.size();
|
||||||
}
|
}
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
#include "graph_loops.h"
|
#include "graph_loops.h"
|
||||||
#include "CFGraph/CFGraph.h"
|
#include "CFGraph/CFGraph.h"
|
||||||
|
|
||||||
void findPrivateArrays(std::map<std::string, std::vector<LoopGraph*>>& loopGraph, std::map<FuncInfo*,
|
int findPrivateArrays(std::map<std::string, std::vector<LoopGraph*>>& loopGraph, std::map<FuncInfo*,
|
||||||
std::vector<SAPFOR::BasicBlock*>>& FullIR, std::set<SgStatement*>& insertedPrivates,
|
std::vector<SAPFOR::BasicBlock*>>& FullIR, std::set<SgStatement*>& insertedPrivates,
|
||||||
std::map<std::string, std::vector<Messages>>& SPF_messages,
|
std::map<std::string, std::vector<Messages>>& SPF_messages,
|
||||||
const std::map<std::tuple<int, std::string, std::string>, std::pair<DIST::Array*, DIST::ArrayAccessInfo*>>& declaredArrays);
|
const std::map<std::tuple<int, std::string, std::string>, std::pair<DIST::Array*, DIST::ArrayAccessInfo*>>& declaredArrays);
|
||||||
|
|||||||
@@ -203,7 +203,7 @@ void AccessingSet::FindCoveredBy(const vector<ArrayDimension>& element, vector<v
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<vector<ArrayDimension>> AccessingSet::GetElements() const { return allElements; }
|
const vector<vector<ArrayDimension>>& AccessingSet::GetElements() const { return allElements; }
|
||||||
|
|
||||||
void AccessingSet::Insert(const vector<ArrayDimension>& element)
|
void AccessingSet::Insert(const vector<ArrayDimension>& element)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public:
|
|||||||
AccessingSet(std::vector<std::vector<ArrayDimension>> input) : allElements(input) {};
|
AccessingSet(std::vector<std::vector<ArrayDimension>> input) : allElements(input) {};
|
||||||
AccessingSet() {};
|
AccessingSet() {};
|
||||||
AccessingSet(const AccessingSet& a) { allElements = a.GetElements(); };
|
AccessingSet(const AccessingSet& a) { allElements = a.GetElements(); };
|
||||||
std::vector<std::vector<ArrayDimension>> GetElements() const;
|
const std::vector<std::vector<ArrayDimension>>& GetElements() const;
|
||||||
void Insert(const std::vector<ArrayDimension>& element);
|
void Insert(const std::vector<ArrayDimension>& element);
|
||||||
AccessingSet Union(const AccessingSet& source);
|
AccessingSet Union(const AccessingSet& source);
|
||||||
AccessingSet Intersect(const AccessingSet& secondSet) const;
|
AccessingSet Intersect(const AccessingSet& secondSet) const;
|
||||||
|
|||||||
@@ -1036,24 +1036,6 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
|||||||
if (internalExit < 0)
|
if (internalExit < 0)
|
||||||
throw -1;
|
throw -1;
|
||||||
|
|
||||||
set<int> applyFor = { LOOPS_SPLITTER,
|
|
||||||
LOOPS_COMBINER,
|
|
||||||
PRIVATE_REMOVING,
|
|
||||||
PRIVATE_ARRAYS_EXPANSION,
|
|
||||||
PRIVATE_ARRAYS_SHRINKING,
|
|
||||||
REMOVE_DEAD_CODE,
|
|
||||||
MOVE_OPERATORS };
|
|
||||||
|
|
||||||
if ((countOfTransform == 0 || internalExit > 0) && applyFor.find(curr_regime) != applyFor.end())
|
|
||||||
{
|
|
||||||
SgStatement* mainUnit = findMainUnit(&project, SPF_messages);
|
|
||||||
checkNull(mainUnit, convertFileName(__FILE__).c_str(), __LINE__);
|
|
||||||
|
|
||||||
getObjectForFileFromMap(mainUnit->fileName(), SPF_messages).push_back(Messages(ERROR, mainUnit->lineNumber(), R197, L"Transformation cannot be performed - nothing to change", 2023));
|
|
||||||
__spf_print(1, "%d Transformation cannot be performed - nothing to change, count of transform %d, err %d\n", mainUnit->lineNumber(), countOfTransform, internalExit);
|
|
||||||
throw -11;
|
|
||||||
}
|
|
||||||
|
|
||||||
sendMessage_2lvl(2);
|
sendMessage_2lvl(2);
|
||||||
// ********************************** ///
|
// ********************************** ///
|
||||||
/// SECOND AGGREGATION STEP ///
|
/// SECOND AGGREGATION STEP ///
|
||||||
@@ -1905,7 +1887,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
|||||||
else if (curr_regime == TRANSFORM_ASSUMED_SIZE_PARAMETERS)
|
else if (curr_regime == TRANSFORM_ASSUMED_SIZE_PARAMETERS)
|
||||||
transformAssumedSizeParameters(allFuncInfo);
|
transformAssumedSizeParameters(allFuncInfo);
|
||||||
else if (curr_regime == FIND_PRIVATE_ARRAYS_ANALYSIS)
|
else if (curr_regime == FIND_PRIVATE_ARRAYS_ANALYSIS)
|
||||||
findPrivateArrays(loopGraph, fullIR, insertedPrivates, SPF_messages, declaredArrays);
|
countOfTransform = findPrivateArrays(loopGraph, fullIR, insertedPrivates, SPF_messages, declaredArrays);
|
||||||
else if (curr_regime == MERGE_REGIONS)
|
else if (curr_regime == MERGE_REGIONS)
|
||||||
mergeRegions(parallelRegions, allFuncInfo);
|
mergeRegions(parallelRegions, allFuncInfo);
|
||||||
else if (curr_regime == ARRAY_PROPAGATION)
|
else if (curr_regime == ARRAY_PROPAGATION)
|
||||||
@@ -1921,6 +1903,25 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
|||||||
if (internalExit != 0)
|
if (internalExit != 0)
|
||||||
throw -1;
|
throw -1;
|
||||||
|
|
||||||
|
set<int> applyFor = { LOOPS_SPLITTER,
|
||||||
|
LOOPS_COMBINER,
|
||||||
|
PRIVATE_REMOVING,
|
||||||
|
PRIVATE_ARRAYS_EXPANSION,
|
||||||
|
PRIVATE_ARRAYS_SHRINKING,
|
||||||
|
REMOVE_DEAD_CODE,
|
||||||
|
MOVE_OPERATORS,
|
||||||
|
FIND_PRIVATE_ARRAYS_ANALYSIS };
|
||||||
|
|
||||||
|
if ((countOfTransform == 0 || internalExit > 0) && applyFor.find(curr_regime) != applyFor.end())
|
||||||
|
{
|
||||||
|
SgStatement* mainUnit = findMainUnit(&project, SPF_messages);
|
||||||
|
checkNull(mainUnit, convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
|
|
||||||
|
getObjectForFileFromMap(mainUnit->fileName(), SPF_messages).push_back(Messages(ERROR, mainUnit->lineNumber(), R197, L"Transformation cannot be performed - nothing to change", 2023));
|
||||||
|
__spf_print(1, "%d Transformation cannot be performed - nothing to change, count of transform %d, err %d\n", mainUnit->lineNumber(), countOfTransform, internalExit);
|
||||||
|
throw - 11;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define VERSION_SPF "2484"
|
#define VERSION_SPF "2485"
|
||||||
|
|||||||
Reference in New Issue
Block a user