Reputation: 75
I have a simple MPI application that is used to pass values from process 0 to other processes upon entering the desired value but it is triggering a breakpoint on "else".
What am I missing?
#include "stdafx.h"
#include "mpi.h"
#include "stdio.h"
#include "stdlib.h"
int main(int argc, char* argv[])
{
int rank;
int value;
int size;
MPI_Status status;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
do
{
if (rank == 0)
{
printf("Enter the value: ");
scanf_s("%d", &value);
MPI_Send(&value, 1, MPI_INT, rank + 1, 0, MPI_COMM_WORLD);
}
else
{
MPI_Recv(&value, 1, MPI_INT, rank - 1, 0, MPI_COMM_WORLD,
&status);
if (rank < size - 1)
MPI_Send(&value, 1, MPI_INT, rank + 1, 0, MPI_COMM_WORLD);
}
printf("Process %d got %d ", rank, value);
} while (value >= 0);
MPI_Finalize();
return 0;
}
This is output from debug:
'MPIHelloWorld.exe' (Win32): Loaded 'C:\WINDOWS\SysWOW64\KernelBase.dll'. Cannot find or open the PDB file.
'MPIHelloWorld.exe' (Win32): Loaded 'C:\WINDOWS\SysWOW64\gdi32.dll'. Cannot find or open the PDB file.
'MPIHelloWorld.exe' (Win32): Loaded 'C:\Program Files (x86)\Bonjour\mdnsNSP.dll'. Cannot find or open the PDB file.
MPIHelloWorld.exe has triggered a breakpoint.
MPIHelloWorld.exe has triggered a breakpoint.
The thread 0x3308 has exited with code 0 (0x0).
The thread 0x1dfc has exited with code 0 (0x0).
The thread 0x2e5c has exited with code 0 (0x0).
The program '[4400] MPIHelloWorld.exe' has exited with code 0 (0x0).
UPDATE:
When I press CTRL + 5 I get this error written in my console:
job aborted: [ ranks ] message
[0] fatal error Fatal error in MPI_Send: Invalid rank has value 1 but must be nonnegative and less than 1
Upvotes: 0
Views: 1181
Reputation: 75
Ok, I have finally found an answer!
I couldn't use Cluster Debugger for MPI since I am running Visual Studio 2015 and the problem was that only 1 process was running.
I opened CMD and ran my application using "mpiexec.exe -n 4 myMpiApp.exe" and it worked.
Upvotes: 3