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

Running an MPI Fortran program within visual studio 2019

galli_m
New Contributor I
3,182 Views


I ran the following FORTRAN program in command prompt....

cccccccccccccc PROGRAM ccccccccccccccc

program mpi7

IMPLICIT DOUBLE PRECISION (A-H,O-Z)

parameter (ms=10,mp=12) ! array has 10 entries for each of the 12 processors

dimension ar(ms,mp)

include 'mpif.h'
integer status(MPI_STATUS_SIZE)
call mpi_init(ierr)
call mpi_comm_rank(MPI_COMM_WORLD,my_rank,ierr)
call mpi_comm_size(MPI_COMM_WORLD,nsize,ierr)

if (my_rank.eq.0) then

ccccccccc CALCULATIONS cccccccccccc
part=12.0d0
calc=part+100.0d0
do 20 i=1,ms
ar(i,mp)=calc
20 continue
ccccccccc CALCULATIONS cccccccccccc

do 30 nproc=1,nsize-1
do 30 i=1,ms
call mpi_recv(ar(i,nproc),1,MPI_DOUBLE_PRECISION,nproc,1,
* MPI_COMM_WORLD,status,ierr)
30 continue

else

ccccccccc CALCULATIONS cccccccccccc
part=dble(my_rank)
calc=part+100.0d0

do 40 i=1,ms
ar(i,my_rank)=calc
40 continue
ccccccccc CALCULATIONS cccccccccccc

do 45 i=1,ms
call mpi_send(ar(i,my_rank),1,MPI_DOUBLE_PRECISION,0,1,
* MPI_COMM_WORLD,ierr)
45 continue

endif

if (my_rank.eq.0) then

do 50 j=1,nsize
write(*,*) j,ar(1,j),ar(ms,j)
50 continue

write(*,*) ' '
do 60 i=1,ms
write(*,*) i,ar(i,nsize)
60 continue

endif

call mpi_finalize(ierr)

end

cccccccccccccc PROGRAM ccccccccccccccc

I had no difficulties compiling and executing the program....

cccccccccccc COMPILING and EXECUTION cccccccccccccccc

F:\MPI>c

F:\MPI>mpif77 mpi7.f
mpifc.bat for the Intel(R) MPI Library 2021.2 for Windows*
Copyright 2007-2021 Intel Corporation.

Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.2.0 Build 20210228_000000
Copyright (C) 1985-2021 Intel Corporation. All rights reserved.

Microsoft (R) Incremental Linker Version 14.28.29914.0
Copyright (C) Microsoft Corporation. All rights reserved.

-out:mpi7.exe
-subsystem:console
"/LIBPATH:C:\Program Files (x86)\Intel\oneAPI\mpi\latest\env\..\lib\release"
"/LIBPATH:C:\Program Files (x86)\Intel\oneAPI\mpi\latest\env\..\lib"
impi.lib
mpi7.obj
F:\MPI>r

F:\MPI>mpiexec -np 12 mpi7
1 101.000000000000 101.000000000000
2 102.000000000000 102.000000000000
3 103.000000000000 103.000000000000
4 104.000000000000 104.000000000000
5 105.000000000000 105.000000000000
6 106.000000000000 106.000000000000
7 107.000000000000 107.000000000000
8 108.000000000000 108.000000000000
9 109.000000000000 109.000000000000
10 110.000000000000 110.000000000000
11 111.000000000000 111.000000000000
12 112.000000000000 112.000000000000

1 112.000000000000
2 112.000000000000
3 112.000000000000
4 112.000000000000
5 112.000000000000
6 112.000000000000
7 112.000000000000
8 112.000000000000
9 112.000000000000
10 112.000000000000

F:\MPI>

cccccccccccc COMPILING and EXECUTION cccccccccccccccc

I am now trying to do the same within Microsoft Visual Studio (Community 2019
Version 16.9.4)

Configured as follows.....

Configuration Properties : configuration 'Active(Debug)' ; platform 'x64'

Debugging>Command...
c:\program files (x86)\intel\oneapi\mpi\2021.2.0\bin\mpiexec.exe

Debugging>Command arguments...
-np 12

Debugging>Environment...
PATH=C:\Program Files (x86)\Intel\oneAPI\mpi\2021.2.0\bin$C:\Program Files (x86)\Intel\oneAPI\mpi\2021.2.0\libfabric\bin

Fortran>Additional Include Directories....
C:\Program Files (x86)\Intel\oneAPI\mpi\2021.2.0\include

Linker>Additional Library Directories....
C:\Program Files (x86)\Intel\oneAPI\mpi\2021.2.0\lib

Linker>Input>Additional Dependancies....
C:\Program Files (x86)\Intel\oneAPI\mpi\2021.2.0\lib\debug\impi.lib

 

When I Build Solution.....I get...

fatal error LNK1181: cannot open input file 'C:\Program.obj'

Where did I go wrong??? There is likely multiple errors here...

My apologies for the extended detail. (I hope it helps)

0 Kudos
1 Solution
AbhishekD_Intel
Moderator
3,103 Views

Hi Mike,


Thanks for the details.

Please check if the impi.dll is present in the installed oneAPI directory. You can refer to the below path:

Intel\oneAPI\mpi\2021.2.0\bin\debug for the presence of impi.dll.

If the file is not present then, please reinstall the latest oneAPI Basekit and HPCkit.

If the file is present in the directory then try adding the below lines in Project Properties -> Configuration Properties -> Build Events -> Post Build Event -> Command Line option.


copy /Y "$(I_MPI_ONEAPI_ROOT)\bin\debug\impi.dll" "$(TargetDir)"

copy /Y "$(I_MPI_ONEAPI_ROOT)\libfabric\bin\libfabric.dll" "$(TargetDir)"


And try re-building and debugging your project. Let us know if are still getting the same issue.

Hope the provided details will help you to resolve your issue.



Warm Regards,

Abhishek


View solution in original post

0 Kudos
5 Replies
AbhishekD_Intel
Moderator
3,156 Views

Hi Mike,

 

Thanks for reaching out to us.

Please check the attached visual studio configuration file. We tried the code with the same configuration(attached) and it's working for us on VS we also tried it through the command line and it's compiling and executing without any errors.

Please try using the same configuration for your project and let us know if you get any issues.

 

 

Warm Regards,

Abhishek

 

0 Kudos
galli_m
New Contributor I
3,141 Views

Thank you for your reply,

I have dissected the configuration you sent me.

I am again including details for a variety of reasons,
including for the benefit to others that may require
this information.

From what I gathered, this is the current configuration:
I put this in myself in a new project...


In configuration properties:

>Fortran>Additional Include Directories:

$(I_MPI_ONEAPI_ROOT)\include

>Linker>Additional Library Directories:

$(I_MPI_ONEAPI_ROOT)\lib\debug;$(I_MPI_ONEAPI_ROOT)\lib\

>Linker>Input>Additional Dependancies:

impi.lib libmpi_ilp64.lib


I build the solution and got my executable file.
Thank You!

I ran this file in the appropriate command prompt
and had no difficulties running the program.

I then tried running this within Visual Studio...
Debug>Start Without Debugging

I get a system error when the command prompt opens...
"The code execution cannot proceed because
impi.dll was not found"

There is something still missing....
It appears to not open into an appropriate
command prompt environment???

Thanks again

0 Kudos
AbhishekD_Intel
Moderator
3,104 Views

Hi Mike,


Thanks for the details.

Please check if the impi.dll is present in the installed oneAPI directory. You can refer to the below path:

Intel\oneAPI\mpi\2021.2.0\bin\debug for the presence of impi.dll.

If the file is not present then, please reinstall the latest oneAPI Basekit and HPCkit.

If the file is present in the directory then try adding the below lines in Project Properties -> Configuration Properties -> Build Events -> Post Build Event -> Command Line option.


copy /Y "$(I_MPI_ONEAPI_ROOT)\bin\debug\impi.dll" "$(TargetDir)"

copy /Y "$(I_MPI_ONEAPI_ROOT)\libfabric\bin\libfabric.dll" "$(TargetDir)"


And try re-building and debugging your project. Let us know if are still getting the same issue.

Hope the provided details will help you to resolve your issue.



Warm Regards,

Abhishek


0 Kudos
galli_m
New Contributor I
3,092 Views

Thank you for your help.

impi.dll was in the appropriate directory.
I included these lines and no longer had
the system error.

However for the program to work properly
I had to add entries to Debugging>Command
and Debugging>Command Arguments.
For the potential benefit to others, here
is the final configuration to run my MPI
FORTRAN program.

Thanks again for all your help!

Configuration Properties : configuration 'Active(Debug)' ; platform 'x64'

Debugging>Command...
$(I_MPI_ONEAPI_ROOT)\bin\mpiexec.exe

Debugging>Command arguments...
-np 12 "$(TargetPath)"

Fortran>Additional Include Directories....
$(I_MPI_ONEAPI_ROOT)\include

Linker>Additional Library Directories....
$(I_MPI_ONEAPI_ROOT)\lib\debug;$(I_MPI_ONEAPI_ROOT)\lib\

Linker>Input>Additional Dependancies....
impi.lib libmpi_ilp64.lib

Build Events>Post-Build Event>Command Line....
copy /Y "$(I_MPI_ONEAPI_ROOT)\bin\debug\impi.dll" "$(TargetDir)"
copy /Y "$(I_MPI_ONEAPI_ROOT)\libfabric\bin\libfabric.dll" "$(TargetDir)"

0 Kudos
AbhishekD_Intel
Moderator
3,063 Views

Hi Mike,


Thanks for the confirmation.

We will no longer monitor this thread, as your issue is resolved.  If you require any additional assistance from Intel, please start a new thread. 

Any further interaction in this thread will be considered community only.


Warm Regards,

Abhishek


0 Kudos
Reply