Discussion:
Running MPI on a single node
(too old to reply)
l***@yahoo.com
2008-08-13 01:57:24 UTC
Permalink
Hi,

I have a few questions regarding running MPI on just one node.

If I used "mpiexec -n 3 ./a.out", does it create 3 threads and run
them independently as if there are 3 nodes? Are the variables all
shared, unlike when there's actually 3 nodes and the variables are
local and can be written without affecting variables of the same name
in another node?

If I have MPI functions like MPI_Send and MPI_Recv, does the node
actually try to simulate the sending/receiving of data? Is that data
shared or local?

I tried a program that does the following. It simulates 5 nodes when
there is really only 1:

I have declared a variable i, and it's equal to the value of rank, and
I do a sum reduction. I get the correct value 0 + 1 + 2 + 3 + 4 = 10
Then I send i from "Node" 1,2,3,4 to "Node" 0, explicitly calculate
the sum and get 10.
Now I do a sum reduction again and this time, I got the result 14,
which is 10 + (the last value of i, 4). Why is the last value of i
kept?

Thank you.

Regards,
Rayne
Michael Hofmann
2008-08-13 07:24:51 UTC
Permalink
Post by l***@yahoo.com
If I used "mpiexec -n 3 ./a.out", does it create 3 threads and run
them independently as if there are 3 nodes? Are the variables all
shared, unlike when there's actually 3 nodes and the variables are
local and can be written without affecting variables of the same name
in another node?
It creates 3 _processes_ (each process may have a "main-thread") and there
are _no_ shared variables.
Post by l***@yahoo.com
If I have MPI functions like MPI_Send and MPI_Recv, does the node
actually try to simulate the sending/receiving of data? Is that data
shared or local?
There is no need to simulate anything. MPI is _distributed_ memory
parallel programming. Depending on the interconnection between the nodes,
MPI chooses an appropriate communication channel. The usage of
MPI_Send/MPI_Recv is completely independent from the channel. However, on
a single node, the channel can be a shared memory region (data is copied
from send buffer to shared memory + from shared memory to receive buffer).
Post by l***@yahoo.com
I tried a program that does the following. It simulates 5 nodes when
I have declared a variable i, and it's equal to the value of rank, and
I do a sum reduction. I get the correct value 0 + 1 + 2 + 3 + 4 = 10
Then I send i from "Node" 1,2,3,4 to "Node" 0, explicitly calculate
the sum and get 10.
Now I do a sum reduction again and this time, I got the result 14,
which is 10 + (the last value of i, 4). Why is the last value of i
kept?
Because there is something wrong in your program.


Michael
l***@yahoo.com
2008-08-13 08:31:38 UTC
Permalink
Post by Michael Hofmann
Post by l***@yahoo.com
If I used "mpiexec -n 3 ./a.out", does it create 3 threads and run
them independently as if there are 3 nodes? Are the variables all
shared, unlike when there's actually 3 nodes and the variables are
local and can be written without affecting variables of the same name
in another node?
It creates 3 _processes_ (each process may have a "main-thread") and there
are _no_ shared variables.
Post by l***@yahoo.com
If I have MPI functions like MPI_Send and MPI_Recv, does the node
actually try to simulate the sending/receiving of data? Is that data
shared or local?
There is no need to simulate anything. MPI is _distributed_ memory
parallel programming. Depending on the interconnection between the nodes,
MPI chooses an appropriate communication channel. The usage of
MPI_Send/MPI_Recv is completely independent from the channel. However, on
a single node, the channel can be a shared memory region (data is copied
from send buffer to shared memory + from shared memory to receive buffer).
Michael
So even when the variables in the various processes have the same
name, the variables are stored in separate areas of the memory on the
single node?

Also, the program on the single node would run just as if there were
multiple nodes, i.e. give the same results?

Regards,
Rayne
Michael Hofmann
2008-08-13 08:58:52 UTC
Permalink
Post by l***@yahoo.com
So even when the variables in the various processes have the same
name, the variables are stored in separate areas of the memory on the
single node?
Yes.
Post by l***@yahoo.com
Also, the program on the single node would run just as if there were
multiple nodes, i.e. give the same results?
Basically, yes (if the program is correct, if the program behavior is
clearly determined, if the results are independent from the properties of
nodes).


Michael
Dave Seaman
2008-08-13 13:34:28 UTC
Permalink
Post by l***@yahoo.com
Post by Michael Hofmann
Post by l***@yahoo.com
If I used "mpiexec -n 3 ./a.out", does it create 3 threads and run
them independently as if there are 3 nodes? Are the variables all
shared, unlike when there's actually 3 nodes and the variables are
local and can be written without affecting variables of the same name
in another node?
It creates 3 _processes_ (each process may have a "main-thread") and there
are _no_ shared variables.
Post by l***@yahoo.com
If I have MPI functions like MPI_Send and MPI_Recv, does the node
actually try to simulate the sending/receiving of data? Is that data
shared or local?
There is no need to simulate anything. MPI is _distributed_ memory
parallel programming. Depending on the interconnection between the nodes,
MPI chooses an appropriate communication channel. The usage of
MPI_Send/MPI_Recv is completely independent from the channel. However, on
a single node, the channel can be a shared memory region (data is copied
from send buffer to shared memory + from shared memory to receive buffer).
Michael
So even when the variables in the various processes have the same
name, the variables are stored in separate areas of the memory on the
single node?
Also, the program on the single node would run just as if there were
multiple nodes, i.e. give the same results?
Even on a single node, an MPI job can make use of multiple processor
cores, if your computer has them. Otherwise, your operating system will
need to schedule multiple processes to run sequentially on a single CPU.
Each process has its own memory image and its own variables.
--
Dave Seaman
Third Circuit ignores precedent in Mumia Abu-Jamal ruling.
<http://www.indybay.org/newsitems/2008/03/29/18489281.php>
l***@yahoo.com
2008-08-14 00:33:40 UTC
Permalink
Post by Dave Seaman
Even on a single node, an MPI job can make use of multiple processor
cores, if your computer has them. Otherwise, your operating system will
need to schedule multiple processes to run sequentially on a single CPU.
Each process has its own memory image and its own variables.
--
Dave Seaman
Third Circuit ignores precedent in Mumia Abu-Jamal ruling.
<http://www.indybay.org/newsitems/2008/03/29/18489281.php>
Does the computer automatically make use of its multiple processor
cores, or do I have to specify it somewhere?

Also, say I have 5 nodes, and I run a MPI program using "-n 5", does
it mean one process is created in each of the 5 nodes? If I have 3
nodes and I run the program using "-n 5", does the local computer
create the additional 2 processes, or any of the 3 nodes can create
the extra 2 processes?

Regards,
Rayne
Dave Seaman
2008-08-14 12:06:22 UTC
Permalink
Post by l***@yahoo.com
Post by Dave Seaman
Even on a single node, an MPI job can make use of multiple processor
cores, if your computer has them. Otherwise, your operating system will
need to schedule multiple processes to run sequentially on a single CPU.
Each process has its own memory image and its own variables.
Does the computer automatically make use of its multiple processor
cores, or do I have to specify it somewhere?
If you start your MPI program with multiple processes, it is up to the
operating system to assign those processes to the available processor cores.
Modern operating systems can do this automatically.
Post by l***@yahoo.com
Also, say I have 5 nodes, and I run a MPI program using "-n 5", does
it mean one process is created in each of the 5 nodes? If I have 3
nodes and I run the program using "-n 5", does the local computer
create the additional 2 processes, or any of the 3 nodes can create
the extra 2 processes?
That depends on the MPI impleemntation, but usually you specify a file
that contains the hostnames on which the MPI processes are to be run.
You can list the same hostname more than once, and it makes sense to do
that if it has multiple cores.
--
Dave Seaman
Third Circuit ignores precedent in Mumia Abu-Jamal ruling.
<http://www.indybay.org/newsitems/2008/03/29/18489281.php>
Loading...