RepastHPC  2.3.1
SRManager.h
1 /*
2  *Repast for High Performance Computing (Repast HPC)
3  *
4  * Copyright (c) 2010 Argonne National Laboratory
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with
8  * or without modification, are permitted provided that the following
9  * conditions are met:
10  *
11  * Redistributions of source code must retain the above copyright notice,
12  * this list of conditions and the following disclaimer.
13  *
14  * Redistributions in binary form must reproduce the above copyright notice,
15  * this list of conditions and the following disclaimer in the documentation
16  * and/or other materials provided with the distribution.
17  *
18  * Neither the name of the Argonne National Laboratory nor the names of its
19  * contributors may be used to endorse or promote products derived from
20  * this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
25  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE TRUSTEES OR
26  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
32  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  *
34  * SRManager.h
35  *
36  * Created on: 2 Dec 2011
37  * Author: JTM
38  */
39 
40 #ifndef SRMANAGER_H_
41 #define SRMANAGER_H_
42 
43 #include <vector>
44 
45 #include <boost/mpi/communicator.hpp>
46 
52 class SRManager{
53 
54 private:
55  boost::mpi::communicator* _comm;
56  int *send;
57  int *recv;
58  int *mySend;
59  int *myRecv;
60 
61 public:
67  SRManager(boost::mpi::communicator* comm);
68 
84  SRManager(boost::mpi::communicator* comm, int* toSend, int* toRecv);
85 
86  ~SRManager();
87 
94  void mark(int pos);
95 
103  void setVal(int pos, int val);
104 
108  inline void clear();
109 
114  void retrieveSources();
115 
116 
125  void retrieveSources(std::vector<int>& sources);
126 
141  void retrieveSources(const std::vector<int>& targets, std::vector<int>& sources, int tag = 0);
142 
143 };
144 
145 
146 
147 #endif /* SRMANAGER_H_ */
SRManager::clear
void clear()
Clears the send and receive arrays (sets all values to 0).
Definition: SRManager.cpp:80
SRManager::setVal
void setVal(int pos, int val)
Sets the value at the given index in the array.
Definition: SRManager.cpp:76
SRManager::SRManager
SRManager(boost::mpi::communicator *comm)
Creates an SRManager that uses the specified communicator.
Definition: SRManager.cpp:46
SRManager::retrieveSources
void retrieveSources()
Performs the actual send operation, populating the receive array with values from the other processes...
Definition: SRManager.cpp:86
SRManager::mark
void mark(int pos)
Marks the position in the array as 'true' (sets to one).
Definition: SRManager.cpp:72
SRManager
Coordinates send and receive between processes by notifying processes to expect a send from X other p...
Definition: SRManager.h:52