GAP (HAP commands) - Chapter 14: Parallel computation

Goto Chapter: Top 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Bib Ind
[Top of Book] [Contents] [Previous Chapter] [Next Chapter]

[MathJax off]

14 Parallel computation
14.1 An embarassingly parallel computation
14.2 An non-embarassingly parallel computation

### 14 Parallel computation

#### 14.1 An embarassingly parallel computation

The following example creates five child processes and uses them simultaneously to compute the second integral homology of each of the \(267\) groups of order \(64\). The final command shows that

\(H_2(G,\mathbb Z)=\mathbb Z_2^{15}\)

for the \(267\)-th group \(G\) in GAP's library of small groups.

    gap> Processes:=List([1..5],i->ChildProcess());;
    gap> fn:=function(i);return GroupHomology(SmallGroup(64,i),2);end;;
    gap> for p in Processes do
    > ChildPut(fn,"fn",p);
    > od;

    gap> NrSmallGroups(64);
    267

    gap> L:=ParallelList([1..267],"fn",Processes);;

    gap> L[267];
    [ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]

The function `ParallelList()` is built from HAP's six core functions for parallel computation.

#### 14.2 An non-embarassingly parallel computation

The following commands use core functions to compute the product \(A=M\times N\) of two random matrices by distributing the work over two processors.

    gap> M:=RandomMat(2000,2000);;
    gap> N:=RandomMat(2000,2000);;

    gap> s:=ChildProcess();;

    gap> Mtop:=M{[1..1000]};;
    gap> Mbottom:=M{[1001..2000]};;

    gap> ChildPut(Mtop,"Mtop",s);
    gap> ChildPut(N,"N",s);
    gap> NextAvailableChild([s]);;

    gap> ChildCommand("Atop:=Mtop*N;;",s);;
    gap> Abottom:=Mbottom*N;;
    gap> A:=ChildGet("Atop",s);;
    gap> Append(A,Abottom);;

[Top of Book] [Contents] [Previous Chapter] [Next Chapter]
Goto Chapter: Top 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Bib Ind

generated by GAPDoc2HTML