From e5da5157fb61cdb006f3f50a2b3bd3b922644f1f Mon Sep 17 00:00:00 2001 From: Nunigan Date: Tue, 3 Aug 2021 22:08:02 +0200 Subject: update --- buch/papers/multiplikation/code/MM.py | 53 +++++++++------- buch/papers/multiplikation/code/meas_1024.pdf | Bin 18813 -> 18813 bytes buch/papers/multiplikation/code/meas_4096.pdf | Bin 0 -> 12952 bytes buch/papers/multiplikation/code/meas_4096.txt | 0 buch/papers/multiplikation/images/c_meas_4096.pdf | Bin 15865 -> 17400 bytes buch/papers/multiplikation/loesungsmethoden.tex | 73 +++++++++++++++++++++- 6 files changed, 101 insertions(+), 25 deletions(-) create mode 100644 buch/papers/multiplikation/code/meas_4096.pdf create mode 100644 buch/papers/multiplikation/code/meas_4096.txt (limited to 'buch/papers/multiplikation') 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 Binary files a/buch/papers/multiplikation/code/meas_1024.pdf and b/buch/papers/multiplikation/code/meas_1024.pdf 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 Binary files /dev/null and b/buch/papers/multiplikation/code/meas_4096.pdf 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 diff --git a/buch/papers/multiplikation/images/c_meas_4096.pdf b/buch/papers/multiplikation/images/c_meas_4096.pdf index 547d794..304015a 100644 Binary files a/buch/papers/multiplikation/images/c_meas_4096.pdf and b/buch/papers/multiplikation/images/c_meas_4096.pdf differ diff --git a/buch/papers/multiplikation/loesungsmethoden.tex b/buch/papers/multiplikation/loesungsmethoden.tex index 8a95dd5..780cbf3 100755 --- a/buch/papers/multiplikation/loesungsmethoden.tex +++ b/buch/papers/multiplikation/loesungsmethoden.tex @@ -358,10 +358,81 @@ Folgende Algorithmen wurden jweiles in \texttt{C} und \texttt{Python} implementi \item \textit{Devide and Conquer} Matrizenmultiplikation \item Strassen's Matrizenmultiplikation \item Winograd's Matrizenmultiplikation - \item \texttt{CBLAS} Matrizenmultiplikation in \texttt{C} + \item \texttt{BLAS} Matrizenmultiplikation in \texttt{C} \item \texttt{Numpy} Matrizenmultiplikation in \texttt{Python} \end{itemize} +Der Code kann im dazugeh\"orgien \textit{GitHub} Repository gefunden werden. + +\begin{table} + \begin{center} + \begin{tabular}{l l l l l l} + \hline + \hline + \textbf{n} & \textbf{MM (\textit{s})} & \textbf{MM DC (\textit{s})} & \textbf{Strassen (\textit{s})} & \textbf{Winograd (\textit{s})} & \textbf{BLAS (\textit{s})} \\ + \hline + \multicolumn{6}{c}{} \\ + \textbf{32} & 0.000081 &0.000594 & 0.00047& 0.00010 & 0.000022 \\ + \textbf{64} & 0.00065 & 0.0042& 0.0033& 0.00065& 0.00017 \\ + \textbf{128} & 0.0055 & 0.036& 0.024& 0.0052 & 0.0012 \\ + \textbf{256} & 0.054 & 0.32 & 0.17 & 0.057& 0.010 \\ + \textbf{512} & 0.48 & 2.61 & 1.20 & 0.51 & 0.074\\ + \textbf{1024} & 4.16 & 19.92& 8.45 & 4.53 & 0.704 \\ + \textbf{2048} & 125.90 & 159.33& 59.26 & 130.62 & 6.84 \\ + \textbf{4096} & 1111.31 & 1147.10& 414.64 & 1179.26 & 55.84\\ + \multicolumn{6}{c}{} \\ + \hline + \hline + \end{tabular} + \end{center} + \caption{Messresultate \texttt{C}} + \label{multiplikation:tab:messung_C} + \end{table} + + + + \begin{table} + \begin{center} + \begin{tabular}{l l l l l l} + \hline + \hline + \textbf{n} & \textbf{MM (\textit{s})} & \textbf{MM DC (\textit{s})} & \textbf{Strassen (\textit{s})} & \textbf{Winograd (\textit{s})} & \textbf{\texttt{NumPy}(\textit{s})} \\ + \hline + \multicolumn{6}{c}{} \\ + \textbf{32} & 0.0240 &0.0271 & 0.04852& 0.01871 & 4.26e-05 \\ + \textbf{64} & 0.186 & 0.265& 0.2204& 0.1530& 0.000118 \\ + \textbf{128} & 1.563 & 1.777& 1.447& 1.1947 & 0.000244 \\ + \textbf{256} & 11.006 & 13.27 & 9.938 & 8.298& 0.000695 \\ + \textbf{512} & 85.476 & 105.397 & 63.961 & 68.36 & 0.00221\\ + \textbf{1024} & 750.757 & 847.321& 461.494 & 537.374 & 0.0188 \\ + \textbf{4096} & - & - & - & - & 1.633 \\ + \multicolumn{6}{c}{} \\ + \hline + \hline + \end{tabular} + \end{center} + \caption{Messresultate \texttt{Python}} + \label{multiplikation:tab:messung_Python} + \end{table} + + \begin{table} + \begin{center} + \begin{tabular}{c c c c} + \hline + \hline + \textbf{CPU} & \textbf{OS} & \textbf{GPU } & \textbf{Memory } \\ + \hline + \multicolumn{4}{c}{} \\ + Intel® Core™ i7-4770K CPU & Ubuntu 20.04.2 LTS & Radeon RX 570 & 32 GB 1600 MHz \\ + @ 3.50GHz × 8 & 64-bit & & \\ + \multicolumn{4}{c}{} \\ + \hline + \hline + \end{tabular} + \end{center} + \caption{Messsystem} + \label{multiplikation:tab:pc_config} + \end{table} \begin{figure} \center -- cgit v1.2.1