#include "G4MPIutils.hh"
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <assert.h>
#include <utility>
#include "globals.hh"
Go to the source code of this file.
int _testMe |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 93 of file G4MPIutils.cc.
94 using namespace G4mpi;
95 unsigned int worldSize = 10;
96 if ( argc > 1 ) worldSize = atoi(argv[1]);
97 unsigned int myRank = worldSize-1;
98 if ( argc > 2 ) myRank = atoi(argv[2]);
99 std::cout<<
"World size: "<<worldSize<<std::endl;
101 assert( myRank < worldSize);
104 std::cout<<
"MPI_Receive from: "<<
s<<
" to "<<r<<std::endl;
108 std::cout<<
"MPI_Send from: "<<
s<<
" to "<<r<<std::endl;;
111 auto MPI_Barrier = [] {
112 std::cout<<
"MPI_Barrier"<<std::endl;
117 std::vector<rank_t> ranks(worldSize);
118 for (
unsigned int i = 0 ; i<worldSize ; ++i ) {
120 { ranks.push_back(i);
127 ranks.erase( std::unique(ranks.begin(),ranks.end()),ranks.end());
130 if ( ranks.size() == 1 ) {
131 std::cout<<
"only one rank, nothing to do"<<std::endl;
135 assert( ranks.size() == 1 && ranks[0] == 0 );
137 std::cout<<
"Communiction Map (size: "<<comms.size()<<
"):"<<std::endl;
138 for (
const auto&
x : comms ) {
139 std::cout<<
"Cycle "<<
x.first<<
": ";
140 for (
const auto& y :
x.second ) {
141 std::cout<<y.first<<
"->"<<y.second<<
", ";
143 std::cout<<std::endl;
146 std::cout<<
"Simulate communication pattern for rank: "<<myRank<<std::endl;
147 for (
const auto&
x: comms ) {
148 std::cout<<
"Cycle "<<
x.first<<std::endl;
149 for (
const auto& y :
x.second ) {
150 if ( myRank == y.first ) {
MPI_Send(y.first,y.second); }
151 else if ( myRank == y.second ) { MPI_Receive(y.first,y.second); }
commMap_t buildCommunicationMap(std::vector< rank_t > &input)
int MPI_Send(const void *, int, MPI_Datatype, int, int, MPI_Comm)