Intel® Moderncode for Parallel Architectures
Support for developing parallel programming applications on Intel® Architecture.
1696 Discussions

Can I use Visual Studio to produce an executable to be run by mpiexec?

Anders_S_1
New Contributor III
2,250 Views

Hi,

I have Windows 7, Microsoft Visual Studio 2013 SDK and Intel Fortran Cluster Studio XE 2017 for Windows. As my program consists of some 400 subroutines, it seems convenient to try to compile and link my code with MPI loops after adding the MPI library reference in the compiler include section.

Can I use the executable produced by Visual Studio as an input to mpiexec?

Best regards

Anders S

0 Kudos
13 Replies
TimP
Honored Contributor III
2,250 Views

Yes

0 Kudos
Anders_S_1
New Contributor III
2,250 Views

Hi Tim,

Thank you for a prompt and positive answer!

My code is first sequential, then parallelized via MPI to speed up the calculation of a Jacobian and then finally sequential again. My PC has a maximum of 8 threads.

When I run my executable gem.exe from a folder named CALCGEM by mpiexec -n 8 gem.exe no menus show up.

Using mpiexec -localroot -n 8 gem.exe everything looks good except that the initial sequential part appears on 8 windows.

My question is now how to instruct the system in the simplest (or best) way to show the sequential parts in only one window.

The main program has a row USE MPI at the top.

Best regards

Anders S

0 Kudos
Gregg_S_Intel
Employee
2,250 Views
    int myrank;
    MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
    if (myrank == 0) { ...

 

But this sounds like a job for OpenMP, not MPI.

 

0 Kudos
Anders_S_1
New Contributor III
2,250 Views

Hi Gregg,

Thanks for a rapid respons! The reason for going to MPI is that the third party library routines do not work with OpenMP.

Just to be clear, as I am new to MPI, your command is used in the beginning of a sequential part (consisting of several hundred of subroutines)? 

At the beginning of the parallelized part I request 8 threads.

After the parallelized part I issue your command again?

Or shall each subroutine in the sequential parts have the  myrank==0 check?

Best regards

Anders S

0 Kudos
Anders_S_1
New Contributor III
2,250 Views

Hi,

I forgot to tell that my code is a QuickWin project with graphics being displayed by the sequential parts in order to monitor the numerics etc. during computation. It would be most convenient to have just one window with the graphics and the menues for data input.

Best regards

Anders S

0 Kudos
jimdempseyatthecove
Honored Contributor III
2,250 Views

What Greg was trying to tell you was to:

a) Obtain the rank number
b) conditionalize your code such that only one rank (0 in the above example) performs the QuickWin part of the application. This rank can also partake in the computation if you so desire.

Jim Dempsey

0 Kudos
Gregg_S_Intel
Employee
2,250 Views

MPI ranks do nothing sequentially -- everything is parallel.  If you want a single rank to do something and other ranks to skip it, have to say so explicitly with a conditional test for rank number.

 

0 Kudos
jimdempseyatthecove
Honored Contributor III
2,250 Views

Also note that if you do not want to use (or cannot use) conditional branch you can execute different programs by each rank:

mpiexec -localroot -n 1 GUIgem.exe : -localroot -n 7 Consolegem.exe

In the above GUIgem.exe will run as rank 0, and Consolegem.exe will run as ranks 1:7

Jim Dempsey

0 Kudos
Anders_S_1
New Contributor III
2,250 Views

Hi Jim,

Thank you for a very clarifying comment that everything is parallel; it is sometimes deceptive to try to compare with OpenMP:

If I have understood it right all rank have access to the parameters values of a calling subroutine. What needs to be communicated is the rank-dependent data. Which command is used to check that all ranks have finished their part of a computation which means it is possible to collect all results to a specific rank? In my case I use an array to collect the computation results. Each rank puts its results in rank-dependant positions in the array.

Best regards

Anders S

0 Kudos
Gregg_S_Intel
Employee
2,250 Views

MPI_Send() & MPI_Recv().

Gropp, Ewing, Lusk classic book Using MPI is an excellent introduction and reference for MPI.

 

 

 

0 Kudos
Anders_S_1
New Contributor III
2,250 Views

Hi Gregg,

Thanks for your quick answer and the literature advice!

Best regards

Anders S

0 Kudos
Anders_S_1
New Contributor III
2,250 Views

Hi,

I discovered that MPI can be run from Visual Studio after reading the document "Intel MPI Library Guide for Windows OS, February 22,1917.

It worked fine for a console application but when I tried a QuickWin application I got into trouble. No windows appeared.

Is it not possible or should something be added in the project setup?

Best regards

Anders S

0 Kudos
Anders_S_1
New Contributor III
2,250 Views

Hi Tim and Gregg,

In another case I was informed by Jim how to configure VS with MPI. I did that and produced an executable. Instead of using Ctrl+F5 to run the executable in the VS environment I ran it from the command line. That gave me breakpoint errors.

So, to conlude: Your affirmative yes is true if you run the executable by the Ctrl+F5?

Best regards

Anders S

0 Kudos
Reply