HavoqGT
transfer_graph.cpp File Reference
#include <time.h>
#include <fstream>
#include <sstream>
#include <iostream>
#include <havoqgt/mpi.hpp>
#include <sys/mman.h>
Include dependency graph for transfer_graph.cpp:

Go to the source code of this file.

Functions

void execute_command (int backup, std::string fname_input, std::string fname_output)
 
int main (int argc, char **argv)
 

Variables

const bool verbose = false
 
const int processes_per_node = 24
 
const int node_partions = 8
 

Function Documentation

void execute_command ( int  backup,
std::string  fname_input,
std::string  fname_output 
)

Definition at line 91 of file transfer_graph.cpp.

92  {
93 
94  std::string tar_str;
95  if (verbose)
96  std::cout << "Restoring File:";
97 
98  tar_str = "cp " + fname_input + " " + fname_output;
99 
100  if (verbose)
101  std::cout << "Source = '" << fname_input.c_str() << "' "
102  << "Destination = '" << fname_output.c_str() << "'" << std::endl
103  << "Command = '" << tar_str.c_str() << "'" << std::endl;
104 
105  system(tar_str.c_str());
106  std::cout << std::flush;
107 
108 }; // execute_command;
const bool verbose

Here is the caller graph for this function:

int main ( int  argc,
char **  argv 
)

Definition at line 17 of file transfer_graph.cpp.

17  {
18  int mpi_rank(0), mpi_size(0);
19  CHK_MPI(MPI_Init(&argc, &argv));
20  CHK_MPI( MPI_Comm_rank( MPI_COMM_WORLD, &mpi_rank) );
21  CHK_MPI( MPI_Comm_size( MPI_COMM_WORLD, &mpi_size) );
22 
23  int backup;
24  std::string fname_input;
25  std::string fname_output;
26 
27  int pos = 1;
28  if (argc == 3) {
29  fname_input = argv[pos++];
30  fname_output = argv[pos++];
31 
32  } else {
33  if (mpi_rank == 0) {
34  std::cout << "Parameter Error: <input_file> <output_file>" << std::endl;
35  }
36  return -1;
37  }
38 
39  if (mpi_rank == 0) {
40  std::cout << "Restoring File:";
41  std::cout << "Source = '" << fname_input.c_str() << std::endl;
42  std::cout << "Dest = '" << fname_output.c_str() << std::endl;
43  }
44 
45  fname_input += "_" + std::to_string(mpi_rank);
46  {
47  std::ifstream fin(fname_input);
48  bool is_good = fin.good();
49  fin.close();
50  if (!is_good) {
51  std::cout << "[" << mpi_rank << "] File not found: " << fname_input
52  << "." << std::endl;
53  return -1;
54  }
55  }
56 
57  bool hit = false;
58  for (int i = 0; i < node_partions; i++) {
59  if (mpi_rank == 0) {
60  const int lower_bound = (i)*(processes_per_node/node_partions);
61  const int upper_bound = (i+1)*(processes_per_node/node_partions)-1;
62 
63  std::cout << "***(" << i << "/" << node_partions << ") Processes: "
64  << lower_bound << " - " << upper_bound
65  << " executing on each node." << std::endl;
66  }
67  if ((mpi_rank % processes_per_node) % node_partions == i){
68  if (hit) {
69  std::cout << "[" << mpi_rank
70  << "] error: attempting to backup/restor twice." << std::endl;
71  exit(-1);
72  } else {
73  hit = true;
74  if (verbose)
75  std::cout << "[" << mpi_rank << "]";
76  execute_command(backup, fname_input, fname_output);
77  }
78 
79  }
80  MPI_Barrier(MPI_COMM_WORLD);
81  }
82 
83  MPI_Barrier(MPI_COMM_WORLD);
84  if (mpi_rank == 0)
85  std::cout << "Transfer Graph Fin." << std::endl;
86  MPI_Finalize();
87  return 0;
88 
89 };
void execute_command(int backup, std::string fname_input, std::string fname_output)
const int node_partions
const int processes_per_node
#define CHK_MPI(a)
Definition: mpi.hpp:68
const bool verbose

Here is the call graph for this function:

Variable Documentation

const int node_partions = 8

Definition at line 12 of file transfer_graph.cpp.

const int processes_per_node = 24

Definition at line 11 of file transfer_graph.cpp.

const bool verbose = false

Definition at line 9 of file transfer_graph.cpp.