# MPICH2 on single machine

**URL:** <https://forums.developer.nvidia.com/t/mpich2-on-single-machine/131771>\
**Category:** Legacy PGI Compilers (archived)\
**Created:** [June 1, 2010, 12:58am UTC](https://forums.developer.nvidia.com/t/mpich2-on-single-machine/131771 "2010-06-01T00:58:48Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tuan](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Tuan](https://forums.developer.nvidia.com/u/Tuan)\
**Post date:** [June 1, 2010, 12:58am UTC](https://forums.developer.nvidia.com/t/mpich2-on-single-machine/131771/1 "2010-06-01T00:58:48Z")

</div>

I have a single machine with 2 CPU, each with 4 cores. May I assk how could I configure to get it work with multiple processes. I always get the following message

> mpdboot -n 4 -f ~/mpd.hosts\_cardiac  
> totalnum=4 numhosts=1  
> there are not enough hosts on which to start all processes

Thanks,  
Tuan

---

<div class="post-metadata">

**Author:** ![MatColgrove](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/matcolgrove/32/14047_2.png) [@MatColgrove](https://forums.developer.nvidia.com/u/MatColgrove)\
**Post date:** [June 1, 2010, 4:18pm UTC](https://forums.developer.nvidia.com/t/mpich2-on-single-machine/131771/2 "2010-06-01T16:18:34Z")

</div>

Hi Tuan,

What’s your “machine.LINUX” file look like? Do you list your host 8 times in it or put a “:8” after the name to let the mpdboot know you have 8 cores on this system?

- Mat

---

<div class="post-metadata">

**Author:** ![Tuan](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Tuan](https://forums.developer.nvidia.com/u/Tuan)\
**Post date:** [June 1, 2010, 5:10pm UTC](https://forums.developer.nvidia.com/t/mpich2-on-single-machine/131771/3 "2010-06-01T17:10:51Z")

</div>

> [@mkcolg](#):
>
> Hi Tuan,
> 
> What’s your “machine.LINUX” file look like? Do you list your host 8 times in it or put a “:8” after the name to let the mpdboot know you have 8 cores on this system?
> 
> - Mat

I list my hostname 8 times. I guess the mpdboot only allow each hostname to occur once.

Tuan

---

<div class="post-metadata">

**Author:** ![hongyon](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@hongyon](https://forums.developer.nvidia.com/u/hongyon)\
**Post date:** [June 1, 2010, 6:15pm UTC](https://forums.developer.nvidia.com/t/mpich2-on-single-machine/131771/4 "2010-06-01T18:15:21Z")

</div>

Hi,

For MPICH2, you need to start only one daemon per machine. Once the daemon started, then you can run multiple processes.

% mpdboot  
%mpiexec -np 2 a.out  
%mpdallexit  
  
  
  
If you have more than one machine, put all hosts in mpd.hosts and then invoke:  
%mpdboot --totalnum=3

where 3 is a number of hosts in mpd.hosts file.

% mpdtrace # test if all hosts list in mpd.hosts starts the daemon

Hongyon

---

<div class="post-metadata">

**Author:** ![Tuan](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Tuan](https://forums.developer.nvidia.com/u/Tuan)\
**Post date:** [June 2, 2010, 3:02am UTC](https://forums.developer.nvidia.com/t/mpich2-on-single-machine/131771/5 "2010-06-02T03:02:18Z")

</div>

Thanks, Hongyon.

A simple test case on a single-host cluster seem to work. However, when I add collective communication call, MPI\_Bcast. It doesn’t work. The error output is

> $mpdboot  
> minhtuan@cardiac:\ $mpiexec -n 3 ./vect  
> Time to initialize MPI is 0  
> FORTRAN STOP  
> FORTRAN STOP  
> End test  
> FORTRAN STOP  
> rank 2 in job 1 cardiac.binf\_57734 caused collective abort of all ranks  
> exit status of rank 2: return code 0  
> rank 1 in job 1 cardiac.binf\_57734 caused collective abort of all ranks  
> exit status of rank 1: return code 0  
> rank 0 in job 1 cardiac.binf\_57734 caused collective abort of all ranks  
> exit status of rank 0: return code 0

The test code is given

```plaintext
  IMPLICIT NONE
  INCLUDE 'mpif.h'
  
  
  INTEGER :: mpierror, numprocs, myrank
  DOUBLE PRECISION :: mytime, maxtime, mintime, avgtime
  INTEGER :: count0, count1, count_max, count_rate, dtime
  LOGICAL :: flag
  INTEGER :: data
  CHARACTER (MPI_MAX_ERROR_STRING+1) :: err_msg
  
  CALL MPI_Initialized(flag, mpierror)
  IF (.NOT. flag) THEN
     ! start timer
     CALL SYSTEM_CLOCK(count0, count_rate, count_max)
     CALL MPI_Init(mpierror)
     IF( mpierror .NE. MPI_SUCCESS) THEN
        PRINT *, "Error Init MPI"
        STOP
     END IF
     CALL MPI_Comm_Size(MPI_COMM_WORLD, numprocs, mpierror)
     IF( mpierror .NE. MPI_SUCCESS) THEN
        PRINT *, "Error Detect Communicator size"
        STOP
     END IF

     CALL MPI_Comm_Rank(MPI_COMM_WORLD, myrank, mpierror)
     IF( mpierror .NE. MPI_SUCCESS) THEN
        PRINT *, "Error Detect process rank"
        STOP
     END IF
     
     ! stop timer
     CALL SYSTEM_CLOCK(count1, count_rate, count_max)
     dtime = (count1-count0)/count_rate
     ! end timer
  END IF
  IF (myrank .EQ. 0) THEN
     PRINT *, "Time to initialize MPI is ", dtime
     ! initialize
     data = 1000
  ENDIF
  CALL MPI_Bcast(data, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, mpierror)
  IF( mpierror .NE. MPI_SUCCESS) THEN
     PRINT *, "Error Broadcast message"
     STOP
  END IF
  
  CALL MPI_Barrier(MPI_COMM_WORLD, mpierror)
  IF( mpierror .NE. MPI_SUCCESS) THEN
     PRINT *, "Error Barrier"
     STOP
  END IF
  
  IF (myrank .EQ. 0) THEN
     PRINT *, "End test"
  END IF
  STOP

```

Thanks,  
Tuan

---

<div class="post-metadata">

**Author:** ![hongyon](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@hongyon](https://forums.developer.nvidia.com/u/hongyon)\
**Post date:** [June 2, 2010, 3:08pm UTC](https://forums.developer.nvidia.com/t/mpich2-on-single-machine/131771/6 "2010-06-02T15:08:52Z")

</div>

Remove the last “STOP” statement from your program and add a call to MPI\_FINALIZE(some\_integer).  
  
  
Here is more information about MPI:

[http://www.mcs.anl.gov/research/projects/mpi/](http://www.mcs.anl.gov/research/projects/mpi/)  
  
  
Hongyon

---

<div class="post-metadata">

**Author:** ![Tuan](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Tuan](https://forums.developer.nvidia.com/u/Tuan)\
**Post date:** [June 3, 2010, 4:10am UTC](https://forums.developer.nvidia.com/t/mpich2-on-single-machine/131771/7 "2010-06-03T04:10:45Z")

</div>

Thanks, Hongyon. I forgot to add that in the sample code, but in the real code it does have the finalization statement.

I realize one issue, the call to flush() statement (without any argument) doesn’t work properly in MPICH2. It causes the error that I mentioned above. It works if a given device ID is passed as the input. Could you please confirm this.

Thanks,  
Tuan

---

<div class="post-metadata">

**Author:** ![hongyon](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@hongyon](https://forums.developer.nvidia.com/u/hongyon)\
**Post date:** [June 3, 2010, 6:32pm UTC](https://forums.developer.nvidia.com/t/mpich2-on-single-machine/131771/8 "2010-06-03T18:32:22Z")

</div>

Hi,

Yes, you will need to give the file unit as an argument.

Hongyon

---

<div class="post-metadata">

**Author:** ![Tuan](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Tuan](https://forums.developer.nvidia.com/u/Tuan)\
**Post date:** [June 4, 2010, 1:44am UTC](https://forums.developer.nvidia.com/t/mpich2-on-single-machine/131771/9 "2010-06-04T01:44:16Z")

</div>

thanks. Hongyon. Did you get any forwarded email from trs. Could you please check and help me to resolve my network problem when I run MPICH2 on a cluster, not a single host machine.

Tuan
