CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

Please help me about MPI and c++

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 21, 2010, 10:26
Default Please help me about MPI and c++
  #1
Member
 
Join Date: Mar 2009
Posts: 43
Rep Power: 17
gholamghar is on a distinguished road
Hello
I am a total beginner in parallel programming and I have the simplest C++ code which prints "Hello World" message.this is what i did in order to run my code: I have windows xp,microsoft visual studio 2008,then i installed MPICH2 and then opened my C++ code and went to properties and added "...\MPICH2\include" and "...\MPICH2\lib" and "...\MPICH2\lib\mpi.lib" to my code. then i compiled it and it was comiled with no errors,then i pressed "Ctrl+F5" (in Microsoft Visual studio 2008 it runs the program) and the output i got was:

node 0: Hello, world
Press any key to continue . . .

But it seems parallel codes should not be ran in the way i did and i should use "mpirun" so that i get a message like this:

node 0: Hello, world
node 1: Hello, world
node 2: Hello, world
node 3: Hello, world
Press any key to continue . . .

and all my 4 cpu cores are used,but i have no idea how and where i should use mpirun, some guy told me i should go to command prompt but as i told i have no idea how i should use mpirun,Please help me about this problem.
Thanks in advance
gholamghar is offline   Reply With Quote

Old   July 30, 2010, 12:32
Default
  #2
New Member
 
MT
Join Date: Mar 2010
Location: USA
Posts: 20
Rep Power: 16
MechE is on a distinguished road
I would first make sure you are compiling with the mpi command. I think the command is mpicc in for c programs and mpicpp for c++ programs. you must run the code using mpirun in order for it to run within more than one core. I run my code on linux systems with mpi installed and run the code from the terminal:

ie: $: mpirun name_of_program.x
MechE is offline   Reply With Quote

Old   August 1, 2010, 09:00
Default Mpich2
  #3
Super Moderator
 
Hans Bihs
Join Date: Jun 2009
Location: Trondheim, Norway
Posts: 377
Rep Power: 17
valgrinda is on a distinguished road
Hei,

There is nothing wrong with the way your compile your program, but in the way you execute it. First of all, since you use MPICH on a Windows machine, the command is not 'mpirun', but 'mpiexec'.
Also 'C:\Program Files\MPICH2\bin' needs to be in the PATH environment variable, so that the location of the excutable 'mpiexec.exe' is known to your system. If you have problems with this, you can also put your compiled program into MPICH's bin folder. Then you can use the DOS command window and start it from there.


Regards
Hans
valgrinda is offline   Reply With Quote

Old   August 1, 2010, 10:45
Default
  #4
Member
 
Join Date: Mar 2009
Posts: 43
Rep Power: 17
gholamghar is on a distinguished road
Thank you valgrinda it helped a lot.Thank you MechE too.
gholamghar is offline   Reply With Quote

Reply


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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with MPI? cwang5 OpenFOAM Running, Solving & CFD 3 July 12, 2010 10:38
Error using LaunderGibsonRSTM on SGI ALTIX 4700 jaswi OpenFOAM 2 April 29, 2008 10:54
Is Testsuite on the way or not lakeat OpenFOAM Installation 6 April 28, 2008 11:12
Fluent PARALLEL & MPI Luca FLUENT 0 May 13, 2006 03:04
MPI and parallel computation Wang Main CFD Forum 7 April 15, 2004 11:25


All times are GMT -4. The time now is 14:50.