Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,5 @@ jobs:
./cpp_test "--success"
./sketch_test "--success"
./crs_test "--success"
./weighted_cr_test "--success"
./weighted_cr_test "--success"
./block_partition_test "--success"
2 changes: 1 addition & 1 deletion Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = "AMMBench"
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 0.1.2
PROJECT_NUMBER = 0.1.3

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,14 @@ mkdir build && cd build
```

Build for release by default:

```shell
cmake -DCMAKE_PREFIX_PATH=`python3 -c 'import torch;print(torch.utils.cmake_prefix_path)'` ..
make
```

Or you can build with debug mode to debug cpp dynamic lib:

```shell
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH=`python3 -c 'import torch;print(torch.utils.cmake_prefix_path)'` ..
make
Expand Down Expand Up @@ -213,4 +215,5 @@ You will find the figures then.
2. Some pytorch version can not work well with liblog4cxx and googletest, so we diabled it.
3. Clion may fail to render and highlight the torch apis. In this case, kindly type a random line of "555"
to validate the highlight when you need it, and comment it during a compile. :)
4. When setting up torch for cpu under python version > 3.10, torch == 1.13.0 would conflict with torchaudio according to https://pytorch.org/audio/stable/installation.html. Use Python version <= 3.10 for smooth installation.
4. When setting up torch for cpu under python version > 3.10, torch == 1.13.0 would conflict with torchaudio according
to https://pytorch.org/audio/stable/installation.html. Use Python version <= 3.10 for smooth installation.
6 changes: 6 additions & 0 deletions benchmark/scripts/scanARow/config_WCR.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
key,value,type
aRow,100,U64
aCol,1000,U64
bCol,500,U64
sketchDimension,25,U64
ptFile,torchscripts/WeightedCR.pt,String
76 changes: 43 additions & 33 deletions benchmark/scripts/scanARow/drawTogether.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,65 +98,75 @@ def readResultVector(singleValueVec, resultPath):
cacheRefVec.append(float(cacheRefs))
return np.array(elapseTimeVec), np.array(cacheMissVec), np.array(cacheRefVec)

def compareMethod(exeSpace,commonPathBase,resultPaths,csvTemplates,periodVec,reRun=1):
elapsedTimeAll=[]
cacheMissAll=[]
cacheRefAll=[]
periodAll=[]

def compareMethod(exeSpace, commonPathBase, resultPaths, csvTemplates, periodVec, reRun=1):
elapsedTimeAll = []
cacheMissAll = []
cacheRefAll = []
periodAll = []
for i in range(len(csvTemplates)):
resultPath=commonPathBase+resultPaths[i]
if(reRun==1):
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 = readResultVector(periodVec, resultPath)
runScanVector(exeSpace, periodVec, resultPath, csvTemplates[i])
elapsedTime, cacheMiss, cacheRef = readResultVector(periodVec, resultPath)
elapsedTimeAll.append(elapsedTime)
cacheMissAll.append(cacheMiss)
cacheRefAll.append(cacheRef)
periodAll.append(periodVec)
cacheMissRateAll=np.array(cacheMissAll)/np.array(cacheRefAll)*100.0
#periodAll.append(periodVec)
return np.array(elapsedTimeAll),cacheMissRateAll,periodAll
cacheMissRateAll = np.array(cacheMissAll) / np.array(cacheRefAll) * 100.0
# periodAll.append(periodVec)
return np.array(elapsedTimeAll), cacheMissRateAll, periodAll


def main():
exeSpace = os.path.abspath(os.path.join(os.getcwd(), "../..")) + "/"
commonBase = os.path.abspath(os.path.join(os.getcwd(), "../..")) + "/results/" + scanTag+"/"
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 = ["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]
valueVecDisp = np.array(valueVec)
# run
reRun=0
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
#skech
elapsedTimeAll,cacheMissAll,periodAll=compareMethod(exeSpace,commonBase,resultPaths,csvTemplates,valueVec,reRun)
groupLine.DrawFigure(periodAll,elapsedTimeAll,
reRun = 1
# skech
elapsedTimeAll, cacheMissAll, periodAll = 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_elapsedTime",
"#elements in A's row", "elapsed time (ms)", 0, 1,
figPath + "/" + scanTag + "sketch_elapsedTime",
True)
groupLine.DrawFigureYnormal(periodAll,cacheMissAll,
groupLine.DrawFigureYnormal(periodAll, cacheMissAll,
methodTags,
"#elements in A's row", "cacheMiss (%)", 0, 1, figPath + "/"+scanTag + "sketch_cacheMiss",
"#elements in A's row", "cacheMiss (%)", 0, 1,
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"]
elapsedTimeAll,cacheMissAll,periodAll=compareMethod(exeSpace,commonBase,resultPaths,csvTemplates,valueVec,reRun)
groupLine.DrawFigure(periodAll,elapsedTimeAll,
# 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"]
elapsedTimeAll, cacheMissAll, periodAll = compareMethod(exeSpace, commonBase, resultPaths, csvTemplates, valueVec,
reRun)
groupLine.DrawFigure(periodAll, elapsedTimeAll,
methodTags,
"#elements in A's row", "elapsed time (ms)", 0, 1, figPath +"/"+ scanTag + "sampling_elapsedTime",
"#elements in A's row", "elapsed time (ms)", 0, 1,
figPath + "/" + scanTag + "sampling_elapsedTime",
True)
groupLine.DrawFigureYnormal(periodAll,cacheMissAll,
groupLine.DrawFigureYnormal(periodAll, cacheMissAll,
methodTags,
"#elements in A's row", "cacheMiss (%)", 0, 1, figPath + "/"+scanTag + "sampling_cacheMiss",
"#elements in A's row", "cacheMiss (%)", 0, 1,
figPath + "/" + scanTag + "sampling_cacheMiss",
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")
Expand Down
125 changes: 125 additions & 0 deletions benchmark/scripts/scanThreads/OoOCommon.py
Original file line number Diff line number Diff line change
@@ -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")
Loading