<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=EN-US link=blue vlink=purple>
<div class=WordSection1>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>You can do that. The trick is, for starters you'll
probably only want a single "communicator" to get your feet wet, so
only 1 of the "B"'s should call MPI_INIT and hence become "Node
0". So your "B" logic needs to be clever enough to have an
algorithm to let a single "B" do the INIT and FINALIZE.<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'>
<p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span
style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>
mpich-discuss-bounces@mcs.anl.gov [mailto:mpich-discuss-bounces@mcs.anl.gov] <b>On
Behalf Of </b>Michael Morrison<br>
<b>Sent:</b> Monday, July 12, 2010 5:46 PM<br>
<b>To:</b> mpich-discuss@mcs.anl.gov<br>
<b>Subject:</b> Re: [mpich-discuss] Integrating parallel and serial code<o:p></o:p></span></p>
</div>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal style='margin-bottom:12.0pt'>Thanks again Dave, here is a
clearer description of what i'm trying to accomplish:<br>
<br>
I would like an application to be able to call a routine that happens to use
MPI. The application itself is not fully aware that MPI is being used
in the lower level routine. <br>
<br>
(Thanks to Mr. Solt for helping me to clarify my problem!)<br>
<br>
Thanks,<br>
<br>
Mike<o:p></o:p></p>
<div>
<p class=MsoNormal>On Mon, Jul 12, 2010 at 3:22 PM, Hiatt, Dave M <<a
href="mailto:dave.m.hiatt@citi.com">dave.m.hiatt@citi.com</a>> wrote:<o:p></o:p></p>
<div>
<div>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
style='font-size:11.0pt;color:#1F497D'>Then MPI will work exactly as you are
expecting, that's what it does as it were.</span><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
style='font-size:11.0pt;color:#1F497D'> </span><o:p></o:p></p>
<div style='border:none;border-top:solid windowtext 1.0pt;padding:3.0pt 0in 0in 0in;
border-color:-moz-use-text-color -moz-use-text-color'>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><b><span
style='font-size:10.0pt'>From:</span></b><span style='font-size:10.0pt'> <a
href="mailto:mpich-discuss-bounces@mcs.anl.gov" target="_blank">mpich-discuss-bounces@mcs.anl.gov</a>
[mailto:<a href="mailto:mpich-discuss-bounces@mcs.anl.gov" target="_blank">mpich-discuss-bounces@mcs.anl.gov</a>]
<b>On Behalf Of </b>Michael Morrison<br>
<b>Sent:</b> Monday, July 12, 2010 5:21 PM<o:p></o:p></span></p>
<div>
<p class=MsoNormal><span style='font-size:10.0pt'><br>
<b>To:</b> <a href="mailto:mpich-discuss@mcs.anl.gov" target="_blank">mpich-discuss@mcs.anl.gov</a><o:p></o:p></span></p>
</div>
<p class=MsoNormal><b><span style='font-size:10.0pt'>Subject:</span></b><span
style='font-size:10.0pt'> Re: [mpich-discuss] Integrating parallel and serial
code</span><o:p></o:p></p>
</div>
<div>
<div>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:auto;margin-bottom:12.0pt'>Hey
Dave, Thanks for taking the time to responsd! Actually i am thinking
function A and B as separate modules. Basically i want function A to be able to
call function B in its separate module and then have function B execute it's
parallel algorithm and then return the results to function A. A and B could be
completely different code sets on separate machines. Does that clarify what i'm
trying to do? Sorry if i'm not explaining this clearly.<br>
<br>
Mike<o:p></o:p></p>
<div>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>On
Mon, Jul 12, 2010 at 2:57 PM, Hiatt, Dave M <<a
href="mailto:dave.m.hiatt@citi.com" target="_blank">dave.m.hiatt@citi.com</a>>
wrote:<o:p></o:p></p>
<div>
<div>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
style='font-size:11.0pt;color:#1F497D'>It sounds like you are imagining
function A and B are both part of the same executable module. If that is
the case, then A can be single threaded, but you'd be better off using OpenMP
to thread function B and run in parallel locally. Where MPI would help
you is if function A is part of a program that sends messages out to a group of
computers all running function B, and you are sending different data to all the
functions B's hence you are running in parallel that way.</span><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
style='font-size:11.0pt;color:#1F497D'> </span><o:p></o:p></p>
<div style='border:none;border-top:solid windowtext 1.0pt;padding:3.0pt 0in 0in 0in;
border-color:-moz-use-text-color'>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><b><span
style='font-size:10.0pt'>From:</span></b><span style='font-size:10.0pt'> <a
href="mailto:mpich-discuss-bounces@mcs.anl.gov" target="_blank">mpich-discuss-bounces@mcs.anl.gov</a>
[mailto:<a href="mailto:mpich-discuss-bounces@mcs.anl.gov" target="_blank">mpich-discuss-bounces@mcs.anl.gov</a>]
<b>On Behalf Of </b>Michael Morrison<br>
<b>Sent:</b> Monday, July 12, 2010 4:52 PM<br>
<b>To:</b> <a href="mailto:mpich-discuss@mcs.anl.gov" target="_blank">mpich-discuss@mcs.anl.gov</a><br>
<b>Subject:</b> [mpich-discuss] Integrating parallel and serial code</span><o:p></o:p></p>
</div>
<div>
<div>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Hi
All, I hope i'm posting this in the correct forum. I'm extremely new to MPI so
forgive me if my question comes off as silly. I've only been dabbling around
with parallel computing for a few weeks now but I'm wondering about the
possibilities. So far with each example that I've been through, I create an MPI
application and then run this application using the mpiexec command. What I'm
wondering about is if it would be possible to say have a C function that
executes some algorithm in a parallel manner that could be called by another C
function. For example suppose i had two C functions, the first called function
A and the second called function B. Function A is just a normal function that
runs serially, function B executes its algorithm parallelly using MPI constucts.
Is it possible to have a set up like this?<br>
<br>
>From the examples I've seen it appears that the MPI code runs as standalone
units and couldn't be integrated with serially executing code. Is this
true or is there someway to make this set up work? I may not have given enough
information to answer the question, if there's any confusion please ask and
i'll clarify.<br>
<br>
Thanks for your time,<br>
<br>
Mike<o:p></o:p></p>
</div>
</div>
</div>
</div>
<p class=MsoNormal style='mso-margin-top-alt:auto;margin-bottom:12.0pt'><br>
_______________________________________________<br>
mpich-discuss mailing list<br>
<a href="mailto:mpich-discuss@mcs.anl.gov" target="_blank">mpich-discuss@mcs.anl.gov</a><br>
<a href="https://lists.mcs.anl.gov/mailman/listinfo/mpich-discuss"
target="_blank">https://lists.mcs.anl.gov/mailman/listinfo/mpich-discuss</a><o:p></o:p></p>
</div>
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p>
</div>
</div>
</div>
</div>
<p class=MsoNormal style='margin-bottom:12.0pt'><br>
_______________________________________________<br>
mpich-discuss mailing list<br>
<a href="mailto:mpich-discuss@mcs.anl.gov">mpich-discuss@mcs.anl.gov</a><br>
<a href="https://lists.mcs.anl.gov/mailman/listinfo/mpich-discuss"
target="_blank">https://lists.mcs.anl.gov/mailman/listinfo/mpich-discuss</a><o:p></o:p></p>
</div>
<p class=MsoNormal><o:p> </o:p></p>
</div>
</body>
</html>