1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
|
[1X15 [33X[0;0YParallel computation[133X[101X
[1X15.1 [33X[0;0YAn embarassingly parallel computation[133X[101X
[33X[0;0YThe following example creates fifteen child processes and uses them
simultaneously to compute the second integral homology of each of the [22X2328[122X
groups of order [22X128[122X. The final command shows that[133X
[33X[0;0Y[22XH_2(G, Z)= Z_2^21[122X[133X
[33X[0;0Yfor the [22X2328[122X-th group [22XG[122X in [12XGAP[112X's library of small groups. The penulimate
command shows that the parallel computation achieves a speedup of 10.4 .[133X
[4X[32X Example [32X[104X
[4X[25Xgap>[125X [27XProcesses:=List([1..15],i->ChildProcess());;[127X[104X
[4X[25Xgap>[125X [27Xfn:=function(i);return GroupHomology(SmallGroup(128,i),2);end;;[127X[104X
[4X[25Xgap>[125X [27Xfor p in Processes do[127X[104X
[4X[25X>[125X [27XChildPut(fn,"fn",p);[127X[104X
[4X[25X>[125X [27Xod;[127X[104X
[4X[25Xgap>[125X [27XExec("date +%s");L:=ParallelList([1..2328],"fn",Processes);;Exec("date +%s");[127X[104X
[4X[28X1716105545[128X[104X
[4X[28X1716105554[128X[104X
[4X[25Xgap>[125X [27XExec("date +%s");L1:=List([1..2328],fn);;Exec("date +%s");[127X[104X
[4X[28X1716105586[128X[104X
[4X[28X1716105680[128X[104X
[4X[28X[128X[104X
[4X[25Xgap>[125X [27Xspeedup:=1.0*(680-586)/(554-545);[127X[104X
[4X[28X10.4444[128X[104X
[4X[28X[128X[104X
[4X[25Xgap>[125X [27XL[2328];[127X[104X
[4X[28X[ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ][128X[104X
[4X[28X[128X[104X
[4X[32X[104X
[33X[0;0YThe function [10XParallelList()[110X is built from [12XHAP[112X's six core functions for
parallel computation.[133X
[1X15.2 [33X[0;0YA non-embarassingly parallel computation[133X[101X
[33X[0;0YThe following commands use core functions to compute the product [22XA=M× N[122X of
two random matrices by distributing the work over two processors.[133X
[4X[32X Example [32X[104X
[4X[25Xgap>[125X [27XM:=RandomMat(10000,10000);;[127X[104X
[4X[25Xgap>[125X [27XN:=RandomMat(10000,10000);;[127X[104X
[4X[25Xgap>[125X [27X[127X[104X
[4X[25Xgap>[125X [27Xs:=ChildProcess();;[127X[104X
[4X[25Xgap>[125X [27X[127X[104X
[4X[25Xgap>[125X [27XExec("date +%s");[127X[104X
[4X[28X1716109418[128X[104X
[4X[25Xgap>[125X [27XMtop:=M{[1..5000]};;[127X[104X
[4X[25Xgap>[125X [27XMbottom:=M{[5001..10000]};;[127X[104X
[4X[25Xgap>[125X [27XChildPut(Mtop,"Mtop",s);[127X[104X
[4X[25Xgap>[125X [27XChildPut(N,"N",s);[127X[104X
[4X[25Xgap>[125X [27XNextAvailableChild([s]);;[127X[104X
[4X[25Xgap>[125X [27XChildCommand("Atop:=Mtop*N;;",s);;[127X[104X
[4X[25Xgap>[125X [27XAbottom:=Mbottom*N;;[127X[104X
[4X[25Xgap>[125X [27XA:=ChildGet("Atop",s);;[127X[104X
[4X[25Xgap>[125X [27XAppend(A,Abottom);;[127X[104X
[4X[25Xgap>[125X [27XExec("date +%s");[127X[104X
[4X[28X1716110143[128X[104X
[4X[28X[128X[104X
[4X[25Xgap>[125X [27XAA:=M*N;;Exec("date +%s");[127X[104X
[4X[28X1716111389[128X[104X
[4X[28X[128X[104X
[4X[25Xgap>[125X [27Xspeedup:=1.0*(111389-110143)/(110143-109418);[127X[104X
[4X[28X1.71862[128X[104X
[4X[28X[128X[104X
[4X[32X[104X
[33X[0;0YThe next commands compute the product [22XA=M× N[122X of two random matrices by
distributing the work over fifteen processors. The parallelization is very
naive (the entire matrices [22XM[122X and [22XN[122X are communicated to all processes) and
the computation achieves a speedup of 7.6.[133X
[4X[32X Example [32X[104X
[4X[25Xgap>[125X [27XM:=RandomMat(15000,15000);;[127X[104X
[4X[25Xgap>[125X [27XN:=RandomMat(15000,15000);;[127X[104X
[4X[25Xgap>[125X [27XS:=List([1..15],i->ChildCreate());;[127X[104X
[4X[28X[128X[104X
[4X[25Xgap>[125X [27XExec("date +%s");[127X[104X
[4X[28X1716156583[128X[104X
[4X[25Xgap>[125X [27XChildPutObj(M,"M",S);[127X[104X
[4X[25Xgap>[125X [27XChildPutObj(N,"N",S);[127X[104X
[4X[25Xgap>[125X [27Xfor i in [1..15] do[127X[104X
[4X[25X>[125X [27Xcmd:=Concatenation("A:=M{[1..1000]+(",String(i),"-1)*1000}*N;");[127X[104X
[4X[25X>[125X [27XChildCommand(cmd,S[i]);[127X[104X
[4X[25X>[125X [27Xod;[127X[104X
[4X[25Xgap>[125X [27XA:=[];;[127X[104X
[4X[25Xgap>[125X [27Xfor i in [1..15] do[127X[104X
[4X[25X>[125X [27X C:=ChildGet("A",S[i]);[127X[104X
[4X[25X>[125X [27X Append(A,C);[127X[104X
[4X[25X>[125X [27Xod;[127X[104X
[4X[25Xgap>[125X [27XExec("date +%s");[127X[104X
[4X[28X1716157489[128X[104X
[4X[28X[128X[104X
[4X[25Xgap>[125X [27XAA:=M*N;;Exec("date +%s");[127X[104X
[4X[28X1716164405[128X[104X
[4X[28X[128X[104X
[4X[25Xgap>[125X [27Xspeedup:=1.0*(64405-57489)/(57489-56583);[127X[104X
[4X[28X7.63355[128X[104X
[4X[28X[128X[104X
[4X[32X[104X
[1X15.3 [33X[0;0YParallel persistent homology[133X[101X
[33X[0;0YSection [14X5.8[114X illustrates an alternative method of computing the persitent
Betti numbers of a filtered pure cubical complex. The method lends itself to
parallelisation. However, the following parallel computation of persistent
Betti numbers achieves only a speedup of [22X1.5[122X due to a significant time spent
transferring data structures between processes. On the other hand, the
persistent Betti function could be used to distribute computations over
several computers. This might be useful for larger computations that require
significant memory resources.[133X
[4X[32X Example [32X[104X
[4X[25Xgap>[125X [27Xfile:=HapFile("data247.txt");;[127X[104X
[4X[25Xgap>[125X [27XRead(file);;[127X[104X
[4X[25Xgap>[125X [27XF:=ThickeningFiltration(T,25);;[127X[104X
[4X[25Xgap>[125X [27XS:=List([1..15],i->ChildCreate());;[127X[104X
[4X[25Xgap>[125X [27XN:=[0,1,2];;[127X[104X
[4X[25Xgap>[125X [27XExec("date +%s");P:=ParallelPersistentBettiNumbers(F,N,S);;Exec("date +%s");[127X[104X
[4X[28X1717160785[128X[104X
[4X[28X1717161285[128X[104X
[4X[28X[128X[104X
[4X[25Xgap>[125X [27XExec("date +%s");Q:=PersistentBettiNumbersAlt(F,N);;Exec("date +%s");[127X[104X
[4X[28X1717161528[128X[104X
[4X[28X1717162276[128X[104X
[4X[25Xgap>[125X [27Xspeedup:=1.0*(1717162276-1717161528)/(1717161285-1717160785);[127X[104X
[4X[28X1.496[128X[104X
[4X[28X[128X[104X
[4X[32X[104X
|