From 8dce83172bdb260e5b004821a01598fe72f1bd3a Mon Sep 17 00:00:00 2001 From: mtzikara Date: Sun, 16 Sep 2018 18:19:00 +0200 Subject: [PATCH] Add files via upload --- serial_v2/Makefile | 37 ++ serial_v2/pagerank.out | Bin 0 -> 18669 bytes serial_v2/pagerank_output | 1 + serial_v2/serial_gs_pagerank.c | 33 ++ serial_v2/serial_gs_pagerank.o | Bin 0 -> 2824 bytes serial_v2/serial_gs_pagerank_functions.c | 437 +++++++++++++++++++++++ serial_v2/serial_gs_pagerank_functions.h | 86 +++++ serial_v2/serial_gs_pagerank_functions.o | Bin 0 -> 12784 bytes 8 files changed, 594 insertions(+) create mode 100644 serial_v2/Makefile create mode 100644 serial_v2/pagerank.out create mode 100644 serial_v2/pagerank_output create mode 100644 serial_v2/serial_gs_pagerank.c create mode 100644 serial_v2/serial_gs_pagerank.o create mode 100644 serial_v2/serial_gs_pagerank_functions.c create mode 100644 serial_v2/serial_gs_pagerank_functions.h create mode 100644 serial_v2/serial_gs_pagerank_functions.o diff --git a/serial_v2/Makefile b/serial_v2/Makefile new file mode 100644 index 0000000..a038971 --- /dev/null +++ b/serial_v2/Makefile @@ -0,0 +1,37 @@ +SHELL := /bin/bash + +# ============================================ +# COMMANDS + +CC = gcc +RM = rm -f +CFLAGS_DEBUG=-O0 -g -I. +CFLAGS=-std=gnu99 -O3 -I. +OBJ=serial_gs_pagerank.o serial_gs_pagerank_functions.o +DEPS=serial_gs_pagerank_functions.h + +# ========================================== +# TARGETS + +EXECUTABLES = pagerank.out + +.PHONY: all clean + +all: $(EXECUTABLES) + +# ========================================== +# DEPENDENCIES (HEADERS) + +%.o: %.c $(DEPS) + $(CC) -c -o $@ $< $(CFLAGS) + +.PRECIOUS: $(EXECUTABLES) $(OBJ) + +# ========================================== +# EXECUTABLE (MAIN) + +$(EXECUTABLES): $(OBJ) + $(CC) -o $@ $^ $(CFLAGS) + +clean: + $(RM) *.o *~ $(EXECUTABLES) diff --git a/serial_v2/pagerank.out b/serial_v2/pagerank.out new file mode 100644 index 0000000000000000000000000000000000000000..713bdcb3602545b7145e875f064edfd432b59126 GIT binary patch literal 18669 zcmeHve{@sFmH+4mL^#G02|t`PO_Wxo&JQ~%5P||}BwNByL^dv%grpEz$P(7ZmR;$I zU!}&aZJM`=DCzdw<=eB{WqWq_WcTcLX}g=lm+gWbgAFukfiz80+V8SyAQBFVOA?3D zCfd)P_eOdW_I`WLp6`DdAHSJ<=iWPa?%cUE?`huKBn4kB;k1(8>iLP+biT=0>4#8;#7)o6SoKcy)q za?wBP8~wLx{cAP40TJw`jCuLBm=i6fmh*Bum4|NUAaXY^i2NB9%|tHvz5qVb^N&q7 zjc|?D-gI`E(E2BG4P^Ir#x^Zoa&KpQZD%Z=+E%-5+0xpjOX`x{b@%aplYF9WY+lD( z5_YTxL^{vKKbe~9PgfpWa7X7|&vcyp=al1fqs}ihgx(}x@sHvkot^~c4O38mb{hP> z)8JFn;A^JA_fLawmz&){ESa;K#%80<;J;&L+dca6}1(R|pAqTrcu{bcBySn2VCde8C{`!XCeRYfLmK4g)V)4GZ z`wQp?&~;|SEV%ZM=7t&nGk6`vI|E>v4`SZRH^pXABs{3$zV+<4G5yW#s0OEQrg{_m znFcS2#b#4$X8}{Xa&H^YDP~mil6t9L)W!?f;Y#g^WY^)fkjATObaeJz?3RuRT*5R!>{9YYij44&`)8Xgn==baJ`g!!64u7MLUh03_BBf`{tFbd_a7dn! zeHoQf|53|`jtIs4{YH@F7n*Uk-sVP$;0_|noy#LFy!tu7fnXZaTpNcE5j>0F77qWA zU>d@lo5TM=Fb!R95r@A=Fb!GG&f)J6Ohc8karm1A(-7qthyRpd8k*e1$3QIn8o@Lq zxpN%eK`;$P?i7a;1k(`Yh5$=nefw#YrA(`%C3_p#q)fokLZBpNWQSYI>~t*4?uI_j z$s;Y!HkQ3eTxl;6$waghM2gu#sP&TKbzs=Mjy5XUsMJBFYAW?m$xfwhRI15N!0LTF z9UV-*QF-C;vQN9&5gI4wQ1%XV1ns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OWOkwJX*~{@XhwwP^SrZ5;V; zvA_p8UTsT%-LBCenC({4+D7(kz?1*9mFbh7M$UJEx9bIK`&B#VZqJGpg25I7iQsvoRm{I zrbe%_uWDEm4EWc!27|0Ul89`^ft*MpD0c;MYAhb1SLClj1%vI~!OflBIMWks$MKzH zFqGQH@Zbig&*VsZ-BQ;Biy?UmBAi}|$J7TxK^%ff;H7!~2&p~Q)wLZgIw(j_o=Qls z?MpD4iii0@Io_3(YdlT9ps(4BzNj4&JEp<==ffw8ONk> z2x&*8y%mRck}=Y=iLjAN8$i^ffp5f~~6qzBL|{STMq$yQ$wTDCJapseT@z zv?hVWef;R#N}TIkiDOVDUpgqIRllK7iVJr{!cY0*;RHXZsD5mrltLzR_25$qnzi^x z7fMNJ)NtSt#uXz|{H8)FCET!R&`7*}D;zQ<5X$xn=}OX7?bWR`rDft$9olp1oA z-N6o=LxTm>4?q+N@X3ate>FxC#~_2LWTc%HM#Af9YVkKW23L9-T34?r;#aS0ZCTeE zT-V$m?*YJqwn>t^sEcC2Cor=E;G%Yws3DHw`9$5i#7fR zxOu&2t*@v>lV?4A6YkOKU){VGO5l;K#?3!hfis%Ph(|lZmPCE=+ZaWC=;IY4+OTBg zOF?dO{?&~l5h)#9wI#Sl3oi|wp=1)_reG-eE1!nkE=9D~K?xCS^_s`|2R+J!1~Huq jK|uHMjv^T;m<(-+v}ot)TD!R)^I0jvUCEr}QG)#!y0NBn literal 0 HcmV?d00001 diff --git a/serial_v2/pagerank_output b/serial_v2/pagerank_output new file mode 100644 index 0000000..63a248f --- /dev/null +++ b/serial_v2/pagerank_output @@ -0,0 +1 @@ +7.647500 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 0.950000 diff --git a/serial_v2/serial_gs_pagerank.c b/serial_v2/serial_gs_pagerank.c new file mode 100644 index 0000000..041d784 --- /dev/null +++ b/serial_v2/serial_gs_pagerank.c @@ -0,0 +1,33 @@ +#include + +#include "serial_gs_pagerank_functions.h" + +struct timeval startwtime, endwtime; +double seq_time; + +int main(int argc, char **argv) { + int **directedWebGraph; + int **transitionMatrix; + double *pagerankVector; + Parameters parameters; + + parseArguments(argc, argv, ¶meters); + + initialize(&directedWebGraph, &transitionMatrix, &pagerankVector, ¶meters); + + // Starts wall-clock timer + gettimeofday (&startwtime, NULL); + + int iterations = pagerank(&transitionMatrix, &pagerankVector, parameters); + if (parameters.verbose) { + printf("\n----- Results -----\ + \nTotal iterations = %d\n", 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); +} diff --git a/serial_v2/serial_gs_pagerank.o b/serial_v2/serial_gs_pagerank.o new file mode 100644 index 0000000000000000000000000000000000000000..95ff2eeb9deb8e94ca34852ae48854f238be5af2 GIT binary patch literal 2824 zcmbtW&u<$=6duQcCV|Foi%?NHERqW;)Jt4)h>Ae2(vlU5APTJ%i63TTkK-lw+Vzgr zG>V`V91^NX6$iwH3kNRTH~|OhwjA;&p#B5pz@b>E;(!S6o1N!Ow)O>{wEN!s=6i46 z&aa(ME-bt;l1d4dlz3h2dyERPJF;&VwOJHdaac^`AgscOy2snbp*+W`U_t-5T;Q0ZuK zGIFl?^}188H_K~|3K|mms+7;W{`(e{oX+oCisPv`M7x(VR!nvbTLcHwNoNSXo##SjSco?W#%@yA&k~LY@(*6~lQ&Z%4=2Z9L)_?UL-{MDRXf%-wv=2~!maqq7w$?F3Af#Z z17^XUJ?Iw5m37}m3=#ac>a_Zda-@h}ZZ@z2gc~-Mbm!l?lqX(!%>>F?soM4%GOp@> zzfVvGjQrz?OvQxHF1WTlM-H&G4U%0<`0OU*U!Vqz@qdj!O|i&%h8|mr#;MvM**u?I z$E$=5ivQNcJ(Gy%IM#2Q_~iI?O`Kj!R*tM?!+evT(F6u}c{~QcG968li$1vi<8iZi zpEM{(jnArU;+W4k`>a2r22iJ&VDzqu$N1V}U>yTIqK7e?_vavR0C&q^)-kKo{AJ>2 z?WAOL-3)(9#-Qi})f@T8&CAbLDW$!d;jvh=w18qUEcOh#e(zg2@-zOx!tL*MEc}qMq5cJMt5xv; literal 0 HcmV?d00001 diff --git a/serial_v2/serial_gs_pagerank_functions.c b/serial_v2/serial_gs_pagerank_functions.c new file mode 100644 index 0000000..ca7ba9a --- /dev/null +++ b/serial_v2/serial_gs_pagerank_functions.c @@ -0,0 +1,437 @@ +#include "serial_gs_pagerank_functions.h" + +const char *ARGUMENT_CONVERGENCE_TOLERANCE = "-c"; +const char *ARGUMENT_MAX_ITERATIONS = "-m"; +const char *ARGUMENT_DAMPING_FACTOR = "-a"; +const char *ARGUMENT_VERBAL_OUTPUT = "-v"; +const char *ARGUMENT_OUTPUT_HISTORY = "-h"; +const char *ARGUMENT_OUTPUT_FILENAME = "-o"; + +const int NUMERICAL_BASE = 10; +char *DEFAULT_OUTPUT_FILENAME = "pagerank_output"; + +// ==================== PAGERANK ==================== + +int pagerank(int ***transitionMatrix, double **pagerankVector, Parameters parameters) { + int iterations = 0; + double delta, + *vectorDifference = (double *) malloc(parameters.numberOfPages * sizeof(double)), + *previousPagerankVector = (double *) malloc(parameters.numberOfPages * sizeof(double)), + *convergedPagerankVector = (double *) malloc(parameters.numberOfPages * sizeof(double)), + **linksFromConvergedPages = (double **) malloc(parameters.numberOfPages * sizeof(double *)), + *linksFromConvergedPagesPagerankVector = (double *) malloc(parameters.numberOfPages * sizeof(double)); + bool *converganceMatrix = (bool *) malloc(parameters.numberOfPages * sizeof(bool)); + + for (int i=0; i parameters.convergenceCriterion && + (parameters.maxIterations == 0 || iterations < parameters.maxIterations)); + + if (!parameters.history) { + savePagerankToFile(parameters.outputFilename, false, *pagerankVector, + parameters.numberOfPages); + } + + return iterations; +} + +// ==================== INITIALIZATION ==================== + +/* + * initialize allocates required memory for arrays, reads the web graph from the + * from the file and creates the initial transition probability distribution + * matrix. +*/ +void initialize(int ***directedWebGraph, int ***transitionMatrix, + double **pagerankVector, Parameters *parameters) { + + // Reads web graph from file + if ((*parameters).verbose) { + printf("----- Reading graph from file -----\n"); + } + readGraphFromFile(directedWebGraph, parameters); + + // Outputs the algorithm parameters to the console + if ((*parameters).verbose) { + printf("\n----- Running with parameters -----\ + \nNumber of pages: %d", (*parameters).numberOfPages); + if (!(*parameters).maxIterations) { + printf("\nMaximum number of iterations: inf"); + } else { + printf("\nMaximum number of iterations: %d", (*parameters).maxIterations); + } + printf("\nConvergence criterion: %f\ + \nDamping factor: %f\ + \nGraph filename: %s\n", (*parameters).convergenceCriterion, + (*parameters).dampingFactor, (*parameters).graphFilename); + } + + // Allocates memory for the pagerank vector + (*pagerankVector) = (double *) malloc((*parameters).numberOfPages * sizeof(double)); + double webUniformProbability = 1. / (*parameters).numberOfPages; + for (int i=0; i<(*parameters).numberOfPages; ++i) { + (*pagerankVector)[i] = webUniformProbability; + } + + // Generates the initial transition matrix (matrix P). + generateNormalizedTransitionMatrix(transitionMatrix, *directedWebGraph, *parameters); + // Transposes the transition matrix (P^T). + transposeMatrix(transitionMatrix, (*parameters).numberOfPages, (*parameters).numberOfPages); +} + +/* + * generateNormalizedTransitionMatrix generates the normalized transition matrix + * from the graph data (matrix P'). +*/ +void generateNormalizedTransitionMatrix(int ***transitionMatrix, + int **directedWebGraph, Parameters parameters) { + // Allocates memory for the transitionMatrix rows + (*transitionMatrix) = (int **) malloc(parameters.numberOfPages * sizeof(int *)); + + for (int i=0; i 10) { + validUsage(argumentVector[0]); + } + + (*parameters).numberOfPages = 0; + (*parameters).maxIterations = 0; + (*parameters).convergenceCriterion = 1; + (*parameters).dampingFactor = 0.85; + (*parameters).verbose = false; + (*parameters).history = false; + (*parameters).outputFilename = DEFAULT_OUTPUT_FILENAME; + + char *endPointer; + int argumentIndex = 1; + + while (argumentIndex < argumentCount) { + if (!strcmp(argumentVector[argumentIndex], ARGUMENT_CONVERGENCE_TOLERANCE)) { + argumentIndex = checkIncrement(argumentIndex, argumentCount, argumentVector[0]); + + double convergenceInput = strtod(argumentVector[argumentIndex], &endPointer); + if (convergenceInput == 0) { + printf("Invalid convergence argument\n"); + exit(EXIT_FAILURE); + } + (*parameters).convergenceCriterion = convergenceInput; + } else if (!strcmp(argumentVector[argumentIndex], ARGUMENT_MAX_ITERATIONS)) { + argumentIndex = checkIncrement(argumentIndex, argumentCount, argumentVector[0]); + + size_t iterationsInput = strtol(argumentVector[argumentIndex], &endPointer, NUMERICAL_BASE); + if (iterationsInput == 0 && endPointer) { + printf("Invalid iterations argument\n"); + exit(EXIT_FAILURE); + } + (*parameters).maxIterations = iterationsInput; + } else if (!strcmp(argumentVector[argumentIndex], ARGUMENT_DAMPING_FACTOR)) { + argumentIndex = checkIncrement(argumentIndex, argumentCount, argumentVector[0]); + + double alphaInput = strtod(argumentVector[argumentIndex], &endPointer); + if ((alphaInput == 0 || alphaInput > 1) && endPointer) { + printf("Invalid alpha argument\n"); + exit(EXIT_FAILURE); + } + (*parameters).dampingFactor = alphaInput; + } else if (!strcmp(argumentVector[argumentIndex], ARGUMENT_VERBAL_OUTPUT)) { + (*parameters).verbose = true; + } else if (!strcmp(argumentVector[argumentIndex], ARGUMENT_OUTPUT_HISTORY)) { + (*parameters).history = true; + } else if (!strcmp(argumentVector[argumentIndex], ARGUMENT_OUTPUT_FILENAME)) { + argumentIndex = checkIncrement(argumentIndex, argumentCount, argumentVector[0]); + + if (fopen(argumentVector[argumentIndex], "w") == NULL) { + printf("Invalid output filename. Reverting to default.\n"); + continue; + } + (*parameters).outputFilename = argumentVector[argumentIndex]; + } else if (argumentIndex == argumentCount - 1) { + (*parameters).graphFilename = argumentVector[argumentIndex]; + } else { + validUsage(argumentVector[0]); + exit(EXIT_FAILURE); + } + ++argumentIndex; + } +} + +/* + * readGraphFromFile loads the file supplied in the command line arguments to an + * array (directedWebGraph) that represents the graph. +*/ +void readGraphFromFile(int ***directedWebGraph, Parameters *parameters) { + FILE *graphFile; + + // Opens the file for reading + graphFile = fopen((*parameters).graphFilename, "r+"); + if (!graphFile) { + printf("Error opening file \n"); + exit(EXIT_FAILURE); + } + + // Reads the dimensions of the (square) array from the file + int readChar, numberOfLines=0; + while((readChar = fgetc(graphFile))) { + // Breaks if end of file + if (readChar == EOF) break; + // Otherwise, if the character is a break line, adds one to the count of lines + if (readChar == '\n') { + ++numberOfLines; + } + } + + if ((*parameters).verbose) { + printf("Line count of file is %d \n", numberOfLines + 1); + } + + // Each line of the file represents one page of the graph + (*parameters).numberOfPages = numberOfLines + 1; + rewind(graphFile); + + // Allocates memory and loads values into directedWebGraph (matrix A) + // Allocates memory for the rows + (*directedWebGraph) = (int **) malloc((*parameters).numberOfPages * sizeof(int *)); + + for (int i=0; i<(*parameters).numberOfPages; ++i) { + // Allocates memory for the columns of this row + (*directedWebGraph)[i] = (int *) malloc((*parameters).numberOfPages * sizeof(int)); + // Reads values from the file + for (int j=0; j<(*parameters).numberOfPages; ++j) { + if (!fscanf(graphFile, "%d ", &(*directedWebGraph)[i][j])) { + break; + } + } + } + + fclose(graphFile); +} + +/* + * validUsage outputs a message to the console that informs the user of the + * correct (valid) way to use the program. +*/ +void validUsage(char *programName) { + printf("%s [-c convergence_criterion] [-m max_iterations] [-a alpha] [-v] [-h] [-o output_filename] \ + \n-c convergence_criterion\ + \n\tthe convergence tolerance criterion\ + \n-m max_iterations\ + \n\tmaximum number of iterations to perform\ + \n-a alpha\ + \n\tthe damping factor\ + \n-v enable verbal output\ + \n-h enable history output to file\ + \n-o output_filename\ + \n\tfilename and path for the output\ + \n", programName); + exit(EXIT_FAILURE); +} + +/* + * checkIncrement is a helper function for parseArguments function. +*/ +int checkIncrement(int previousIndex, int maxIndex, char *programName) { + if (previousIndex == maxIndex) { + validUsage(programName); + exit(EXIT_FAILURE); + } + return ++previousIndex; +} + +void savePagerankToFile(char *filename, bool append, double *pagerankVector, + int vectorSize) { + FILE *outputFile; + + if (append) { + outputFile = fopen(filename, "a"); + } else { + outputFile = fopen(filename, "w"); + } + + if (outputFile == NULL) { + printf("Error while opening the output file.\n"); + return; + } + + for (int i=0; i +#include +#include +#include +#include + +/* + * Constant strings that store the command line options available. +*/ +extern const char *ARGUMENT_CONVERGENCE_TOLERANCE; +extern const char *ARGUMENT_MAX_ITERATIONS; +extern const char *ARGUMENT_DAMPING_FACTOR; +extern const char *ARGUMENT_VERBAL_OUTPUT; +extern const char *ARGUMENT_OUTPUT_HISTORY; +extern const char *ARGUMENT_OUTPUT_FILENAME; + +// This is the numerical base used when parsing the numerical command line +// arguments. +extern const int NUMERICAL_BASE; +// Default filename used for the output. +extern char *DEFAULT_OUTPUT_FILENAME; + +// Declares a data structure to conveniently hold the algorithm's parameters. +typedef struct parameters { + int numberOfPages, maxIterations; + double convergenceCriterion, dampingFactor; + bool verbose, history; + char *outputFilename, *graphFilename; +} Parameters; + +// Function validUsage outputs the correct way to use the program with command +// line arguments. +void validUsage(char *programName); + +// Function checkIncrement is a helper function used in parseArguments (see +// bellow). +int checkIncrement(int previousIndex, int maxIndex, char *programName); + +// Function parseArguments parses command line arguments. +void parseArguments(int argumentCount, char **argumentVector, Parameters *parameters); + +// Function readGraphFromFile loads adjacency matrix, that represents the web +// graph, stored in the file provided in the command line arguments to the array +// directedWebGraph. +void readGraphFromFile(int ***directedWebGraph, Parameters *parameters); + +// 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); + +// Function generateNormalizedTransitionMatrix generates the normalized +// transition matrix from the web graph data. +void generateNormalizedTransitionMatrix(int ***transitionMatrix, + int **directedWebGraph, Parameters parameters); + +// Function transposeMatrix transposes a matrix. +void transposeMatrix(int ***matrix, int rows, int columns); + +// Function initialize allocates required memory for arrays, reads the dataset +// from the file and creates the transition probability distribution matrix. +void initialize( + int ***directedWebGraph, /*This is matrix G (web graph)*/ + int ***transitionMatrix, /*This is matrix A (transition probability distribution matrix)*/ + double **pagerankVector, /*This is the resulting pagerank vector*/ + Parameters *parameters + ); + +// Function vectorNorm calculates the first norm of a vector. +double vectorNorm(double *vector, int vectorSize); + +// Function matrixVectorMultiplication calculates the product of the +// multiplication between a matrix and the a vector. +void matrixVectorMultiplication(int **transitionMatrix, double *previousPagerankVector, + double *linksFromConvergedPagesPagerankVector, double *convergedPagerankVector, + double **pagerankVector, int vectorSize, double dampingFactor); + +// 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(int ***transitionMatrix, double **pagerankVector, Parameters parameters); + +#endif // SERIAL_GS_PAGERANK_FUNCTIONS_H \ No newline at end of file diff --git a/serial_v2/serial_gs_pagerank_functions.o b/serial_v2/serial_gs_pagerank_functions.o new file mode 100644 index 0000000000000000000000000000000000000000..7c9075b2557dc51ee7089430fb823c26f0d079e6 GIT binary patch literal 12784 zcmcgydvIITnZL3`q8OvAKnSL#pi-q(2zITKwh^So*Ou^AA{%ewKqv;I$WrW$UzM)% zV1u1jR?1zWG<`0erDdn>>@qvEox(6owzS2@i5&wcvu?d|siG>{ z?b>bHI<0NpTHXAMo_nV{TZaj$Hzz(^Rb2TI5uczxk^CFF=~Q=p3w^EFXMXtO;}N4g=KnSrJo5{ZHB+3L~|4F=Fr*f@!%Qt zntDYG{b}$f^Tg6qdg6>edfXW+R_!DH;D~OX)txXyciyC4qv(Z2^9q&tJ73R@xMQLH zW@UCNY#z^zJ0N0ckDl9Gedk?TyLOj$x7INR<-=qejDAMlwGI){+D@z98iG>l?T6Q$ zR@+YmPp)k)_#(lPlp1)g*?gVs(akB{c~w8dehneH|QC z<0MZDjezCQ(1~bn%&q74xhDT^dU`rq4Ew!$@m{YUI#{oMe>@ucuwMPn#DepBaT~Dx z>i0(k^g;dbxN)zR`{3fuM%bJPjs(vfdM{k8x*6V9RUkTeE^?&Q#jy%EbbDPc^xGWn zl%_5YyI|J(XYm`w@G?wk>JcM(gLDRu|5r zXum&3fueP0G}gQZs=X8h*IvuT(V_pEIz$1OTny(@)M~~0Ncs1*cOJy*6o&mT(c>Zi zK|CP#asO}8(ar5vS_aIp{~q;;VgDqdi7A+ZB)LEA->8H26eA7$x9UaLN%WDM!I*hAYVIv{_lYi%)XRf`Nbn3B>*jkjsk1@;sBZ2X?24J4es9d|@%x(1KgY0T z*2fCl{R6Rr;n!I_^a8{+jE9kNG4rj}6Rvm3npG1nCWZY8o>^_W-iw*9!N6#4pM!zn z(A3Zv3G~JakiO%W*49z;KXWNcv2hv!`KA9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