Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade instrument helpful for conducting experiments #2

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
77e05c4
Add kernels by Ivan Khromov
spisladqo Oct 21, 2024
be846fc
Fix kernel1 and kernel2 headers
spisladqo Oct 29, 2024
3e673f4
Add script to run kernelN tests and store output to file
spisladqo Oct 29, 2024
b8576b7
Fix order of loops in script for running tests
spisladqo Oct 29, 2024
dfaa1c4
Remove triple loop sgemm from experiments
spisladqo Nov 7, 2024
d6b580c
Fix kernel3 and add triple loop sgemm in drivers back
spisladqo Nov 15, 2024
3c1cc28
Merge branch 'SparseLinearAlgebra:master' into optimization_check
spisladqo Jan 4, 2025
b403d52
Modify script for running custom kernels
spisladqo Jan 5, 2025
33f15e7
Modify script to save all program outputs
spisladqo Jan 5, 2025
fe18375
Change warps and threads depending on test. Add IPC graph. TS=4 again
spisladqo Jan 5, 2025
30a4ef9
Remove kernel4 example for being irrelevant
spisladqo Jan 5, 2025
51801bb
Add time collection, normality tests and refactor code
spisladqo Jan 24, 2025
3695976
Fix incorrect conditions and syntax errors in script
spisladqo Jan 25, 2025
f7ed9d1
Add compiler flag to save asm files, save asm of first 3 kernels from…
spisladqo Jan 28, 2025
a1117ef
Modify driver code to run N tests in a single program build
spisladqo Feb 22, 2025
7660cc7
Add asm generated by llvm clang to compare it to vortex-native asm
spisladqo Feb 26, 2025
0beee6a
Merge branch 'SparseLinearAlgebra:master' into optimization_check
spisladqo Mar 7, 2025
d284530
xrt sandbox simulation
tinebp Feb 12, 2025
68f93f8
Fix incorrect local and global sizes in test 3
spisladqo Mar 10, 2025
5a1dc50
Fix warps num in runtests script
spisladqo Mar 11, 2025
9ff7c09
Add directories needed by script
spisladqo Mar 11, 2025
6f46bb5
Add full artifacts of kernel build
spisladqo Mar 12, 2025
5ecff3e
Delete build artifacts
spisladqo Mar 19, 2025
3bc7b48
Move experiments directory, add instructions
spisladqo Mar 19, 2025
cfb5d07
Remove auxiliary macroses in VX_config
spisladqo Mar 19, 2025
2a9115f
Delete generated assembler files
spisladqo Mar 19, 2025
aa22703
Add details to instruction
spisladqo Mar 19, 2025
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
12 changes: 12 additions & 0 deletions for_experiments/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# runtests.py
Инструмент для конфигурации параметров тестов и Vortex, сборки тестов, их запуска под симуляциями/на FPGA, сбора статистики и отрисовки графиков.

Для того, чтобы тесты запускались TESTS_NUM раз, требуется обернуть код хоста, отвечающий за запуск тестов и сбор результатов, в цикл. Пример можно увидеть в `vortex/tests/opencl/kernel1/main.cc`. Вывод со всех запусков одного теста сохраняется в один файл.

# Эксперименты с локальной памятью и стеком

В `vortex/hw/rtl/VX_config.vh` задаются начальные адреса стека и локальной памяти.

Там была добавлена переменная NEW_STACK_BASE_ADDR. На данный момент она вычисляется аналогично формуле из `vortex/hw/rtl/core/VX_lsu_slice.sv` (формула вычисления конца локальной памяти).

Для смещения стека нужно изменить STACK_BASE_ADDR на NEW_STACK_BASE_ADDR в `vortex/kernel/src/vx_start.S` в данной строчке: `LOAD_IMMEDIATE64(sp, STACK_BASE_ADDR)` и пересобрать Vortex.
93 changes: 93 additions & 0 deletions for_experiments/draw_time.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import matplotlib.pyplot as plt
from scipy import stats
import numpy as np
from matplotlib.pyplot import figure

# PUT YOUR PATH HERE
IMG_PATH="/home/spisladqo/Desktop/"

n256_kernel1_res = [373.0, 366.0, 372.0, 373.0, 366.0, 371.0, 365.0, 365.0, 365.0, 370.0, 372.0, 364.0, 370.0, 365.0, 371.0, 374.0, 364.0, 372.0, 374.0, 369.0, 371.0, 377.0, 371.0, 370.0, 373.0, 367.0, 371.0, 365.0, 371.0, 370.0, 364.0, 364.0, 374.0, 369.0, 364.0, 369.0, 370.0, 372.0, 373.0, 370.0, 368.0, 364.0, 365.0, 364.0, 373.0, 371.0, 373.0, 370.0, 371.0, 365.0, 373.0, 374.0, 365.0, 388.0, 368.0, 372.0, 376.0, 371.0, 366.0, 372.0, 366.0, 365.0, 365.0, 370.0, 365.0, 372.0, 371.0, 367.0, 371.0, 371.0, 371.0, 374.0, 384.0, 365.0, 365.0, 369.0, 369.0, 373.0, 369.0, 373.0, 369.0, 366.0, 365.0, 364.0, 372.0, 365.0, 370.0, 364.0, 370.0, 366.0, 373.0, 371.0, 377.0, 367.0, 366.0]

n256_kernel2_res = [1358.0, 1353.0, 1358.0, 1336.0, 1357.0, 1359.0, 1358.0, 1357.0, 1357.0, 1358.0, 1358.0, 1358.0, 1356.0, 1355.0, 1359.0, 1358.0, 1358.0, 1359.0, 1358.0, 1359.0, 1358.0, 1359.0, 1359.0, 1357.0, 1355.0, 1358.0, 1359.0, 1358.0, 1358.0, 1358.0, 1337.0, 1358.0, 1356.0, 1358.0, 1358.0, 1359.0, 1356.0, 1358.0, 1341.0, 1358.0, 1358.0, 1358.0, 1357.0, 1358.0, 1358.0, 1357.0, 1358.0, 1358.0, 1352.0, 1344.0, 1357.0, 1358.0, 1348.0, 1358.0, 1357.0, 1351.0, 1354.0, 1358.0, 1357.0, 1359.0, 1358.0, 1332.0, 1332.0, 1356.0, 1358.0, 1357.0, 1356.0, 1358.0, 1357.0, 1357.0, 1358.0, 1331.0, 1358.0, 1358.0, 1340.0, 1356.0, 1358.0, 1359.0, 1357.0, 1358.0, 1357.0, 1357.0, 1358.0, 1358.0, 1358.0, 1356.0, 1358.0, 1328.0, 1357.0, 1357.0, 1357.0, 1358.0, 1358.0, 1358.0, 1340.0]

n256_kernel3_res = [6059.0, 6055.0, 6059.0, 6061.0, 6058.0, 6054.0, 6060.0, 6056.0, 6057.0, 6054.0, 6059.0, 6062.0, 6057.0, 6057.0, 6053.0, 6059.0, 6059.0, 6054.0, 6060.0, 6057.0, 6057.0, 6058.0, 6057.0, 6059.0, 6058.0, 6060.0, 6055.0, 6054.0, 6058.0, 6049.0, 6058.0, 6057.0, 6060.0, 6058.0, 6060.0, 6060.0, 6054.0, 6060.0, 6049.0, 6057.0, 6062.0, 6056.0, 6058.0, 6058.0, 6050.0, 6059.0, 6056.0, 6054.0, 6056.0, 6058.0, 6056.0, 6063.0, 6052.0, 6052.0, 6054.0, 6056.0, 6060.0, 6060.0, 6060.0, 6051.0, 6064.0, 6056.0, 6057.0, 6058.0, 6057.0, 6056.0, 6062.0, 6051.0, 6058.0, 6054.0, 6061.0, 6050.0, 6060.0, 6059.0, 6057.0, 6039.0, 6056.0, 6056.0, 6044.0, 6058.0, 6046.0, 6059.0, 6052.0, 6062.0, 6057.0, 6057.0, 6054.0, 6053.0, 6056.0, 6056.0, 6060.0, 6058.0, 6061.0, 6058.0, 6055.0]


n512_kernel1_res = [3448.0, 3279.0, 3587.0, 3495.0, 3293.0, 3556.0, 3307.0, 3240.0, 3400.0, 3170.0, 3645.0, 3302.0, 3558.0, 3425.0, 3192.0, 3290.0, 3375.0, 3280.0, 3372.0, 3412.0, 3486.0, 3058.0, 3146.0, 3110.0, 3114.0, 3385.0, 3349.0, 3558.0, 3309.0, 3157.0, 3260.0, 3445.0, 3304.0, 3434.0, 3417.0, 3015.0, 3545.0, 3430.0, 3016.0, 3418.0, 3016.0, 3392.0, 3416.0, 3260.0, 3211.0, 3143.0, 3375.0, 3421.0, 3432.0, 3517.0, 3438.0, 3430.0, 3143.0, 3398.0, 3121.0, 3452.0, 3673.0, 3014.0, 3457.0, 3398.0, 3248.0, 3340.0, 3260.0, 3145.0, 3401.0, 3474.0, 3233.0, 3363.0, 3405.0, 3015.0, 3336.0, 3471.0, 3179.0, 3398.0, 3078.0, 3154.0, 3456.0, 3433.0, 3396.0, 3417.0, 3349.0, 3309.0, 3146.0, 3573.0, 3016.0, 3275.0, 3294.0, 3312.0, 3474.0, 3407.0, 3342.0, 3467.0, 3634.0, 3110.0, 3394.0]

n512_kernel2_res = [10405.0, 10419.0, 10407.0, 10396.0, 10407.0, 10400.0, 10404.0, 10406.0, 10410.0, 10404.0, 10407.0, 10408.0, 10398.0, 10399.0, 10417.0, 10405.0, 10400.0, 10409.0, 10401.0, 10418.0, 10410.0, 10404.0, 10397.0, 10411.0, 10421.0, 10413.0, 10407.0, 10406.0, 10397.0, 10400.0, 10413.0, 10412.0, 10405.0, 10409.0, 10401.0, 10397.0, 10405.0, 10396.0, 10403.0, 10408.0, 10402.0, 10399.0, 10395.0, 10404.0, 10405.0, 10402.0, 10399.0, 10397.0, 10404.0, 10405.0, 10405.0, 10412.0, 10400.0, 10410.0, 10405.0, 10413.0, 10414.0, 10404.0, 10410.0, 10405.0, 10406.0, 10410.0, 10411.0, 10414.0, 10408.0, 10396.0, 10401.0, 10413.0, 10403.0, 10410.0, 10410.0, 10404.0, 10406.0, 10403.0, 10403.0, 10414.0, 10412.0, 10416.0, 10399.0, 10403.0, 10409.0, 10394.0, 10398.0, 10395.0, 10400.0, 10401.0, 10407.0, 10403.0, 10411.0, 10399.0, 10418.0, 10401.0, 10402.0, 10401.0, 10406.0]

n512_kernel3_res = [47582.0, 47570.0, 47583.0, 47582.0, 47573.0, 47585.0, 47574.0, 47581.0, 47569.0, 47583.0, 47582.0, 47590.0, 47576.0, 47584.0, 47578.0, 47581.0, 47601.0, 47582.0, 47587.0, 47578.0, 47587.0, 47596.0, 47590.0, 47577.0, 47574.0, 47575.0, 47581.0, 47582.0, 47588.0, 47582.0, 47587.0, 47600.0, 47605.0, 47577.0, 47582.0, 47594.0, 47572.0, 47586.0, 47595.0, 47595.0, 47587.0, 47577.0, 47580.0, 47560.0, 47590.0, 47577.0, 47574.0, 47584.0, 47592.0, 47584.0, 47575.0, 47584.0, 47581.0, 47576.0, 47593.0, 47580.0, 47575.0, 47576.0, 47573.0, 47591.0, 47576.0, 47591.0, 47597.0, 47579.0, 47560.0, 47598.0, 47600.0, 47575.0, 47573.0, 47587.0, 47570.0, 47592.0, 47577.0, 47573.0, 47596.0, 47554.0, 47591.0, 47564.0, 47582.0, 47583.0, 47606.0, 47582.0, 47581.0, 47578.0, 47568.0, 47596.0, 47586.0, 47597.0, 47578.0, 47591.0, 47589.0, 47575.0, 47576.0, 47569.0, 47576.0]


n1024_kernel1_res = [28150.0, 28862.0, 29544.0, 30206.0, 28569.0, 28654.0, 30181.0, 30150.0, 29474.0, 30106.0, 28512.0, 30042.0, 28701.0, 28152.0, 28859.0, 30155.0, 30224.0, 29432.0, 28911.0, 28687.0, 30063.0, 30143.0, 28861.0, 28211.0, 28954.0, 29875.0, 29986.0, 30087.0, 30087.0, 28651.0, 28900.0, 28697.0, 28846.0, 29990.0, 28665.0, 30013.0, 28193.0, 29111.0, 30110.0, 29093.0, 28558.0, 28558.0, 28635.0, 30102.0, 30165.0, 29002.0, 29136.0, 28254.0, 28054.0, 30038.0, 30063.0, 30144.0, 30051.0, 29017.0, 28873.0, 28867.0, 28559.0, 28502.0, 28640.0, 29110.0, 28493.0, 29467.0, 28175.0, 28537.0, 30084.0, 29158.0, 28046.0, 28292.0, 28527.0, 28814.0, 28063.0, 28756.0, 30168.0, 29314.0, 29363.0, 28504.0, 28446.0, 29029.0, 28272.0, 29360.0, 29034.0, 28835.0, 28704.0, 28443.0, 28983.0, 29316.0, 30144.0, 28205.0, 28947.0, 29641.0, 29991.0, 30107.0, 30053.0, 28549.0, 28545.0]

n1024_kernel2_res = [82354.0, 82365.0, 82404.0, 82295.0, 82304.0, 82384.0, 82319.0, 82314.0, 82291.0, 82312.0, 82352.0, 82349.0, 82393.0, 82389.0, 82373.0, 82363.0, 82416.0, 82292.0, 82394.0, 82397.0, 82371.0, 82316.0, 82255.0, 82382.0, 82385.0, 82385.0, 82339.0, 82405.0, 82378.0, 82342.0, 82413.0, 82401.0, 82385.0, 82328.0, 82299.0, 82389.0, 82341.0, 82394.0, 82318.0, 82378.0, 82407.0, 82337.0, 82396.0, 82360.0, 82323.0, 82374.0, 82358.0, 82356.0, 82314.0, 82334.0, 82327.0, 82396.0, 82366.0, 82348.0, 82346.0, 82381.0, 82424.0, 82278.0, 82314.0, 82365.0, 82350.0, 82363.0, 82378.0, 82415.0, 82378.0, 82458.0, 82366.0, 82250.0, 82399.0, 82376.0, 82357.0, 82350.0, 82209.0, 82382.0, 82396.0, 82282.0, 82315.0, 82313.0, 82385.0, 82291.0, 82395.0, 82312.0, 82324.0, 82313.0, 82327.0, 82419.0, 82381.0, 82362.0, 82324.0, 82372.0, 82327.0, 82389.0, 82339.0, 82320.0, 82265.0]

n1024_kernel3_res = [391810.0, 386761.0, 393515.0, 395321.0, 397165.0, 394845.0, 392653.0, 392496.0, 401358.0, 395533.0, 396324.0, 387395.0, 384694.0, 394182.0, 393119.0, 390446.0, 387248.0, 394546.0, 387006.0, 392582.0, 394817.0, 399672.0, 396924.0, 391020.0, 385367.0, 389838.0, 390885.0, 387743.0, 395776.0, 393097.0, 390371.0, 392909.0, 387943.0, 392467.0, 384945.0, 394151.0, 394899.0, 386740.0, 395799.0, 392502.0, 388976.0, 390435.0, 395814.0, 390241.0, 390657.0, 390629.0, 395900.0, 403441.0, 389058.0, 395286.0, 394472.0, 390110.0, 399185.0, 393488.0, 393870.0, 395265.0, 395560.0, 391591.0, 391356.0, 389840.0, 393721.0, 398932.0, 393984.0, 386239.0, 385353.0, 390503.0, 392246.0, 403124.0, 394703.0, 395079.0, 389900.0, 391337.0, 392764.0, 398275.0, 396458.0, 390787.0, 393488.0, 404521.0, 389960.0, 393945.0, 392484.0, 387752.0, 386394.0, 390836.0, 397008.0, 394390.0, 389267.0, 394980.0, 396399.0, 389091.0, 390432.0, 395251.0, 394293.0, 391675.0, 396709.0]

n256_res = [n256_kernel1_res, n256_kernel2_res, n256_kernel3_res]
n512_res = [n512_kernel1_res, n512_kernel2_res, n512_kernel3_res]
n1024_res = [n1024_kernel1_res, n1024_kernel2_res, n1024_kernel3_res]

def find_list_means(ls: list) -> list:
return list(map(lambda x: (np.mean(x)), ls))

def find_list_stds(ls: list) -> list:
return list(map(lambda x: (np.std(x, ddof=1)), ls))

def find_list_margin_of_err(ls : list) -> list:
return list(map(lambda x: stats.t.ppf(0.975, df=len(x)-1)*stats.sem(x), ls))

testnames = ("No opt", "LT", "LT + More WPT")

matrices = ["Matrices 256x256", "Matrices 512x512", "Matrices 1024x1024"]

n256_means = find_list_means(n256_res)
n512_means = find_list_means(n512_res)
n1024_means = find_list_means(n1024_res)

time_means = {
matrices[0]: n256_means,
matrices[1]: n512_means,
matrices[2]: n1024_means,
}

n256_stds = find_list_stds(n256_res)
n512_stds = find_list_stds(n512_res)
n1024_stds = find_list_stds(n1024_res)

time_stds = {
matrices[0]: n256_stds,
matrices[1]: n512_stds,
matrices[2]: n1024_stds,
}

time_margins_of_err = {
matrices[0]: find_list_margin_of_err(n256_res),
matrices[1]: find_list_margin_of_err(n512_res),
matrices[2]: find_list_margin_of_err(n1024_res),
}

for i in matrices:
print(i)
for j in range(3):
print("Testname:", testnames[j])
print("Mean:", time_means[i][j])
print("Std: ", time_stds[i][j])
print("Margin of err:", time_margins_of_err[i][j])
print("Margin of err, relative (% of mean):", time_margins_of_err[i][j] * 100 / time_means[i][j])
print("Margin of err, relative (% of std):", time_margins_of_err[i][j] * 100 / time_stds[i][j])

matrices = ["Matrices 256x256", "Matrices 512x512", "Matrices 1024x1024"]
sizes = [256, 512, 1024]

for i in range(len(matrices)):
key = matrices[i]
figure(figsize=(6.5, 8), dpi=80)
plt.bar(testnames, time_means[key])
plt.errorbar(testnames, time_means[key], yerr=time_stds[matrices[i]], capsize=3, ecolor="black", fmt="o")
plt.title(f"Avg time of matrix multiplication on FPGA\n{key}")
plt.xlabel("Test")
plt.ylabel("Time (ms)")
plt.savefig(f"{IMG_PATH}/time_graph_fpga_{sizes[i]}")
Empty file added for_experiments/graphics/.keep
Empty file.
Empty file added for_experiments/outputs/.keep
Empty file.
Loading