~ubuntu-branches/ubuntu/quantal/ceph/quantal

« back to all changes in this revision

Viewing changes to src/test/old/testmpi.cc

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2012-07-16 09:56:24 UTC
  • mfrom: (0.3.11)
  • mto: This revision was merged to the branch mainline in revision 17.
  • Revision ID: package-import@ubuntu.com-20120716095624-azr2w4hbhei1rxmx
Tags: upstream-0.48
ImportĀ upstreamĀ versionĀ 0.48

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <sys/stat.h>
 
2
#include <iostream>
 
3
#include <string>
 
4
using namespace std;
 
5
 
 
6
#include "common/config.h"
 
7
#include "messages/MPing.h"
 
8
#include "common/Mutex.h"
 
9
 
 
10
#include "msg/MPIMessenger.h"
 
11
 
 
12
class Pinger : public Dispatcher {
 
13
public:
 
14
  Messenger *messenger;
 
15
  Pinger(Messenger *m) : messenger(m) {
 
16
    m->set_dispatcher(this);
 
17
  }
 
18
  void dispatch(Message *m) {
 
19
    //dout(1) << "got incoming " << m << endl;
 
20
    delete m;
 
21
 
 
22
  }
 
23
};
 
24
 
 
25
int main(int argc, char **argv) {
 
26
  int num = 1000;
 
27
 
 
28
  int myrank = mpimessenger_init(argc, argv);
 
29
  int world = mpimessenger_world();
 
30
  
 
31
  Pinger *p = new Pinger( new MPIMessenger(myrank) );
 
32
 
 
33
  mpimessenger_start();
 
34
 
 
35
  //while (1) {
 
36
  for (int i=0; i<10000; i++) {
 
37
    
 
38
    // ping random nodes
 
39
    int d = rand() % world;
 
40
    if (d != myrank) {
 
41
      //cout << "sending " << i << " to " << d << endl;
 
42
      p->messenger->send_message(new MPing(), d);
 
43
     }
 
44
    
 
45
  }
 
46
 
 
47
 
 
48
  //cout << "shutting down" << endl;
 
49
  //p->messenger->shutdown();
 
50
  
 
51
  mpimessenger_wait();
 
52
  mpimessenger_shutdown();  // shutdown MPI
 
53
}