Skip to content

Commit

Permalink
Merge branch 'master' of github.com:IObundle/iob-versat
Browse files Browse the repository at this point in the history
  • Loading branch information
jjts committed Jul 31, 2024
2 parents cc939e6 + 5eafe83 commit ed9196e
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 34 deletions.
21 changes: 12 additions & 9 deletions software/compiler/accelerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2240,9 +2240,6 @@ Pair<Accelerator*,SubMap*> Flatten2(Accelerator* accel,int times,Arena* temp){

FUDeclaration base = {};
newAccel->name = accel->name;

String path = PushDebugPath(temp,{},STRING("test.txt"));
FILE* allDeclarations = fopen(StaticFormat("%.*s",UNPACK_SS(path)),"w");

return {newAccel,subMappingDone};
}
Expand Down Expand Up @@ -2335,7 +2332,8 @@ CalculateDelayResult CalculateDelay(Accelerator* accel,DAGOrderNodes order,Array
nodeDelay->Insert(node,{0,false});
SendLatencyUpwards(node,edgeToDelay,nodeDelay,nodeToPart);

region(out){
if(globalOptions.debug){
BLOCK_REGION(out);
String fileName = PushString(out,"1_%d_out1_%d.dot",functionCalls,graphs++);
String filePath = PushDebugPath(out,accel->name,STRING("delays"),fileName);

Expand Down Expand Up @@ -2387,7 +2385,8 @@ CalculateDelayResult CalculateDelay(Accelerator* accel,DAGOrderNodes order,Array
SendLatencyUpwards(node,edgeToDelay,nodeDelay,nodeToPart);
}

region(out){
if(globalOptions.debug){
BLOCK_REGION(out);
String fileName = PushString(out,"1_%d_out2_%d.dot",functionCalls,graphs++);
String filePath = PushDebugPath(out,accel->name,STRING("delays"),fileName);

Expand Down Expand Up @@ -2423,7 +2422,8 @@ CalculateDelayResult CalculateDelay(Accelerator* accel,DAGOrderNodes order,Array
*delay -= minimum;
}

region(out){
if(globalOptions.debug){
BLOCK_REGION(out);
String fileName = PushString(out,"1_%d_out3_%d.dot",functionCalls,graphs++);
String filePath = PushDebugPath(out,accel->name,STRING("delays"),fileName);

Expand Down Expand Up @@ -2459,7 +2459,8 @@ CalculateDelayResult CalculateDelay(Accelerator* accel,DAGOrderNodes order,Array
}
}

region(out){
if(globalOptions.debug){
BLOCK_REGION(out);
String fileName = PushString(out,"1_%d_out4_%d.dot",functionCalls,graphs++);
String filePath = PushDebugPath(out,accel->name,STRING("delays"),fileName);

Expand Down Expand Up @@ -2529,7 +2530,8 @@ CalculateDelayResult CalculateDelay(Accelerator* accel,DAGOrderNodes order,Array
}
}

region(out){
if(globalOptions.debug){
BLOCK_REGION(out);
String fileName = PushString(out,"1_%d_out5_%d.dot",functionCalls,graphs++);
String filePath = PushDebugPath(out,accel->name,STRING("delays"),fileName);

Expand Down Expand Up @@ -2585,7 +2587,8 @@ CalculateDelayResult CalculateDelay(Accelerator* accel,DAGOrderNodes order,Array
}
}

region(out){
if(globalOptions.debug){
BLOCK_REGION(out);
String fileName = PushString(out,"1_%d_out_final.dot",functionCalls);
String filepath = PushDebugPath(out,accel->name,STRING("delays"),fileName);

Expand Down
3 changes: 2 additions & 1 deletion software/compiler/configurations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,8 @@ TestResult CalculateOneInstance(Accelerator* accel,bool recursive,Array<Partitio
DAGOrderNodes order = CalculateDAGOrder(accel->allocated,temp);
CalculateDelayResult calculatedDelay = CalculateDelay(accel,order,partitions,temp);

region(out){
if(globalOptions.debug){
BLOCK_REGION(out);
auto builder = StartString(out);
PushString(out,"CalculateOneInstance_");
bool first = true;
Expand Down
13 changes: 8 additions & 5 deletions software/compiler/debugVersat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <algorithm>

#include "globals.hpp"
#include "memory.hpp"
#include "type.hpp"
#include "utilsCore.hpp"
Expand Down Expand Up @@ -92,7 +93,7 @@ static void OutputGraphDotFile_(Accelerator* accel,bool collapseSameEdges,Set<FU
}

void OutputGraphDotFile(Accelerator* accel,bool collapseSameEdges,String filename,Arena* temp){
if(!globalDebug.outputGraphs){
if(!globalOptions.debug){
return;
}

Expand All @@ -102,7 +103,7 @@ void OutputGraphDotFile(Accelerator* accel,bool collapseSameEdges,String filenam
}

void OutputGraphDotFile(Accelerator* accel,bool collapseSameEdges,FUInstance* highlighInstance,String filename,Arena* temp){
if(!globalDebug.outputGraphs){
if(!globalOptions.debug){
return;
}

Expand All @@ -116,7 +117,7 @@ void OutputGraphDotFile(Accelerator* accel,bool collapseSameEdges,FUInstance* hi
}

void OutputGraphDotFile(Accelerator* accel,bool collapseSameEdges,Set<FUInstance*>* highlight,String filename,Arena* temp){
if(!globalDebug.outputGraphs){
if(!globalOptions.debug){
return;
}

Expand Down Expand Up @@ -173,7 +174,7 @@ void OutputMemoryHex(void* memory,int size){
}

void OutputGraphDotFile(Accelerator* accel,bool collapseSameEdges,FUInstance* highlighInstance,CalculateDelayResult delays,String filename,Arena* temp){
if(!globalDebug.outputGraphs){
if(!globalOptions.debug){
return;
}

Expand Down Expand Up @@ -258,9 +259,10 @@ void OutputGraphDotFile(Accelerator* accel,bool collapseSameEdges,FUInstance* hi
}

String PushDebugPath(Arena* out,String folderName,String fileName){
Assert(globalOptions.debug);
Assert(!Contains(fileName,"/"));
Assert(fileName.size != 0);

const char* fullFolderPath = nullptr;
if(folderName.size == 0){
fullFolderPath = StaticFormat("%.*s",UNPACK_SS(globalOptions.debugPath));
Expand All @@ -275,6 +277,7 @@ String PushDebugPath(Arena* out,String folderName,String fileName){
}

String PushDebugPath(Arena* out,String folderName,String subFolder,String fileName){
Assert(globalOptions.debug);
Assert(!Contains(fileName,"/"));
Assert(folderName.size != 0);
Assert(subFolder.size != 0);
Expand Down
18 changes: 12 additions & 6 deletions software/compiler/delayCalculation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ CalculateDelayResult CalculateDelay(Accelerator* accel,DAGOrderNodes order,Arena

SendLatencyUpwards(node,edgeDelay,nodeDelay);

region(out){
if(globalOptions.debug){
BLOCK_REGION(out);
String fileName = PushString(out,"0_%d_out1_%d.dot",functionCalls,graphs++);
String filePath = PushDebugPath(out,accel->name,STRING("delays"),fileName);

Expand Down Expand Up @@ -188,7 +189,8 @@ CalculateDelayResult CalculateDelay(Accelerator* accel,DAGOrderNodes order,Arena
SendLatencyUpwards(node,edgeDelay,nodeDelay);
}

region(out){
if(globalOptions.debug){
BLOCK_REGION(out);
String fileName = PushString(out,"0_%d_out2_%d.dot",functionCalls,graphs++);
String filePath = PushDebugPath(out,accel->name,STRING("delays"),fileName);

Expand Down Expand Up @@ -224,7 +226,8 @@ CalculateDelayResult CalculateDelay(Accelerator* accel,DAGOrderNodes order,Arena
*delay -= minimum;
}

region(out){
if(globalOptions.debug){
BLOCK_REGION(out);
String fileName = PushString(out,"0_%d_out3_%d.dot",functionCalls,graphs++);
String filePath = PushDebugPath(out,accel->name,STRING("delays"),fileName);

Expand Down Expand Up @@ -260,7 +263,8 @@ CalculateDelayResult CalculateDelay(Accelerator* accel,DAGOrderNodes order,Arena
}
}

region(out){
if(globalOptions.debug){
BLOCK_REGION(out);
String fileName = PushString(out,"0_%d_out4_%d.dot",functionCalls,graphs++);
String filePath = PushDebugPath(out,accel->name,STRING("delays"),fileName);

Expand Down Expand Up @@ -329,7 +333,8 @@ CalculateDelayResult CalculateDelay(Accelerator* accel,DAGOrderNodes order,Arena
}
}

region(out){
if(globalOptions.debug){
BLOCK_REGION(out);
String fileName = PushString(out,"0_%d_out5_%d.dot",functionCalls,graphs++);
String filePath = PushDebugPath(out,accel->name,STRING("delays"),fileName);

Expand Down Expand Up @@ -367,7 +372,8 @@ CalculateDelayResult CalculateDelay(Accelerator* accel,DAGOrderNodes order,Arena
}
}

region(out){
if(globalOptions.debug){
BLOCK_REGION(out);
String fileName = PushString(out,"0_%d_out_final.dot",functionCalls);
String filepath = PushDebugPath(out,accel->name,STRING("delays"),fileName);

Expand Down
12 changes: 12 additions & 0 deletions software/compiler/dotGraphPrinting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ String GenerateDotGraph(Accelerator* accel,GraphPrintingContent content,Arena* o
}

void OutputDebugDotGraph(Accelerator* accel,String fileName,Arena* temp){
if(!globalOptions.debug){
return;
}

Arena* temp2 = debugArena;

BLOCK_REGION(temp);
Expand All @@ -141,6 +145,10 @@ void OutputDebugDotGraph(Accelerator* accel,String fileName,Arena* temp){
}

void OutputDebugDotGraph(Accelerator* accel,String fileName,FUInstance* highlight,Arena* temp){
if(!globalOptions.debug){
return;
}

Arena* temp2 = debugArena;

BLOCK_REGION(temp);
Expand All @@ -166,6 +174,10 @@ void OutputDebugDotGraph(Accelerator* accel,String fileName,FUInstance* highligh
}

void OutputDebugDotGraph(Accelerator* accel,String fileName,Set<FUInstance*>* highlight,Arena* temp){
if(!globalOptions.debug){
return;
}

Arena* temp2 = debugArena;

BLOCK_REGION(temp);
Expand Down
26 changes: 16 additions & 10 deletions software/compiler/merge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,10 @@ CliqueState MaxClique(ConsolidationGraph graph,int upperBound,Arena* arena,Time
}

void OutputConsolidationGraph(ConsolidationGraph graph,bool onlyOutputValid,String moduleName,String fileName,Arena* temp){
if(!globalOptions.debug){
return;
}

BLOCK_REGION(temp);
String filePath = PushDebugPath(temp,moduleName,fileName);

Expand Down Expand Up @@ -2127,18 +2131,20 @@ FUDeclaration* Merge(Array<FUDeclaration*> types,
}

size = recon.size;

for(int i = 0; i < size; i++){
BLOCK_REGION(temp);
String fileName = PushString(temp,"finalRecon_%d.dot",i);
String filePath = PushDebugPath(temp,permanentName,fileName);

GraphPrintingContent content = GenerateDelayDotGraph(recon[i],reconDelay[i],temp,debugArena);
String result = GenerateDotGraph(recon[i],content,temp,debugArena);
OutputContentToFile(filePath,result);
}
if(globalOptions.debug){
for(int i = 0; i < size; i++){
BLOCK_REGION(temp);
String fileName = PushString(temp,"finalRecon_%d.dot",i);
String filePath = PushDebugPath(temp,permanentName,fileName);

OutputDebugDotGraph(circuit,STRING("FullCircuitFinal.dot"),temp);
GraphPrintingContent content = GenerateDelayDotGraph(recon[i],reconDelay[i],temp,debugArena);
String result = GenerateDotGraph(recon[i],content,temp,debugArena);
OutputContentToFile(filePath,result);
}

OutputDebugDotGraph(circuit,STRING("FullCircuitFinal.dot"),temp);
}

declInst.fixedDelayCircuit = circuit;

Expand Down
5 changes: 2 additions & 3 deletions software/compiler/versat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,8 @@ void FillDeclarationWithAcceleratorValues(FUDeclaration* decl,Accelerator* accel

AccelInfo val = CalculateAcceleratorInfo(accel,true,perm,temp2);

String path = PushDebugPath(temp,decl->name,STRING("composite_stats.txt"));

#if 0
String path = PushDebugPath(temp,decl->name,STRING("composite_stats.txt"));
FILE* stats = OpenFileAndCreateDirectories(StaticFormat("%.*s",UNPACK_SS(path)),"w");
DEFER_CLOSE_FILE(stats);

Expand Down Expand Up @@ -555,7 +554,7 @@ FUDeclaration* RegisterSubUnit(Accelerator* circuit,Arena* temp,Arena* temp2){

String name = circuit->name;

OutputDelayDebugInfo(circuit,temp);
//OutputDelayDebugInfo(circuit,temp); // Disabled for now

FUDeclaration decl = {};
decl.name = name;
Expand Down

0 comments on commit ed9196e

Please sign in to comment.