"...sampling/git@developer.sourcefind.cn:OpenDAS/dgl.git" did not exist on "f8594230018647d4ff0532923ba098ce56571779"
Unverified Commit 62077ef3 authored by Da Zheng's avatar Da Zheng Committed by GitHub
Browse files

[Distributed] update Metis (#1856)



* fix bugs.

* improve.

* more updates.

* remove print.

* change the heterograph version.

* fix.
Co-authored-by: default avatarUbuntu <ubuntu@ip-172-31-19-1.us-west-2.compute.internal>
Co-authored-by: default avatarUbuntu <ubuntu@ip-172-31-30-164.us-west-2.compute.internal>
parent b885c82f
...@@ -202,7 +202,14 @@ def metis_partition_assignment(g, k, balance_ntypes=None, balance_edges=False): ...@@ -202,7 +202,14 @@ def metis_partition_assignment(g, k, balance_ntypes=None, balance_edges=False):
# When balancing edges in partitions, we use in-degree as one of the weights. # When balancing edges in partitions, we use in-degree as one of the weights.
if balance_edges: if balance_edges:
vwgt.append(F.astype(g.in_degrees(), F.int64)) if balance_ntypes is None:
vwgt.append(F.astype(g.in_degrees(), F.int64))
else:
for ntype in uniq_ntypes:
nids = F.asnumpy(F.nonzero_1d(balance_ntypes == ntype))
degs = np.zeros((g.number_of_nodes(),), np.int64)
degs[nids] = F.asnumpy(g.in_degrees(nids))
vwgt.append(F.tensor(degs))
# The vertex weights have to be stored in a vector. # The vertex weights have to be stored in a vector.
if len(vwgt) > 0: if len(vwgt) > 0:
......
...@@ -1071,7 +1071,14 @@ def metis_partition_assignment(g, k, balance_ntypes=None, balance_edges=False): ...@@ -1071,7 +1071,14 @@ def metis_partition_assignment(g, k, balance_ntypes=None, balance_edges=False):
# When balancing edges in partitions, we use in-degree as one of the weights. # When balancing edges in partitions, we use in-degree as one of the weights.
if balance_edges: if balance_edges:
vwgt.append(F.astype(g.in_degrees(), F.int64)) if balance_ntypes is None:
vwgt.append(F.astype(g.in_degrees(), F.int64))
else:
for ntype in uniq_ntypes:
nids = F.asnumpy(F.nonzero_1d(balance_ntypes == ntype))
degs = np.zeros((g.number_of_nodes(),), np.int64)
degs[nids] = F.asnumpy(g.in_degrees(nids))
vwgt.append(F.tensor(degs))
# The vertex weights have to be stored in a vector. # The vertex weights have to be stored in a vector.
if len(vwgt) > 0: if len(vwgt) > 0:
......
...@@ -41,6 +41,10 @@ IdArray GraphOp::MetisPartition(GraphPtr g, int k, NDArray vwgt_arr) { ...@@ -41,6 +41,10 @@ IdArray GraphOp::MetisPartition(GraphPtr g, int k, NDArray vwgt_arr) {
vwgt = static_cast<idx_t*>(vwgt_arr->data); vwgt = static_cast<idx_t*>(vwgt_arr->data);
} }
idx_t options[METIS_NOPTIONS];
METIS_SetDefaultOptions(options);
options[METIS_OPTION_ONDISK] = 1;
int ret = METIS_PartGraphKway(&nvtxs, // The number of vertices int ret = METIS_PartGraphKway(&nvtxs, // The number of vertices
&ncon, // The number of balancing constraints. &ncon, // The number of balancing constraints.
xadj, // indptr xadj, // indptr
...@@ -52,7 +56,7 @@ IdArray GraphOp::MetisPartition(GraphPtr g, int k, NDArray vwgt_arr) { ...@@ -52,7 +56,7 @@ IdArray GraphOp::MetisPartition(GraphPtr g, int k, NDArray vwgt_arr) {
&nparts, // The number of partitions. &nparts, // The number of partitions.
NULL, // the desired weight for each partition and constraint NULL, // the desired weight for each partition and constraint
NULL, // the allowed load imbalance tolerance NULL, // the allowed load imbalance tolerance
NULL, // the array of options options, // the array of options
&objval, // the edge-cut or the total communication volume of &objval, // the edge-cut or the total communication volume of
// the partitioning solution // the partitioning solution
part); part);
......
...@@ -45,6 +45,10 @@ IdArray MetisPartition(UnitGraphPtr g, int k, NDArray vwgt_arr) { ...@@ -45,6 +45,10 @@ IdArray MetisPartition(UnitGraphPtr g, int k, NDArray vwgt_arr) {
vwgt = static_cast<idx_t *>(vwgt_arr->data); vwgt = static_cast<idx_t *>(vwgt_arr->data);
} }
idx_t options[METIS_NOPTIONS];
METIS_SetDefaultOptions(options);
options[METIS_OPTION_ONDISK] = 1;
int ret = METIS_PartGraphKway( int ret = METIS_PartGraphKway(
&nvtxs, // The number of vertices &nvtxs, // The number of vertices
&ncon, // The number of balancing constraints. &ncon, // The number of balancing constraints.
...@@ -57,7 +61,7 @@ IdArray MetisPartition(UnitGraphPtr g, int k, NDArray vwgt_arr) { ...@@ -57,7 +61,7 @@ IdArray MetisPartition(UnitGraphPtr g, int k, NDArray vwgt_arr) {
&nparts, // The number of partitions. &nparts, // The number of partitions.
NULL, // the desired weight for each partition and constraint NULL, // the desired weight for each partition and constraint
NULL, // the allowed load imbalance tolerance NULL, // the allowed load imbalance tolerance
NULL, // the array of options options, // the array of options
&objval, // the edge-cut or the total communication volume of &objval, // the edge-cut or the total communication volume of
// the partitioning solution // the partitioning solution
part); 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