diff --git a/benchmark/scripts/scanACol/config_BCoAMM.csv b/benchmark/scripts/scanACol/config_BCoAMM.csv index aa481d3d..797a3c25 100644 --- a/benchmark/scripts/scanACol/config_BCoAMM.csv +++ b/benchmark/scripts/scanACol/config_BCoAMM.csv @@ -3,4 +3,5 @@ aRow,1000,U64 aCol,1000,U64 bCol,500,U64 sketchDimension,25,U64 -ptFile,torchscripts/BetaCoOccurringFD.pt,String \ No newline at end of file +ptFile,torchscripts/BetaCoOccurringFD.pt,String +forceMP,1,U64 diff --git a/benchmark/scripts/scanACol/config_BerCRS.csv b/benchmark/scripts/scanACol/config_BerCRS.csv index 14a0cdc1..4d9e7feb 100644 --- a/benchmark/scripts/scanACol/config_BerCRS.csv +++ b/benchmark/scripts/scanACol/config_BerCRS.csv @@ -3,4 +3,5 @@ aRow,1000,U64 aCol,1000,U64 bCol,500,U64 sketchDimension,25,U64 -ptFile,torchscripts/BernoulliCRS.pt,String \ No newline at end of file +ptFile,torchscripts/BernoulliCRS.pt,String +forceMP,1,U64 diff --git a/benchmark/scripts/scanACol/config_CPPCRS.csv b/benchmark/scripts/scanACol/config_CPPCRS.csv deleted file mode 100644 index a9b928d2..00000000 --- a/benchmark/scripts/scanACol/config_CPPCRS.csv +++ /dev/null @@ -1,8 +0,0 @@ -key,value,type -aRow,1000,U64 -aCol,1000,U64 -bCol,500,U64 -sketchDimension,25,U64 -ptFile,torchscripts/CRS.pt,String -useCPP,1,U64 -cppAlgoTag,crs,String \ No newline at end of file diff --git a/benchmark/scripts/scanACol/config_CRS.csv b/benchmark/scripts/scanACol/config_CRS.csv index 620247f2..faf584f0 100644 --- a/benchmark/scripts/scanACol/config_CRS.csv +++ b/benchmark/scripts/scanACol/config_CRS.csv @@ -3,4 +3,5 @@ aRow,1000,U64 aCol,1000,U64 bCol,500,U64 sketchDimension,25,U64 -ptFile,torchscripts/CRS.pt,String \ No newline at end of file +ptFile,torchscripts/CRS.pt,String +forceMP,1,U64 diff --git a/benchmark/scripts/scanAColCPP/config_CRS.csv b/benchmark/scripts/scanACol/config_CRSV2.csv similarity index 61% rename from benchmark/scripts/scanAColCPP/config_CRS.csv rename to benchmark/scripts/scanACol/config_CRSV2.csv index 620247f2..7d8585a0 100644 --- a/benchmark/scripts/scanAColCPP/config_CRS.csv +++ b/benchmark/scripts/scanACol/config_CRSV2.csv @@ -3,4 +3,5 @@ aRow,1000,U64 aCol,1000,U64 bCol,500,U64 sketchDimension,25,U64 -ptFile,torchscripts/CRS.pt,String \ No newline at end of file +ptFile,torchscripts/CRSV2.pt,String +forceMP,1,U64 diff --git a/benchmark/scripts/scanACol/config_CoAMM.csv b/benchmark/scripts/scanACol/config_CoAMM.csv index 765e54de..26aabc0e 100644 --- a/benchmark/scripts/scanACol/config_CoAMM.csv +++ b/benchmark/scripts/scanACol/config_CoAMM.csv @@ -3,4 +3,5 @@ aRow,1000,U64 aCol,1000,U64 bCol,500,U64 sketchDimension,25,U64 -ptFile,torchscripts/CoOccurringFD.pt,String \ No newline at end of file +ptFile,torchscripts/CoOccurringFD.pt,String +forceMP,1,U64 diff --git a/benchmark/scripts/scanACol/config_CounterSketch.csv b/benchmark/scripts/scanACol/config_CounterSketch.csv index 79eabd46..ad0ac1a4 100644 --- a/benchmark/scripts/scanACol/config_CounterSketch.csv +++ b/benchmark/scripts/scanACol/config_CounterSketch.csv @@ -4,3 +4,4 @@ aCol,1000,U64 bCol,500,U64 sketchDimension,25,U64 ptFile,torchscripts/CountSketch.pt,String +forceMP,1,U64 diff --git a/benchmark/scripts/scanACol/config_EWS.csv b/benchmark/scripts/scanACol/config_EWS.csv index 0a752db9..f5834cbd 100644 --- a/benchmark/scripts/scanACol/config_EWS.csv +++ b/benchmark/scripts/scanACol/config_EWS.csv @@ -3,4 +3,5 @@ aRow,1000,U64 aCol,1000,U64 bCol,500,U64 sketchDimension,25,U64 -ptFile,torchscripts/EWS.pt,String \ No newline at end of file +ptFile,torchscripts/EWS.pt,String +forceMP,1,U64 diff --git a/benchmark/scripts/scanACol/config_RAWMM.csv b/benchmark/scripts/scanACol/config_RAWMM.csv index 57e126f7..78e00b13 100644 --- a/benchmark/scripts/scanACol/config_RAWMM.csv +++ b/benchmark/scripts/scanACol/config_RAWMM.csv @@ -3,4 +3,5 @@ aRow,1000,U64 aCol,1000,U64 bCol,500,U64 sketchDimension,25,U64 -ptFile,torchscripts/RAWMM.pt,String \ No newline at end of file +ptFile,torchscripts/RAWMM.pt,String +forceMP,1,U64 diff --git a/benchmark/scripts/scanAColCPP/config_BCoAMM.csv b/benchmark/scripts/scanACol/config_TugOfWar.csv similarity index 59% rename from benchmark/scripts/scanAColCPP/config_BCoAMM.csv rename to benchmark/scripts/scanACol/config_TugOfWar.csv index aa481d3d..61ba7a68 100644 --- a/benchmark/scripts/scanAColCPP/config_BCoAMM.csv +++ b/benchmark/scripts/scanACol/config_TugOfWar.csv @@ -3,4 +3,5 @@ aRow,1000,U64 aCol,1000,U64 bCol,500,U64 sketchDimension,25,U64 -ptFile,torchscripts/BetaCoOccurringFD.pt,String \ No newline at end of file +ptFile,torchscripts/TugOfWar.pt,String +forceMP,1,U64 diff --git a/benchmark/scripts/scanACol/config_WCR.csv b/benchmark/scripts/scanACol/config_WCR.csv index a2b6b73c..83a349df 100644 --- a/benchmark/scripts/scanACol/config_WCR.csv +++ b/benchmark/scripts/scanACol/config_WCR.csv @@ -3,4 +3,5 @@ aRow,1000,U64 aCol,1000,U64 bCol,500,U64 sketchDimension,25,U64 -ptFile,torchscripts/WeightedCR.pt,String \ No newline at end of file +ptFile,torchscripts/WeightedCR.pt,String +forceMP,1,U64 diff --git a/benchmark/scripts/scanACol/drawTogether.py b/benchmark/scripts/scanACol/drawTogether.py index 2222a7b6..29e4d304 100755 --- a/benchmark/scripts/scanACol/drawTogether.py +++ b/benchmark/scripts/scanACol/drawTogether.py @@ -124,10 +124,10 @@ def main(): exeSpace = os.path.abspath(os.path.join(os.getcwd(), "../..")) + "/" commonBase = os.path.abspath(os.path.join(os.getcwd(), "../..")) + "/results/" + scanTag + "/" figPath = os.path.abspath(os.path.join(os.getcwd(), "../..")) + "/figures/" + scanTag - methodTags = ["FD-AMM", "Co-AMM", "BCo-AMM", "Couter-sketch", "MM"] - resultPaths = ["fd", "co", "co", "cs", "mm"] - csvTemplates = ["config_FDAMM.csv", "config_CoAMM.csv", "config_BCoAMM.csv", "config_CounterSketch.csv", - "config_RAWMM.csv"] + methodTags = ["Co-AMM", "BCo-AMM", "Count-sketch", "Tug-of-War", "MM"] + resultPaths = ["co", "co", "cs", "tow", "mm"] + csvTemplates = ["config_CoAMM.csv", "config_BCoAMM.csv", "config_CounterSketch.csv", + "config_TugOfWar.csv", "config_RAWMM.csv"] valueVec = [100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000] valueVecDisp = np.array(valueVec) # run @@ -153,9 +153,10 @@ def main(): figPath + "/" + scanTag + "sketch_cacheMiss", True) # sampling - resultPaths = ["crs", "bcrs", "ews", "mm"] - csvTemplates = ["config_CRS.csv", "config_BerCRS.csv", "config_EWS.csv", "config_RAWMM.csv"] - methodTags = ["CRS", "Ber-CRS", "EWS", "MM"] + resultPaths = ["crs", "crsv2", "bcrs", "wcr", "ews", "mm"] + csvTemplates = ["config_CRS.csv", "config_CRSV2.csv", "config_BerCRS.csv", "config_WCR.csv", + "config_EWS.csv", "config_RAWMM.csv"] + methodTags = ["CRS", "CRSV2", "Ber-CRS", "Weighted-CR", "EWS", "MM"] elapsedTimeAll, cacheMissAll, periodAll = compareMethod(exeSpace, commonBase, resultPaths, csvTemplates, valueVec, reRun) groupLine.DrawFigure(periodAll, elapsedTimeAll, diff --git a/benchmark/scripts/scanAColCPP/config_CPPBCOOFD.csv b/benchmark/scripts/scanAColCPP/config_CPPBCOOFD.csv new file mode 100644 index 00000000..d43c92f9 --- /dev/null +++ b/benchmark/scripts/scanAColCPP/config_CPPBCOOFD.csv @@ -0,0 +1,10 @@ +key,value,type +aRow,100,U64 +aCol,1000,U64 +bCol,500,U64 +sketchDimension,25,U64 +ptFile,torchscripts/BetaCoOccurringFD.pt,String +useCPP,1,U64 +cppAlgoTag,bcooFD,String +threads,1,U64 +forceMP,1,U64 diff --git a/benchmark/scripts/scanAColCPP/config_CPPBCRS.csv b/benchmark/scripts/scanAColCPP/config_CPPBCRS.csv new file mode 100644 index 00000000..3b7ee42c --- /dev/null +++ b/benchmark/scripts/scanAColCPP/config_CPPBCRS.csv @@ -0,0 +1,10 @@ +key,value,type +aRow,100,U64 +aCol,1000,U64 +bCol,500,U64 +sketchDimension,25,U64 +ptFile,torchscripts/BernoulliCRS.pt,String +useCPP,1,U64 +cppAlgoTag,bcrs,String +threads,1,U64 +forceMP,1,U64 diff --git a/benchmark/scripts/scanAColCPP/config_CPPCRSV2.csv b/benchmark/scripts/scanAColCPP/config_CPPCRSV2.csv new file mode 100644 index 00000000..b94e2d2f --- /dev/null +++ b/benchmark/scripts/scanAColCPP/config_CPPCRSV2.csv @@ -0,0 +1,10 @@ +key,value,type +aRow,100,U64 +aCol,1000,U64 +bCol,500,U64 +sketchDimension,25,U64 +ptFile,torchscripts/CRSV2.pt,String +useCPP,1,U64 +cppAlgoTag,crsV2,String +threads,1,U64 +forceMP,1,U64 diff --git a/benchmark/scripts/scanAColCPP/config_CPPINT8.csv b/benchmark/scripts/scanAColCPP/config_CPPINT8.csv new file mode 100644 index 00000000..2b61c43e --- /dev/null +++ b/benchmark/scripts/scanAColCPP/config_CPPINT8.csv @@ -0,0 +1,10 @@ +key,value,type +aRow,100,U64 +aCol,1000,U64 +bCol,500,U64 +sketchDimension,25,U64 +ptFile,torchscripts/FDAMM.pt,String +useCPP,1,U64 +cppAlgoTag,int8,String +threads,1,U64 +forceMP,1,U64 diff --git a/benchmark/scripts/scanAColCPP/config_CPPSMPPCA.csv b/benchmark/scripts/scanAColCPP/config_CPPSMPPCA.csv new file mode 100644 index 00000000..7c3a0223 --- /dev/null +++ b/benchmark/scripts/scanAColCPP/config_CPPSMPPCA.csv @@ -0,0 +1,9 @@ +key,value,type +aRow,10000,U64 +aCol,1000,U64 +bCol,500,U64 +sketchDimension,25,U64 +threads,1,U64 +ptFile,torchscripts/WeightedCR.pt,String +useCPP,1,U64 +cppAlgoTag,smp-pca,String \ No newline at end of file diff --git a/benchmark/scripts/scanAColCPP/config_CPPWeightedCR.csv b/benchmark/scripts/scanAColCPP/config_CPPWeightedCR.csv new file mode 100644 index 00000000..e92a7939 --- /dev/null +++ b/benchmark/scripts/scanAColCPP/config_CPPWeightedCR.csv @@ -0,0 +1,9 @@ +key,value,type +aRow,10000,U64 +aCol,1000,U64 +bCol,500,U64 +sketchDimension,25,U64 +threads,1,U64 +ptFile,torchscripts/WeightedCR.pt,String +useCPP,1,U64 +cppAlgoTag,weighted-cr,String \ No newline at end of file diff --git a/benchmark/scripts/scanAColCPP/config_CoAMM.csv b/benchmark/scripts/scanAColCPP/config_CoAMM.csv deleted file mode 100644 index 765e54de..00000000 --- a/benchmark/scripts/scanAColCPP/config_CoAMM.csv +++ /dev/null @@ -1,6 +0,0 @@ -key,value,type -aRow,1000,U64 -aCol,1000,U64 -bCol,500,U64 -sketchDimension,25,U64 -ptFile,torchscripts/CoOccurringFD.pt,String \ No newline at end of file diff --git a/benchmark/scripts/scanAColCPP/config_CounterSketch.csv b/benchmark/scripts/scanAColCPP/config_CounterSketch.csv deleted file mode 100644 index 79eabd46..00000000 --- a/benchmark/scripts/scanAColCPP/config_CounterSketch.csv +++ /dev/null @@ -1,6 +0,0 @@ -key,value,type -aRow,1000,U64 -aCol,1000,U64 -bCol,500,U64 -sketchDimension,25,U64 -ptFile,torchscripts/CountSketch.pt,String diff --git a/benchmark/scripts/scanAColCPP/config_EWS.csv b/benchmark/scripts/scanAColCPP/config_EWS.csv deleted file mode 100644 index 0a752db9..00000000 --- a/benchmark/scripts/scanAColCPP/config_EWS.csv +++ /dev/null @@ -1,6 +0,0 @@ -key,value,type -aRow,1000,U64 -aCol,1000,U64 -bCol,500,U64 -sketchDimension,25,U64 -ptFile,torchscripts/EWS.pt,String \ No newline at end of file diff --git a/benchmark/scripts/scanAColCPP/config_FDAMM.csv b/benchmark/scripts/scanAColCPP/config_FDAMM.csv deleted file mode 100644 index 2dac7db7..00000000 --- a/benchmark/scripts/scanAColCPP/config_FDAMM.csv +++ /dev/null @@ -1,6 +0,0 @@ -key,value,type -aRow,1000,U64 -aCol,1000,U64 -bCol,500,U64 -sketchDimension,25,U64 -ptFile,torchscripts/FDAMM.pt,String \ No newline at end of file diff --git a/benchmark/scripts/scanAColCPP/config_RAWMM.csv b/benchmark/scripts/scanAColCPP/config_RAWMM.csv deleted file mode 100644 index 57e126f7..00000000 --- a/benchmark/scripts/scanAColCPP/config_RAWMM.csv +++ /dev/null @@ -1,6 +0,0 @@ -key,value,type -aRow,1000,U64 -aCol,1000,U64 -bCol,500,U64 -sketchDimension,25,U64 -ptFile,torchscripts/RAWMM.pt,String \ No newline at end of file diff --git a/benchmark/scripts/scanAColCPP/config_WCR.csv b/benchmark/scripts/scanAColCPP/config_WCR.csv deleted file mode 100644 index a2b6b73c..00000000 --- a/benchmark/scripts/scanAColCPP/config_WCR.csv +++ /dev/null @@ -1,6 +0,0 @@ -key,value,type -aRow,1000,U64 -aCol,1000,U64 -bCol,500,U64 -sketchDimension,25,U64 -ptFile,torchscripts/WeightedCR.pt,String \ No newline at end of file diff --git a/benchmark/scripts/scanAColCPP/drawTogether.py b/benchmark/scripts/scanAColCPP/drawTogether.py index 20d8aa55..5cba8047 100755 --- a/benchmark/scripts/scanAColCPP/drawTogether.py +++ b/benchmark/scripts/scanAColCPP/drawTogether.py @@ -135,11 +135,11 @@ def main(): exeSpace = os.path.abspath(os.path.join(os.getcwd(), "../..")) + "/" commonBase = os.path.abspath(os.path.join(os.getcwd(), "../..")) + "/results/" + scanTag + "/" figPath = os.path.abspath(os.path.join(os.getcwd(), "../..")) + "/figures/" + scanTag + "CPP" - methodTags = ["FD-AMM", "Co-AMM", "BCo-AMM", "Couter-sketch", "MM"] - resultPaths = ["fd", "co", "co", "cs", "mm"] - csvTemplates = ["config_FDAMM.csv", "config_CoAMM.csv", "config_BCoAMM.csv", "config_CounterSketch.csv", - "config_RAWMM.csv"] - valueVec = [100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000] + methodTags = ["Co-AMM", "BCo-AMM", "Count-sketch", "Tug-of-War", "SMP-PCA", "MM"] + resultPaths = ["co", "co", "cs", "tow", "smp-pca", "mm"] + csvTemplates = ["config_CPPCOFD.csv", "config_CPPBCOOFD.csv", "config_CPPCOUNTERSKETCH.csv", + "config_CPPTOW.csv", "config_CPPSMPPCA.csv", "config_CPPMM.csv"] + valueVec = [100, 200, 500, 1000, 5000, 10000, 20000, 50000] valueVecDisp = np.array(valueVec) # run reRun = 0 @@ -150,13 +150,37 @@ def main(): os.system("sudo rm -rf " + commonBase) os.system("sudo mkdir " + commonBase) reRun = 1 - + # skech + elapsedTimeAll, cacheMissAll, periodAll, fro, eb = compareMethod(exeSpace, commonBase, resultPaths, csvTemplates, valueVec, + reRun) + groupLine.DrawFigure(periodAll, elapsedTimeAll, + methodTags, + "#elements in A's col", "elapsed time (ms)", 0, 1, + figPath + "/" + scanTag + "sketch_cpp_elapsedTime", + True) + groupLine.DrawFigureYnormal(periodAll, cacheMissAll, + methodTags, + "#elements in A's col", "cacheMiss (%)", 0, 1, + figPath + "/" + scanTag + "sketch_cpp_cacheMiss", + True) + groupLine.DrawFigureYnormal(periodAll, + fro * 100.0, + methodTags, + "#A's row", "normalized error %", 0, 100, figPath + "/" +scanTag + + "sketch_cpp_froError", + True) + groupLine.DrawFigureYnormal(periodAll, + eb * 100.0, + methodTags, + "#A's row", "error bound ratio %", 0, 100, figPath + "/" + scanTag + + "sketch_cpp_ebRatio", + True) # sampling - # sampling # resultPaths = ["crs", "bcrs", "ews", "mm","mm-cpp","crs-cpp"] - resultPaths = ["mm", "crs","ews","counterSketch","cofd","tow"] - csvTemplates = ["config_CPPMM.csv", "config_CPPCRS.csv","config_CPPEWS.csv","config_CPPCOUNTERSKETCH.csv","config_CPPCOFD.csv","config_CPPTOW.csv"] - methodTags = ["mm", "crs","ews","counterSketch","cofd","tow"] + resultPaths = ["crs", "crsv2", "bcrs", "wcr", "ews", "int8", "mm"] + csvTemplates = ["config_CPPCRS.csv", "config_CPPCRSV2.csv", "config_CPPBCRS.csv", "config_CPPWeightedCR.csv", + "config_CPPEWS.csv", "config_CPPINT8.csv", "config_CPPMM.csv"] + methodTags = ["CRS", "CRSV2", "Ber-CRS", "Weighted-CR", "EWS", "INT8", "MM"] # csvTemplates = ["config_CRS.csv", "config_BerCRS.csv", "config_EWS.csv", "config_RAWMM.csv","config_CPPMM.csv","config_CPPCRS.csv"] # methodTags = ["CRS", "Ber-CRS", "EWS",, "MM","MM_CPP","CRS_CPP"] elapsedTimeAll, cacheMissAll, periodAll,fro,eb = compareMethod(exeSpace, commonBase, resultPaths, csvTemplates, valueVec, @@ -164,12 +188,12 @@ def main(): groupLine.DrawFigure(periodAll, elapsedTimeAll, methodTags, "#A's col", "elapsed time (ms)", 0, 1, - figPath + "/" + scanTag + "cpp_elapsedTime", + figPath + "/" + scanTag + "sampling_cpp_elapsedTime", True) groupLine.DrawFigureYnormal(periodAll, cacheMissAll, methodTags, "#A's col", "cacheMiss (%)", 0, 1, - figPath + "/" + scanTag + "cpp_cacheMiss", + figPath + "/" + scanTag + "sampling_cpp_cacheMiss", True) groupLine.DrawFigureYnormal(periodAll, fro * 100.0, diff --git a/benchmark/scripts/scanARow/config_BCoAMM.csv b/benchmark/scripts/scanARow/config_BCoAMM.csv index b65317af..2865329c 100644 --- a/benchmark/scripts/scanARow/config_BCoAMM.csv +++ b/benchmark/scripts/scanARow/config_BCoAMM.csv @@ -3,4 +3,5 @@ aRow,100,U64 aCol,1000,U64 bCol,500,U64 sketchDimension,25,U64 -ptFile,torchscripts/BetaCoOccurringFD.pt,String \ No newline at end of file +ptFile,torchscripts/BetaCoOccurringFD.pt,String +forceMP,1,U64 diff --git a/benchmark/scripts/scanARow/config_BerCRS.csv b/benchmark/scripts/scanARow/config_BerCRS.csv index d2b758a5..310d285c 100644 --- a/benchmark/scripts/scanARow/config_BerCRS.csv +++ b/benchmark/scripts/scanARow/config_BerCRS.csv @@ -3,4 +3,5 @@ aRow,100,U64 aCol,1000,U64 bCol,500,U64 sketchDimension,25,U64 -ptFile,torchscripts/BernoulliCRS.pt,String \ No newline at end of file +ptFile,torchscripts/BernoulliCRS.pt,String +forceMP,1,U64 diff --git a/benchmark/scripts/scanARow/config_CRS.csv b/benchmark/scripts/scanARow/config_CRS.csv index b6afe1ef..90915b42 100644 --- a/benchmark/scripts/scanARow/config_CRS.csv +++ b/benchmark/scripts/scanARow/config_CRS.csv @@ -3,4 +3,5 @@ aRow,100,U64 aCol,1000,U64 bCol,500,U64 sketchDimension,25,U64 -ptFile,torchscripts/CRS.pt,String \ No newline at end of file +ptFile,torchscripts/CRS.pt,String +forceMP,1,U64 diff --git a/benchmark/scripts/scanACol/config_FDAMM.csv b/benchmark/scripts/scanARow/config_CRSV2.csv similarity index 61% rename from benchmark/scripts/scanACol/config_FDAMM.csv rename to benchmark/scripts/scanARow/config_CRSV2.csv index 2dac7db7..7d8585a0 100644 --- a/benchmark/scripts/scanACol/config_FDAMM.csv +++ b/benchmark/scripts/scanARow/config_CRSV2.csv @@ -3,4 +3,5 @@ aRow,1000,U64 aCol,1000,U64 bCol,500,U64 sketchDimension,25,U64 -ptFile,torchscripts/FDAMM.pt,String \ No newline at end of file +ptFile,torchscripts/CRSV2.pt,String +forceMP,1,U64 diff --git a/benchmark/scripts/scanARow/config_CoAMM.csv b/benchmark/scripts/scanARow/config_CoAMM.csv index f41d7ddd..7b6baf83 100644 --- a/benchmark/scripts/scanARow/config_CoAMM.csv +++ b/benchmark/scripts/scanARow/config_CoAMM.csv @@ -3,4 +3,5 @@ aRow,100,U64 aCol,1000,U64 bCol,500,U64 sketchDimension,25,U64 -ptFile,torchscripts/CoOccurringFD.pt,String \ No newline at end of file +ptFile,torchscripts/CoOccurringFD.pt,String +forceMP,1,U64 diff --git a/benchmark/scripts/scanARow/config_CounterSketch.csv b/benchmark/scripts/scanARow/config_CounterSketch.csv index 50cf2770..80d9bd4f 100644 --- a/benchmark/scripts/scanARow/config_CounterSketch.csv +++ b/benchmark/scripts/scanARow/config_CounterSketch.csv @@ -4,3 +4,4 @@ aCol,1000,U64 bCol,500,U64 sketchDimension,25,U64 ptFile,torchscripts/CountSketch.pt,String +forceMP,1,U64 diff --git a/benchmark/scripts/scanARow/config_EWS.csv b/benchmark/scripts/scanARow/config_EWS.csv index 8e09f17b..d1a15d00 100644 --- a/benchmark/scripts/scanARow/config_EWS.csv +++ b/benchmark/scripts/scanARow/config_EWS.csv @@ -3,4 +3,5 @@ aRow,100,U64 aCol,1000,U64 bCol,500,U64 sketchDimension,25,U64 -ptFile,torchscripts/EWS.pt,String \ No newline at end of file +ptFile,torchscripts/EWS.pt,String +forceMP,1,U64 diff --git a/benchmark/scripts/scanARow/config_FDAMM.csv b/benchmark/scripts/scanARow/config_FDAMM.csv deleted file mode 100644 index 18b9efde..00000000 --- a/benchmark/scripts/scanARow/config_FDAMM.csv +++ /dev/null @@ -1,6 +0,0 @@ -key,value,type -aRow,100,U64 -aCol,1000,U64 -bCol,500,U64 -sketchDimension,25,U64 -ptFile,torchscripts/FDAMM.pt,String \ No newline at end of file diff --git a/benchmark/scripts/scanARow/config_RAWMM.csv b/benchmark/scripts/scanARow/config_RAWMM.csv index aeb092a8..8401fe58 100644 --- a/benchmark/scripts/scanARow/config_RAWMM.csv +++ b/benchmark/scripts/scanARow/config_RAWMM.csv @@ -3,4 +3,5 @@ aRow,100,U64 aCol,1000,U64 bCol,500,U64 sketchDimension,25,U64 -ptFile,torchscripts/RAWMM.pt,String \ No newline at end of file +ptFile,torchscripts/RAWMM.pt,String +forceMP,1,U64 diff --git a/benchmark/scripts/scanAColCPP/config_BerCRS.csv b/benchmark/scripts/scanARow/config_TugOfWar.csv similarity index 59% rename from benchmark/scripts/scanAColCPP/config_BerCRS.csv rename to benchmark/scripts/scanARow/config_TugOfWar.csv index 14a0cdc1..61ba7a68 100644 --- a/benchmark/scripts/scanAColCPP/config_BerCRS.csv +++ b/benchmark/scripts/scanARow/config_TugOfWar.csv @@ -3,4 +3,5 @@ aRow,1000,U64 aCol,1000,U64 bCol,500,U64 sketchDimension,25,U64 -ptFile,torchscripts/BernoulliCRS.pt,String \ No newline at end of file +ptFile,torchscripts/TugOfWar.pt,String +forceMP,1,U64 diff --git a/benchmark/scripts/scanARow/config_WCR.csv b/benchmark/scripts/scanARow/config_WCR.csv index d9b055fb..f02285a4 100644 --- a/benchmark/scripts/scanARow/config_WCR.csv +++ b/benchmark/scripts/scanARow/config_WCR.csv @@ -3,4 +3,5 @@ aRow,100,U64 aCol,1000,U64 bCol,500,U64 sketchDimension,25,U64 -ptFile,torchscripts/WeightedCR.pt,String \ No newline at end of file +ptFile,torchscripts/WeightedCR.pt,String +forceMP,1,U64 diff --git a/benchmark/scripts/scanARow/drawTogether.py b/benchmark/scripts/scanARow/drawTogether.py index 8078984b..9efed6fa 100755 --- a/benchmark/scripts/scanARow/drawTogether.py +++ b/benchmark/scripts/scanARow/drawTogether.py @@ -124,10 +124,10 @@ def main(): exeSpace = os.path.abspath(os.path.join(os.getcwd(), "../..")) + "/" commonBase = os.path.abspath(os.path.join(os.getcwd(), "../..")) + "/results/" + scanTag + "/" figPath = os.path.abspath(os.path.join(os.getcwd(), "../..")) + "/figures/" + scanTag - methodTags = ["FD-AMM", "Co-AMM", "BCo-AMM", "Couter-sketch", "MM"] - resultPaths = ["fd", "co", "co", "cs", "mm"] - csvTemplates = ["config_FDAMM.csv", "config_CoAMM.csv", "config_BCoAMM.csv", "config_CounterSketch.csv", - "config_RAWMM.csv"] + methodTags = ["Co-AMM", "BCo-AMM", "Count-sketch", "Tug-of-War", "MM"] + resultPaths = ["co", "co", "cs", "tow", "mm"] + csvTemplates = ["config_CoAMM.csv", "config_BCoAMM.csv", "config_CounterSketch.csv", + "config_TugOfWar.csv", "config_RAWMM.csv"] valueVec = [100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000] valueVecDisp = np.array(valueVec) # run @@ -153,9 +153,10 @@ def main(): figPath + "/" + scanTag + "sketch_cacheMiss", True) # sampling - resultPaths = ["crs", "bcrs", "ews", "mm"] - csvTemplates = ["config_CRS.csv", "config_BerCRS.csv", "config_EWS.csv", "config_RAWMM.csv"] - methodTags = ["CRS", "Ber-CRS", "EWS", "MM"] + resultPaths = ["crs", "crsv2", "bcrs", "wcr", "ews", "mm"] + csvTemplates = ["config_CRS.csv", "config_CRSV2.csv", "config_BerCRS.csv", "config_WCR.csv", + "config_EWS.csv", "config_RAWMM.csv"] + methodTags = ["CRS", "CRSV2", "Ber-CRS", "Weighted-CR", "EWS", "MM"] elapsedTimeAll, cacheMissAll, periodAll = compareMethod(exeSpace, commonBase, resultPaths, csvTemplates, valueVec, reRun) groupLine.DrawFigure(periodAll, elapsedTimeAll, diff --git a/benchmark/scripts/scanARowCPP/config_BCoAMM.csv b/benchmark/scripts/scanARowCPP/config_BCoAMM.csv deleted file mode 100644 index b65317af..00000000 --- a/benchmark/scripts/scanARowCPP/config_BCoAMM.csv +++ /dev/null @@ -1,6 +0,0 @@ -key,value,type -aRow,100,U64 -aCol,1000,U64 -bCol,500,U64 -sketchDimension,25,U64 -ptFile,torchscripts/BetaCoOccurringFD.pt,String \ No newline at end of file diff --git a/benchmark/scripts/scanARowCPP/config_BerCRS.csv b/benchmark/scripts/scanARowCPP/config_BerCRS.csv deleted file mode 100644 index d2b758a5..00000000 --- a/benchmark/scripts/scanARowCPP/config_BerCRS.csv +++ /dev/null @@ -1,6 +0,0 @@ -key,value,type -aRow,100,U64 -aCol,1000,U64 -bCol,500,U64 -sketchDimension,25,U64 -ptFile,torchscripts/BernoulliCRS.pt,String \ No newline at end of file diff --git a/benchmark/scripts/scanARowCPP/config_CPPBCOOFD.csv b/benchmark/scripts/scanARowCPP/config_CPPBCOOFD.csv new file mode 100644 index 00000000..d43c92f9 --- /dev/null +++ b/benchmark/scripts/scanARowCPP/config_CPPBCOOFD.csv @@ -0,0 +1,10 @@ +key,value,type +aRow,100,U64 +aCol,1000,U64 +bCol,500,U64 +sketchDimension,25,U64 +ptFile,torchscripts/BetaCoOccurringFD.pt,String +useCPP,1,U64 +cppAlgoTag,bcooFD,String +threads,1,U64 +forceMP,1,U64 diff --git a/benchmark/scripts/scanARowCPP/config_CPPBCRS.csv b/benchmark/scripts/scanARowCPP/config_CPPBCRS.csv new file mode 100644 index 00000000..3b7ee42c --- /dev/null +++ b/benchmark/scripts/scanARowCPP/config_CPPBCRS.csv @@ -0,0 +1,10 @@ +key,value,type +aRow,100,U64 +aCol,1000,U64 +bCol,500,U64 +sketchDimension,25,U64 +ptFile,torchscripts/BernoulliCRS.pt,String +useCPP,1,U64 +cppAlgoTag,bcrs,String +threads,1,U64 +forceMP,1,U64 diff --git a/benchmark/scripts/scanARowCPP/config_CPPCOUNTERSKETCH.csv b/benchmark/scripts/scanARowCPP/config_CPPCOUNTERSKETCH.csv index a06776ab..6823e4e2 100644 --- a/benchmark/scripts/scanARowCPP/config_CPPCOUNTERSKETCH.csv +++ b/benchmark/scripts/scanARowCPP/config_CPPCOUNTERSKETCH.csv @@ -7,4 +7,4 @@ ptFile,torchscripts/CRS.pt,String useCPP,1,U64 cppAlgoTag,countSketch,String threads,1,U64 -forceMP,1,U64 \ No newline at end of file +forceMP,1,U64 diff --git a/benchmark/scripts/scanARowCPP/config_CPPCRSV2.csv b/benchmark/scripts/scanARowCPP/config_CPPCRSV2.csv new file mode 100644 index 00000000..b94e2d2f --- /dev/null +++ b/benchmark/scripts/scanARowCPP/config_CPPCRSV2.csv @@ -0,0 +1,10 @@ +key,value,type +aRow,100,U64 +aCol,1000,U64 +bCol,500,U64 +sketchDimension,25,U64 +ptFile,torchscripts/CRSV2.pt,String +useCPP,1,U64 +cppAlgoTag,crsV2,String +threads,1,U64 +forceMP,1,U64 diff --git a/benchmark/scripts/scanARowCPP/config_CPPINT8.csv b/benchmark/scripts/scanARowCPP/config_CPPINT8.csv new file mode 100644 index 00000000..2b61c43e --- /dev/null +++ b/benchmark/scripts/scanARowCPP/config_CPPINT8.csv @@ -0,0 +1,10 @@ +key,value,type +aRow,100,U64 +aCol,1000,U64 +bCol,500,U64 +sketchDimension,25,U64 +ptFile,torchscripts/FDAMM.pt,String +useCPP,1,U64 +cppAlgoTag,int8,String +threads,1,U64 +forceMP,1,U64 diff --git a/benchmark/scripts/scanARowCPP/config_CPPSMPPCA.csv b/benchmark/scripts/scanARowCPP/config_CPPSMPPCA.csv new file mode 100644 index 00000000..7c3a0223 --- /dev/null +++ b/benchmark/scripts/scanARowCPP/config_CPPSMPPCA.csv @@ -0,0 +1,9 @@ +key,value,type +aRow,10000,U64 +aCol,1000,U64 +bCol,500,U64 +sketchDimension,25,U64 +threads,1,U64 +ptFile,torchscripts/WeightedCR.pt,String +useCPP,1,U64 +cppAlgoTag,smp-pca,String \ No newline at end of file diff --git a/benchmark/scripts/scanARowCPP/config_CPPWeightedCR.csv b/benchmark/scripts/scanARowCPP/config_CPPWeightedCR.csv new file mode 100644 index 00000000..e92a7939 --- /dev/null +++ b/benchmark/scripts/scanARowCPP/config_CPPWeightedCR.csv @@ -0,0 +1,9 @@ +key,value,type +aRow,10000,U64 +aCol,1000,U64 +bCol,500,U64 +sketchDimension,25,U64 +threads,1,U64 +ptFile,torchscripts/WeightedCR.pt,String +useCPP,1,U64 +cppAlgoTag,weighted-cr,String \ No newline at end of file diff --git a/benchmark/scripts/scanARowCPP/config_CRS.csv b/benchmark/scripts/scanARowCPP/config_CRS.csv deleted file mode 100644 index b6afe1ef..00000000 --- a/benchmark/scripts/scanARowCPP/config_CRS.csv +++ /dev/null @@ -1,6 +0,0 @@ -key,value,type -aRow,100,U64 -aCol,1000,U64 -bCol,500,U64 -sketchDimension,25,U64 -ptFile,torchscripts/CRS.pt,String \ No newline at end of file diff --git a/benchmark/scripts/scanARowCPP/config_CoAMM.csv b/benchmark/scripts/scanARowCPP/config_CoAMM.csv deleted file mode 100644 index f41d7ddd..00000000 --- a/benchmark/scripts/scanARowCPP/config_CoAMM.csv +++ /dev/null @@ -1,6 +0,0 @@ -key,value,type -aRow,100,U64 -aCol,1000,U64 -bCol,500,U64 -sketchDimension,25,U64 -ptFile,torchscripts/CoOccurringFD.pt,String \ No newline at end of file diff --git a/benchmark/scripts/scanARowCPP/config_CounterSketch.csv b/benchmark/scripts/scanARowCPP/config_CounterSketch.csv deleted file mode 100644 index 50cf2770..00000000 --- a/benchmark/scripts/scanARowCPP/config_CounterSketch.csv +++ /dev/null @@ -1,6 +0,0 @@ -key,value,type -aRow,100,U64 -aCol,1000,U64 -bCol,500,U64 -sketchDimension,25,U64 -ptFile,torchscripts/CountSketch.pt,String diff --git a/benchmark/scripts/scanARowCPP/config_EWS.csv b/benchmark/scripts/scanARowCPP/config_EWS.csv deleted file mode 100644 index 8e09f17b..00000000 --- a/benchmark/scripts/scanARowCPP/config_EWS.csv +++ /dev/null @@ -1,6 +0,0 @@ -key,value,type -aRow,100,U64 -aCol,1000,U64 -bCol,500,U64 -sketchDimension,25,U64 -ptFile,torchscripts/EWS.pt,String \ No newline at end of file diff --git a/benchmark/scripts/scanARowCPP/config_FDAMM.csv b/benchmark/scripts/scanARowCPP/config_FDAMM.csv deleted file mode 100644 index 18b9efde..00000000 --- a/benchmark/scripts/scanARowCPP/config_FDAMM.csv +++ /dev/null @@ -1,6 +0,0 @@ -key,value,type -aRow,100,U64 -aCol,1000,U64 -bCol,500,U64 -sketchDimension,25,U64 -ptFile,torchscripts/FDAMM.pt,String \ No newline at end of file diff --git a/benchmark/scripts/scanARowCPP/config_RAWMM.csv b/benchmark/scripts/scanARowCPP/config_RAWMM.csv deleted file mode 100644 index aeb092a8..00000000 --- a/benchmark/scripts/scanARowCPP/config_RAWMM.csv +++ /dev/null @@ -1,6 +0,0 @@ -key,value,type -aRow,100,U64 -aCol,1000,U64 -bCol,500,U64 -sketchDimension,25,U64 -ptFile,torchscripts/RAWMM.pt,String \ No newline at end of file diff --git a/benchmark/scripts/scanARowCPP/config_WCR.csv b/benchmark/scripts/scanARowCPP/config_WCR.csv deleted file mode 100644 index d9b055fb..00000000 --- a/benchmark/scripts/scanARowCPP/config_WCR.csv +++ /dev/null @@ -1,6 +0,0 @@ -key,value,type -aRow,100,U64 -aCol,1000,U64 -bCol,500,U64 -sketchDimension,25,U64 -ptFile,torchscripts/WeightedCR.pt,String \ No newline at end of file diff --git a/benchmark/scripts/scanARowCPP/drawTogether.py b/benchmark/scripts/scanARowCPP/drawTogether.py index c67ec677..edcb416a 100755 --- a/benchmark/scripts/scanARowCPP/drawTogether.py +++ b/benchmark/scripts/scanARowCPP/drawTogether.py @@ -135,10 +135,10 @@ def main(): exeSpace = os.path.abspath(os.path.join(os.getcwd(), "../..")) + "/" commonBase = os.path.abspath(os.path.join(os.getcwd(), "../..")) + "/results/" + scanTag + "/" figPath = os.path.abspath(os.path.join(os.getcwd(), "../..")) + "/figures/" + scanTag + "CPP" - methodTags = ["FD-AMM", "Co-AMM", "BCo-AMM", "Couter-sketch", "MM"] - resultPaths = ["fd", "co", "co", "cs", "mm"] - csvTemplates = ["config_FDAMM.csv", "config_CoAMM.csv", "config_BCoAMM.csv", "config_CounterSketch.csv", - "config_RAWMM.csv"] + methodTags = ["Co-AMM", "BCo-AMM", "Count-sketch", "Tug-of-War", "SMP-PCA", "MM"] + resultPaths = ["co", "co", "cs", "tow", "smp-pca", "mm"] + csvTemplates = ["config_CPPCOFD.csv", "config_CPPBCOOFD.csv", "config_CPPCOUNTERSKETCH.csv", + "config_CPPTOW.csv", "config_CPPSMPPCA.csv", "config_CPPMM.csv"] valueVec = [100, 200, 500, 1000, 5000, 10000, 20000, 50000, 100000] valueVecDisp = np.array(valueVec) # run @@ -151,12 +151,37 @@ def main(): os.system("sudo mkdir " + commonBase) reRun = 1 # skech + elapsedTimeAll, cacheMissAll, periodAll, fro, eb = compareMethod(exeSpace, commonBase, resultPaths, csvTemplates, valueVec, + reRun) + groupLine.DrawFigure(periodAll, elapsedTimeAll, + methodTags, + "#elements in A's row", "elapsed time (ms)", 0, 1, + figPath + "/" + scanTag + "sketch_cpp_elapsedTime", + True) + groupLine.DrawFigureYnormal(periodAll, cacheMissAll, + methodTags, + "#elements in A's row", "cacheMiss (%)", 0, 1, + figPath + "/" + scanTag + "sketch_cpp_cacheMiss", + True) + groupLine.DrawFigureYnormal(periodAll, + fro * 100.0, + methodTags, + "#A's row", "normalized error %", 0, 100, figPath + "/" +scanTag + + "sketch_cpp_froError", + True) + groupLine.DrawFigureYnormal(periodAll, + eb * 100.0, + methodTags, + "#A's row", "error bound ratio %", 0, 100, figPath + "/" + scanTag + + "sketch_cpp_ebRatio", + True) # sampling # resultPaths = ["crs", "bcrs", "ews", "mm","mm-cpp","crs-cpp"] - resultPaths = ["mm", "crs","ews","counterSketch","cofd","tow"] - csvTemplates = ["config_CPPMM.csv", "config_CPPCRS.csv","config_CPPEWS.csv","config_CPPCOUNTERSKETCH.csv","config_CPPCOFD.csv","config_CPPTOW.csv"] - methodTags = ["mm", "crs","ews","counterSketch","cofd","tow"] + resultPaths = ["crs", "crsv2", "bcrs", "wcr", "ews", "int8", "mm"] + csvTemplates = ["config_CPPCRS.csv", "config_CPPCRSV2.csv", "config_CPPBCRS.csv", "config_CPPWeightedCR.csv", + "config_CPPEWS.csv", "config_CPPINT8.csv", "config_CPPMM.csv"] + methodTags = ["CRS", "CRSV2", "Ber-CRS", "Weighted-CR", "EWS", "INT8", "MM"] # csvTemplates = ["config_CRS.csv", "config_BerCRS.csv", "config_EWS.csv", "config_RAWMM.csv","config_CPPMM.csv","config_CPPCRS.csv"] # methodTags = ["CRS", "Ber-CRS", "EWS",, "MM","MM_CPP","CRS_CPP"] elapsedTimeAll, cacheMissAll, periodAll,fro,eb = compareMethod(exeSpace, commonBase, resultPaths, csvTemplates, valueVec, @@ -164,22 +189,24 @@ def main(): groupLine.DrawFigure(periodAll, elapsedTimeAll, methodTags, "#A's row", "elapsed time (ms)", 0, 1, - figPath + "/" + scanTag + "cpp_elapsedTime", + figPath + "/" + scanTag + "sampling_cpp_elapsedTime", True) groupLine.DrawFigureYnormal(periodAll, cacheMissAll, methodTags, "#A's row", "cacheMiss (%)", 0, 100, - figPath + "/" + scanTag + "cpp_cacheMiss", + figPath + "/" + scanTag + "sampling_cpp_cacheMiss", True) groupLine.DrawFigureYnormal(periodAll, fro * 100.0, methodTags, - "#A's row", "normalized error %", 0, 100, figPath + "/" +scanTag + "_froError", + "#A's row", "normalized error %", 0, 100, figPath + "/" +scanTag + + "sampling_cpp_froError", True) groupLine.DrawFigureYnormal(periodAll, eb * 100.0, methodTags, - "#A's row", "error bound ratio %", 0, 100, figPath + "/" + scanTag + "_ebRatio", + "#A's row", "error bound ratio %", 0, 100, figPath + "/" + scanTag + + "sampling_cpp_ebRatio", True) # draw2yLine("watermark time (ms)",singleValueVecDisp,lat95Vec,errVec,"95% Latency (ms)","Error","ms","",figPath+"wm_lat") # draw2yLine("watermark time (ms)",singleValueVecDisp,thrVec,errVec,"Throughput (KTp/s)","Error","KTp/s","",figPath+"wm_thr") diff --git a/benchmark/scripts/scanAlgoBeta/OoOCommon.py b/benchmark/scripts/scanAlgoBeta/OoOCommon.py new file mode 100755 index 00000000..70f4cf33 --- /dev/null +++ b/benchmark/scripts/scanAlgoBeta/OoOCommon.py @@ -0,0 +1,125 @@ +import csv +import numpy as np +import matplotlib.pyplot as plt +import itertools as it +import os + +import matplotlib +import matplotlib.pyplot as plt +import numpy as np +import pylab +from matplotlib.font_manager import FontProperties +from matplotlib.ticker import LogLocator, LinearLocator +import os +import pandas as pd +import sys +import matplotlib.ticker as mtick + +OPT_FONT_NAME = 'Helvetica' +TICK_FONT_SIZE = 22 +LABEL_FONT_SIZE = 28 +LEGEND_FONT_SIZE = 30 +LABEL_FP = FontProperties(style='normal', size=LABEL_FONT_SIZE) +LEGEND_FP = FontProperties(style='normal', size=LEGEND_FONT_SIZE) +TICK_FP = FontProperties(style='normal', size=TICK_FONT_SIZE) + +MARKERS = (['*', '|', 'v', "^", "", "h", "<", ">", "+", "d", "<", "|", "", "+", "_"]) +# you may want to change the color map for different figures +COLOR_MAP = ( + '#B03A2E', '#2874A6', '#239B56', '#7D3C98', '#FFFFFF', '#F1C40F', '#F5CBA7', '#82E0AA', '#AEB6BF', '#AA4499') +# you may want to change the patterns for different figures +PATTERNS = (["////", "o", "", "||", "-", "//", "\\", "o", "O", "////", ".", "|||", "o", "---", "+", "\\\\", "*"]) +LABEL_WEIGHT = 'bold' +LINE_COLORS = COLOR_MAP +LINE_WIDTH = 3.0 +MARKER_SIZE = 15.0 +MARKER_FREQUENCY = 1000 + + +def editConfig(src, dest, key, value): + df = pd.read_csv(src, header=None) + rowIdx = 0 + idxt = 0 + for cell in df[0]: + # print(cell) + if (cell == key): + rowIdx = idxt + break + idxt = idxt + 1 + df[1][rowIdx] = str(value) + df.to_csv(dest, index=False, header=False) + + +def readConfig(src, key): + df = pd.read_csv(src, header=None) + rowIdx = 0 + idxt = 0 + for cell in df[0]: + # print(cell) + if (cell == key): + rowIdx = idxt + break + idxt = idxt + 1 + return df[1][rowIdx] + + +def draw2yLine(NAME, Com, R1, R2, l1, l2, m1, m2, fname): + fig, ax1 = plt.subplots(figsize=(10, 6.4)) + lines = [None] * 2 + # ax1.set_ylim(0, 1) + print(Com) + print(R1) + lines[0], = ax1.plot(Com, R1, color=LINE_COLORS[0], \ + linewidth=LINE_WIDTH, marker=MARKERS[0], \ + markersize=MARKER_SIZE + # + ) + + # plt.show() + ax1.set_ylabel(m1, fontproperties=LABEL_FP) + ax1.set_xlabel(NAME, fontproperties=LABEL_FP) + # ax1.set_xticklabels(ax1.get_xticklabels()) # 设置共用的x轴 + plt.xticks(rotation=0, size=TICK_FONT_SIZE) + plt.yticks(rotation=0, size=TICK_FONT_SIZE) + plt.rcParams['axes.unicode_minus'] = False # 用来正常显示负号 + ax2 = ax1.twinx() + + # ax2.set_ylabel('latency/us') + # ax2.set_ylim(0, 0.5) + lines[1], = ax2.plot(Com, R2, color=LINE_COLORS[1], \ + linewidth=LINE_WIDTH, marker=MARKERS[1], \ + markersize=MARKER_SIZE) + + ax2.set_ylabel(m2, fontproperties=LABEL_FP) + # ax2.vlines(192000, min(R2)-1, max(R2)+1, colors = "GREEN", linestyles = "dashed",label='total L1 size') + # plt.grid(axis='y', color='gray') + + # style = dict(size=10, color='black') + # ax2.hlines(tset, 0, x2_list[len(x2_list)-1]+width, colors = "r", linestyles = "dashed",label="tset") + # ax2.text(4, tset, "$T_{set}$="+str(tset)+"us", ha='right', **style) + + # plt.xlabel('batch', fontproperties=LABEL_FP) + + # plt.xscale('log') + # figure.xaxis.set_major_locator(LinearLocator(5)) + ax1.yaxis.set_major_locator(LinearLocator(5)) + ax2.yaxis.set_major_locator(LinearLocator(5)) + ax1.yaxis.set_major_formatter(mtick.FormatStrFormatter('%.1f')) + ax2.yaxis.set_major_formatter(mtick.FormatStrFormatter('%.1f')) + ax1.yaxis.set_major_formatter(mtick.FormatStrFormatter('%.1f')) + ax2.yaxis.set_major_formatter(mtick.FormatStrFormatter('%.1f')) + plt.legend(lines, + [l1, l2], + prop=LEGEND_FP, + loc='upper center', + ncol=1, + bbox_to_anchor=(0.55, 1.3 + ), shadow=False, + columnspacing=0.1, + frameon=True, borderaxespad=-1.5, handlelength=1.2, + handletextpad=0.1, + labelspacing=0.1) + plt.yticks(rotation=0, size=TICK_FONT_SIZE) + plt.tight_layout() + + plt.savefig(fname + ".pdf") diff --git a/benchmark/scripts/scanAlgoBeta/accuBar.py b/benchmark/scripts/scanAlgoBeta/accuBar.py new file mode 100755 index 00000000..638c8a60 --- /dev/null +++ b/benchmark/scripts/scanAlgoBeta/accuBar.py @@ -0,0 +1,328 @@ +import getopt +import os +import sys + +import matplotlib +import matplotlib.pyplot as plt +import numpy as np +import pylab +from matplotlib.font_manager import FontProperties +from matplotlib.ticker import LinearLocator, LogLocator, MaxNLocator, ScalarFormatter +from numpy import double + +OPT_FONT_NAME = 'Helvetica' +TICK_FONT_SIZE = 24 +LABEL_FONT_SIZE = 28 +LEGEND_FONT_SIZE = 26 +TITLE_FRONT_SIZE = 32 +LABEL_FP = FontProperties(style='normal', size=LABEL_FONT_SIZE) +LEGEND_FP = FontProperties(style='normal', size=LEGEND_FONT_SIZE) +TICK_FP = FontProperties(style='normal', size=TICK_FONT_SIZE) +TITLE_FP = FontProperties(style='normal', size=TITLE_FRONT_SIZE) +MARKERS = (['o', 's', 'v', "^", "h", "v", ">", "x", "d", "<", "|", "", "|", "_"]) +# you may want to change the color map for different figures +COLOR_MAP = ('#B03A2E', '#2874A6', '#239B56', '#7D3C98', '#F1C40F', '#F5CBA7', '#82E0AA', '#AEB6BF', '#AA4499') +# you may want to change the patterns for different figures +PATTERNS = (["\\", "///", "o", "||", "\\\\", "\\\\", "//////", "//////", ".", "\\\\\\", "\\\\\\"]) +LABEL_WEIGHT = 'bold' +LINE_COLORS = COLOR_MAP +LINE_WIDTH = 3.0 +MARKER_SIZE = 0.0 +MARKER_FREQUENCY = 1000 + +matplotlib.rcParams['ps.useafm'] = True +matplotlib.rcParams['pdf.use14corefonts'] = True +matplotlib.rcParams['xtick.labelsize'] = TICK_FONT_SIZE +matplotlib.rcParams['ytick.labelsize'] = TICK_FONT_SIZE +matplotlib.rcParams['font.family'] = OPT_FONT_NAME +matplotlib.rcParams['pdf.fonttype'] = 42 + +exp_dir = "/data1/xtra" + +FIGURE_FOLDER = exp_dir + '/results/figure' + + +# there are some embedding problems if directly exporting the pdf figure using matplotlib. +# so we generate the eps format first and convert it to pdf. +def ConvertEpsToPdf(dir_filename): + os.system("epstopdf --outfile " + dir_filename + ".pdf " + dir_filename + ".eps") + os.system("rm -rf " + dir_filename + ".eps") + + +class ScalarFormatterForceFormat(ScalarFormatter): + def _set_format(self): # Override function that finds format to use. + self.format = "%1.1f" # Give format here + + +# draw a line chart +def DrawFigure(x_values, y_values, legend_labels, x_label, y_label, filename, allow_legend, title): + # you may change the figure size on your own. + + fig = plt.figure(figsize=(16, 9)) + figure = fig.add_subplot(111) + + FIGURE_LABEL = legend_labels + + # if not os.path.exists(FIGURE_FOLDER): + # os.makedirs(FIGURE_FOLDER) + + # values in the x_xis + index = np.arange(len(x_values)) + # the bar width. + # you may need to tune it to get the best figure. + width = 0.5 + # draw the bars + bottom_base = np.zeros(len(y_values[0])) + bars = [None] * (len(FIGURE_LABEL)) + for i in range(len(y_values)): + bars[i] = plt.bar(index + width / 2, y_values[i], width, hatch=PATTERNS[i], color=LINE_COLORS[i], + label=FIGURE_LABEL[i], bottom=bottom_base, edgecolor='black', linewidth=3) + bottom_base = np.array(y_values[i]) + bottom_base + + # sometimes you may not want to draw legends. + if allow_legend == True: + plt.legend(bars, FIGURE_LABEL + # mode='expand', + # shadow=False, + # columnspacing=0.25, + # labelspacing=-2.2, + # borderpad=5, + # bbox_transform=ax.transAxes, + # frameon=False, + # columnspacing=5.5, + # handlelength=2, + ) + if allow_legend == True: + handles, labels = figure.get_legend_handles_labels() + if allow_legend == True: + leg = plt.legend(handles[::-1], labels[::-1], + loc='upper center', + # prop=#LEGEND_FP, + # ncol=3, + # bbox_to_anchor=(0.5, 1.25), + # bbox_to_anchor=(1.17, 0.5), + # handletextpad=0.1, + # borderaxespad=0.0, + # handlelength=1.8, + # labelspacing=0.3, + # columnspacing=0.3, + ) + leg.get_frame().set_linewidth(2) + leg.get_frame().set_edgecolor("black") + + # you may need to tune the xticks position to get the best figure. + plt.xticks(index + 0.6 * width, x_values) + yfmt = ScalarFormatterForceFormat() + yfmt.set_powerlimits((0, 0)) + figure.get_yaxis().set_major_formatter(yfmt) + plt.ticklabel_format(axis="y", style="sci", scilimits=(0, 0), useMathText=True) + plt.grid(axis='y', color='gray') + figure.yaxis.set_major_locator(LinearLocator(3)) + # figure.yaxis.set_major_locator(LogLocator(base=10)) + # figure.yaxis.set_major_locator(LinearLocator(6)) + + figure.get_xaxis().set_tick_params(direction='in', pad=10) + figure.get_yaxis().set_tick_params(direction='in', pad=10) + + plt.xlabel(x_label, fontproperties=LABEL_FP) + plt.ylabel(y_label, fontproperties=LABEL_FP) + + size = fig.get_size_inches() + dpi = fig.get_dpi() + plt.title(title, fontproperties=TITLE_FP) + plt.savefig(filename + ".pdf", bbox_inches='tight', format='pdf') + + +def DrawLegend(legend_labels, filename): + fig = pylab.figure() + ax1 = fig.add_subplot(111) + FIGURE_LABEL = legend_labels + LEGEND_FP = FontProperties(style='normal', size=26) + + bars = [None] * (len(FIGURE_LABEL)) + data = [1] + x_values = [1] + + width = 0.3 + for i in range(len(FIGURE_LABEL)): + bars[i] = ax1.bar(x_values, data, width, hatch=PATTERNS[i], color=LINE_COLORS[i], + linewidth=0.2) + + # LEGEND + figlegend = pylab.figure(figsize=(11, 0.5)) + figlegend.legend(bars, FIGURE_LABEL, prop=LEGEND_FP, \ + loc=9, + bbox_to_anchor=(0, 0.4, 1, 1), + ncol=len(FIGURE_LABEL), mode="expand", shadow=False, \ + frameon=False, handlelength=1.1, handletextpad=0.2, columnspacing=0.1) + + figlegend.savefig(FIGURE_FOLDER + '/' + filename + '.pdf') + + +def normalize(y_values): + y_total_values = np.zeros(len(y_values[0])) + + for i in range(len(y_values)): + y_total_values += np.array(y_values[i]) + y_norm_values = [] + + for i in range(len(y_values)): + y_norm_values.append(np.array(y_values[i]) / (y_total_values) * 100) + return y_norm_values + + +# example for reading csv file +def ReadFile(id): + # Creates a list containing w lists, each of h items, all set to 0 + w, h = 5, 3 + y = [[0 for x in range(w)] for y in range(h)] + # print(matches) + max_value = 0 + j = 0 + bound = id + 1 * w + for i in range(id, bound, 1): + cnt = 0 + print(i) + f = open(exp_dir + "/results/breakdown/PMJ_JBCR_NP_{}.txt".format(i), "r") + read = f.readlines() + others = 0 + for x in read: + value = double(x.strip("\n")) + if value > max_value: + max_value = value + elif cnt == 3: # sort + y[0][j] = value + elif cnt == 4: # merge + y[1][j] = value + elif cnt == 5: # join + y[2][j] = value + else: + others += value + # if cnt == 6: + # y[2][j] = others + cnt += 1 + j += 1 + print(y) + return y, max_value + + +if __name__ == "__main__": + id = 119 + try: + opts, args = getopt.getopt(sys.argv[1:], '-i:h', ['test id', 'help']) + except getopt.GetoptError: + print('breakdown.py -id testid') + sys.exit(2) + for opt, opt_value in opts: + if opt in ('-h', '--help'): + print("[*] Help info") + exit() + elif opt == '-i': + print('Test ID:', opt_value) + id = (int)(opt_value) + + x_values = ['10%', '20%', '30%', '40%', '50%'] # sorting step size + + y_values, max_value = ReadFile(id) # 55 + + # y_norm_values = normalize(y_values) + + # break into 4 parts + legend_labels = ['sort', 'merge', 'join'] # , 'others' + + DrawFigure(x_values, y_values, legend_labels, + 'sorting step size', 'cycles per input tuple', + 'breakdown_sort_figure', True) + + # DrawLegend(legend_labels, 'breakdown_radix_legend') + + +def DrawPercentageFigure(x_values, y_values, legend_labels, x_label, y_label, filename, allow_legend, title): + # you may change the figure size on your own. + fig = plt.figure(figsize=(9, 3)) + figure = fig.add_subplot(111) + + FIGURE_LABEL = legend_labels + + # values in the x_xis + index = np.arange(len(x_values)) + # the bar width. + # you may need to tune it to get the best figure. + width = 0.5 + # draw the bars + bottom_base = np.zeros(len(y_values[0])) + bars = [None] * (len(FIGURE_LABEL)) + for i in range(len(y_values)): + bars[i] = plt.bar(index + width / 2, y_values[i], width, hatch=PATTERNS[i], color=LINE_COLORS[i], + label=FIGURE_LABEL[i], bottom=bottom_base, edgecolor='black', linewidth=3) + bottom_base = np.array(y_values[i]) + bottom_base + + # sometimes you may not want to draw legends. + if allow_legend == True: + plt.legend(bars, FIGURE_LABEL + # mode='expand', + # shadow=False, + # columnspacing=0.25, + # labelspacing=-2.2, + # borderpad=5, + # bbox_transform=ax.transAxes, + # frameon=False, + # columnspacing=5.5, + # handlelength=2, + ) + if allow_legend == True: + handles, labels = figure.get_legend_handles_labels() + if allow_legend == True: + print(handles[::-1], labels[::-1]) + leg = plt.legend(handles[::-1], labels[::-1], + loc='center', + prop=LEGEND_FP, + ncol=3, + bbox_to_anchor=(0.5, 1.2), + handletextpad=0.1, + borderaxespad=0.0, + handlelength=1.8, + labelspacing=0.3, + columnspacing=0.3, + ) + leg.get_frame().set_linewidth(2) + leg.get_frame().set_edgecolor("black") + + # sometimes you may not want to draw legends. + # if allow_legend == True: + # leg=plt.legend(bars, + # FIGURE_LABEL, + # prop=LEGEND_FP, + # loc='right', + # ncol=1, + # # mode='expand', + # bbox_to_anchor=(0.45, 1.1), shadow=False, + # columnspacing=0.1, + # frameon=True, borderaxespad=0.0, handlelength=1.5, + # handletextpad=0.1, + # labelspacing=0.1) + # leg.get_frame().set_linewidth(2) + # leg.get_frame().set_edgecolor("black") + + plt.ylim(0, 100) + + # you may need to tune the xticks position to get the best figure. + plt.xticks(index + 0.5 * width, x_values) + plt.xticks(rotation=30) + + # plt.xlim(0,) + # plt.ylim(0,1) + + plt.grid(axis='y', color='gray') + figure.yaxis.set_major_locator(LinearLocator(6)) + + figure.get_xaxis().set_tick_params(direction='in', pad=10) + figure.get_yaxis().set_tick_params(direction='in', pad=10) + + plt.xlabel(x_label, fontproperties=LABEL_FP) + plt.ylabel(y_label, fontproperties=LABEL_FP) + + size = fig.get_size_inches() + dpi = fig.get_dpi() + + plt.savefig(filename + ".pdf", bbox_inches='tight', format='pdf') diff --git a/benchmark/scripts/scanAlgoBeta/autoParase.py b/benchmark/scripts/scanAlgoBeta/autoParase.py new file mode 100755 index 00000000..9375c8e0 --- /dev/null +++ b/benchmark/scripts/scanAlgoBeta/autoParase.py @@ -0,0 +1,87 @@ +import csv + + +def paraseValidStageNames(a): + nameList = [] + with open(a, 'r') as f: + reader = csv.reader(f) + # reader = [each for each in csv.DictReader(f, delimiter=',')] + result = list(reader) + rows = len(result) + # print('rows=',rows) + firstRow = result[0] + # print(firstRow) + index = 0 + # define what may attract our interest + idxCpu = 0 + idxName = 0 + for i in firstRow: + # print(i) + if (i == 'cpu'): + idxCpu = index + if (i == 'name'): + idxName = index + index = index + 1 + # read the valid stages + vdataEntries = 0 + + for k in range(1, rows): + if (result[k][idxCpu] != 'NA'): + R1 = ((result[k][idxName])) + nameList.append(R1) + return nameList + + +def paraseValidColums(a, nameList, colTitle): + with open(a, 'r') as f: + reader = csv.reader(f) + # reader = [each for each in csv.DictReader(f, delimiter=',')] + result = list(reader) + rows = len(result) + # print('rows=',rows) + firstRow = result[0] + # print(firstRow) + index = 0 + # define what may attract our interest + idxCpu = 0 + idxName = 0 + idxTitle = 0 + for i in firstRow: + # print(i) + if (i == 'cpu'): + idxCpu = index + if (i == 'name'): + idxName = index + if (i == colTitle): + idxTitle = index + index = index + 1 + # read the valid stages + vdataEntries = 0 + ru = [] + for k in range(1, rows): + if (result[k][idxCpu] != 'NA'): + R1 = ((result[k][idxName])) + for j in range(len(nameList)): + if (R1 == nameList[j]): + s = int(result[k][idxTitle]) + ru.append(s) + break + return ru + + +def maxInList(a): + # a in [[1,2] [3,4]] + inLen = len(a[0]) + ru = [] + index = [] + ti = 0 + for i in range(len(a[0])): + ts = 0 + ti = 0 + for k in range(len(a)): + if (a[k][i] > ts): + ts = a[k][i] + ti = k + ru.append(ts) + index.append(ti) + return ru, index diff --git a/benchmark/scripts/scanAlgoBeta/config_CPPBCOOFD.csv b/benchmark/scripts/scanAlgoBeta/config_CPPBCOOFD.csv new file mode 100644 index 00000000..3db65119 --- /dev/null +++ b/benchmark/scripts/scanAlgoBeta/config_CPPBCOOFD.csv @@ -0,0 +1,11 @@ +key,value,type +aRow,100,U64 +aCol,1000,U64 +bCol,500,U64 +sketchDimension,25,U64 +ptFile,torchscripts/BetaCoOccurringFD.pt,String +useCPP,1,U64 +cppAlgoTag,bcooFD,String +threads,1,U64 +forceMP,1,U64 +algoBeta,1.0,Double diff --git a/benchmark/scripts/scanAlgoBeta/config_RAWMM.csv b/benchmark/scripts/scanAlgoBeta/config_RAWMM.csv new file mode 100644 index 00000000..db4593f3 --- /dev/null +++ b/benchmark/scripts/scanAlgoBeta/config_RAWMM.csv @@ -0,0 +1,9 @@ +key,value,type +aRow,1000,U64 +aCol,1000,U64 +bCol,500,U64 +sketchDimension,25,U64 +ptFile,torchscripts/RAWMM.pt,String +threads,1,U64 +forceMP,1,U64 +algoBeta,1.0,Double diff --git a/benchmark/scripts/scanAlgoBeta/drawTogether.py b/benchmark/scripts/scanAlgoBeta/drawTogether.py new file mode 100755 index 00000000..203b84f4 --- /dev/null +++ b/benchmark/scripts/scanAlgoBeta/drawTogether.py @@ -0,0 +1,178 @@ +#!/usr/bin/env python3 +import csv +import numpy as np +import accuBar as accuBar +import groupBar as groupBar +import groupBar2 as groupBar2 +import groupLine as groupLine +from autoParase import * +import itertools as it +import os + +import matplotlib +import numpy as np +import pylab +import matplotlib.font_manager as fm +from matplotlib.font_manager import FontProperties +from matplotlib.ticker import LogLocator, LinearLocator +import os +import pandas as pd +import sys +from OoOCommon import * +import time + +# OPT_FONT_NAME = 'Helvetica' +TICK_FONT_SIZE = 22 +LABEL_FONT_SIZE = 28 +LEGEND_FONT_SIZE = 30 +LABEL_FP = FontProperties(style='normal', size=LABEL_FONT_SIZE) +LEGEND_FP = FontProperties(style='normal', size=LEGEND_FONT_SIZE) +TICK_FP = FontProperties(style='normal', size=TICK_FONT_SIZE) + +MARKERS = (['*', '|', 'v', "^", "", "h", "<", ">", "+", "d", "<", "|", "", "+", "_"]) +# you may want to change the color map for different figures +COLOR_MAP = ( + '#B03A2E', '#2874A6', '#239B56', '#7D3C98', '#FFFFFF', '#F1C40F', '#F5CBA7', '#82E0AA', '#AEB6BF', '#AA4499') +# you may want to change the patterns for different figures +PATTERNS = (["////", "o", "", "||", "-", "//", "\\", "o", "O", "////", ".", "|||", "o", "---", "+", "\\\\", "*"]) +LABEL_WEIGHT = 'bold' +LINE_COLORS = COLOR_MAP +LINE_WIDTH = 3.0 +MARKER_SIZE = 15.0 +MARKER_FREQUENCY = 1000 + +matplotlib.rcParams['ps.useafm'] = True +matplotlib.rcParams['pdf.use14corefonts'] = True +matplotlib.rcParams['xtick.labelsize'] = TICK_FONT_SIZE +matplotlib.rcParams['ytick.labelsize'] = TICK_FONT_SIZE +matplotlib.rcParams['font.family'] = OPT_FONT_NAME +matplotlib.rcParams['pdf.fonttype'] = 42 + +scanTag = "algoBeta" + + +def singleRun(exePath, singleValue, resultPath, configTemplate): + # resultFolder="singleValueTests" + configFname = "config_" + scanTag + str(singleValue) + ".csv" + # configTemplate = "config.csv" + # clear old files + os.system("cd " + exePath + "&& sudo rm *.csv") + + # editConfig(configTemplate, exePath + configFname, "earlierEmitMs", 0) + editConfig(configTemplate, exePath + configFname, scanTag, singleValue) + # prepare new file + # run + os.system("cd " + exePath + "&& sudo ./benchmark " + configFname) + # copy result + os.system("sudo rm -rf " + resultPath + "/" + str(singleValue)) + os.system("sudo mkdir " + resultPath + "/" + str(singleValue)) + os.system("cd " + exePath + "&& sudo cp *.csv " + resultPath + "/" + str(singleValue)) + + +def runScanVector(exePath, singleValueVec, resultPath, templateName="config.csv"): + for i in singleValueVec: + singleRun(exePath, i, resultPath, templateName) + + +def readResultSingle(singleValue, resultPath): + resultFname = resultPath + "/" + str(singleValue) + "/default.csv" + elapsedTime = readConfig(resultFname, "perfElapsedTime") + cacheMiss = readConfig(resultFname, "cacheMiss") + cacheRefs = readConfig(resultFname, "cacheRefs") + froError = readConfig(resultFname, "froError") + errorBoundRatio = readConfig(resultFname, "errorBoundRatio") + return elapsedTime, cacheMiss, cacheRefs, froError, errorBoundRatio + + +def cleanPath(path): + os.system("sudo rm -rf " + path) + os.system("sudo mkdir " + path) + + +def readResultVector(singleValueVec, resultPath): + elapseTimeVec = [] + cacheMissVec = [] + cacheRefVec = [] + froErrorVec = [] + errorBoundRatioVec = [] + for i in singleValueVec: + elapsedTime, cacheMiss, cacheRefs, froError, errorBoundRatio = readResultSingle(i, resultPath) + elapseTimeVec.append(float(elapsedTime) / 1000.0) + cacheMissVec.append(float(cacheMiss)) + cacheRefVec.append(float(cacheRefs)) + froErrorVec.append(float(froError)) + errorBoundRatioVec.append(float(errorBoundRatio)) + return np.array(elapseTimeVec), np.array(cacheMissVec), np.array(cacheRefVec), np.array(froErrorVec), np.array( + errorBoundRatioVec) + + +def compareMethod(exeSpace, commonPathBase, resultPaths, csvTemplates, periodVec, reRun=1): + elapsedTimeAll = [] + cacheMissAll = [] + cacheRefAll = [] + periodAll = [] + froAll = [] + errorBoundRatioAll = [] + for i in range(len(csvTemplates)): + resultPath = commonPathBase + resultPaths[i] + if (reRun == 1): + os.system("sudo rm -rf " + resultPath) + os.system("sudo mkdir " + resultPath) + runScanVector(exeSpace, periodVec, resultPath, csvTemplates[i]) + elapsedTime, cacheMiss, cacheRef, fro, eb = readResultVector(periodVec, resultPath) + elapsedTimeAll.append(elapsedTime) + cacheMissAll.append(cacheMiss) + cacheRefAll.append(cacheRef) + periodAll.append(periodVec) + cacheMissRateAll = np.array(cacheMissAll) / np.array(cacheRefAll) * 100.0 + froAll.append(fro) + errorBoundRatioAll.append(eb) + # periodAll.append(periodVec) + return np.array(elapsedTimeAll), cacheMissRateAll, periodAll, np.array(froAll), np.array(errorBoundRatioAll) + + +def main(): + exeSpace = os.path.abspath(os.path.join(os.getcwd(), "../..")) + "/" + commonBase = os.path.abspath(os.path.join(os.getcwd(), "../..")) + "/results/" + scanTag + "/" + figPath = os.path.abspath(os.path.join(os.getcwd(), "../..")) + "/figures/" + scanTag + methodTags = ["BCo-AMM", "MM"] + resultPaths = ["co", "mm"] + csvTemplates = ["config_CPPBCOOFD.csv", "config_RAWMM.csv"] + valueVec = [1.0, 5.0, 10.0, 15.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 88.0] + valueVecDisp = np.array(valueVec) + # run + reRun = 0 + if (len(sys.argv) < 2): + os.system("mkdir ../../results") + os.system("mkdir ../../figures") + os.system("mkdir " + figPath) + os.system("sudo rm -rf " + commonBase) + os.system("sudo mkdir " + commonBase) + reRun = 1 + + elapsedTimeAll, cacheMissAll, periodAll,fro,eb = compareMethod(exeSpace, commonBase, resultPaths, csvTemplates, valueVec, + reRun) + groupLine.DrawFigure(periodAll, elapsedTimeAll, + methodTags, + "value of beta", "elapsed time (ms)", 0, 1, + figPath + "/" + scanTag + "_elapsedTime", + True) + groupLine.DrawFigureYnormal(periodAll, cacheMissAll, + methodTags, + "value of beta", "cacheMiss (%)", 0, 1, + figPath + "/" + scanTag + "_cacheMiss", + True) + groupLine.DrawFigureYnormal(periodAll, + fro * 100.0, + methodTags, + "value of beta", "normalized error %", 0, 1, figPath + "/" +scanTag + "_froError", + True) + groupLine.DrawFigureYnormal(periodAll, + eb * 100.0, + methodTags, + "value of beta", "error bound ratio %", 0, 1, figPath + "/" + scanTag + "_ebRatio", + True) + + +if __name__ == "__main__": + main() diff --git a/benchmark/scripts/scanAlgoBeta/groupBar.py b/benchmark/scripts/scanAlgoBeta/groupBar.py new file mode 100755 index 00000000..ef2d9842 --- /dev/null +++ b/benchmark/scripts/scanAlgoBeta/groupBar.py @@ -0,0 +1,236 @@ +import itertools as it +import os + +import matplotlib +import matplotlib.pyplot as plt +import numpy as np +import pylab +from matplotlib.font_manager import FontProperties +from matplotlib.ticker import LogLocator, LinearLocator + +OPT_FONT_NAME = 'Helvetica' +TICK_FONT_SIZE = 24 +LABEL_FONT_SIZE = 28 +LEGEND_FONT_SIZE = 15 +LABEL_FP = FontProperties(style='normal', size=LABEL_FONT_SIZE) +LEGEND_FP = FontProperties(style='normal', size=LEGEND_FONT_SIZE) +TICK_FP = FontProperties(style='normal', size=TICK_FONT_SIZE) + +MARKERS = (["", 'o', 's', 'v', "^", "", "h", "<", ">", "+", "d", "<", "|", "", "+", "_"]) +# you may want to change the color map for different figures +COLOR_MAP = ( + '#7FFFFF', '#B03A2E', '#2874A6', '#FFFFFF', '#7FFFFF', '#B03A2E', '#2874A6', '#FFFFFF', '#F5CBA7', '#82E0AA', + '#AEB6BF', + '#AA4499') +# you may want to change the patterns for different figures +PATTERNS = ( + ["////", "\\\\", "//", "o", "*", "||", "-", "//", "\\", "o", "O", "////", ".", "|||", "o", "---", "+", "\\\\", "*"]) +LABEL_WEIGHT = 'bold' +LINE_COLORS = COLOR_MAP +LINE_WIDTH = 3.0 +MARKER_SIZE = 15.0 +MARKER_FREQUENCY = 1000 + +matplotlib.rcParams['ps.useafm'] = True +matplotlib.rcParams['pdf.use14corefonts'] = True +matplotlib.rcParams['xtick.labelsize'] = TICK_FONT_SIZE +matplotlib.rcParams['ytick.labelsize'] = TICK_FONT_SIZE +matplotlib.rcParams['font.family'] = OPT_FONT_NAME +matplotlib.rcParams['pdf.fonttype'] = 42 + +exp_dir = "/data1/xtra" + +FIGURE_FOLDER = exp_dir + '/results/figure' + + +def DrawLegend(legend_labels, filename): + fig = pylab.figure() + ax1 = fig.add_subplot(111) + FIGURE_LABEL = legend_labels + LEGEND_FP = FontProperties(style='normal', size=26) + figlegend = pylab.figure(figsize=(16, 0.5)) + bars = [None] * (len(FIGURE_LABEL)) + data = [1] + x_values = [1] + + width = 0.3 + for i in range(len(FIGURE_LABEL)): + bars[i] = ax1.bar(x_values, data, width, + hatch=PATTERNS[i], + color=LINE_COLORS[i], + label=FIGURE_LABEL[i], + edgecolor='black', linewidth=3) + + # LEGEND + + figlegend.legend(bars, FIGURE_LABEL, prop=LEGEND_FP, \ + loc=1, ncol=len(FIGURE_LABEL), mode="expand", shadow=True, \ + frameon=True, handlelength=2, handletextpad=0.3, columnspacing=0.5, + borderaxespad=-0.2, fancybox=True + ) + figlegend.savefig(FIGURE_FOLDER + '/' + filename + '.pdf') + + +# draw a bar chart +def DrawFigure(x_values, y_values, legend_labels, x_label, y_label, y_min, y_max, filename, allow_legend): + # you may change the figure size on your own. + fig = plt.figure(figsize=(10, 3)) + figure = fig.add_subplot(111) + + FIGURE_LABEL = legend_labels + + # values in the x_xis + index = np.arange(len(x_values)) + # the bar width. + # you may need to tune it to get the best figure. + width = 0.08 + # draw the bars + bars = [] + ts = 0 + pos = 0 + gl = len(y_values[0]) + for i in range(len(y_values)): + pos = pos + 3 * width + for j in range(len(y_values[i])): + pos = pos + width + bar = plt.bar(pos, y_values[i][j], width, hatch=PATTERNS[j], color=LINE_COLORS[j], label=FIGURE_LABEL[j], + edgecolor='black', linewidth=3) + bars.append(bar) + ts = ts + 1 + + # sometimes you may not want to draw legends. + if allow_legend == True: + plt.legend(bars, FIGURE_LABEL, + prop=LEGEND_FP, + ncol=4, + loc='upper center', + # mode='expand', + shadow=False, + bbox_to_anchor=(0.45, 1.6), + columnspacing=0.1, + handletextpad=0.2, + # bbox_transform=ax.transAxes, + # frameon=True, + # columnspacing=5.5, + # handlelength=2, + ) + + # you may need to tune the xticks position to get the best figure. + plt.xticks(index, x_values) + # plt.ticklabel_format(axis="y", style="sci", scilimits=(0, 0)) + # plt.grid(axis='y', color='gray') + # figure.get_xaxis().set_major_formatter(matplotlib.ticker.ScalarFormatter()) + + # you may need to tune the xticks position to get the best figure. + # plt.yscale('log') + # + # plt.grid(axis='y', color='gray') + figure.yaxis.set_major_locator(LinearLocator(5)) + # figure.xaxis.set_major_locator(LinearLocator(5)) + figure.get_xaxis().set_tick_params(direction='in', pad=10) + figure.get_yaxis().set_tick_params(direction='in', pad=10) + + plt.xlabel(x_label, fontproperties=LABEL_FP) + plt.ylabel(y_label, fontproperties=LABEL_FP) + plt.ylim(y_min, y_max) + plt.savefig(filename + ".pdf", bbox_inches='tight') + + +# example for reading csv file +def ReadFile(): + y = [] + col1 = [] + col2 = [] + col3 = [] + col4 = [] + col5 = [] + col6 = [] + col7 = [] + col8 = [] + col9 = [] + + for id in it.chain(range(38, 42)): + col9.append(0) + y.append(col9) # this is a lz4_pipe2 empty line to separate eager and lazy. + + for id in it.chain(range(38, 42)): + file = exp_dir + '/results/latency/NPJ_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(int(len(read) * 0.95)).strip("\n")) # get the 99th timestamp + col1.append(x) + y.append(col1) + + for id in it.chain(range(38, 42)): + file = exp_dir + '/results/latency/PRJ_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(int(len(read) * 0.95)).strip("\n")) # get the 99th timestamp + col2.append(x) + y.append(col2) + + for id in it.chain(range(38, 42)): + file = exp_dir + '/results/latency/MWAY_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(int(len(read) * 0.95)).strip("\n")) # get the 99th timestamp + col3.append(x) + y.append(col3) + + for id in it.chain(range(38, 42)): + file = exp_dir + '/results/latency/MPASS_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(int(len(read) * 0.95)).strip("\n")) # get the 99th timestamp + col4.append(x) + y.append(col4) + + y.append(col9) # this is a lz4_pipe2 empty line to separate eager and lazy. + + for id in it.chain(range(38, 42)): + file = exp_dir + '/results/latency/SHJ_JM_NP_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(int(len(read) * 0.95)).strip("\n")) # get last timestamp + col5.append(x) + y.append(col5) + + for id in it.chain(range(38, 42)): + file = exp_dir + '/results/latency/SHJ_JBCR_NP_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(int(len(read) * 0.95)).strip("\n")) # get last timestamp + col6.append(x) + y.append(col6) + + for id in it.chain(range(38, 42)): + file = exp_dir + '/results/latency/PMJ_JM_NP_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(int(len(read) * 0.95)).strip("\n")) # get last timestamp + col7.append(x) + y.append(col7) + + for id in it.chain(range(38, 42)): + file = exp_dir + '/results/latency/PMJ_JBCR_NP_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(int(len(read) * 0.95)).strip("\n")) # get last timestamp + col8.append(x) + y.append(col8) + return y + + +if __name__ == "__main__": + x_values = ["Stock", "Rovio", "YSB", "DEBS"] + + y_values = ReadFile() + + legend_labels = ['Lazy:', 'NPJ', 'PRJ', 'MWAY', 'MPASS', + 'Eager:', 'SHJ$^{JM}$', 'SHJ$^{JB}$', 'PMJ$^{JM}$', 'PMJ$^{JB}$'] + print(y_values) + DrawFigure(x_values, y_values, legend_labels, + '', 'Latency (ms)', 0, + 400, 'latency_figure_app', False) + + # DrawLegend(legend_labels, 'latency_legend') diff --git a/benchmark/scripts/scanAlgoBeta/groupBar2.py b/benchmark/scripts/scanAlgoBeta/groupBar2.py new file mode 100755 index 00000000..31155695 --- /dev/null +++ b/benchmark/scripts/scanAlgoBeta/groupBar2.py @@ -0,0 +1,232 @@ +import itertools as it +import os + +import matplotlib +import matplotlib.pyplot as plt +import numpy as np +import pylab +from matplotlib.font_manager import FontProperties +from matplotlib.ticker import LogLocator, LinearLocator + +OPT_FONT_NAME = 'Helvetica' +TICK_FONT_SIZE = 24 +LABEL_FONT_SIZE = 28 +LEGEND_FONT_SIZE = 30 +LABEL_FP = FontProperties(style='normal', size=LABEL_FONT_SIZE) +LEGEND_FP = FontProperties(style='normal', size=LEGEND_FONT_SIZE) +TICK_FP = FontProperties(style='normal', size=TICK_FONT_SIZE) + +MARKERS = (["", 'o', 's', 'v', "^", "", "h", "<", ">", "+", "d", "<", "|", "", "+", "_"]) +# you may want to change the color map for different figures +COLOR_MAP = ( + '#FFFFFF', '#B03A2E', '#2874A6', '#239B56', '#7D3C98', '#00FFFF', '#F1C40F', '#F5CBA7', '#82E0AA', '#AEB6BF', + '#AA4499') +# you may want to change the patterns for different figures +PATTERNS = ( + ["", "////", "\\\\", "//", "o", "", "||", "-", "//", "\\", "o", "O", "////", ".", "|||", "o", "---", "+", "\\\\", + "*"]) +LABEL_WEIGHT = 'bold' +LINE_COLORS = COLOR_MAP +LINE_WIDTH = 3.0 +MARKER_SIZE = 15.0 +MARKER_FREQUENCY = 1000 + +matplotlib.rcParams['ps.useafm'] = True +matplotlib.rcParams['pdf.use14corefonts'] = True +matplotlib.rcParams['xtick.labelsize'] = TICK_FONT_SIZE +matplotlib.rcParams['ytick.labelsize'] = TICK_FONT_SIZE +matplotlib.rcParams['font.family'] = OPT_FONT_NAME +matplotlib.rcParams['pdf.fonttype'] = 42 + +exp_dir = "/data1/xtra" + +FIGURE_FOLDER = exp_dir + '/results/figure' + + +def DrawLegend(legend_labels, filename): + fig = pylab.figure() + ax1 = fig.add_subplot(111) + FIGURE_LABEL = legend_labels + LEGEND_FP = FontProperties(style='normal', size=26) + figlegend = pylab.figure(figsize=(16, 0.5)) + bars = [None] * (len(FIGURE_LABEL)) + data = [1] + x_values = [1] + + width = 0.3 + for i in range(len(FIGURE_LABEL)): + bars[i] = ax1.bar(x_values, data, width, + hatch=PATTERNS[i], + color=LINE_COLORS[i], + label=FIGURE_LABEL[i], + edgecolor='black', linewidth=3) + + # LEGEND + + figlegend.legend(bars, FIGURE_LABEL, prop=LEGEND_FP, \ + loc=1, ncol=len(FIGURE_LABEL), mode="expand", shadow=True, \ + frameon=True, handlelength=2, handletextpad=0.3, columnspacing=0.5, + borderaxespad=-0.2, fancybox=True + ) + figlegend.savefig(FIGURE_FOLDER + '/' + filename + '.pdf') + + +# draw a bar chart +def DrawFigure(x_values, y_values, legend_labels, x_label, y_label, y_min, y_max, filename, allow_legend): + # you may change the figure size on your own. + fig = plt.figure(figsize=(10, 3)) + figure = fig.add_subplot(111) + + FIGURE_LABEL = legend_labels + + # values in the x_xis + index = np.arange(len(x_values)) + # the bar width. + # you may need to tune it to get the best figure. + width = 0.12 + # draw the bars + bars = [None] * (len(FIGURE_LABEL)) + for i in range(len(y_values)): + bars[i] = plt.bar(index + i * width + width / 2, + y_values[i], width, + hatch=PATTERNS[i], + color=LINE_COLORS[i], + label=FIGURE_LABEL[i], edgecolor='black', linewidth=3) + + # sometimes you may not want to draw legends. + if allow_legend == True: + plt.legend(bars, FIGURE_LABEL, + prop=LEGEND_FP, + ncol=3, + loc='upper center', + # mode='expand', + shadow=False, + bbox_to_anchor=(0.45, 1.7), + columnspacing=0.1, + handletextpad=0.2, + # bbox_transform=ax.transAxes, + # frameon=True, + # columnspacing=5.5, + # handlelength=2, + ) + + # you may need to tune the xticks position to get the best figure. + plt.xticks(index + 3 * width, x_values, rotation=30) + + # plt.ticklabel_format(axis="y", style="sci", scilimits=(0, 0)) + # plt.grid(axis='y', color='gray') + # figure.get_xaxis().set_major_formatter(matplotlib.ticker.ScalarFormatter()) + + # you may need to tune the xticks position to get the best figure. + # plt.yscale('log') + # + # plt.grid(axis='y', color='gray') + figure.yaxis.set_major_locator(LinearLocator(10)) + # figure.xaxis.set_major_locator(LinearLocator(5)) + figure.get_xaxis().set_tick_params(direction='in', pad=10) + figure.get_yaxis().set_tick_params(direction='in', pad=10) + + plt.xlabel(x_label, fontproperties=LABEL_FP) + plt.ylabel(y_label, fontproperties=LABEL_FP) + + plt.savefig(filename + ".pdf", bbox_inches='tight') + + +# example for reading csv file +def ReadFile(): + y = [] + col1 = [] + col2 = [] + col3 = [] + col4 = [] + col5 = [] + col6 = [] + col7 = [] + col8 = [] + col9 = [] + + for id in it.chain(range(38, 42)): + col9.append(0) + y.append(col9) # this is a fake empty line to separate eager and lazy. + + for id in it.chain(range(38, 42)): + file = exp_dir + '/results/latency/NPJ_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(int(len(read) * 0.95)).strip("\n")) # get the 99th timestamp + col1.append(x) + y.append(col1) + + for id in it.chain(range(38, 42)): + file = exp_dir + '/results/latency/PRJ_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(int(len(read) * 0.95)).strip("\n")) # get the 99th timestamp + col2.append(x) + y.append(col2) + + for id in it.chain(range(38, 42)): + file = exp_dir + '/results/latency/MWAY_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(int(len(read) * 0.95)).strip("\n")) # get the 99th timestamp + col3.append(x) + y.append(col3) + + for id in it.chain(range(38, 42)): + file = exp_dir + '/results/latency/MPASS_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(int(len(read) * 0.95)).strip("\n")) # get the 99th timestamp + col4.append(x) + y.append(col4) + + y.append(col9) # this is a fake empty line to separate eager and lazy. + + for id in it.chain(range(38, 42)): + file = exp_dir + '/results/latency/SHJ_JM_NP_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(int(len(read) * 0.95)).strip("\n")) # get last timestamp + col5.append(x) + y.append(col5) + + for id in it.chain(range(38, 42)): + file = exp_dir + '/results/latency/SHJ_JBCR_NP_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(int(len(read) * 0.95)).strip("\n")) # get last timestamp + col6.append(x) + y.append(col6) + + for id in it.chain(range(38, 42)): + file = exp_dir + '/results/latency/PMJ_JM_NP_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(int(len(read) * 0.95)).strip("\n")) # get last timestamp + col7.append(x) + y.append(col7) + + for id in it.chain(range(38, 42)): + file = exp_dir + '/results/latency/PMJ_JBCR_NP_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(int(len(read) * 0.95)).strip("\n")) # get last timestamp + col8.append(x) + y.append(col8) + return y + + +if __name__ == "__main__": + x_values = ["Stock", "Rovio", "YSB", "DEBS"] + + y_values = ReadFile() + + legend_labels = ['Lazy:', 'NPJ', 'PRJ', 'MWAY', 'MPASS', + 'Eager:', 'SHJ$^{JM}$', 'SHJ$^{JB}$', 'PMJ$^{JM}$', 'PMJ$^{JB}$'] + print(y_values) + DrawFigure(x_values, y_values, legend_labels, + '', 'Latency (ms)', 0, + 400, 'latency_figure_app', False) + + # DrawLegend(legend_labels, 'latency_legend') diff --git a/benchmark/scripts/scanAlgoBeta/groupLine.py b/benchmark/scripts/scanAlgoBeta/groupLine.py new file mode 100755 index 00000000..8110fd3b --- /dev/null +++ b/benchmark/scripts/scanAlgoBeta/groupLine.py @@ -0,0 +1,366 @@ +import itertools as it +import os +import matplotlib.pyplot as plt +import matplotlib.font_manager as fm +import matplotlib +import numpy as np +import pylab +from matplotlib.font_manager import FontProperties +from matplotlib.ticker import MaxNLocator +from matplotlib.font_manager import FontProperties +from matplotlib.ticker import LinearLocator, LogLocator, MaxNLocator, ScalarFormatter +from numpy import double + +# 获取系统中可用的字体路径 +# font_paths = fm.findSystemFonts() +# OPT_FONT_NAME = 'Helvetica' +TICK_FONT_SIZE = 20 +LABEL_FONT_SIZE = 20 +LEGEND_FONT_SIZE = 20 +LABEL_FP = FontProperties(style='normal', size=LABEL_FONT_SIZE) +LEGEND_FP = FontProperties(style='normal', size=LEGEND_FONT_SIZE) +TICK_FP = FontProperties(style='normal', size=TICK_FONT_SIZE) + +MARKERS = (['o', 's', 'v', "^", "h", "v", ">", "x", "d", "<", "|", "p", "+", "_", "%", "|", "|", "|", "|", "|"]) +# you may want to change the color map for different figures +COLOR_MAP = ( + '#F15854', '#5DA5DA', '#60BD68', '#B276B2', '#DECF3F', '#F17CB0', '#B2912F', '#FAA43A', '#AFAFAF', '#087878', + '#783456', + '#560012', '#431256', "#00AABB", "#AA00BB") +# you may want to change the patterns for different figures +PATTERNS = (["|", "\\", "/", "+", "-", ".", "*", "x", "o", "O", "////", ".", "|||", "o", "---", "+", "\\\\", "*"]) +LABEL_WEIGHT = 'bold' +LINE_COLORS = COLOR_MAP +LINE_WIDTH = 3.0 +MARKER_SIZE = 13.0 +MARKER_FREQUENCY = 1000 + +# matplotlib.rcParams['ps.useafm'] = True +# matplotlib.rcParams['pdf.use14corefonts'] = True +# matplotlib.rcParams['xtick.labelsize'] = TICK_FONT_SIZE +# matplotlib.rcParams['ytick.labelsize'] = TICK_FONT_SIZE +# 创建字体列表 +# Explicitly specify the font path +# 获取系统中可用的字体路径 +font_paths = fm.findSystemFonts() + +# 创建字体列表 +font_list = [] +for font_path in font_paths: + try: + font_name = fm.FontProperties(fname=font_path).get_name() + if font_name not in font_list: + font_list.append(font_name) + except: + pass + +# 配置 matplotlib 使用系统中可用的字体 +plt.rcParams['font.family'] = font_list[0] + +FIGURE_FOLDER = '/data1/xtra/results/figure' + + +# there are some embedding problems if directly exporting the pdf figure using matplotlib. +# so we generate the eps format first and convert it to pdf. +def ConvertEpsToPdf(dir_filename): + os.system("epstopdf --outfile " + dir_filename + ".pdf " + dir_filename + ".eps") + os.system("rm -rf " + dir_filename + ".eps") + + +def DrawLegend(legend_labels, filename): + fig = pylab.figure() + ax1 = fig.add_subplot(111) + FIGURE_LABEL = legend_labels + LINE_WIDTH = 8.0 + MARKER_SIZE = 12.0 + LEGEND_FP = FontProperties(style='normal', size=26) + + figlegend = pylab.figure(figsize=(12, 0.5)) + idx = 0 + lines = [None] * (len(FIGURE_LABEL)) + data = [1] + x_values = [1] + + idx = 0 + for group in range(len(FIGURE_LABEL)): + lines[idx], = ax1.plot(x_values, data, + color=LINE_COLORS[idx], linewidth=LINE_WIDTH, + marker=MARKERS[idx], markersize=MARKER_SIZE, label=str(group)) + idx = idx + 1 + + # LEGEND + figlegend.legend(lines, FIGURE_LABEL, prop=LEGEND_FP, + loc=1, ncol=len(FIGURE_LABEL), mode="expand", shadow=False, + frameon=False, borderaxespad=0.0, handlelength=2) + + if not os.path.exists(FIGURE_FOLDER): + os.makedirs(FIGURE_FOLDER) + # no need to export eps in this case. + figlegend.savefig(filename + '.pdf') + + +# draw a line chart +def DrawFigure(xvalues, yvalues, legend_labels, x_label, y_label, y_min, y_max, filename, allow_legend): + # you may change the figure size on your own. + fig = plt.figure(figsize=(10, 3)) + figure = fig.add_subplot(111) + + FIGURE_LABEL = legend_labels + + x_values = xvalues + y_values = yvalues + + lines = [None] * (len(FIGURE_LABEL)) + for i in range(len(y_values)): + lines[i], = figure.plot(x_values[i], y_values[i], color=LINE_COLORS[i], \ + linewidth=LINE_WIDTH, marker=MARKERS[i], \ + markersize=MARKER_SIZE, label=FIGURE_LABEL[i]) + + # sometimes you may not want to draw legends. + if allow_legend == True: + plt.legend(lines, + FIGURE_LABEL, + prop=LEGEND_FP, + loc='upper center', + ncol=3, + # mode='expand', + bbox_to_anchor=(0.55, 1.6), shadow=False, + columnspacing=0.1, + frameon=True, borderaxespad=0.0, handlelength=1.5, + handletextpad=0.1, + labelspacing=0.1) + plt.xscale('log') + plt.yscale('log') + # plt.yscale('log') + + # you may control the limits on your own. + + # plt.ylim(y_min, y_max) + + plt.grid(axis='y', color='gray') + figure.yaxis.set_major_locator(LogLocator(base=10)) + figure.xaxis.set_major_locator(LogLocator(base=10)) + + figure.get_xaxis().set_tick_params(direction='in', pad=10) + figure.get_yaxis().set_tick_params(direction='in', pad=10) + + plt.xlabel(x_label, fontproperties=LABEL_FP) + plt.ylabel(y_label, fontproperties=LABEL_FP) + + size = fig.get_size_inches() + dpi = fig.get_dpi() + + # plt.show() + plt.savefig(filename + ".pdf", bbox_inches='tight') + + +# draw a line chart +def DrawFigureXYnormal(xvalues, yvalues, legend_labels, x_label, y_label, y_min, y_max, filename, allow_legend): + # you may change the figure size on your own. + fig = plt.figure(figsize=(10, 3)) + figure = fig.add_subplot(111) + + FIGURE_LABEL = legend_labels + + x_values = xvalues + y_values = yvalues + + lines = [None] * (len(FIGURE_LABEL)) + for i in range(len(y_values)): + lines[i], = figure.plot(x_values[i], y_values[i], color=LINE_COLORS[i], \ + linewidth=LINE_WIDTH, marker=MARKERS[i], \ + markersize=MARKER_SIZE, label=FIGURE_LABEL[i], markeredgecolor='k') + + # sometimes you may not want to draw legends. + if allow_legend == True: + plt.legend(lines, + FIGURE_LABEL, + prop=LEGEND_FP, + loc='upper center', + ncol=3, + bbox_to_anchor=(0.55, 1.5), shadow=False, + columnspacing=0.1, + frameon=True, borderaxespad=0, handlelength=1.2, + handletextpad=0.1, + labelspacing=0.1) + # plt.xscale('log') + # plt.yscale('log') + # plt.yscale('log') + + # you may control the limits on your own. + + # plt.ylim(y_min, y_max) + + plt.grid(axis='y', color='gray') + plt.rcParams['axes.unicode_minus'] = False # 用来正常显示负号 + # figure.yaxis.set_major_locator(LogLocator(base=10)) + # figure.xaxis.set_major_locator(LogLocator(base=10)) + plt.xticks(rotation=0, fontsize=TICK_FONT_SIZE) + figure.get_xaxis().set_tick_params(direction='in', pad=10) + figure.get_yaxis().set_tick_params(direction='in', pad=10) + + plt.xlabel(x_label, fontproperties=LABEL_FP) + plt.ylabel(y_label, fontproperties=LABEL_FP) + + size = fig.get_size_inches() + dpi = fig.get_dpi() + + # plt.show() + plt.savefig(filename + ".pdf", bbox_inches='tight') + + +# draw a line chart +def DrawFigureYnormal(xvalues, yvalues, legend_labels, x_label, y_label, y_min, y_max, filename, allow_legend): + # you may change the figure size on your own. + fig = plt.figure(figsize=(10, 3)) + figure = fig.add_subplot(111) + + FIGURE_LABEL = legend_labels + + x_values = xvalues + y_values = yvalues + + lines = [None] * (len(FIGURE_LABEL)) + for i in range(len(y_values)): + lines[i], = figure.plot(x_values[i], y_values[i], color=LINE_COLORS[i], \ + linewidth=LINE_WIDTH, marker=MARKERS[i], \ + markersize=MARKER_SIZE, label=FIGURE_LABEL[i], markeredgecolor='k') + + # sometimes you may not want to draw legends. + if allow_legend == True: + plt.legend(lines, + FIGURE_LABEL, + prop=LEGEND_FP, + loc='upper center', + ncol=3, + bbox_to_anchor=(0.55, 1.5), shadow=False, + columnspacing=0.1, + frameon=True, borderaxespad=0, handlelength=1.2, + handletextpad=0.1, + labelspacing=0.1) + plt.xscale('log') + # plt.yscale('log') + # plt.yscale('log') + + # you may control the limits on your own. + + # plt.ylim(y_min, y_max) + + plt.grid(axis='y', color='gray') + plt.rcParams['axes.unicode_minus'] = False # 用来正常显示负号 + # figure.yaxis.set_major_locator(LogLocator(base=10)) + # figure.xaxis.set_major_locator(LogLocator(base=10)) + plt.xticks(rotation=0, fontsize=TICK_FONT_SIZE) + figure.get_xaxis().set_tick_params(direction='in', pad=10) + figure.get_yaxis().set_tick_params(direction='in', pad=10) + + plt.xlabel(x_label, fontproperties=LABEL_FP) + plt.ylabel(y_label, fontproperties=LABEL_FP) + + size = fig.get_size_inches() + dpi = fig.get_dpi() + + # plt.show() + plt.savefig(filename + ".pdf", bbox_inches='tight') + + +# example for reading csv file +def ReadFile(): + y = [] + col1 = [] + col2 = [] + col3 = [] + col4 = [] + col5 = [] + col6 = [] + col7 = [] + col8 = [] + + for id in it.chain(range(28, 32)): + file = '/data1/xtra/results/timestamps/PRJ_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(len(read) - 1).strip("\n")) # get last timestamp + value = len(read) / x # get throughput (#items/ms) + col1.append(value) + y.append(col1) + + for id in it.chain(range(28, 32)): + file = '/data1/xtra/results/timestamps/NPJ_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(len(read) - 1).strip("\n")) # get last timestamp + value = len(read) / x # get throughput (#items/ms) + col2.append(value) + y.append(col2) + + for id in it.chain(range(28, 32)): + file = '/data1/xtra/results/timestamps/MPASS_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(len(read) - 1).strip("\n")) # get last timestamp + value = len(read) / x # get throughput (#items/ms) + col3.append(value) + y.append(col3) + + for id in it.chain(range(28, 32)): + file = '/data1/xtra/results/timestamps/MWAY_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(len(read) - 1).strip("\n")) # get last timestamp + value = len(read) / x # get throughput (#items/ms) + col4.append(value) + y.append(col4) + + for id in it.chain(range(28, 32)): + file = '/data1/xtra/results/timestamps/SHJ_JM_NP_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(len(read) - 1).strip("\n")) # get last timestamp + value = len(read) / x # get throughput (#items/ms) + col5.append(value) + y.append(col5) + + for id in it.chain(range(28, 32)): + file = '/data1/xtra/results/timestamps/SHJ_JBCR_NP_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(len(read) - 1).strip("\n")) # get last timestamp + value = len(read) / x # get throughput (#items/ms) + col6.append(value) + y.append(col6) + + for id in it.chain(range(28, 32)): + file = '/data1/xtra/results/timestamps/PMJ_JM_NP_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(len(read) - 1).strip("\n")) # get last timestamp + value = len(read) / x # get throughput (#items/ms) + col7.append(value) + y.append(col7) + + for id in it.chain(range(28, 32)): + file = '/data1/xtra/results/timestamps/PMJ_JBCR_NP_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(len(read) - 1).strip("\n")) # get last timestamp + value = len(read) / x # get throughput (#items/ms) + col8.append(value) + y.append(col8) + return y + + +if __name__ == "__main__": + # x_values = ['Unique', 'Zipf(0)', 'Zipf(0.2)', 'Zipf(0.4)', 'Zipf(0.8)', 'Zipf(1)'] + x_values = [1600, 3200, 6400, 12800, 25600] + + y_values = ReadFile() + + legend_labels = ['NPJ', 'PRJ', 'MWAY', 'MPASS', 'SHJ$^{JM}$', 'SHJ$^{JB}$', 'PMJ$^{JM}$', + 'PMJ$^{JB}$'] + + DrawFigure(x_values, y_values, legend_labels, + 'Input arrival rate of R (e/ms)', 'Tpt. (#matches/ms)', x_values[0], + x_values[4], 'throughput_figure1_1', False) + +# DrawLegend(legend_labels, 'factor_legend') diff --git a/benchmark/scripts/scanAlgoBeta/perfRu.csv b/benchmark/scripts/scanAlgoBeta/perfRu.csv new file mode 100644 index 00000000..9ee43623 --- /dev/null +++ b/benchmark/scripts/scanAlgoBeta/perfRu.csv @@ -0,0 +1,7 @@ +key,value,type +cacheMiss,12491377,U64 +cacheRefs,35327177,U64 +cpuClock,2478812100,U64 +cpuCycle,9889422467,U64 +instructions,16997458033,U64 +taskClock,2478813000,U64 diff --git a/benchmark/scripts/scanAlgoDelta/OoOCommon.py b/benchmark/scripts/scanAlgoDelta/OoOCommon.py new file mode 100755 index 00000000..70f4cf33 --- /dev/null +++ b/benchmark/scripts/scanAlgoDelta/OoOCommon.py @@ -0,0 +1,125 @@ +import csv +import numpy as np +import matplotlib.pyplot as plt +import itertools as it +import os + +import matplotlib +import matplotlib.pyplot as plt +import numpy as np +import pylab +from matplotlib.font_manager import FontProperties +from matplotlib.ticker import LogLocator, LinearLocator +import os +import pandas as pd +import sys +import matplotlib.ticker as mtick + +OPT_FONT_NAME = 'Helvetica' +TICK_FONT_SIZE = 22 +LABEL_FONT_SIZE = 28 +LEGEND_FONT_SIZE = 30 +LABEL_FP = FontProperties(style='normal', size=LABEL_FONT_SIZE) +LEGEND_FP = FontProperties(style='normal', size=LEGEND_FONT_SIZE) +TICK_FP = FontProperties(style='normal', size=TICK_FONT_SIZE) + +MARKERS = (['*', '|', 'v', "^", "", "h", "<", ">", "+", "d", "<", "|", "", "+", "_"]) +# you may want to change the color map for different figures +COLOR_MAP = ( + '#B03A2E', '#2874A6', '#239B56', '#7D3C98', '#FFFFFF', '#F1C40F', '#F5CBA7', '#82E0AA', '#AEB6BF', '#AA4499') +# you may want to change the patterns for different figures +PATTERNS = (["////", "o", "", "||", "-", "//", "\\", "o", "O", "////", ".", "|||", "o", "---", "+", "\\\\", "*"]) +LABEL_WEIGHT = 'bold' +LINE_COLORS = COLOR_MAP +LINE_WIDTH = 3.0 +MARKER_SIZE = 15.0 +MARKER_FREQUENCY = 1000 + + +def editConfig(src, dest, key, value): + df = pd.read_csv(src, header=None) + rowIdx = 0 + idxt = 0 + for cell in df[0]: + # print(cell) + if (cell == key): + rowIdx = idxt + break + idxt = idxt + 1 + df[1][rowIdx] = str(value) + df.to_csv(dest, index=False, header=False) + + +def readConfig(src, key): + df = pd.read_csv(src, header=None) + rowIdx = 0 + idxt = 0 + for cell in df[0]: + # print(cell) + if (cell == key): + rowIdx = idxt + break + idxt = idxt + 1 + return df[1][rowIdx] + + +def draw2yLine(NAME, Com, R1, R2, l1, l2, m1, m2, fname): + fig, ax1 = plt.subplots(figsize=(10, 6.4)) + lines = [None] * 2 + # ax1.set_ylim(0, 1) + print(Com) + print(R1) + lines[0], = ax1.plot(Com, R1, color=LINE_COLORS[0], \ + linewidth=LINE_WIDTH, marker=MARKERS[0], \ + markersize=MARKER_SIZE + # + ) + + # plt.show() + ax1.set_ylabel(m1, fontproperties=LABEL_FP) + ax1.set_xlabel(NAME, fontproperties=LABEL_FP) + # ax1.set_xticklabels(ax1.get_xticklabels()) # 设置共用的x轴 + plt.xticks(rotation=0, size=TICK_FONT_SIZE) + plt.yticks(rotation=0, size=TICK_FONT_SIZE) + plt.rcParams['axes.unicode_minus'] = False # 用来正常显示负号 + ax2 = ax1.twinx() + + # ax2.set_ylabel('latency/us') + # ax2.set_ylim(0, 0.5) + lines[1], = ax2.plot(Com, R2, color=LINE_COLORS[1], \ + linewidth=LINE_WIDTH, marker=MARKERS[1], \ + markersize=MARKER_SIZE) + + ax2.set_ylabel(m2, fontproperties=LABEL_FP) + # ax2.vlines(192000, min(R2)-1, max(R2)+1, colors = "GREEN", linestyles = "dashed",label='total L1 size') + # plt.grid(axis='y', color='gray') + + # style = dict(size=10, color='black') + # ax2.hlines(tset, 0, x2_list[len(x2_list)-1]+width, colors = "r", linestyles = "dashed",label="tset") + # ax2.text(4, tset, "$T_{set}$="+str(tset)+"us", ha='right', **style) + + # plt.xlabel('batch', fontproperties=LABEL_FP) + + # plt.xscale('log') + # figure.xaxis.set_major_locator(LinearLocator(5)) + ax1.yaxis.set_major_locator(LinearLocator(5)) + ax2.yaxis.set_major_locator(LinearLocator(5)) + ax1.yaxis.set_major_formatter(mtick.FormatStrFormatter('%.1f')) + ax2.yaxis.set_major_formatter(mtick.FormatStrFormatter('%.1f')) + ax1.yaxis.set_major_formatter(mtick.FormatStrFormatter('%.1f')) + ax2.yaxis.set_major_formatter(mtick.FormatStrFormatter('%.1f')) + plt.legend(lines, + [l1, l2], + prop=LEGEND_FP, + loc='upper center', + ncol=1, + bbox_to_anchor=(0.55, 1.3 + ), shadow=False, + columnspacing=0.1, + frameon=True, borderaxespad=-1.5, handlelength=1.2, + handletextpad=0.1, + labelspacing=0.1) + plt.yticks(rotation=0, size=TICK_FONT_SIZE) + plt.tight_layout() + + plt.savefig(fname + ".pdf") diff --git a/benchmark/scripts/scanAlgoDelta/accuBar.py b/benchmark/scripts/scanAlgoDelta/accuBar.py new file mode 100755 index 00000000..638c8a60 --- /dev/null +++ b/benchmark/scripts/scanAlgoDelta/accuBar.py @@ -0,0 +1,328 @@ +import getopt +import os +import sys + +import matplotlib +import matplotlib.pyplot as plt +import numpy as np +import pylab +from matplotlib.font_manager import FontProperties +from matplotlib.ticker import LinearLocator, LogLocator, MaxNLocator, ScalarFormatter +from numpy import double + +OPT_FONT_NAME = 'Helvetica' +TICK_FONT_SIZE = 24 +LABEL_FONT_SIZE = 28 +LEGEND_FONT_SIZE = 26 +TITLE_FRONT_SIZE = 32 +LABEL_FP = FontProperties(style='normal', size=LABEL_FONT_SIZE) +LEGEND_FP = FontProperties(style='normal', size=LEGEND_FONT_SIZE) +TICK_FP = FontProperties(style='normal', size=TICK_FONT_SIZE) +TITLE_FP = FontProperties(style='normal', size=TITLE_FRONT_SIZE) +MARKERS = (['o', 's', 'v', "^", "h", "v", ">", "x", "d", "<", "|", "", "|", "_"]) +# you may want to change the color map for different figures +COLOR_MAP = ('#B03A2E', '#2874A6', '#239B56', '#7D3C98', '#F1C40F', '#F5CBA7', '#82E0AA', '#AEB6BF', '#AA4499') +# you may want to change the patterns for different figures +PATTERNS = (["\\", "///", "o", "||", "\\\\", "\\\\", "//////", "//////", ".", "\\\\\\", "\\\\\\"]) +LABEL_WEIGHT = 'bold' +LINE_COLORS = COLOR_MAP +LINE_WIDTH = 3.0 +MARKER_SIZE = 0.0 +MARKER_FREQUENCY = 1000 + +matplotlib.rcParams['ps.useafm'] = True +matplotlib.rcParams['pdf.use14corefonts'] = True +matplotlib.rcParams['xtick.labelsize'] = TICK_FONT_SIZE +matplotlib.rcParams['ytick.labelsize'] = TICK_FONT_SIZE +matplotlib.rcParams['font.family'] = OPT_FONT_NAME +matplotlib.rcParams['pdf.fonttype'] = 42 + +exp_dir = "/data1/xtra" + +FIGURE_FOLDER = exp_dir + '/results/figure' + + +# there are some embedding problems if directly exporting the pdf figure using matplotlib. +# so we generate the eps format first and convert it to pdf. +def ConvertEpsToPdf(dir_filename): + os.system("epstopdf --outfile " + dir_filename + ".pdf " + dir_filename + ".eps") + os.system("rm -rf " + dir_filename + ".eps") + + +class ScalarFormatterForceFormat(ScalarFormatter): + def _set_format(self): # Override function that finds format to use. + self.format = "%1.1f" # Give format here + + +# draw a line chart +def DrawFigure(x_values, y_values, legend_labels, x_label, y_label, filename, allow_legend, title): + # you may change the figure size on your own. + + fig = plt.figure(figsize=(16, 9)) + figure = fig.add_subplot(111) + + FIGURE_LABEL = legend_labels + + # if not os.path.exists(FIGURE_FOLDER): + # os.makedirs(FIGURE_FOLDER) + + # values in the x_xis + index = np.arange(len(x_values)) + # the bar width. + # you may need to tune it to get the best figure. + width = 0.5 + # draw the bars + bottom_base = np.zeros(len(y_values[0])) + bars = [None] * (len(FIGURE_LABEL)) + for i in range(len(y_values)): + bars[i] = plt.bar(index + width / 2, y_values[i], width, hatch=PATTERNS[i], color=LINE_COLORS[i], + label=FIGURE_LABEL[i], bottom=bottom_base, edgecolor='black', linewidth=3) + bottom_base = np.array(y_values[i]) + bottom_base + + # sometimes you may not want to draw legends. + if allow_legend == True: + plt.legend(bars, FIGURE_LABEL + # mode='expand', + # shadow=False, + # columnspacing=0.25, + # labelspacing=-2.2, + # borderpad=5, + # bbox_transform=ax.transAxes, + # frameon=False, + # columnspacing=5.5, + # handlelength=2, + ) + if allow_legend == True: + handles, labels = figure.get_legend_handles_labels() + if allow_legend == True: + leg = plt.legend(handles[::-1], labels[::-1], + loc='upper center', + # prop=#LEGEND_FP, + # ncol=3, + # bbox_to_anchor=(0.5, 1.25), + # bbox_to_anchor=(1.17, 0.5), + # handletextpad=0.1, + # borderaxespad=0.0, + # handlelength=1.8, + # labelspacing=0.3, + # columnspacing=0.3, + ) + leg.get_frame().set_linewidth(2) + leg.get_frame().set_edgecolor("black") + + # you may need to tune the xticks position to get the best figure. + plt.xticks(index + 0.6 * width, x_values) + yfmt = ScalarFormatterForceFormat() + yfmt.set_powerlimits((0, 0)) + figure.get_yaxis().set_major_formatter(yfmt) + plt.ticklabel_format(axis="y", style="sci", scilimits=(0, 0), useMathText=True) + plt.grid(axis='y', color='gray') + figure.yaxis.set_major_locator(LinearLocator(3)) + # figure.yaxis.set_major_locator(LogLocator(base=10)) + # figure.yaxis.set_major_locator(LinearLocator(6)) + + figure.get_xaxis().set_tick_params(direction='in', pad=10) + figure.get_yaxis().set_tick_params(direction='in', pad=10) + + plt.xlabel(x_label, fontproperties=LABEL_FP) + plt.ylabel(y_label, fontproperties=LABEL_FP) + + size = fig.get_size_inches() + dpi = fig.get_dpi() + plt.title(title, fontproperties=TITLE_FP) + plt.savefig(filename + ".pdf", bbox_inches='tight', format='pdf') + + +def DrawLegend(legend_labels, filename): + fig = pylab.figure() + ax1 = fig.add_subplot(111) + FIGURE_LABEL = legend_labels + LEGEND_FP = FontProperties(style='normal', size=26) + + bars = [None] * (len(FIGURE_LABEL)) + data = [1] + x_values = [1] + + width = 0.3 + for i in range(len(FIGURE_LABEL)): + bars[i] = ax1.bar(x_values, data, width, hatch=PATTERNS[i], color=LINE_COLORS[i], + linewidth=0.2) + + # LEGEND + figlegend = pylab.figure(figsize=(11, 0.5)) + figlegend.legend(bars, FIGURE_LABEL, prop=LEGEND_FP, \ + loc=9, + bbox_to_anchor=(0, 0.4, 1, 1), + ncol=len(FIGURE_LABEL), mode="expand", shadow=False, \ + frameon=False, handlelength=1.1, handletextpad=0.2, columnspacing=0.1) + + figlegend.savefig(FIGURE_FOLDER + '/' + filename + '.pdf') + + +def normalize(y_values): + y_total_values = np.zeros(len(y_values[0])) + + for i in range(len(y_values)): + y_total_values += np.array(y_values[i]) + y_norm_values = [] + + for i in range(len(y_values)): + y_norm_values.append(np.array(y_values[i]) / (y_total_values) * 100) + return y_norm_values + + +# example for reading csv file +def ReadFile(id): + # Creates a list containing w lists, each of h items, all set to 0 + w, h = 5, 3 + y = [[0 for x in range(w)] for y in range(h)] + # print(matches) + max_value = 0 + j = 0 + bound = id + 1 * w + for i in range(id, bound, 1): + cnt = 0 + print(i) + f = open(exp_dir + "/results/breakdown/PMJ_JBCR_NP_{}.txt".format(i), "r") + read = f.readlines() + others = 0 + for x in read: + value = double(x.strip("\n")) + if value > max_value: + max_value = value + elif cnt == 3: # sort + y[0][j] = value + elif cnt == 4: # merge + y[1][j] = value + elif cnt == 5: # join + y[2][j] = value + else: + others += value + # if cnt == 6: + # y[2][j] = others + cnt += 1 + j += 1 + print(y) + return y, max_value + + +if __name__ == "__main__": + id = 119 + try: + opts, args = getopt.getopt(sys.argv[1:], '-i:h', ['test id', 'help']) + except getopt.GetoptError: + print('breakdown.py -id testid') + sys.exit(2) + for opt, opt_value in opts: + if opt in ('-h', '--help'): + print("[*] Help info") + exit() + elif opt == '-i': + print('Test ID:', opt_value) + id = (int)(opt_value) + + x_values = ['10%', '20%', '30%', '40%', '50%'] # sorting step size + + y_values, max_value = ReadFile(id) # 55 + + # y_norm_values = normalize(y_values) + + # break into 4 parts + legend_labels = ['sort', 'merge', 'join'] # , 'others' + + DrawFigure(x_values, y_values, legend_labels, + 'sorting step size', 'cycles per input tuple', + 'breakdown_sort_figure', True) + + # DrawLegend(legend_labels, 'breakdown_radix_legend') + + +def DrawPercentageFigure(x_values, y_values, legend_labels, x_label, y_label, filename, allow_legend, title): + # you may change the figure size on your own. + fig = plt.figure(figsize=(9, 3)) + figure = fig.add_subplot(111) + + FIGURE_LABEL = legend_labels + + # values in the x_xis + index = np.arange(len(x_values)) + # the bar width. + # you may need to tune it to get the best figure. + width = 0.5 + # draw the bars + bottom_base = np.zeros(len(y_values[0])) + bars = [None] * (len(FIGURE_LABEL)) + for i in range(len(y_values)): + bars[i] = plt.bar(index + width / 2, y_values[i], width, hatch=PATTERNS[i], color=LINE_COLORS[i], + label=FIGURE_LABEL[i], bottom=bottom_base, edgecolor='black', linewidth=3) + bottom_base = np.array(y_values[i]) + bottom_base + + # sometimes you may not want to draw legends. + if allow_legend == True: + plt.legend(bars, FIGURE_LABEL + # mode='expand', + # shadow=False, + # columnspacing=0.25, + # labelspacing=-2.2, + # borderpad=5, + # bbox_transform=ax.transAxes, + # frameon=False, + # columnspacing=5.5, + # handlelength=2, + ) + if allow_legend == True: + handles, labels = figure.get_legend_handles_labels() + if allow_legend == True: + print(handles[::-1], labels[::-1]) + leg = plt.legend(handles[::-1], labels[::-1], + loc='center', + prop=LEGEND_FP, + ncol=3, + bbox_to_anchor=(0.5, 1.2), + handletextpad=0.1, + borderaxespad=0.0, + handlelength=1.8, + labelspacing=0.3, + columnspacing=0.3, + ) + leg.get_frame().set_linewidth(2) + leg.get_frame().set_edgecolor("black") + + # sometimes you may not want to draw legends. + # if allow_legend == True: + # leg=plt.legend(bars, + # FIGURE_LABEL, + # prop=LEGEND_FP, + # loc='right', + # ncol=1, + # # mode='expand', + # bbox_to_anchor=(0.45, 1.1), shadow=False, + # columnspacing=0.1, + # frameon=True, borderaxespad=0.0, handlelength=1.5, + # handletextpad=0.1, + # labelspacing=0.1) + # leg.get_frame().set_linewidth(2) + # leg.get_frame().set_edgecolor("black") + + plt.ylim(0, 100) + + # you may need to tune the xticks position to get the best figure. + plt.xticks(index + 0.5 * width, x_values) + plt.xticks(rotation=30) + + # plt.xlim(0,) + # plt.ylim(0,1) + + plt.grid(axis='y', color='gray') + figure.yaxis.set_major_locator(LinearLocator(6)) + + figure.get_xaxis().set_tick_params(direction='in', pad=10) + figure.get_yaxis().set_tick_params(direction='in', pad=10) + + plt.xlabel(x_label, fontproperties=LABEL_FP) + plt.ylabel(y_label, fontproperties=LABEL_FP) + + size = fig.get_size_inches() + dpi = fig.get_dpi() + + plt.savefig(filename + ".pdf", bbox_inches='tight', format='pdf') diff --git a/benchmark/scripts/scanAlgoDelta/autoParase.py b/benchmark/scripts/scanAlgoDelta/autoParase.py new file mode 100755 index 00000000..9375c8e0 --- /dev/null +++ b/benchmark/scripts/scanAlgoDelta/autoParase.py @@ -0,0 +1,87 @@ +import csv + + +def paraseValidStageNames(a): + nameList = [] + with open(a, 'r') as f: + reader = csv.reader(f) + # reader = [each for each in csv.DictReader(f, delimiter=',')] + result = list(reader) + rows = len(result) + # print('rows=',rows) + firstRow = result[0] + # print(firstRow) + index = 0 + # define what may attract our interest + idxCpu = 0 + idxName = 0 + for i in firstRow: + # print(i) + if (i == 'cpu'): + idxCpu = index + if (i == 'name'): + idxName = index + index = index + 1 + # read the valid stages + vdataEntries = 0 + + for k in range(1, rows): + if (result[k][idxCpu] != 'NA'): + R1 = ((result[k][idxName])) + nameList.append(R1) + return nameList + + +def paraseValidColums(a, nameList, colTitle): + with open(a, 'r') as f: + reader = csv.reader(f) + # reader = [each for each in csv.DictReader(f, delimiter=',')] + result = list(reader) + rows = len(result) + # print('rows=',rows) + firstRow = result[0] + # print(firstRow) + index = 0 + # define what may attract our interest + idxCpu = 0 + idxName = 0 + idxTitle = 0 + for i in firstRow: + # print(i) + if (i == 'cpu'): + idxCpu = index + if (i == 'name'): + idxName = index + if (i == colTitle): + idxTitle = index + index = index + 1 + # read the valid stages + vdataEntries = 0 + ru = [] + for k in range(1, rows): + if (result[k][idxCpu] != 'NA'): + R1 = ((result[k][idxName])) + for j in range(len(nameList)): + if (R1 == nameList[j]): + s = int(result[k][idxTitle]) + ru.append(s) + break + return ru + + +def maxInList(a): + # a in [[1,2] [3,4]] + inLen = len(a[0]) + ru = [] + index = [] + ti = 0 + for i in range(len(a[0])): + ts = 0 + ti = 0 + for k in range(len(a)): + if (a[k][i] > ts): + ts = a[k][i] + ti = k + ru.append(ts) + index.append(ti) + return ru, index diff --git a/benchmark/scripts/scanAlgoDelta/config_CPPTOW.csv b/benchmark/scripts/scanAlgoDelta/config_CPPTOW.csv new file mode 100644 index 00000000..5bd39217 --- /dev/null +++ b/benchmark/scripts/scanAlgoDelta/config_CPPTOW.csv @@ -0,0 +1,11 @@ +key,value,type +aRow,100,U64 +aCol,1000,U64 +bCol,500,U64 +sketchDimension,25,U64 +ptFile,torchscripts/TugOfWar.pt,String +useCPP,1,U64 +cppAlgoTag,tugOfWar,String +threads,1,U64 +forceMP,1,U64 +algoDelta,0.02,Double diff --git a/benchmark/scripts/scanAlgoDelta/config_RAWMM.csv b/benchmark/scripts/scanAlgoDelta/config_RAWMM.csv new file mode 100644 index 00000000..a1e0fe71 --- /dev/null +++ b/benchmark/scripts/scanAlgoDelta/config_RAWMM.csv @@ -0,0 +1,9 @@ +key,value,type +aRow,1000,U64 +aCol,1000,U64 +bCol,500,U64 +sketchDimension,25,U64 +ptFile,torchscripts/RAWMM.pt,String +threads,1,U64 +forceMP,1,U64 +algoDelta,0.02,Double diff --git a/benchmark/scripts/scanAlgoDelta/drawTogether.py b/benchmark/scripts/scanAlgoDelta/drawTogether.py new file mode 100755 index 00000000..aefede61 --- /dev/null +++ b/benchmark/scripts/scanAlgoDelta/drawTogether.py @@ -0,0 +1,177 @@ +#!/usr/bin/env python3 +import csv +import numpy as np +import accuBar as accuBar +import groupBar as groupBar +import groupBar2 as groupBar2 +import groupLine as groupLine +from autoParase import * +import itertools as it +import os + +import matplotlib +import numpy as np +import pylab +import matplotlib.font_manager as fm +from matplotlib.font_manager import FontProperties +from matplotlib.ticker import LogLocator, LinearLocator +import os +import pandas as pd +import sys +from OoOCommon import * +import time + +# OPT_FONT_NAME = 'Helvetica' +TICK_FONT_SIZE = 22 +LABEL_FONT_SIZE = 28 +LEGEND_FONT_SIZE = 30 +LABEL_FP = FontProperties(style='normal', size=LABEL_FONT_SIZE) +LEGEND_FP = FontProperties(style='normal', size=LEGEND_FONT_SIZE) +TICK_FP = FontProperties(style='normal', size=TICK_FONT_SIZE) + +MARKERS = (['*', '|', 'v', "^", "", "h", "<", ">", "+", "d", "<", "|", "", "+", "_"]) +# you may want to change the color map for different figures +COLOR_MAP = ( + '#B03A2E', '#2874A6', '#239B56', '#7D3C98', '#FFFFFF', '#F1C40F', '#F5CBA7', '#82E0AA', '#AEB6BF', '#AA4499') +# you may want to change the patterns for different figures +PATTERNS = (["////", "o", "", "||", "-", "//", "\\", "o", "O", "////", ".", "|||", "o", "---", "+", "\\\\", "*"]) +LABEL_WEIGHT = 'bold' +LINE_COLORS = COLOR_MAP +LINE_WIDTH = 3.0 +MARKER_SIZE = 15.0 +MARKER_FREQUENCY = 1000 + +matplotlib.rcParams['ps.useafm'] = True +matplotlib.rcParams['pdf.use14corefonts'] = True +matplotlib.rcParams['xtick.labelsize'] = TICK_FONT_SIZE +matplotlib.rcParams['ytick.labelsize'] = TICK_FONT_SIZE +matplotlib.rcParams['font.family'] = OPT_FONT_NAME +matplotlib.rcParams['pdf.fonttype'] = 42 + +scanTag = "algoDelta" + + +def singleRun(exePath, singleValue, resultPath, configTemplate): + # resultFolder="singleValueTests" + configFname = "config_" + scanTag + str(singleValue) + ".csv" + # configTemplate = "config.csv" + # clear old files + os.system("cd " + exePath + "&& sudo rm *.csv") + + # editConfig(configTemplate, exePath + configFname, "earlierEmitMs", 0) + editConfig(configTemplate, exePath + configFname, scanTag, singleValue) + # prepare new file + # run + os.system("cd " + exePath + "&& sudo ./benchmark " + configFname) + # copy result + os.system("sudo rm -rf " + resultPath + "/" + str(singleValue)) + os.system("sudo mkdir " + resultPath + "/" + str(singleValue)) + os.system("cd " + exePath + "&& sudo cp *.csv " + resultPath + "/" + str(singleValue)) + + +def runScanVector(exePath, singleValueVec, resultPath, templateName="config.csv"): + for i in singleValueVec: + singleRun(exePath, i, resultPath, templateName) + +def readResultSingle(singleValue, resultPath): + resultFname = resultPath + "/" + str(singleValue) + "/default.csv" + elapsedTime = readConfig(resultFname, "perfElapsedTime") + cacheMiss = readConfig(resultFname, "cacheMiss") + cacheRefs = readConfig(resultFname, "cacheRefs") + froError = readConfig(resultFname, "froError") + errorBoundRatio = readConfig(resultFname, "errorBoundRatio") + return elapsedTime, cacheMiss, cacheRefs, froError, errorBoundRatio + + +def cleanPath(path): + os.system("sudo rm -rf " + path) + os.system("sudo mkdir " + path) + + +def readResultVector(singleValueVec, resultPath): + elapseTimeVec = [] + cacheMissVec = [] + cacheRefVec = [] + froErrorVec = [] + errorBoundRatioVec = [] + for i in singleValueVec: + elapsedTime, cacheMiss, cacheRefs, froError, errorBoundRatio = readResultSingle(i, resultPath) + elapseTimeVec.append(float(elapsedTime) / 1000.0) + cacheMissVec.append(float(cacheMiss)) + cacheRefVec.append(float(cacheRefs)) + froErrorVec.append(float(froError)) + errorBoundRatioVec.append(float(errorBoundRatio)) + return np.array(elapseTimeVec), np.array(cacheMissVec), np.array(cacheRefVec), np.array(froErrorVec), np.array( + errorBoundRatioVec) + + +def compareMethod(exeSpace, commonPathBase, resultPaths, csvTemplates, periodVec, reRun=1): + elapsedTimeAll = [] + cacheMissAll = [] + cacheRefAll = [] + periodAll = [] + froAll = [] + errorBoundRatioAll = [] + for i in range(len(csvTemplates)): + resultPath = commonPathBase + resultPaths[i] + if (reRun == 1): + os.system("sudo rm -rf " + resultPath) + os.system("sudo mkdir " + resultPath) + runScanVector(exeSpace, periodVec, resultPath, csvTemplates[i]) + elapsedTime, cacheMiss, cacheRef, fro, eb = readResultVector(periodVec, resultPath) + elapsedTimeAll.append(elapsedTime) + cacheMissAll.append(cacheMiss) + cacheRefAll.append(cacheRef) + periodAll.append(periodVec) + cacheMissRateAll = np.array(cacheMissAll) / np.array(cacheRefAll) * 100.0 + froAll.append(fro) + errorBoundRatioAll.append(eb) + # periodAll.append(periodVec) + return np.array(elapsedTimeAll), cacheMissRateAll, periodAll, np.array(froAll), np.array(errorBoundRatioAll) + + +def main(): + exeSpace = os.path.abspath(os.path.join(os.getcwd(), "../..")) + "/" + commonBase = os.path.abspath(os.path.join(os.getcwd(), "../..")) + "/results/" + scanTag + "/" + figPath = os.path.abspath(os.path.join(os.getcwd(), "../..")) + "/figures/" + scanTag + methodTags = ["TOW", "MM"] + resultPaths = ["tow", "mm"] + csvTemplates = ["config_CPPTOW.csv", "config_RAWMM.csv"] + valueVec = [0.2, 0.1, 0.02, 0.005, 5e-4, 2e-9, 9e-14, 2e-22, 3e-44] + valueVecDisp = np.array(valueVec) + # run + reRun = 0 + if (len(sys.argv) < 2): + os.system("mkdir ../../results") + os.system("mkdir ../../figures") + os.system("mkdir " + figPath) + os.system("sudo rm -rf " + commonBase) + os.system("sudo mkdir " + commonBase) + reRun = 1 + + elapsedTimeAll, cacheMissAll, periodAll, fro, eb = compareMethod(exeSpace, commonBase, resultPaths, csvTemplates, valueVec, + reRun) + groupLine.DrawFigure(periodAll, elapsedTimeAll, + methodTags, + "value of delta", "elapsed time (ms)", 0, 1, + figPath + "/" + scanTag + "_elapsedTime", + True) + groupLine.DrawFigureYnormal(periodAll, cacheMissAll, + methodTags, + "value of delta", "cacheMiss (%)", 0, 1, + figPath + "/" + scanTag + "_cacheMiss", + True) + + groupLine.DrawFigureYnormal(periodAll, + fro * 100.0, + methodTags, + "value of delta", "normalized error %", 0, 1, figPath + "/" +scanTag + "_froError", + True) + groupLine.DrawFigureYnormal(periodAll, + eb * 100.0, + methodTags, + "value of delta", "error bound ratio %", 0, 1, figPath + "/" + scanTag + "_ebRatio", + True) + +if __name__ == "__main__": + main() diff --git a/benchmark/scripts/scanAlgoDelta/groupBar.py b/benchmark/scripts/scanAlgoDelta/groupBar.py new file mode 100755 index 00000000..ef2d9842 --- /dev/null +++ b/benchmark/scripts/scanAlgoDelta/groupBar.py @@ -0,0 +1,236 @@ +import itertools as it +import os + +import matplotlib +import matplotlib.pyplot as plt +import numpy as np +import pylab +from matplotlib.font_manager import FontProperties +from matplotlib.ticker import LogLocator, LinearLocator + +OPT_FONT_NAME = 'Helvetica' +TICK_FONT_SIZE = 24 +LABEL_FONT_SIZE = 28 +LEGEND_FONT_SIZE = 15 +LABEL_FP = FontProperties(style='normal', size=LABEL_FONT_SIZE) +LEGEND_FP = FontProperties(style='normal', size=LEGEND_FONT_SIZE) +TICK_FP = FontProperties(style='normal', size=TICK_FONT_SIZE) + +MARKERS = (["", 'o', 's', 'v', "^", "", "h", "<", ">", "+", "d", "<", "|", "", "+", "_"]) +# you may want to change the color map for different figures +COLOR_MAP = ( + '#7FFFFF', '#B03A2E', '#2874A6', '#FFFFFF', '#7FFFFF', '#B03A2E', '#2874A6', '#FFFFFF', '#F5CBA7', '#82E0AA', + '#AEB6BF', + '#AA4499') +# you may want to change the patterns for different figures +PATTERNS = ( + ["////", "\\\\", "//", "o", "*", "||", "-", "//", "\\", "o", "O", "////", ".", "|||", "o", "---", "+", "\\\\", "*"]) +LABEL_WEIGHT = 'bold' +LINE_COLORS = COLOR_MAP +LINE_WIDTH = 3.0 +MARKER_SIZE = 15.0 +MARKER_FREQUENCY = 1000 + +matplotlib.rcParams['ps.useafm'] = True +matplotlib.rcParams['pdf.use14corefonts'] = True +matplotlib.rcParams['xtick.labelsize'] = TICK_FONT_SIZE +matplotlib.rcParams['ytick.labelsize'] = TICK_FONT_SIZE +matplotlib.rcParams['font.family'] = OPT_FONT_NAME +matplotlib.rcParams['pdf.fonttype'] = 42 + +exp_dir = "/data1/xtra" + +FIGURE_FOLDER = exp_dir + '/results/figure' + + +def DrawLegend(legend_labels, filename): + fig = pylab.figure() + ax1 = fig.add_subplot(111) + FIGURE_LABEL = legend_labels + LEGEND_FP = FontProperties(style='normal', size=26) + figlegend = pylab.figure(figsize=(16, 0.5)) + bars = [None] * (len(FIGURE_LABEL)) + data = [1] + x_values = [1] + + width = 0.3 + for i in range(len(FIGURE_LABEL)): + bars[i] = ax1.bar(x_values, data, width, + hatch=PATTERNS[i], + color=LINE_COLORS[i], + label=FIGURE_LABEL[i], + edgecolor='black', linewidth=3) + + # LEGEND + + figlegend.legend(bars, FIGURE_LABEL, prop=LEGEND_FP, \ + loc=1, ncol=len(FIGURE_LABEL), mode="expand", shadow=True, \ + frameon=True, handlelength=2, handletextpad=0.3, columnspacing=0.5, + borderaxespad=-0.2, fancybox=True + ) + figlegend.savefig(FIGURE_FOLDER + '/' + filename + '.pdf') + + +# draw a bar chart +def DrawFigure(x_values, y_values, legend_labels, x_label, y_label, y_min, y_max, filename, allow_legend): + # you may change the figure size on your own. + fig = plt.figure(figsize=(10, 3)) + figure = fig.add_subplot(111) + + FIGURE_LABEL = legend_labels + + # values in the x_xis + index = np.arange(len(x_values)) + # the bar width. + # you may need to tune it to get the best figure. + width = 0.08 + # draw the bars + bars = [] + ts = 0 + pos = 0 + gl = len(y_values[0]) + for i in range(len(y_values)): + pos = pos + 3 * width + for j in range(len(y_values[i])): + pos = pos + width + bar = plt.bar(pos, y_values[i][j], width, hatch=PATTERNS[j], color=LINE_COLORS[j], label=FIGURE_LABEL[j], + edgecolor='black', linewidth=3) + bars.append(bar) + ts = ts + 1 + + # sometimes you may not want to draw legends. + if allow_legend == True: + plt.legend(bars, FIGURE_LABEL, + prop=LEGEND_FP, + ncol=4, + loc='upper center', + # mode='expand', + shadow=False, + bbox_to_anchor=(0.45, 1.6), + columnspacing=0.1, + handletextpad=0.2, + # bbox_transform=ax.transAxes, + # frameon=True, + # columnspacing=5.5, + # handlelength=2, + ) + + # you may need to tune the xticks position to get the best figure. + plt.xticks(index, x_values) + # plt.ticklabel_format(axis="y", style="sci", scilimits=(0, 0)) + # plt.grid(axis='y', color='gray') + # figure.get_xaxis().set_major_formatter(matplotlib.ticker.ScalarFormatter()) + + # you may need to tune the xticks position to get the best figure. + # plt.yscale('log') + # + # plt.grid(axis='y', color='gray') + figure.yaxis.set_major_locator(LinearLocator(5)) + # figure.xaxis.set_major_locator(LinearLocator(5)) + figure.get_xaxis().set_tick_params(direction='in', pad=10) + figure.get_yaxis().set_tick_params(direction='in', pad=10) + + plt.xlabel(x_label, fontproperties=LABEL_FP) + plt.ylabel(y_label, fontproperties=LABEL_FP) + plt.ylim(y_min, y_max) + plt.savefig(filename + ".pdf", bbox_inches='tight') + + +# example for reading csv file +def ReadFile(): + y = [] + col1 = [] + col2 = [] + col3 = [] + col4 = [] + col5 = [] + col6 = [] + col7 = [] + col8 = [] + col9 = [] + + for id in it.chain(range(38, 42)): + col9.append(0) + y.append(col9) # this is a lz4_pipe2 empty line to separate eager and lazy. + + for id in it.chain(range(38, 42)): + file = exp_dir + '/results/latency/NPJ_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(int(len(read) * 0.95)).strip("\n")) # get the 99th timestamp + col1.append(x) + y.append(col1) + + for id in it.chain(range(38, 42)): + file = exp_dir + '/results/latency/PRJ_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(int(len(read) * 0.95)).strip("\n")) # get the 99th timestamp + col2.append(x) + y.append(col2) + + for id in it.chain(range(38, 42)): + file = exp_dir + '/results/latency/MWAY_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(int(len(read) * 0.95)).strip("\n")) # get the 99th timestamp + col3.append(x) + y.append(col3) + + for id in it.chain(range(38, 42)): + file = exp_dir + '/results/latency/MPASS_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(int(len(read) * 0.95)).strip("\n")) # get the 99th timestamp + col4.append(x) + y.append(col4) + + y.append(col9) # this is a lz4_pipe2 empty line to separate eager and lazy. + + for id in it.chain(range(38, 42)): + file = exp_dir + '/results/latency/SHJ_JM_NP_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(int(len(read) * 0.95)).strip("\n")) # get last timestamp + col5.append(x) + y.append(col5) + + for id in it.chain(range(38, 42)): + file = exp_dir + '/results/latency/SHJ_JBCR_NP_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(int(len(read) * 0.95)).strip("\n")) # get last timestamp + col6.append(x) + y.append(col6) + + for id in it.chain(range(38, 42)): + file = exp_dir + '/results/latency/PMJ_JM_NP_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(int(len(read) * 0.95)).strip("\n")) # get last timestamp + col7.append(x) + y.append(col7) + + for id in it.chain(range(38, 42)): + file = exp_dir + '/results/latency/PMJ_JBCR_NP_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(int(len(read) * 0.95)).strip("\n")) # get last timestamp + col8.append(x) + y.append(col8) + return y + + +if __name__ == "__main__": + x_values = ["Stock", "Rovio", "YSB", "DEBS"] + + y_values = ReadFile() + + legend_labels = ['Lazy:', 'NPJ', 'PRJ', 'MWAY', 'MPASS', + 'Eager:', 'SHJ$^{JM}$', 'SHJ$^{JB}$', 'PMJ$^{JM}$', 'PMJ$^{JB}$'] + print(y_values) + DrawFigure(x_values, y_values, legend_labels, + '', 'Latency (ms)', 0, + 400, 'latency_figure_app', False) + + # DrawLegend(legend_labels, 'latency_legend') diff --git a/benchmark/scripts/scanAlgoDelta/groupBar2.py b/benchmark/scripts/scanAlgoDelta/groupBar2.py new file mode 100755 index 00000000..31155695 --- /dev/null +++ b/benchmark/scripts/scanAlgoDelta/groupBar2.py @@ -0,0 +1,232 @@ +import itertools as it +import os + +import matplotlib +import matplotlib.pyplot as plt +import numpy as np +import pylab +from matplotlib.font_manager import FontProperties +from matplotlib.ticker import LogLocator, LinearLocator + +OPT_FONT_NAME = 'Helvetica' +TICK_FONT_SIZE = 24 +LABEL_FONT_SIZE = 28 +LEGEND_FONT_SIZE = 30 +LABEL_FP = FontProperties(style='normal', size=LABEL_FONT_SIZE) +LEGEND_FP = FontProperties(style='normal', size=LEGEND_FONT_SIZE) +TICK_FP = FontProperties(style='normal', size=TICK_FONT_SIZE) + +MARKERS = (["", 'o', 's', 'v', "^", "", "h", "<", ">", "+", "d", "<", "|", "", "+", "_"]) +# you may want to change the color map for different figures +COLOR_MAP = ( + '#FFFFFF', '#B03A2E', '#2874A6', '#239B56', '#7D3C98', '#00FFFF', '#F1C40F', '#F5CBA7', '#82E0AA', '#AEB6BF', + '#AA4499') +# you may want to change the patterns for different figures +PATTERNS = ( + ["", "////", "\\\\", "//", "o", "", "||", "-", "//", "\\", "o", "O", "////", ".", "|||", "o", "---", "+", "\\\\", + "*"]) +LABEL_WEIGHT = 'bold' +LINE_COLORS = COLOR_MAP +LINE_WIDTH = 3.0 +MARKER_SIZE = 15.0 +MARKER_FREQUENCY = 1000 + +matplotlib.rcParams['ps.useafm'] = True +matplotlib.rcParams['pdf.use14corefonts'] = True +matplotlib.rcParams['xtick.labelsize'] = TICK_FONT_SIZE +matplotlib.rcParams['ytick.labelsize'] = TICK_FONT_SIZE +matplotlib.rcParams['font.family'] = OPT_FONT_NAME +matplotlib.rcParams['pdf.fonttype'] = 42 + +exp_dir = "/data1/xtra" + +FIGURE_FOLDER = exp_dir + '/results/figure' + + +def DrawLegend(legend_labels, filename): + fig = pylab.figure() + ax1 = fig.add_subplot(111) + FIGURE_LABEL = legend_labels + LEGEND_FP = FontProperties(style='normal', size=26) + figlegend = pylab.figure(figsize=(16, 0.5)) + bars = [None] * (len(FIGURE_LABEL)) + data = [1] + x_values = [1] + + width = 0.3 + for i in range(len(FIGURE_LABEL)): + bars[i] = ax1.bar(x_values, data, width, + hatch=PATTERNS[i], + color=LINE_COLORS[i], + label=FIGURE_LABEL[i], + edgecolor='black', linewidth=3) + + # LEGEND + + figlegend.legend(bars, FIGURE_LABEL, prop=LEGEND_FP, \ + loc=1, ncol=len(FIGURE_LABEL), mode="expand", shadow=True, \ + frameon=True, handlelength=2, handletextpad=0.3, columnspacing=0.5, + borderaxespad=-0.2, fancybox=True + ) + figlegend.savefig(FIGURE_FOLDER + '/' + filename + '.pdf') + + +# draw a bar chart +def DrawFigure(x_values, y_values, legend_labels, x_label, y_label, y_min, y_max, filename, allow_legend): + # you may change the figure size on your own. + fig = plt.figure(figsize=(10, 3)) + figure = fig.add_subplot(111) + + FIGURE_LABEL = legend_labels + + # values in the x_xis + index = np.arange(len(x_values)) + # the bar width. + # you may need to tune it to get the best figure. + width = 0.12 + # draw the bars + bars = [None] * (len(FIGURE_LABEL)) + for i in range(len(y_values)): + bars[i] = plt.bar(index + i * width + width / 2, + y_values[i], width, + hatch=PATTERNS[i], + color=LINE_COLORS[i], + label=FIGURE_LABEL[i], edgecolor='black', linewidth=3) + + # sometimes you may not want to draw legends. + if allow_legend == True: + plt.legend(bars, FIGURE_LABEL, + prop=LEGEND_FP, + ncol=3, + loc='upper center', + # mode='expand', + shadow=False, + bbox_to_anchor=(0.45, 1.7), + columnspacing=0.1, + handletextpad=0.2, + # bbox_transform=ax.transAxes, + # frameon=True, + # columnspacing=5.5, + # handlelength=2, + ) + + # you may need to tune the xticks position to get the best figure. + plt.xticks(index + 3 * width, x_values, rotation=30) + + # plt.ticklabel_format(axis="y", style="sci", scilimits=(0, 0)) + # plt.grid(axis='y', color='gray') + # figure.get_xaxis().set_major_formatter(matplotlib.ticker.ScalarFormatter()) + + # you may need to tune the xticks position to get the best figure. + # plt.yscale('log') + # + # plt.grid(axis='y', color='gray') + figure.yaxis.set_major_locator(LinearLocator(10)) + # figure.xaxis.set_major_locator(LinearLocator(5)) + figure.get_xaxis().set_tick_params(direction='in', pad=10) + figure.get_yaxis().set_tick_params(direction='in', pad=10) + + plt.xlabel(x_label, fontproperties=LABEL_FP) + plt.ylabel(y_label, fontproperties=LABEL_FP) + + plt.savefig(filename + ".pdf", bbox_inches='tight') + + +# example for reading csv file +def ReadFile(): + y = [] + col1 = [] + col2 = [] + col3 = [] + col4 = [] + col5 = [] + col6 = [] + col7 = [] + col8 = [] + col9 = [] + + for id in it.chain(range(38, 42)): + col9.append(0) + y.append(col9) # this is a fake empty line to separate eager and lazy. + + for id in it.chain(range(38, 42)): + file = exp_dir + '/results/latency/NPJ_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(int(len(read) * 0.95)).strip("\n")) # get the 99th timestamp + col1.append(x) + y.append(col1) + + for id in it.chain(range(38, 42)): + file = exp_dir + '/results/latency/PRJ_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(int(len(read) * 0.95)).strip("\n")) # get the 99th timestamp + col2.append(x) + y.append(col2) + + for id in it.chain(range(38, 42)): + file = exp_dir + '/results/latency/MWAY_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(int(len(read) * 0.95)).strip("\n")) # get the 99th timestamp + col3.append(x) + y.append(col3) + + for id in it.chain(range(38, 42)): + file = exp_dir + '/results/latency/MPASS_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(int(len(read) * 0.95)).strip("\n")) # get the 99th timestamp + col4.append(x) + y.append(col4) + + y.append(col9) # this is a fake empty line to separate eager and lazy. + + for id in it.chain(range(38, 42)): + file = exp_dir + '/results/latency/SHJ_JM_NP_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(int(len(read) * 0.95)).strip("\n")) # get last timestamp + col5.append(x) + y.append(col5) + + for id in it.chain(range(38, 42)): + file = exp_dir + '/results/latency/SHJ_JBCR_NP_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(int(len(read) * 0.95)).strip("\n")) # get last timestamp + col6.append(x) + y.append(col6) + + for id in it.chain(range(38, 42)): + file = exp_dir + '/results/latency/PMJ_JM_NP_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(int(len(read) * 0.95)).strip("\n")) # get last timestamp + col7.append(x) + y.append(col7) + + for id in it.chain(range(38, 42)): + file = exp_dir + '/results/latency/PMJ_JBCR_NP_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(int(len(read) * 0.95)).strip("\n")) # get last timestamp + col8.append(x) + y.append(col8) + return y + + +if __name__ == "__main__": + x_values = ["Stock", "Rovio", "YSB", "DEBS"] + + y_values = ReadFile() + + legend_labels = ['Lazy:', 'NPJ', 'PRJ', 'MWAY', 'MPASS', + 'Eager:', 'SHJ$^{JM}$', 'SHJ$^{JB}$', 'PMJ$^{JM}$', 'PMJ$^{JB}$'] + print(y_values) + DrawFigure(x_values, y_values, legend_labels, + '', 'Latency (ms)', 0, + 400, 'latency_figure_app', False) + + # DrawLegend(legend_labels, 'latency_legend') diff --git a/benchmark/scripts/scanAlgoDelta/groupLine.py b/benchmark/scripts/scanAlgoDelta/groupLine.py new file mode 100755 index 00000000..8110fd3b --- /dev/null +++ b/benchmark/scripts/scanAlgoDelta/groupLine.py @@ -0,0 +1,366 @@ +import itertools as it +import os +import matplotlib.pyplot as plt +import matplotlib.font_manager as fm +import matplotlib +import numpy as np +import pylab +from matplotlib.font_manager import FontProperties +from matplotlib.ticker import MaxNLocator +from matplotlib.font_manager import FontProperties +from matplotlib.ticker import LinearLocator, LogLocator, MaxNLocator, ScalarFormatter +from numpy import double + +# 获取系统中可用的字体路径 +# font_paths = fm.findSystemFonts() +# OPT_FONT_NAME = 'Helvetica' +TICK_FONT_SIZE = 20 +LABEL_FONT_SIZE = 20 +LEGEND_FONT_SIZE = 20 +LABEL_FP = FontProperties(style='normal', size=LABEL_FONT_SIZE) +LEGEND_FP = FontProperties(style='normal', size=LEGEND_FONT_SIZE) +TICK_FP = FontProperties(style='normal', size=TICK_FONT_SIZE) + +MARKERS = (['o', 's', 'v', "^", "h", "v", ">", "x", "d", "<", "|", "p", "+", "_", "%", "|", "|", "|", "|", "|"]) +# you may want to change the color map for different figures +COLOR_MAP = ( + '#F15854', '#5DA5DA', '#60BD68', '#B276B2', '#DECF3F', '#F17CB0', '#B2912F', '#FAA43A', '#AFAFAF', '#087878', + '#783456', + '#560012', '#431256', "#00AABB", "#AA00BB") +# you may want to change the patterns for different figures +PATTERNS = (["|", "\\", "/", "+", "-", ".", "*", "x", "o", "O", "////", ".", "|||", "o", "---", "+", "\\\\", "*"]) +LABEL_WEIGHT = 'bold' +LINE_COLORS = COLOR_MAP +LINE_WIDTH = 3.0 +MARKER_SIZE = 13.0 +MARKER_FREQUENCY = 1000 + +# matplotlib.rcParams['ps.useafm'] = True +# matplotlib.rcParams['pdf.use14corefonts'] = True +# matplotlib.rcParams['xtick.labelsize'] = TICK_FONT_SIZE +# matplotlib.rcParams['ytick.labelsize'] = TICK_FONT_SIZE +# 创建字体列表 +# Explicitly specify the font path +# 获取系统中可用的字体路径 +font_paths = fm.findSystemFonts() + +# 创建字体列表 +font_list = [] +for font_path in font_paths: + try: + font_name = fm.FontProperties(fname=font_path).get_name() + if font_name not in font_list: + font_list.append(font_name) + except: + pass + +# 配置 matplotlib 使用系统中可用的字体 +plt.rcParams['font.family'] = font_list[0] + +FIGURE_FOLDER = '/data1/xtra/results/figure' + + +# there are some embedding problems if directly exporting the pdf figure using matplotlib. +# so we generate the eps format first and convert it to pdf. +def ConvertEpsToPdf(dir_filename): + os.system("epstopdf --outfile " + dir_filename + ".pdf " + dir_filename + ".eps") + os.system("rm -rf " + dir_filename + ".eps") + + +def DrawLegend(legend_labels, filename): + fig = pylab.figure() + ax1 = fig.add_subplot(111) + FIGURE_LABEL = legend_labels + LINE_WIDTH = 8.0 + MARKER_SIZE = 12.0 + LEGEND_FP = FontProperties(style='normal', size=26) + + figlegend = pylab.figure(figsize=(12, 0.5)) + idx = 0 + lines = [None] * (len(FIGURE_LABEL)) + data = [1] + x_values = [1] + + idx = 0 + for group in range(len(FIGURE_LABEL)): + lines[idx], = ax1.plot(x_values, data, + color=LINE_COLORS[idx], linewidth=LINE_WIDTH, + marker=MARKERS[idx], markersize=MARKER_SIZE, label=str(group)) + idx = idx + 1 + + # LEGEND + figlegend.legend(lines, FIGURE_LABEL, prop=LEGEND_FP, + loc=1, ncol=len(FIGURE_LABEL), mode="expand", shadow=False, + frameon=False, borderaxespad=0.0, handlelength=2) + + if not os.path.exists(FIGURE_FOLDER): + os.makedirs(FIGURE_FOLDER) + # no need to export eps in this case. + figlegend.savefig(filename + '.pdf') + + +# draw a line chart +def DrawFigure(xvalues, yvalues, legend_labels, x_label, y_label, y_min, y_max, filename, allow_legend): + # you may change the figure size on your own. + fig = plt.figure(figsize=(10, 3)) + figure = fig.add_subplot(111) + + FIGURE_LABEL = legend_labels + + x_values = xvalues + y_values = yvalues + + lines = [None] * (len(FIGURE_LABEL)) + for i in range(len(y_values)): + lines[i], = figure.plot(x_values[i], y_values[i], color=LINE_COLORS[i], \ + linewidth=LINE_WIDTH, marker=MARKERS[i], \ + markersize=MARKER_SIZE, label=FIGURE_LABEL[i]) + + # sometimes you may not want to draw legends. + if allow_legend == True: + plt.legend(lines, + FIGURE_LABEL, + prop=LEGEND_FP, + loc='upper center', + ncol=3, + # mode='expand', + bbox_to_anchor=(0.55, 1.6), shadow=False, + columnspacing=0.1, + frameon=True, borderaxespad=0.0, handlelength=1.5, + handletextpad=0.1, + labelspacing=0.1) + plt.xscale('log') + plt.yscale('log') + # plt.yscale('log') + + # you may control the limits on your own. + + # plt.ylim(y_min, y_max) + + plt.grid(axis='y', color='gray') + figure.yaxis.set_major_locator(LogLocator(base=10)) + figure.xaxis.set_major_locator(LogLocator(base=10)) + + figure.get_xaxis().set_tick_params(direction='in', pad=10) + figure.get_yaxis().set_tick_params(direction='in', pad=10) + + plt.xlabel(x_label, fontproperties=LABEL_FP) + plt.ylabel(y_label, fontproperties=LABEL_FP) + + size = fig.get_size_inches() + dpi = fig.get_dpi() + + # plt.show() + plt.savefig(filename + ".pdf", bbox_inches='tight') + + +# draw a line chart +def DrawFigureXYnormal(xvalues, yvalues, legend_labels, x_label, y_label, y_min, y_max, filename, allow_legend): + # you may change the figure size on your own. + fig = plt.figure(figsize=(10, 3)) + figure = fig.add_subplot(111) + + FIGURE_LABEL = legend_labels + + x_values = xvalues + y_values = yvalues + + lines = [None] * (len(FIGURE_LABEL)) + for i in range(len(y_values)): + lines[i], = figure.plot(x_values[i], y_values[i], color=LINE_COLORS[i], \ + linewidth=LINE_WIDTH, marker=MARKERS[i], \ + markersize=MARKER_SIZE, label=FIGURE_LABEL[i], markeredgecolor='k') + + # sometimes you may not want to draw legends. + if allow_legend == True: + plt.legend(lines, + FIGURE_LABEL, + prop=LEGEND_FP, + loc='upper center', + ncol=3, + bbox_to_anchor=(0.55, 1.5), shadow=False, + columnspacing=0.1, + frameon=True, borderaxespad=0, handlelength=1.2, + handletextpad=0.1, + labelspacing=0.1) + # plt.xscale('log') + # plt.yscale('log') + # plt.yscale('log') + + # you may control the limits on your own. + + # plt.ylim(y_min, y_max) + + plt.grid(axis='y', color='gray') + plt.rcParams['axes.unicode_minus'] = False # 用来正常显示负号 + # figure.yaxis.set_major_locator(LogLocator(base=10)) + # figure.xaxis.set_major_locator(LogLocator(base=10)) + plt.xticks(rotation=0, fontsize=TICK_FONT_SIZE) + figure.get_xaxis().set_tick_params(direction='in', pad=10) + figure.get_yaxis().set_tick_params(direction='in', pad=10) + + plt.xlabel(x_label, fontproperties=LABEL_FP) + plt.ylabel(y_label, fontproperties=LABEL_FP) + + size = fig.get_size_inches() + dpi = fig.get_dpi() + + # plt.show() + plt.savefig(filename + ".pdf", bbox_inches='tight') + + +# draw a line chart +def DrawFigureYnormal(xvalues, yvalues, legend_labels, x_label, y_label, y_min, y_max, filename, allow_legend): + # you may change the figure size on your own. + fig = plt.figure(figsize=(10, 3)) + figure = fig.add_subplot(111) + + FIGURE_LABEL = legend_labels + + x_values = xvalues + y_values = yvalues + + lines = [None] * (len(FIGURE_LABEL)) + for i in range(len(y_values)): + lines[i], = figure.plot(x_values[i], y_values[i], color=LINE_COLORS[i], \ + linewidth=LINE_WIDTH, marker=MARKERS[i], \ + markersize=MARKER_SIZE, label=FIGURE_LABEL[i], markeredgecolor='k') + + # sometimes you may not want to draw legends. + if allow_legend == True: + plt.legend(lines, + FIGURE_LABEL, + prop=LEGEND_FP, + loc='upper center', + ncol=3, + bbox_to_anchor=(0.55, 1.5), shadow=False, + columnspacing=0.1, + frameon=True, borderaxespad=0, handlelength=1.2, + handletextpad=0.1, + labelspacing=0.1) + plt.xscale('log') + # plt.yscale('log') + # plt.yscale('log') + + # you may control the limits on your own. + + # plt.ylim(y_min, y_max) + + plt.grid(axis='y', color='gray') + plt.rcParams['axes.unicode_minus'] = False # 用来正常显示负号 + # figure.yaxis.set_major_locator(LogLocator(base=10)) + # figure.xaxis.set_major_locator(LogLocator(base=10)) + plt.xticks(rotation=0, fontsize=TICK_FONT_SIZE) + figure.get_xaxis().set_tick_params(direction='in', pad=10) + figure.get_yaxis().set_tick_params(direction='in', pad=10) + + plt.xlabel(x_label, fontproperties=LABEL_FP) + plt.ylabel(y_label, fontproperties=LABEL_FP) + + size = fig.get_size_inches() + dpi = fig.get_dpi() + + # plt.show() + plt.savefig(filename + ".pdf", bbox_inches='tight') + + +# example for reading csv file +def ReadFile(): + y = [] + col1 = [] + col2 = [] + col3 = [] + col4 = [] + col5 = [] + col6 = [] + col7 = [] + col8 = [] + + for id in it.chain(range(28, 32)): + file = '/data1/xtra/results/timestamps/PRJ_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(len(read) - 1).strip("\n")) # get last timestamp + value = len(read) / x # get throughput (#items/ms) + col1.append(value) + y.append(col1) + + for id in it.chain(range(28, 32)): + file = '/data1/xtra/results/timestamps/NPJ_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(len(read) - 1).strip("\n")) # get last timestamp + value = len(read) / x # get throughput (#items/ms) + col2.append(value) + y.append(col2) + + for id in it.chain(range(28, 32)): + file = '/data1/xtra/results/timestamps/MPASS_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(len(read) - 1).strip("\n")) # get last timestamp + value = len(read) / x # get throughput (#items/ms) + col3.append(value) + y.append(col3) + + for id in it.chain(range(28, 32)): + file = '/data1/xtra/results/timestamps/MWAY_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(len(read) - 1).strip("\n")) # get last timestamp + value = len(read) / x # get throughput (#items/ms) + col4.append(value) + y.append(col4) + + for id in it.chain(range(28, 32)): + file = '/data1/xtra/results/timestamps/SHJ_JM_NP_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(len(read) - 1).strip("\n")) # get last timestamp + value = len(read) / x # get throughput (#items/ms) + col5.append(value) + y.append(col5) + + for id in it.chain(range(28, 32)): + file = '/data1/xtra/results/timestamps/SHJ_JBCR_NP_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(len(read) - 1).strip("\n")) # get last timestamp + value = len(read) / x # get throughput (#items/ms) + col6.append(value) + y.append(col6) + + for id in it.chain(range(28, 32)): + file = '/data1/xtra/results/timestamps/PMJ_JM_NP_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(len(read) - 1).strip("\n")) # get last timestamp + value = len(read) / x # get throughput (#items/ms) + col7.append(value) + y.append(col7) + + for id in it.chain(range(28, 32)): + file = '/data1/xtra/results/timestamps/PMJ_JBCR_NP_{}.txt'.format(id) + f = open(file, "r") + read = f.readlines() + x = float(read.pop(len(read) - 1).strip("\n")) # get last timestamp + value = len(read) / x # get throughput (#items/ms) + col8.append(value) + y.append(col8) + return y + + +if __name__ == "__main__": + # x_values = ['Unique', 'Zipf(0)', 'Zipf(0.2)', 'Zipf(0.4)', 'Zipf(0.8)', 'Zipf(1)'] + x_values = [1600, 3200, 6400, 12800, 25600] + + y_values = ReadFile() + + legend_labels = ['NPJ', 'PRJ', 'MWAY', 'MPASS', 'SHJ$^{JM}$', 'SHJ$^{JB}$', 'PMJ$^{JM}$', + 'PMJ$^{JB}$'] + + DrawFigure(x_values, y_values, legend_labels, + 'Input arrival rate of R (e/ms)', 'Tpt. (#matches/ms)', x_values[0], + x_values[4], 'throughput_figure1_1', False) + +# DrawLegend(legend_labels, 'factor_legend') diff --git a/benchmark/scripts/scanAlgoDelta/perfRu.csv b/benchmark/scripts/scanAlgoDelta/perfRu.csv new file mode 100644 index 00000000..9ee43623 --- /dev/null +++ b/benchmark/scripts/scanAlgoDelta/perfRu.csv @@ -0,0 +1,7 @@ +key,value,type +cacheMiss,12491377,U64 +cacheRefs,35327177,U64 +cpuClock,2478812100,U64 +cpuCycle,9889422467,U64 +instructions,16997458033,U64 +taskClock,2478813000,U64 diff --git a/figures/aCol/aColsampling_cacheMiss.pdf b/figures/aCol/aColsampling_cacheMiss.pdf new file mode 100644 index 00000000..c8dcb49e Binary files /dev/null and b/figures/aCol/aColsampling_cacheMiss.pdf differ diff --git a/figures/aCol/aColsampling_elapsedTime.pdf b/figures/aCol/aColsampling_elapsedTime.pdf new file mode 100644 index 00000000..49c2519d Binary files /dev/null and b/figures/aCol/aColsampling_elapsedTime.pdf differ diff --git a/figures/aCol/aColsketch_cacheMiss.pdf b/figures/aCol/aColsketch_cacheMiss.pdf new file mode 100644 index 00000000..1ad0ada0 Binary files /dev/null and b/figures/aCol/aColsketch_cacheMiss.pdf differ diff --git a/figures/aCol/aColsketch_elapsedTime.pdf b/figures/aCol/aColsketch_elapsedTime.pdf new file mode 100644 index 00000000..bbe20ede Binary files /dev/null and b/figures/aCol/aColsketch_elapsedTime.pdf differ diff --git a/figures/aColCPP/aCol_ebRatio.pdf b/figures/aColCPP/aCol_ebRatio.pdf new file mode 100644 index 00000000..af7b36e0 Binary files /dev/null and b/figures/aColCPP/aCol_ebRatio.pdf differ diff --git a/figures/aColCPP/aCol_froError.pdf b/figures/aColCPP/aCol_froError.pdf new file mode 100644 index 00000000..b8e87b8e Binary files /dev/null and b/figures/aColCPP/aCol_froError.pdf differ diff --git a/figures/aColCPP/aColsampling_cpp_cacheMiss.pdf b/figures/aColCPP/aColsampling_cpp_cacheMiss.pdf new file mode 100644 index 00000000..c5fa654a Binary files /dev/null and b/figures/aColCPP/aColsampling_cpp_cacheMiss.pdf differ diff --git a/figures/aColCPP/aColsampling_cpp_elapsedTime.pdf b/figures/aColCPP/aColsampling_cpp_elapsedTime.pdf new file mode 100644 index 00000000..a6bf4ec5 Binary files /dev/null and b/figures/aColCPP/aColsampling_cpp_elapsedTime.pdf differ diff --git a/figures/aColCPP/aColsketch_cpp_cacheMiss.pdf b/figures/aColCPP/aColsketch_cpp_cacheMiss.pdf new file mode 100644 index 00000000..b0385a7f Binary files /dev/null and b/figures/aColCPP/aColsketch_cpp_cacheMiss.pdf differ diff --git a/figures/aColCPP/aColsketch_cpp_ebRatio.pdf b/figures/aColCPP/aColsketch_cpp_ebRatio.pdf new file mode 100644 index 00000000..54f5659d Binary files /dev/null and b/figures/aColCPP/aColsketch_cpp_ebRatio.pdf differ diff --git a/figures/aColCPP/aColsketch_cpp_elapsedTime.pdf b/figures/aColCPP/aColsketch_cpp_elapsedTime.pdf new file mode 100644 index 00000000..07d2d8d7 Binary files /dev/null and b/figures/aColCPP/aColsketch_cpp_elapsedTime.pdf differ diff --git a/figures/aColCPP/aColsketch_cpp_froError.pdf b/figures/aColCPP/aColsketch_cpp_froError.pdf new file mode 100644 index 00000000..33380a8b Binary files /dev/null and b/figures/aColCPP/aColsketch_cpp_froError.pdf differ diff --git a/figures/aRow/aRowsampling_cacheMiss.pdf b/figures/aRow/aRowsampling_cacheMiss.pdf new file mode 100644 index 00000000..146a2023 Binary files /dev/null and b/figures/aRow/aRowsampling_cacheMiss.pdf differ diff --git a/figures/aRow/aRowsampling_elapsedTime.pdf b/figures/aRow/aRowsampling_elapsedTime.pdf new file mode 100644 index 00000000..5698dfa0 Binary files /dev/null and b/figures/aRow/aRowsampling_elapsedTime.pdf differ diff --git a/figures/aRow/aRowsketch_cacheMiss.pdf b/figures/aRow/aRowsketch_cacheMiss.pdf new file mode 100644 index 00000000..3d5449de Binary files /dev/null and b/figures/aRow/aRowsketch_cacheMiss.pdf differ diff --git a/figures/aRow/aRowsketch_elapsedTime.pdf b/figures/aRow/aRowsketch_elapsedTime.pdf new file mode 100644 index 00000000..3e5a2c4b Binary files /dev/null and b/figures/aRow/aRowsketch_elapsedTime.pdf differ diff --git a/figures/aRowCPP/aRowsampling_cpp_cacheMiss.pdf b/figures/aRowCPP/aRowsampling_cpp_cacheMiss.pdf new file mode 100644 index 00000000..a5678626 Binary files /dev/null and b/figures/aRowCPP/aRowsampling_cpp_cacheMiss.pdf differ diff --git a/figures/aRowCPP/aRowsampling_cpp_ebRatio.pdf b/figures/aRowCPP/aRowsampling_cpp_ebRatio.pdf new file mode 100644 index 00000000..912858f3 Binary files /dev/null and b/figures/aRowCPP/aRowsampling_cpp_ebRatio.pdf differ diff --git a/figures/aRowCPP/aRowsampling_cpp_elapsedTime.pdf b/figures/aRowCPP/aRowsampling_cpp_elapsedTime.pdf new file mode 100644 index 00000000..6e55ee63 Binary files /dev/null and b/figures/aRowCPP/aRowsampling_cpp_elapsedTime.pdf differ diff --git a/figures/aRowCPP/aRowsampling_cpp_froError.pdf b/figures/aRowCPP/aRowsampling_cpp_froError.pdf new file mode 100644 index 00000000..028a6803 Binary files /dev/null and b/figures/aRowCPP/aRowsampling_cpp_froError.pdf differ diff --git a/figures/aRowCPP/aRowsketch_cpp_cacheMiss.pdf b/figures/aRowCPP/aRowsketch_cpp_cacheMiss.pdf new file mode 100644 index 00000000..40a3add2 Binary files /dev/null and b/figures/aRowCPP/aRowsketch_cpp_cacheMiss.pdf differ diff --git a/figures/aRowCPP/aRowsketch_cpp_ebRatio.pdf b/figures/aRowCPP/aRowsketch_cpp_ebRatio.pdf new file mode 100644 index 00000000..a6114e39 Binary files /dev/null and b/figures/aRowCPP/aRowsketch_cpp_ebRatio.pdf differ diff --git a/figures/aRowCPP/aRowsketch_cpp_elapsedTime.pdf b/figures/aRowCPP/aRowsketch_cpp_elapsedTime.pdf new file mode 100644 index 00000000..5e62c94f Binary files /dev/null and b/figures/aRowCPP/aRowsketch_cpp_elapsedTime.pdf differ diff --git a/figures/aRowCPP/aRowsketch_cpp_froError.pdf b/figures/aRowCPP/aRowsketch_cpp_froError.pdf new file mode 100644 index 00000000..9a382895 Binary files /dev/null and b/figures/aRowCPP/aRowsketch_cpp_froError.pdf differ diff --git a/figures/algoBeta/algoBeta_cacheMiss.pdf b/figures/algoBeta/algoBeta_cacheMiss.pdf new file mode 100644 index 00000000..f59eaf14 Binary files /dev/null and b/figures/algoBeta/algoBeta_cacheMiss.pdf differ diff --git a/figures/algoBeta/algoBeta_ebRatio.pdf b/figures/algoBeta/algoBeta_ebRatio.pdf new file mode 100644 index 00000000..3e02ad5e Binary files /dev/null and b/figures/algoBeta/algoBeta_ebRatio.pdf differ diff --git a/figures/algoBeta/algoBeta_elapsedTime.pdf b/figures/algoBeta/algoBeta_elapsedTime.pdf new file mode 100644 index 00000000..e20e8204 Binary files /dev/null and b/figures/algoBeta/algoBeta_elapsedTime.pdf differ diff --git a/figures/algoBeta/algoBeta_froError.pdf b/figures/algoBeta/algoBeta_froError.pdf new file mode 100644 index 00000000..189352e2 Binary files /dev/null and b/figures/algoBeta/algoBeta_froError.pdf differ diff --git a/figures/algoDelta/algoDelta_cacheMiss.pdf b/figures/algoDelta/algoDelta_cacheMiss.pdf new file mode 100644 index 00000000..9ae6e511 Binary files /dev/null and b/figures/algoDelta/algoDelta_cacheMiss.pdf differ diff --git a/figures/algoDelta/algoDelta_ebRatio.pdf b/figures/algoDelta/algoDelta_ebRatio.pdf new file mode 100644 index 00000000..188005b5 Binary files /dev/null and b/figures/algoDelta/algoDelta_ebRatio.pdf differ diff --git a/figures/algoDelta/algoDelta_elapsedTime.pdf b/figures/algoDelta/algoDelta_elapsedTime.pdf new file mode 100644 index 00000000..1892bda3 Binary files /dev/null and b/figures/algoDelta/algoDelta_elapsedTime.pdf differ diff --git a/figures/algoDelta/algoDelta_froError.pdf b/figures/algoDelta/algoDelta_froError.pdf new file mode 100644 index 00000000..c971b4c6 Binary files /dev/null and b/figures/algoDelta/algoDelta_froError.pdf differ diff --git a/include/CPPAlgos/TugOfWarCPPAlgo.h b/include/CPPAlgos/TugOfWarCPPAlgo.h index 63e1692a..25c155d1 100644 --- a/include/CPPAlgos/TugOfWarCPPAlgo.h +++ b/include/CPPAlgos/TugOfWarCPPAlgo.h @@ -16,22 +16,24 @@ namespace AMMBench { /** * @class TugOfWarCPPAlgo CPPAlgos/TugOfWarCPPAlgo.h * @brief The tug of war class of c++ algoS + * @note parameters + * - algoDelta Double, the delta parameter in this algo, default 0.02 */ class TugOfWarCPPAlgo : public AMMBench::AbstractCPPAlgo { - double delta = 0.2; + double algoDelta = 0.02; public: TugOfWarCPPAlgo() { } - TugOfWarCPPAlgo(double delta) : delta(delta) { - - } - ~TugOfWarCPPAlgo() { } + /** + * @brief set the algo-specfic config related to one algorithm + */ + virtual void setConfig(INTELLI::ConfigMapPtr cfg); /** * @brief the virtual function provided for outside callers, rewrite in children classes diff --git a/src/CPPAlgos/TugOfWarCPPAlgo.cpp b/src/CPPAlgos/TugOfWarCPPAlgo.cpp index 54e0d592..1306612d 100644 --- a/src/CPPAlgos/TugOfWarCPPAlgo.cpp +++ b/src/CPPAlgos/TugOfWarCPPAlgo.cpp @@ -5,6 +5,10 @@ #include namespace AMMBench { +void TugOfWarCPPAlgo::setConfig(INTELLI::ConfigMapPtr cfg) { + algoDelta = cfg->tryDouble("algoDelta",algoDelta,true); +} + torch::Tensor TugOfWarCPPAlgo::generateTugOfWarMatrix(int64_t m, int64_t n) { double e = 1.0 / std::sqrt(m); torch::Tensor M = torch::randint(2, {m, n}); @@ -15,6 +19,9 @@ torch::Tensor TugOfWarCPPAlgo::amm(torch::Tensor A, torch::Tensor B, uint64_t l2 int64_t n = A.size(1); int64_t p = B.size(1); int64_t l = (int64_t) l2; + + double delta = algoDelta; + int64_t i_iters = static_cast(-std::log(delta)); int64_t j_iters = static_cast(2 * (-std::log(delta) + std::log(-std::log(delta))));