9 This is not presently in use but is left here since it is actually useful. It provides
a process map that can use
a cost
function for partitioning subtrees. Originally written by Rebecca Hartman-Baker.
17 unsigned int map_type;
21 Tensor<ProcessID> simple_key_map;
25 void build_tree_map(std::vector< TreeCoords<D> > v) {
29 ProcessID simple_hash(
const KeyD& key)
const {
30 if (key.
level() == 0)
return 0;
32 return (parent.
hash()%nproc);
34 ProcessID not_so_simple_hash(
const KeyD& key)
const {
36 return simple_key_map((
const long *) &(parent.
translation()[0]));
39 void prepare_not_so_simple_map(
World& world) {
40 std::vector<long> vdim(D);
41 for (
int i=0; i<D; ++i) vdim[i] = 1
L<<n;
42 simple_key_map = Tensor<ProcessID>(vdim);
44 std::list< std::pair<KeyD,double> > costmap;
46 long cent = (1
L<<n) / 2;
49 for (
int i=0; i<D; ++i) {
51 dist += (l[i] - cent)*(l[i] - cent);
53 double cost = 1.0/dist;
55 costmap.push_back(std::pair<KeyD,double>(KeyD(n,l),cost));
57 costmap.sort(costmapcmp);
64 for (
typename std::list< std::pair<KeyD,double> >::iterator it=costmap.begin(); it!=costmap.end(); ++it) {
65 const long *l = (
const long *) &(it->first.translation()[0]);
66 simple_key_map(l) = p;
68 if (p == world.
size()) p = 0;
78 static bool costmapcmp(
const std::pair<KeyD,double>&
a,
const std::pair<KeyD,double>&
b) {
79 return a.second > b.second;
83 , nproc(world.nproc())
84 , n(int((
std::
log((double)world.size())/
std::
log(2.0)+3)/D) + 2) {
92 prepare_not_so_simple_map(world);
97 , nproc(world.nproc())
101 prepare_not_so_simple_map(world);
105 MyPmap(
World& world, std::vector<TreeCoords<D> > v) : map_type(2), nproc(world.nproc()), n(0) {
109 MyPmap(
const MyPmap<D>& other) : map_type(other.map_type), nproc(other.nproc), n(other.n), tree_map(other.tree_map) {};
112 if (
this != &other) {
113 map_type = other.map_type;
114 simple_key_map = other.simple_key_map;
117 tree_map = other.tree_map;
125 }
else if (map_type == 1) {
135 return simple_hash(key);
136 }
else if (map_type == 1) {
137 return not_so_simple_hash(key);
139 return tree_map->find_owner(key);
Definition: shared_ptr_bits.h:38
ProcessID owner(const KeyD &key) const
Find the owner of a given key.
Definition: mypmap.h:133
const mpreal log(const mpreal &v, mp_rnd_t rnd_mode)
Definition: mpreal.h:2213
const Vector< Translation, NDIM > & translation() const
Definition: key.h:225
A simple, fixed dimension Coordinate.
Definition: array.h:99
const double L
Definition: 3dharmonic.cc:123
MyPmap< D > & operator=(const MyPmap< D > &other)
Definition: mypmap.h:111
Definition: mpreal.h:3066
ProcessID size() const
Returns the number of processes in this world (same as MPI_Comm_size())
Definition: worldfwd.h:533
void print() const
Definition: mypmap.h:122
MyPmap(World &world, std::vector< TreeCoords< D > > v)
Definition: mypmap.h:105
MyPmap(World &world)
Definition: mypmap.h:81
Key parent(int generation=1) const
Returns the key of the parent.
Definition: key.h:248
Procmap implemented using Tree of TreeCoords.
Definition: mypmap.h:15
MyPmap(World &world, unsigned int map_type, int n=100)
Definition: mypmap.h:95
FLOAT a(int j, FLOAT z)
Definition: y1.cc:86
Level level() const
Definition: key.h:220
MyPmap()
Definition: mypmap.h:76
double RandomValue< double >()
Random double.
Definition: ran.cc:234
A parallel world with full functionality wrapping an MPI communicator.
Definition: worldfwd.h:416
int ProcessID
Used to clearly identify process number/rank.
Definition: worldtypes.h:37
MyPmap(const MyPmap< D > &other)
Definition: mypmap.h:109
hashT hash() const
Definition: key.h:209
Interface to be provided by any process map.
Definition: worlddc.h:64
Definition: tensoriter.h:61
void print(const A &a)
Print a single item to std::cout terminating with new line.
Definition: print.h:122
Holds machinery to set up Functions/FuncImpls using various Factories and Interfaces.
Definition: chem/atomutil.cc:45
FLOAT b(int j, FLOAT z)
Definition: y1.cc:79
Key is the index for a node of the 2^NDIM-tree.
Definition: key.h:69
static bool costmapcmp(const std::pair< KeyD, double > &a, const std::pair< KeyD, double > &b)
Definition: mypmap.h:78