MPI+C++版helloworld
时间: 2023-10-22 13:09:15 浏览: 127
MPI_hello_world.zip_use mpi_world
好的,以下是MPI+C++版helloworld的代码:
```c++
#include <mpi.h>
#include <iostream>
int main(int argc, char** argv) {
MPI_Init(&argc, &argv);
int rank, size;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
std::cout << "Hello world from process " << rank << " of " << size << std::endl;
MPI_Finalize();
return 0;
}
```
阅读全文