9This 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.
26 tree_map = std::shared_ptr< ProcMapImpl<D> > (
new ProcMapImpl<D>(
v));
30 if (key.
level() == 0)
return 0;
32 return (parent.
hash()%nproc);
36 return simple_key_map((
const long *) &(parent.
translation()[0]));
40 std::vector<long> vdim(
D);
41 for (
int i=0; i<
D; ++i) vdim[i] = 1L<<n;
44 std::list< std::pair<KeyD,double> > costmap;
46 long cent = (1L<<n) / 2;
49 for (
int i=0; i<
D; ++i) {
51 dist += (l[i] - cent)*(l[i] - cent);
53 double cost = 1.0/
dist;
54 cost *= (1.0 + 0.001*RandomValue<double>());
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())
100 n =int((std::log((
double)world.
size())/std::log(2.0)+3)/
D) + 2;
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) {
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);
Key is the index for a node of the 2^NDIM-tree.
Definition key.h:68
Level level() const
Definition key.h:161
hashT hash() const
Definition key.h:150
Key parent(int generation=1) const
Returns the key of the parent.
Definition key.h:245
const Vector< Translation, NDIM > & translation() const
Definition key.h:166
Procmap implemented using Tree of TreeCoords.
Definition mypmap.h:15
void build_tree_map(std::vector< TreeCoords< D > > v)
private method that builds the Tree underlying the procmap
Definition mypmap.h:25
MyPmap(World &world, std::vector< TreeCoords< D > > v)
Definition mypmap.h:105
Tensor< ProcessID > simple_key_map
Definition mypmap.h:21
unsigned int map_type
Definition mypmap.h:17
Key< D > KeyD
Definition mypmap.h:22
ProcessID not_so_simple_hash(const KeyD &key) const
Definition mypmap.h:34
ProcessID simple_hash(const KeyD &key) const
Definition mypmap.h:29
const int nproc
Definition mypmap.h:18
void prepare_not_so_simple_map(World &world)
Definition mypmap.h:39
std::shared_ptr< ProcMapImpl< D > > tree_map
Definition mypmap.h:20
MyPmap(const MyPmap< D > &other)
Definition mypmap.h:109
ProcessID owner(const KeyD &key) const
Find the owner of a given key.
Definition mypmap.h:133
MyPmap()
Definition mypmap.h:76
MyPmap(World &world)
Definition mypmap.h:81
const int n
Definition mypmap.h:19
MyPmap< D > & operator=(const MyPmap< D > &other)
Definition mypmap.h:111
MyPmap(World &world, unsigned int map_type, int n=100)
Definition mypmap.h:95
void print() const
Definition mypmap.h:122
static bool costmapcmp(const std::pair< KeyD, double > &a, const std::pair< KeyD, double > &b)
Definition mypmap.h:78
Definition tensoriter.h:61
A tensor is a multidimensional array.
Definition tensor.h:317
TensorIterator< T > unary_iterator(long iterlevel=0, bool optimize=true, bool fusedim=true, long jdim=default_jdim) const
Return iterator over single tensor.
Definition tensor.h:1844
A simple, fixed dimension vector.
Definition vector.h:64
Interface to be provided by any process map.
Definition worlddc.h:82
A parallel world class.
Definition world.h:132
ProcessID size() const
Returns the number of processes in this World (same as MPI_Comm_size()).
Definition world.h:330
char * p(char *buf, const char *name, int k, int initial_level, double thresh, int order)
Definition derivatives.cc:72
static double function(const coord_3d &r)
Normalized gaussian.
Definition functionio.cc:100
static const double v
Definition hatom_sf_dirac.cc:20
Namespace for all elements and tools of MADNESS.
Definition DFParameters.h:10
void print(const T &t, const Ts &... ts)
Print items to std::cout (items separated by spaces) and terminate with a new line.
Definition print.h:225
static const double b
Definition nonlinschro.cc:119
static const double a
Definition nonlinschro.cc:118
Definition test_ar.cc:204
double dist(const Vector< double, 3 > v1, const Vector< double, 3 > v2)
distance between v1 and v2
Definition test_localizer.cc:38
int ProcessID
Used to clearly identify process number/rank.
Definition worldtypes.h:43