From ef493d09a3bd3c22d4ae46a8df4a9a9c85492797 Mon Sep 17 00:00:00 2001 From: Apostolof Date: Wed, 3 Oct 2018 23:42:01 +0300 Subject: [PATCH] Implement parallel openmp algorithm --- openmp/Makefile | 4 +- openmp/coo_sparse_matrix.c | 17 +- openmp/coo_sparse_matrix.h | 27 +++ openmp/coo_sparse_matrix.o | Bin 4096 -> 0 bytes openmp/csr_sparse_matrix.c | 17 +- openmp/csr_sparse_matrix.h | 27 ++- openmp/csr_sparse_matrix.o | Bin 3192 -> 0 bytes openmp/openmp_gs_pagerank.c | 65 +++++++ ...tions.c => openmp_gs_pagerank_functions.c} | 184 +++++++++++------- ...tions.h => openmp_gs_pagerank_functions.h} | 18 +- openmp/pagerank.out | Bin 28459 -> 0 bytes openmp/serial_gs_pagerank.c | 44 ----- openmp/serial_gs_pagerank.o | Bin 3456 -> 0 bytes openmp/serial_gs_pagerank_functions.o | Bin 18752 -> 0 bytes 14 files changed, 262 insertions(+), 141 deletions(-) delete mode 100644 openmp/coo_sparse_matrix.o delete mode 100644 openmp/csr_sparse_matrix.o create mode 100644 openmp/openmp_gs_pagerank.c rename openmp/{serial_gs_pagerank_functions.c => openmp_gs_pagerank_functions.c} (75%) rename openmp/{serial_gs_pagerank_functions.h => openmp_gs_pagerank_functions.h} (86%) delete mode 100644 openmp/pagerank.out delete mode 100644 openmp/serial_gs_pagerank.c delete mode 100644 openmp/serial_gs_pagerank.o delete mode 100644 openmp/serial_gs_pagerank_functions.o diff --git a/openmp/Makefile b/openmp/Makefile index 2e297ea..a810950 100644 --- a/openmp/Makefile +++ b/openmp/Makefile @@ -7,8 +7,8 @@ CC = gcc -std=gnu99 -fopenmp RM = rm -f CFLAGS_DEBUG=-O0 -ggdb3 -Wall -I. CFLAGS=-O3 -Wall -I. -OBJ=serial_gs_pagerank.o serial_gs_pagerank_functions.o coo_sparse_matrix.o csr_sparse_matrix.o -DEPS=serial_gs_pagerank_functions.h coo_sparse_matrix.h csr_sparse_matrix.h +OBJ=openmp_gs_pagerank.o openmp_gs_pagerank_functions.o coo_sparse_matrix.o csr_sparse_matrix.o +DEPS=openmp_gs_pagerank_functions.h coo_sparse_matrix.h csr_sparse_matrix.h # ========================================== # TARGETS diff --git a/openmp/coo_sparse_matrix.c b/openmp/coo_sparse_matrix.c index 93d0ac9..689a0fe 100644 --- a/openmp/coo_sparse_matrix.c +++ b/openmp/coo_sparse_matrix.c @@ -15,9 +15,8 @@ void allocMemoryForCoo(CooSparseMatrix *sparseMatrix, int numberOfElements) { } void addElement(CooSparseMatrix *sparseMatrix, double value, int row, int column) { + // Checks if there is enough space allocated if (sparseMatrix->numberOfNonZeroElements == sparseMatrix->size) { - printf("%d == %d |||| %d, %d\n", sparseMatrix->numberOfNonZeroElements, - sparseMatrix->size, row, column); printf("Number of non zero elements exceeded size of matrix!\n"); exit(EXIT_FAILURE); } @@ -29,6 +28,7 @@ void addElement(CooSparseMatrix *sparseMatrix, double value, int row, int column newElement->rowIndex = row; newElement->columnIndex = column; + // Adds the new element to the first empty (NULL) address of the matrix sparseMatrix->elements[sparseMatrix->numberOfNonZeroElements] = newElement; sparseMatrix->numberOfNonZeroElements = sparseMatrix->numberOfNonZeroElements + 1; } @@ -42,14 +42,19 @@ void transposeSparseMatrix(CooSparseMatrix *sparseMatrix) { } } +/* + * This function is a port of the one found here: + * https://github.com/scipy/scipy/blob/3b36a57/scipy/sparse/sparsetools/coo.h#L34 +*/ void transformToCSR(CooSparseMatrix initialSparseMatrix, CsrSparseMatrix *transformedSparseMatrix) { - // Taken from here: https://github.com/scipy/scipy/blob/3b36a57/scipy/sparse/sparsetools/coo.h#L34 - if (initialSparseMatrix.numberOfNonZeroElements > transformedSparseMatrix->size) { + // Checks if the sizes of the two matrices fit + if (initialSparseMatrix.numberOfNonZeroElements > transformedSparseMatrix->numberOfElements) { printf("Transformed CSR matrix does not have enough space!\n"); exit(EXIT_FAILURE); } + // Calculates the elements per row for (int i=0; irowIndex; transformedSparseMatrix->rowCumulativeIndexes[rowIndex] = @@ -63,6 +68,7 @@ void transformToCSR(CooSparseMatrix initialSparseMatrix, sum += temp; } + // Copies the values and columns of the elements for (int i=0; irowIndex; int destinationIndex = transformedSparseMatrix->rowCumulativeIndexes[row]; @@ -73,13 +79,12 @@ void transformToCSR(CooSparseMatrix initialSparseMatrix, transformedSparseMatrix->rowCumulativeIndexes[row]++; } + // Fixes the cumulative sum for (int i=0, last=0; i<=transformedSparseMatrix->size; i++){ int temp = transformedSparseMatrix->rowCumulativeIndexes[i]; transformedSparseMatrix->rowCumulativeIndexes[i] = last; last = temp; } - - transformedSparseMatrix->numberOfNonZeroElements = initialSparseMatrix.numberOfNonZeroElements; } void cooSparseMatrixVectorMultiplication(CooSparseMatrix sparseMatrix, diff --git a/openmp/coo_sparse_matrix.h b/openmp/coo_sparse_matrix.h index dd4c31d..0a34b7e 100644 --- a/openmp/coo_sparse_matrix.h +++ b/openmp/coo_sparse_matrix.h @@ -1,6 +1,8 @@ #ifndef COO_SPARSE_MATRIX_H /* Include guard */ #define COO_SPARSE_MATRIX_H +/* ===== INCLUDES ===== */ + #include #include #include @@ -8,26 +10,51 @@ #include "csr_sparse_matrix.h" +/* ===== STRUCTURES ===== */ + +// One element of the coordinate formated sparse matrix. typedef struct cooSparseMatrixElement { double value; int rowIndex, columnIndex; } CooSparseMatrixElement; +// A sparse matrix in COOrdinate format (aka triplet format). typedef struct cooSparseMatrix { int size, numberOfNonZeroElements; CooSparseMatrixElement **elements; } CooSparseMatrix; +/* ===== FUNCTION DEFINITIONS ===== */ + +// initCooSparseMatrix creates and initializes the members of a CooSparseMatrix +// structure instance. CooSparseMatrix initCooSparseMatrix(); + +//allocMemoryForCoo allocates memory for the elements of the matrix. void allocMemoryForCoo(CooSparseMatrix *sparseMatrix, int numberOfElements); + +// addElement adds an element representing the triplet passed in the arguments +// to the first empty address of the space allocated for the elements. void addElement(CooSparseMatrix *sparseMatrix, double value, int row, int column); + +// transposeSparseMatrix transposes the matrix. void transposeSparseMatrix(CooSparseMatrix *sparseMatrix); + +// transformToCSR transforms the sparse matrix representation format from COO +// to CSR. void transformToCSR(CooSparseMatrix initialSparseMatrix, CsrSparseMatrix *transformedSparseMatrix); + +// cooSparseMatrixVectorMultiplication calculates the product of a +// CooSparseMatrix and a vector. void cooSparseMatrixVectorMultiplication(CooSparseMatrix sparseMatrix, double *vector, double **product, int vectorSize); + +// destroyCooSparseMatrix frees all space used by the CooSparseMatrix. void destroyCooSparseMatrix(CooSparseMatrix *sparseMatrix); + +// printCooSparseMatrix prints the values of a CooSparseMatrix. void printCooSparseMatrix(CooSparseMatrix sparseMatrix); #endif // COO_SPARSE_MATRIX_H \ No newline at end of file diff --git a/openmp/coo_sparse_matrix.o b/openmp/coo_sparse_matrix.o deleted file mode 100644 index 8b80d4e77349e7a99abd331292352e4fbfe21943..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4096 zcmbtWUu+yl8K3iQlI``_v#SCp6)8h;E0?xgU+V`SCDpBc7tcv{TE)JSCN}PQZ?8V$ zyES|3)UjF{>2P4RHsk>$o_Og4Jb?OwPbyht#0rXwIQ8K*W8e@j{w-UE& zeUSET<!_o_1gyg#HAme&?3^Ow}jrPIt;e#crb z$BgWz&s2Xl>9M3Yt1i9s;YMnIo)BX!?Ga-%D2Jc%S-QpZDIMs{M`(w1=z|9r}I86inP{aKvoK|SAbz; zFFgP5^7i7vVSh?x{?|G)Ys^2IhLj=xu&;2xMU$xo|44GnNOh9pYI0@RyzQVjzDl+R zQeDcctr!n@Q3UM9fSK!=3-2dHetGYF-p9CJFGkKLp18NuN1vEj3u_Ut9M?0|Ffz6IoP+otaTm^euwu(IDTB=6_&lcHJExzd2K6o1Ztuy zHg_o~Ff0J$tHxwBbMN=O7GxRh9)7qUA^DF>nQNm^2bn)W?so_KT=b#jS{pIuf4PUX z&IKiDWXHRerMHhw6#eJARb%`ro-|bVP5!VricsF(jZtv8z4#D6x1z7Sxm%eGJo_x^ zKcV8{UfRhl`_|HBeg^kc=z#+ip3i}RegIm6IQFv?(F8dL&^?t2990vT#i6UJ&5}~VSB&O z4}ku$=>G#X&{sN`mOh34T1v;o1dlCT5C)Vhf`3-$Fp5c*)VAX^m_X)ur+Trp% zIroIj66f^h$+}yf0_{41o|Zkwnknn9HSZF=Qg+KkpK3OV?$|g$dPdLOJnSdBY1gqx zi4MhP=|hJ~4>sMhc^r7?%$lC8I_0{Bf&V|DV2(=+{nog{9Dfq>Ok8w?!a54eT`*9> zfapK{si5;mv42SzVi)%nB^@YoFKEOgVaSi7fZz*vVnhhm68enN|5y7A*rLyep@l`- z>tPW3GQQL~fko}Fh=hI_v6t(Y_KypD`5sF8_r<2-`obdZq{jDB_QSmOc8Ai2TNhYI z*cke+2>bbnbD6)SPeZ3&s9Y*wtO+8X|83Buy*&Rez@le|COJ`%&*C5?k#zXlqq!r! zpMU+qkC?=AL?{{`b7~iV9uo%nbD(yf(fB(Pkq+_{^4IMM%!l!|Cx&^n%LMUuJB+ye zlHVL9e#_e&%*S_DALZjN+$wRh?-uaWfZP$vUuJNhz~%R$TUb5{T4Dm?Y5<<-CnrGu zUxEGzw08WXpMXz(0$u?e{cnOsk^i0r==1!=LGu3(V4lQ9y_|(H%1@!S%jai+bN_;m z>p^)HT01`GfqW{CnEy}Ez_jhj;I1$kTt9S^)EYH+(6&cIR|ry`nX%0g3vLQ0584jQ zk~)V-xl$%*(lYa0#Q1BfO|I2>C(ZD}`k|cj4gyVTh{B2Pe(oetOT@^US4g2{pgoph+f;)nNPErf^j`6z^=51G#aQID7p`lrxP zjtU&j!v3`o9`-}g2n6{e6d(8T=Pr&pp^OJ=ho2MUA4Kp?G5$#ehgXTqn^9Z@?+Kj? NLYo2~i{SEo{157s#?$}+ diff --git a/openmp/csr_sparse_matrix.c b/openmp/csr_sparse_matrix.c index bdf8413..65e200a 100644 --- a/openmp/csr_sparse_matrix.c +++ b/openmp/csr_sparse_matrix.c @@ -3,7 +3,7 @@ CsrSparseMatrix initCsrSparseMatrix() { CsrSparseMatrix sparseMatrix; sparseMatrix.size = 0; - sparseMatrix.numberOfNonZeroElements = 0; + sparseMatrix.numberOfElements = 0; sparseMatrix.values = NULL; sparseMatrix.columnIndexes = NULL; @@ -11,21 +11,23 @@ CsrSparseMatrix initCsrSparseMatrix() { return sparseMatrix; } -void allocMemoryForCsr(CsrSparseMatrix *sparseMatrix, int numberOfElements) { +void allocMemoryForCsr(CsrSparseMatrix *sparseMatrix, int size, int numberOfElements) { sparseMatrix->values = (double *) malloc(numberOfElements * sizeof(double)); sparseMatrix->columnIndexes = (int *) malloc( numberOfElements * sizeof(int)); sparseMatrix->rowCumulativeIndexes = (int *) malloc( - (numberOfElements + 1) * sizeof(int)); + (size + 1) * sizeof(int)); - for (int i=0; irowCumulativeIndexes[i] = 0; } - sparseMatrix->size = numberOfElements; + + sparseMatrix->size = size; + sparseMatrix->numberOfElements = numberOfElements; } -// Row indexes start from 0! void zeroOutRow(CsrSparseMatrix *sparseMatrix, int row) { + // Gets start and end indexes of the row's elements int startIndex = sparseMatrix->rowCumulativeIndexes[row], endIndex = sparseMatrix->rowCumulativeIndexes[row+1]; for (int i=startIndex; inumberOfNonZeroElements; ++i){ + for (int i=0; inumberOfElements; ++i){ if(sparseMatrix->columnIndexes[i] == column){ - // Zeros out this element sparseMatrix->values[i] = 0; } } diff --git a/openmp/csr_sparse_matrix.h b/openmp/csr_sparse_matrix.h index a964514..5588e9a 100644 --- a/openmp/csr_sparse_matrix.h +++ b/openmp/csr_sparse_matrix.h @@ -1,24 +1,47 @@ #ifndef CSR_SPARSE_MATRIX_H /* Include guard */ #define CSR_SPARSE_MATRIX_H +/* ===== INCLUDES ===== */ + #include #include #include #include +/* ===== STRUCTURES ===== */ + +// A sparse matrix in compressed SparseRow format. typedef struct csrSparseMatrix { - int size, numberOfNonZeroElements; + int size, numberOfElements; int *rowCumulativeIndexes, *columnIndexes; double *values; } CsrSparseMatrix; +/* ===== FUNCTION DEFINITIONS ===== */ + +// initCsrSparseMatrix creates and initializes the members of a CsrSparseMatrix +// structure instance. CsrSparseMatrix initCsrSparseMatrix(); -void allocMemoryForCsr(CsrSparseMatrix *sparseMatrix, int numberOfElements); + +// allocMemoryForCsr allocates memory for the elements of the matrix. +void allocMemoryForCsr(CsrSparseMatrix *sparseMatrix, int size, int numberOfElements); + +// zeroOutRow assigns a zero value to all the elements of a row in the matrix. void zeroOutRow(CsrSparseMatrix *sparseMatrix, int row); + +// zeroOutColumn assigns a zero value to all the elements of a column in the +// matrix. void zeroOutColumn(CsrSparseMatrix *sparseMatrix, int column); + +// csrSparseMatrixVectorMultiplication calculates the product of a +// CsrSparseMatrix and a vector. void csrSparseMatrixVectorMultiplication(CsrSparseMatrix sparseMatrix, double *vector, double **product, int vectorSize); + +// destroyCsrSparseMatrix frees all space used by the CsrSparseMatrix. void destroyCsrSparseMatrix(CsrSparseMatrix *sparseMatrix); + +// printCsrSparseMatrix prints the values of a CsrSparseMatrix. void printCsrSparseMatrix(CsrSparseMatrix sparseMatrix); #endif // CSR_SPARSE_MATRIX_H \ No newline at end of file diff --git a/openmp/csr_sparse_matrix.o b/openmp/csr_sparse_matrix.o deleted file mode 100644 index c5872b439d8077c33563caffdd2443694f24642e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3192 zcmbtWUu;ul6#v>@SQ+!SQ%q{ma388}DmN?aVFSe7tz);O69Ow^G8o<6ZPw5~OM9yu z!Y0;Dn@eFYzUhPd!W#)Okr#A-kS>~#IehV7f&>HwjE+D^B*AmO`+cL_Z7+I~@1Aph z=kNEo9cc}3b2=P^lY?v}k2H=Fa#?sJH&L;PJV7dnTDV`TK)uvPJ=9X08&%+5#(l`A zJ?q{b!wMxNu!9wD_nTDjx9*pn0h_dK*OdV0AI# z2;5T(C3W(O6;gP4-+rZgI_6pT9%dk_+38lbd#Wa!F+0u(jk8CeQ_UT|+9?Q|yy8-e zTPA-;Kkk2LI))^3-Ru-b=Z0T`7;j+W=BjZuKjCPc8h)m+{#fo#*lhEKO2PytunZ&D ztpp44N+eXct8_$gero=fdvq>n_WA2nGvRL-u2#*hsy1h}Lg&>wdUbdx=IQ(?Y7wa#Ei(5{rj_=fB z;-cHLj30Y$?;yApEI0n6r zwN(}FacCMZ#k0&-%Xkg&Iwp4_Zx+4Bok7tz=4uh8yx`m}`V`UIEV`}uZsxmzam+cu z z@x1d5EKlHwk)II*I*T8OI_Yc{eJ5PaqEr-G#hT+Q6tQk>r6M-uD}v%q=SN}#08kJd zz|ks0$65wI|P0ht@roDGSQ@t9sVzpAR5owN?VpDrk`>?Zos`Lr?sHq{j}2zoGBzX zCI?y#14Ue8B>HFqe*p&KE*Rx>!&aBuSURqfS3ts?|1~}Uv6z#eH4rKB`mb?-ao#`g zqX}@7`T1sUH=Y@{hP%N z13G0fx_=nU<&p0{(@%z&OGUBroC4|4%y$tuV4WMr} zU}M~$;S%UbAH!IxpHBhD{C_cj`bGox#WMax%Vv7A1JO)Y?@30DOngw*NIVrcTC$nl z6mF*|i6#jqPp3$q4$pde$X+v+(RDJAiKiBI)6+xYSdZ3!2xbQV1?ZO$yeoJ$A3U@u zvJ9>*gC8lw@lNqPo7s9|{&M_>G92$Z_rJ0Xp27q`c>T&x_c4YedkO~6^Et>!_PV#0 u$uCiF%b%sBNWBfOWBNfG&d;l1!})prz=rel%HI*JiDQ=aciHC8&*i@xdkho+ diff --git a/openmp/openmp_gs_pagerank.c b/openmp/openmp_gs_pagerank.c new file mode 100644 index 0000000..17a4e66 --- /dev/null +++ b/openmp/openmp_gs_pagerank.c @@ -0,0 +1,65 @@ +#include + +#include "openmp_gs_pagerank_functions.h" + +struct timeval startwtime, endwtime; + +int main(int argc, char **argv) { + CsrSparseMatrix transitionMatrix = initCsrSparseMatrix(); + double *pagerankVector; + bool convergenceStatus; + Parameters parameters; + int maxIterationsForConvergence = 0; + + parseArguments(argc, argv, ¶meters); + + initialize(&transitionMatrix, &pagerankVector, ¶meters); + + // Saves information about the dataset to the output file + { + FILE *outputFile; + outputFile = fopen(parameters.outputFilename, "w"); + + if (outputFile == NULL) { + printf("Error while opening the output file.\n"); + exit(EXIT_FAILURE); + } + + fprintf(outputFile, "Pagerank will run for the dataset %s\n"\ + "Dataset contains %d pages with %d outlinks.\n", + parameters.graphFilename, parameters.numberOfPages, transitionMatrix.size); + + fclose(outputFile); + } + + // Starts wall-clock timer + gettimeofday (&startwtime, NULL); + int* iterations = (int *)malloc(parameters.numberOfPages*sizeof(int)); + + // Calculates pagerank + iterations = pagerank(&transitionMatrix, &pagerankVector, + &convergenceStatus, parameters, &maxIterationsForConvergence); + + // Stops wall-clock timer + gettimeofday (&endwtime, NULL); + double seq_time = (double)((endwtime.tv_usec - startwtime.tv_usec)/1.0e6 + + endwtime.tv_sec - startwtime.tv_sec); + printf("%s wall clock time = %f\n","Pagerank (Gauss-Seidel method), serial implementation", + seq_time); + + printf(ANSI_COLOR_YELLOW "\n----- RESULTS -----\n" ANSI_COLOR_RESET); + if (convergenceStatus) { + printf(ANSI_COLOR_GREEN "Pagerank converged after %d iterations!\n" \ + ANSI_COLOR_RESET, maxIterationsForConvergence); + } else { + printf(ANSI_COLOR_RED "Pagerank did not converge after max number of" \ + " iterations (%d) was reached!\n" ANSI_COLOR_RESET, maxIterationsForConvergence); + } + + // Saves results to the output file + savePagerankToFile(parameters.outputFilename, iterations, pagerankVector, + parameters.numberOfPages, maxIterationsForConvergence); + + free(pagerankVector); + destroyCsrSparseMatrix(&transitionMatrix); +} diff --git a/openmp/serial_gs_pagerank_functions.c b/openmp/openmp_gs_pagerank_functions.c similarity index 75% rename from openmp/serial_gs_pagerank_functions.c rename to openmp/openmp_gs_pagerank_functions.c index cb406c1..4d24b17 100644 --- a/openmp/serial_gs_pagerank_functions.c +++ b/openmp/openmp_gs_pagerank_functions.c @@ -1,12 +1,13 @@ /* ===== INCLUDES ===== */ -#include "serial_gs_pagerank_functions.h" -#include +#include "openmp_gs_pagerank_functions.h" + /* ===== CONSTANTS ===== */ const char *ARGUMENT_CONVERGENCE_TOLERANCE = "-c"; const char *ARGUMENT_MAX_ITERATIONS = "-m"; const char *ARGUMENT_DAMPING_FACTOR = "-a"; +const char *ARGUMENT_THREADS_NUMBER = "-t"; const char *ARGUMENT_VERBAL_OUTPUT = "-v"; const char *ARGUMENT_OUTPUT_HISTORY = "-h"; const char *ARGUMENT_OUTPUT_FILENAME = "-o"; @@ -15,26 +16,31 @@ const int NUMERICAL_BASE = 10; char *DEFAULT_OUTPUT_FILENAME = "pagerank_output"; const int FILE_READ_BUFFER_SIZE = 4096; -const int CONVERGENCE_CHECK_ITERATION_PERIOD = 3; -const int SPARSITY_INCREASE_ITERATION_PERIOD = 3; +const int CONVERGENCE_CHECK_ITERATION_PERIOD = 2; +const int SPARSITY_INCREASE_ITERATION_PERIOD = 10; + +/* ===== GLOBAL VARIABLES ====== */ + +int numberOfThreads; /* ===== FUNCTIONS ===== */ -int pagerank(CsrSparseMatrix *transitionMatrix, double **pagerankVector, - bool *convergenceStatus, Parameters parameters) { +int* pagerank(CsrSparseMatrix *transitionMatrix, double **pagerankVector, + bool *convergenceStatus, Parameters parameters, int* maxIterationsForConvergence) { // Variables declaration - int iterations = 0, numberOfPages = parameters.numberOfPages; + int numberOfPages = parameters.numberOfPages; + int *iterations; double delta, *pagerankDifference, *previousPagerankVector, *convergedPagerankVector, *linksFromConvergedPagesPagerankVector; + CsrSparseMatrix originalTransitionMatrix = initCsrSparseMatrix(); CooSparseMatrix linksFromConvergedPages = initCooSparseMatrix(); bool *convergenceMatrix; - int P = omp_get_max_threads(); - omp_set_num_threads(P); - // Space allocation { size_t sizeofDouble = sizeof(double); + // iterations until each page converged + iterations = (int *) malloc(numberOfPages * sizeof(int)); // pagerankDifference used to calculate delta pagerankDifference = (double *) malloc(numberOfPages * sizeofDouble); // previousPagerankVector holds last iteration's pagerank vector @@ -50,12 +56,22 @@ int pagerank(CsrSparseMatrix *transitionMatrix, double **pagerankVector, *convergenceStatus = false; // Initialization - allocMemoryForCoo(&linksFromConvergedPages, transitionMatrix->numberOfNonZeroElements); - #pragma omp parallel for num_threads(P) + // originalTransitionMatrix used to run pagerank in phases + allocMemoryForCsr(&originalTransitionMatrix, transitionMatrix->size, transitionMatrix->numberOfElements); + memcpy(originalTransitionMatrix.rowCumulativeIndexes, transitionMatrix->rowCumulativeIndexes, + (transitionMatrix->size+1) * sizeof(int)); + memcpy(originalTransitionMatrix.columnIndexes, transitionMatrix->columnIndexes, + transitionMatrix->numberOfElements * sizeof(int)); + memcpy(originalTransitionMatrix.values, transitionMatrix->values, + transitionMatrix->numberOfElements * sizeof(double)); + + allocMemoryForCoo(&linksFromConvergedPages, transitionMatrix->numberOfElements); + #pragma omp parallel for num_threads(numberOfThreads) for (int i=0; ivalues, originalTransitionMatrix.values, + transitionMatrix->numberOfElements * sizeof(double)); + #pragma omp parallel for num_threads(numberOfThreads) + for (int i=0; i 10) { + if (argumentCount < 2 || argumentCount > 16) { validUsage(argumentVector[0]); } + numberOfThreads = omp_get_max_threads(); + (*parameters).numberOfPages = 0; (*parameters).maxIterations = 0; - (*parameters).convergenceCriterion = 1; + (*parameters).convergenceCriterion = 0.001; (*parameters).dampingFactor = 0.85; (*parameters).verbose = false; (*parameters).history = false; @@ -304,6 +336,15 @@ void parseArguments(int argumentCount, char **argumentVector, Parameters *parame exit(EXIT_FAILURE); } (*parameters).dampingFactor = alphaInput; + } else if (!strcmp(argumentVector[argumentIndex], ARGUMENT_THREADS_NUMBER)) { + argumentIndex = checkIncrement(argumentIndex, argumentCount, argumentVector[0]); + + size_t threadsInput = strtol(argumentVector[argumentIndex], &endPointer, NUMERICAL_BASE); + if (threadsInput == 0 && endPointer) { + printf("Invalid iterations argument\n"); + exit(EXIT_FAILURE); + } + numberOfThreads = threadsInput; } else if (!strcmp(argumentVector[argumentIndex], ARGUMENT_VERBAL_OUTPUT)) { (*parameters).verbose = true; } else if (!strcmp(argumentVector[argumentIndex], ARGUMENT_OUTPUT_HISTORY)) { @@ -423,33 +464,27 @@ void generateNormalizedTransitionMatrixFromFile(CsrSparseMatrix *transitionMatri // Calculates the outdegree of each page and assigns the uniform probability // of transition to the elements of the corresponding row - int* pageOutdegree = malloc((*parameters).numberOfPages*sizeof(int)); for (int i=0; i<(*parameters).numberOfPages; ++i){ pageOutdegree[i] = 0; } - for (int i=0; irowIndex; - - if (currentRow == tempMatrix.elements[i]->rowIndex) { - ++pageOutdegree[currentRow]; - } - - + ++pageOutdegree[currentRow]; } for (int i=0; ivalue = 1./pageOutdegree[tempMatrix.elements[i]->rowIndex]; } - + free(pageOutdegree); + // Transposes the temporary transition matrix (P^T). transposeSparseMatrix(&tempMatrix); - allocMemoryForCsr(transitionMatrix, numberOfEdges); + + allocMemoryForCsr(transitionMatrix, (*parameters).numberOfPages, numberOfEdges); // Transforms the temporary COO matrix to the desired CSR format transformToCSR(tempMatrix, transitionMatrix); - //printCsrSparseMatrix(*transitionMatrix); destroyCooSparseMatrix(&tempMatrix); fclose(graphFile); @@ -486,27 +521,34 @@ int checkIncrement(int previousIndex, int maxIndex, char *programName) { return ++previousIndex; } -void savePagerankToFile(char *filename, bool append, double *pagerankVector, - int vectorSize, int realIterations) { +void savePagerankToFile(char *filename, int *iterationsUntilConvergence, + double *pagerankVector, int vectorSize, int iteration) { FILE *outputFile; - if (append) { - outputFile = fopen(filename, "a"); - } else { - outputFile = fopen(filename, "w"); - } + outputFile = fopen(filename, "a"); if (outputFile == NULL) { printf("Error while opening the output file.\n"); return; } - //Save numberofPages and convergence time - + + fprintf(outputFile, "\n----- Iteration %d -----\n", iteration); + + // Saves the pagerank vector + double sum = 0; for (int i=0; i #include #include +#include #include "coo_sparse_matrix.h" @@ -27,6 +28,7 @@ extern const char *ARGUMENT_CONVERGENCE_TOLERANCE; extern const char *ARGUMENT_MAX_ITERATIONS; extern const char *ARGUMENT_DAMPING_FACTOR; +extern const char *ARGUMENT_THREADS_NUMBER; extern const char *ARGUMENT_VERBAL_OUTPUT; extern const char *ARGUMENT_OUTPUT_HISTORY; extern const char *ARGUMENT_OUTPUT_FILENAME; @@ -41,7 +43,7 @@ extern const int FILE_READ_BUFFER_SIZE; // A data structure to conveniently hold the algorithm's parameters. typedef struct parameters { - int numberOfPages, maxIterations, realIterations; + int numberOfPages, maxIterations; double convergenceCriterion, dampingFactor; bool verbose, history; char *outputFilename, *graphFilename; @@ -71,8 +73,8 @@ void generateNormalizedTransitionMatrixFromFile(CsrSparseMatrix *transitionMatri // Function savePagerankToFile appends or overwrites the pagerank vector // "pagerankVector" to the file with the filename supplied in the arguments. -void savePagerankToFile(char *filename, bool append, double *pagerankVector, - int vectorSize, int realIterations); +void savePagerankToFile(char *filename, int *iterationsUntilConvergence, + double *pagerankVector, int vectorSize, int iteration); // Function initialize allocates memory for the pagerank vector, reads the // dataset from the file and creates the transition probability distribution @@ -92,7 +94,7 @@ void calculateNextPagerank(CsrSparseMatrix *transitionMatrix, // Function pagerank iteratively calculates the pagerank of each page until // either the convergence criterion is met or the maximum number of iterations // is reached. -int pagerank(CsrSparseMatrix *transitionMatrix, double **pagerankVector, - bool *convergenceStatus, Parameters parameters); +int* pagerank(CsrSparseMatrix *transitionMatrix, double **pagerankVector, + bool *convergenceStatus, Parameters parameters, int* maxIterationsForConvergence); -#endif // SERIAL_GS_PAGERANK_FUNCTIONS_H \ No newline at end of file +#endif // OPENMP_GS_PAGERANK_FUNCTIONS_H \ No newline at end of file diff --git a/openmp/pagerank.out b/openmp/pagerank.out deleted file mode 100644 index 37ff79d49f942d0c283a294b8594d6e676621673..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 28459 zcmeHwdw5gVmG6-)Ksd${2_a6?Bqte>m;@Xf2(=QLNVbHJKnB;31PVk}WEs1$Eyt1w z?Y7k3t?UX^2Z6zQ484 z-qNwKGV|Th*C2J0Bg zX%*63$thhXT_Vi}WfuOOEQO$cCg3C&Eue+-PK~> z{{~*ahCC-Q!kq*pH~Y;%;-#bZ?PxQd4^}V~(8*2&wDa-=6#2e`e5B`p_pousI$mBb zyV$t?0`lUe>)P9HU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br@vXq}oT7E8R*}0@L*dpxLA0hB}uxAKJzex8vG{1j!ovX&< z_pEc%M=Mxki1TUnZREi z^{-V-r@88?8*4o48vIr3*WKc&tM;s`^7tFp`#g0noJsx=+a1?GO))(u`%Fbm2+v>a zSRL-Jigah`gRgcNv^n=%9ZsjvRJV}$Ob4Dr6QAYCuw)e$4omg5uDW_}!$!Y%T~(dO zRqug4p>%_H{W^cGr_Q_HEm2cdg~RoR$4O@T_(!G`<2N^^S62U;$8;K=S`6Od?F@Fa zrw}E2KxTa`ile(MLRTBm9dsI^4Xib9#PO^+@-$-0Zs~)7kJaRJ1$1Bil#_9~lQkJKjZ)Q}U0H zOcyX?zfK!@#-?Nsb2UZ~BP3Q!dQzw%j0c5Kr)i&&VeZ;Ky*y|Z3H$M&PcuF{qklIg z!+=knhzey@-S1tG?t~{P{jo@>nIeSIGBZ76B&9os+f`HRU03a2?W$^6Uzee;Z)~V- zZ17W)A~v9_WO_VVALha%rn=?yPr76jrOxQ~tajm1T>m*@=xaB;@9PgUt%HH2b?Bva z-YUeIO8B~Pwkr1cQbwm5*M>|tsE10ps>Nlo&&9Bw;NnlN;iEi;Z`)+Fqp!z^c#JXZ zPCsjXV|=JmJXLEm1&RK~K8%x*lMXp|OsCECd7!kl5rbGTWyZ}^j9W>;Sh>D#Bl`|d zmQX*wNR$rchHvg<*r;9+JSr=Or-txqJeK$sUnXK7?#b>Of#zn9{uCTO(bGu}Mu(_@ kSg&kmkG`RghCB5q)K=rMUA++I5*UU4OTW_#oz5uzA7iPvU;qFB diff --git a/openmp/serial_gs_pagerank.c b/openmp/serial_gs_pagerank.c deleted file mode 100644 index 3836cf8..0000000 --- a/openmp/serial_gs_pagerank.c +++ /dev/null @@ -1,44 +0,0 @@ -#include -#include -#include "serial_gs_pagerank_functions.h" -//#include "coo_sparse_matrix.h" - -struct timeval startwtime, endwtime; -double seq_time; - -int main(int argc, char **argv) { - CsrSparseMatrix transitionMatrix = initCsrSparseMatrix(); - double *pagerankVector; - bool convergenceStatus; - Parameters parameters; - omp_set_dynamic(0); - parseArguments(argc, argv, ¶meters); - - initialize(&transitionMatrix, &pagerankVector, ¶meters); - - // Starts wall-clock timer - gettimeofday (&startwtime, NULL); - - int iterations = pagerank(&transitionMatrix, &pagerankVector, - &convergenceStatus, parameters); - if (parameters.verbose) { - printf(ANSI_COLOR_YELLOW "\n----- RESULTS -----\n" ANSI_COLOR_RESET); - if (convergenceStatus) { - printf(ANSI_COLOR_GREEN "Pagerank converged after %d iterations!\n" \ - ANSI_COLOR_RESET, iterations); - } else { - printf(ANSI_COLOR_RED "Pagerank did not converge after max number of" \ - " iterations (%d) was reached!\n" ANSI_COLOR_RESET, iterations); - } - } - - // Stops wall-clock timer - gettimeofday (&endwtime, NULL); - double seq_time = (double)((endwtime.tv_usec - startwtime.tv_usec)/1.0e6 + - endwtime.tv_sec - startwtime.tv_sec); - printf("%s wall clock time = %f\n","Pagerank (Gauss-Seidel method), serial implementation", - seq_time); - - free(pagerankVector); - destroyCsrSparseMatrix(&transitionMatrix); -} diff --git a/openmp/serial_gs_pagerank.o b/openmp/serial_gs_pagerank.o deleted file mode 100644 index 366656bad738e1327246669f577a5f563a5691df..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3456 zcmbtWQEMDk6uz5{Hb%R&r9rZUKoJD-$)BL$LlLnlRS=&FzV*fWB8nmy&=(8woICgK-kr_7=z*Pc&Ue0Z z?zwmGy)#$N&YbH?B#4j%IYU~WKnb~*Y}q+x=17JdCH;%z<96=|igNyJVSZ+=pfInu ze{s|%7$37|jb-W?&WciUolDePrlw+)1L`RQrec9M0?T#$lRSl0hdiy7XIiG>xIr_Y zr`yJ=;?(UWsN|NVO3L7XIiy@Re8r1Hc~d86+8BL!-iw5r%NsJQ0Pu;NqC zGOCJY*Q(T}PQY3t13px%R+UoKEv+blWmDxPWuV+k$h@|vH~uO#{?V`gegit!cQ>-L zzu*+K1E%!dxok~u{L%PPa(9EQE;0YUi3wqRXBy~`lh>Ohz0sZ30bkV{)7c(g$>``o5li?kMnxzViT6&olKU+F#@2 zChiSn?cHEj`XVFjrx$KDbNAD4-{N!G$m*fhTowK5H@HmN-r|MZjoYlIw#TZ5ZEa-p zq;a=?qBWYf$0EPZ9UL5VqGtfb#!xo5)Jc+`ntDMQoL{OtL0y?pPpcCnV|C_f?`sq4 z=!7~x6yhxBG4>=Rv3{N;Rx^qIM~?Jdhp7z%{uGaG;Z!G6nGd?orTVTVUrF6bBu^!J zQ+-pZ%w(!(@?qqu{+b;aOP~WU)D>X`bTuHVX#@sQmwcb7o{J7LHT876tAR_ahKe~r zFub5%YcfiH0Q8b;+1TIq17w#%#FcDF;!%dkyH$U;{bOo75NME`vuOfG=Np^kH3sPA~5 z;0s*%Lcaq6%pVm5uJ7=CTwhtlyoL55C~TQ`pXbXM+EMN{$2#bIL+FtLqHh6T1LLsu ztFUX15V20Uez>F}U*N|8i|##uh|a+e(UBzDKl&ZL19tC7m{jAzG`QGObo_?^J8b+} zc=w>Nt2s2;GdjK$YBQ17P5x}&opLbQ@h^nYZuM)nWH z7(!by{7W(Tm6$r)G5n8W@K0j!&v|{ZqC%7K1FE>}7i;{hPc0F3W@?<+hUE~;v4Sbz zE7T0nr>`4aj;}eNrNB3twN43pAzsGsFS1Mn)Na`{ z)*vJNz$DZ$!*H=!^DHMQ7fY2DQuZh%CWZH{yA~bXr|%Y7L6{IoxKF|}i+93(_`X1S znngn#&#J)1{fEaG|0{v#z(zqF?+}6K5d^`VE8od83=R2@f-U%8NH~702>e@)W1Yvj zjp}=D7%E5{`WeT)Z!FTs*~}ao%rSBQC$|y7+~J{ott-kGV3!tuWl_%jmzgoF=EINsTU|1!r#pAcg5n#7muzZKyxa6XOUyAi&^`R~Q>MI6_G IU;QlOUp7|u&;S4c diff --git a/openmp/serial_gs_pagerank_functions.o b/openmp/serial_gs_pagerank_functions.o deleted file mode 100644 index 6e91ac740e531c407f846b1524581cbd678197cf..0000000000000000000000000000000000000000 GIT binary patch literal 0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