Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graph: Deterministic coloring #249

Merged
merged 13 commits into from
Jul 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
.cproject
.project
*.o
TAGS
20 changes: 19 additions & 1 deletion perf_test/graph/KokkosGraph_color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ int parse_inputs (KokkosKernels::Experiment::Parameters &params, int argc, char
else if ( 0 == strcasecmp( argv[i] , "COLORING_EB" ) ) {
params.algorithm = 6;
}
else if ( 0 == strcasecmp( argv[i] , "COLORING_VBD" ) ) {
params.algorithm = 7;
}
else if ( 0 == strcasecmp( argv[i] , "COLORING_VBDBIT" ) ) {
params.algorithm = 8;
}
else {
std::cerr << "2-Unrecognized command line argument #" << i << ": " << argv[i] << std::endl ;
print_options();
Expand Down Expand Up @@ -181,6 +187,8 @@ void run_experiment(
kh.set_verbose(true);
}

std::cout << "algorithm: " << algorithm << std::endl;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assume this is temporary.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind previous comment, this is in testing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added guards and now you need to request these outputs explicitly, it might actually make sense to have some special debugging flag to get that level of output details?


for (int i = 0; i < repeat; ++i){

switch (algorithm){
Expand All @@ -206,13 +214,23 @@ void run_experiment(
case 6:
kh.create_graph_coloring_handle(COLORING_EB);
break;

case 7:
kh.create_graph_coloring_handle(COLORING_VBD);
break;

case 8:
kh.create_graph_coloring_handle(COLORING_VBDBIT);
break;

default:
kh.create_graph_coloring_handle(COLORING_DEFAULT);

}

graph_color_symbolic(&kh,crsGraph.numRows(), crsGraph.numCols(), crsGraph.row_map, crsGraph.entries);

std::cout <<
std::cout << std::endl <<
"Time:" << kh.get_graph_coloring_handle()->get_overall_coloring_time() << " "
"Num colors:" << kh.get_graph_coloring_handle()->get_num_colors() << " "
"Num Phases:" << kh.get_graph_coloring_handle()->get_num_phases() << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion src/blas/KokkosBlas1_dot.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ dot (const XVector& x, const YVector& y)
Kokkos::HostSpace,
Kokkos::MemoryTraits<Kokkos::Unmanaged> > RVector_Internal;

typename XVector::non_const_value_type result;
typename XVector::non_const_value_type result = 0;
RVector_Internal R = RVector_Internal(&result);
XVector_Internal X = x;
YVector_Internal Y = y;
Expand Down
2 changes: 1 addition & 1 deletion src/blas/impl/KokkosBlas1_team_dot_spec.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ struct TeamDot<TeamType, XV, YV, false> {
typedef typename IPT::dot_type dot_type;

static KOKKOS_INLINE_FUNCTION dot_type team_dot (const TeamType& team, const XV& X, const YV& Y) {
dot_type result;
dot_type result = 0.0; //Kokkos::Details::ArithTraits<dot_type>zero();
int N = X.extent(0);
Kokkos::parallel_reduce(Kokkos::TeamThreadRange(team,N), [&] (const int& i, dot_type& val) {
val += IPT::dot(X(i),Y(i));// X(i) * Y(i)
Expand Down
2 changes: 1 addition & 1 deletion src/blas/impl/KokkosBlas1_team_nrm2_spec.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ struct TeamNrm2<TeamType, XV, false> {
typedef Kokkos::Details::ArithTraits<typename IPT::mag_type> AT;

static KOKKOS_INLINE_FUNCTION mag_type team_nrm2 (const TeamType& team, const XV& X) {
mag_type result;
mag_type result = 0.0; //Kokkos::Details::ArithTraits<mag_type>zero();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a TBD later for using ArithTraits ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had issues compiling the code when result is not initialized, I attempted using the ArithTraits as it seemed to be the cleanest option but the compiler complained about it so I left it as a comment in order to look at it again later.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, Thanks ! Just a TBD that needs clean up in the next round.

int N = X.extent(0);
Kokkos::parallel_reduce(Kokkos::TeamThreadRange(team,N), [&] (const int& i, mag_type& val) {
const typename IPT::mag_type tmp = IPT::norm (X(i));
Expand Down
18 changes: 11 additions & 7 deletions src/graph/KokkosGraph_GraphColorHandle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,13 @@
namespace KokkosGraph {

enum ColoringAlgorithm { COLORING_DEFAULT,
COLORING_SERIAL,
COLORING_VB,
COLORING_VBBIT,
COLORING_VBCS,
COLORING_EB,
COLORING_SERIAL, // Serial Greedy Coloring
COLORING_VB, // Vertex Based Coloring
COLORING_VBBIT, // Vertex Based Coloring with bit array
COLORING_VBCS, // Vertex Based Color Set
COLORING_VBD, // Vertex Based Deterministic Coloring
COLORING_VBDBIT, // Vertex Based Deterministic Coloring with bit array
COLORING_EB, // Edge Based Coloring
COLORING_SERIAL2,
COLORING_SPGEMM,
COLORING_D2_MATRIX_SQUARED, // Distance-2 Graph Coloring (Brian's Code)
Expand All @@ -66,7 +68,7 @@ enum ConflictList{COLORING_NOCONFLICT, COLORING_ATOMIC, COLORING_PPS};

enum ColoringType {Distance1, Distance2};

template <class size_type_, class color_t_, class lno_t_,
template <class size_type_, class color_t_, class lno_t_,
//class lno_row_view_t_, class nonconst_color_view_t_, class lno_nnz_view_t_,
class ExecutionSpace, class TemporaryMemorySpace, class PersistentMemorySpace>
class GraphColoringHandle
Expand Down Expand Up @@ -113,7 +115,7 @@ class GraphColoringHandle

ColoringType GraphColoringType;
//Parameters
ColoringAlgorithm coloring_algorithm_type; //VB, VBBIT or EB.
ColoringAlgorithm coloring_algorithm_type; //VB, VBBIT, VBCS, VBD or EB.
ConflictList conflict_list_type; // whether to use a conflict list or not, and
// if using it wheter to create it with atomic or parallel prefix sum.

Expand Down Expand Up @@ -593,6 +595,8 @@ class GraphColoringHandle
case COLORING_VB:
case COLORING_VBBIT:
case COLORING_VBCS:
case COLORING_VBD:
case COLORING_VBDBIT:
case COLORING_SERIAL:
case COLORING_SERIAL2:
case COLORING_SPGEMM:
Expand Down
10 changes: 7 additions & 3 deletions src/graph/KokkosGraph_graph_color.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ void graph_color_symbolic(
<typename KernelHandle::GraphColoringHandleType, lno_row_view_t_, lno_nnz_view_t_> BaseGraphColoring;
BaseGraphColoring *gc = NULL;


switch (algorithm){
case COLORING_SERIAL:
gc = new BaseGraphColoring(num_rows, entries.extent(0), row_map, entries, gch);
Expand All @@ -98,11 +97,17 @@ void graph_color_symbolic(
gc = new VBGraphColoring(num_rows, entries.extent(0), row_map, entries, gch);
break;

case COLORING_VBD:
case COLORING_VBDBIT:
typedef typename Impl::GraphColor_VBD <typename KernelHandle::GraphColoringHandleType, lno_row_view_t_, lno_nnz_view_t_> VBDGraphColoring;
gc = new VBDGraphColoring(num_rows, entries.dimension_0(), row_map, entries, gch);
break;

case COLORING_EB:
typedef typename Impl::GraphColor_EB <typename KernelHandle::GraphColoringHandleType, lno_row_view_t_, lno_nnz_view_t_> EBGraphColoring;
gc = new EBGraphColoring(num_rows, entries.extent(0),row_map, entries, gch);
break;

case COLORING_SPGEMM:
case COLORING_D2_MATRIX_SQUARED:
//std::cout << ">>> WCMCLEN graph_color_symbolic (KokkosGraph_graph_color.hpp) [ COLORING_SPGEMM / COLORING_D2_MATRIX_SQUARED ]" << std::endl;
Expand Down Expand Up @@ -153,7 +158,6 @@ void graph_color(
lno_nnz_view_t_ entries,
bool is_symmetric = true)
{
//std::cout << ">>> WCMCLEN graph_color (KokkosGraph_graph_color.hpp)" << std::endl;
graph_color_symbolic(handle, num_rows, num_cols, row_map, entries, is_symmetric);
}

Expand Down
Loading