source: src/comm/mpi/key.cpp@ 76e019

Last change on this file since 76e019 was 97c25dd, checked in by Julian Iseringhausen <isering@…>, 14 years ago

Work on a red-black communication routine to half the communication amount.

git-svn-id: https://svn.version.fz-juelich.de/scafacos/trunk@1247 5161e1c8-67bf-11de-9fd5-51895aff932f

  • Property mode set to 100644
File size: 2.1 KB
Line 
1/**
2 * @file key.cpp
3 * @author Julian Iseringhausen <isering@ins.uni-bonn.de>
4 * @date Mon Nov 21 13:27:22 2011
5 *
6 * @brief Class to distinguish the different entities in maps.
7 *
8 */
9
10#ifdef HAVE_CONFIG_H
11#include <config.h>
12#endif
13
14#include "comm/mpi/key.hpp"
15#include "grid/grid.hpp"
16
17using namespace VMG;
18
19VMG::MPI::Key::Key()
20{
21}
22
23VMG::MPI::Key::Key(const VMG::MPI::Key& other)
24{
25 this->int_keys.assign(other.int_keys.begin(), other.int_keys.end());
26 this->addr_keys.assign(other.addr_keys.begin(), other.addr_keys.end());
27}
28
29VMG::MPI::Key::Key(const Grid& grid)
30{
31 AddKey(grid);
32}
33
34VMG::MPI::Key::Key(const Grid& grid_1, const Grid& grid_2)
35{
36 AddKey(grid_1);
37 AddKey(grid_2);
38}
39
40VMG::MPI::Key::Key(const Index& i1, const Index& i2, const Index& i3)
41{
42 AddKey(i1);
43 AddKey(i2);
44 AddKey(i3);
45}
46
47void VMG::MPI::Key::AddKey(const Grid& grid)
48{
49 for (int i=0; i<3; ++i) {
50 int_keys.push_back(grid.Global().BeginLocal()[i]);
51 int_keys.push_back(grid.Global().EndLocal()[i]);
52 int_keys.push_back(grid.Global().SizeGlobal()[i]);
53 }
54 addr_keys.push_back(reinterpret_cast<const void*>(&grid));
55}
56
57void VMG::MPI::Key::AddKey(const Index& index)
58{
59 for (int i=0; i<3; ++i)
60 int_keys.push_back(index[i]);
61}
62
63void VMG::MPI::Key::AddKey(const int& i)
64{
65 int_keys.push_back(i);
66}
67
68void VMG::MPI::Key::AddKey(const void* addr)
69{
70 addr_keys.push_back(addr);
71}
72
73bool VMG::MPI::Key::operator<(const Key& other) const
74{
75 if (this->int_keys.size() < other.int_keys.size())
76 return true;
77 else if (this->int_keys.size() > other.int_keys.size())
78 return false;
79
80 if (this->addr_keys.size() < other.addr_keys.size())
81 return true;
82 else if (this->addr_keys.size() > other.addr_keys.size())
83 return false;
84
85 for (unsigned int i=0; i<int_keys.size(); ++i)
86 if (this->int_keys[i] < other.int_keys[i])
87 return true;
88 else if (this->int_keys[i] > other.int_keys[i])
89 return false;
90
91 for (unsigned int i=0; i<addr_keys.size(); ++i)
92 if (this->addr_keys[i] < other.addr_keys[i])
93 return true;
94 else if (this-> addr_keys[i] > other.addr_keys[i])
95 return false;
96
97 return false;
98}
Note: See TracBrowser for help on using the repository browser.