Skip to content
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

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
ede67e7
[feat] add support for look-up-table
HobbitQia Jul 17, 2024
3d060fd
merge
HobbitQia Jul 17, 2024
32a9671
[fix] change initialization for call and lut, then we can enable it o…
HobbitQia Jul 17, 2024
219d1d8
[update] add special functional support for div
HobbitQia Jul 22, 2024
b7f2926
[update] add special functional support for quantization
HobbitQia Jul 22, 2024
e26df4f
[fix] combine getelemtnptr + load/store in DFG
HobbitQia Jul 22, 2024
7fb0f61
[update] add support for int
HobbitQia Jul 24, 2024
7fbd95f
[feat] add support for fine-grained fusion
HobbitQia Aug 2, 2024
be01199
[update] add support for new special funtionalities in dfg
HobbitQia Aug 12, 2024
c7df862
[update] Add more detailed comments
HobbitQia Aug 24, 2024
f405e5e
[feat] split non-vectorized operations into seperate nodes rather tha…
HobbitQia Sep 4, 2024
42df212
[fix] only enable vectorization in integer format
HobbitQia Oct 3, 2024
73df393
[feat] parameterizable vectorization factor for tuning division patterns
HobbitQia Oct 25, 2024
e9d6c61
[feat] refactor codes for fine-grained fusion and special functions
HobbitQia Nov 12, 2024
67ffd08
[fix] resolve conflicts
HobbitQia Nov 12, 2024
050f675
[update] fix bugs & add a reference param.json
HobbitQia Nov 13, 2024
daceefd
[update] add nonlinear_test.cpp
HobbitQia Nov 13, 2024
88840d2
[update] rename vectorFactor to vectorFactorForIdiv
HobbitQia Nov 16, 2024
f0967de
[update] add idiv_test and enable github testing flow
HobbitQia Nov 16, 2024
553c187
[fix] correct path in cmake.yml
HobbitQia Nov 16, 2024
514b909
[fix] adjust file struct of test
HobbitQia Nov 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,13 @@ jobs:
# Build your program with the given configuration
run: make

- name: Test Nonlinear Feature
working-directory: ${{github.workspace}}/test/nonlinear_test
run: clang-12 -emit-llvm -O3 -fno-unroll-loops -fno-vectorize -o nonlinear_test.bc -c nonlinear_test.cpp && opt-12 -load ../../build/src/libmapperPass.so -mapperPass nonlinear_test.bc

- name: Test Idiv Feature
working-directory: ${{github.workspace}}/test/nonlinear_test
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idiv_test

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

run: clang-12 -emit-llvm -O3 -fno-unroll-loops -fno-vectorize -o idiv_test.bc -c idiv_test.cpp && opt-12 -load ../../build/src/libmapperPass.so -mapperPass idiv_test.bc

HobbitQia marked this conversation as resolved.
Show resolved Hide resolved


50 changes: 39 additions & 11 deletions src/CGRA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is a bug fix, right? So from now on, call can only be supported if user specify it in the param.json or user needs to modify this CGRA.cpp file?

And is this call actually how is the lut is recognized? i.e., instead of support call, user provide the lut func that is actually called in the IR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, call can only be supported if user specify. For lut, it should be writed as call-lut in param.json after I refactored the code.

// }
// }

// Enable the vectorization.
if (t_diagonalVectorization) {
Expand All @@ -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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Means heterogeneity in the param.json won't take effect any more?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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) {
Expand Down Expand Up @@ -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();
Expand Down
4 changes: 4 additions & 0 deletions src/CGRA.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class CGRA {
int m_LinkCount;
int m_rows;
int m_columns;
list<string>* m_supportComplex;
list<string>* m_supportCall;
void disableSpecificConnections();

public:
Expand All @@ -38,4 +40,6 @@ class CGRA {
void setBypassConstraint(int);
void setCtrlMemConstraint(int);
void setRegConstraint(int);
list<string>* getSupportComplex();
list<string>* getSupportCall();
};
77 changes: 56 additions & 21 deletions src/CGRANode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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";
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";
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;
Expand All @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -544,6 +574,10 @@ bool CGRANode::canBr() {
return m_canBr;
}

bool CGRANode::canDiv() {
return m_canDiv;
}

int CGRANode::getX() {
return m_x;
}
Expand All @@ -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;
Expand Down
14 changes: 9 additions & 5 deletions src/CGRANode.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ class CGRANode {
bool m_canReturn;
bool m_canStore;
bool m_canLoad;
bool m_canCall;
bool m_canAdd;
bool m_canMul;
bool m_canShift;
Expand All @@ -64,11 +63,14 @@ class CGRANode {
bool m_canMAC;
bool m_canLogic;
bool m_canBr;
bool m_canDiv;
bool m_supportComplex;
bool m_supportVectorization;
int** m_regs_duration;
int** m_regs_timing;
vector<list<pair<DFGNode*, int>>*> m_dfgNodesWithOccupyStatus;
vector<string> m_canCall;
vector<string> m_supportComplexType;

public:
CGRANode(int, int, int);
Expand All @@ -82,8 +84,8 @@ class CGRANode {
void enableReturn();
void enableStore();
void enableLoad();
void enableCall();
void enableComplex();
void enableCall(string t_func="");
void enableComplex(string t_func="");
void enableVectorization();
void enableAdd();
void enableMul();
Expand All @@ -94,6 +96,7 @@ class CGRANode {
void enableMAC();
void enableLogic();
void enableBr();
void enableDiv();

void attachInLink(CGRALink*);
void attachOutLink(CGRALink*);
Expand Down Expand Up @@ -121,8 +124,8 @@ class CGRANode {
bool canReturn();
bool canStore();
bool canLoad();
bool canCall();
bool supportComplex();
bool canCall(string t_func="");
bool supportComplex(string type="");
bool supportVectorization();
bool canAdd();
bool canMul();
Expand All @@ -133,6 +136,7 @@ class CGRANode {
bool canMAC();
bool canLogic();
bool canBr();
bool canDiv();
DFGNode* getMappedDFGNode(int);
bool containMappedDFGNode(DFGNode*, int);
void allocateReg(CGRALink*, int, int, int);
Expand Down
Loading
Loading