Reputation: 1
hello i'm using windows and i use both codeblock & visual studio 2019 to programm using mpi. but after i use this code
int main(int argc, char *argv[])
{
int rank, size;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
printf("Hello world! I am %d of %d\n", rank, size);
MPI_Finalize();
return 0;
}
it return me 1 processor while if use echo %NUMBER_OF_PROCESSORS% on normal cmd it return me 4 .
i was using MPI_SEND & MPI_Recv and i had a A FATAL ERROR AFTER USING THIS CODE
#include <stdio.h>
#include "mpi.h"
int main(int argc, char* argv[])
{
int menum, nproc;
int n, tag, num;
MPI_Status info;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &menum);
MPI_Comm_size(MPI_COMM_WORLD, &nproc);
printf("menum:%d nproc :%d", menum, nproc);
if (menum == 0) {
printf("\ninsert number: ");
scanf_s(" %d", &n);
tag = 10;
MPI_Send(&n, 1, MPI_INT, 1, tag, MPI_COMM_WORLD);
}
else {
tag = 10;
MPI_Recv(&n, 1, MPI_INT, 0, tag, MPI_COMM_WORLD, &info);
}
MPI_Get_count(&info, MPI_INT, &num);
MPI_Finalize();
return 0;
}
i searched online and as i could understand it's like mpi cant find another processor to send the value. how can i make it?? is there a way i could use mpi with all my processor with visual studio or codeblock?
job aborted: [ranks] message
[0] fatal error Fatal error in MPI_Send: Invalid rank, error stack: MPI_Send(buf=0x0056F9F0, count=1, MPI_INT, dest=1, tag=10, MPI_COMM_WORLD) failed Invalid rank has value 1 but must be nonnegative and less than 1
Upvotes: 0
Views: 356
Reputation: 5223
If you write an MPI program and just execute it directly you get what's called singleton init
-- The MPI library will start itself up and you get one process in MPI_COMM_WORLD
.
To launch a parallel MPI program on Windows, you'll need to consult your MPI implementation. For MS-MPI, you will use the HPC Job Manager
(https://learn.microsoft.com/en-us/powershell/high-performance-computing/overview?view=hpc19-ps) .
For Intel-MPI you go through a similar process constructing a host file and registering your windows credentials with each machine (https://software.intel.com/content/www/us/en/develop/documentation/mpi-developer-guide-windows/top.htm)
I don't have any experience with MPI on Windows machines so this is as much help as I can give you. Hope it gets you pointed in the right direction.
Upvotes: 1