Commit 4f7ac2f6 authored by Kenneth Leiter's avatar Kenneth Leiter

BUG: Fix off by one error when partitioning graph on one processor.

For some reason metis gets this wrong - when "partitioning" graph onto one
processor metis returns all ones instead of zeros despite having the correct
METIS_OPTION_NUMBERING. We now check explicitly for the case of partitioning
on one processor and handle it ourselves instead of relying on metis.
parent f1f7237c
......@@ -134,11 +134,28 @@ XdmfPartitioner::partition(const shared_ptr<XdmfGraph> graphToPartition,
XdmfError::message(XdmfError::FATAL,
"Current graph's row pointer or column index is null "
"in XdmfPartitioner::partition");
graphToPartition->removeAttribute("Partition");
shared_ptr<XdmfAttribute> attribute = XdmfAttribute::New();
attribute->setName("Partition");
attribute->setCenter(XdmfAttributeCenter::Node());
attribute->setType(XdmfAttributeType::Scalar());
graphToPartition->insert(attribute);
idx_t numberVertices = graphToPartition->getNumberNodes();
// Handle case where we partition onto 1 processor. Metis for some reason
// handles this incorrectly (indices are 1 instead of zero even though
// correct numbering option is supplied to metis)
if(numberOfPartitions == 1) {
attribute->resize<idx_t>(numberVertices, 0);
return;
}
shared_ptr<XdmfArray> rowPointer = graphToPartition->getRowPointer();
shared_ptr<XdmfArray> columnIndex = graphToPartition->getColumnIndex();
idx_t numberVertices = graphToPartition->getNumberNodes();
idx_t numberConstraints = 1;
bool releaseRowPointer = false;
......@@ -239,16 +256,9 @@ XdmfPartitioner::partition(const shared_ptr<XdmfGraph> graphToPartition,
delete [] xadj;
delete [] adjncy;
graphToPartition->removeAttribute("Partition");
shared_ptr<XdmfAttribute> attribute = XdmfAttribute::New();
attribute->setName("Partition");
attribute->setCenter(XdmfAttributeCenter::Node());
attribute->setType(XdmfAttributeType::Scalar());
attribute->insert(0,
part,
numberVertices);
graphToPartition->insert(attribute);
delete [] part;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment