-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feat] Add support for nonlinear operations #27
Changes from 21 commits
ede67e7
3d060fd
32a9671
219d1d8
b7f2926
e26df4f
7fb0f61
7fbd95f
be01199
c7df862
f405e5e
42df212
73df393
e9d6c61
67ffd08
050f675
daceefd
88840d2
f0967de
553c187
514b909
83d04f3
4153456
e36645e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,8 +20,28 @@ CGRA::CGRA(int t_rows, int t_columns, bool t_diagonalVectorization, | |
m_rows = t_rows; | ||
m_columns = t_columns; | ||
m_FUCount = t_rows * t_columns; | ||
m_supportComplex = new list<string>(); | ||
m_supportCall = new list<string>(); | ||
nodes = new CGRANode**[t_rows]; | ||
|
||
// Initialize the m_supportComplex & m_supportCall list. | ||
for (auto x: *t_additionalFunc) { | ||
string func = x.first; | ||
if (func.find("call") != string::npos) { | ||
if (func.length() == 4) { | ||
m_supportCall->push_back(""); | ||
} else { | ||
m_supportCall->push_back(func.substr(func.find("call") + 5)); | ||
} | ||
} else if (func.find("complex") != string::npos) { | ||
if (func.length() == 7) { | ||
m_supportComplex->push_back(""); | ||
} else { | ||
m_supportComplex->push_back(func.substr(func.find("complex") + 8)); | ||
} | ||
} | ||
} | ||
|
||
if (t_parameterizableCGRA) { | ||
|
||
int node_id = 0; | ||
|
@@ -143,11 +163,11 @@ CGRA::CGRA(int t_rows, int t_columns, bool t_diagonalVectorization, | |
|
||
// Some other basic operations that can be indicated in the param.json: | ||
// Enable the specialized 'call' functionality. | ||
for (int r=0; r<t_rows; ++r) { | ||
for (int c=0; c<t_columns; ++c) { | ||
nodes[r][c]->enableCall(); | ||
} | ||
} | ||
// for (int r=0; r<t_rows; ++r) { | ||
// for (int c=0; c<t_columns; ++c) { | ||
// nodes[r][c]->enableCall(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change is a bug fix, right? So from now on, And is this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, |
||
// } | ||
// } | ||
|
||
// Enable the vectorization. | ||
if (t_diagonalVectorization) { | ||
|
@@ -168,12 +188,12 @@ CGRA::CGRA(int t_rows, int t_columns, bool t_diagonalVectorization, | |
|
||
// Enable the heterogeneity. | ||
if (t_heterogeneity) { | ||
for (int r=0; r<t_rows; ++r) { | ||
for (int c=0; c<t_columns; ++c) { | ||
if(r%2==1 and c%2 == 1) | ||
nodes[r][c]->enableComplex(); | ||
} | ||
} | ||
// for (int r=0; r<t_rows; ++r) { | ||
// for (int c=0; c<t_columns; ++c) { | ||
// // if(c == 0 || (r%2==1 and c%2 == 1)) | ||
// nodes[r][c]->enableComplex(); | ||
// } | ||
// } | ||
Comment on lines
+191
to
+196
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Means There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No. Here I mean complex operations should be manually specified in the param.json rather than we configure it for the default. |
||
} | ||
|
||
for (int r=0; r<t_rows; ++r) { | ||
|
@@ -255,6 +275,14 @@ CGRA::CGRA(int t_rows, int t_columns, bool t_diagonalVectorization, | |
|
||
} | ||
|
||
list<string>* CGRA::getSupportComplex() { | ||
return m_supportComplex; | ||
} | ||
|
||
list<string>* CGRA::getSupportCall() { | ||
return m_supportCall; | ||
} | ||
|
||
void CGRA::disableSpecificConnections() { | ||
// nodes[0][0]->disable(); | ||
// nodes[0][1]->disable(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,19 +30,19 @@ CGRANode::CGRANode(int t_id, int t_x, int t_y) { | |
m_canStore = false; | ||
m_canLoad = false; | ||
m_supportComplex = false; | ||
m_supportComplexType = vector<string>(); | ||
// It's not necessary to support specific function on each tile. | ||
m_canCall = vector<string>(); | ||
|
||
m_x = t_x; | ||
m_y = t_y; | ||
m_neighbors = NULL; | ||
m_occupiableInLinks = NULL; | ||
m_occupiableOutLinks = NULL; | ||
// new list<list<pair<DFGNode*, int>>*>();//DFGNode*[1]; | ||
// m_dfgNodes = new DFGNode*[1]; | ||
// m_fuOccupied = new int[1]; | ||
m_regs_duration = NULL; | ||
m_regs_timing = NULL; | ||
|
||
// used for parameterizable CGRA functional units | ||
m_canCall = true; | ||
m_canAdd = true; | ||
m_canMul = true; | ||
m_canShift = true; | ||
|
@@ -185,20 +185,28 @@ bool CGRANode::canSupport(DFGNode* t_opt) { | |
if (m_disabled) | ||
return false; | ||
// Check whether this CGRA node supports the required functionality. | ||
string call_f = t_opt->isCall(); | ||
if (call_f.compare("None") && !canCall(call_f)) { | ||
return false; | ||
} | ||
string complex_f = t_opt->getComplexType(); | ||
if (complex_f.compare("None") && !supportComplex(complex_f)) { | ||
return false; | ||
} | ||
if ((t_opt->isLoad() and !canLoad()) or | ||
(t_opt->isStore() and !canStore()) or | ||
(t_opt->isReturn() and !canReturn()) or | ||
(t_opt->isCall() and !canCall()) or | ||
(t_opt->isVectorized() and !supportVectorization()) or | ||
(t_opt->hasCombined() and !supportComplex()) or | ||
(t_opt->isAdd() and !canAdd()) or | ||
(t_opt->isMul() and !canMul()) or | ||
(t_opt->isPhi() and !canPhi()) or | ||
(t_opt->isSel() and !canSel()) or | ||
(t_opt->isMAC() and !canMAC()) or | ||
(t_opt->isLogic() and !canLogic()) or | ||
(t_opt->isBranch() and !canBr()) or | ||
(t_opt->isCmp() and !canCmp()) ){ | ||
(t_opt->isCmp() and !canCmp()) or | ||
(t_opt->isDiv() and !canDiv()) | ||
) { | ||
return false; | ||
} | ||
return true; | ||
|
@@ -413,11 +421,20 @@ bool CGRANode::enableFunctionality(string t_func) { | |
enableLoad(); | ||
} else if (t_func.compare("return") == 0) { | ||
enableReturn(); | ||
} else if (t_func.compare("call") == 0) { | ||
enableCall(); | ||
} else if (t_func.compare("complex") == 0) { | ||
enableComplex(); | ||
} else { | ||
} else if (t_func.find("call") != string::npos) { | ||
string type; | ||
if (t_func.length() == 4) type = "none"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can plz add comment about what does There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good. Plz just add this comment above. And refactor the code like:
|
||
else type = t_func.substr(t_func.find("call") + 5); | ||
enableCall(type); | ||
} else if (t_func.find("complex") != string::npos) { | ||
string type; | ||
if (t_func.length() == 7) type = "none"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sry but I remembered deleteing these printing statements and this line has been removed from the code. |
||
else type = t_func.substr(t_func.find("complex") + 8); | ||
enableComplex(type); | ||
} else if (t_func.compare("div") == 0) { | ||
enableDiv(); | ||
} | ||
else { | ||
return false; | ||
} | ||
return true; | ||
|
@@ -435,12 +452,13 @@ void CGRANode::enableLoad() { | |
m_canLoad = true; | ||
} | ||
|
||
void CGRANode::enableCall() { | ||
m_canCall = true; | ||
void CGRANode::enableCall(string t_func) { | ||
m_canCall.push_back(t_func); | ||
} | ||
|
||
void CGRANode::enableComplex() { | ||
m_supportComplex = true; | ||
void CGRANode::enableComplex(string type) { | ||
if (type == "") m_supportComplex = true; | ||
else m_supportComplexType.push_back(type); | ||
} | ||
|
||
void CGRANode::enableVectorization() { | ||
|
@@ -483,17 +501,29 @@ void CGRANode::enableBr() { | |
m_canBr = true; | ||
} | ||
|
||
void CGRANode::enableDiv() { | ||
m_canDiv = true; | ||
} | ||
|
||
bool CGRANode::supportComplex() { | ||
return m_supportComplex; | ||
bool CGRANode::supportComplex(string type) { | ||
if (type == "") return m_supportComplex; | ||
for (string t: m_supportComplexType) { | ||
if (t.compare(type) == 0) return true; | ||
} | ||
return false; | ||
} | ||
|
||
bool CGRANode::supportVectorization() { | ||
return m_supportVectorization; | ||
} | ||
|
||
bool CGRANode::canCall() { | ||
return m_canCall; | ||
bool CGRANode::canCall(string t_func) { | ||
for (string func: m_canCall) { | ||
if (func.compare(t_func) == 0) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
bool CGRANode::canReturn() { | ||
|
@@ -544,6 +574,10 @@ bool CGRANode::canBr() { | |
return m_canBr; | ||
} | ||
|
||
bool CGRANode::canDiv() { | ||
return m_canDiv; | ||
} | ||
|
||
int CGRANode::getX() { | ||
return m_x; | ||
} | ||
|
@@ -566,7 +600,8 @@ void CGRANode::disableAllFUs() { | |
m_canReturn = false; | ||
m_canStore = false; | ||
m_canLoad = false; | ||
m_canCall = false; | ||
m_canCall = vector<string>(); | ||
m_supportComplexType = vector<string>(); | ||
m_canAdd = false; | ||
m_canMul = false; | ||
m_canShift = false; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idiv_test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok