Skip to content

Commit 0a517ac

Browse files
committed
Realized there is no need for transitive closure to correctly synthsize code
1 parent bee393c commit 0a517ac

4 files changed

Lines changed: 56 additions & 10 deletions

File tree

README.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,49 @@ more formats will be added
2121
```shell script
2222
cd build
2323
./bin/CodeSynthesis_Driver -src <formatname>,<dataName> -dest <formatName>,<dataName>\
24-
[-fuse <statement-list-delimited-by-comma> -fuselevel <level>]
24+
[-fuse <statement-list-delimited-by-comma> -fuselevel <level>] [-known "<set>"]
2525
```
2626

27+
28+
2729
Driver generates synth.h and synth.c files which can be compiled / added to a pre-existing project.
2830

31+
### Optimization options
32+
33+
Fuse Syntax:
34+
35+
Example S0: {[0,i,0,j,0] | stuff}; S1:{[1,i,0,j,0] | stuff}
36+
37+
Option: -fuse S0,S1 -fuselevel 2
38+
39+
```cpp
40+
for (i to ..)
41+
for (j to ..)
42+
S0
43+
44+
for (i to ..)
45+
for (j to ..)
46+
S1
47+
```
48+
49+
Result
50+
S0: {[0,i,0,j,0] | stuff}; S1:{[0,i,1,j,0] | stuff}
51+
52+
53+
```cpp
54+
for (i to ..)
55+
for (j to ..)
56+
S0
57+
S1
58+
```
59+
60+
Constraint simplification:
61+
62+
option: -known "<iteration space>"
63+
64+
The iteration space explores constraints that are true and not needed to be generated
65+
66+
2967
### Examples
3068

3169
COO TO CSR + Fusion

src/CodeSynthesis.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ CodeSynthesis::CodeSynthesis(SparseFormat* source,
772772

773773
//std::cout << "Composed Rel: " << composeRel->prettyPrintString() << "\n";
774774

775-
transRel = composeRel->TransitiveClosure();
775+
transRel = new Relation(*composeRel);
776776
// Expanded candidates for statement selections.
777777
transRelExpanded = substituteDirectEqualities(transRel);
778778

@@ -1475,7 +1475,7 @@ CodeSynthesis::getCopyReadAccess() {
14751475

14761476

14771477
std::string CodeSynthesis::generateFullCode(std::vector<int>& fuseStmts,
1478-
int level) {
1478+
int level,iegenlib::Set* known ) {
14791479
Computation* comp = generateInspectorComputation();
14801480
// Manual Fusion
14811481
ReadReductionFusionOptimization(comp,fuseStmts,level);
@@ -1582,7 +1582,7 @@ std::string CodeSynthesis::generateFullCode(std::vector<int>& fuseStmts,
15821582
destDataAccessMap->getTupleDecl().elemVarString(i)) << "]";
15831583
}
15841584
ss << "\n";
1585-
std::string code = comp->codeGen();
1585+
std::string code = comp->codeGen(known);
15861586

15871587
for(auto permute : permutes) {
15881588
// This has to be modified to use

src/CodeSynthesis.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,8 @@ class CodeSynthesis {
214214

215215
~CodeSynthesis();
216216

217-
std::string generateFullCode( std::vector<int>& fuseStmts,int level);
217+
std::string generateFullCode( std::vector<int>& fuseStmts,int level,
218+
iegenlib::Set* known = NULL);
218219

219220

220221
/// This gets the list of all expressions in a conjunction.

src/drivers/code_synthesis_main.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010

1111
using namespace code_synthesis;
1212
int main(int argc, char**argv) {
13-
if(argc != 5 && argc != 9) {
13+
if(argc != 5 && argc != 9 && argc!=7 && argc!= 11) {
1414
std::cerr << "Usage: synthDriver -src "
1515
<<"<formatname>,<dataName> -dest <formatName>,<dataName> "
16-
<<" [-fuse <fuse-list> -fuselevel <level>]\n";
16+
<<" [-fuse <fuse-list> -fuselevel <level> ] [-known \"<space>\"] \n";
1717
return 0;
1818
}
1919
// Load preset optimizations
@@ -213,7 +213,7 @@ int main(int argc, char**argv) {
213213
SparseFormat* sourceFormat = NULL;
214214
SparseFormat* destFormat = NULL;
215215

216-
216+
Set* known = NULL;
217217
while(currIndex < argc ) {
218218
std::string argString (argv[currIndex]);
219219
if(argString == "-src") {
@@ -259,12 +259,19 @@ int main(int argc, char**argv) {
259259
std::string level(argv[++currIndex]);
260260
fuseLevel = std::stoi(level);
261261
}
262-
currIndex++;
262+
263+
if (argString == "-known"){
264+
std::string s(argv[++currIndex]);
265+
std::cout << "test: "<< s << "\n";
266+
known = new Set(s);
267+
}
268+
269+
currIndex++;
263270
}
264271
assert(sourceFormat && destFormat
265272
&& "Unsopported Source or Destination Format");
266273
CodeSynthesis* synth = new CodeSynthesis(sourceFormat, destFormat);
267-
std::string code = synth->generateFullCode(fuseStmts,fuseLevel);
274+
std::string code = synth->generateFullCode(fuseStmts,fuseLevel,known);
268275
std::ofstream fileOut;
269276
fileOut.open("synth.h");
270277
fileOut << synth->GetSupportHeader();

0 commit comments

Comments
 (0)