X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=octave_packages%2Fopenmpi_ext-1.0.2%2Fhellocell.m;fp=octave_packages%2Fopenmpi_ext-1.0.2%2Fhellocell.m;h=0059d0b2e13350d841a53dccb5f373ffdf7cf30d;hb=c880e8788dfc484bf23ce13fa2787f2c6bca4863;hp=0000000000000000000000000000000000000000;hpb=1705066eceaaea976f010f669ce8e972f3734b05;p=CreaPhase.git diff --git a/octave_packages/openmpi_ext-1.0.2/hellocell.m b/octave_packages/openmpi_ext-1.0.2/hellocell.m new file mode 100644 index 0000000..0059d0b --- /dev/null +++ b/octave_packages/openmpi_ext-1.0.2/hellocell.m @@ -0,0 +1,52 @@ +## Copyright (C) 2009 Riccardo Corradini +## under the terms of the GNU General Public License. +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; If not, see . + + +# if you have 4 cores or a network of 4 computers with a ssh connection with no password and same openmpi 1.3.3 installation +# type at the terminal mpirun -np 4 octave --eval hellocell + + + 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 is very important to identify the message + TAG = 1; + + + message=""; + if (my_rank != 0) + message = {magic(3) 17 'fred'; ... + 'AliceBettyCarolDianeEllen' 'yp' 42; ... + {1} 2 3}; + rankvect = 0; + [info] = MPI_Send(message,rankvect,TAG,CW); + else + for source = 1:p-1 + disp("We are at rank 0 that is master etc.."); + [messager, info] = MPI_Recv(source,TAG,CW); + info + messager + endfor + end + + + MPI_Finalize(); +