Skip to content

Commit

Permalink
reorgnized tree interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
liuyangzhuan committed Feb 13, 2018
1 parent f49b990 commit 4fe9531
Show file tree
Hide file tree
Showing 12 changed files with 33,643 additions and 16,860 deletions.
153 changes: 125 additions & 28 deletions SRC/TreeInterface.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "TreeReduce_v2.hpp"

#include "dcomplex.h"

namespace ASYNCOMM{

Expand All @@ -9,49 +9,98 @@ namespace ASYNCOMM{
extern "C" {
#endif

BcTree BcTree_Create(MPI_Comm comm, Int* ranks, Int rank_cnt, Int msgSize, double rseed){
BcTree BcTree_Create(MPI_Comm comm, Int* ranks, Int rank_cnt, Int msgSize, double rseed, char precision){
assert(msgSize>0);
TreeBcast_v2<double>* BcastTree = TreeBcast_v2<double>::Create(comm,ranks,rank_cnt,msgSize,rseed);
return (BcTree) BcastTree;
if(precision=='d'){
TreeBcast_v2<double>* BcastTree = TreeBcast_v2<double>::Create(comm,ranks,rank_cnt,msgSize,rseed);
return (BcTree) BcastTree;
}
if(precision=='z'){
TreeBcast_v2<doublecomplex>* BcastTree = TreeBcast_v2<doublecomplex>::Create(comm,ranks,rank_cnt,msgSize,rseed);
return (BcTree) BcastTree;
}
}

void BcTree_Destroy(BcTree Tree){
TreeBcast_v2<double>* BcastTree = (TreeBcast_v2<double>*) Tree;
delete BcastTree;
void BcTree_Destroy(BcTree Tree, char precision){
if(precision=='d'){
TreeBcast_v2<double>* BcastTree = (TreeBcast_v2<double>*) Tree;
delete BcastTree;
}
if(precision=='z'){
TreeBcast_v2<doublecomplex>* BcastTree = (TreeBcast_v2<doublecomplex>*) Tree;
delete BcastTree;
}

}

void BcTree_SetTag(BcTree Tree, Int tag){
void BcTree_SetTag(BcTree Tree, Int tag, char precision){
if(precision=='d'){
TreeBcast_v2<double>* BcastTree = (TreeBcast_v2<double>*) Tree;
BcastTree->SetTag(tag);
}
if(precision=='z'){
TreeBcast_v2<doublecomplex>* BcastTree = (TreeBcast_v2<doublecomplex>*) Tree;
BcastTree->SetTag(tag);
}
}


yes_no_t BcTree_IsRoot(BcTree Tree){
yes_no_t BcTree_IsRoot(BcTree Tree, char precision){
if(precision=='d'){
TreeBcast_v2<double>* BcastTree = (TreeBcast_v2<double>*) Tree;
return BcastTree->IsRoot()?YES:NO;
}
if(precision=='z'){
TreeBcast_v2<doublecomplex>* BcastTree = (TreeBcast_v2<doublecomplex>*) Tree;
return BcastTree->IsRoot()?YES:NO;
}
}


void BcTree_forwardMessageSimple(BcTree Tree, void* localBuffer){
void BcTree_forwardMessageSimple(BcTree Tree, void* localBuffer, char precision){
if(precision=='d'){
TreeBcast_v2<double>* BcastTree = (TreeBcast_v2<double>*) Tree;
BcastTree->forwardMessageSimple((double*)localBuffer);
BcastTree->forwardMessageSimple((double*)localBuffer);
}
if(precision=='z'){
TreeBcast_v2<doublecomplex>* BcastTree = (TreeBcast_v2<doublecomplex>*) Tree;
BcastTree->forwardMessageSimple((doublecomplex*)localBuffer);
}
}

void BcTree_waitSendRequest(BcTree Tree){
void BcTree_waitSendRequest(BcTree Tree, char precision){
if(precision=='d'){
TreeBcast_v2<double>* BcastTree = (TreeBcast_v2<double>*) Tree;
BcastTree->waitSendRequest();
}
if(precision=='z'){
TreeBcast_v2<doublecomplex>* BcastTree = (TreeBcast_v2<doublecomplex>*) Tree;
BcastTree->waitSendRequest();
}
}



void BcTree_allocateRequest(BcTree Tree){
void BcTree_allocateRequest(BcTree Tree, char precision){
if(precision=='d'){
TreeBcast_v2<double>* BcastTree = (TreeBcast_v2<double>*) Tree;
BcastTree->allocateRequest();
BcastTree->allocateRequest();
}
if(precision=='z'){
TreeBcast_v2<doublecomplex>* BcastTree = (TreeBcast_v2<doublecomplex>*) Tree;
BcastTree->allocateRequest();
}
}

int BcTree_getDestCount(BcTree Tree){
int BcTree_getDestCount(BcTree Tree, char precision){
if(precision=='d'){
TreeBcast_v2<double>* BcastTree = (TreeBcast_v2<double>*) Tree;
return BcastTree->GetDestCount();
return BcastTree->GetDestCount();
}
if(precision=='z'){
TreeBcast_v2<doublecomplex>* BcastTree = (TreeBcast_v2<doublecomplex>*) Tree;
return BcastTree->GetDestCount();
}
}


Expand Down Expand Up @@ -100,47 +149,95 @@ namespace ASYNCOMM{
}


RdTree RdTree_Create(MPI_Comm comm, Int* ranks, Int rank_cnt, Int msgSize, double rseed){
RdTree RdTree_Create(MPI_Comm comm, Int* ranks, Int rank_cnt, Int msgSize, double rseed, char precision){
assert(msgSize>0);
if(precision=='d'){
TreeReduce_v2<double>* ReduceTree = TreeReduce_v2<double>::Create(comm,ranks,rank_cnt,msgSize,rseed);
return (RdTree) ReduceTree;
}
if(precision=='z'){
TreeReduce_v2<doublecomplex>* ReduceTree = TreeReduce_v2<doublecomplex>::Create(comm,ranks,rank_cnt,msgSize,rseed);
return (RdTree) ReduceTree;
}
}

void RdTree_Destroy(RdTree Tree){
void RdTree_Destroy(RdTree Tree, char precision){
if(precision=='d'){
TreeReduce_v2<double>* ReduceTree = (TreeReduce_v2<double>*) Tree;
delete ReduceTree;
}
if(precision=='z'){
TreeReduce_v2<doublecomplex>* ReduceTree = (TreeReduce_v2<doublecomplex>*) Tree;
delete ReduceTree;
}
}


void RdTree_SetTag(RdTree Tree, Int tag){
void RdTree_SetTag(RdTree Tree, Int tag, char precision){
if(precision=='d'){
TreeReduce_v2<double>* ReduceTree = (TreeReduce_v2<double>*) Tree;
ReduceTree->SetTag(tag);
}
if(precision=='z'){
TreeReduce_v2<doublecomplex>* ReduceTree = (TreeReduce_v2<doublecomplex>*) Tree;
ReduceTree->SetTag(tag);
}
}

int RdTree_GetDestCount(RdTree Tree){
int RdTree_GetDestCount(RdTree Tree, char precision){
if(precision=='d'){
TreeReduce_v2<double>* ReduceTree = (TreeReduce_v2<double>*) Tree;
return ReduceTree->GetDestCount();
return ReduceTree->GetDestCount();
}
if(precision=='z'){
TreeReduce_v2<doublecomplex>* ReduceTree = (TreeReduce_v2<doublecomplex>*) Tree;
return ReduceTree->GetDestCount();
}
}


yes_no_t RdTree_IsRoot(RdTree Tree){
yes_no_t RdTree_IsRoot(RdTree Tree, char precision){
if(precision=='d'){
TreeReduce_v2<double>* ReduceTree = (TreeReduce_v2<double>*) Tree;
return ReduceTree->IsRoot()?YES:NO;
}
if(precision=='z'){
TreeReduce_v2<doublecomplex>* ReduceTree = (TreeReduce_v2<doublecomplex>*) Tree;
return ReduceTree->IsRoot()?YES:NO;
}
}


void RdTree_forwardMessageSimple(RdTree Tree, void* localBuffer){
void RdTree_forwardMessageSimple(RdTree Tree, void* localBuffer, char precision){
if(precision=='d'){
TreeReduce_v2<double>* ReduceTree = (TreeReduce_v2<double>*) Tree;
ReduceTree->forwardMessageSimple((double*)localBuffer);
ReduceTree->forwardMessageSimple((double*)localBuffer);
}
if(precision=='z'){TreeReduce_v2<doublecomplex>* ReduceTree = (TreeReduce_v2<doublecomplex>*) Tree;
ReduceTree->forwardMessageSimple((doublecomplex*)localBuffer);
}
}
void RdTree_allocateRequest(RdTree Tree){
void RdTree_allocateRequest(RdTree Tree, char precision){
if(precision=='d'){
TreeReduce_v2<double>* ReduceTree = (TreeReduce_v2<double>*) Tree;
ReduceTree->allocateRequest();
ReduceTree->allocateRequest();
}
if(precision=='z'){
TreeReduce_v2<doublecomplex>* ReduceTree = (TreeReduce_v2<doublecomplex>*) Tree;
ReduceTree->allocateRequest();
}

}

void RdTree_waitSendRequest(RdTree Tree){
void RdTree_waitSendRequest(RdTree Tree, char precision){
if(precision=='d'){
TreeReduce_v2<double>* ReduceTree = (TreeReduce_v2<double>*) Tree;
ReduceTree->waitSendRequest();
ReduceTree->waitSendRequest();
}
if(precision=='z'){
TreeReduce_v2<doublecomplex>* ReduceTree = (TreeReduce_v2<doublecomplex>*) Tree;
ReduceTree->waitSendRequest();
}
}


Expand Down
4 changes: 4 additions & 0 deletions SRC/dcomplex.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ extern SUPERLU_DIST_EXPORT MPI_Datatype SuperLU_MPI_DOUBLE_COMPLEX;

/* Macro definitions */

/*! \brief Complex Copy c = a */
#define z_copy(c, a) { (c)->r = (a)->r ; \
(c)->i = (a)->i ; }

/*! \brief Complex Addition c = a + b */
#define z_add(c, a, b) { (c)->r = (a)->r + (b)->r; \
(c)->i = (a)->i + (b)->i; }
Expand Down
3 changes: 2 additions & 1 deletion SRC/global.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "environment.hpp"
#include <deque>
#include <deque>

namespace ASYNCOMM{

Expand Down Expand Up @@ -35,4 +35,5 @@ namespace ASYNCOMM{
}

#endif // ifndef _RELEASE_

} // namespace ASYNCOMM
20 changes: 10 additions & 10 deletions SRC/pddistribute.c
Original file line number Diff line number Diff line change
Expand Up @@ -1327,14 +1327,14 @@ pddistribute(fact_t fact, int_t n, SuperMatrix *A,
// rseed=rand();
// rseed=1.0;
msgsize = SuperSize( jb )*nrhs+XK_H;
LBtree_ptr[ljb] = BcTree_Create(grid->comm, ranks, rank_cnt, msgsize,SeedSTD_BC[ljb]);
BcTree_SetTag(LBtree_ptr[ljb],BC_L);
LBtree_ptr[ljb] = BcTree_Create(grid->comm, ranks, rank_cnt, msgsize,SeedSTD_BC[ljb],'d');
BcTree_SetTag(LBtree_ptr[ljb],BC_L,'d');

// printf("iam %5d btree rank_cnt %5d \n",iam,rank_cnt);
// fflush(stdout);

// if(iam==15 || iam==3){
// printf("iam %5d btree lk %5d tag %5d root %5d\n",iam, ljb,jb,BcTree_IsRoot(LBtree_ptr[ljb]));
// printf("iam %5d btree lk %5d tag %5d root %5d\n",iam, ljb,jb,BcTree_IsRoot(LBtree_ptr[ljb],'d'));
// fflush(stdout);
// }

Expand Down Expand Up @@ -1510,8 +1510,8 @@ pddistribute(fact_t fact, int_t n, SuperMatrix *A,

// if(ib==0){

LRtree_ptr[lib] = RdTree_Create(grid->comm, ranks, rank_cnt, msgsize,SeedSTD_RD[lib]);
RdTree_SetTag(LRtree_ptr[lib], RD_L);
LRtree_ptr[lib] = RdTree_Create(grid->comm, ranks, rank_cnt, msgsize,SeedSTD_RD[lib],'d');
RdTree_SetTag(LRtree_ptr[lib], RD_L,'d');
// }

// printf("iam %5d rtree rank_cnt %5d \n",iam,rank_cnt);
Expand All @@ -1520,7 +1520,7 @@ pddistribute(fact_t fact, int_t n, SuperMatrix *A,
// if(ib==15 || ib ==16){

// if(iam==15 || iam==3){
// printf("iam %5d rtree lk %5d tag %5d root %5d\n",iam,lib,ib,RdTree_IsRoot(LRtree_ptr[lib]));
// printf("iam %5d rtree lk %5d tag %5d root %5d\n",iam,lib,ib,RdTree_IsRoot(LRtree_ptr[lib],'d'));
// fflush(stdout);
// }

Expand Down Expand Up @@ -1667,8 +1667,8 @@ pddistribute(fact_t fact, int_t n, SuperMatrix *A,
// rseed=rand();
// rseed=1.0;
msgsize = SuperSize( jb )*nrhs+XK_H;
UBtree_ptr[ljb] = BcTree_Create(grid->comm, ranks, rank_cnt, msgsize,SeedSTD_BC[ljb]);
BcTree_SetTag(UBtree_ptr[ljb],BC_U);
UBtree_ptr[ljb] = BcTree_Create(grid->comm, ranks, rank_cnt, msgsize,SeedSTD_BC[ljb],'d');
BcTree_SetTag(UBtree_ptr[ljb],BC_U,'d');

// printf("iam %5d btree rank_cnt %5d \n",iam,rank_cnt);
// fflush(stdout);
Expand Down Expand Up @@ -1868,8 +1868,8 @@ pddistribute(fact_t fact, int_t n, SuperMatrix *A,

// if(ib==0){

URtree_ptr[lib] = RdTree_Create(grid->comm, ranks, rank_cnt, msgsize,SeedSTD_RD[lib]);
RdTree_SetTag(URtree_ptr[lib], RD_U);
URtree_ptr[lib] = RdTree_Create(grid->comm, ranks, rank_cnt, msgsize,SeedSTD_RD[lib],'d');
RdTree_SetTag(URtree_ptr[lib], RD_U,'d');
// }

// #if ( PRNTlevel>=1 )
Expand Down
Loading

0 comments on commit 4fe9531

Please sign in to comment.