Skip to content

Commit

Permalink
enable/disable node aware fix
Browse files Browse the repository at this point in the history
  • Loading branch information
raghavendrak committed Oct 31, 2022
1 parent 73466cd commit f04f035
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 20 deletions.
1 change: 0 additions & 1 deletion src/contraction/contraction.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -4447,7 +4447,6 @@ namespace CTF_int {
for (int j=0; j<orig_topo.order; j++){
intra_node_lens[j] = orig_topo.lens[j] / inter_node_grids[i][j];
}
intra_node_lens[orig_topo.order] = C->wrld->ppn;
topology na_topo_i(orig_topo.order, orig_topo.lens, orig_topo.glb_comm, C->wrld->ppn, 0, intra_node_lens);
// overwrite topology object in a way that also changes information in CommData objects pointed to ctrf
C->topo->morph_to(na_topo_i);
Expand Down
8 changes: 4 additions & 4 deletions src/interface/world.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ namespace CTF {
if (mach == TOPOLOGY_GENERIC)
phys_topology = NULL;
else
phys_topology = get_phys_topo(cdt, mach);
phys_topology = get_phys_topo(cdt, mach, ppn);

return initialize(argc, argv);
}
Expand All @@ -200,7 +200,7 @@ namespace CTF {
int argc,
const char * const * argv){
cdt = CommData(global_context);
phys_topology = new topology(order, dim_len, cdt, 1);
phys_topology = new topology(order, dim_len, cdt, ppn, 1);

return initialize(argc, argv);
}
Expand All @@ -219,8 +219,8 @@ namespace CTF {
MPI_Comm_rank(comm, &rank);
MPI_Comm_size(comm, &np);
if (phys_topology == NULL){
phys_topology = get_phys_topo(cdt, TOPOLOGY_GENERIC);
topovec = get_generic_topovec(cdt);
phys_topology = get_phys_topo(cdt, TOPOLOGY_GENERIC, ppn);
topovec = get_generic_topovec(cdt, ppn);
/* std::vector<topology*> topovec2;
topovec2 = peel_perm_torus(get_phys_topo(cdt, TOPOLOGY_GENERIC), cdt);
printf("topovec size is %ld, via old method was %ld\n",topovec.size(), topovec2.size());*/
Expand Down
27 changes: 14 additions & 13 deletions src/mapping/topology.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -203,22 +203,23 @@ namespace CTF_int {
}

topology * get_phys_topo(CommData glb_comm,
TOPOLOGY mach){
TOPOLOGY mach,
int ppn){
int np = glb_comm.np;
int * dl;
int * dim_len;
topology * topo;
if (mach == NO_TOPOLOGY){
dl = (int*)CTF_int::alloc(sizeof(int));
dl[0] = np;
topo = new topology(1, dl, glb_comm, 1);
topo = new topology(1, dl, glb_comm, ppn, 1);
CTF_int::cdealloc(dl);
return topo;
}
if (mach == TOPOLOGY_GENERIC){
int order;
factorize(np, &order, &dim_len);
topo = new topology(order, dim_len, glb_comm, 1);
topo = new topology(order, dim_len, glb_comm, ppn, 1);
if (order>0) CTF_int::cdealloc(dim_len);
return topo;
} else if (mach == TOPOLOGY_BGQ) {
Expand Down Expand Up @@ -257,15 +258,15 @@ namespace CTF_int {
{
int order;
factorize(np, &order, &dim_len);
topo = new topology(order, dim_len, glb_comm, 1);
topo = new topology(order, dim_len, glb_comm, ppn, 1);
CTF_int::cdealloc(dim_len);
return topo;
}
} else if (mach == TOPOLOGY_BGP) {
int order;
if (1<<(int)log2(np) != np){
factorize(np, &order, &dim_len);
topo = new topology(order, dim_len, glb_comm, 1);
topo = new topology(order, dim_len, glb_comm, ppn, 1);
CTF_int::cdealloc(dim_len);
return topo;
}
Expand Down Expand Up @@ -350,15 +351,15 @@ namespace CTF_int {
factorize(np, &order, &dim_len);
break;
}
topo = new topology(order, dim_len, glb_comm, 1);
topo = new topology(order, dim_len, glb_comm, ppn, 1);
CTF_int::cdealloc(dim_len);
return topo;
} else if (mach == TOPOLOGY_8D) {
int order;
int * dim_len;
if (1<<(int)log2(np) != np){
factorize(np, &order, &dim_len);
topo = new topology(order, dim_len, glb_comm, 1);
topo = new topology(order, dim_len, glb_comm, ppn, 1);
CTF_int::cdealloc(dim_len);
return topo;
}
Expand Down Expand Up @@ -496,14 +497,14 @@ namespace CTF_int {
break;

}
topo = new topology(order, dim_len, glb_comm, 1);
topo = new topology(order, dim_len, glb_comm, ppn, 1);
CTF_int::cdealloc(dim_len);
return topo;
} else {
int order;
dim_len = (int*)CTF_int::alloc((log2(np)+1)*sizeof(int));
factorize(np, &order, &dim_len);
topo = new topology(order, dim_len, glb_comm, 1);
topo = new topology(order, dim_len, glb_comm, ppn, 1);
return topo;
}
}
Expand Down Expand Up @@ -602,17 +603,17 @@ namespace CTF_int {
}


std::vector< topology* > create_topos_from_shapes(std::vector< std::vector<int>* > shapes, CommData cdt){
std::vector< topology* > create_topos_from_shapes(std::vector< std::vector<int>* > shapes, CommData cdt, int ppn){
std::vector< topology* > topos;
for (int i=0; i<(int)shapes.size(); i++){
topos.push_back(new topology(shapes[i]->size(), &shapes[i]->operator[](0), cdt));
topos.push_back(new topology(shapes[i]->size(), &shapes[i]->operator[](0), cdt, ppn));
}
return topos;
}

std::vector< topology* > get_generic_topovec(CommData cdt){
std::vector< topology* > get_generic_topovec(CommData cdt, int ppn){
std::vector< std::vector<int> * > shapes = get_all_shapes(cdt.np);
std::vector< topology* > topos = create_topos_from_shapes(shapes, cdt);
std::vector< topology* > topos = create_topos_from_shapes(shapes, cdt, ppn);
for (int i=0; i<(int)shapes.size(); i++){
delete shapes[i];
}
Expand Down
5 changes: 3 additions & 2 deletions src/mapping/topology.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ namespace CTF_int {
* \param[in] mach specified topology
*/
topology * get_phys_topo(CommData glb_comm,
TOPOLOGY mach);
TOPOLOGY mach,
int ppn);


/**
Expand All @@ -110,7 +111,7 @@ namespace CTF_int {
* \brief computes all topology configurations given undelying physical topology information
* \param[in] cdt global communicator
*/
std::vector< topology* > get_generic_topovec(CommData cdt);
std::vector< topology* > get_generic_topovec(CommData cdt, int ppn);

/**
* \brief folds specified topology and all of its permutations into all configurations of lesser dimensionality
Expand Down

0 comments on commit f04f035

Please sign in to comment.