aboutsummaryrefslogtreecommitdiffstats
path: root/buch/papers/multiplikation/code
diff options
context:
space:
mode:
authorNunigan <michael.schmid2@ost.ch>2021-08-03 22:08:02 +0200
committerNunigan <michael.schmid2@ost.ch>2021-08-03 22:08:02 +0200
commite5da5157fb61cdb006f3f50a2b3bd3b922644f1f (patch)
treedb84132c4dfbe94692a153895fb83eb84d3ed402 /buch/papers/multiplikation/code
parentupdate (diff)
downloadSeminarMatrizen-e5da5157fb61cdb006f3f50a2b3bd3b922644f1f.tar.gz
SeminarMatrizen-e5da5157fb61cdb006f3f50a2b3bd3b922644f1f.zip
update
Diffstat (limited to 'buch/papers/multiplikation/code')
-rw-r--r--buch/papers/multiplikation/code/MM.py53
-rw-r--r--buch/papers/multiplikation/code/meas_1024.pdfbin18813 -> 18813 bytes
-rw-r--r--buch/papers/multiplikation/code/meas_4096.pdfbin0 -> 12952 bytes
-rw-r--r--buch/papers/multiplikation/code/meas_4096.txt0
4 files changed, 29 insertions, 24 deletions
diff --git a/buch/papers/multiplikation/code/MM.py b/buch/papers/multiplikation/code/MM.py
index ee6f598..47bd6ab 100644
--- a/buch/papers/multiplikation/code/MM.py
+++ b/buch/papers/multiplikation/code/MM.py
@@ -132,6 +132,10 @@ def winograd2(A, B):
return C
def test_perfomance(n):
+
+ import mkl
+ mkl.set_num_threads(1)
+
t_mm = []
t_mm_dc = []
t_mm_strassen = []
@@ -144,21 +148,21 @@ def test_perfomance(n):
# A = np.random.randint(-100, 100,(i, i))
# B = np.random.randint(-100, 100,(i, i))
- start = time.time()
- C3 = strassen(A, B)
- t_mm_strassen.append(time.time() - start)
+ # start = time.time()
+ # C3 = strassen(A, B)
+ # t_mm_strassen.append(time.time() - start)
- start = time.time()
- C1 = MM(A, B)
- t_mm.append(time.time() - start)
+ # start = time.time()
+ # C1 = MM(A, B)
+ # t_mm.append(time.time() - start)
- start = time.time()
- C2 = MM_dc(A, B)
- t_mm_dc.append(time.time() - start)
+ # start = time.time()
+ # C2 = MM_dc(A, B)
+ # t_mm_dc.append(time.time() - start)
- start = time.time()
- C4 = winograd2(A, B)
- t_wino.append(time.time() - start)
+ # start = time.time()
+ # C4 = winograd2(A, B)
+ # t_wino.append(time.time() - start)
start = time.time()
C = A@B
@@ -169,10 +173,10 @@ def test_perfomance(n):
plt.rc('axes', labelsize=23)
plt.rc('xtick', labelsize=23)
plt.rc('ytick', labelsize=23)
- plt.plot(n, t_mm, label='Standard', lw=5)
- plt.plot(n, t_mm_dc, label='Divide and conquer', lw=5)
- plt.plot(n, t_mm_strassen, label='Strassen', lw=5)
- plt.plot(n, t_wino, label='Winograd', lw=5)
+ # plt.plot(n, t_mm, label='Standard', lw=5)
+ # plt.plot(n, t_mm_dc, label='Divide and conquer', lw=5)
+ # plt.plot(n, t_mm_strassen, label='Strassen', lw=5)
+ # plt.plot(n, t_wino, label='Winograd', lw=5)
plt.plot(n, t_np, label='NumPy A@B', lw=5)
# plt.xscale('log', base=2)
plt.legend()
@@ -182,10 +186,10 @@ def test_perfomance(n):
plt.tight_layout()
# plt.yscale('log')
plt.legend(fontsize=19)
- plt.savefig('meas_' + str(max(n))+ '.pdf')
- arr = np.array([n, t_mm, t_mm_dc, t_mm_strassen, t_wino, t_np])
- np.savetxt('meas_' + str(max(n))+ '.txt',arr)
- return arr
+ # plt.savefig('meas_' + str(max(n))+ '.pdf')
+ # arr = np.array([n, t_mm, t_mm_dc, t_mm_strassen, t_wino, t_np])
+ # np.savetxt('meas_' + str(max(n))+ '.txt',arr)
+ return t_np
def plot(num):
@@ -213,6 +217,7 @@ def plot(num):
return arr
def plot_c_res(ave, num):
+
MM = np.loadtxt("meas/MM.txt", delimiter=',')
winograd = np.loadtxt("meas/winograd.txt", delimiter=',')
blas = np.loadtxt("meas/blas.txt", delimiter=',')
@@ -277,11 +282,11 @@ def plot_c_res(ave, num):
# test%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if __name__ == '__main__':
- plot_c_res(1, 4096)
+ # plot_c_res(1, 4096)
- # plot(1024)
- # n = np.logspace(1,10,10,base=2,dtype=(np.int))
+ # arr = plot(1024)
+ n = np.logspace(1,12,12,base=2,dtype=(np.int))
# n = np.arange(1,50,2)
# A = np.random.randint(-10, 6, (5,3))
# B = np.random.randint(-10, 6, (3,5))
@@ -292,7 +297,7 @@ if __name__ == '__main__':
# print(C_test)
# print(np.equal(C, C_test))
- # t_np = test_perfomance(n)
+ t_np = test_perfomance(n)
# C = strassen(A, B)
# C_test = A@B
diff --git a/buch/papers/multiplikation/code/meas_1024.pdf b/buch/papers/multiplikation/code/meas_1024.pdf
index 70c7ec1..3312420 100644
--- a/buch/papers/multiplikation/code/meas_1024.pdf
+++ b/buch/papers/multiplikation/code/meas_1024.pdf
Binary files differ
diff --git a/buch/papers/multiplikation/code/meas_4096.pdf b/buch/papers/multiplikation/code/meas_4096.pdf
new file mode 100644
index 0000000..e889d17
--- /dev/null
+++ b/buch/papers/multiplikation/code/meas_4096.pdf
Binary files differ
diff --git a/buch/papers/multiplikation/code/meas_4096.txt b/buch/papers/multiplikation/code/meas_4096.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/buch/papers/multiplikation/code/meas_4096.txt