Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Parallelise matlab using MPI (C or C++)
Replies: 9   Last Post: Apr 10, 2014 6:20 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Yair Altman

Posts: 1,349
Registered: 3/19/07
Re: Parallelise matlab using MPI (C or C++)
Posted: Apr 6, 2014 2:01 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Leo Kay" <anousleshommes@hotmail.com> wrote in message <lhmihf$l6o$1@newscl01ah.mathworks.com>...
> Hello,
> I guess this question is more for the initiated, but I don't really know where to look so here goes.
> I'd like to run the simple matlab piece of code below on a supercomputer using C to lanuch mpi and then entering parameters in C which would then be taken as parameter attributes by a matlab piece of code. The parameter attributes entered into matlab would designate which core performs which computation and in that sense should speed up the operation.
> Example C initiates MPI and asks for say 4 workers on a single core. For each worker, see sends the worker parameter to a matlab script and the script thus runs up to a set number n where n = N/4 , so for a FOR LOOP you only solve the loop up to n for the worker.
> Then you need to return results and aggregate.
>
> Apparently this is doable with system function for C
>
> Can someone enlighten me of how I should go about implement this please?
>
> Here is a piece of code for which I would very much like this to work
>
>
> if matlabpool('size') == 0 % checking to see if my pool is already open
> matlabpool open 2
> end
> parfor kay = 1:size(eige,1)
> % normalise eigenvector
> eige(kay,:) = eige(kay,:)./norm(eige(kay,:));
> entrop(kay) = -(1/log(QG.numB))*sum((abs(eige(kay,:)).^2).*log(abs(eige(kay,:)).^2)) ;
> end
>
>
>
> where eige is a matrix and entrop a vector.
> Things to note: The node on the supercomputer has 16 cores and 8 workers per core. I am unsure if the code I use to open the matlabpool is valid and whether I should actually open more than 2 (this is just a safe but obviously low choice). Other thing to note is that code above will run as slowly as a for look because the time consuming sum is actually for each index 'kay'. It is possible I might want to have the parfor inside the for loop to compute the sum, but isn't that illegal?
>
> So can someone help as to use the simple piece of code above into a c script for mpi?
>
> Thanks in advance


I think you'll find Jeremy Kepner's pMatlab and his "Parallel Matlab for Multicore and Multinode Computers" book (SIAM 2009, ISBN 089871673X) helpful.

Yair Altman
http://UndocumentedMatlab.com




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.