X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?p=CreaPhase.git;a=blobdiff_plain;f=octave_packages%2Fopenmpi_ext-1.0.2%2Fhellosparsemat.m;fp=octave_packages%2Fopenmpi_ext-1.0.2%2Fhellosparsemat.m;h=cbacce375661f0765d012386d48a5471b95a8dbe;hp=0000000000000000000000000000000000000000;hb=c880e8788dfc484bf23ce13fa2787f2c6bca4863;hpb=1705066eceaaea976f010f669ce8e972f3734b05 diff --git a/octave_packages/openmpi_ext-1.0.2/hellosparsemat.m b/octave_packages/openmpi_ext-1.0.2/hellosparsemat.m new file mode 100644 index 0000000..cbacce3 --- /dev/null +++ b/octave_packages/openmpi_ext-1.0.2/hellosparsemat.m @@ -0,0 +1,47 @@ + 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); +# tag[0] ----> type of octave_value +# tag[1] ----> array of three elements 1) num of rows 2) number of columns 3) number of non zero elements +# tag[2] ----> vector of rowindex +# tag[3] ----> vector of columnindex +# tag[4] ----> vector of non zero elements +# These tags will be generated after mytag by the MPI_Send and MPI_Recv (see source code) + + mytag = 48; + + + + +# This is just to fill the sparse matrix + M=5; + N=5; + D=0.9; + message = sprand (M, N, D); +# load message + + + + if (my_rank != 0) + dest = 0; +# rankvect is the vector containing the list of rank destination process + rankvect(1,1) = 0; + [info] = MPI_Send(message,rankvect,mytag,CW); + disp("This is flag for sending the message --") + info + else + for source = 1:p-1 + messager=''; + disp("We are at rank 0 that is master etc.."); + [messager, info] = MPI_Recv(source,mytag,CW); + disp("Rank 0 is the master receiving ... :"); + if (messager/message) + disp('OK!'); + endif + messager + endfor + end + + MPI_Finalize();