]> Creatis software - CreaPhase.git/blob - octave_packages/openmpi_ext-1.0.2/hello2dimmat.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / openmpi_ext-1.0.2 / hello2dimmat.m
1   MPI_SUCCESS =0;
2   MPI_Init();
3
4   # the string NEWORLD is just a label could be whatever you want    
5   CW = MPI_Comm_Load("NEWORLD");
6   my_rank = MPI_Comm_rank(CW);
7   p = MPI_Comm_size(CW);
8   mytag = 48;
9
10
11  
12   if (my_rank != 0)
13 #        Generate a random matrix
14        message=rand(444440,8);
15 #        load message
16 #       rankvect is the vector containing the list of rank  destination process
17      rankvect = 0;
18      [info] = MPI_Send(message,rankvect,mytag,CW);
19   else
20         for source = 1:p-1
21           disp("We are at rank 0 that is master etc..");
22           [messager, info] = MPI_Recv(source,mytag,CW);
23           
24 #       You could also save each result and make comparisons if you don't trust MPI
25           disp("Rank 0 is the master receiving ... :");
26             if (info == MPI_SUCCESS)
27               disp('OK!');
28           endif
29           endfor
30   end   
31
32
33    MPI_Finalize();