Last change
on this file since 723 was
721,
checked in by mhnguyen, 9 years ago
|
Templated version of distributed hashed table
+) Implement DHT in more generic way to work with different type of information
+) Some old codes of DHT are kept to be a reference (they will be deleted soon)
Test
+) On local, mode attached, 8 processes
+) test_remap passes and result is correct
|
File size:
1.3 KB
|
Line | |
---|
1 | /*! |
---|
2 | \file policy.cpp |
---|
3 | \author Ha NGUYEN |
---|
4 | \since 06 Oct 2015 |
---|
5 | \date 06 Oct 2015 |
---|
6 | |
---|
7 | \brief Some useful policies for templated classes |
---|
8 | */ |
---|
9 | |
---|
10 | #include "policy.hpp" |
---|
11 | #include <cmath> |
---|
12 | |
---|
13 | namespace xios |
---|
14 | { |
---|
15 | /*! |
---|
16 | Calculate MPI communicator for each level of hierarchy. |
---|
17 | \param[in] mpiCommRoot MPI communicator of the level 0 (usually communicator of all clients) |
---|
18 | \param[in] levels number of level in hierarchy |
---|
19 | */ |
---|
20 | void DivideCommByTwo::computeMPICommLevel(const MPI_Comm& mpiCommRoot, int levels) |
---|
21 | { |
---|
22 | int nbProc; |
---|
23 | MPI_Comm_size(mpiCommRoot,&nbProc); |
---|
24 | if (levels > nbProc) levels = std::log10(nbProc) * 3.3219; // log2(x) = log2(10) * log10(x); stupid C++98 |
---|
25 | else if (1 > levels) levels = 1; |
---|
26 | |
---|
27 | commLevel_.push_back(mpiCommRoot); |
---|
28 | divideMPICommLevel(mpiCommRoot, levels); |
---|
29 | } |
---|
30 | |
---|
31 | /*! |
---|
32 | Divide each MPI communicator into sub-communicator. Recursive function |
---|
33 | \param [in] mpiCommLevel MPI communicator of current level |
---|
34 | \param [in] level current level |
---|
35 | */ |
---|
36 | void DivideCommByTwo::divideMPICommLevel(const MPI_Comm& mpiCommLevel, int level) |
---|
37 | { |
---|
38 | int clientRank; |
---|
39 | MPI_Comm_rank(mpiCommLevel,&clientRank); |
---|
40 | |
---|
41 | --level; |
---|
42 | if (0 < level) |
---|
43 | { |
---|
44 | int color = clientRank % 2; |
---|
45 | commLevel_.push_back(MPI_Comm()); |
---|
46 | MPI_Comm_split(mpiCommLevel, color, 0, &(commLevel_.back())); |
---|
47 | divideMPICommLevel(commLevel_.back(), level); |
---|
48 | } |
---|
49 | } |
---|
50 | |
---|
51 | } |
---|
52 | |
---|
Note: See
TracBrowser
for help on using the repository browser.