X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?p=CreaPhase.git;a=blobdiff_plain;f=octave_packages%2Fopenmpi_ext-1.0.2%2Fhello2dimmat.m;fp=octave_packages%2Fopenmpi_ext-1.0.2%2Fhello2dimmat.m;h=36ed497b8aa5ebb0f54770516e018177a039d078;hp=0000000000000000000000000000000000000000;hb=c880e8788dfc484bf23ce13fa2787f2c6bca4863;hpb=1705066eceaaea976f010f669ce8e972f3734b05 diff --git a/octave_packages/openmpi_ext-1.0.2/hello2dimmat.m b/octave_packages/openmpi_ext-1.0.2/hello2dimmat.m new file mode 100644 index 0000000..36ed497 --- /dev/null +++ b/octave_packages/openmpi_ext-1.0.2/hello2dimmat.m @@ -0,0 +1,33 @@ + MPI_SUCCESS =0; + MPI_Init(); + + # the string NEWORLD is just a label could be whatever you want + CW = MPI_Comm_Load("NEWORLD"); + my_rank = MPI_Comm_rank(CW); + p = MPI_Comm_size(CW); + mytag = 48; + + + + if (my_rank != 0) +# Generate a random matrix + message=rand(444440,8); +# load message +# rankvect is the vector containing the list of rank destination process + rankvect = 0; + [info] = MPI_Send(message,rankvect,mytag,CW); + else + for source = 1:p-1 + disp("We are at rank 0 that is master etc.."); + [messager, info] = MPI_Recv(source,mytag,CW); + +# You could also save each result and make comparisons if you don't trust MPI + disp("Rank 0 is the master receiving ... :"); + if (info == MPI_SUCCESS) + disp('OK!'); + endif + endfor + end + + + MPI_Finalize();