diff --git a/DergunPiotr-WaskoDominik/zad3/macierz_gpu b/DergunPiotr-WaskoDominik/zad3/macierz_gpu deleted file mode 100755 index 96aa776..0000000 Binary files a/DergunPiotr-WaskoDominik/zad3/macierz_gpu and /dev/null differ diff --git a/DergunPiotr-WaskoDominik/zad4/Makefile b/DergunPiotr-WaskoDominik/zad4/Makefile new file mode 100644 index 0000000..e98e265 --- /dev/null +++ b/DergunPiotr-WaskoDominik/zad4/Makefile @@ -0,0 +1,5 @@ +macierz_omp: gauss_omp.cpp + g++ -O3 -fopenmp -Wall `pkg-config opencv --cflags --libs` -o gauss_omp gauss_omp.cpp + +clean: + rm -rf gauss_omp diff --git a/DergunPiotr-WaskoDominik/zad4/Ttiming.h b/DergunPiotr-WaskoDominik/zad4/Ttiming.h new file mode 100644 index 0000000..93d6e19 --- /dev/null +++ b/DergunPiotr-WaskoDominik/zad4/Ttiming.h @@ -0,0 +1,40 @@ +#if !defined(DEF_TTIMING) +#define DEF_TTIMING +#include + +class TTiming +{ +protected: + struct timeval start; + struct timeval stop; + void getTime(timeval &tv); + +public: + TTiming(void); + + void Begin(void); + long End(void); +}; + +inline TTiming::TTiming(void) +{ + +} + +inline void TTiming::Begin(void) +{ + getTime(start); +} + +inline long TTiming::End(void) +{ + getTime(stop); + return ((stop.tv_sec-start.tv_sec) * 1000 + (stop.tv_usec-start.tv_usec)/1000.0) + 0.5; +} + +inline void TTiming::getTime(timeval &tv) +{ + gettimeofday(&tv,NULL); +} + +#endif diff --git a/DergunPiotr-WaskoDominik/zad4/dane/czas.jpg b/DergunPiotr-WaskoDominik/zad4/dane/czas.jpg new file mode 100644 index 0000000..f549aca Binary files /dev/null and b/DergunPiotr-WaskoDominik/zad4/dane/czas.jpg differ diff --git a/DergunPiotr-WaskoDominik/zad4/dane/przyspieszenie.jpg b/DergunPiotr-WaskoDominik/zad4/dane/przyspieszenie.jpg new file mode 100644 index 0000000..9d00fe6 Binary files /dev/null and b/DergunPiotr-WaskoDominik/zad4/dane/przyspieszenie.jpg differ diff --git a/DergunPiotr-WaskoDominik/zad4/dane/wykres.gnuplot b/DergunPiotr-WaskoDominik/zad4/dane/wykres.gnuplot new file mode 100644 index 0000000..5beba86 --- /dev/null +++ b/DergunPiotr-WaskoDominik/zad4/dane/wykres.gnuplot @@ -0,0 +1,19 @@ +#set terminal x11 +set terminal jpeg +set xrange [0:16] +set yrange [0:6] + +set xlabel "Liczba watkow [n]" +set ylabel "Przyspieszenie [n]" + +set out "przyspieszenie.jpg" +plot \ + "wyniki.txt" using 1:3 with points ls 3 lc rgb "red" title "przyspieszenie", \ + "wyniki.txt" using 1:3 with lines ls 3 lc rgb "blue" notitle + +set out "czas.jpg" +set ylabel "Czas obliczen [ms]" +set yrange [0:16000] +plot \ + "wyniki.txt" using 1:2 with points ls 3 lc rgb "red" title "czas", \ + "wyniki.txt" using 1:2 with lines ls 3 lc rgb "blue" notitle \ No newline at end of file diff --git a/DergunPiotr-WaskoDominik/zad4/dok.tex b/DergunPiotr-WaskoDominik/zad4/dok.tex new file mode 100644 index 0000000..d0e4612 --- /dev/null +++ b/DergunPiotr-WaskoDominik/zad4/dok.tex @@ -0,0 +1,117 @@ +\documentclass[a4paper,12pt]{article} +\usepackage{amsmath} +\usepackage{amssymb} +\usepackage[polish]{babel} +\usepackage{polski} +\usepackage[utf8]{inputenc} +\usepackage{indentfirst} +\usepackage{geometry} +\usepackage{array} +\usepackage[pdftex]{color,graphicx} +\usepackage{subfigure} +\usepackage{afterpage} +\usepackage{setspace} +\usepackage{color} +\usepackage{wrapfig} +\usepackage{listings} +\usepackage{datetime} + +\renewcommand{\onehalfspacing}{\setstretch{1.6}} + +\geometry{tmargin=2.5cm,bmargin=2.5cm,lmargin=2.5cm,rmargin=2.5cm} +\setlength{\parindent}{1cm} +\setlength{\parskip}{0mm} + +\newenvironment{lista}{ +\begin{itemize} + \setlength{\itemsep}{1pt} + \setlength{\parskip}{0pt} + \setlength{\parsep}{0pt} +}{\end{itemize}} + +\newcommand{\linia}{\rule{\linewidth}{0.4mm}} + +\definecolor{lbcolor}{rgb}{0.95,0.95,0.95} +\lstset{ + backgroundcolor=\color{lbcolor}, + tabsize=4, + language=C++, + captionpos=b, + tabsize=3, + frame=lines, + numbers=left, + numberstyle=\tiny, + numbersep=5pt, + breaklines=true, + showstringspaces=false, + basicstyle=\footnotesize, + identifierstyle=\color{magenta}, + keywordstyle=\color[rgb]{0,0,1}, + commentstyle=\color{Darkgreen}, + stringstyle=\color{red} + } + +\begin{document} + +\noindent +\begin{tabular}{|c|p{11cm}|c|} \hline +Grupa 1 & Piotr Dergun, Dominik Waśko & \ddmmyyyydate\today \tabularnewline +\hline +\end{tabular} + + +\section*{Zadanie 1 - Macierze OMP} + +Celem zadania jest obliczenie iloczynu dwóch macierzy prostokątnych na konkretnej liczbie wątków (dane te podane jako parametry programu). Istotą problemu są trzy pętle, których złożoność obliczeniowa jest O($n^3$) + +\begin{lstlisting} + #pragma omp parallel for default(none) shared(A, B, C) firstprivate(rozmiar)private(i, j) + for (i=0; i +#include +#include +#include +#include "Ttiming.h" +#include + +using namespace std; +using namespace cv; + +#define RX 5 +#define RY 5 +int main(int argc, char *argv[]) +{ + int i,j,k,l,m,n; + TTiming tt; + char *endptr; + + int ratio[RX][RY] = + { + {1, 4, 7, 4, 1}, + {4, 16, 26, 16, 4}, + {7, 26, 41, 26, 7}, + {4, 16, 26, 16, 4}, + {1, 4, 7, 4, 1} + }; + + if (argc < 4) + { + cerr << "Usage: " << argv[0] << " " << endl; + exit(1); + } + + int threads_num = strtol(argv[1], &endptr, 10); + + if (*endptr) + { + cerr << "Invalid number of threads format" << endl; + exit(1); + } + + if (threads_num <= 0) + { + cerr << "The number of threads must be positive" << endl; + exit(1); + } + + int suma_wag = 0; + for (i=0; iimg.rows-3 || j<2 || j>img.cols-3) + { + img_out.at(i, j)[0] = img.at(i, j)[0]; + img_out.at(i, j)[1] = img.at(i, j)[1]; + img_out.at(i, j)[2] = img.at(i, j)[2]; + } + else + { + sumka_r = 0; + sumka_g = 0; + sumka_b = 0; + m=i-2; + for (k=0; k(m, n)[0]; + sumka_g += ratio[k][l] * img.at(m, n)[1]; + sumka_r += ratio[k][l] * img.at(m, n)[2]; + } + } + img_out.at(i, j).val[0] = sumka_b / suma_wag; + img_out.at(i, j).val[1] = sumka_g / suma_wag; + img_out.at(i, j).val[2] = sumka_r / suma_wag; + } + + //cout << img_out.at(i, j)[0].val[0]; + } + } + long elapsed = tt.End(); + cout << "Time: " << elapsed << " ms" << endl; + + imwrite(argv[3], img_out); + + exit(0); +} \ No newline at end of file