Mercurial > forge
changeset 6436:d89d4abbff76 octave-forge
(none)
author | rikcorradini |
---|---|
date | Wed, 09 Dec 2009 17:12:19 +0000 |
parents | 864b3f361d47 |
children | 92cd6f28bc7f |
files | extra/openmpi_ext/inst/hellostruct.m |
diffstat | 1 files changed, 51 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/extra/openmpi_ext/inst/hellostruct.m Wed Dec 09 17:12:19 2009 +0000 @@ -0,0 +1,51 @@ +## Copyright (C) 2009 Riccardo Corradini <riccardocorradini@yahoo.it> +## 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 <http://www.gnu.org/licenses/>. + + +# Please add the oct files openmpi_ext folder +# For instance +addpath("../src"); +# 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 hellostruct + + + 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 = struct('f1', {1 3; 2 4}, 'f2', 25); + # Could be a vector containing the list of ranks identifiers; + 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.."); + [message, info] = MPI_Recv(source,TAG,CW); + message + endfor + end + MPI_Finalize(); +