Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > MPI and Pthread

Reply
Thread Tools

MPI and Pthread

 
 
Pallav singh
Guest
Posts: n/a
 
      09-13-2010
Hi ,

i am trying to compile following program and getting error due to
unable to include
path to File "mpi.h" . Is it provided under Linux kernel or we need to
download library for this

#include "mpi.h"
#include <stdio.h>
#include <stdlib.h>

/* A simple test of Reduce with all choices of root process */
int main( int argc, char *argv[] )
{
int errs = 0;
int rank, size, root;
int *sendbuf, *recvbuf, i;
int minsize = 2, count;
MPI_Comm comm;

MPI_Init( &argc, &argv );

comm = MPI_COMM_WORLD;
/* Determine the sender and receiver */
MPI_Comm_rank( comm, &rank );
MPI_Comm_size( comm, &size );

for (count = 1; count < 130000; count = count * 2) {
sendbuf = (int *)malloc( count * sizeof(int) );
recvbuf = (int *)malloc( count * sizeof(int) );
for (root = 0; root < size; root ++) {
for (i=0; i<count; i++) sendbuf[i] = i;
for (i=0; i<count; i++) recvbuf[i] = -1;
MPI_Reduce( sendbuf, recvbuf, count, MPI_INT, MPI_SUM,
root, comm );
if (rank == root) {
for (i=0; i<count; i++) {
if (recvbuf[i] != i * size) {
errs++;
}
}
}
}
free( sendbuf );
free( recvbuf );
}

MPI_Finalize();
return errs;
}

Thanks
Pallav Singh
 
Reply With Quote
 
 
 
 
Malcolm McLean
Guest
Posts: n/a
 
      09-13-2010
On Sep 13, 2:28*pm, Pallav singh <singh.pal...@gmail.com> wrote:
> Hi ,
>
> i am trying to compile following program and getting error due to
> unable to include path to File "mpi.h" .
>

A standard C compiler won't compile MPI programs. You need an MPI
compiler, usually called "mpicc". It should link the MPI library
automatically.



 
Reply With Quote
 
 
 
 
blmblm@myrealbox.com
Guest
Posts: n/a
 
      09-13-2010
In article <7a961a92-cb31-46eb-afe4->,
Malcolm McLean <> wrote:
> On Sep 13, 2:28pm, Pallav singh <singh.pal...@gmail.com> wrote:
> > Hi ,
> >
> > i am trying to compile following program and getting error due to
> > unable to include path to File "mpi.h" .
> >

> A standard C compiler won't compile MPI programs. You need an MPI
> compiler, usually called "mpicc". It should link the MPI library
> automatically.
>


Are you sure you're not thinking of OpenMP rather than MPI? In at
least some implementations of MPI, mpicc is just a wrapper script
that calls an underlying compiler with appropriate flags to help it
find the include file (mpi.h) and libraries.

But the OP does indeed need an MPI implementation to compile the
program shown.

--
B. L. Massingill
ObDisclaimer: I don't speak for my employers; they return the favor.
 
Reply With Quote
 
Malcolm McLean
Guest
Posts: n/a
 
      09-13-2010
On Sep 13, 3:19*pm, blm...@myrealbox.com <blm...@myrealbox.com> wrote:
> In article <7a961a92-cb31-46eb-afe4-db4193281...@q26g2000vbn.googlegroups..com>,
> Malcolm McLean *<malcolm.mcle...@btinternet.com> wrote:
>
> > On Sep 13, 2:28pm, Pallav singh <singh.pal...@gmail.com> wrote:
> > > Hi ,

>
> > > i am trying to compile following program and getting error due to
> > > unable to include path to File "mpi.h" .

>
> > A standard C compiler won't compile MPI programs. You need an MPI
> > compiler, usually called "mpicc". It should link the MPI library
> > automatically.

>
> Are you sure you're not thinking of OpenMP rather than MPI? *In at
> least some implementations of MPI, mpicc is just a wrapper script
> that calls an underlying compiler with appropriate flags to help it
> find the include file (mpi.h) and libraries.
>

On my MPI implementation the mpicc was very fussy, rejecting C++ style
comments. So I would guess that it was a special compiler. I never
tried to dive into its internals, however.
 
Reply With Quote
 
blmblm@myrealbox.com
Guest
Posts: n/a
 
      09-13-2010
In article <98dda78b-6b9c-4089-8e79->,
Malcolm McLean <> wrote:
> On Sep 13, 3:19pm, blm...@myrealbox.com <blm...@myrealbox.com> wrote:
> > In article

> <7a961a92-cb31-46eb-afe4-db4193281...@q26g2000vbn.googlegroups.com>,
> > Malcolm McLean <malcolm.mcle...@btinternet.com> wrote:
> >
> > > On Sep 13, 2:28pm, Pallav singh <singh.pal...@gmail.com> wrote:
> > > > Hi ,

> >
> > > > i am trying to compile following program and getting error due to
> > > > unable to include path to File "mpi.h" .

> >
> > > A standard C compiler won't compile MPI programs. You need an MPI
> > > compiler, usually called "mpicc". It should link the MPI library
> > > automatically.

> >
> > Are you sure you're not thinking of OpenMP rather than MPI? In at
> > least some implementations of MPI, mpicc is just a wrapper script
> > that calls an underlying compiler with appropriate flags to help it
> > find the include file (mpi.h) and libraries.
> >

> On my MPI implementation the mpicc was very fussy, rejecting C++ style
> comments. So I would guess that it was a special compiler. I never
> tried to dive into its internals, however.


I guess that's possible, though it seems equally possible to me that
it called a regular C compiler but passed it flags that made it reject
C++-style comments. I can't really imagine why someone implementing
MPI would produce a full compiler -- I mean, the MPI API defines a set
of library functions rather than language extensions -- but what do
I know, right?

(What implementation was this? I'm curious.)

--
B. L. Massingill
ObDisclaimer: I don't speak for my employers; they return the favor.
 
Reply With Quote
 
blmblm@myrealbox.com
Guest
Posts: n/a
 
      09-13-2010
In article <>,
<> wrote:
> In article <7a961a92-cb31-46eb-afe4->,
> Malcolm McLean <> wrote:
> > On Sep 13, 2:28pm, Pallav singh <singh.pal...@gmail.com> wrote:
> > > Hi ,
> > >
> > > i am trying to compile following program and getting error due to
> > > unable to include path to File "mpi.h" .
> > >

> > A standard C compiler won't compile MPI programs. You need an MPI
> > compiler, usually called "mpicc". It should link the MPI library
> > automatically.
> >

>
> Are you sure you're not thinking of OpenMP rather than MPI? In at
> least some implementations of MPI, mpicc is just a wrapper script
> that calls an underlying compiler with appropriate flags to help it
> find the include file (mpi.h) and libraries.
>
> But the OP does indeed need an MPI implementation to compile the
> program shown.


This being clc, I feel obligated to dot the T's and cross the I's:

To compile and link the program the OP will need the include
file and the library file(s) from an MPI implementation.
The runtime-system part of the implementation (mpiexec or mpirun
command, e.g.) will also be needed to execute the program.

--
B. L. Massingill
ObDisclaimer: I don't speak for my employers; they return the favor.
 
Reply With Quote
 
Malcolm McLean
Guest
Posts: n/a
 
      09-13-2010
On Sep 13, 4:53*pm, blm...@myrealbox.com <blm...@myrealbox.com> wrote:
> In article <98dda78b-6b9c-4089-8e79-d1389b691...@y31g2000vbt.googlegroups..com>,
> Malcolm McLean *<malcolm.mcle...@btinternet.com> wrote:
>
>
>
>
>
> > On Sep 13, 3:19pm, blm...@myrealbox.com <blm...@myrealbox.com> wrote:
> > > In article

> > <7a961a92-cb31-46eb-afe4-db4193281...@q26g2000vbn.googlegroups.com>,
> > > Malcolm McLean <malcolm.mcle...@btinternet.com> wrote:

>
> > > > On Sep 13, 2:28pm, Pallav singh <singh.pal...@gmail.com> wrote:
> > > > > Hi ,

>
> > > > > i am trying to compile following program and getting error due to
> > > > > unable to include path to File "mpi.h" .

>
> > > > A standard C compiler won't compile MPI programs. You need an MPI
> > > > compiler, usually called "mpicc". It should link the MPI library
> > > > automatically.

>
> > > Are you sure you're not thinking of OpenMP rather than MPI? *In at
> > > least some implementations of MPI, mpicc is just a wrapper script
> > > that calls an underlying compiler with appropriate flags to help it
> > > find the include file (mpi.h) and libraries.

>
> > On my MPI implementation the mpicc was very fussy, rejecting C++ style
> > comments. So I would guess that it was a special compiler. I never
> > tried to dive into its internals, however.

>
> I guess that's possible, though it seems equally possible to me that
> it called a regular C compiler but passed it flags that made it reject
> C++-style comments. *I can't really imagine why someone implementing
> MPI would produce a full compiler -- I mean, the MPI API defines a set
> of library functions rather than language extensions -- but what do
> I know, right? *
>
> (What implementation was this? *I'm curious.)
>

It was running on a Beowulf. There were endless versions, for 64 bit
and 32-bit libraries. The system kept falling over because the paths
were set up incorrectly and the wrong version of mpirun was being used
with the mpi compiler, or likewise.

Whilst I agree that someone wouldn't write a compiler from scratch
just to compile MPI, they might have patched a compiler to get rid of
some of the problems, such as IO not working normally any more.
 
Reply With Quote
 
blmblm@myrealbox.com
Guest
Posts: n/a
 
      09-13-2010
In article <cf1a10df-04a2-4ec6-b2d4->,
Malcolm McLean <> wrote:
> On Sep 13, 4:53pm, blm...@myrealbox.com <blm...@myrealbox.com> wrote:
> > In article

> <98dda78b-6b9c-4089-8e79-d1389b691...@y31g2000vbt.googlegroups.com>,
> > Malcolm McLean <malcolm.mcle...@btinternet.com> wrote:
> >
> > > On Sep 13, 3:19pm, blm...@myrealbox.com <blm...@myrealbox.com> wrote:


[ snip ]

> > > On my MPI implementation the mpicc was very fussy, rejecting C++ style
> > > comments. So I would guess that it was a special compiler. I never
> > > tried to dive into its internals, however.

> >
> > I guess that's possible, though it seems equally possible to me that
> > it called a regular C compiler but passed it flags that made it reject
> > C++-style comments. I can't really imagine why someone implementing
> > MPI would produce a full compiler -- I mean, the MPI API defines a set
> > of library functions rather than language extensions -- but what do
> > I know, right?
> >
> > (What implementation was this? I'm curious.)
> >

> It was running on a Beowulf. There were endless versions, for 64 bit
> and 32-bit libraries. The system kept falling over because the paths
> were set up incorrectly and the wrong version of mpirun was being used
> with the mpi compiler, or likewise.


Sounds very irritating. So this was a heterogeneous cluster? I don't
have any real experience with those -- in theory MPI is supposed to be
able to deal with them, but in practice, well, we know the difference
between theory and practice, right?

> Whilst I agree that someone wouldn't write a compiler from scratch
> just to compile MPI, they might have patched a compiler to get rid of
> some of the problems, such as IO not working normally any more.


Define "normally" . (I/O does get a little potentially
strange when a "program" consists of multiple processes running on
different computers that don't share access to a terminal window
and indeed may not even have access to a shared filesystem.)

I guess it's possible, though it seems like making stdout/stderr
do something sensible would be something one would address in a
runtime system rather than in the compiler. But you used this
system and I didn't ....

I think I'm drifting further and further off topic, here, though.

--
B. L. Massingill
ObDisclaimer: I don't speak for my employers; they return the favor.
 
Reply With Quote
 
Malcolm McLean
Guest
Posts: n/a
 
      09-13-2010
On Sep 13, 6:36*pm, blm...@myrealbox.com <blm...@myrealbox.com> wrote:
>
> I guess it's possible, though it seems like making stdout/stderr
> do something sensible would be something one would address in a
> runtime system rather than in the compiler. *But you used this
> system and I didn't ....
>

I never delved into the system's internals. But all the standard
output was scooped up by the runtime system and mixed together, so
effectively you could only call printf() from the root node. If you
had any bugs things got very strange. Sometimes it would report that a
node had failed, but only if you were lucky. Usually it tended to get
tangled up in a web of unresolved messages, and the program output
would be of no help - the output log didn't relect the point the
program had reached, at all. Whilst they could have done everything by
rewriting the standard library, I suspect there were compiler patches
to ease things along, maybe inserting calls to the output scavenger,
or something like that.







 
Reply With Quote
 
Seebs
Guest
Posts: n/a
 
      09-13-2010
On 2010-09-13, Pallav singh <> wrote:
> Hi ,
>
> i am trying to compile following program and getting error due to
> unable to include
> path to File "mpi.h" . Is it provided under Linux kernel or we need to
> download library for this


This is largely non-topical, but:

> #include "mpi.h"


That it's in "" rather than <> suggests that this file was supposed to
be provided with or as part of whatever source you got the program from.

That's the sum total of C-related answers you can get. My guess is that
you are very deeply confused, because you seem to think that what appears
to be a normal userspace library thing should be "provided under Linux
kernel". That's nonsensical.

-s
--
Copyright 2010, all wrongs reversed. Peter Seebach / usenet-
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
MPI and Pthread Pallav singh C++ 1 09-13-2010 02:03 PM
GNU GMP and MPI hector C Programming 4 03-20-2008 04:36 PM
parallel programming using MPI and C++ aaragon C++ 1 08-29-2007 01:56 AM
MPI and python+threads on IRIX Marc Poinot Python 0 01-21-2005 04:09 PM
pyMPI and calling MPI functions using Boost.Python Natsu Mizutani Python 0 02-20-2004 10:17 PM



Advertisments