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

Zoltan2: small coloring cleanup #9268

Merged
merged 1 commit into from
Aug 23, 2021
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
12 changes: 8 additions & 4 deletions packages/zoltan2/test/core/color/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
TRIBITS_ADD_EXECUTABLE(
Coloring1
SOURCES coloring1.cpp
)

IF (${PROJECT_NAME}_ENABLE_Galeri)
TRIBITS_ADD_EXECUTABLE_AND_TEST(
TRIBITS_ADD_TEST(
Coloring1
SOURCES coloring1.cpp
NAME Coloring1_galeri
NUM_MPI_PROCS 4
COMM serial mpi
PASS_REGULAR_EXPRESSION "PASS"
FAIL_REGULAR_EXPRESSION "FAIL"
)
ENDIF()

TRIBITS_ADD_TEST(
Coloring1
Expand Down Expand Up @@ -124,9 +129,9 @@ TRIBITS_ADD_TEST(
PASS_REGULAR_EXPRESSION "PASS"
FAIL_REGULAR_EXPRESSION "FAIL"
)

ENDIF()


TRIBITS_ADD_TEST(
Coloring1
NAME Coloring1_noedges_D1
Expand Down Expand Up @@ -501,7 +506,6 @@ TRIBITS_ADD_TEST(
PASS_REGULAR_EXPRESSION "PASS"
FAIL_REGULAR_EXPRESSION "FAIL"
)
ENDIF()


# Command that copies files to the executable directory.
Expand Down
20 changes: 14 additions & 6 deletions packages/zoltan2/test/core/color/coloring1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ typedef Zoltan2::XpetraCrsMatrixAdapter<SparseMatrix> SparseMatrixAdapter;
int validateColoring(RCP<SparseMatrix> A, int *color)
// returns 0 if coloring is valid, nonzero if invalid
{
if (A->getRowMap()->getComm()->getRank() == 0)
std::cout << "validate coloring: local graph, distance-one" << std::endl;
int nconflicts = 0;
Teuchos::ArrayView<const zlno_t> indices;
Teuchos::ArrayView<const zscalar_t> values; // Not used
Expand All @@ -108,6 +110,8 @@ int validateColoring(RCP<SparseMatrix> A, int *color)
}

int validateDistributedColoring(RCP<SparseMatrix> A, int *color){
if (A->getRowMap()->getComm()->getRank() == 0)
std::cout << "validate coloring: distributed, distance-one" << std::endl;
int nconflicts = 0;
RCP<const SparseMatrix::map_type> rowMap = A->getRowMap();
RCP<const SparseMatrix::map_type> colMap = A->getColMap();
Expand Down Expand Up @@ -143,6 +147,8 @@ int validateDistributedColoring(RCP<SparseMatrix> A, int *color){

int validateDistributedDistance2Coloring(RCP<SparseMatrix> A, int* color){

if (A->getRowMap()->getComm()->getRank() == 0)
std::cout << "validate coloring: distributed, distance-two" << std::endl;

//To check distance-2 conflicts, we square the input matrix and check
//for distance-1 conflicts on the squared matrix.
Expand Down Expand Up @@ -215,7 +221,7 @@ int main(int narg, char** arg)
// Read run-time options.
Teuchos::CommandLineProcessor cmdp (false, false);
cmdp.setOption("colorMethod", &colorAlg,
"Coloring algorithms supported: SerialGreedy, Hybrid, 2GL, D2");
"Coloring algorithms supported: SerialGreedy, D1, D1-2GL, D2, PD2");
cmdp.setOption("inputFile", &inputFile,
"Name of a Matrix Market file in the data directory; "
"if not specified, a matrix will be generated by Galeri.");
Expand Down Expand Up @@ -347,6 +353,7 @@ int main(int narg, char** arg)
params.set("timing", timing);
params.set("serial_threshold",serialThreshold);
params.set("recolor_degrees",recolorDegrees);

//params.set("balance_colors", balanceColors); // TODO

////// Create an input adapter for the Tpetra matrix.
Expand All @@ -356,7 +363,7 @@ int main(int narg, char** arg)
try
{
Zoltan2::ColoringProblem<SparseMatrixAdapter> problem(&adapter, &params);
std::cout << "Going to color" << std::endl;
std::cout << "Going to color " << colorAlg << std::endl;
problem.solve();

////// Basic metric checking of the coloring solution
Expand Down Expand Up @@ -425,9 +432,10 @@ int main(int narg, char** arg)
if(hasDiagonal) {
if(Matrix->replaceGlobalValues(rowInds[i],idx,val) == Teuchos::OrdinalTraits<zlno_t>::invalid()){
std::cout<<"Either !isFillActive() or inds.extent != vals.extent()\n";
} else {
std::cout<<"*******DIAGONAL REPLACED*********\n";
}
}
//else {
// std::cout<<"*******DIAGONAL REPLACED*********\n";
//}
}
}
Matrix->fillComplete();
Expand All @@ -437,7 +445,7 @@ int main(int narg, char** arg)
testReturn += validateDistributedDistance2Coloring(Matrix, checkColoring);
} else if (colorAlg == "PD2"){
testReturn = validateDistributedDistance2Coloring(Matrix, checkColoring);
}else if(colorAlg == "2GL" || colorAlg == "Hybrid"){
}else if(colorAlg == "D1-2GL" || colorAlg == "D1"){
testReturn = validateDistributedColoring(Matrix, checkColoring);
} else if (checkLength > 0){
testReturn = validateColoring(Matrix, checkColoring);
Expand Down