Skip to content

Commit

Permalink
chg: change naming rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Chenhan Yu committed Mar 6, 2019
1 parent 3f693b5 commit f95c22b
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 118 deletions.
21 changes: 17 additions & 4 deletions frame/base/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,26 @@ const char* getErrorString( hmlpError_t error )
*/
void handleError( hmlpError_t error, const char* file, int line )
{
if ( error == HMLP_ERROR_SUCCESS ) return;
/** Otherwise, handle the error and provide information. */
printf( "Error: %s in %s at line %d\n", getErrorString( error ), file, line );
if ( error == HMLP_ERROR_SUCCESS )
{
return;
}
if ( error < HMLP_ERROR_MPI_ERROR )
{
/** Otherwise, handle the error and provide information. */
fprintf( stderr, "Error: HMLP_ERROR_MPI_ERROR %d in %s at line %d\n",
error, file, line );
}
else
{
/** Otherwise, handle the error and provide information. */
fprintf( stderr, "Error: %s in %s at line %d\n",
getErrorString( error ), file, line );
}
throw std::invalid_argument( "Program encounters hmlp error." );
};


hmlpError_t returnIfError( hmlpError_t error, const char* file, int line )
{
if ( error == HMLP_ERROR_SUCCESS )
Expand All @@ -59,5 +73,4 @@ hmlpError_t returnIfError( hmlpError_t error, const char* file, int line )
return error;
};


}; /* end namespace hmlp */
2 changes: 1 addition & 1 deletion frame/base/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#include <hmlp.h>


#define HANDLE_ERROR( err ) (hmlp::handleError( err, __FILE__, __LINE__ ))
#define HANDLE_ERROR( err ) (hmlp::handleError( (hmlpError_t)err, __FILE__, __LINE__ ))
#define RETURN_IF_ERROR( err ) { auto hmlp_err = hmlp::returnIfError( (hmlpError_t)err, __FILE__, __LINE__ );\
if ( hmlp_err != HMLP_ERROR_SUCCESS ) return hmlp_err; }

Expand Down
64 changes: 32 additions & 32 deletions gofmm/gofmm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3057,7 +3057,7 @@ Data<T> Evaluate( TREE &tree, Data<T> &weights )
double forward_permute_time, backward_permute_time;

/** clean up all r/w dependencies left on tree nodes */
tree.DependencyCleanUp();
HANDLE_ERROR( tree.dependencyClean() );

/** n-by-nrhs initialize potentials */
size_t n = weights.row();
Expand Down Expand Up @@ -3139,30 +3139,30 @@ Data<T> Evaluate( TREE &tree, Data<T> &weights )
// if ( USE_OMP_TASK )
// {
// assert( !USE_RUNTIME );
// tree.template TraverseLeafs<false, false>( leaftoleaftask1 );
// tree.template TraverseLeafs<false, false>( leaftoleaftask2 );
// tree.template TraverseLeafs<false, false>( leaftoleaftask3 );
// tree.template TraverseLeafs<false, false>( leaftoleaftask4 );
// tree.template traverseLeafs<false, false>( leaftoleaftask1 );
// tree.template traverseLeafs<false, false>( leaftoleaftask2 );
// tree.template traverseLeafs<false, false>( leaftoleaftask3 );
// tree.template traverseLeafs<false, false>( leaftoleaftask4 );
// tree.template UpDown<true, true, true>( nodetoskeltask, skeltoskeltask, skeltonodetask );
// }
// else
// {
// assert( !USE_OMP_TASK );
//
//#ifdef HMLP_USE_CUDA
// tree.template TraverseLeafs<AUTO_DEPENDENCY, USE_RUNTIME>( leaftoleafver2task );
// tree.template traverseLeafs<AUTO_DEPENDENCY, USE_RUNTIME>( leaftoleafver2task );
//#else
// tree.template TraverseLeafs<AUTO_DEPENDENCY, USE_RUNTIME>( leaftoleaftask1 );
// tree.template TraverseLeafs<AUTO_DEPENDENCY, USE_RUNTIME>( leaftoleaftask2 );
// tree.template TraverseLeafs<AUTO_DEPENDENCY, USE_RUNTIME>( leaftoleaftask3 );
// tree.template TraverseLeafs<AUTO_DEPENDENCY, USE_RUNTIME>( leaftoleaftask4 );
// tree.template traverseLeafs<AUTO_DEPENDENCY, USE_RUNTIME>( leaftoleaftask1 );
// tree.template traverseLeafs<AUTO_DEPENDENCY, USE_RUNTIME>( leaftoleaftask2 );
// tree.template traverseLeafs<AUTO_DEPENDENCY, USE_RUNTIME>( leaftoleaftask3 );
// tree.template traverseLeafs<AUTO_DEPENDENCY, USE_RUNTIME>( leaftoleaftask4 );
//#endif
//
// /** check scheduler */
// //hmlp_get_runtime_handle()->scheduler->ReportRemainingTime();
// tree.template TraverseUp <AUTO_DEPENDENCY, USE_RUNTIME>( nodetoskeltask );
// tree.template TraverseUnOrdered<AUTO_DEPENDENCY, USE_RUNTIME>( skeltoskeltask );
// tree.template TraverseDown <AUTO_DEPENDENCY, USE_RUNTIME>( skeltonodetask );
// tree.template traverseUp <AUTO_DEPENDENCY, USE_RUNTIME>( nodetoskeltask );
// tree.template traverseUnOrdered<AUTO_DEPENDENCY, USE_RUNTIME>( skeltoskeltask );
// tree.template traverseDown <AUTO_DEPENDENCY, USE_RUNTIME>( skeltonodetask );
// /** check scheduler */
// //hmlp_get_runtime_handle()->scheduler->ReportRemainingTime();
//
Expand All @@ -3184,16 +3184,16 @@ Data<T> Evaluate( TREE &tree, Data<T> &weights )

/** CPU-GPU hybrid uses a different kind of L2L task */
#ifdef HMLP_USE_CUDA
tree.TraverseLeafs( leaftoleafver2task );
tree.traverseLeafs( leaftoleafver2task );
#else
tree.TraverseLeafs( leaftoleaftask1 );
tree.TraverseLeafs( leaftoleaftask2 );
tree.TraverseLeafs( leaftoleaftask3 );
tree.TraverseLeafs( leaftoleaftask4 );
tree.traverseLeafs( leaftoleaftask1 );
tree.traverseLeafs( leaftoleaftask2 );
tree.traverseLeafs( leaftoleaftask3 );
tree.traverseLeafs( leaftoleaftask4 );
#endif
tree.TraverseUp( nodetoskeltask );
tree.TraverseUnOrdered( skeltoskeltask );
tree.TraverseDown( skeltonodetask );
tree.traverseUp( nodetoskeltask );
tree.traverseUnOrdered( skeltoskeltask );
tree.traverseDown( skeltonodetask );
tree.ExecuteAllTasks();
//if ( USE_RUNTIME ) hmlp_run();

Expand Down Expand Up @@ -3297,7 +3297,7 @@ Data<T> Evaluate( TREE &tree, Data<T> &weights )


/** clean up all r/w dependencies left on tree nodes */
tree.DependencyCleanUp();
HANDLE_ERROR( tree.dependencyClean() );

/** return nrhs-by-N outputs */
return potentials;
Expand Down Expand Up @@ -3393,10 +3393,10 @@ tree::Tree< gofmm::Setup<SPDMATRIX, SPLITTER, T>, gofmm::NodeData<T>>

if ( REPORT_COMPRESS_STATUS )
{
printf( "TreePartitioning ...\n" ); fflush( stdout );
printf( "partitioning ...\n" ); fflush( stdout );
}
beg = omp_get_wtime();
HANDLE_ERROR( tree.TreePartition() );
HANDLE_ERROR( tree.partition() );
tree_time = omp_get_wtime() - beg;


Expand All @@ -3422,9 +3422,9 @@ tree::Tree< gofmm::Setup<SPDMATRIX, SPLITTER, T>, gofmm::NodeData<T>>

/** Build near interaction lists. */
NearSamplesTask<NODE, T> NEARSAMPLEStask;
tree.DependencyCleanUp();
HANDLE_ERROR( tree.dependencyClean() );
printf( "Dependency clean up\n" ); fflush( stdout );
tree.TraverseLeafs( NEARSAMPLEStask );
tree.traverseLeafs( NEARSAMPLEStask );
tree.ExecuteAllTasks();
//hmlp_run();
printf( "Finish NearSamplesTask\n" ); fflush( stdout );
Expand All @@ -3442,13 +3442,13 @@ tree::Tree< gofmm::Setup<SPDMATRIX, SPLITTER, T>, gofmm::NodeData<T>>
gofmm::SkeletonKIJTask<NNPRUNE, NODE, T> GETMTXtask;
gofmm::SkeletonizeTask<NODE, T> SKELtask;
gofmm::InterpolateTask<NODE> PROJtask;
tree.DependencyCleanUp();
tree.TraverseUp( GETMTXtask, SKELtask );
tree.TraverseUnOrdered( PROJtask );
HANDLE_ERROR( tree.dependencyClean() );
tree.traverseUp( GETMTXtask, SKELtask );
tree.traverseUnOrdered( PROJtask );
if ( CACHE )
{
gofmm::CacheNearNodesTask<NNPRUNE, NODE> KIJtask;
tree.template TraverseLeafs( KIJtask );
tree.template traverseLeafs( KIJtask );
}
other_time += omp_get_wtime() - beg;
hmlp_run();
Expand Down Expand Up @@ -3490,7 +3490,7 @@ tree::Tree< gofmm::Setup<SPDMATRIX, SPLITTER, T>, gofmm::NodeData<T>>
printf( "GOFMM compression phase\n" );
printf( "========================================================\n");
printf( "NeighborSearch ------------------------ %5.2lfs (%5.1lf%%)\n", ann_time, ann_time * time_ratio );
printf( "TreePartitioning ---------------------- %5.2lfs (%5.1lf%%)\n", tree_time, tree_time * time_ratio );
printf( "partitioning ---------------------- %5.2lfs (%5.1lf%%)\n", tree_time, tree_time * time_ratio );
printf( "Skeletonization ----------------------- %5.2lfs (%5.1lf%%)\n", skel_time, skel_time * time_ratio );
printf( "MergeFarNodes ------------------------- %5.2lfs (%5.1lf%%)\n", mergefarnodes_time, mergefarnodes_time * time_ratio );
printf( "CacheFarNodes ------------------------- %5.2lfs (%5.1lf%%)\n", cachefarnodes_time, cachefarnodes_time * time_ratio );
Expand All @@ -3501,7 +3501,7 @@ tree::Tree< gofmm::Setup<SPDMATRIX, SPLITTER, T>, gofmm::NodeData<T>>
}

/** Clean up all r/w dependencies left on tree nodes. */
tree_ptr->DependencyCleanUp();
HANDLE_ERROR( tree_ptr->dependencyClean() );
/** Return the hierarhical compreesion of K as a binary tree. */
return tree_ptr;
}
Expand Down
16 changes: 8 additions & 8 deletions gofmm/gofmm_mpi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3805,7 +3805,7 @@ DistData<RIDS, STAR, T> Evaluate( TREE &tree, DistData<RIDS, STAR, T> &weights )
double forward_permute_time, backward_permute_time;

/** Clean up all r/w dependencies left on tree nodes. */
tree.DependencyCleanUp();
HANDLE_ERROR( tree.dependencyClean() );

/** n-by-nrhs, initialize potentials. */
size_t n = weights.row();
Expand Down Expand Up @@ -3891,7 +3891,7 @@ DistData<RIDS, STAR, T> Evaluate( TREE &tree, DistData<RIDS, STAR, T> &weights )

/** Stage 1: TreeView and upward telescoping */
beg = omp_get_wtime();
tree.DependencyCleanUp();
HANDLE_ERROR( tree.dependencyClean() );
tree.DistTraverseDown( mpiVIEWtask );
tree.LocaTraverseDown( seqVIEWtask );
tree.ExecuteAllTasks();
Expand Down Expand Up @@ -4122,8 +4122,8 @@ mpitree::Tree<mpigofmm::Setup<SPDMATRIX, SPLITTER, T>, gofmm::NodeData<T>>

mpi::PrintProgress( "[BEG] Skeletonization ...", tree.GetComm() );
/** Skeletonization */
beg = omp_get_wtime();
tree.DependencyCleanUp();
beg = omp_get_wtime();
HANDLE_ERROR( tree.dependencyClean() );
/** Gather sample rows and skeleton columns, then ID */
gofmm::SkeletonKIJTask<NNPRUNE, NODE, T> seqGETMTXtask;
mpigofmm::DistSkeletonKIJTask<NNPRUNE, MPINODE, T> mpiGETMTXtask;
Expand All @@ -4141,7 +4141,7 @@ mpitree::Tree<mpigofmm::Setup<SPDMATRIX, SPLITTER, T>, gofmm::NodeData<T>>
tree.ExecuteAllTasks();
skel_time = omp_get_wtime() - beg;

beg = omp_get_wtime();
beg = omp_get_wtime();
tree.DistTraverseUp( mpiGETMTXtask, mpiSKELtask );
tree.DistTraverseUnOrdered( mpiPROJtask );
tree.ExecuteAllTasks();
Expand All @@ -4155,7 +4155,7 @@ mpitree::Tree<mpigofmm::Setup<SPDMATRIX, SPLITTER, T>, gofmm::NodeData<T>>
/** Find and merge far interactions. */
mpi::PrintProgress( "[BEG] MergeFarNodes ...", tree.GetComm() );
beg = omp_get_wtime();
tree.DependencyCleanUp();
HANDLE_ERROR( tree.dependencyClean() );
MergeFarNodesTask<true, NODE, T> seqMERGEtask;
DistMergeFarNodesTask<true, MPINODE, T> mpiMERGEtask;
tree.LocaTraverseUp( seqMERGEtask );
Expand Down Expand Up @@ -4256,8 +4256,8 @@ mpitree::Tree<mpigofmm::Setup<SPDMATRIX, SPLITTER, T>, gofmm::NodeData<T>>
printf( "========================================================\n\n");
}

/** Cleanup all w/r dependencies on tree nodes */
tree_ptr->DependencyCleanUp();
/* Cleanup all w/r dependencies on tree nodes */
HANDLE_ERROR( tree_ptr->dependencyClean() );
/** Global barrier to make sure all processes have completed */
mpi::Barrier( tree.GetComm() );

Expand Down
32 changes: 16 additions & 16 deletions gofmm/igofmm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1549,29 +1549,29 @@ hmlpError_t Solve( TREE &tree, Data<T> &input )
if ( tree.setup.do_ulv_factorization )
{
/** clean up all dependencies on tree nodes */
tree.DependencyCleanUp();
tree.TraverseDown( treeviewtask );
tree.TraverseLeafs( forwardpermutetask );
tree.TraverseUp( ulvforwardsolvetask );
tree.TraverseDown( ulvbackwardsolvetask );
RETURN_IF_ERROR( tree.dependencyClean() );
tree.traverseDown( treeviewtask );
tree.traverseLeafs( forwardpermutetask );
tree.traverseUp( ulvforwardsolvetask );
tree.traverseDown( ulvbackwardsolvetask );
if ( USE_RUNTIME ) hmlp_run();

/** clean up all dependencies on tree nodes */
tree.DependencyCleanUp();
tree.TraverseLeafs( inversepermutetask );
RETURN_IF_ERROR( tree.dependencyClean() );
tree.traverseLeafs( inversepermutetask );
if ( USE_RUNTIME ) hmlp_run();
}
else
{
/** clean up all dependencies on tree nodes */
tree.DependencyCleanUp();
tree.TraverseDown( treeviewtask );
tree.TraverseLeafs( forwardpermutetask );
tree.TraverseUp( solvetask1 );
RETURN_IF_ERROR( tree.dependencyClean() );
tree.traverseDown( treeviewtask );
tree.traverseLeafs( forwardpermutetask );
tree.traverseUp( solvetask1 );
if ( USE_RUNTIME ) hmlp_run();
/** clean up all dependencies on tree nodes */
tree.DependencyCleanUp();
tree.TraverseLeafs( inversepermutetask );
RETURN_IF_ERROR( tree.dependencyClean() );
tree.traverseLeafs( inversepermutetask );
if ( USE_RUNTIME ) hmlp_run();
}

Expand Down Expand Up @@ -1859,7 +1859,7 @@ hmlpError_t Factorize( TREE &tree, T lambda )
using NODE = typename TREE::NODE;

/** Clean up all dependencies on tree nodes. */
tree.DependencyCleanUp();
RETURN_IF_ERROR( tree.dependencyClean() );

/** Regularization parameter lambda. */
tree.setup.lambda = lambda;
Expand All @@ -1869,12 +1869,12 @@ hmlpError_t Factorize( TREE &tree, T lambda )

/** Setup */
SetupFactorTask<NODE, T> setupfactortask;
tree.TraverseUp( setupfactortask );
tree.traverseUp( setupfactortask );
tree.ExecuteAllTasks();

/** Factorization */
FactorizeTask<NODE, T> factorizetask;
tree.TraverseUp( factorizetask );
tree.traverseUp( factorizetask );
tree.ExecuteAllTasks();

return HMLP_ERROR_SUCCESS;
Expand Down
8 changes: 5 additions & 3 deletions gofmm/igofmm_mpi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ class DistULVBackwardSolveTask : public Task

/** @biref Top-level factorization routine. */
template<typename T, typename TREE>
void DistFactorize( TREE &tree, T lambda )
hmlpError_t DistFactorize( TREE &tree, T lambda )
{
using NODE = typename TREE::NODE;
using MPINODE = typename TREE::MPINODE;
Expand All @@ -367,7 +367,7 @@ void DistFactorize( TREE &tree, T lambda )
DistSetupFactorTask<MPINODE, T> parSETUPFACTORtask;

mpi::PrintProgress( "[BEG] DistFactorize setup ...\n", tree.GetComm() );
tree.DependencyCleanUp();
RETURN_IF_ERROR( tree.dependencyClean() );
tree.LocaTraverseUp( seqSETUPFACTORtask );
tree.DistTraverseUp( parSETUPFACTORtask );
tree.ExecuteAllTasks();
Expand All @@ -381,7 +381,9 @@ void DistFactorize( TREE &tree, T lambda )
tree.ExecuteAllTasks();
mpi::PrintProgress( "[END] DistFactorize ...\n", tree.GetComm() );

}; /** end DistFactorize() */
/* Return with no error. */
return HMLP_ERROR_SUCCESS;
}; /* end DistFactorize() */


template<typename T, typename TREE>
Expand Down
Loading

0 comments on commit f95c22b

Please sign in to comment.