Intel® MPI Library
Get help with building, analyzing, optimizing, and scaling high-performance computing (HPC) applications.

mpirun issue

karamiag
Beginner
1,152 Views

Hello everybody,

I have just installed oneapi 2021.1 and I had no problems in compiling and executing this C source

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

int main(int argc, char** argv)
{
MPI_Init(NULL,NULL);
int world_size;
MPI_Comm_size(MPI_COMM_WORLD, &world_size);

int world_rank;
MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);

char processor_name[MPI_MAX_PROCESSOR_NAME];
int name_len;
MPI_Get_processor_name(processor_name, &name_len);

printf("Hello world from processor %s, rank %d out of %d processors\n", processor_name, world_rank, world_size);
MPI_Finalize();

}

 

The compilation command is

mpiicc hello.c -o hello_mpi

The execution command is

mpirun ./hello_mpi

Even the compilation of this fortran source is ok

program greet
implicit none
include 'mpif.h'
integer my_rank
integer p
integer source
integer dest
integer tag
integer size
integer status(MPI_STATUS_SIZE)
integer ierr
character*23 message
character*10 digit_string
call MPI_Init(ierr)
call MPI_Comm_size(MPI_COMM_WORLD,p,ierr)
call MPI_Comm_rank(MPI_COMM_WORLD,my_rank,ierr)
write(*,*) my_rank,p
if (my_rank.ne.0) then
write(digit_string,FMT="(I3)") my_rank
message = 'Hello from'//achar(9)
> // digit_string // ' !'//achar(0)
dest = 0
tag = 0
write(*,*) len_trim(message)
write(*,*)message
call MPI_Send(message,len_trim(message),
> MPI_CHARACTER,dest,tag,MPI_COMM_WORLD,ierr)
else
do source=1, p-1
tag = 0
call MPI_RECV(message, 200, MPI_INTEGER,source,tag,
> MPI_COMM_WORLD,status,ierr)
write(6,FMT="(A)") message
write(*,*) message
enddo
end if
call MPI_FINALIZE(ierr)
stop
end

The compilation command is

mpifort -o greet.e greet.f

The problem is the execution of the command

mpirun -n 4 -ppn 1 ./greet.e

which is wrong:

0     1
0     1
0     1
0     1

Could anyone help me?

Thank you.

Labels (1)
0 Kudos
1 Solution
PrasanthD_intel
Moderator
1,126 Views

Hi Giovanni,


I ran your code in my environment with the same 2021 version oneAPI Fortran compiler.

I have changed the extension .f to .f90 and it ran fine.

Here is my output:

[pdwadasx@eln6 urgent]$ mpiifort greet.f90

[pdwadasx@eln6 urgent]$ mpirun -n 5 ./a.out

      2      5

     23

 Hello from    2    !

      0      5

      3      5

     23

 Hello from    3    !

      1      5

     23

 Hello from    1    !

      4      5

     23

 Hello from    4    !

Hello from    1    !

 Hello from    1    !

Hello from    2    !

 Hello from    2    !

Hello from    3    !

 Hello from    3    !

Hello from    4    !

 Hello from    4    !

Here i can see all the ranks getting printed in the output, unlike yours. Also, from your query, I can observe that you are using mpifort(GNU based) instead mpiifort (Intel compiler).

Let me know if doing the same solves your issue.


Regards

Prasanth


View solution in original post

2 Replies
PrasanthD_intel
Moderator
1,127 Views

Hi Giovanni,


I ran your code in my environment with the same 2021 version oneAPI Fortran compiler.

I have changed the extension .f to .f90 and it ran fine.

Here is my output:

[pdwadasx@eln6 urgent]$ mpiifort greet.f90

[pdwadasx@eln6 urgent]$ mpirun -n 5 ./a.out

      2      5

     23

 Hello from    2    !

      0      5

      3      5

     23

 Hello from    3    !

      1      5

     23

 Hello from    1    !

      4      5

     23

 Hello from    4    !

Hello from    1    !

 Hello from    1    !

Hello from    2    !

 Hello from    2    !

Hello from    3    !

 Hello from    3    !

Hello from    4    !

 Hello from    4    !

Here i can see all the ranks getting printed in the output, unlike yours. Also, from your query, I can observe that you are using mpifort(GNU based) instead mpiifort (Intel compiler).

Let me know if doing the same solves your issue.


Regards

Prasanth


PrasanthD_intel
Moderator
1,111 Views

Hi Giovanni,

Thanks for the confirmation.

As the issue has been resolved, we will no longer respond to this thread. If you require additional assistance from Intel, please start a new thread. Any further interaction in this thread will be considered community only.

 

Regards

Prasanth

0 Kudos
Reply