diff --git a/software/compiler/accelerator.cpp b/software/compiler/accelerator.cpp index 43e1e4c..3f58838 100644 --- a/software/compiler/accelerator.cpp +++ b/software/compiler/accelerator.cpp @@ -2240,9 +2240,6 @@ Pair 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}; } @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); diff --git a/software/compiler/configurations.cpp b/software/compiler/configurations.cpp index 9664ae3..6dc4766 100644 --- a/software/compiler/configurations.cpp +++ b/software/compiler/configurations.cpp @@ -513,7 +513,8 @@ TestResult CalculateOneInstance(Accelerator* accel,bool recursive,Arrayallocated,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; diff --git a/software/compiler/debugVersat.cpp b/software/compiler/debugVersat.cpp index 2d92bb8..02565ce 100644 --- a/software/compiler/debugVersat.cpp +++ b/software/compiler/debugVersat.cpp @@ -6,6 +6,7 @@ #include +#include "globals.hpp" #include "memory.hpp" #include "type.hpp" #include "utilsCore.hpp" @@ -92,7 +93,7 @@ static void OutputGraphDotFile_(Accelerator* accel,bool collapseSameEdges,Set* highlight,String filename,Arena* temp){ - if(!globalDebug.outputGraphs){ + if(!globalOptions.debug){ return; } @@ -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; } @@ -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)); @@ -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); diff --git a/software/compiler/delayCalculation.cpp b/software/compiler/delayCalculation.cpp index 66fe91d..9abad67 100644 --- a/software/compiler/delayCalculation.cpp +++ b/software/compiler/delayCalculation.cpp @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); diff --git a/software/compiler/dotGraphPrinting.cpp b/software/compiler/dotGraphPrinting.cpp index 22f22e7..2bccf73 100644 --- a/software/compiler/dotGraphPrinting.cpp +++ b/software/compiler/dotGraphPrinting.cpp @@ -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); @@ -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); @@ -166,6 +174,10 @@ void OutputDebugDotGraph(Accelerator* accel,String fileName,FUInstance* highligh } void OutputDebugDotGraph(Accelerator* accel,String fileName,Set* highlight,Arena* temp){ + if(!globalOptions.debug){ + return; + } + Arena* temp2 = debugArena; BLOCK_REGION(temp); diff --git a/software/compiler/merge.cpp b/software/compiler/merge.cpp index 9ce80e2..99abf21 100644 --- a/software/compiler/merge.cpp +++ b/software/compiler/merge.cpp @@ -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); @@ -2127,18 +2131,20 @@ FUDeclaration* Merge(Array 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; diff --git a/software/compiler/versat.cpp b/software/compiler/versat.cpp index 99a66b8..377dafc 100644 --- a/software/compiler/versat.cpp +++ b/software/compiler/versat.cpp @@ -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); @@ -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;